@@ -235,7 +235,9 @@ export interface ChangeCurrentDetail {
235235 *
236236 * Additional attributes:
237237 * - data-layout: If this is set to 'small', flags for current and cursor
238- * positions will be smaller.
238+ * positions will be smaller.
239+ * - compact: If this is set, the data-row-height is interpreted as the total
240+ * height instead of the height of a single dimension.
239241 */
240242export class MultiDimNav extends NanoElement {
241243 // Element that creates all space necessary for items. Flags and slotted
@@ -319,7 +321,7 @@ export class MultiDimNav extends NanoElement {
319321 }
320322
321323 static get observedAttributes ( ) {
322- return [ 'data-sizes' , 'data-layout' ] ;
324+ return [ 'data-sizes' , 'data-layout' , 'compact' ] ;
323325 }
324326
325327 get numDims ( ) {
@@ -331,7 +333,11 @@ export class MultiDimNav extends NanoElement {
331333 }
332334
333335 get rowHeight ( ) {
334- return Number ( this . dataset [ 'rowHeight' ] ?? 30 ) ;
336+ const rowHeight = Number ( this . dataset [ 'rowHeight' ] ?? 30 ) ;
337+ if ( this . hasAttribute ( 'compact' ) ) {
338+ return rowHeight / ( this . node . depth + 1 ) ;
339+ }
340+ return rowHeight ;
335341 }
336342
337343 /**
@@ -365,6 +371,7 @@ export class MultiDimNav extends NanoElement {
365371 ) ;
366372 this . currentFlag = html . tag ( 'kd-multi-index-flag' , flagClasses ) ;
367373 this . cursorFlag = html . tag ( 'kd-multi-index-flag' , flagClasses ) ;
374+ this . syncCompact ( ) ;
368375
369376 this . currentFlag . setAttribute ( 'current' , '' ) ;
370377 this . cursorFlag . setAttribute ( 'cursor' , '' ) ;
@@ -423,6 +430,17 @@ export class MultiDimNav extends NanoElement {
423430 this . render ( ) ;
424431 }
425432
433+ private syncCompact ( ) {
434+ const compact = this . hasAttribute ( 'compact' ) ;
435+ if ( compact ) {
436+ this . currentFlag ?. setAttribute ( 'compact' , '' ) ;
437+ this . cursorFlag ?. setAttribute ( 'compact' , '' ) ;
438+ } else {
439+ this . currentFlag ?. removeAttribute ( 'compact' ) ;
440+ this . cursorFlag ?. removeAttribute ( 'compact' ) ;
441+ }
442+ }
443+
426444 private repositionSlottedElement ( target : HTMLElement ) {
427445 target . style . setProperty ( 'top' , '0' ) ;
428446 const begin = Number ( target . dataset [ 'begin' ] ) || 0 ;
@@ -492,6 +510,8 @@ export class MultiDimNav extends NanoElement {
492510 0 ,
493511 ) ;
494512 super . attributeChangedCallback ( name , oldValue , newValue ) ;
513+ } else if ( name === 'compact' ) {
514+ this . syncCompact ( ) ;
495515 }
496516 }
497517
0 commit comments