frontile 0.18.0-beta.0 → 0.18.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/components/collections/simple-table/body.d.ts +4 -4
- package/declarations/components/collections/simple-table/cell.d.ts +4 -4
- package/declarations/components/collections/simple-table/column.d.ts +4 -4
- package/declarations/components/collections/simple-table/footer.d.ts +4 -4
- package/declarations/components/collections/simple-table/header.d.ts +4 -4
- package/declarations/components/collections/simple-table/index.d.ts +16 -4
- package/declarations/components/collections/simple-table/row.d.ts +4 -4
- package/declarations/components/collections/table/column-visibility.d.ts +4 -4
- package/declarations/components/collections/table/sort-button.d.ts +4 -4
- package/declarations/components/collections/table/table.d.ts +5 -4
- package/declarations/components/forms/select/trigger.d.ts +5 -3
- package/declarations/components/navigation/pagination/pagination.d.ts +3 -2
- package/declarations/test-support.d.ts +22 -0
- package/declarations/utils/selection-indicator.d.ts +4 -0
- package/dist/components/buttons/button-group.js +1 -1
- package/dist/components/buttons/button-group.js.map +1 -1
- package/dist/components/buttons/button.js +2 -2
- package/dist/components/buttons/button.js.map +1 -1
- package/dist/components/buttons/chip.js +1 -1
- package/dist/components/buttons/chip.js.map +1 -1
- package/dist/components/buttons/close-button.js +1 -1
- package/dist/components/buttons/close-button.js.map +1 -1
- package/dist/components/buttons/segmented-control/item.js +1 -1
- package/dist/components/buttons/segmented-control/item.js.map +1 -1
- package/dist/components/buttons/segmented-control/segmented-control.js +1 -1
- package/dist/components/buttons/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/buttons/toggle-button.js +1 -1
- package/dist/components/buttons/toggle-button.js.map +1 -1
- package/dist/components/collections/calendar/calendar.js +8 -4
- package/dist/components/collections/calendar/calendar.js.map +1 -1
- package/dist/components/collections/calendar/day-cell.js +1 -1
- package/dist/components/collections/calendar/day-cell.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/header.js.map +1 -1
- package/dist/components/collections/calendar/month-grid.js +1 -1
- package/dist/components/collections/calendar/month-grid.js.map +1 -1
- package/dist/components/collections/calendar/year-grid.js +15 -3
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/command/command.js +1 -1
- package/dist/components/collections/command/command.js.map +1 -1
- package/dist/components/collections/command/dialog.js +1 -1
- package/dist/components/collections/command/dialog.js.map +1 -1
- package/dist/components/collections/command/footer.js +3 -3
- package/dist/components/collections/command/footer.js.map +1 -1
- package/dist/components/collections/command/input.js +1 -1
- package/dist/components/collections/command/input.js.map +1 -1
- package/dist/components/collections/command/list.js +1 -1
- package/dist/components/collections/command/list.js.map +1 -1
- package/dist/components/collections/listbox/group.js +1 -1
- package/dist/components/collections/listbox/group.js.map +1 -1
- package/dist/components/collections/listbox/item.js +1 -1
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/listbox/listbox.js +1 -1
- package/dist/components/collections/listbox/listbox.js.map +1 -1
- package/dist/components/collections/simple-table/body.js +1 -1
- package/dist/components/collections/simple-table/body.js.map +1 -1
- package/dist/components/collections/simple-table/cell.js +1 -1
- package/dist/components/collections/simple-table/cell.js.map +1 -1
- package/dist/components/collections/simple-table/column.js +1 -1
- package/dist/components/collections/simple-table/column.js.map +1 -1
- package/dist/components/collections/simple-table/footer.js +1 -1
- package/dist/components/collections/simple-table/footer.js.map +1 -1
- package/dist/components/collections/simple-table/header.js +1 -1
- package/dist/components/collections/simple-table/header.js.map +1 -1
- package/dist/components/collections/simple-table/index.js +5 -3
- package/dist/components/collections/simple-table/index.js.map +1 -1
- package/dist/components/collections/simple-table/row.js +1 -1
- package/dist/components/collections/simple-table/row.js.map +1 -1
- package/dist/components/collections/table/checkbox.js +1 -1
- package/dist/components/collections/table/checkbox.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/column-visibility.js.map +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/collections/table/sort-button.js.map +1 -1
- package/dist/components/collections/table/table.js +7 -3
- package/dist/components/collections/table/table.js.map +1 -1
- package/dist/components/disclosure/accordion/accordion.js +3 -2
- package/dist/components/disclosure/accordion/accordion.js.map +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/disclosure/accordion/item.js.map +1 -1
- package/dist/components/forms/autocomplete.js +1 -1
- package/dist/components/forms/autocomplete.js.map +1 -1
- package/dist/components/forms/checkbox-group.js +1 -1
- package/dist/components/forms/checkbox-group.js.map +1 -1
- package/dist/components/forms/checkbox.js +1 -1
- package/dist/components/forms/checkbox.js.map +1 -1
- package/dist/components/forms/form-control.js +1 -1
- package/dist/components/forms/form-control.js.map +1 -1
- package/dist/components/forms/form-description.js +1 -1
- package/dist/components/forms/form-description.js.map +1 -1
- package/dist/components/forms/form-feedback.js +1 -1
- package/dist/components/forms/form-feedback.js.map +1 -1
- package/dist/components/forms/input-otp.js +1 -1
- package/dist/components/forms/input-otp.js.map +1 -1
- package/dist/components/forms/input.js +1 -1
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/label.js +1 -1
- package/dist/components/forms/label.js.map +1 -1
- package/dist/components/forms/native-select.js +2 -2
- package/dist/components/forms/native-select.js.map +1 -1
- package/dist/components/forms/radio-group.js +1 -1
- package/dist/components/forms/radio-group.js.map +1 -1
- package/dist/components/forms/radio.js +1 -1
- package/dist/components/forms/radio.js.map +1 -1
- package/dist/components/forms/select/end-content.js +1 -1
- package/dist/components/forms/select/end-content.js.map +1 -1
- package/dist/components/forms/select/select.js +1 -1
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/forms/select/selected-items.js +1 -1
- package/dist/components/forms/select/selected-items.js.map +1 -1
- package/dist/components/forms/select/trigger.js +6 -4
- package/dist/components/forms/select/trigger.js.map +1 -1
- package/dist/components/forms/switch.js +1 -1
- package/dist/components/forms/switch.js.map +1 -1
- package/dist/components/forms/textarea.js +1 -1
- package/dist/components/forms/textarea.js.map +1 -1
- package/dist/components/navigation/external-link.js +2 -2
- package/dist/components/navigation/external-link.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +1 -1
- package/dist/components/navigation/pagination/pagination.js.map +1 -1
- package/dist/components/navigation/tab-nav/item.js +1 -1
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/navigation/tab-nav/tab-nav.js +1 -1
- package/dist/components/navigation/tab-nav/tab-nav.js.map +1 -1
- package/dist/components/navigation/tabs/panel.js +1 -1
- package/dist/components/navigation/tabs/panel.js.map +1 -1
- package/dist/components/navigation/tabs/tab.js +1 -1
- package/dist/components/navigation/tabs/tab.js.map +1 -1
- package/dist/components/navigation/tabs/tabs.js +2 -2
- package/dist/components/navigation/tabs/tabs.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/notifications/notification-card.js +1 -1
- package/dist/components/notifications/notifications-container.js +2 -2
- package/dist/components/notifications/notifications-container.js.map +1 -1
- package/dist/components/overlays/drawer/body.js +1 -1
- package/dist/components/overlays/drawer/body.js.map +1 -1
- package/dist/components/overlays/drawer/drag-handle.js +1 -1
- package/dist/components/overlays/drawer/drag-handle.js.map +1 -1
- package/dist/components/overlays/drawer/footer.js +1 -1
- package/dist/components/overlays/drawer/footer.js.map +1 -1
- package/dist/components/overlays/drawer/header.js +4 -4
- package/dist/components/overlays/drawer/header.js.map +1 -1
- package/dist/components/overlays/drawer.js +1 -1
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/modal/body.js +1 -1
- package/dist/components/overlays/modal/body.js.map +1 -1
- package/dist/components/overlays/modal/footer.js +1 -1
- package/dist/components/overlays/modal/footer.js.map +1 -1
- package/dist/components/overlays/modal/header.js +1 -1
- package/dist/components/overlays/modal/header.js.map +1 -1
- package/dist/components/overlays/modal.js +1 -1
- package/dist/components/overlays/modal.js.map +1 -1
- package/dist/components/overlays/overlay.js +1 -1
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/overlays/tooltip.js +13 -1
- package/dist/components/overlays/tooltip.js.map +1 -1
- package/dist/components/status/alert.js +1 -1
- package/dist/components/status/alert.js.map +1 -1
- package/dist/components/status/progress-bar.js +1 -1
- package/dist/components/status/progress-bar.js.map +1 -1
- package/dist/components/utilities/avatar.js +1 -1
- package/dist/components/utilities/avatar.js.map +1 -1
- package/dist/components/utilities/divider.js +1 -1
- package/dist/components/utilities/divider.js.map +1 -1
- package/dist/components/utilities/kbd.js +1 -1
- package/dist/components/utilities/kbd.js.map +1 -1
- package/dist/components/utilities/skeleton.js +1 -1
- package/dist/components/utilities/skeleton.js.map +1 -1
- package/dist/components/utilities/spinner.js +1 -1
- package/dist/components/utilities/spinner.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{notification-card-D5fd-Sxa.js → notification-card-BHTra4Zh.js} +2 -2
- package/dist/{notification-card-D5fd-Sxa.js.map → notification-card-BHTra4Zh.js.map} +1 -1
- package/dist/notifications.js +1 -1
- package/dist/test-support.js +40 -2
- package/dist/test-support.js.map +1 -1
- package/dist/utils/selection-indicator.js +30 -2
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sources":["../../../../src/components/collections/command/list.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { hash } from '@ember/helper';\nimport { useStyles } from '@frontile/theme';\nimport { Listbox } from '../listbox/listbox';\nimport { Spinner } from '../../utilities/spinner';\nimport { Divider } from '../../utilities/divider';\nimport { keyAndLabelForItem, type ListItem } from '../../../utils/listManager';\nimport type { CommandGroup } from './command';\nimport type { ListboxItem } from '../listbox/item';\nimport type { CommandSlots, SlotsToClasses } from '@frontile/theme';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<typeof ListboxItem, 'manager'>;\n\ninterface RenderableGroup<T> extends CommandGroup<T> {\n /** Separator between sections; never after the last one. */\n withDivider: boolean;\n}\n\nexport interface CommandListSignature<T> {\n Args: {\n /** @internal bound by Command */\n groups?: CommandGroup<T>[];\n /** @internal bound by Command */\n id?: string;\n /** @internal bound by Command */\n isLoading?: boolean;\n /** @internal bound by Command */\n isSearchPrompt?: boolean;\n /** @internal bound by Command */\n inputElement?: HTMLInputElement;\n /** @internal bound by Command */\n onSelect?: (key: string) => void;\n /** @internal bound by Command */\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n\n disabledKeys?: string[];\n size?: 'sm' | 'md' | 'lg';\n classes?: SlotsToClasses<CommandSlots>;\n };\n Element: HTMLUListElement;\n Blocks: {\n item: [{ item: T; key: string; label: string; Item: ItemCompBounded }];\n empty: [];\n loading: [];\n /** Shown by an async palette before anything has been typed. */\n prompt: [];\n };\n}\n\n/**\n * Renders the ranked results.\n *\n * Sections come from the ranked data rather than from markup, so a group whose\n * items all filtered out is simply not rendered — heading, wrapper and\n * separator disappear together, with no visibility tracking or `forceMount`\n * escape hatch. Reordering is a keyed `{{#each}}` over a sorted array, which\n * Glimmer handles natively.\n */\nclass CommandList<T = unknown> extends Component<CommandListSignature<T>> {\n @cached\n get groups(): RenderableGroup<T>[] {\n const groups = this.args.groups ?? [];\n\n return groups.map((group, index) => ({\n ...group,\n withDivider: index < groups.length - 1\n }));\n }\n\n get isEmpty(): boolean {\n return this.groups.length === 0;\n }\n\n /** Loading only replaces the list while there is nothing to show yet. */\n get showLoading(): boolean {\n return Boolean(this.args.isLoading) && this.isEmpty;\n }\n\n get classNames() {\n const { command, listboxGroup } = useStyles();\n // No size fallback: the theme's `defaultVariants` owns the default.\n return {\n ...command({ size: this.args.size }),\n // Same spacing a Group gives its own separator, so the ungrouped run\n // does not drift from the grouped one.\n divider: listboxGroup().divider()\n };\n }\n\n <template>\n {{#if this.showLoading}}\n <div\n class={{this.classNames.loading class=@classes.loading}}\n data-
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../src/components/collections/command/list.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { hash } from '@ember/helper';\nimport { useStyles } from '@frontile/theme';\nimport { Listbox } from '../listbox/listbox';\nimport { Spinner } from '../../utilities/spinner';\nimport { Divider } from '../../utilities/divider';\nimport { keyAndLabelForItem, type ListItem } from '../../../utils/listManager';\nimport type { CommandGroup } from './command';\nimport type { ListboxItem } from '../listbox/item';\nimport type { CommandSlots, SlotsToClasses } from '@frontile/theme';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<typeof ListboxItem, 'manager'>;\n\ninterface RenderableGroup<T> extends CommandGroup<T> {\n /** Separator between sections; never after the last one. */\n withDivider: boolean;\n}\n\nexport interface CommandListSignature<T> {\n Args: {\n /** @internal bound by Command */\n groups?: CommandGroup<T>[];\n /** @internal bound by Command */\n id?: string;\n /** @internal bound by Command */\n isLoading?: boolean;\n /** @internal bound by Command */\n isSearchPrompt?: boolean;\n /** @internal bound by Command */\n inputElement?: HTMLInputElement;\n /** @internal bound by Command */\n onSelect?: (key: string) => void;\n /** @internal bound by Command */\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n\n disabledKeys?: string[];\n size?: 'sm' | 'md' | 'lg';\n classes?: SlotsToClasses<CommandSlots>;\n };\n Element: HTMLUListElement;\n Blocks: {\n item: [{ item: T; key: string; label: string; Item: ItemCompBounded }];\n empty: [];\n loading: [];\n /** Shown by an async palette before anything has been typed. */\n prompt: [];\n };\n}\n\n/**\n * Renders the ranked results.\n *\n * Sections come from the ranked data rather than from markup, so a group whose\n * items all filtered out is simply not rendered — heading, wrapper and\n * separator disappear together, with no visibility tracking or `forceMount`\n * escape hatch. Reordering is a keyed `{{#each}}` over a sorted array, which\n * Glimmer handles natively.\n */\nclass CommandList<T = unknown> extends Component<CommandListSignature<T>> {\n @cached\n get groups(): RenderableGroup<T>[] {\n const groups = this.args.groups ?? [];\n\n return groups.map((group, index) => ({\n ...group,\n withDivider: index < groups.length - 1\n }));\n }\n\n get isEmpty(): boolean {\n return this.groups.length === 0;\n }\n\n /** Loading only replaces the list while there is nothing to show yet. */\n get showLoading(): boolean {\n return Boolean(this.args.isLoading) && this.isEmpty;\n }\n\n get classNames() {\n const { command, listboxGroup } = useStyles();\n // No size fallback: the theme's `defaultVariants` owns the default.\n return {\n ...command({ size: this.args.size }),\n // Same spacing a Group gives its own separator, so the ungrouped run\n // does not drift from the grouped one.\n divider: listboxGroup().divider()\n };\n }\n\n <template>\n {{#if this.showLoading}}\n <div\n class={{this.classNames.loading class=@classes.loading}}\n data-part=\"loading\"\n >\n {{#if (has-block \"loading\")}}\n {{yield to=\"loading\"}}\n {{else}}\n <Spinner @size=\"sm\" />\n Searching…\n {{/if}}\n </div>\n {{else if @isSearchPrompt}}\n <div\n class={{this.classNames.empty class=@classes.empty}}\n data-part=\"empty\"\n >\n {{#if (has-block \"prompt\")}}\n {{yield to=\"prompt\"}}\n {{else}}\n Start typing to search.\n {{/if}}\n </div>\n {{else if this.isEmpty}}\n <div\n class={{this.classNames.empty class=@classes.empty}}\n data-part=\"empty\"\n role=\"status\"\n >\n {{#if (has-block \"empty\")}}\n {{yield to=\"empty\"}}\n {{else}}\n No results found.\n {{/if}}\n </div>\n {{else}}\n <Listbox\n id={{@id}}\n @selectionMode=\"none\"\n @type=\"listbox\"\n @isKeyboardEventsEnabled={{true}}\n @autoActivateMode=\"first\"\n @disabledKeys={{@disabledKeys}}\n {{! A palette row wants a quiet trailing shortcut, not a keycap. }}\n @shortcutAppearance=\"plain\"\n @onAction={{@onSelect}}\n @onActiveItemChange={{@onActiveItemChange}}\n @elementToAddKeyboardEvents={{@inputElement}}\n @class={{this.classNames.list class=@classes.list}}\n data-part=\"list\"\n ...attributes\n as |l|\n >\n {{#each this.groups key=\"@index\" as |group|}}\n {{#if group.title}}\n <l.Group\n @title={{group.title}}\n @withDivider={{group.withDivider}}\n as |g|\n >\n {{#each group.items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{yield\n (hash\n item=item\n key=keyLabel.key\n label=keyLabel.label\n Item=g.Item\n )\n to=\"item\"\n }}\n {{/let}}\n {{/each}}\n </l.Group>\n {{else}}\n {{#each group.items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{yield\n (hash\n item=item key=keyLabel.key label=keyLabel.label Item=l.Item\n )\n to=\"item\"\n }}\n {{/let}}\n {{/each}}\n {{! Ungrouped items render without a Group wrapper, so their\n separator has to come from here or it goes missing. }}\n {{#if group.withDivider}}\n <Divider @as=\"li\" @class={{this.classNames.divider}} />\n {{/if}}\n {{/if}}\n {{/each}}\n </Listbox>\n {{/if}}\n </template>\n}\n\nexport { CommandList };\nexport default CommandList;\n"],"names":["CommandList","Component","groups","args","map","group","index","withDivider","length","n","prototype","cached","isEmpty","showLoading","Boolean","isLoading","classNames","command","listboxGroup","useStyles","size","divider","setComponentTemplate","precompileTemplate","strictMode","scope","Spinner","Listbox","keyAndLabelForItem","hash","Divider"],"mappings":";;;;;;;;;;;;AAmDA;;;;;;;;AAQC;AACD,MAAMA,WAAA,SAAiCC,UAA+B;EACpE,IACIC,MAAAA,GAA+B;IACjC,MAAMA,SAAS,IAAI,CAACC,IAAI,CAACD,MAAM,IAAI,EAAE;IAErC,OAAOA,OAAOE,GAAG,CAAC,CAACC,KAAA,EAAOC,WAAW;AACnC,MAAA,GAAGD,KAAK;AACRE,MAAAA,WAAA,EAAaD,KAAA,GAAQJ,MAAA,CAAOM,MAAM,GAAG;AACvC,KAAC,CAAA,CAAA;AACH,EAAA;AAAA,EAAA;IAAAC,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CARCC,MAAA,CAAA,CAAA;AAAA;EAUD,IAAIC,OAAAA,GAAmB;AACrB,IAAA,OAAO,IAAI,CAACV,MAAM,CAACM,MAAM,KAAK,CAAA;AAChC,EAAA;AAEA;EACA,IAAIK,WAAAA,GAAuB;IACzB,OAAOC,OAAA,CAAQ,IAAI,CAACX,IAAI,CAACY,SAAS,CAAA,IAAK,IAAI,CAACH,OAAO;AACrD,EAAA;EAEA,IAAII,UAAAA,GAAa;IACf,MAAM;MAAEC,OAAO;AAAEC,MAAAA;KAAc,GAAGC,SAAA,EAAA;AAClC;IACA,OAAO;AACL,MAAA,GAAGF,OAAA,CAAQ;AAAEG,QAAAA,IAAA,EAAM,IAAI,CAACjB,IAAI,CAACiB;AAAK,OAAA,CAAE;AACpC;AACA;AACAC,MAAAA,OAAA,EAASH,eAAeG,OAAO;KACjC;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,otEAAA,EA+FA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,OAAA;QAAAC,OAAA;QAAAC,kBAAA;QAAAC,IAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -45,7 +45,7 @@ class ListboxGroup extends Component {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
static {
|
|
48
|
-
setComponentTemplate(precompileTemplate("<li role=\"group\" aria-labelledby={{if @title this.titleId}} data-
|
|
48
|
+
setComponentTemplate(precompileTemplate("<li role=\"group\" aria-labelledby={{if @title this.titleId}} data-component=\"listbox-group\" data-part=\"base\" class={{this.classNames.base}} ...attributes>\n {{#if @title}}\n <span id={{this.titleId}} data-part=\"title\" class={{this.classNames.title}}>{{@title}}</span>\n {{/if}}\n\n <ul role=\"none\" data-part=\"list\" class={{this.classNames.list}}>\n {{yield (hash Item=(component ListboxItem manager=@manager appearance=@appearance intent=@intent shortcutAppearance=@shortcutAppearance type=@type))}}\n </ul>\n</li>\n\n{{#if @withDivider}}\n <Divider @as=\"li\" @class={{this.classNames.divider}} data-part=\"divider\" />\n{{/if}}", {
|
|
49
49
|
strictMode: true,
|
|
50
50
|
scope: () => ({
|
|
51
51
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sources":["../../../../src/components/collections/listbox/group.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { guidFor } from '@ember/object/internals';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { ListboxItem } from './item';\nimport type { ListManager } from '../../../utils/listManager';\nimport type { ListboxItemSignature } from './item';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<\n typeof ListboxItem,\n 'manager' | 'type' | 'appearance' | 'intent' | 'shortcutAppearance'\n>;\n\nexport interface ListboxGroupSignature {\n Args: {\n manager: ListManager;\n\n /**\n * The heading rendered above the group's options. When omitted, the group\n * still groups its options but renders no heading — and carries no\n * `aria-labelledby`, since there would be nothing to point at.\n */\n title?: string;\n\n class?: string;\n classes?: {\n base?: string;\n title?: string;\n list?: string;\n };\n\n /**\n * Render a divider after the group. Groups in a palette are usually\n * separated visually; the divider is a sibling of the group rather than a\n * child so it does not sit inside the group's labelled region.\n */\n withDivider?: boolean;\n\n type?: ListboxItemSignature['Args']['type'];\n appearance?: ListboxItemSignature['Args']['appearance'];\n intent?: ListboxItemSignature['Args']['intent'];\n shortcutAppearance?: ListboxItemSignature['Args']['shortcutAppearance'];\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [{ Item: ItemCompBounded }];\n };\n}\n\n/**\n * A labelled section of options within a `Listbox`.\n *\n * The markup nests the options one level deeper than an ungrouped listbox, so\n * the intervening list is marked `role=\"none\"` to keep the\n * `listbox` -> `option` ownership chain intact.\n *\n * Grouping deliberately adds no concepts to `ListManager`: navigation order is\n * derived from the live DOM via `compareDocumentPosition`, so nesting options\n * inside a group leaves keyboard traversal across group boundaries correct by\n * construction.\n */\nclass ListboxGroup extends Component<ListboxGroupSignature> {\n titleId = `${guidFor(this)}-title`;\n\n get classNames() {\n const { listboxGroup } = useStyles();\n const { base, title, list, divider } = listboxGroup();\n\n return {\n base: base({ class: [this.args.class, this.args.classes?.base] }),\n title: title({ class: this.args.classes?.title }),\n list: list({ class: this.args.classes?.list }),\n divider: divider()\n };\n }\n\n <template>\n <li\n role=\"group\"\n aria-labelledby={{if @title this.titleId}}\n data-
|
|
1
|
+
{"version":3,"file":"group.js","sources":["../../../../src/components/collections/listbox/group.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { guidFor } from '@ember/object/internals';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { ListboxItem } from './item';\nimport type { ListManager } from '../../../utils/listManager';\nimport type { ListboxItemSignature } from './item';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<\n typeof ListboxItem,\n 'manager' | 'type' | 'appearance' | 'intent' | 'shortcutAppearance'\n>;\n\nexport interface ListboxGroupSignature {\n Args: {\n manager: ListManager;\n\n /**\n * The heading rendered above the group's options. When omitted, the group\n * still groups its options but renders no heading — and carries no\n * `aria-labelledby`, since there would be nothing to point at.\n */\n title?: string;\n\n class?: string;\n classes?: {\n base?: string;\n title?: string;\n list?: string;\n };\n\n /**\n * Render a divider after the group. Groups in a palette are usually\n * separated visually; the divider is a sibling of the group rather than a\n * child so it does not sit inside the group's labelled region.\n */\n withDivider?: boolean;\n\n type?: ListboxItemSignature['Args']['type'];\n appearance?: ListboxItemSignature['Args']['appearance'];\n intent?: ListboxItemSignature['Args']['intent'];\n shortcutAppearance?: ListboxItemSignature['Args']['shortcutAppearance'];\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [{ Item: ItemCompBounded }];\n };\n}\n\n/**\n * A labelled section of options within a `Listbox`.\n *\n * The markup nests the options one level deeper than an ungrouped listbox, so\n * the intervening list is marked `role=\"none\"` to keep the\n * `listbox` -> `option` ownership chain intact.\n *\n * Grouping deliberately adds no concepts to `ListManager`: navigation order is\n * derived from the live DOM via `compareDocumentPosition`, so nesting options\n * inside a group leaves keyboard traversal across group boundaries correct by\n * construction.\n */\nclass ListboxGroup extends Component<ListboxGroupSignature> {\n titleId = `${guidFor(this)}-title`;\n\n get classNames() {\n const { listboxGroup } = useStyles();\n const { base, title, list, divider } = listboxGroup();\n\n return {\n base: base({ class: [this.args.class, this.args.classes?.base] }),\n title: title({ class: this.args.classes?.title }),\n list: list({ class: this.args.classes?.list }),\n divider: divider()\n };\n }\n\n <template>\n <li\n role=\"group\"\n aria-labelledby={{if @title this.titleId}}\n data-component=\"listbox-group\"\n data-part=\"base\"\n class={{this.classNames.base}}\n ...attributes\n >\n {{#if @title}}\n <span\n id={{this.titleId}}\n data-part=\"title\"\n class={{this.classNames.title}}\n >{{@title}}</span>\n {{/if}}\n\n <ul role=\"none\" data-part=\"list\" class={{this.classNames.list}}>\n {{yield\n (hash\n Item=(component\n ListboxItem\n manager=@manager\n appearance=@appearance\n intent=@intent\n shortcutAppearance=@shortcutAppearance\n type=@type\n )\n )\n }}\n </ul>\n </li>\n\n {{#if @withDivider}}\n <Divider\n @as=\"li\"\n @class={{this.classNames.divider}}\n data-part=\"divider\"\n />\n {{/if}}\n </template>\n}\n\nexport { ListboxGroup };\nexport default ListboxGroup;\n"],"names":["ListboxGroup","Component","titleId","guidFor","classNames","listboxGroup","useStyles","base","title","list","divider","class","args","classes","setComponentTemplate","precompileTemplate","strictMode","scope","hash","ListboxItem","Divider"],"mappings":";;;;;;;;;AAmDA;;;;;;;;;;;;AAYA,MAAMA,qBAAqBC,SAAA,CAAU;AACnCC,EAAAA,OAAA,GAAU,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,MAAA,CAAS;EAElC,IAAIC,UAAAA,GAAa;IACf,MAAM;AAAEC,MAAAA;KAAc,GAAGC,SAAA,EAAA;IACzB,MAAM;MAAEC,IAAI;MAAEC,KAAK;MAAEC,IAAI;AAAEC,MAAAA;KAAS,GAAGL,YAAA,EAAA;IAEvC,OAAO;MACLE,IAAA,EAAMA,IAAA,CAAK;AAAEI,QAAAA,KAAA,EAAO,CAAC,IAAI,CAACC,IAAI,CAACD,KAAK,EAAE,IAAI,CAACC,IAAI,CAACC,OAAO,EAAEN,IAAA;AAAM,OAAA,CAAA;MAC/DC,KAAA,EAAOA,KAAA,CAAM;AAAEG,QAAAA,KAAA,EAAO,IAAI,CAACC,IAAI,CAACC,OAAO,EAAEL;AAAM,OAAA,CAAA;MAC/CC,IAAA,EAAMA,IAAA,CAAK;AAAEE,QAAAA,KAAA,EAAO,IAAI,CAACC,IAAI,CAACC,OAAO,EAAEJ;AAAK,OAAA,CAAA;MAC5CC,OAAA,EAASA,OAAA;KACX;AACF,EAAA;AAEA,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,6oBAAA,EAwCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;QAAAC,WAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -174,7 +174,7 @@ class ListboxItem extends Component {
|
|
|
174
174
|
return this.submenuOpenState;
|
|
175
175
|
}
|
|
176
176
|
static {
|
|
177
|
-
setComponentTemplate(precompileTemplate("<li {{this.manager.setupItem key=this.key textValue=@textValue item=@item onRegister=this.onRegister}} {{on \"click\" this.onClick}} id={{this.itemId}} role={{this.role}} aria-labelledby={{this.labelId}} aria-selected={{this.ariaSelected}} aria-haspopup={{this.ariaHasPopup}} aria-expanded={{this.ariaExpanded}} aria-controls={{if @hasSubmenu @submenuId}} data-submenu-open={{this.dataSubmenuOpen}} tabindex={{this.tabindex}} data-active=\"{{this.listItem.isActive}}\" data-selected=\"{{this.listItem.isSelected}}\" data-
|
|
177
|
+
setComponentTemplate(precompileTemplate("<li {{this.manager.setupItem key=this.key textValue=@textValue item=@item onRegister=this.onRegister}} {{on \"click\" this.onClick}} id={{this.itemId}} role={{this.role}} aria-labelledby={{this.labelId}} aria-selected={{this.ariaSelected}} aria-haspopup={{this.ariaHasPopup}} aria-expanded={{this.ariaExpanded}} aria-controls={{if @hasSubmenu @submenuId}} data-submenu-open={{this.dataSubmenuOpen}} tabindex={{this.tabindex}} data-active=\"{{this.listItem.isActive}}\" data-selected=\"{{this.listItem.isSelected}}\" data-component=\"listbox-item\" data-part=\"base\" data-key={{this.key}} aria-disabled={{if this.listItem.isDisabled \"true\"}} class={{this.classNames.base}} ...attributes>\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div data-part=\"description-wrapper\" class={{this.classNames.descriptionWrapper}}>\n <span data-part=\"label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n <span data-part=\"description\" class={{this.classNames.description}}>{{@description}}</span>\n </div>\n {{else}}\n <span data-part=\"label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <Kbd @keys={{@shortcut}} @size=\"sm\" @appearance={{this.shortcutAppearance}} data-test-id=\"listbox-item-shortcut\" />\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-part=\"selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{#if @hasSubmenu}}\n {{#unless (has-block \"end\")}}\n <span data-part=\"submenu-indicator\" class={{this.submenuIndicatorClass}}>\n <ChevronRightIcon class=\"h-full w-full\" />\n </span>\n {{/unless}}\n {{/if}}\n\n {{yield to=\"end\"}}\n</li>\n{{#if @withDivider}}\n <Divider @as=\"li\" />\n{{/if}}", {
|
|
178
178
|
strictMode: true,
|
|
179
179
|
scope: () => ({
|
|
180
180
|
on,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../../src/components/collections/listbox/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { Kbd } from '../../utilities/kbd';\nimport type { KbdSignature } from '../../utilities/kbd';\nimport { guidFor } from '@ember/object/internals';\nimport type { TOC } from '@ember/component/template-only';\nimport type { ListManager, ListItem } from '../../../utils/listManager';\n\nexport interface ListboxItemSignature {\n Args: {\n manager: ListManager;\n key: string;\n textValue?: string;\n\n /**\n * The entry of `@items` this option renders, remembered on the registered\n * list item so a selection can hand it back. Bound for you on the Item\n * yielded from the `:item` block; block-form options have no such entry.\n */\n item?: unknown;\n\n description?: string;\n\n /**\n * A keyboard shortcut shown at the end of the option, rendered by `Kbd`.\n * Accepts named keys (`\"mod+k\"`) or a literal string (`\"⌘K\"`).\n */\n shortcut?: string;\n\n /**\n * The appearance of the rendered shortcut. Defaults to `inherit`, so the\n * keycap follows the option's own colour on active and filled rows.\n *\n * @defaultValue 'inherit'\n */\n shortcutAppearance?: KbdSignature['Args']['appearance'];\n onClick?: () => void;\n class?: string;\n withDivider?: boolean;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n type?: 'menu' | 'listbox';\n\n /**\n * Marks this option as the trigger for a submenu.\n *\n * It stops the option selecting: opening a submenu is not choosing\n * anything, so `onAction` and `onSelectionChange` must not fire for it.\n * The option still registers with the `ListManager` and so still takes\n * part in arrow navigation, type-ahead and the roving tab stop.\n *\n * Renders `aria-haspopup=\"menu\"` and a trailing chevron, unless an `:end`\n * block supplies its own trailing content.\n */\n hasSubmenu?: boolean;\n\n /**\n * Whether this option's submenu is currently open. Only meaningful\n * alongside `@hasSubmenu`; drives `aria-expanded` and the highlighted\n * resting state via `data-submenu-open`.\n */\n isSubmenuOpen?: boolean;\n\n /**\n * The id of the `role=\"menu\"` element this option opens, for\n * `aria-controls`. Only meaningful alongside `@hasSubmenu`.\n */\n submenuId?: string;\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [];\n selectedIcon: [];\n start: [];\n end: [];\n };\n}\n\nclass ListboxItem extends Component<ListboxItemSignature> {\n // Stable element id so consumers (e.g. Autocomplete) can reference the\n // option via aria-activedescendant.\n itemId = `${guidFor(this)}-option`;\n labelId = guidFor(this);\n @tracked listItem?: ListItem;\n\n get manager(): ListManager {\n assert(\n `ListboxItem does not have a listManager; Missing argument @manager`,\n this.args.manager\n );\n\n return this.args.manager;\n }\n\n get key(): string {\n assert(\n `Argument @key is undefined or null, @key must be provided in Listbox.Item component`,\n this.args.key\n );\n\n return this.args.key;\n }\n\n @action\n onRegister(item: ListItem) {\n this.listItem = item;\n }\n\n @action\n onClick(): void {\n if (this.listItem?.isDisabled) {\n return;\n }\n\n // Opening a submenu is not choosing anything, so a sub-trigger must not\n // reach `selectItem` -- that is what fires `onAction` and\n // `onSelectionChange`. It still registers as an item, so arrow\n // navigation, type-ahead and the roving tab stop are unaffected.\n if (!this.args.hasSubmenu) {\n this.manager.selectItem(this.listItem);\n }\n\n if (typeof this.args.onClick === 'function') {\n this.args.onClick();\n }\n }\n\n /**\n * A roving tabindex: the manager nominates one option as the composite's tab\n * stop and every other option stays out of the tab order, as the ARIA\n * listbox pattern requires. Giving a `0` to each active *or selected* option\n * turned a multi-select with eight selections into eight tab stops.\n */\n get tabindex() {\n return this.manager.isTabStop(this.key) ? 0 : -1;\n }\n\n get classNames() {\n const { listboxItem } = useStyles();\n\n const { base, descriptionWrapper, label, description, selectedIcon } =\n listboxItem({\n appearance: this.args.appearance || 'default',\n intent: this.args.intent || 'default',\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return {\n base: base({ class: this.args.class }),\n descriptionWrapper: descriptionWrapper(),\n label: label(),\n description: description(),\n selectedIcon: selectedIcon()\n };\n }\n\n /**\n * The `submenuIndicator` slot is only ever rendered on a sub-trigger, so it\n * is looked up here rather than in `classNames`, and only when\n * `@hasSubmenu` is set — a plain item never pays for it.\n *\n * `registerCustomStyles` (`packages/theme/src/index.ts`) shallow-replaces:\n * a consumer supplying their own `listboxItem` via `tv({...})` swaps out\n * the whole config, not just the slots they mention. `tv()` in turn only\n * produces a function for a slot it was actually given. So a third-party\n * override written before this slot existed has no `submenuIndicator` key\n * at all, and calling it would throw. A published component library must\n * not crash a consumer's app over a stale override, so this stays\n * defensive — but the check now only runs for sub-triggers, not for every\n * item on every render.\n */\n get submenuIndicatorClass(): string | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n\n const { listboxItem } = useStyles();\n const { submenuIndicator } = listboxItem({\n appearance: this.args.appearance || 'default',\n intent: this.args.intent || 'default',\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return typeof submenuIndicator === 'function'\n ? submenuIndicator()\n : undefined;\n }\n\n get shortcutAppearance() {\n return this.args.shortcutAppearance ?? 'inherit';\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return 'menuitem';\n }\n return 'option';\n }\n\n /**\n * `aria-selected` belongs on `option`, and only there — a plain `menuitem`\n * that carries it is invalid ARIA, since menu items convey state through\n * `aria-checked` and only as `menuitemcheckbox`/`menuitemradio`. Returning\n * undefined omits the attribute rather than rendering an empty one.\n */\n get ariaSelected(): 'true' | 'false' | undefined {\n if (this.role !== 'option') {\n return undefined;\n }\n return this.listItem?.isSelected ? 'true' : 'false';\n }\n\n /**\n * `aria-haspopup=\"menu\"` rather than the bare `\"true\"`: both are valid, but\n * the explicit role tells a screen reader what is about to open.\n */\n get ariaHasPopup(): 'menu' | undefined {\n return this.args.hasSubmenu ? 'menu' : undefined;\n }\n\n /**\n * Only a row that owns a popup has an expanded state. Rendering\n * `aria-expanded` on a plain `menuitem` would be invalid ARIA, so this is\n * undefined -- and therefore omitted -- unless `@hasSubmenu` is set.\n */\n /**\n * `aria-expanded` and `data-submenu-open` share this same value — one is\n * the ARIA state for assistive tech, the other a styling hook for the\n * template's own resting/hover state — so both getters delegate here.\n */\n get submenuOpenState(): 'true' | 'false' | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n return this.args.isSubmenuOpen ? 'true' : 'false';\n }\n\n get ariaExpanded(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n get dataSubmenuOpen(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n <template>\n <li\n {{this.manager.setupItem\n key=this.key\n textValue=@textValue\n item=@item\n onRegister=this.onRegister\n }}\n {{on \"click\" this.onClick}}\n id={{this.itemId}}\n role={{this.role}}\n aria-labelledby={{this.labelId}}\n aria-selected={{this.ariaSelected}}\n aria-haspopup={{this.ariaHasPopup}}\n aria-expanded={{this.ariaExpanded}}\n aria-controls={{if @hasSubmenu @submenuId}}\n data-submenu-open={{this.dataSubmenuOpen}}\n tabindex={{this.tabindex}}\n data-active=\"{{this.listItem.isActive}}\"\n data-selected=\"{{this.listItem.isSelected}}\"\n data-test-id=\"listbox-item\"\n data-component=\"listbox-item\"\n data-key={{this.key}}\n aria-disabled={{if this.listItem.isDisabled \"true\"}}\n class={{this.classNames.base}}\n ...attributes\n >\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div class={{this.classNames.descriptionWrapper}}>\n <span\n data-test-id=\"listbox-item-label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n <span\n data-test-id=\"listbox-item-description\"\n class={{this.classNames.description}}\n >{{@description}}</span>\n </div>\n {{else}}\n <span\n data-test-id=\"listbox-item-label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <Kbd\n @keys={{@shortcut}}\n @size=\"sm\"\n @appearance={{this.shortcutAppearance}}\n data-test-id=\"listbox-item-shortcut\"\n />\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span\n data-test-id=\"listbox-item-selected-icon\"\n class={{this.classNames.selectedIcon}}\n >\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{#if @hasSubmenu}}\n {{#unless (has-block \"end\")}}\n <span\n data-test-id=\"listbox-item-submenu-indicator\"\n class={{this.submenuIndicatorClass}}\n >\n <ChevronRightIcon class=\"h-full w-full\" />\n </span>\n {{/unless}}\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n </template>\n}\n\nconst CheckIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m4.5 12.75 6 6 9-13.5\"\n />\n </svg>\n</template>;\n\nconst ChevronRightIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m8.25 4.5 7.5 7.5-7.5 7.5\"\n />\n </svg>\n</template>;\n\nexport { ListboxItem };\n"],"names":["ListboxItem","Component","itemId","guidFor","labelId","g","prototype","tracked","i","manager","assert","args","key","onRegister","item","listItem","n","action","onClick","isDisabled","hasSubmenu","selectItem","tabindex","isTabStop","classNames","listboxItem","useStyles","base","descriptionWrapper","label","description","selectedIcon","appearance","intent","isSelected","isActive","withDivider","class","submenuIndicatorClass","undefined","submenuIndicator","shortcutAppearance","role","type","ariaSelected","ariaHasPopup","submenuOpenState","isSubmenuOpen","ariaExpanded","dataSubmenuOpen","setComponentTemplate","precompileTemplate","strictMode","scope","on","Kbd","CheckIcon","ChevronR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I,CAACS,UAAU,GAAG,MAAA,GAASmB,SAAA;AACzC,EAAA;AAEA;;;;;;;;AASC;EACD,IAAIO,gBAAAA,GAAiD;AACnD,IAAA,IAAI,CAAC,IAAI,CAACnC,IAAI,CAACS,UAAU,EAAE;AACzB,MAAA,OAAOmB,SAAA;AACT,IAAA;IACA,OAAO,IAAI,CAAC5B,IAAI,CAACoC,aAAa,GAAG,MAAA,GAAS,OAAA;AAC5C,EAAA;EAEA,IAAIC,YAAAA,GAA6C;IAC/C,OAAO,IAAI,CAACF,gBAAgB;AAC9B,EAAA;EAEA,IAAIG,eAAAA,GAAgD;IAClD,OAAO,IAAI,CAACH,gBAAgB;AAC9B,EAAA;AAEA,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,q+DAAA,EAuFA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,gBAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA,MAAMF,SAED,GAAAN,oBAAA,CAAAC,kBAAA,CAAA,8OAAA,EAeL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAO,YAAA,EAAA,CAAA;AAEV,MAAMF,gBAED,GAAAP,oBAAA,CAAAC,kBAAA,CAAA,kPAAA,EAeL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAO,YAAA,EAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../../src/components/collections/listbox/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { Kbd } from '../../utilities/kbd';\nimport type { KbdSignature } from '../../utilities/kbd';\nimport { guidFor } from '@ember/object/internals';\nimport type { TOC } from '@ember/component/template-only';\nimport type { ListManager, ListItem } from '../../../utils/listManager';\n\nexport interface ListboxItemSignature {\n Args: {\n manager: ListManager;\n key: string;\n textValue?: string;\n\n /**\n * The entry of `@items` this option renders, remembered on the registered\n * list item so a selection can hand it back. Bound for you on the Item\n * yielded from the `:item` block; block-form options have no such entry.\n */\n item?: unknown;\n\n description?: string;\n\n /**\n * A keyboard shortcut shown at the end of the option, rendered by `Kbd`.\n * Accepts named keys (`\"mod+k\"`) or a literal string (`\"⌘K\"`).\n */\n shortcut?: string;\n\n /**\n * The appearance of the rendered shortcut. Defaults to `inherit`, so the\n * keycap follows the option's own colour on active and filled rows.\n *\n * @defaultValue 'inherit'\n */\n shortcutAppearance?: KbdSignature['Args']['appearance'];\n onClick?: () => void;\n class?: string;\n withDivider?: boolean;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n type?: 'menu' | 'listbox';\n\n /**\n * Marks this option as the trigger for a submenu.\n *\n * It stops the option selecting: opening a submenu is not choosing\n * anything, so `onAction` and `onSelectionChange` must not fire for it.\n * The option still registers with the `ListManager` and so still takes\n * part in arrow navigation, type-ahead and the roving tab stop.\n *\n * Renders `aria-haspopup=\"menu\"` and a trailing chevron, unless an `:end`\n * block supplies its own trailing content.\n */\n hasSubmenu?: boolean;\n\n /**\n * Whether this option's submenu is currently open. Only meaningful\n * alongside `@hasSubmenu`; drives `aria-expanded` and the highlighted\n * resting state via `data-submenu-open`.\n */\n isSubmenuOpen?: boolean;\n\n /**\n * The id of the `role=\"menu\"` element this option opens, for\n * `aria-controls`. Only meaningful alongside `@hasSubmenu`.\n */\n submenuId?: string;\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [];\n selectedIcon: [];\n start: [];\n end: [];\n };\n}\n\nclass ListboxItem extends Component<ListboxItemSignature> {\n // Stable element id so consumers (e.g. Autocomplete) can reference the\n // option via aria-activedescendant.\n itemId = `${guidFor(this)}-option`;\n labelId = guidFor(this);\n @tracked listItem?: ListItem;\n\n get manager(): ListManager {\n assert(\n `ListboxItem does not have a listManager; Missing argument @manager`,\n this.args.manager\n );\n\n return this.args.manager;\n }\n\n get key(): string {\n assert(\n `Argument @key is undefined or null, @key must be provided in Listbox.Item component`,\n this.args.key\n );\n\n return this.args.key;\n }\n\n @action\n onRegister(item: ListItem) {\n this.listItem = item;\n }\n\n @action\n onClick(): void {\n if (this.listItem?.isDisabled) {\n return;\n }\n\n // Opening a submenu is not choosing anything, so a sub-trigger must not\n // reach `selectItem` -- that is what fires `onAction` and\n // `onSelectionChange`. It still registers as an item, so arrow\n // navigation, type-ahead and the roving tab stop are unaffected.\n if (!this.args.hasSubmenu) {\n this.manager.selectItem(this.listItem);\n }\n\n if (typeof this.args.onClick === 'function') {\n this.args.onClick();\n }\n }\n\n /**\n * A roving tabindex: the manager nominates one option as the composite's tab\n * stop and every other option stays out of the tab order, as the ARIA\n * listbox pattern requires. Giving a `0` to each active *or selected* option\n * turned a multi-select with eight selections into eight tab stops.\n */\n get tabindex() {\n return this.manager.isTabStop(this.key) ? 0 : -1;\n }\n\n get classNames() {\n const { listboxItem } = useStyles();\n\n const { base, descriptionWrapper, label, description, selectedIcon } =\n listboxItem({\n appearance: this.args.appearance || 'default',\n intent: this.args.intent || 'default',\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return {\n base: base({ class: this.args.class }),\n descriptionWrapper: descriptionWrapper(),\n label: label(),\n description: description(),\n selectedIcon: selectedIcon()\n };\n }\n\n /**\n * The `submenuIndicator` slot is only ever rendered on a sub-trigger, so it\n * is looked up here rather than in `classNames`, and only when\n * `@hasSubmenu` is set — a plain item never pays for it.\n *\n * `registerCustomStyles` (`packages/theme/src/index.ts`) shallow-replaces:\n * a consumer supplying their own `listboxItem` via `tv({...})` swaps out\n * the whole config, not just the slots they mention. `tv()` in turn only\n * produces a function for a slot it was actually given. So a third-party\n * override written before this slot existed has no `submenuIndicator` key\n * at all, and calling it would throw. A published component library must\n * not crash a consumer's app over a stale override, so this stays\n * defensive — but the check now only runs for sub-triggers, not for every\n * item on every render.\n */\n get submenuIndicatorClass(): string | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n\n const { listboxItem } = useStyles();\n const { submenuIndicator } = listboxItem({\n appearance: this.args.appearance || 'default',\n intent: this.args.intent || 'default',\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return typeof submenuIndicator === 'function'\n ? submenuIndicator()\n : undefined;\n }\n\n get shortcutAppearance() {\n return this.args.shortcutAppearance ?? 'inherit';\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return 'menuitem';\n }\n return 'option';\n }\n\n /**\n * `aria-selected` belongs on `option`, and only there — a plain `menuitem`\n * that carries it is invalid ARIA, since menu items convey state through\n * `aria-checked` and only as `menuitemcheckbox`/`menuitemradio`. Returning\n * undefined omits the attribute rather than rendering an empty one.\n */\n get ariaSelected(): 'true' | 'false' | undefined {\n if (this.role !== 'option') {\n return undefined;\n }\n return this.listItem?.isSelected ? 'true' : 'false';\n }\n\n /**\n * `aria-haspopup=\"menu\"` rather than the bare `\"true\"`: both are valid, but\n * the explicit role tells a screen reader what is about to open.\n */\n get ariaHasPopup(): 'menu' | undefined {\n return this.args.hasSubmenu ? 'menu' : undefined;\n }\n\n /**\n * Only a row that owns a popup has an expanded state. Rendering\n * `aria-expanded` on a plain `menuitem` would be invalid ARIA, so this is\n * undefined -- and therefore omitted -- unless `@hasSubmenu` is set.\n */\n /**\n * `aria-expanded` and `data-submenu-open` share this same value — one is\n * the ARIA state for assistive tech, the other a styling hook for the\n * template's own resting/hover state — so both getters delegate here.\n */\n get submenuOpenState(): 'true' | 'false' | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n return this.args.isSubmenuOpen ? 'true' : 'false';\n }\n\n get ariaExpanded(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n get dataSubmenuOpen(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n <template>\n <li\n {{this.manager.setupItem\n key=this.key\n textValue=@textValue\n item=@item\n onRegister=this.onRegister\n }}\n {{on \"click\" this.onClick}}\n id={{this.itemId}}\n role={{this.role}}\n aria-labelledby={{this.labelId}}\n aria-selected={{this.ariaSelected}}\n aria-haspopup={{this.ariaHasPopup}}\n aria-expanded={{this.ariaExpanded}}\n aria-controls={{if @hasSubmenu @submenuId}}\n data-submenu-open={{this.dataSubmenuOpen}}\n tabindex={{this.tabindex}}\n data-active=\"{{this.listItem.isActive}}\"\n data-selected=\"{{this.listItem.isSelected}}\"\n data-component=\"listbox-item\"\n data-part=\"base\"\n data-key={{this.key}}\n aria-disabled={{if this.listItem.isDisabled \"true\"}}\n class={{this.classNames.base}}\n ...attributes\n >\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div\n data-part=\"description-wrapper\"\n class={{this.classNames.descriptionWrapper}}\n >\n <span\n data-part=\"label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n <span\n data-part=\"description\"\n class={{this.classNames.description}}\n >{{@description}}</span>\n </div>\n {{else}}\n <span\n data-part=\"label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <Kbd\n @keys={{@shortcut}}\n @size=\"sm\"\n @appearance={{this.shortcutAppearance}}\n data-test-id=\"listbox-item-shortcut\"\n />\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-part=\"selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{#if @hasSubmenu}}\n {{#unless (has-block \"end\")}}\n <span\n data-part=\"submenu-indicator\"\n class={{this.submenuIndicatorClass}}\n >\n <ChevronRightIcon class=\"h-full w-full\" />\n </span>\n {{/unless}}\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n </template>\n}\n\nconst CheckIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m4.5 12.75 6 6 9-13.5\"\n />\n </svg>\n</template>;\n\nconst ChevronRightIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m8.25 4.5 7.5 7.5-7.5 7.5\"\n />\n </svg>\n</template>;\n\nexport { ListboxItem };\n"],"names":["ListboxItem","Component","itemId","guidFor","labelId","g","prototype","tracked","i","manager","assert","args","key","onRegister","item","listItem","n","action","onClick","isDisabled","hasSubmenu","selectItem","tabindex","isTabStop","classNames","listboxItem","useStyles","base","descriptionWrapper","label","description","selectedIcon","appearance","intent","isSelected","isActive","withDivider","class","submenuIndicatorClass","undefined","submenuIndicator","shortcutAppearance","role","type","ariaSelected","ariaHasPopup","submenuOpenState","isSubmenuOpen","ariaExpanded","dataSubmenuOpen","setComponentTemplate","precompileTemplate","strictMode","scope","on","Kbd","CheckIcon","ChevronRightIcon","Divider","templateOnly"],"mappings":";;;;;;;;;;;;;;AAqGA,MAAMA,oBAAoBC,SAAA,CAAU;AAClC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gBAAAA,GAAiD;AACnD,IAAA,IAAI,CAAC,IAAI,CAACnC,IAAI,CAACS,UAAU,EAAE;AACzB,MAAA,OAAOmB,SAAA;AACT,IAAA;IACA,OAAO,IAAI,CAAC5B,IAAI,CAACoC,aAAa,GAAG,MAAA,GAAS,OAAA;AAC5C,EAAA;EAEA,IAAIC,YAAAA,GAA6C;IAC/C,OAAO,IAAI,CAACF,gBAAgB;AAC9B,EAAA;EAEA,IAAIG,eAAAA,GAAgD;IAClD,OAAO,IAAI,CAACH,gBAAgB;AAC9B,EAAA;AAEA,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,46DAAA,EAuFA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,gBAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA,MAAMF,SAED,GAAAN,oBAAA,CAAAC,kBAAA,CAAA,8OAAA,EAeL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAO,YAAA,EAAA,CAAA;AAEV,MAAMF,gBAED,GAAAP,oBAAA,CAAAC,kBAAA,CAAA,kPAAA,EAeL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAO,YAAA,EAAA,CAAA;;;;"}
|
|
@@ -169,7 +169,7 @@ class Listbox extends Component {
|
|
|
169
169
|
return this.args.selectionMode === 'multiple' ? 'true' : undefined;
|
|
170
170
|
}
|
|
171
171
|
static {
|
|
172
|
-
setComponentTemplate(precompileTemplate("<ul tabindex=\"0\" role={{this.role}} aria-multiselectable={{this.ariaMultiselectable}} {{!-- The callbacks travel through setup, not only through the manager's\n field initializer above: that initializer runs once, so an onAction\n rebuilt on a later render would otherwise never reach the manager. --}} {{this.listManager.setup selectedKeys=@selectedKeys disabledKeys=@disabledKeys selectionMode=@selectionMode allowEmpty=@allowEmpty onAction=@onAction onSelectionChange=@onSelectionChange onActiveItemChange=@onActiveItemChange autoActivateMode=(if (isUndefined @autoActivateMode) \"first\" @autoActivateMode)}} {{on \"keydown\" this.onKeyDown}} {{this.setupEvents elementToAddKeyboardEvents=@elementToAddKeyboardEvents}} data-
|
|
172
|
+
setComponentTemplate(precompileTemplate("<ul tabindex=\"0\" role={{this.role}} aria-multiselectable={{this.ariaMultiselectable}} {{!-- The callbacks travel through setup, not only through the manager's\n field initializer above: that initializer runs once, so an onAction\n rebuilt on a later render would otherwise never reach the manager. --}} {{this.listManager.setup selectedKeys=@selectedKeys disabledKeys=@disabledKeys selectionMode=@selectionMode allowEmpty=@allowEmpty onAction=@onAction onSelectionChange=@onSelectionChange onActiveItemChange=@onActiveItemChange autoActivateMode=(if (isUndefined @autoActivateMode) \"first\" @autoActivateMode)}} {{on \"keydown\" this.onKeyDown}} {{this.setupEvents elementToAddKeyboardEvents=@elementToAddKeyboardEvents}} data-component=\"listbox\" data-part=\"base\" class={{this.classNames}} ...attributes>\n {{#each @items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{#if (has-block \"item\")}}\n {{yield (hash item=item key=keyLabel.key label=keyLabel.label Item=(component ListboxItem manager=this.listManager appearance=@appearance intent=@intent shortcutAppearance=@shortcutAppearance type=this.role key=keyLabel.key item=item)) to=\"item\"}}\n {{else}}\n <ListboxItem @manager={{this.listManager}} @key={{keyLabel.key}} @item={{item}} @appearance={{@appearance}} @intent={{@intent}} @shortcutAppearance={{@shortcutAppearance}} @type={{this.role}}>\n {{keyLabel.label}}\n </ListboxItem>\n {{/if}}\n {{/let}}\n {{/each}}\n\n {{yield (hash Item=(component ListboxItem manager=this.listManager appearance=@appearance intent=@intent shortcutAppearance=@shortcutAppearance type=this.role) Group=(component ListboxGroup manager=this.listManager appearance=@appearance intent=@intent shortcutAppearance=@shortcutAppearance type=this.role))}}\n</ul>", {
|
|
173
173
|
strictMode: true,
|
|
174
174
|
scope: () => ({
|
|
175
175
|
isUndefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.js","sources":["../../../../src/components/collections/listbox/listbox.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport {\n ListManager,\n keyAndLabelForItem,\n type SelectionMode,\n type ListItem\n} from '../../../utils/listManager';\nimport { ListboxItem, type ListboxItemSignature } from './item';\nimport { ListboxGroup, type ListboxGroupSignature } from './group';\nimport { modifier } from 'ember-modifier';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<typeof ListboxItem, 'manager'>;\ntype GroupCompBounded = WithBoundArgs<typeof ListboxGroup, 'manager'>;\ntype ItemCompBoundedWithItem = WithBoundArgs<\n typeof ListboxItem,\n 'manager' | 'item'\n>;\n\ninterface ListboxSignature<T> {\n Args: {\n /**\n * @default 'listbox'\n */\n type?: 'menu' | 'listbox';\n selectionMode?: SelectionMode;\n selectedKeys?: string[];\n disabledKeys?: string[];\n allowEmpty?: boolean;\n items?: T[];\n class?: string;\n isKeyboardEventsEnabled?: boolean;\n\n /** The element to add keyboard events to.\n *\n * This does not respect the option `iskeyboardEventsEnabled`.\n * @defaultValue null\n */\n elementToAddKeyboardEvents?: HTMLElement;\n\n /**\n * @defaultValue 'first'\n */\n autoActivateMode?: 'none' | 'first' | 'selected';\n\n onAction?: (key: string) => void;\n onSelectionChange?: (key: string[]) => void;\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * The appearance of the keycap rendered for each item's `@shortcut`.\n *\n * @defaultValue 'inherit'\n */\n shortcutAppearance?: ListboxItemSignature['Args']['shortcutAppearance'];\n };\n Element: HTMLUListElement;\n Blocks: {\n item: [\n { item: T; key: string; label: string; Item: ItemCompBoundedWithItem }\n ];\n default: [{ Item: ItemCompBounded; Group: GroupCompBounded }];\n };\n}\n\nconst isInputElement = (\n target: EventTarget | null\n): target is HTMLInputElement => {\n return target instanceof HTMLInputElement;\n};\n\nconst isUndefined = (a: unknown) => typeof a === 'undefined';\n\nconst NAVIGATION_KEYS = [\n 'ArrowUp',\n 'ArrowDown',\n 'PageUp',\n 'PageDown',\n 'Home',\n 'End'\n];\n\n/**\n * Whether a command-style modifier is held.\n *\n * Enter, Space and type-ahead moved here from the deprecated `keypress`,\n * which largely did not deliver modifier combinations at all. `keydown` does,\n * and it reports an unchanged `key`: Cmd+K arrives as `key === 'k'`, Cmd+Space\n * (Spotlight) as `key === ' '`. Acting on those would swallow the user's and\n * the OS's shortcuts -- typing them into the search buffer, or selecting an\n * option nobody asked for -- so a modifier combo is not ours to handle.\n *\n * Shift is deliberately absent: a capital letter is legitimate type-ahead.\n * `Popover`'s open-on-letter handler makes the same check for the same\n * reason.\n *\n * Arrow and Home/End navigation is exempt, because it always lived on\n * `keydown` and so already had to tolerate these combinations.\n */\nconst hasCommandModifier = (event: KeyboardEvent): boolean => {\n return event.metaKey || event.ctrlKey || event.altKey;\n};\n\n/**\n * Whether a keystroke should extend the type-ahead search buffer.\n *\n * Any single printable character qualifies. Unlike `Popover`'s letter check\n * this deliberately does not require `event.code === 'Key' + key`, which\n * restricts matching to A-Z: a listbox types ahead with digits and\n * punctuation too, and the WAI-ARIA APG requires Space to extend an active\n * search.\n *\n * Autorepeat is dropped. `search()` accumulates a prefix rather than cycling\n * between same-initial items, so a leaned-on 'a' would build \"aaaa\" and match\n * nothing -- a hazard `keypress` never surfaced here. Keystrokes mid-IME\n * composition belong to the input method, not to type-ahead.\n */\nconst isTypeAheadKey = (event: KeyboardEvent): boolean => {\n return event.key.length === 1 && !event.repeat && !event.isComposing;\n};\n\nclass Listbox<T = unknown> extends Component<ListboxSignature<T>> {\n listManager = new ListManager({\n selectionMode: this.args.selectionMode,\n selectedKeys: this.args.selectedKeys,\n disabledKeys: this.args.disabledKeys,\n allowEmpty: this.args.allowEmpty,\n onSelectionChange: this.args.onSelectionChange,\n onAction: this.args.onAction,\n onActiveItemChange: this.args.onActiveItemChange,\n autoActivateMode: isUndefined(this.args.autoActivateMode)\n ? 'first'\n : this.args.autoActivateMode\n });\n\n /**\n * All keyboard behaviour lands on `keydown`.\n *\n * Selection and type-ahead used to live on a separate `keypress` listener.\n * A browser fires `keypress` only when the preceding `keydown` was not\n * canceled, so any co-located `keydown` handler calling `preventDefault()`\n * -- `Dropdown`'s submenu keys, a consuming app's shortcut handler --\n * silently deleted the event this component depended on, and Enter\n * selection stopped working with no error at all. `keypress` is also absent\n * from current spec guidance and inconsistent for non-printable keys.\n */\n handleKeyDown = (event: KeyboardEvent) => {\n if (NAVIGATION_KEYS.includes(event.key)) {\n event.preventDefault();\n\n if (event.key === 'ArrowDown') {\n this.listManager.setNextOptionActive();\n } else if (event.key === 'ArrowUp') {\n this.listManager.setPreviousOptionActive();\n } else if (event.key === 'Home' || event.key === 'PageUp') {\n this.listManager.setFirstOptionActive();\n } else if (event.key === 'End' || event.key === 'PageDown') {\n this.listManager.setLastOptionActive();\n }\n\n return;\n }\n\n if (hasCommandModifier(event)) {\n return;\n }\n\n // Navigation above applies wherever the keystroke came from, but text\n // entry does not: when the events are forwarded from a real input (an\n // Autocomplete or Select trigger), the input owns the typing and only\n // Enter is ours to act on.\n if (isInputElement(event.target)) {\n if (event.key === 'Enter') {\n this.listManager.selectActiveItem();\n }\n return;\n }\n\n if (event.key === 'Enter') {\n // Enter always selects the active item, even mid-search — unlike\n // Space, Enter is never itself a type-ahead character (its length is\n // 5, not 1), so gating it on an empty search buffer just drops the\n // keystroke while `search()`'s 500ms debounce is still pending. Do\n // not fold this back into the Space branch below.\n this.listManager.selectActiveItem();\n this.listManager.clearSearch();\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (event.key === ' ' && this.listManager.searchKeys == '') {\n this.listManager.selectActiveItem();\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (isTypeAheadKey(event)) {\n if (event.key === ' ') {\n // Space extends an active search rather than selecting, but it must\n // still not scroll the page. Only `keydown` can prevent that; the\n // old `keypress` listener fired too late to stop it.\n event.preventDefault();\n }\n\n this.listManager.search(event.key);\n }\n };\n\n onKeyDown = (event: KeyboardEvent) => {\n if (this.args.isKeyboardEventsEnabled) {\n this.handleKeyDown(event);\n }\n };\n\n setupEvents = modifier(\n (\n _el: HTMLElement,\n _: unknown[],\n args: { elementToAddKeyboardEvents?: HTMLElement }\n ) => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n\n return () => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n };\n }\n );\n\n get classNames() {\n const { listbox } = useStyles();\n return listbox({ class: this.args.class });\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return this.args.type;\n }\n return 'listbox';\n }\n\n /**\n * A listbox that accepts more than one selection has to say so, otherwise a\n * screen reader presents it as a single-choice list. Only meaningful on\n * `role=\"listbox\"`; a `menu` conveys multi-select through its item roles.\n */\n get ariaMultiselectable(): 'true' | undefined {\n if (this.role !== 'listbox') {\n return undefined;\n }\n return this.args.selectionMode === 'multiple' ? 'true' : undefined;\n }\n\n <template>\n <ul\n tabindex=\"0\"\n role={{this.role}}\n aria-multiselectable={{this.ariaMultiselectable}}\n {{! The callbacks travel through setup, not only through the manager's\n field initializer above: that initializer runs once, so an onAction\n rebuilt on a later render would otherwise never reach the manager. }}\n {{this.listManager.setup\n selectedKeys=@selectedKeys\n disabledKeys=@disabledKeys\n selectionMode=@selectionMode\n allowEmpty=@allowEmpty\n onAction=@onAction\n onSelectionChange=@onSelectionChange\n onActiveItemChange=@onActiveItemChange\n autoActivateMode=(if\n (isUndefined @autoActivateMode) \"first\" @autoActivateMode\n )\n }}\n {{on \"keydown\" this.onKeyDown}}\n {{this.setupEvents\n elementToAddKeyboardEvents=@elementToAddKeyboardEvents\n }}\n data-test-id=\"listbox\"\n data-component=\"listbox\"\n class={{this.classNames}}\n ...attributes\n >\n {{#each @items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{#if (has-block \"item\")}}\n {{yield\n (hash\n item=item\n key=keyLabel.key\n label=keyLabel.label\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n shortcutAppearance=@shortcutAppearance\n type=this.role\n key=keyLabel.key\n item=item\n )\n )\n to=\"item\"\n }}\n {{else}}\n <ListboxItem\n @manager={{this.listManager}}\n @key={{keyLabel.key}}\n @item={{item}}\n @appearance={{@appearance}}\n @intent={{@intent}}\n @shortcutAppearance={{@shortcutAppearance}}\n @type={{this.role}}\n >\n {{keyLabel.label}}\n </ListboxItem>\n {{/if}}\n {{/let}}\n {{/each}}\n\n {{yield\n (hash\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n shortcutAppearance=@shortcutAppearance\n type=this.role\n )\n Group=(component\n ListboxGroup\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n shortcutAppearance=@shortcutAppearance\n type=this.role\n )\n )\n }}\n </ul>\n </template>\n}\n\nexport {\n Listbox,\n ListboxItem,\n ListboxGroup,\n type ListboxSignature,\n type ListboxItemSignature,\n type ListboxGroupSignature,\n type ListItem\n};\nexport default Listbox;\n"],"names":["isInputElement","target","HTMLInputElement","isUndefined","a","NAVIGATION_KEYS","hasCommandModifier","event","metaKey","ctrlKey","altKey","isTypeAheadKey","key","length","repeat","isComposing","Listbox","Component","listManager","ListManager","selectionMode","args","selectedKeys","disabledKeys","allowEmpty","onSelectionChange","onAction","onActiveItemChange","autoActivateMode","handleKeyDown","includes","preventDefault","setNextOptionActive","setPreviousOptionActive","setFirstOptionActive","setLastOptionActive","selectActiveItem","clearSearch","stopPropagation","searchKeys","search","onKeyDown","isKeyboardEventsEnabled","setupEvents","modifier","_el","_","elementToAddKeyboardEvents","addEventListener","removeEventListener","classNames","listbox","useStyles","class","role","type","ariaMultiselectable","undefined","setComponentTemplate","precompileTemplate","strictMode","scope","on","keyAndLabelForItem","hash","ListboxItem","ListboxGroup"],"mappings":";;;;;;;;;;;AAuFA,MAAMA,iBACJC,MAA0B,IACf;EACX,OAAOA,MAAA,YAAkBC,gBAAA;AAC3B,CAAA;AAEA,MAAMC,cAAeC,CAAU,IAAK,OAAOA,CAAA,KAAM,WAAA;AAEjD,MAAMC,eAAA,GAAkB,CACtB,SAAA,EACA,WAAA,EACA,QAAA,EACA,UAAA,EACA,MAAA,EACA,KAAA,CACD;AAED;;;;;;;;;;;;;;;;AAgBC;AACD,MAAMC,kBAAA,GAAsBC,SAA8B;EACxD,OAAOA,MAAMC,OAAO,IAAID,MAAME,OAAO,IAAIF,MAAMG,MAAM;AACvD,CAAA;AAEA;;;;;;;;;;;;;AAaC;AACD,MAAMC,cAAA,GAAkBJ,SAA8B;AACpD,EAAA,OAAOA,KAAA,CAAMK,GAAG,CAACC,MAAM,KAAK,CAAA,IAAK,CAACN,KAAA,CAAMO,MAAM,IAAI,CAACP,KAAA,CAAMQ,WAAW;AACtE,CAAA;AAEA,MAAMC,OAAA,SAA6BC,UAA2B;EAC5DC,WAAA,GAAc,IAAIC,WAAA,CAAY;AAC5BC,IAAAA,aAAA,EAAe,IAAI,CAACC,IAAI,CAACD,aAAa;AACtCE,IAAAA,YAAA,EAAc,IAAI,CAACD,IAAI,CAACC,YAAY;AACpCC,IAAAA,YAAA,EAAc,IAAI,CAACF,IAAI,CAACE,YAAY;AACpCC,IAAAA,UAAA,EAAY,IAAI,CAACH,IAAI,CAACG,UAAU;AAChCC,IAAAA,iBAAA,EAAmB,IAAI,CAACJ,IAAI,CAACI,iBAAiB;AAC9CC,IAAAA,QAAA,EAAU,IAAI,CAACL,IAAI,CAACK,QAAQ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B,0BAA0B,CAACE,mBAAmB,CACjD,SAAA,EACA,IAAI,CAACpB,aAAa,CAAA;AAEtB,MAAA;IACF,CAAA;AACF,EAAA,CAAA,CAAA;EAGF,IAAIqB,UAAAA,GAAa;IACf,MAAM;AAAEC,MAAAA;KAAS,GAAGC,SAAA,EAAA;AACpB,IAAA,OAAOD,OAAA,CAAQ;AAAEE,MAAAA,KAAA,EAAO,IAAI,CAAChC,IAAI,CAACgC;AAAM,KAAA,CAAA;AAC1C,EAAA;EAEA,IAAIC,IAAAA,GAAO;AACT,IAAA,IAAI,IAAI,CAACjC,IAAI,CAACkC,IAAI,KAAK,MAAA,EAAQ;AAC7B,MAAA,OAAO,IAAI,CAAClC,IAAI,CAACkC,IAAI;AACvB,IAAA;AACA,IAAA,OAAO,SAAA;AACT,EAAA;AAEA;;;;AAIC;EACD,IAAIC,mBAAAA,GAA0C;AAC5C,IAAA,IAAI,IAAI,CAACF,IAAI,KAAK,SAAA,EAAW;AAC3B,MAAA,OAAOG,SAAA;AACT,IAAA;IACA,OAAO,IAAI,CAACpC,IAAI,CAACD,aAAa,KAAK,aAAa,MAAA,GAASqC,SAAA;AAC3D,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,6yDAAA,EAuFA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAA1D,WAAA;QAAA2D,EAAA;QAAAC,kBAAA;QAAAC,IAAA;QAAAC,WAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
1
|
+
{"version":3,"file":"listbox.js","sources":["../../../../src/components/collections/listbox/listbox.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport {\n ListManager,\n keyAndLabelForItem,\n type SelectionMode,\n type ListItem\n} from '../../../utils/listManager';\nimport { ListboxItem, type ListboxItemSignature } from './item';\nimport { ListboxGroup, type ListboxGroupSignature } from './group';\nimport { modifier } from 'ember-modifier';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<typeof ListboxItem, 'manager'>;\ntype GroupCompBounded = WithBoundArgs<typeof ListboxGroup, 'manager'>;\ntype ItemCompBoundedWithItem = WithBoundArgs<\n typeof ListboxItem,\n 'manager' | 'item'\n>;\n\ninterface ListboxSignature<T> {\n Args: {\n /**\n * @default 'listbox'\n */\n type?: 'menu' | 'listbox';\n selectionMode?: SelectionMode;\n selectedKeys?: string[];\n disabledKeys?: string[];\n allowEmpty?: boolean;\n items?: T[];\n class?: string;\n isKeyboardEventsEnabled?: boolean;\n\n /** The element to add keyboard events to.\n *\n * This does not respect the option `iskeyboardEventsEnabled`.\n * @defaultValue null\n */\n elementToAddKeyboardEvents?: HTMLElement;\n\n /**\n * @defaultValue 'first'\n */\n autoActivateMode?: 'none' | 'first' | 'selected';\n\n onAction?: (key: string) => void;\n onSelectionChange?: (key: string[]) => void;\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * The appearance of the keycap rendered for each item's `@shortcut`.\n *\n * @defaultValue 'inherit'\n */\n shortcutAppearance?: ListboxItemSignature['Args']['shortcutAppearance'];\n };\n Element: HTMLUListElement;\n Blocks: {\n item: [\n { item: T; key: string; label: string; Item: ItemCompBoundedWithItem }\n ];\n default: [{ Item: ItemCompBounded; Group: GroupCompBounded }];\n };\n}\n\nconst isInputElement = (\n target: EventTarget | null\n): target is HTMLInputElement => {\n return target instanceof HTMLInputElement;\n};\n\nconst isUndefined = (a: unknown) => typeof a === 'undefined';\n\nconst NAVIGATION_KEYS = [\n 'ArrowUp',\n 'ArrowDown',\n 'PageUp',\n 'PageDown',\n 'Home',\n 'End'\n];\n\n/**\n * Whether a command-style modifier is held.\n *\n * Enter, Space and type-ahead moved here from the deprecated `keypress`,\n * which largely did not deliver modifier combinations at all. `keydown` does,\n * and it reports an unchanged `key`: Cmd+K arrives as `key === 'k'`, Cmd+Space\n * (Spotlight) as `key === ' '`. Acting on those would swallow the user's and\n * the OS's shortcuts -- typing them into the search buffer, or selecting an\n * option nobody asked for -- so a modifier combo is not ours to handle.\n *\n * Shift is deliberately absent: a capital letter is legitimate type-ahead.\n * `Popover`'s open-on-letter handler makes the same check for the same\n * reason.\n *\n * Arrow and Home/End navigation is exempt, because it always lived on\n * `keydown` and so already had to tolerate these combinations.\n */\nconst hasCommandModifier = (event: KeyboardEvent): boolean => {\n return event.metaKey || event.ctrlKey || event.altKey;\n};\n\n/**\n * Whether a keystroke should extend the type-ahead search buffer.\n *\n * Any single printable character qualifies. Unlike `Popover`'s letter check\n * this deliberately does not require `event.code === 'Key' + key`, which\n * restricts matching to A-Z: a listbox types ahead with digits and\n * punctuation too, and the WAI-ARIA APG requires Space to extend an active\n * search.\n *\n * Autorepeat is dropped. `search()` accumulates a prefix rather than cycling\n * between same-initial items, so a leaned-on 'a' would build \"aaaa\" and match\n * nothing -- a hazard `keypress` never surfaced here. Keystrokes mid-IME\n * composition belong to the input method, not to type-ahead.\n */\nconst isTypeAheadKey = (event: KeyboardEvent): boolean => {\n return event.key.length === 1 && !event.repeat && !event.isComposing;\n};\n\nclass Listbox<T = unknown> extends Component<ListboxSignature<T>> {\n listManager = new ListManager({\n selectionMode: this.args.selectionMode,\n selectedKeys: this.args.selectedKeys,\n disabledKeys: this.args.disabledKeys,\n allowEmpty: this.args.allowEmpty,\n onSelectionChange: this.args.onSelectionChange,\n onAction: this.args.onAction,\n onActiveItemChange: this.args.onActiveItemChange,\n autoActivateMode: isUndefined(this.args.autoActivateMode)\n ? 'first'\n : this.args.autoActivateMode\n });\n\n /**\n * All keyboard behaviour lands on `keydown`.\n *\n * Selection and type-ahead used to live on a separate `keypress` listener.\n * A browser fires `keypress` only when the preceding `keydown` was not\n * canceled, so any co-located `keydown` handler calling `preventDefault()`\n * -- `Dropdown`'s submenu keys, a consuming app's shortcut handler --\n * silently deleted the event this component depended on, and Enter\n * selection stopped working with no error at all. `keypress` is also absent\n * from current spec guidance and inconsistent for non-printable keys.\n */\n handleKeyDown = (event: KeyboardEvent) => {\n if (NAVIGATION_KEYS.includes(event.key)) {\n event.preventDefault();\n\n if (event.key === 'ArrowDown') {\n this.listManager.setNextOptionActive();\n } else if (event.key === 'ArrowUp') {\n this.listManager.setPreviousOptionActive();\n } else if (event.key === 'Home' || event.key === 'PageUp') {\n this.listManager.setFirstOptionActive();\n } else if (event.key === 'End' || event.key === 'PageDown') {\n this.listManager.setLastOptionActive();\n }\n\n return;\n }\n\n if (hasCommandModifier(event)) {\n return;\n }\n\n // Navigation above applies wherever the keystroke came from, but text\n // entry does not: when the events are forwarded from a real input (an\n // Autocomplete or Select trigger), the input owns the typing and only\n // Enter is ours to act on.\n if (isInputElement(event.target)) {\n if (event.key === 'Enter') {\n this.listManager.selectActiveItem();\n }\n return;\n }\n\n if (event.key === 'Enter') {\n // Enter always selects the active item, even mid-search — unlike\n // Space, Enter is never itself a type-ahead character (its length is\n // 5, not 1), so gating it on an empty search buffer just drops the\n // keystroke while `search()`'s 500ms debounce is still pending. Do\n // not fold this back into the Space branch below.\n this.listManager.selectActiveItem();\n this.listManager.clearSearch();\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (event.key === ' ' && this.listManager.searchKeys == '') {\n this.listManager.selectActiveItem();\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (isTypeAheadKey(event)) {\n if (event.key === ' ') {\n // Space extends an active search rather than selecting, but it must\n // still not scroll the page. Only `keydown` can prevent that; the\n // old `keypress` listener fired too late to stop it.\n event.preventDefault();\n }\n\n this.listManager.search(event.key);\n }\n };\n\n onKeyDown = (event: KeyboardEvent) => {\n if (this.args.isKeyboardEventsEnabled) {\n this.handleKeyDown(event);\n }\n };\n\n setupEvents = modifier(\n (\n _el: HTMLElement,\n _: unknown[],\n args: { elementToAddKeyboardEvents?: HTMLElement }\n ) => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n\n return () => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n };\n }\n );\n\n get classNames() {\n const { listbox } = useStyles();\n return listbox({ class: this.args.class });\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return this.args.type;\n }\n return 'listbox';\n }\n\n /**\n * A listbox that accepts more than one selection has to say so, otherwise a\n * screen reader presents it as a single-choice list. Only meaningful on\n * `role=\"listbox\"`; a `menu` conveys multi-select through its item roles.\n */\n get ariaMultiselectable(): 'true' | undefined {\n if (this.role !== 'listbox') {\n return undefined;\n }\n return this.args.selectionMode === 'multiple' ? 'true' : undefined;\n }\n\n <template>\n <ul\n tabindex=\"0\"\n role={{this.role}}\n aria-multiselectable={{this.ariaMultiselectable}}\n {{! The callbacks travel through setup, not only through the manager's\n field initializer above: that initializer runs once, so an onAction\n rebuilt on a later render would otherwise never reach the manager. }}\n {{this.listManager.setup\n selectedKeys=@selectedKeys\n disabledKeys=@disabledKeys\n selectionMode=@selectionMode\n allowEmpty=@allowEmpty\n onAction=@onAction\n onSelectionChange=@onSelectionChange\n onActiveItemChange=@onActiveItemChange\n autoActivateMode=(if\n (isUndefined @autoActivateMode) \"first\" @autoActivateMode\n )\n }}\n {{on \"keydown\" this.onKeyDown}}\n {{this.setupEvents\n elementToAddKeyboardEvents=@elementToAddKeyboardEvents\n }}\n data-component=\"listbox\"\n data-part=\"base\"\n class={{this.classNames}}\n ...attributes\n >\n {{#each @items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{#if (has-block \"item\")}}\n {{yield\n (hash\n item=item\n key=keyLabel.key\n label=keyLabel.label\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n shortcutAppearance=@shortcutAppearance\n type=this.role\n key=keyLabel.key\n item=item\n )\n )\n to=\"item\"\n }}\n {{else}}\n <ListboxItem\n @manager={{this.listManager}}\n @key={{keyLabel.key}}\n @item={{item}}\n @appearance={{@appearance}}\n @intent={{@intent}}\n @shortcutAppearance={{@shortcutAppearance}}\n @type={{this.role}}\n >\n {{keyLabel.label}}\n </ListboxItem>\n {{/if}}\n {{/let}}\n {{/each}}\n\n {{yield\n (hash\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n shortcutAppearance=@shortcutAppearance\n type=this.role\n )\n Group=(component\n ListboxGroup\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n shortcutAppearance=@shortcutAppearance\n type=this.role\n )\n )\n }}\n </ul>\n </template>\n}\n\nexport {\n Listbox,\n ListboxItem,\n ListboxGroup,\n type ListboxSignature,\n type ListboxItemSignature,\n type ListboxGroupSignature,\n type ListItem\n};\nexport default Listbox;\n"],"names":["isInputElement","target","HTMLInputElement","isUndefined","a","NAVIGATION_KEYS","hasCommandModifier","event","metaKey","ctrlKey","altKey","isTypeAheadKey","key","length","repeat","isComposing","Listbox","Component","listManager","ListManager","selectionMode","args","selectedKeys","disabledKeys","allowEmpty","onSelectionChange","onAction","onActiveItemChange","autoActivateMode","handleKeyDown","includes","preventDefault","setNextOptionActive","setPreviousOptionActive","setFirstOptionActive","setLastOptionActive","selectActiveItem","clearSearch","stopPropagation","searchKeys","search","onKeyDown","isKeyboardEventsEnabled","setupEvents","modifier","_el","_","elementToAddKeyboardEvents","addEventListener","removeEventListener","classNames","listbox","useStyles","class","role","type","ariaMultiselectable","undefined","setComponentTemplate","precompileTemplate","strictMode","scope","on","keyAndLabelForItem","hash","ListboxItem","ListboxGroup"],"mappings":";;;;;;;;;;;AAuFA,MAAMA,iBACJC,MAA0B,IACf;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AAI,CAACgC;AAAM,KAAA,CAAA;AAC1C,EAAA;EAEA,IAAIC,IAAAA,GAAO;AACT,IAAA,IAAI,IAAI,CAACjC,IAAI,CAACkC,IAAI,KAAK,MAAA,EAAQ;AAC7B,MAAA,OAAO,IAAI,CAAClC,IAAI,CAACkC,IAAI;AACvB,IAAA;AACA,IAAA,OAAO,SAAA;AACT,EAAA;AAEA;;;;AAIC;EACD,IAAIC,mBAAAA,GAA0C;AAC5C,IAAA,IAAI,IAAI,CAACF,IAAI,KAAK,SAAA,EAAW;AAC3B,MAAA,OAAOG,SAAA;AACT,IAAA;IACA,OAAO,IAAI,CAACpC,IAAI,CAACD,aAAa,KAAK,aAAa,MAAA,GAASqC,SAAA;AAC3D,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,uyDAAA,EAuFA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAA1D,WAAA;QAAA2D,EAAA;QAAAC,kBAAA;QAAAC,IAAA;QAAAC,WAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -17,7 +17,7 @@ class SimpleTableBody extends Component {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
static {
|
|
20
|
-
setComponentTemplate(precompileTemplate("<tbody class={{this.classNames}}
|
|
20
|
+
setComponentTemplate(precompileTemplate("<tbody data-part=\"tbody\" class={{this.classNames}} ...attributes>\n {{yield (hash Row=(component SimpleTableRow styleFns=this.styles classes=@classes) Cell=(component SimpleTableCell styleFns=this.styles classes=@classes))}}\n</tbody>", {
|
|
21
21
|
strictMode: true,
|
|
22
22
|
scope: () => ({
|
|
23
23
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.js","sources":["../../../../src/components/collections/simple-table/body.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableRow } from './row';\nimport { SimpleTableCell } from './cell';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface SimpleTableBodySignature {\n Args: {\n /** Additional CSS class to apply to the body section */\n class?: string;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableSectionElement;\n Blocks: {\n default: [\n {\n Row: WithBoundArgs<typeof SimpleTableRow, 'styleFns' | 'classes'>;\n Cell: WithBoundArgs<typeof SimpleTableCell, 'styleFns' | 'classes'>;\n }\n ];\n };\n}\n\nclass SimpleTableBody extends Component<SimpleTableBodySignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const mergedClass = twMerge(this.args.class, this.args.classes?.tbody);\n return this.styles.tbody({ class: mergedClass });\n }\n\n <template>\n <tbody\
|
|
1
|
+
{"version":3,"file":"body.js","sources":["../../../../src/components/collections/simple-table/body.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableRow } from './row';\nimport { SimpleTableCell } from './cell';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface SimpleTableBodySignature {\n Args: {\n /** Additional CSS class to apply to the body section */\n class?: string;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableSectionElement;\n Blocks: {\n default: [\n {\n Row: WithBoundArgs<typeof SimpleTableRow, 'styleFns' | 'classes'>;\n Cell: WithBoundArgs<typeof SimpleTableCell, 'styleFns' | 'classes'>;\n }\n ];\n };\n}\n\nclass SimpleTableBody extends Component<SimpleTableBodySignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const mergedClass = twMerge(this.args.class, this.args.classes?.tbody);\n return this.styles.tbody({ class: mergedClass });\n }\n\n <template>\n <tbody data-part=\"tbody\" class={{this.classNames}} ...attributes>\n {{yield\n (hash\n Row=(component SimpleTableRow styleFns=this.styles classes=@classes)\n Cell=(component SimpleTableCell styleFns=this.styles classes=@classes)\n )\n }}\n </tbody>\n </template>\n}\n\nexport { SimpleTableBody, type SimpleTableBodySignature };\nexport default SimpleTableBody;\n"],"names":["SimpleTableBody","Component","styles","args","styleFns","useStyles","table","classNames","mergedClass","twMerge","class","classes","tbody","setComponentTemplate","precompileTemplate","strictMode","scope","hash","SimpleTableRow","SimpleTableCell"],"mappings":";;;;;;;;AAkCA,MAAMA,wBAAwBC,SAAA,CAAU;EACtC,IAAIC,MAAAA,GAAS;AACX,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,IAAIC,YAAYC,KAAK,EAAA;AAChD,EAAA;EAEA,IAAIC,UAAAA,GAAa;AACf,IAAA,MAAMC,WAAA,GAAcC,OAAA,CAAQ,IAAI,CAACN,IAAI,CAACO,KAAK,EAAE,IAAI,CAACP,IAAI,CAACQ,OAAO,EAAEC,KAAA,CAAA;AAChE,IAAA,OAAO,IAAI,CAACV,MAAM,CAACU,KAAK,CAAC;AAAEF,MAAAA,KAAA,EAAOF;AAAY,KAAA,CAAA;AAChD,EAAA;AAEA,EAAA;IAAAK,oBAAA,CAAAC,kBAAA,CAAA,+OAAA,EASA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;QAAAC,cAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -17,7 +17,7 @@ class SimpleTableCell extends Component {
|
|
|
17
17
|
return this.styles.td(options);
|
|
18
18
|
}
|
|
19
19
|
static {
|
|
20
|
-
setComponentTemplate(precompileTemplate("<td class={{this.classNames}}
|
|
20
|
+
setComponentTemplate(precompileTemplate("<td data-part=\"td\" class={{this.classNames}} ...attributes>\n {{yield}}\n</td>", {
|
|
21
21
|
strictMode: true
|
|
22
22
|
}), this);
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell.js","sources":["../../../../src/components/collections/simple-table/cell.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\n\ninterface SimpleTableCellSignature {\n Args: {\n /** Additional CSS class to apply to the cell */\n class?: string;\n /** Whether this cell should be sticky during horizontal scrolling */\n isSticky?: boolean;\n /** Position where the sticky cell should stick. @default 'left' */\n stickyPosition?: 'left' | 'right';\n /** Whether this cell is part of a sticky row (used for intersection styling) */\n isInStickyRow?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableCellElement;\n Blocks: {\n default: [];\n };\n}\n\nclass SimpleTableCell extends Component<SimpleTableCellSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky\n ? (this.args.stickyPosition as 'left' | 'right') || 'left'\n : undefined,\n isInStickyRow: this.args.isInStickyRow || false,\n class: twMerge(this.args.class || '', this.args.classes?.td || '')\n };\n\n return this.styles.td(options);\n }\n\n <template>\n <td\
|
|
1
|
+
{"version":3,"file":"cell.js","sources":["../../../../src/components/collections/simple-table/cell.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\n\ninterface SimpleTableCellSignature {\n Args: {\n /** Additional CSS class to apply to the cell */\n class?: string;\n /** Whether this cell should be sticky during horizontal scrolling */\n isSticky?: boolean;\n /** Position where the sticky cell should stick. @default 'left' */\n stickyPosition?: 'left' | 'right';\n /** Whether this cell is part of a sticky row (used for intersection styling) */\n isInStickyRow?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableCellElement;\n Blocks: {\n default: [];\n };\n}\n\nclass SimpleTableCell extends Component<SimpleTableCellSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky\n ? (this.args.stickyPosition as 'left' | 'right') || 'left'\n : undefined,\n isInStickyRow: this.args.isInStickyRow || false,\n class: twMerge(this.args.class || '', this.args.classes?.td || '')\n };\n\n return this.styles.td(options);\n }\n\n <template>\n <td data-part=\"td\" class={{this.classNames}} ...attributes>\n {{yield}}\n </td>\n </template>\n}\n\nexport { SimpleTableCell, type SimpleTableCellSignature };\nexport default SimpleTableCell;\n"],"names":["SimpleTableCell","Component","styles","args","styleFns","useStyles","table","classNames","options","isSticky","stickyPosition","undefined","isInStickyRow","class","twMerge","classes","td","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AA+BA,MAAMA,wBAAwBC,SAAA,CAAU;EACtC,IAAIC,MAAAA,GAAS;AACX,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,IAAIC,YAAYC,KAAK,EAAA;AAChD,EAAA;EAEA,IAAIC,UAAAA,GAAa;AACf,IAAA,MAAMC,OAAA,GAAU;AACdC,MAAAA,QAAA,EAAU,IAAI,CAACN,IAAI,CAACM,QAAQ,IAAI,KAAA;AAChCC,MAAAA,cAAA,EAAgB,IAAI,CAACP,IAAI,CAACM,QAAQ,GAC7B,IAAI,CAACN,IAAI,CAACO,cAAc,IAAyB,MAAA,GAClDC,SAAA;AACJC,MAAAA,aAAA,EAAe,IAAI,CAACT,IAAI,CAACS,aAAa,IAAI,KAAA;AAC1CC,MAAAA,KAAA,EAAOC,OAAA,CAAQ,IAAI,CAACX,IAAI,CAACU,KAAK,IAAI,EAAA,EAAI,IAAI,CAACV,IAAI,CAACY,OAAO,EAAEC,EAAA,IAAM,EAAA;KACjE;AAEA,IAAA,OAAO,IAAI,CAACd,MAAM,CAACc,EAAE,CAACR,OAAA,CAAA;AACxB,EAAA;AAEA,EAAA;IAAAS,oBAAA,CAAAC,kBAAA,CAAA,mFAAA,EAIA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -16,7 +16,7 @@ class SimpleTableColumn extends Component {
|
|
|
16
16
|
return this.styles.th(options);
|
|
17
17
|
}
|
|
18
18
|
static {
|
|
19
|
-
setComponentTemplate(precompileTemplate("<th scope=\"col\" class={{this.classNames}}
|
|
19
|
+
setComponentTemplate(precompileTemplate("<th data-part=\"th\" scope=\"col\" class={{this.classNames}} ...attributes>\n {{yield}}\n</th>", {
|
|
20
20
|
strictMode: true
|
|
21
21
|
}), this);
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.js","sources":["../../../../src/components/collections/simple-table/column.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\n\ninterface SimpleTableColumnSignature {\n Args: {\n /** Additional CSS class to apply to the header cell */\n class?: string;\n /** Whether this column should be sticky during horizontal scrolling */\n isSticky?: boolean;\n /** Position where the sticky column should stick. @default 'left' */\n stickyPosition?: 'left' | 'right';\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n };\n Element: HTMLTableCellElement;\n Blocks: {\n default: [];\n };\n}\n\nclass SimpleTableColumn extends Component<SimpleTableColumnSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky\n ? (this.args.stickyPosition as 'left' | 'right') || 'left'\n : undefined,\n class: this.args.class\n };\n\n return this.styles.th(options);\n }\n\n <template>\n <th\
|
|
1
|
+
{"version":3,"file":"column.js","sources":["../../../../src/components/collections/simple-table/column.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\n\ninterface SimpleTableColumnSignature {\n Args: {\n /** Additional CSS class to apply to the header cell */\n class?: string;\n /** Whether this column should be sticky during horizontal scrolling */\n isSticky?: boolean;\n /** Position where the sticky column should stick. @default 'left' */\n stickyPosition?: 'left' | 'right';\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n };\n Element: HTMLTableCellElement;\n Blocks: {\n default: [];\n };\n}\n\nclass SimpleTableColumn extends Component<SimpleTableColumnSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky\n ? (this.args.stickyPosition as 'left' | 'right') || 'left'\n : undefined,\n class: this.args.class\n };\n\n return this.styles.th(options);\n }\n\n <template>\n <th data-part=\"th\" scope=\"col\" class={{this.classNames}} ...attributes>\n {{yield}}\n </th>\n </template>\n}\n\nexport { SimpleTableColumn, type SimpleTableColumnSignature };\nexport default SimpleTableColumn;\n"],"names":["SimpleTableColumn","Component","styles","args","styleFns","useStyles","table","classNames","options","isSticky","stickyPosition","undefined","class","th","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AAuBA,MAAMA,0BAA0BC,SAAA,CAAU;EACxC,IAAIC,MAAAA,GAAS;AACX,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,IAAIC,YAAYC,KAAK,EAAA;AAChD,EAAA;EAEA,IAAIC,UAAAA,GAAa;AACf,IAAA,MAAMC,OAAA,GAAU;AACdC,MAAAA,QAAA,EAAU,IAAI,CAACN,IAAI,CAACM,QAAQ,IAAI,KAAA;AAChCC,MAAAA,cAAA,EAAgB,IAAI,CAACP,IAAI,CAACM,QAAQ,GAC7B,IAAI,CAACN,IAAI,CAACO,cAAc,IAAyB,MAAA,GAClDC,SAAA;AACJC,MAAAA,KAAA,EAAO,IAAI,CAACT,IAAI,CAACS;KACnB;AAEA,IAAA,OAAO,IAAI,CAACV,MAAM,CAACW,EAAE,CAACL,OAAA,CAAA;AACxB,EAAA;AAEA,EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,iGAAA,EAIA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -30,7 +30,7 @@ class SimpleTableFooter extends Component {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
static {
|
|
33
|
-
setComponentTemplate(precompileTemplate("<tfoot class={{this.classNames}}
|
|
33
|
+
setComponentTemplate(precompileTemplate("<tfoot data-part=\"tfoot\" class={{this.classNames}} ...attributes>\n <tr data-part=\"separator\" class={{this.separatorClassNames}} />\n <tr data-part=\"tr\" class={{this.rowClassNames}}>\n {{yield (hash Column=SimpleTableColumn)}}\n </tr>\n</tfoot>", {
|
|
34
34
|
strictMode: true,
|
|
35
35
|
scope: () => ({
|
|
36
36
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sources":["../../../../src/components/collections/simple-table/footer.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableColumn } from './column';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\n\ninterface SimpleTableFooterSignature {\n Args: {\n /** Additional CSS class to apply to the footer element */\n class?: string;\n /** Whether this footer should be sticky during vertical scrolling */\n isSticky?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableSectionElement;\n Blocks: {\n default: [\n {\n Column: typeof SimpleTableColumn;\n }\n ];\n };\n}\n\nclass SimpleTableFooter extends Component<SimpleTableFooterSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky ? ('bottom' as const) : undefined,\n class: twMerge(this.args.class, this.args.classes?.tfoot)\n };\n\n return this.styles.tfoot(options);\n }\n\n get rowClassNames() {\n const options = {\n class: twMerge('', this.args.classes?.tr || ''),\n isSticky: false\n };\n return this.styles.tr(options);\n }\n\n get separatorClassNames() {\n return this.styles.separator({\n class: this.args.classes?.separator\n });\n }\n\n <template>\n <tfoot\
|
|
1
|
+
{"version":3,"file":"footer.js","sources":["../../../../src/components/collections/simple-table/footer.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableColumn } from './column';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\n\ninterface SimpleTableFooterSignature {\n Args: {\n /** Additional CSS class to apply to the footer element */\n class?: string;\n /** Whether this footer should be sticky during vertical scrolling */\n isSticky?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableSectionElement;\n Blocks: {\n default: [\n {\n Column: typeof SimpleTableColumn;\n }\n ];\n };\n}\n\nclass SimpleTableFooter extends Component<SimpleTableFooterSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky ? ('bottom' as const) : undefined,\n class: twMerge(this.args.class, this.args.classes?.tfoot)\n };\n\n return this.styles.tfoot(options);\n }\n\n get rowClassNames() {\n const options = {\n class: twMerge('', this.args.classes?.tr || ''),\n isSticky: false\n };\n return this.styles.tr(options);\n }\n\n get separatorClassNames() {\n return this.styles.separator({\n class: this.args.classes?.separator\n });\n }\n\n <template>\n <tfoot data-part=\"tfoot\" class={{this.classNames}} ...attributes>\n <tr data-part=\"separator\" class={{this.separatorClassNames}} />\n <tr data-part=\"tr\" class={{this.rowClassNames}}>\n {{yield (hash Column=SimpleTableColumn)}}\n </tr>\n </tfoot>\n </template>\n}\n\nexport { SimpleTableFooter, type SimpleTableFooterSignature };\nexport default SimpleTableFooter;\n"],"names":["SimpleTableFooter","Component","styles","args","styleFns","useStyles","table","classNames","options","isSticky","stickyPosition","undefined","class","twMerge","classes","tfoot","rowClassNames","tr","separatorClassNames","separator","setComponentTemplate","precompileTemplate","strictMode","scope","hash","SimpleTableColumn"],"mappings":";;;;;;;AAiCA,MAAMA,0BAA0BC,SAAA,CAAU;EACxC,IAAIC,MAAAA,GAAS;AACX,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,IAAIC,YAAYC,KAAK,EAAA;AAChD,EAAA;EAEA,IAAIC,UAAAA,GAAa;AACf,IAAA,MAAMC,OAAA,GAAU;AACdC,MAAAA,QAAA,EAAU,IAAI,CAACN,IAAI,CAACM,QAAQ,IAAI,KAAA;MAChCC,cAAA,EAAgB,IAAI,CAACP,IAAI,CAACM,QAAQ,GAAI,WAAqBE,SAAA;AAC3DC,MAAAA,KAAA,EAAOC,OAAA,CAAQ,IAAI,CAACV,IAAI,CAACS,KAAK,EAAE,IAAI,CAACT,IAAI,CAACW,OAAO,EAAEC,KAAA;KACrD;AAEA,IAAA,OAAO,IAAI,CAACb,MAAM,CAACa,KAAK,CAACP,OAAA,CAAA;AAC3B,EAAA;EAEA,IAAIQ,aAAAA,GAAgB;AAClB,IAAA,MAAMR,OAAA,GAAU;AACdI,MAAAA,KAAA,EAAOC,OAAA,CAAQ,IAAI,IAAI,CAACV,IAAI,CAACW,OAAO,EAAEG,EAAA,IAAM,EAAA,CAAA;AAC5CR,MAAAA,QAAA,EAAU;KACZ;AACA,IAAA,OAAO,IAAI,CAACP,MAAM,CAACe,EAAE,CAACT,OAAA,CAAA;AACxB,EAAA;EAEA,IAAIU,mBAAAA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAAChB,MAAM,CAACiB,SAAS,CAAC;AAC3BP,MAAAA,KAAA,EAAO,IAAI,CAACT,IAAI,CAACW,OAAO,EAAEK;AAC5B,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,kQAAA,EAOA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -30,7 +30,7 @@ class SimpleTableHeader extends Component {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
static {
|
|
33
|
-
setComponentTemplate(precompileTemplate("<thead class={{this.classNames}}
|
|
33
|
+
setComponentTemplate(precompileTemplate("<thead data-part=\"thead\" class={{this.classNames}} ...attributes>\n <tr data-part=\"tr\" class={{this.rowClassNames}}>\n {{yield (hash Column=SimpleTableColumn)}}\n </tr>\n <tr data-part=\"separator\" class={{this.separatorClassNames}} />\n</thead>", {
|
|
34
34
|
strictMode: true,
|
|
35
35
|
scope: () => ({
|
|
36
36
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.js","sources":["../../../../src/components/collections/simple-table/header.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableColumn } from './column';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\n\ninterface SimpleTableHeaderSignature {\n Args: {\n /** Additional CSS class to apply to the header section */\n class?: string;\n /** Whether the header should be sticky during vertical scrolling */\n isSticky?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableSectionElement;\n Blocks: {\n default: [\n {\n Column: typeof SimpleTableColumn;\n }\n ];\n };\n}\n\nclass SimpleTableHeader extends Component<SimpleTableHeaderSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky ? ('top' as const) : undefined,\n class: twMerge(this.args.class, this.args.classes?.thead)\n };\n\n return this.styles.thead(options);\n }\n\n get rowClassNames() {\n const options = {\n class: twMerge('', this.args.classes?.tr || ''),\n isSticky: false\n };\n return this.styles.tr(options);\n }\n\n get separatorClassNames() {\n return this.styles.separator({\n class: this.args.classes?.separator\n });\n }\n\n <template>\n <thead\
|
|
1
|
+
{"version":3,"file":"header.js","sources":["../../../../src/components/collections/simple-table/header.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableColumn } from './column';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\n\ninterface SimpleTableHeaderSignature {\n Args: {\n /** Additional CSS class to apply to the header section */\n class?: string;\n /** Whether the header should be sticky during vertical scrolling */\n isSticky?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableSectionElement;\n Blocks: {\n default: [\n {\n Column: typeof SimpleTableColumn;\n }\n ];\n };\n}\n\nclass SimpleTableHeader extends Component<SimpleTableHeaderSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky ? ('top' as const) : undefined,\n class: twMerge(this.args.class, this.args.classes?.thead)\n };\n\n return this.styles.thead(options);\n }\n\n get rowClassNames() {\n const options = {\n class: twMerge('', this.args.classes?.tr || ''),\n isSticky: false\n };\n return this.styles.tr(options);\n }\n\n get separatorClassNames() {\n return this.styles.separator({\n class: this.args.classes?.separator\n });\n }\n\n <template>\n <thead data-part=\"thead\" class={{this.classNames}} ...attributes>\n <tr data-part=\"tr\" class={{this.rowClassNames}}>\n {{yield (hash Column=SimpleTableColumn)}}\n </tr>\n <tr data-part=\"separator\" class={{this.separatorClassNames}} />\n </thead>\n </template>\n}\n\nexport { SimpleTableHeader, type SimpleTableHeaderSignature };\nexport default SimpleTableHeader;\n"],"names":["SimpleTableHeader","Component","styles","args","styleFns","useStyles","table","classNames","options","isSticky","stickyPosition","undefined","class","twMerge","classes","thead","rowClassNames","tr","separatorClassNames","separator","setComponentTemplate","precompileTemplate","strictMode","scope","hash","SimpleTableColumn"],"mappings":";;;;;;;AAiCA,MAAMA,0BAA0BC,SAAA,CAAU;EACxC,IAAIC,MAAAA,GAAS;AACX,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,IAAIC,YAAYC,KAAK,EAAA;AAChD,EAAA;EAEA,IAAIC,UAAAA,GAAa;AACf,IAAA,MAAMC,OAAA,GAAU;AACdC,MAAAA,QAAA,EAAU,IAAI,CAACN,IAAI,CAACM,QAAQ,IAAI,KAAA;MAChCC,cAAA,EAAgB,IAAI,CAACP,IAAI,CAACM,QAAQ,GAAI,QAAkBE,SAAA;AACxDC,MAAAA,KAAA,EAAOC,OAAA,CAAQ,IAAI,CAACV,IAAI,CAACS,KAAK,EAAE,IAAI,CAACT,IAAI,CAACW,OAAO,EAAEC,KAAA;KACrD;AAEA,IAAA,OAAO,IAAI,CAACb,MAAM,CAACa,KAAK,CAACP,OAAA,CAAA;AAC3B,EAAA;EAEA,IAAIQ,aAAAA,GAAgB;AAClB,IAAA,MAAMR,OAAA,GAAU;AACdI,MAAAA,KAAA,EAAOC,OAAA,CAAQ,IAAI,IAAI,CAACV,IAAI,CAACW,OAAO,EAAEG,EAAA,IAAM,EAAA,CAAA;AAC5CR,MAAAA,QAAA,EAAU;KACZ;AACA,IAAA,OAAO,IAAI,CAACP,MAAM,CAACe,EAAE,CAACT,OAAA,CAAA;AACxB,EAAA;EAEA,IAAIU,mBAAAA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAAChB,MAAM,CAACiB,SAAS,CAAC;AAC3BP,MAAAA,KAAA,EAAO,IAAI,CAACT,IAAI,CAACW,OAAO,EAAEK;AAC5B,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,kQAAA,EAOA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -14,6 +14,9 @@ class SimpleTable extends Component {
|
|
|
14
14
|
get hasWrapper() {
|
|
15
15
|
return this.args.hasWrapper ?? true;
|
|
16
16
|
}
|
|
17
|
+
get isRoot() {
|
|
18
|
+
return this.args.isRoot ?? true;
|
|
19
|
+
}
|
|
17
20
|
get styles() {
|
|
18
21
|
const {
|
|
19
22
|
table
|
|
@@ -26,8 +29,7 @@ class SimpleTable extends Component {
|
|
|
26
29
|
hasStickyHeader: false,
|
|
27
30
|
isLoading: this.args.hasCustomLoading ? false : this.args.isLoading || false,
|
|
28
31
|
loadingColor: this.args.loadingColor,
|
|
29
|
-
selectionColor: this.args.selectionColor
|
|
30
|
-
class: this.args.classes?.base
|
|
32
|
+
selectionColor: this.args.selectionColor
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
get wrapperClassNames() {
|
|
@@ -41,7 +43,7 @@ class SimpleTable extends Component {
|
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
static {
|
|
44
|
-
setComponentTemplate(precompileTemplate("{{#if this.hasWrapper}}\n <div class={{this.wrapperClassNames}}
|
|
46
|
+
setComponentTemplate(precompileTemplate("{{#if this.hasWrapper}}\n <div data-part=\"wrapper\" class={{this.wrapperClassNames}}>\n <table data-component={{if this.isRoot \"table\"}} data-part=\"table\" class={{this.tableClassNames}} data-loading={{if this.args.isLoading \"true\" \"false\"}} ...attributes>\n {{yield (hash Header=(component SimpleTableHeader styleFns=this.styles classes=this.args.classes) Body=(component SimpleTableBody styleFns=this.styles classes=this.args.classes) Footer=(component SimpleTableFooter styleFns=this.styles classes=this.args.classes) Column=(component SimpleTableColumn styleFns=this.styles) Row=(component SimpleTableRow styleFns=this.styles classes=this.args.classes) Cell=(component SimpleTableCell styleFns=this.styles classes=this.args.classes))}}\n </table>\n </div>\n{{else}}\n <table data-component={{if this.isRoot \"table\"}} data-part=\"table\" class={{this.tableClassNames}} data-loading={{if this.args.isLoading \"true\" \"false\"}} ...attributes>\n {{yield (hash Header=(component SimpleTableHeader styleFns=this.styles classes=this.args.classes) Body=(component SimpleTableBody styleFns=this.styles classes=this.args.classes) Footer=(component SimpleTableFooter styleFns=this.styles classes=this.args.classes) Column=(component SimpleTableColumn styleFns=this.styles) Row=(component SimpleTableRow styleFns=this.styles classes=this.args.classes) Cell=(component SimpleTableCell styleFns=this.styles classes=this.args.classes))}}\n </table>\n{{/if}}", {
|
|
45
47
|
strictMode: true,
|
|
46
48
|
scope: () => ({
|
|
47
49
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/collections/simple-table/index.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles } from '@frontile/theme';\nimport { SimpleTableHeader, type SimpleTableHeaderSignature } from './header';\nimport { SimpleTableBody, type SimpleTableBodySignature } from './body';\nimport { SimpleTableFooter, type SimpleTableFooterSignature } from './footer';\nimport { SimpleTableColumn, type SimpleTableColumnSignature } from './column';\nimport { SimpleTableRow, type SimpleTableRowSignature } from './row';\nimport { SimpleTableCell, type SimpleTableCellSignature } from './cell';\n\nimport type { TableVariants, TableSlots, SlotsToClasses } from '../table/types';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\n\ninterface SimpleTableSignature {\n Args: {\n /** Custom CSS classes for different table elements (wrapper, table, th, td, etc.) */\n classes?: SlotsToClasses<TableSlots>;\n /** Size variant for table cells and headers. @defaultValue 'md' */\n size?: TableVariants['size'];\n /** Table layout algorithm - 'auto' sizes columns by content, 'fixed' uses first row for sizing. @defaultValue 'auto' */\n layout?: TableVariants['layout'];\n /** Enable striped rows (alternating background colors) */\n isStriped?: TableVariants['striped'];\n /** Enable scrolling for the table container */\n isScrollable?: boolean;\n /** Whether to render the wrapper div. @defaultValue true */\n hasWrapper?: boolean;\n /** Enable loading state styling and behavior */\n isLoading?: boolean;\n /** Color variant for loading animation. @defaultValue 'default' */\n loadingColor?: TableVariants['loadingColor'];\n /** Color variant for selection highlight. @defaultValue 'primary' */\n selectionColor?: TableVariants['selectionColor'];\n /** Whether a custom loading block is provided (disables CSS loading indicator) */\n hasCustomLoading?: boolean;\n };\n Element: HTMLTableElement;\n Blocks: {\n default: [\n {\n Header: WithBoundArgs<\n ComponentLike<SimpleTableHeaderSignature>,\n 'styleFns' | 'classes'\n >;\n Body: WithBoundArgs<\n ComponentLike<SimpleTableBodySignature>,\n 'styleFns' | 'classes'\n >;\n Footer: WithBoundArgs<\n ComponentLike<SimpleTableFooterSignature>,\n 'styleFns' | 'classes'\n >;\n Column: WithBoundArgs<\n ComponentLike<SimpleTableColumnSignature>,\n 'styleFns'\n >;\n Row: WithBoundArgs<\n ComponentLike<SimpleTableRowSignature>,\n 'styleFns' | 'classes'\n >;\n Cell: WithBoundArgs<\n ComponentLike<SimpleTableCellSignature>,\n 'styleFns' | 'classes'\n >;\n }\n ];\n };\n}\n\nclass SimpleTable extends Component<SimpleTableSignature> {\n get hasWrapper() {\n return this.args.hasWrapper ?? true;\n }\n\n get styles() {\n const { table } = useStyles();\n return table({\n size: this.args.size,\n layout: this.args.layout,\n striped: this.args.isStriped,\n isScrollable: this.args.isScrollable || false,\n hasStickyHeader: false, // Will be determined by header component\n isLoading: this.args.hasCustomLoading\n ? false\n : this.args.isLoading || false,\n loadingColor: this.args.loadingColor,\n selectionColor: this.args.selectionColor
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/collections/simple-table/index.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles } from '@frontile/theme';\nimport { SimpleTableHeader, type SimpleTableHeaderSignature } from './header';\nimport { SimpleTableBody, type SimpleTableBodySignature } from './body';\nimport { SimpleTableFooter, type SimpleTableFooterSignature } from './footer';\nimport { SimpleTableColumn, type SimpleTableColumnSignature } from './column';\nimport { SimpleTableRow, type SimpleTableRowSignature } from './row';\nimport { SimpleTableCell, type SimpleTableCellSignature } from './cell';\n\nimport type { TableVariants, TableSlots, SlotsToClasses } from '../table/types';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\n\ninterface SimpleTableSignature {\n Args: {\n /** Custom CSS classes for different table elements (wrapper, table, th, td, etc.) */\n classes?: SlotsToClasses<TableSlots>;\n /** Size variant for table cells and headers. @defaultValue 'md' */\n size?: TableVariants['size'];\n /** Table layout algorithm - 'auto' sizes columns by content, 'fixed' uses first row for sizing. @defaultValue 'auto' */\n layout?: TableVariants['layout'];\n /** Enable striped rows (alternating background colors) */\n isStriped?: TableVariants['striped'];\n /** Enable scrolling for the table container */\n isScrollable?: boolean;\n /** Whether to render the wrapper div. @defaultValue true */\n hasWrapper?: boolean;\n /** Enable loading state styling and behavior */\n isLoading?: boolean;\n /** Color variant for loading animation. @defaultValue 'default' */\n loadingColor?: TableVariants['loadingColor'];\n /** Color variant for selection highlight. @defaultValue 'primary' */\n selectionColor?: TableVariants['selectionColor'];\n /** Whether a custom loading block is provided (disables CSS loading indicator) */\n hasCustomLoading?: boolean;\n /**\n * @internal Whether this instance owns the \"table\" anatomy root\n * (`data-component=\"table\"`). Defaults to `true` for standalone/public\n * usage. `Table` sets this to `false` when it composes `SimpleTable`\n * internally, since `Table`'s own outer wrapper is already the anatomy\n * root for that combined instance -- without this, the `<table>` element\n * rendered here would be a second, nested `data-component=\"table\"`\n * inside Table's own root, breaking the one-root-per-instance contract.\n * @ignore\n */\n isRoot?: boolean;\n };\n Element: HTMLTableElement;\n Blocks: {\n default: [\n {\n Header: WithBoundArgs<\n ComponentLike<SimpleTableHeaderSignature>,\n 'styleFns' | 'classes'\n >;\n Body: WithBoundArgs<\n ComponentLike<SimpleTableBodySignature>,\n 'styleFns' | 'classes'\n >;\n Footer: WithBoundArgs<\n ComponentLike<SimpleTableFooterSignature>,\n 'styleFns' | 'classes'\n >;\n Column: WithBoundArgs<\n ComponentLike<SimpleTableColumnSignature>,\n 'styleFns'\n >;\n Row: WithBoundArgs<\n ComponentLike<SimpleTableRowSignature>,\n 'styleFns' | 'classes'\n >;\n Cell: WithBoundArgs<\n ComponentLike<SimpleTableCellSignature>,\n 'styleFns' | 'classes'\n >;\n }\n ];\n };\n}\n\nclass SimpleTable extends Component<SimpleTableSignature> {\n get hasWrapper() {\n return this.args.hasWrapper ?? true;\n }\n\n get isRoot() {\n return this.args.isRoot ?? true;\n }\n\n get styles() {\n const { table } = useStyles();\n return table({\n size: this.args.size,\n layout: this.args.layout,\n striped: this.args.isStriped,\n isScrollable: this.args.isScrollable || false,\n hasStickyHeader: false, // Will be determined by header component\n isLoading: this.args.hasCustomLoading\n ? false\n : this.args.isLoading || false,\n loadingColor: this.args.loadingColor,\n selectionColor: this.args.selectionColor\n // No `class: this.args.classes?.base` here: `table` has no `base`\n // slot (deleted -- it was never rendered by anything, see\n // packages/theme/src/components/table.ts), so passing a class here\n // was already a no-op.\n });\n }\n\n get wrapperClassNames() {\n return this.styles.wrapper({\n class: this.args.classes?.wrapper\n });\n }\n\n get tableClassNames() {\n return this.styles.table({ class: this.args.classes?.table });\n }\n\n <template>\n {{#if this.hasWrapper}}\n <div data-part=\"wrapper\" class={{this.wrapperClassNames}}>\n <table\n data-component={{if this.isRoot \"table\"}}\n data-part=\"table\"\n class={{this.tableClassNames}}\n data-loading={{if this.args.isLoading \"true\" \"false\"}}\n ...attributes\n >\n {{yield\n (hash\n Header=(component\n SimpleTableHeader styleFns=this.styles classes=this.args.classes\n )\n Body=(component\n SimpleTableBody styleFns=this.styles classes=this.args.classes\n )\n Footer=(component\n SimpleTableFooter styleFns=this.styles classes=this.args.classes\n )\n Column=(component SimpleTableColumn styleFns=this.styles)\n Row=(component\n SimpleTableRow styleFns=this.styles classes=this.args.classes\n )\n Cell=(component\n SimpleTableCell styleFns=this.styles classes=this.args.classes\n )\n )\n }}\n </table>\n </div>\n {{else}}\n <table\n data-component={{if this.isRoot \"table\"}}\n data-part=\"table\"\n class={{this.tableClassNames}}\n data-loading={{if this.args.isLoading \"true\" \"false\"}}\n ...attributes\n >\n {{yield\n (hash\n Header=(component\n SimpleTableHeader styleFns=this.styles classes=this.args.classes\n )\n Body=(component\n SimpleTableBody styleFns=this.styles classes=this.args.classes\n )\n Footer=(component\n SimpleTableFooter styleFns=this.styles classes=this.args.classes\n )\n Column=(component SimpleTableColumn styleFns=this.styles)\n Row=(component\n SimpleTableRow styleFns=this.styles classes=this.args.classes\n )\n Cell=(component\n SimpleTableCell styleFns=this.styles classes=this.args.classes\n )\n )\n }}\n </table>\n {{/if}}\n </template>\n}\n\nexport { SimpleTable, type SimpleTableSignature };\nexport default SimpleTable;\n"],"names":["SimpleTable","Component","hasWrapper","args","isRoot","styles","table","useStyles","size","layout","striped","isStriped","isScrollable","hasStickyHeader","isLoading","hasCustomLoading","loadingColor","selectionColor","wrapperClassNames","wrapper","class","classes","tableClassNames","setComponentTemplate","precompileTemplate","strictMode","scope","hash","SimpleTableHeader","SimpleTableBody","SimpleTableFooter","SimpleTableColumn","SimpleTableRow","SimpleTableCell"],"mappings":";;;;;;;;;;;;AAgFA,MAAMA,oBAAoBC,SAAA,CAAU;EAClC,IAAIC,UAAAA,GAAa;AACf,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,UAAU,IAAI,IAAA;AACjC,EAAA;EAEA,IAAIE,MAAAA,GAAS;AACX,IAAA,OAAO,IAAI,CAACD,IAAI,CAACC,MAAM,IAAI,IAAA;AAC7B,EAAA;EAEA,IAAIC,MAAAA,GAAS;IACX,MAAM;AAAEC,MAAAA;KAAO,GAAGC,SAAA,EAAA;AAClB,IAAA,OAAOD,KAAA,CAAM;AACXE,MAAAA,IAAA,EAAM,IAAI,CAACL,IAAI,CAACK,IAAI;AACpBC,MAAAA,MAAA,EAAQ,IAAI,CAACN,IAAI,CAACM,MAAM;AACxBC,MAAAA,OAAA,EAAS,IAAI,CAACP,IAAI,CAACQ,SAAS;AAC5BC,MAAAA,YAAA,EAAc,IAAI,CAACT,IAAI,CAACS,YAAY,IAAI,KAAA;AACxCC,MAAAA,eAAA,EAAiB,KAAA;AACjBC,MAAAA,SAAA,EAAW,IAAI,CAACX,IAAI,CAACY,gBAAgB,GACjC,KAAA,GACA,IAAI,CAACZ,IAAI,CAACW,SAAS,IAAI,KAAA;AAC3BE,MAAAA,YAAA,EAAc,IAAI,CAACb,IAAI,CAACa,YAAY;AACpCC,MAAAA,cAAA,EAAgB,IAAI,CAACd,IAAI,CAACc;AAK5B,KAAA,CAAA;AACF,EAAA;EAEA,IAAIC,iBAAAA,GAAoB;AACtB,IAAA,OAAO,IAAI,CAACb,MAAM,CAACc,OAAO,CAAC;AACzBC,MAAAA,KAAA,EAAO,IAAI,CAACjB,IAAI,CAACkB,OAAO,EAAEF;AAC5B,KAAA,CAAA;AACF,EAAA;EAEA,IAAIG,eAAAA,GAAkB;AACpB,IAAA,OAAO,IAAI,CAACjB,MAAM,CAACC,KAAK,CAAC;AAAEc,MAAAA,KAAA,EAAO,IAAI,CAACjB,IAAI,CAACkB,OAAO,EAAEf;AAAM,KAAA,CAAA;AAC7D,EAAA;AAEA,EAAA;IAAAiB,oBAAA,CAAAC,kBAAA,CAAA,s8CAAA,EA8DA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;QAAAC,iBAAA;QAAAC,eAAA;QAAAC,iBAAA;QAAAC,iBAAA;QAAAC,cAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -19,7 +19,7 @@ class SimpleTableRow extends Component {
|
|
|
19
19
|
return this.styles.tr(options);
|
|
20
20
|
}
|
|
21
21
|
static {
|
|
22
|
-
setComponentTemplate(precompileTemplate("<tr class={{this.classNames}}
|
|
22
|
+
setComponentTemplate(precompileTemplate("<tr data-part=\"tr\" class={{this.classNames}} ...attributes>\n {{yield (hash Cell=(component SimpleTableCell styleFns=this.styles classes=@classes))}}\n</tr>", {
|
|
23
23
|
strictMode: true,
|
|
24
24
|
scope: () => ({
|
|
25
25
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.js","sources":["../../../../src/components/collections/simple-table/row.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableCell } from './cell';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface SimpleTableRowSignature {\n Args: {\n /** Additional CSS class to apply to the row */\n class?: string;\n /** Whether this row should be sticky during vertical scrolling */\n isSticky?: boolean;\n /** Whether the table has a sticky header (affects positioning of sticky rows) */\n hasStickyHeader?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableRowElement;\n Blocks: {\n default: [\n {\n Cell: WithBoundArgs<typeof SimpleTableCell, 'styleFns' | 'classes'>;\n }\n ];\n };\n}\n\nclass SimpleTableRow extends Component<SimpleTableRowSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky ? ('top' as const) : undefined,\n hasStickyHeader: this.args.hasStickyHeader || false,\n class: twMerge(this.args.class || '', this.args.classes?.tr || '')\n };\n\n return this.styles.tr(options);\n }\n\n <template>\n <tr\
|
|
1
|
+
{"version":3,"file":"row.js","sources":["../../../../src/components/collections/simple-table/row.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles, twMerge } from '@frontile/theme';\nimport { SimpleTableCell } from './cell';\nimport type { SlotsToClasses, TableSlots } from '../table/types';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface SimpleTableRowSignature {\n Args: {\n /** Additional CSS class to apply to the row */\n class?: string;\n /** Whether this row should be sticky during vertical scrolling */\n isSticky?: boolean;\n /** Whether the table has a sticky header (affects positioning of sticky rows) */\n hasStickyHeader?: boolean;\n /**\n * @internal Style functions object from SimpleTable component\n * @ignore\n */\n styleFns?: ReturnType<ReturnType<typeof useStyles>['table']>;\n /**\n * @internal Classes object from SimpleTable component\n * @ignore\n */\n classes?: SlotsToClasses<TableSlots>;\n };\n Element: HTMLTableRowElement;\n Blocks: {\n default: [\n {\n Cell: WithBoundArgs<typeof SimpleTableCell, 'styleFns' | 'classes'>;\n }\n ];\n };\n}\n\nclass SimpleTableRow extends Component<SimpleTableRowSignature> {\n get styles() {\n return this.args.styleFns || useStyles().table();\n }\n\n get classNames() {\n const options = {\n isSticky: this.args.isSticky || false,\n stickyPosition: this.args.isSticky ? ('top' as const) : undefined,\n hasStickyHeader: this.args.hasStickyHeader || false,\n class: twMerge(this.args.class || '', this.args.classes?.tr || '')\n };\n\n return this.styles.tr(options);\n }\n\n <template>\n <tr data-part=\"tr\" class={{this.classNames}} ...attributes>\n {{yield\n (hash\n Cell=(component SimpleTableCell styleFns=this.styles classes=@classes)\n )\n }}\n </tr>\n </template>\n}\n\nexport { SimpleTableRow, type SimpleTableRowSignature };\nexport default SimpleTableRow;\n"],"names":["SimpleTableRow","Component","styles","args","styleFns","useStyles","table","classNames","options","isSticky","stickyPosition","undefined","hasStickyHeader","class","twMerge","classes","tr","setComponentTemplate","precompileTemplate","strictMode","scope","hash","SimpleTableCell"],"mappings":";;;;;;;AAoCA,MAAMA,uBAAuBC,SAAA,CAAU;EACrC,IAAIC,MAAAA,GAAS;AACX,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,IAAIC,YAAYC,KAAK,EAAA;AAChD,EAAA;EAEA,IAAIC,UAAAA,GAAa;AACf,IAAA,MAAMC,OAAA,GAAU;AACdC,MAAAA,QAAA,EAAU,IAAI,CAACN,IAAI,CAACM,QAAQ,IAAI,KAAA;MAChCC,cAAA,EAAgB,IAAI,CAACP,IAAI,CAACM,QAAQ,GAAI,QAAkBE,SAAA;AACxDC,MAAAA,eAAA,EAAiB,IAAI,CAACT,IAAI,CAACS,eAAe,IAAI,KAAA;AAC9CC,MAAAA,KAAA,EAAOC,OAAA,CAAQ,IAAI,CAACX,IAAI,CAACU,KAAK,IAAI,EAAA,EAAI,IAAI,CAACV,IAAI,CAACY,OAAO,EAAEC,EAAA,IAAM,EAAA;KACjE;AAEA,IAAA,OAAO,IAAI,CAACd,MAAM,CAACc,EAAE,CAACR,OAAA,CAAA;AACxB,EAAA;AAEA,EAAA;IAAAS,oBAAA,CAAAC,kBAAA,CAAA,iKAAA,EAQA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|