@frontile/collections 0.18.0-alpha.2 → 0.18.0-alpha.20

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.
Files changed (52) hide show
  1. package/declarations/index.d.ts +1 -3
  2. package/declarations/template-registry.d.ts +1 -7
  3. package/dist/index.js +13 -3
  4. package/dist/index.js.map +1 -1
  5. package/package.json +14 -23
  6. package/declarations/components/dropdown.d.ts +0 -99
  7. package/declarations/components/listbox/item.d.ts +0 -51
  8. package/declarations/components/listbox/listbox.d.ts +0 -75
  9. package/declarations/components/listbox.d.ts +0 -2
  10. package/declarations/components/simple-table/body.d.ts +0 -428
  11. package/declarations/components/simple-table/cell.d.ts +0 -427
  12. package/declarations/components/simple-table/column.d.ts +0 -419
  13. package/declarations/components/simple-table/footer.d.ts +0 -430
  14. package/declarations/components/simple-table/header.d.ts +0 -430
  15. package/declarations/components/simple-table/index.d.ts +0 -446
  16. package/declarations/components/simple-table/row.d.ts +0 -430
  17. package/declarations/components/table/cell-default.d.ts +0 -43
  18. package/declarations/components/table/cell-for.d.ts +0 -38
  19. package/declarations/components/table/cell-rendering-context.d.ts +0 -24
  20. package/declarations/components/table/checkbox.d.ts +0 -50
  21. package/declarations/components/table/column-visibility.d.ts +0 -416
  22. package/declarations/components/table/icons.d.ts +0 -11
  23. package/declarations/components/table/index.d.ts +0 -4
  24. package/declarations/components/table/sort-button.d.ts +0 -413
  25. package/declarations/components/table/table.d.ts +0 -555
  26. package/declarations/components/table/types.d.ts +0 -46
  27. package/declarations/components/table/utils.d.ts +0 -6
  28. package/declarations/components/table.d.ts +0 -2
  29. package/declarations/utils/listManager.d.ts +0 -74
  30. package/dist/_app_/components/dropdown.js +0 -1
  31. package/dist/_app_/components/listbox.js +0 -1
  32. package/dist/_app_/components/table.js +0 -1
  33. package/dist/components/dropdown.js +0 -94
  34. package/dist/components/dropdown.js.map +0 -1
  35. package/dist/components/listbox.js +0 -2
  36. package/dist/components/listbox.js.map +0 -1
  37. package/dist/components/table.js +0 -2
  38. package/dist/components/table.js.map +0 -1
  39. package/dist/listManager-CKsOd2zS.js +0 -438
  40. package/dist/listManager-CKsOd2zS.js.map +0 -1
  41. package/dist/listbox-CkGwpiDp.js +0 -203
  42. package/dist/listbox-CkGwpiDp.js.map +0 -1
  43. package/dist/listbox-Czwb-jUT.js +0 -203
  44. package/dist/listbox-Czwb-jUT.js.map +0 -1
  45. package/dist/table-3uScDwoD.js +0 -877
  46. package/dist/table-3uScDwoD.js.map +0 -1
  47. package/dist/table-DvivyvLm.js +0 -877
  48. package/dist/table-DvivyvLm.js.map +0 -1
  49. package/dist/table-SVR6fEqh.js +0 -877
  50. package/dist/table-SVR6fEqh.js.map +0 -1
  51. package/dist/utils/listManager.js +0 -5
  52. package/dist/utils/listManager.js.map +0 -1
@@ -1,74 +0,0 @@
1
- type SelectionMode = 'none' | 'single' | 'multiple';
2
- type AutoActivateMode = 'none' | 'first' | 'selected';
3
- interface ListItemArgs {
4
- key: string;
5
- textValue?: string;
6
- isSelected?: boolean;
7
- isDisabled?: boolean;
8
- isActive?: boolean;
9
- }
10
- declare class ListItem {
11
- el: HTMLLIElement | HTMLOptionElement;
12
- key: string;
13
- textValue: string;
14
- isSelected: boolean;
15
- isDisabled: boolean;
16
- isActive: boolean;
17
- constructor(el: HTMLLIElement | HTMLOptionElement, args: Required<ListItemArgs>);
18
- }
19
- interface ListManagerArgs {
20
- selectionMode?: SelectionMode;
21
- selectedKeys?: string[];
22
- disabledKeys?: string[];
23
- allowEmpty?: boolean;
24
- autoActivateMode?: AutoActivateMode;
25
- onAction?: (key: string) => void;
26
- onSelectionChange?: (key: string[]) => void;
27
- onListItemsChange?: (items: ListItem[], action: 'add' | 'remove') => void;
28
- onActiveItemChange?: (key?: string) => void;
29
- }
30
- declare class ListManager {
31
- #private;
32
- searchKeys: string;
33
- args: ListManagerArgs;
34
- constructor(args?: ListManagerArgs);
35
- register(el: HTMLLIElement | HTMLOptionElement, args: Required<ListItemArgs>): void;
36
- unregister(el: HTMLLIElement | HTMLOptionElement): void;
37
- at(el?: HTMLLIElement | HTMLOptionElement): ListItem | undefined;
38
- atKey(key: string): ListItem | undefined;
39
- updateArgs(args: ListManagerArgs): void;
40
- selectActiveItem(): void;
41
- selectItem(item?: ListItem): void;
42
- activateItem(item?: ListItem): void;
43
- setNextOptionActive(): void;
44
- setPreviousOptionActive(): void;
45
- setFirstOptionActive(): void;
46
- setSelectedOptionActive(): void;
47
- setLastOptionActive(): void;
48
- search(key: string): void;
49
- isKeyDisabled(key: string): boolean;
50
- isKeySelected(key: string): boolean;
51
- setup: import("ember-modifier").FunctionBasedModifier<{
52
- Args: {
53
- Positional: unknown[];
54
- Named: ListManagerArgs;
55
- };
56
- Element: HTMLUListElement | HTMLSelectElement;
57
- }>;
58
- setupItem: import("ember-modifier").FunctionBasedModifier<{
59
- Args: {
60
- Positional: unknown[];
61
- Named: Pick<ListItemArgs, "key" | "textValue"> & {
62
- onRegister?: (item: ListItem) => void;
63
- disableEvents?: boolean;
64
- };
65
- };
66
- Element: HTMLLIElement | HTMLOptionElement;
67
- }>;
68
- }
69
- declare function keyAndLabelForItem(item: unknown): {
70
- key: string;
71
- label: string;
72
- };
73
- export type { ListItem, ListItemArgs, SelectionMode, AutoActivateMode };
74
- export { ListManager, keyAndLabelForItem };
@@ -1 +0,0 @@
1
- export { default } from "@frontile/collections/components/dropdown";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/collections/components/listbox";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/collections/components/table";
@@ -1,94 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { Button } from '@frontile/buttons';
3
- import { L as Listbox } from '../listbox-Czwb-jUT.js';
4
- import { Popover } from '@frontile/overlays';
5
- import { assert } from '@ember/debug';
6
- import { hash } from '@ember/helper';
7
- import { on } from '@ember/modifier';
8
- import { useStyles } from '@frontile/theme';
9
- import { precompileTemplate } from '@ember/template-compilation';
10
- import { setComponentTemplate } from '@ember/component';
11
-
12
- class Dropdown extends Component {
13
- static {
14
- setComponentTemplate(precompileTemplate("\n <Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{@didClose}} as |p|>\n {{yield (hash Trigger=(component Trigger anchor=p.anchor trigger=p.trigger toggle=p.toggle) Menu=(component Menu Content=p.Content toggle=p.toggle closeOnItemSelect=@closeOnItemSelect))}}\n </Popover>\n ", {
15
- strictMode: true,
16
- scope: () => ({
17
- Popover,
18
- hash,
19
- Trigger,
20
- Menu
21
- })
22
- }), this);
23
- }
24
- }
25
- class Trigger extends Component {
26
- get anchor() {
27
- assert(`Dropdown Trigger does not have anchor modifier; Missing argument @anchor`, this.args.anchor);
28
- return this.args.anchor;
29
- }
30
- get trigger() {
31
- assert(`Dropdown Trigger does not have trigger modifier; Missing argument @trigger`, this.args.trigger);
32
- return this.args.trigger;
33
- }
34
- handleKeyDown = event => {
35
- if (['ArrowUp', 'ArrowDown'].includes(event.key)) {
36
- event.preventDefault();
37
- }
38
- };
39
- handleKeyUp = event => {
40
- if (event.key === 'ArrowDown' || event.key == 'ArrowUp') {
41
- this.args.toggle();
42
- }
43
- };
44
- static {
45
- setComponentTemplate(precompileTemplate("\n <Button {{this.trigger}} {{this.anchor}} {{on \"keydown\" this.handleKeyDown}} {{on \"keyup\" this.handleKeyUp}} @type=\"button\" @appearance={{@appearance}} @intent={{@intent}} @size={{@size}} @class={{@class}} @isInGroup={{@isInGroup}} data-test-id=\"dropdown-trigger\" ...attributes>\n {{yield}}\n </Button>\n ", {
46
- strictMode: true,
47
- scope: () => ({
48
- Button,
49
- on
50
- })
51
- }), this);
52
- }
53
- }
54
- class Menu extends Component {
55
- get classNames() {
56
- const {
57
- dropdownContent
58
- } = useStyles();
59
- return dropdownContent({
60
- class: this.args.class
61
- });
62
- }
63
- onAction = key => {
64
- if (typeof this.args.onAction === 'function') {
65
- this.args.onAction(key);
66
- }
67
- if (typeof this.args.toggle === 'function' && this.args.closeOnItemSelect !== false) {
68
- this.args.toggle();
69
- }
70
- };
71
- get blockScroll() {
72
- if (this.args.blockScroll === false) {
73
- return false;
74
- }
75
- return true;
76
- }
77
- get disableFocusTrap() {
78
- if (this.args.disableFocusTrap === true) {
79
- return true;
80
- }
81
- return false;
82
- }
83
- static {
84
- setComponentTemplate(precompileTemplate("\n <@Content @target={{@target}} @renderInPlace={{@renderInPlace}} @disableFocusTrap={{this.disableFocusTrap}} @blockScroll={{this.blockScroll}} @transitionDuration={{@transitionDuration}} @backdrop={{@backdrop}} @disableTransitions={{@disableTransitions}} @focusTrapOptions={{@focusTrapOptions}} @closeOnOutsideClick={{@closeOnOutsideClick}} @closeOnEscapeKey={{@closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{@transition}}>\n <Listbox @allowEmpty={{@allowEmpty}} @appearance={{@appearance}} @disabledKeys={{@disabledKeys}} @intent={{@intent}} @isKeyboardEventsEnabled={{true}} @onAction={{this.onAction}} @onSelectionChange={{@onSelectionChange}} @selectedKeys={{@selectedKeys}} @selectionMode={{if @selectionMode @selectionMode \"none\"}} @type=\"menu\" @autoActivateMode=\"none\" ...attributes as |l|>\n {{yield (component l.Item)}}\n </Listbox>\n </@Content>\n ", {
85
- strictMode: true,
86
- scope: () => ({
87
- Listbox
88
- })
89
- }), this);
90
- }
91
- }
92
-
93
- export { Dropdown, Dropdown as default };
94
- //# sourceMappingURL=dropdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dropdown.js","sources":["../../src/components/dropdown.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { Button, type ButtonSignature } from '@frontile/buttons';\nimport { Listbox, type ListboxSignature } from './listbox';\nimport {\n Popover,\n type PopoverSignature,\n type ContentSignature\n} from '@frontile/overlays';\nimport { assert } from '@ember/debug';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport type { ModifierLike } from '@glint/template';\nimport type { ListboxItem } from './listbox/item';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface DropdownArgs\n extends Pick<\n PopoverSignature['Args'],\n | 'placement'\n | 'flipOptions'\n | 'middleware'\n | 'shiftOptions'\n | 'offsetOptions'\n | 'strategy'\n | 'didClose'\n > {\n /**\n * Whether the dropdown should close upon selecting an item.\n *\n * @defaultValue true\n */\n closeOnItemSelect?: boolean;\n}\n\ninterface DropdownSignature {\n Args: DropdownArgs;\n Element: HTMLUListElement;\n Blocks: {\n default: [\n {\n Trigger: WithBoundArgs<typeof Trigger, 'anchor' | 'toggle' | 'trigger'>;\n Menu: WithBoundArgs<\n typeof Menu,\n 'toggle' | 'Content' | 'closeOnItemSelect'\n >;\n }\n ];\n };\n}\n\nclass Dropdown extends Component<DropdownSignature> {\n <template>\n <Popover\n @placement={{@placement}}\n @flipOptions={{@flipOptions}}\n @middleware={{@middleware}}\n @shiftOptions={{@shiftOptions}}\n @offsetOptions={{@offsetOptions}}\n @strategy={{@strategy}}\n @didClose={{@didClose}}\n as |p|\n >\n {{yield\n (hash\n Trigger=(component\n Trigger anchor=p.anchor trigger=p.trigger toggle=p.toggle\n )\n Menu=(component\n Menu\n Content=p.Content\n toggle=p.toggle\n closeOnItemSelect=@closeOnItemSelect\n )\n )\n }}\n </Popover>\n </template>\n}\n\ninterface TriggerArgs\n extends Pick<\n ButtonSignature['Args'],\n 'appearance' | 'intent' | 'size' | 'isInGroup' | 'class'\n > {\n /**\n * @internal\n */\n anchor: ModifierLike<{ Element: HTMLElement }>;\n trigger: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * @internal\n */\n toggle: () => void;\n}\n\nexport interface TriggerSignature {\n Args: TriggerArgs;\n Element: HTMLButtonElement;\n Blocks: {\n default: [];\n };\n}\n\nclass Trigger extends Component<TriggerSignature> {\n get anchor() {\n assert(\n `Dropdown Trigger does not have anchor modifier; Missing argument @anchor`,\n this.args.anchor\n );\n return this.args.anchor;\n }\n get trigger() {\n assert(\n `Dropdown Trigger does not have trigger modifier; Missing argument @trigger`,\n this.args.trigger\n );\n return this.args.trigger;\n }\n\n handleKeyDown = (event: KeyboardEvent) => {\n if (['ArrowUp', 'ArrowDown'].includes(event.key)) {\n event.preventDefault();\n }\n };\n\n handleKeyUp = (event: KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key == 'ArrowUp') {\n this.args.toggle();\n }\n };\n\n <template>\n <Button\n {{this.trigger}}\n {{this.anchor}}\n {{on \"keydown\" this.handleKeyDown}}\n {{on \"keyup\" this.handleKeyUp}}\n @type=\"button\"\n @appearance={{@appearance}}\n @intent={{@intent}}\n @size={{@size}}\n @class={{@class}}\n @isInGroup={{@isInGroup}}\n data-test-id=\"dropdown-trigger\"\n ...attributes\n >\n {{yield}}\n </Button>\n </template>\n}\n\ninterface MenuArgs\n extends Pick<\n ListboxSignature<unknown>['Args'],\n | 'appearance'\n | 'intent'\n | 'class'\n | 'selectionMode'\n | 'selectedKeys'\n | 'disabledKeys'\n | 'allowEmpty'\n | 'onSelectionChange'\n >,\n Pick<\n ContentSignature['Args'],\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n | 'transition'\n > {\n /**\n * @internal\n */\n closeOnItemSelect?: boolean;\n\n /**\n * @internal\n */\n Content: PopoverSignature['Blocks']['default'][0]['Content'];\n\n /**\n * @internal\n */\n toggle: () => void;\n\n onAction?: (key: string) => void;\n\n /**\n * @defaultValue true\n */\n blockScroll?: boolean;\n\n /**\n * @defaultValue false\n */\n disableFocusTrap?: boolean;\n}\n\nexport interface MenuSignature {\n Args: MenuArgs;\n Element: HTMLUListElement;\n Blocks: { default: [item: WithBoundArgs<typeof ListboxItem, 'manager'>] };\n}\n\nclass Menu extends Component<MenuSignature> {\n get classNames() {\n const { dropdownContent } = useStyles();\n return dropdownContent({ class: this.args.class });\n }\n\n onAction = (key: string) => {\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(key);\n }\n\n if (\n typeof this.args.toggle === 'function' &&\n this.args.closeOnItemSelect !== false\n ) {\n this.args.toggle();\n }\n };\n\n get blockScroll() {\n if (this.args.blockScroll === false) {\n return false;\n }\n return true;\n }\n\n get disableFocusTrap() {\n if (this.args.disableFocusTrap === true) {\n return true;\n }\n return false;\n }\n\n <template>\n <@Content\n @target={{@target}}\n @renderInPlace={{@renderInPlace}}\n @disableFocusTrap={{this.disableFocusTrap}}\n @blockScroll={{this.blockScroll}}\n @transitionDuration={{@transitionDuration}}\n @backdrop={{@backdrop}}\n @disableTransitions={{@disableTransitions}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{@closeOnOutsideClick}}\n @closeOnEscapeKey={{@closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{@transition}}\n >\n <Listbox\n @allowEmpty={{@allowEmpty}}\n @appearance={{@appearance}}\n @disabledKeys={{@disabledKeys}}\n @intent={{@intent}}\n @isKeyboardEventsEnabled={{true}}\n @onAction={{this.onAction}}\n @onSelectionChange={{@onSelectionChange}}\n @selectedKeys={{@selectedKeys}}\n @selectionMode={{if @selectionMode @selectionMode \"none\"}}\n @type=\"menu\"\n @autoActivateMode=\"none\"\n ...attributes\n as |l|\n >\n {{yield (component l.Item)}}\n </Listbox>\n </@Content>\n </template>\n}\n\nexport { Dropdown, type DropdownSignature };\nexport default Dropdown;\n"],"names":["Dropdown","Component","setComponentTemplate","precompileTemplate","strictMode","scope","Popover","hash","Trigger","Menu","anchor","assert","args","trigger","handleKeyDown","event","includes","key","preventDefault","handleKeyUp","toggle","Button","on","classNames","dropdownContent","useStyles","class","onAction","closeOnItemSelect","blockScroll","disableFocusTrap","Listbox"],"mappings":";;;;;;;;;;;AAmDA,MAAMA,iBAAiBC,SAAA,CAAU;AAC/B,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,qbAAA,EAyBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,OAAA;QAAAC,IAAA;QAAAC,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AA2BA,MAAMD,gBAAgBP,SAAA,CAAU;EAC9B,IAAIS,MAAAA,GAAS;IACXC,MAAA,CACE,0EAA0E,EAC1E,IAAI,CAACC,IAAI,CAACF,MAAM,CAAA;AAElB,IAAA,OAAO,IAAI,CAACE,IAAI,CAACF,MAAM;AACzB,EAAA;EACA,IAAIG,OAAAA,GAAU;IACZF,MAAA,CACE,4EAA4E,EAC5E,IAAI,CAACC,IAAI,CAACC,OAAO,CAAA;AAEnB,IAAA,OAAO,IAAI,CAACD,IAAI,CAACC,OAAO;AAC1B,EAAA;EAEAC,aAAA,GAAiBC,KAAO,IAAA;AACtB,IAAA,IAAI,CAAC,SAAA,EAAW,WAAA,CAAY,CAACC,QAAQ,CAACD,KAAA,CAAME,GAAG,CAAA,EAAG;MAChDF,KAAA,CAAMG,cAAc,EAAA;AACtB,IAAA;EACF,CAAA;EAEAC,WAAA,GAAeJ,KAAO,IAAA;IACpB,IAAIA,MAAME,GAAG,KAAK,eAAeF,KAAA,CAAME,GAAG,IAAI,SAAA,EAAW;AACvD,MAAA,IAAI,CAACL,IAAI,CAACQ,MAAM,EAAA;AAClB,IAAA;EACF,CAAA;AAEA,EAAA;IAAAlB,oBAAA,CAAAC,kBAAA,CAAA,0UAAA,EAiBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAgB,MAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AA6DA,MAAMb,aAAaR,SAAA,CAAU;EAC3B,IAAIsB,UAAAA,GAAa;IACf,MAAM;AAAEC,MAAAA;KAAiB,GAAGC,SAAA,EAAA;AAC5B,IAAA,OAAOD,eAAA,CAAgB;AAAEE,MAAAA,KAAA,EAAO,IAAI,CAACd,IAAI,CAACc;AAAM,KAAA,CAAA;AAClD,EAAA;EAEAC,QAAA,GAAYV,GAAW,IAAA;IACrB,IAAI,OAAO,IAAI,CAACL,IAAI,CAACe,QAAQ,KAAK,UAAA,EAAY;AAC5C,MAAA,IAAI,CAACf,IAAI,CAACe,QAAQ,CAACV,GAAA,CAAA;AACrB,IAAA;AAEA,IAAA,IACE,OAAO,IAAI,CAACL,IAAI,CAACQ,MAAM,KAAK,UAAA,IAC5B,IAAI,CAACR,IAAI,CAACgB,iBAAiB,KAAK,KAAA,EAChC;AACA,MAAA,IAAI,CAAChB,IAAI,CAACQ,MAAM,EAAA;AAClB,IAAA;EACF,CAAA;EAEA,IAAIS,WAAAA,GAAc;AAChB,IAAA,IAAI,IAAI,CAACjB,IAAI,CAACiB,WAAW,KAAK,KAAA,EAAO;AACnC,MAAA,OAAO,KAAA;AACT,IAAA;AACA,IAAA,OAAO,IAAA;AACT,EAAA;EAEA,IAAIC,gBAAAA,GAAmB;AACrB,IAAA,IAAI,IAAI,CAAClB,IAAI,CAACkB,gBAAgB,KAAK,IAAA,EAAM;AACvC,MAAA,OAAO,IAAA;AACT,IAAA;AACA,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA;IAAA5B,oBAAA,CAAAC,kBAAA,CAAA,05BAAA,EAiCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAA0B,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1,2 +0,0 @@
1
- export { L as Listbox, a as ListboxItem, L as default } from '../listbox-Czwb-jUT.js';
2
- //# sourceMappingURL=listbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export { S as SimpleTable, T as Table, T as default } from '../table-3uScDwoD.js';
2
- //# sourceMappingURL=table.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,438 +0,0 @@
1
- import { tracked } from '@glimmer/tracking';
2
- import { later, debounce } from '@ember/runloop';
3
- import { modifier } from 'ember-modifier';
4
-
5
- const deferred = /* @__PURE__ */new WeakMap();
6
- function deferDecorator(proto, prop, desc) {
7
- let map = deferred.get(proto);
8
- if (!map) {
9
- map = /* @__PURE__ */new Map();
10
- deferred.set(proto, map);
11
- }
12
- map.set(prop, desc);
13
- }
14
- function findDeferredDecorator(target, prop) {
15
- var _a;
16
- let cursor = target.prototype;
17
- while (cursor) {
18
- let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);
19
- if (desc) {
20
- return desc;
21
- }
22
- cursor = cursor.prototype;
23
- }
24
- }
25
- function decorateFieldV2(prototype, prop, decorators, initializer) {
26
- let desc = {
27
- configurable: true,
28
- enumerable: true,
29
- writable: true,
30
- initializer: null
31
- };
32
- if (initializer) {
33
- desc.initializer = initializer;
34
- }
35
- for (let decorator of decorators) {
36
- desc = decorator(prototype, prop, desc) || desc;
37
- }
38
- if (desc.initializer === void 0) {
39
- Object.defineProperty(prototype, prop, desc);
40
- } else {
41
- deferDecorator(prototype, prop, desc);
42
- }
43
- }
44
- function decorateMethodV2(prototype, prop, decorators) {
45
- const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);
46
- let desc = {
47
- ...origDesc
48
- };
49
- for (let decorator of decorators) {
50
- desc = decorator(prototype, prop, desc) || desc;
51
- }
52
- if (desc.initializer !== void 0) {
53
- desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;
54
- desc.initializer = void 0;
55
- }
56
- Object.defineProperty(prototype, prop, desc);
57
- }
58
- function initializeDeferredDecorator(target, prop) {
59
- let desc = findDeferredDecorator(target.constructor, prop);
60
- if (desc) {
61
- Object.defineProperty(target, prop, {
62
- enumerable: desc.enumerable,
63
- configurable: desc.configurable,
64
- writable: desc.writable,
65
- value: desc.initializer ? desc.initializer.call(target) : void 0
66
- });
67
- }
68
- }
69
-
70
- /* eslint-disable ember/no-runloop */
71
- class ListItem {
72
- el;
73
- key;
74
- textValue;
75
- static {
76
- decorateFieldV2(this.prototype, "isSelected", [tracked]);
77
- }
78
- #isSelected = (initializeDeferredDecorator(this, "isSelected"), void 0);
79
- static {
80
- decorateFieldV2(this.prototype, "isDisabled", [tracked]);
81
- }
82
- #isDisabled = (initializeDeferredDecorator(this, "isDisabled"), void 0);
83
- static {
84
- decorateFieldV2(this.prototype, "isActive", [tracked]);
85
- }
86
- #isActive = (initializeDeferredDecorator(this, "isActive"), void 0);
87
- constructor(el, args) {
88
- this.el = el;
89
- this.key = args.key;
90
- this.textValue = args.textValue;
91
- this.isSelected = args.isSelected;
92
- this.isDisabled = args.isDisabled;
93
- this.isActive = args.isActive;
94
- }
95
- }
96
- class ListManager {
97
- #items = [];
98
- searchKeys = '';
99
- args = {
100
- selectionMode: 'none',
101
- selectedKeys: [],
102
- disabledKeys: [],
103
- allowEmpty: false,
104
- autoActivateMode: 'none'
105
- };
106
- constructor(args = {}) {
107
- this.updateArgs(args);
108
- }
109
- register(el, args) {
110
- if (this.args.autoActivateMode == 'first' && this.#items.length === 0 && !args.isDisabled) {
111
- args.isActive = true;
112
- this.args.onActiveItemChange?.(args.key);
113
- }
114
- const newItem = new ListItem(el, args);
115
- this.#items.push(newItem);
116
- this.#syncItemsOrderWithDOM();
117
- if (typeof this.args.onListItemsChange === 'function') {
118
- this.args.onListItemsChange(this.#items, 'add');
119
- }
120
- if (this.args.autoActivateMode != 'none' && this.#items.length > 1) {
121
- later(() => {
122
- if (this.args.autoActivateMode == 'first') {
123
- this.setFirstOptionActive();
124
- } else {
125
- this.setSelectedOptionActive();
126
- }
127
- }, 1);
128
- }
129
- }
130
- unregister(el) {
131
- this.#items = this.#items.filter(item => item.el !== el);
132
- if (this.args.autoActivateMode == 'first' && this.#items.length >= 1) {
133
- this.activateItem(this.#items[0]);
134
- }
135
- if (typeof this.args.onListItemsChange === 'function') {
136
- this.args.onListItemsChange(this.#items, 'remove');
137
- }
138
- }
139
- at(el) {
140
- return this.#items.find(item => item.el === el);
141
- }
142
- atKey(key) {
143
- return this.#items.find(item => item.key === key);
144
- }
145
- updateArgs(args) {
146
- this.args.selectedKeys = args.selectedKeys || [];
147
- this.args.disabledKeys = args.disabledKeys || [];
148
- this.args.allowEmpty = args.allowEmpty || false;
149
- this.args.autoActivateMode = args.autoActivateMode || 'none';
150
- for (let i = 0; i < this.#items.length; i++) {
151
- const item = this.#items[i];
152
- item.isSelected = this.isKeySelected(item.key);
153
- item.isDisabled = this.isKeyDisabled(item.key);
154
- }
155
- if (args.selectionMode) {
156
- this.args.selectionMode = args.selectionMode;
157
- }
158
- if (args.onAction) {
159
- this.args.onAction = args.onAction;
160
- }
161
- if (args.onSelectionChange) {
162
- this.args.onSelectionChange = args.onSelectionChange;
163
- }
164
- if (args.onListItemsChange) {
165
- this.args.onListItemsChange = args.onListItemsChange;
166
- }
167
- if (args.onActiveItemChange) {
168
- this.args.onActiveItemChange = args.onActiveItemChange;
169
- }
170
- }
171
- selectActiveItem() {
172
- const item = this.#activeItem;
173
- if (item) {
174
- item.el.click();
175
- }
176
- }
177
- selectItem(item) {
178
- if (item) {
179
- if (this.args.selectionMode !== 'none') {
180
- this.activateItem(item);
181
- }
182
- if (typeof this.args.onAction === 'function') {
183
- this.args.onAction(item.key);
184
- }
185
- if (typeof this.args.onSelectionChange === 'function' && this.args.selectionMode !== 'none') {
186
- this.args.onSelectionChange(this.#toggleSelectedItem(item));
187
- }
188
- }
189
- }
190
- activateItem(item) {
191
- if (item && !item.isActive) {
192
- this.#clearActive();
193
- item.isActive = true;
194
- this.args.onActiveItemChange?.(item.key);
195
-
196
- // Ensure the item is scrolled into view
197
- requestAnimationFrame(() => {
198
- item.el.scrollIntoView({
199
- block: 'nearest',
200
- inline: 'nearest'
201
- });
202
- });
203
- }
204
- }
205
- setNextOptionActive() {
206
- for (let i = this.#indexofActiveItem + 1; i < this.#items.length; i++) {
207
- const item = this.#items[i];
208
- if (item && !item.isDisabled && !item.isActive) {
209
- this.activateItem(item);
210
- break;
211
- }
212
- }
213
- }
214
- setPreviousOptionActive() {
215
- for (let i = this.#indexofActiveItem - 1; i >= 0; i--) {
216
- const item = this.#items[i];
217
- if (item && !item.isDisabled && !item.isActive) {
218
- this.activateItem(item);
219
- break;
220
- }
221
- }
222
- }
223
- setFirstOptionActive() {
224
- for (let i = 0; i < this.#items.length; i++) {
225
- const item = this.#items[i];
226
- if (item && !item.isDisabled) {
227
- this.activateItem(item);
228
- break;
229
- }
230
- }
231
- }
232
- setSelectedOptionActive() {
233
- let activated = false;
234
- for (let i = 0; i < this.#items.length; i++) {
235
- const item = this.#items[i];
236
- if (item && !item.isDisabled && item.isSelected) {
237
- this.activateItem(item);
238
- activated = true;
239
- break;
240
- }
241
- }
242
- if (!activated) {
243
- this.setFirstOptionActive();
244
- }
245
- }
246
- setLastOptionActive() {
247
- for (let i = this.#items.length - 1; i >= 0; i--) {
248
- const item = this.#items[i];
249
- if (item && !item.isDisabled) {
250
- this.activateItem(item);
251
- break;
252
- }
253
- }
254
- }
255
- search(key) {
256
- debounce(this, this.#clearSeaerch, 500);
257
- this.searchKeys += key.toLowerCase();
258
- for (let i = 0; i < this.#items.length; i++) {
259
- const item = this.#items[i];
260
- if (!item.isDisabled && this.searchKeys && item.textValue.trim().toLowerCase().startsWith(this.searchKeys)) {
261
- this.activateItem(item);
262
- break;
263
- }
264
- }
265
- }
266
- isKeyDisabled(key) {
267
- return this.args.disabledKeys?.includes(key) || false;
268
- }
269
- isKeySelected(key) {
270
- return this.args.selectedKeys?.includes(key) || false;
271
- }
272
- get #indexofActiveItem() {
273
- let item = this.#activeItem;
274
- if (!item) {
275
- for (let i = 0; i < this.#items.length; i++) {
276
- const n = this.#items[i];
277
- if (n.isSelected) {
278
- item = n;
279
- break;
280
- }
281
- }
282
- }
283
- if (!item) {
284
- return -1;
285
- }
286
- return this.#items.indexOf(item);
287
- }
288
-
289
- // Ensure #items is always in sync with DOM order
290
- #syncItemsOrderWithDOM() {
291
- if (!this.#items.length) return;
292
-
293
- // Sort items based on their position in the DOM
294
- this.#items.sort((a, b) => {
295
- const position = a.el.compareDocumentPosition(b.el);
296
- if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
297
- if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
298
- return 0;
299
- });
300
- }
301
- #toggleSelectedItem(item) {
302
- let selectedKeys = [];
303
- for (let i = 0; i < this.#items.length; i++) {
304
- const _item = this.#items[i];
305
- if (_item.isSelected) {
306
- selectedKeys.push(_item.key);
307
- }
308
- }
309
- if (selectedKeys.includes(item.key) && (this.args.allowEmpty && selectedKeys.length == 1 || selectedKeys.length > 1)) {
310
- const indexToRemove = selectedKeys.indexOf(item.key);
311
- selectedKeys.splice(indexToRemove, 1);
312
- } else {
313
- if (this.args.selectionMode === 'single') {
314
- selectedKeys = [item.key];
315
- } else if (!selectedKeys.includes(item.key)) {
316
- selectedKeys.push(item.key);
317
- }
318
- }
319
- return selectedKeys;
320
- }
321
- get #activeItem() {
322
- for (let i = 0; i < this.#items.length; i++) {
323
- const item = this.#items[i];
324
- if (item.isActive) {
325
- return item;
326
- }
327
- }
328
- }
329
- #clearSeaerch() {
330
- this.searchKeys = '';
331
- }
332
- #clearActive() {
333
- for (let i = 0; i < this.#items.length; i++) {
334
- const item = this.#items[i];
335
- if (item.isActive) {
336
- item.isActive = false;
337
- }
338
- }
339
- }
340
- setup = modifier((_el, _, args) => {
341
- this.updateArgs({
342
- selectionMode: args.selectionMode,
343
- disabledKeys: args.disabledKeys,
344
- selectedKeys: args.selectedKeys,
345
- allowEmpty: args.allowEmpty,
346
- autoActivateMode: args.autoActivateMode
347
- });
348
- });
349
- setupItem = modifier((el, _, args) => {
350
- let textValue = args.textValue;
351
- if (typeof textValue === 'undefined' || textValue === '' || textValue === null) {
352
- const labelId = el.getAttribute('aria-labelledby');
353
- if (labelId) {
354
- const labelElement = el.querySelector(`#${labelId}`);
355
- if (labelElement) {
356
- textValue = labelElement.textContent?.trim() || '';
357
- }
358
- } else {
359
- textValue = el.textContent?.trim() || '';
360
- }
361
- }
362
- this.register(el, {
363
- key: args.key,
364
- textValue: textValue || '',
365
- isActive: false,
366
- isDisabled: this.isKeyDisabled(args.key),
367
- isSelected: this.isKeySelected(args.key)
368
- });
369
- const item = this.at(el);
370
- if (item && typeof args.onRegister === 'function') {
371
- args.onRegister(item);
372
- }
373
- const mouseEnter = () => {
374
- this.activateItem(item);
375
- };
376
- const mouseLeave = () => {
377
- if (item) {
378
- item.isActive = false;
379
- }
380
- };
381
- if (!args.disableEvents) {
382
- el.addEventListener('mouseenter', mouseEnter);
383
- el.addEventListener('mouseleave', mouseLeave);
384
- el.addEventListener('focusin', mouseEnter);
385
- el.addEventListener('focusout', mouseLeave);
386
- }
387
- return () => {
388
- this.unregister(el);
389
- if (!args.disableEvents) {
390
- el.removeEventListener('mouseenter', mouseEnter);
391
- el.removeEventListener('mouseleave', mouseLeave);
392
- el.removeEventListener('focusin', mouseEnter);
393
- el.removeEventListener('focusout', mouseLeave);
394
- }
395
- };
396
- });
397
- }
398
- function keyAndLabelForItem(item) {
399
- // Handle primitive types directly
400
- if (typeof item === 'string' || typeof item === 'number') {
401
- const value = item.toString();
402
- return {
403
- key: value,
404
- label: value
405
- };
406
- }
407
-
408
- // If the item is an object, try to extract key and label using common property names
409
- if (typeof item === 'object' && item !== null) {
410
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
411
- const typedItem = item;
412
-
413
- // Try to use the 'key' property first; if not available, use 'id'
414
- let keyProp = typedItem.key || typedItem.id;
415
- if (keyProp === undefined) {
416
- keyProp = item.toString();
417
- }
418
-
419
- // Determine the label by checking multiple possible properties
420
- let labelProp = typedItem.label || typedItem.value || typedItem.name || typedItem.title;
421
- if (labelProp === undefined) {
422
- labelProp = item.toString();
423
- }
424
- return {
425
- key: keyProp.toString(),
426
- label: labelProp.toString()
427
- };
428
- }
429
-
430
- // Fallback if item does not match expected types
431
- return {
432
- key: '',
433
- label: ''
434
- };
435
- }
436
-
437
- export { ListManager as L, decorateFieldV2 as a, decorateMethodV2 as d, initializeDeferredDecorator as i, keyAndLabelForItem as k };
438
- //# sourceMappingURL=listManager-CKsOd2zS.js.map