ember-headless-table 1.4.2 → 1.4.4
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/dist/-private/-type-tests/plugin-properties.test.js +1 -1
- package/dist/-private/-type-tests/plugin-properties.test.js.map +1 -1
- package/dist/-private/-type-tests/plugin-with.test.js +0 -1
- package/dist/-private/-type-tests/plugin-with.test.js.map +1 -1
- package/dist/-private/-type-tests/plugins-accessors.test.js +1 -2
- package/dist/-private/-type-tests/plugins-accessors.test.js.map +1 -1
- package/dist/-private/-type-tests/table-api.test.js +0 -1
- package/dist/-private/-type-tests/table-api.test.js.map +1 -1
- package/dist/-private/-type-tests/table-config.test.js +1 -2
- package/dist/-private/-type-tests/table-config.test.js.map +1 -1
- package/dist/-private/column.d.ts +3 -3
- package/dist/-private/column.js.map +1 -1
- package/dist/-private/interfaces/column.d.ts +5 -5
- package/dist/-private/interfaces/index.d.ts +7 -7
- package/dist/-private/interfaces/plugins.d.ts +3 -3
- package/dist/-private/interfaces/table.d.ts +5 -5
- package/dist/-private/js-helper.d.ts +2 -2
- package/dist/-private/js-helper.js +37 -1
- package/dist/-private/js-helper.js.map +1 -1
- package/dist/-private/preferences.d.ts +2 -2
- package/dist/-private/preferences.js +1 -1
- package/dist/-private/preferences.js.map +1 -1
- package/dist/-private/row.d.ts +1 -1
- package/dist/-private/row.js +1 -1
- package/dist/-private/row.js.map +1 -1
- package/dist/-private/table.js +2 -2
- package/dist/-private/utils.d.ts +1 -1
- package/dist/-private/utils.js.map +1 -1
- package/dist/applyDecoratedDescriptor-6b986a67.js.map +1 -1
- package/dist/{classPrivateFieldGet-b4d7d334.js → classPrivateFieldGet-0bfc0262.js} +2 -2
- package/dist/{classPrivateFieldGet-b4d7d334.js.map → classPrivateFieldGet-0bfc0262.js.map} +1 -1
- package/dist/defineProperty-4f0781e1.js +43 -0
- package/dist/defineProperty-4f0781e1.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/plugins/-private/base.d.ts +6 -6
- package/dist/plugins/-private/base.js +51 -18
- package/dist/plugins/-private/base.js.map +1 -1
- package/dist/plugins/-private/utils.d.ts +2 -2
- package/dist/plugins/-private/utils.js.map +1 -1
- package/dist/plugins/column-reordering/helpers.d.ts +2 -2
- package/dist/plugins/column-reordering/helpers.js.map +1 -1
- package/dist/plugins/column-reordering/index.d.ts +3 -3
- package/dist/plugins/column-reordering/plugin.d.ts +3 -3
- package/dist/plugins/column-reordering/plugin.js +23 -26
- package/dist/plugins/column-reordering/plugin.js.map +1 -1
- package/dist/plugins/column-reordering/utils.d.ts +1 -1
- package/dist/plugins/column-reordering/utils.js.map +1 -1
- package/dist/plugins/column-resizing/handle.d.ts +2 -2
- package/dist/plugins/column-resizing/handle.js +4 -1
- package/dist/plugins/column-resizing/handle.js.map +1 -1
- package/dist/plugins/column-resizing/helpers.d.ts +1 -1
- package/dist/plugins/column-resizing/index.d.ts +4 -4
- package/dist/plugins/column-resizing/plugin.d.ts +3 -3
- package/dist/plugins/column-resizing/plugin.js +11 -3
- package/dist/plugins/column-resizing/plugin.js.map +1 -1
- package/dist/plugins/column-resizing/resize-observer.js.map +1 -1
- package/dist/plugins/column-visibility/helpers.d.ts +1 -1
- package/dist/plugins/column-visibility/index.d.ts +3 -3
- package/dist/plugins/column-visibility/plugin.d.ts +3 -3
- package/dist/plugins/column-visibility/plugin.js +1 -1
- package/dist/plugins/column-visibility/plugin.js.map +1 -1
- package/dist/plugins/data-sorting/helpers.d.ts +2 -2
- package/dist/plugins/data-sorting/index.d.ts +5 -5
- package/dist/plugins/data-sorting/plugin.d.ts +4 -4
- package/dist/plugins/data-sorting/plugin.js +1 -1
- package/dist/plugins/data-sorting/plugin.js.map +1 -1
- package/dist/plugins/data-sorting/types.d.ts +1 -1
- package/dist/plugins/data-sorting/types.js +6 -6
- package/dist/plugins/data-sorting/types.js.map +1 -1
- package/dist/plugins/index.d.ts +5 -5
- package/dist/plugins/metadata/helpers.d.ts +1 -1
- package/dist/plugins/metadata/helpers.js.map +1 -1
- package/dist/plugins/metadata/index.d.ts +3 -3
- package/dist/plugins/metadata/plugin.d.ts +1 -1
- package/dist/plugins/metadata/plugin.js +1 -1
- package/dist/plugins/metadata/plugin.js.map +1 -1
- package/dist/plugins/row-selection/helpers.d.ts +1 -1
- package/dist/plugins/row-selection/index.d.ts +3 -3
- package/dist/plugins/row-selection/plugin.d.ts +3 -3
- package/dist/plugins/row-selection/plugin.js +2 -2
- package/dist/plugins/row-selection/plugin.js.map +1 -1
- package/dist/plugins/sticky-columns/helpers.d.ts +1 -1
- package/dist/plugins/sticky-columns/helpers.js +2 -0
- package/dist/plugins/sticky-columns/helpers.js.map +1 -1
- package/dist/plugins/sticky-columns/index.d.ts +3 -3
- package/dist/plugins/sticky-columns/plugin.d.ts +3 -3
- package/dist/plugins/sticky-columns/plugin.js +13 -1
- package/dist/plugins/sticky-columns/plugin.js.map +1 -1
- package/dist/{table-0cbd2720.d.ts → table-443deac1.d.ts} +22 -7
- package/dist/{table-0cbd2720.js → table-443deac1.js} +56 -14
- package/dist/table-443deac1.js.map +1 -0
- package/dist/test-support/index.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/defineProperty-35ce617b.js +0 -16
- package/dist/defineProperty-35ce617b.js.map +0 -1
- package/dist/table-0cbd2720.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/data-sorting/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { action } from '@ember/object';\n\nimport { BasePlugin, meta, options } from '../-private/base';\nimport { SortDirection } from './types';\n\nimport type { Sort, SortItem } from './types';\nimport type { ColumnApi, PluginPreferences } from '[public-plugin-types]';\nimport type { Column, Table } from '[public-types]';\n\ninterface SortingPreferences extends PluginPreferences {\n table: {\n sorts?: Sort[];\n };\n}\n\ndeclare module 'ember-headless-table/plugins' {\n interface Registry {\n Sorting?: SortingPreferences;\n }\n}\n\nexport interface Signature<DataType = unknown> {\n Meta: {\n Column: ColumnMeta;\n Table: TableMeta;\n };\n Options: {\n Plugin: Options<DataType>;\n Column: ColumnOptions;\n };\n}\n\ninterface Options<DataType = unknown> {\n /**\n * Handler for interpreting sort requests from the headless table.\n *\n * Does not actually do the sorting.\n *\n * if omitted, the DataSorting plugin will disable itself\n */\n onSort?: (sorts: SortItem<DataType>[]) => void;\n /**\n * Provided sorts that the table should assume are true.\n *\n * if omitted, the DataSorting plugin will disable itself\n */\n sorts?: SortItem<DataType>[];\n}\n\ninterface ColumnOptions {\n /**\n * Opt in or out of sorting for a particular column.\n * Default is true.\n */\n isSortable?: boolean;\n /**\n * Use this key instead of the `key` on the column config.\n * This has no bearing on any behavior in the plugin, *other than*,\n * swapping out the `property`'s value on the `SortItem`s passed to\n * the table plugin config's `onSort` callback\n */\n sortProperty?: string;\n}\n\n/**\n * Manages basic data-sorting behaviors. Ascending -> Descending -> None\n *\n * This plugin requires a table plugin configuration, `onSort` for handling *how* sorting happens.\n * communicating back to the table that sorting has succeeded can be done by setting the `sorts`\n * property in the table plugin configuration.\n *\n * Note that this plugin doesn't actually sort the data, as data management is not the responsibility\n * of the table, but of the surrounding context providing the data to the table. So sorting can happen\n * client-side still, just in a component -- much the same way you'd handel sorting via API requests.\n *\n * This plugin is for *conveying* what the current sorts are, rather than _doing_ the sorting.\n */\nexport class Sorting<DataType = unknown> extends BasePlugin<Signature<DataType>> {\n name = 'data-sorting';\n\n meta = {\n column: ColumnMeta,\n table: TableMeta,\n };\n\n headerCellModifier = (element: HTMLElement, { column }: ColumnApi) => {\n let columnMeta = meta.forColumn(column, Sorting);\n\n element.setAttribute('data-test-is-sortable', `${columnMeta.isSortable}`);\n element.setAttribute('aria-sort', `${columnMeta.sortDirection}`);\n };\n}\n\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n @cached\n get options() {\n return options.forColumn(this.column, Sorting);\n }\n\n get isSortable() {\n return this.options?.isSortable ?? this.tableMeta.isSortable;\n }\n\n get tableMeta() {\n return meta.forTable(this.column.table, Sorting);\n }\n\n get sortDirection() {\n let sort = this.tableMeta.sorts.find((sort) => sort.property === this.sortProperty);\n\n return sort?.direction ?? SortDirection.None;\n }\n\n get isAscending() {\n return this.sortDirection === SortDirection.Ascending;\n }\n\n get isDescending() {\n return this.sortDirection === SortDirection.Descending;\n }\n\n get isUnsorted() {\n return this.sortDirection === SortDirection.None;\n }\n\n get sortProperty() {\n return this.options?.sortProperty ?? this.column.config.key;\n }\n}\n\nexport class TableMeta {\n constructor(private table: Table) {}\n\n @cached\n get options() {\n return options.forTable(this.table, Sorting);\n }\n\n get sorts() {\n return this.options?.sorts ?? [];\n }\n\n get isSortable() {\n return Boolean(this.options?.onSort) && Boolean(this.options?.sorts);\n }\n\n get onSort() {\n return this.options?.onSort;\n }\n\n @action\n handleSort(column: Column) {\n let columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Ascending) {\n this.onSort?.([]);\n } else if (columnMeta.sortDirection === SortDirection.Descending) {\n this.onSort?.([{ direction: SortDirection.Ascending, property: columnMeta.sortProperty }]);\n } else {\n this.onSort?.([{ direction: SortDirection.Descending, property: columnMeta.sortProperty }]);\n }\n }\n\n @action\n toggleAscending(column: Column) {\n let columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Ascending) {\n return this.onSort?.([]);\n }\n\n this.onSort?.([{ direction: SortDirection.Ascending, property: columnMeta.sortProperty }]);\n }\n\n @action\n toggleDescending(column: Column) {\n let columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Descending) {\n return this.onSort?.([]);\n }\n\n this.onSort?.([{ direction: SortDirection.Descending, property: columnMeta.sortProperty }]);\n }\n}\n"],"names":["Sorting","BasePlugin","column","ColumnMeta","table","TableMeta","element","columnMeta","meta","forColumn","setAttribute","isSortable","sortDirection","constructor","options","tableMeta","forTable","sort","sorts","find","property","sortProperty","direction","SortDirection","None","isAscending","Ascending","isDescending","Descending","isUnsorted","config","key","cached","Boolean","onSort","handleSort","toggleAscending","toggleDescending","action"],"mappings":";;;;;;;;;AAA2C,IAAA,MAAA,GAAA,cAAA,CAAA,mBAAA,CAAA,cAAA,EAAA,kBAAA,CAAA,CAAA,GAAA,UAAA,CAAA,mBAAA,CAAA,CAAA,MAAA,GAAA,UAAA,CAAA,iCAAA,CAAA,CAAA,MAAA,CAAA;AAiE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,OAAO,SAA6BC,UAAU,CAAsB;AAAA,EAAA,WAAA,CAAA,GAAA,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EACxE,cAAc,CAAA,CAAA;IAAA,eAEd,CAAA,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,MAAM,EAAEC,UAAU;AAClBC,MAAAA,KAAK,EAAEC,SAAAA;KACR,CAAA,CAAA;IAAA,eAEoB,CAAA,IAAA,EAAA,oBAAA,EAAA,CAACC,OAAoB,EAAE;AAAEJ,MAAAA,MAAAA;AAAkB,KAAC,KAAK;MACpE,IAAIK,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACP,MAAM,EAAEF,OAAO,CAAC,CAAA;MAEhDM,OAAO,CAACI,YAAY,CAAC,uBAAuB,EAAG,GAAEH,UAAU,CAACI,UAAW,CAAA,CAAC,CAAC,CAAA;MACzEL,OAAO,CAACI,YAAY,CAAC,WAAW,EAAG,GAAEH,UAAU,CAACK,aAAc,CAAA,CAAC,CAAC,CAAA;KACjE,CAAA,CAAA;AAAA,GAAA;AACH,CAAA;AAEA,IAAaT,UAAU,IAAA,MAAA,GAAhB,MAAMA,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,QAAQ,EAAEb,UAAU,CAACc,YAAAA;AAAa,KAAC,CAAC,CAAC,CAAA;AAC7F,GAAA;AACF,CAAC,4DA/DEW,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,OAAA,CAAA,SAAA,EAAA,SAAA,CAAA,EAAA,OAAA,CAAA,SAAA,CAAA,EAAA,yBAAA,CAAA,OAAA,CAAA,SAAA,EAAA,YAAA,EAAA,CAiBNM,MAAM,CAiBNA,EAAAA,MAAAA,CAAAA,wBAAAA,CAAAA,OAAAA,CAAAA,SAAAA,EAAAA,YAAAA,CAAAA,EAAAA,OAAAA,CAAAA,SAAAA,CAAAA,EAAAA,yBAAAA,CAAAA,OAAAA,CAAAA,SAAAA,EAAAA,iBAAAA,EAAAA,CAAAA,MAAM,gKAeNA,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,OAAA,CAAA,SAAA,EAAA,kBAAA,CAAA,EAAA,OAAA,CAAA,SAAA,CAAA,GAAA,OAAA;;;;"}
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/data-sorting/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { action } from '@ember/object';\n\nimport { BasePlugin, meta, options } from '../-private/base';\nimport { SortDirection } from './types';\n\nimport type { Sort, SortItem } from './types';\nimport type { ColumnApi, PluginPreferences } from '[public-plugin-types]';\nimport type { Column, Table } from '[public-types]';\n\ninterface SortingPreferences extends PluginPreferences {\n table: {\n sorts?: Sort[];\n };\n}\n\ndeclare module 'ember-headless-table/plugins' {\n interface Registry {\n Sorting?: SortingPreferences;\n }\n}\n\nexport interface Signature<DataType = unknown> {\n Meta: {\n Column: ColumnMeta;\n Table: TableMeta;\n };\n Options: {\n Plugin: Options<DataType>;\n Column: ColumnOptions;\n };\n}\n\ninterface Options<DataType = unknown> {\n /**\n * Handler for interpreting sort requests from the headless table.\n *\n * Does not actually do the sorting.\n *\n * if omitted, the DataSorting plugin will disable itself\n */\n onSort?: (sorts: SortItem<DataType>[]) => void;\n /**\n * Provided sorts that the table should assume are true.\n *\n * if omitted, the DataSorting plugin will disable itself\n */\n sorts?: SortItem<DataType>[];\n}\n\ninterface ColumnOptions {\n /**\n * Opt in or out of sorting for a particular column.\n * Default is true.\n */\n isSortable?: boolean;\n /**\n * Use this key instead of the `key` on the column config.\n * This has no bearing on any behavior in the plugin, *other than*,\n * swapping out the `property`'s value on the `SortItem`s passed to\n * the table plugin config's `onSort` callback\n */\n sortProperty?: string;\n}\n\n/**\n * Manages basic data-sorting behaviors. Ascending -> Descending -> None\n *\n * This plugin requires a table plugin configuration, `onSort` for handling *how* sorting happens.\n * communicating back to the table that sorting has succeeded can be done by setting the `sorts`\n * property in the table plugin configuration.\n *\n * Note that this plugin doesn't actually sort the data, as data management is not the responsibility\n * of the table, but of the surrounding context providing the data to the table. So sorting can happen\n * client-side still, just in a component -- much the same way you'd handel sorting via API requests.\n *\n * This plugin is for *conveying* what the current sorts are, rather than _doing_ the sorting.\n */\nexport class Sorting<DataType = unknown> extends BasePlugin<Signature<DataType>> {\n name = 'data-sorting';\n\n meta = {\n column: ColumnMeta,\n table: TableMeta,\n };\n\n headerCellModifier = (element: HTMLElement, { column }: ColumnApi) => {\n let columnMeta = meta.forColumn(column, Sorting);\n\n element.setAttribute('data-test-is-sortable', `${columnMeta.isSortable}`);\n element.setAttribute('aria-sort', `${columnMeta.sortDirection}`);\n };\n}\n\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n @cached\n get options() {\n return options.forColumn(this.column, Sorting);\n }\n\n get isSortable() {\n return this.options?.isSortable ?? this.tableMeta.isSortable;\n }\n\n get tableMeta() {\n return meta.forTable(this.column.table, Sorting);\n }\n\n get sortDirection() {\n let sort = this.tableMeta.sorts.find((sort) => sort.property === this.sortProperty);\n\n return sort?.direction ?? SortDirection.None;\n }\n\n get isAscending() {\n return this.sortDirection === SortDirection.Ascending;\n }\n\n get isDescending() {\n return this.sortDirection === SortDirection.Descending;\n }\n\n get isUnsorted() {\n return this.sortDirection === SortDirection.None;\n }\n\n get sortProperty() {\n return this.options?.sortProperty ?? this.column.config.key;\n }\n}\n\nexport class TableMeta {\n constructor(private table: Table) {}\n\n @cached\n get options() {\n return options.forTable(this.table, Sorting);\n }\n\n get sorts() {\n return this.options?.sorts ?? [];\n }\n\n get isSortable() {\n return Boolean(this.options?.onSort) && Boolean(this.options?.sorts);\n }\n\n get onSort() {\n return this.options?.onSort;\n }\n\n @action\n handleSort(column: Column) {\n let columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Ascending) {\n this.onSort?.([]);\n } else if (columnMeta.sortDirection === SortDirection.Descending) {\n this.onSort?.([{ direction: SortDirection.Ascending, property: columnMeta.sortProperty }]);\n } else {\n this.onSort?.([{ direction: SortDirection.Descending, property: columnMeta.sortProperty }]);\n }\n }\n\n @action\n toggleAscending(column: Column) {\n let columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Ascending) {\n return this.onSort?.([]);\n }\n\n this.onSort?.([{ direction: SortDirection.Ascending, property: columnMeta.sortProperty }]);\n }\n\n @action\n toggleDescending(column: Column) {\n let columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Descending) {\n return this.onSort?.([]);\n }\n\n this.onSort?.([{ direction: SortDirection.Descending, property: columnMeta.sortProperty }]);\n }\n}\n"],"names":["cached","macroCondition","dependencySatisfies","importSync","Sorting","BasePlugin","constructor","args","_defineProperty","column","ColumnMeta","table","TableMeta","element","columnMeta","meta","forColumn","setAttribute","isSortable","sortDirection","_class","options","tableMeta","forTable","sort","sorts","find","property","sortProperty","direction","SortDirection","None","isAscending","Ascending","isDescending","Descending","isUnsorted","config","key","_applyDecoratedDescriptor","prototype","Object","getOwnPropertyDescriptor","_class2","Boolean","onSort","handleSort","to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AAM,CAAAyC,EAAAA,MAAA,CAAAC,wBAAA,CAAAC,OAAA,CAAAH,SAAA,cAAAG,OAAA,CAAAH,SAAA,CAAA,EAAAD,yBAAA,CAAAI,OAAA,CAAAH,SAAA,iBAiBNS,MAAM,CAAA,EAAAR,MAAA,CAAAC,wBAAA,CAAAC,OAAA,CAAAH,SAAA,EAAA,YAAA,CAAA,EAAAG,OAAA,CAAAH,SAAA,CAAAD,EAAAA,yBAAA,CAAAI,OAAA,CAAAH,SAAA,EAAA,iBAAA,EAAA,CAiBNS,MAAM,CAAAR,EAAAA,MAAA,CAAAC,wBAAA,CAAAC,OAAA,CAAAH,SAAA,EAAAG,iBAAAA,CAAAA,EAAAA,OAAA,CAAAH,SAAA,CAAA,EAAAD,yBAAA,CAAAI,OAAA,CAAAH,SAAA,uBAeNS,MAAM,CAAA,EAAAR,MAAA,CAAAC,wBAAA,CAAAC,OAAA,CAAAH,SAAA,EAAA,kBAAA,CAAA,EAAAG,OAAA,CAAAH,SAAA,IAAAG,OAAA;;;;"}
|
@@ -1,14 +1,14 @@
|
|
1
|
-
let SortDirection
|
2
|
-
(function (SortDirection) {
|
1
|
+
let SortDirection = /*#__PURE__*/function (SortDirection) {
|
3
2
|
SortDirection["Ascending"] = "ascending";
|
4
3
|
SortDirection["Descending"] = "descending";
|
5
4
|
SortDirection["None"] = "none";
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
return SortDirection;
|
6
|
+
}({});
|
7
|
+
let SortTransform = /*#__PURE__*/function (SortTransform) {
|
9
8
|
SortTransform["Underscore"] = "underscore";
|
10
9
|
SortTransform["Camelize"] = "camelize";
|
11
|
-
|
10
|
+
return SortTransform;
|
11
|
+
}({});
|
12
12
|
|
13
13
|
export { SortDirection, SortTransform };
|
14
14
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/plugins/data-sorting/types.ts"],"sourcesContent":["import type { ColumnKey } from '#/interfaces';\n\nexport enum SortDirection {\n Ascending = 'ascending',\n Descending = 'descending',\n None = 'none',\n}\n\nexport interface Sort {\n property: string;\n direction: SortDirection;\n}\n\nexport enum SortTransform {\n Underscore = 'underscore',\n Camelize = 'camelize',\n}\nexport interface SortsOptions {\n separator: string;\n transform: string | null;\n}\n\nexport interface SortItem<T> {\n direction: SortDirection;\n property: ColumnKey<T>;\n}\n"],"names":["SortDirection","SortTransform"],"mappings":"
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/plugins/data-sorting/types.ts"],"sourcesContent":["import type { ColumnKey } from '#/interfaces';\n\nexport enum SortDirection {\n Ascending = 'ascending',\n Descending = 'descending',\n None = 'none',\n}\n\nexport interface Sort {\n property: string;\n direction: SortDirection;\n}\n\nexport enum SortTransform {\n Underscore = 'underscore',\n Camelize = 'camelize',\n}\nexport interface SortsOptions {\n separator: string;\n transform: string | null;\n}\n\nexport interface SortItem<T> {\n direction: SortDirection;\n property: ColumnKey<T>;\n}\n"],"names":["SortDirection","SortTransform"],"mappings":"AAEYA,IAAAA,aAAa,0BAAbA,aAAa,EAAA;EAAbA,aAAa,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAbA,aAAa,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAbA,aAAa,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;AAAA,EAAA,OAAbA,aAAa,CAAA;AAAA,CAAA,CAAA,EAAA,EAAA;AAWbC,IAAAA,aAAa,0BAAbA,aAAa,EAAA;EAAbA,aAAa,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAbA,aAAa,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;AAAA,EAAA,OAAbA,aAAa,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
export { BasePlugin, columns, hasPlugin, meta, options, preferences } from "./-private/base";
|
2
|
-
export { applyStyles, removeStyles } from "./-private/utils";
|
3
|
-
export type { ColumnFeatures, TableFeatures } from "./-private/base";
|
4
|
-
export type { ColumnApi, Plugin, PluginPreferences, Registry } from "../-private/interfaces/index";
|
5
|
-
export type { PluginSignature } from "../-private/interfaces/plugins";
|
1
|
+
export { BasePlugin, columns, hasPlugin, meta, options, preferences } from "./-private/base.js";
|
2
|
+
export { applyStyles, removeStyles } from "./-private/utils.js";
|
3
|
+
export type { ColumnFeatures, TableFeatures } from "./-private/base.js";
|
4
|
+
export type { ColumnApi, Plugin, PluginPreferences, Registry } from "../-private/interfaces/index.js";
|
5
|
+
export type { PluginSignature } from "../-private/interfaces/plugins.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/metadata/helpers.ts"],"sourcesContent":["import { options } from '../-private/base';\nimport { Metadata } from './plugin';\n\nimport type { Column, Table } from '[public-types]';\n\nexport const forColumn = (column: Column<any>, key: string) => {\n return options.forColumn(column, Metadata)[key];\n};\n\nexport const forTable = (table: Table<any>, key: string) => {\n return options.forTable(table, Metadata)[key];\n};\n"],"names":["forColumn","column","key","options","Metadata","forTable","table"],"mappings":";;;MAKaA,SAAS,
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/metadata/helpers.ts"],"sourcesContent":["import { options } from '../-private/base';\nimport { Metadata } from './plugin';\n\nimport type { Column, Table } from '[public-types]';\n\nexport const forColumn = (column: Column<any>, key: string) => {\n return options.forColumn(column, Metadata)[key];\n};\n\nexport const forTable = (table: Table<any>, key: string) => {\n return options.forTable(table, Metadata)[key];\n};\n"],"names":["forColumn","column","key","options","Metadata","forTable","table"],"mappings":";;;MAKaA,SAAS,GAAGA,CAACC,MAAmB,EAAEC,GAAW,KAAK;EAC7D,OAAOC,OAAO,CAACH,SAAS,CAACC,MAAM,EAAEG,QAAQ,CAAC,CAACF,GAAG,CAAC,CAAA;AACjD,EAAC;MAEYG,QAAQ,GAAGA,CAACC,KAAiB,EAAEJ,GAAW,KAAK;EAC1D,OAAOC,OAAO,CAACE,QAAQ,CAACC,KAAK,EAAEF,QAAQ,CAAC,CAACF,GAAG,CAAC,CAAA;AAC/C;;;;"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from "./helpers";
|
2
|
-
export { Metadata, Metadata as Plugin } from "./plugin";
|
3
|
-
export type { Signature } from "./plugin";
|
1
|
+
export * from "./helpers.js";
|
2
|
+
export { Metadata, Metadata as Plugin } from "./plugin.js";
|
3
|
+
export type { Signature } from "./plugin.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/metadata/plugin.ts"],"sourcesContent":["import { BasePlugin } from '../-private/base';\n\n/**\n * Data stored per column or table can be arbitrary\n *\n */\ntype ArbitraryData = Record<string, any>;\n\nexport interface Signature<Data = ArbitraryData> {\n Options: {\n Column: Data;\n Plugin: Data;\n };\n}\n\n/**\n * This plugin does noting,\n * but gives consumer of it a safe way to store and associate \"any\" data with columns\n * (and have a generic top-level bucket of data as well)\n *\n * This \"metadata\" stored per column per table is managed via the \"options\" part of the Signature, as\n * \"meta\" is a term used for plugins for plugin authors.\n */\nexport class Metadata<S extends Signature> extends BasePlugin<S> {\n name = 'metadata';\n}\n"],"names":["Metadata","BasePlugin"],"mappings":";;;AAEA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,SAA8BC,UAAU,CAAI;
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/metadata/plugin.ts"],"sourcesContent":["import { BasePlugin } from '../-private/base';\n\n/**\n * Data stored per column or table can be arbitrary\n *\n */\ntype ArbitraryData = Record<string, any>;\n\nexport interface Signature<Data = ArbitraryData> {\n Options: {\n Column: Data;\n Plugin: Data;\n };\n}\n\n/**\n * This plugin does noting,\n * but gives consumer of it a safe way to store and associate \"any\" data with columns\n * (and have a generic top-level bucket of data as well)\n *\n * This \"metadata\" stored per column per table is managed via the \"options\" part of the Signature, as\n * \"meta\" is a term used for plugins for plugin authors.\n */\nexport class Metadata<S extends Signature> extends BasePlugin<S> {\n name = 'metadata';\n}\n"],"names":["Metadata","BasePlugin","constructor","args","_defineProperty"],"mappings":";;;AAEA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,SAA8BC,UAAU,CAAI;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,eAAA,eACxD,UAAU,CAAA,CAAA;AAAA,GAAA;AACnB;;;;"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from "./helpers";
|
2
|
-
export { RowSelection as Plugin, RowSelection } from "./plugin";
|
3
|
-
export type { Signature } from "./plugin";
|
1
|
+
export * from "./helpers.js";
|
2
|
+
export { RowSelection as Plugin, RowSelection } from "./plugin.js";
|
3
|
+
export type { Signature } from "./plugin.js";
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { BasePlugin } from "../-private/base";
|
2
|
-
import { Row, Table } from "../../index";
|
3
|
-
import { PluginSignature, RowApi } from "../../-private/interfaces/index";
|
1
|
+
import { BasePlugin } from "../-private/base.js";
|
2
|
+
import { Row, Table } from "../../index.js";
|
3
|
+
import { PluginSignature, RowApi } from "../../-private/interfaces/index.js";
|
4
4
|
interface Signature<DataType = any, Key = DataType> extends PluginSignature {
|
5
5
|
Meta: {
|
6
6
|
Table: TableMeta;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { a as _classExtractFieldDescriptor, _ as _classPrivateFieldGet } from '../../classPrivateFieldGet-0bfc0262.js';
|
2
2
|
import { _ as _applyDecoratedDescriptor } from '../../applyDecoratedDescriptor-6b986a67.js';
|
3
|
-
import { _ as _defineProperty } from '../../defineProperty-
|
3
|
+
import { _ as _defineProperty } from '../../defineProperty-4f0781e1.js';
|
4
4
|
import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
|
5
5
|
import '@glimmer/tracking';
|
6
6
|
import { assert } from '@ember/debug';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js","../../../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js","../../../src/plugins/row-selection/plugin.ts"],"sourcesContent":["export default function _classApplyDescriptorSet(receiver, descriptor, value) {\n if (descriptor.set) {\n descriptor.set.call(receiver, value);\n } else {\n if (!descriptor.writable) {\n throw new TypeError(\"attempted to set read only private field\");\n }\n descriptor.value = value;\n }\n}","import classApplyDescriptorSet from \"./classApplyDescriptorSet.js\";\nimport classExtractFieldDescriptor from \"./classExtractFieldDescriptor.js\";\nexport default function _classPrivateFieldSet(receiver, privateMap, value) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"set\");\n classApplyDescriptorSet(receiver, descriptor, value);\n return value;\n}","import { cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\n\nimport { BasePlugin, meta, options } from '../-private/base';\n\nimport type { Row, Table } from '[public-types]';\nimport type { PluginSignature, RowApi } from '#interfaces';\n\nexport interface Signature<DataType = any, Key = DataType> extends PluginSignature {\n Meta: {\n Table: TableMeta;\n Row: RowMeta;\n };\n Options: {\n Plugin: {\n /**\n * A set of selected things using the same type of Identifier\n * returned from `key`\n */\n selection: Set<Key> | Array<Key>;\n } & (\n | {\n /**\n * For a given row's data, how should the key be determined?\n * this could be a remote id from a database, or some other attribute\n *\n * This could be useful for indicating in UI if a particular item is selected.\n *\n * If not provided, the row's data will be used as the key\n */\n key: (data: DataType) => Key;\n /**\n * When a row is clicked, this will be invoked,\n * allowing you to update your selection object\n */\n onSelect: (item: Key, row: Row<DataType>) => void;\n /**\n * When a row is clicked (and the row is selected), this will be invoked,\n * allowing you to update your selection object\n */\n onDeselect: (item: Key, row: Row<DataType>) => void;\n }\n | {\n /**\n * When a row is clicked (and the row is not selected), this will be invoked,\n * allowing you to update your selection object\n */\n onSelect: (item: DataType | any, row: Row<DataType>) => void;\n /**\n * When a row is clicked (and the row is selected), this will be invoked,\n * allowing you to update your selection object\n */\n onDeselect: (item: DataType | any, row: Row<DataType>) => void;\n }\n );\n };\n}\n\n/**\n * This plugin provides a means of managing selection of a single row in a table.\n *\n * The state of what is actually selected is managed by you, but this plugin\n * will wire up the click listeners as well as let you know which *data* is clicked.\n */\nexport class RowSelection<DataType = any, Key = DataType> extends BasePlugin<\n Signature<DataType, Key>\n> {\n name = 'row-selection';\n\n meta = {\n row: RowMeta,\n table: TableMeta,\n };\n\n constructor(table: Table) {\n super(table);\n\n let pluginOptions = options.forTable(this.table, RowSelection);\n\n assert(\n `selection, onSelect, and onDeselect are all required arguments for the RowSelection plugin. ` +\n `Specify these options via \\`RowSelection.with(() => ({ selection, onSelect, onDeselect }))\\``,\n pluginOptions.selection && pluginOptions.onSelect && pluginOptions.onDeselect\n );\n }\n\n rowModifier = (element: HTMLElement, { row }: RowApi<Table<any>>) => {\n let handler = (event: Event) => {\n this.#clickHandler(row, event);\n };\n\n element.addEventListener('click', handler);\n\n return () => {\n element.removeEventListener('click', handler);\n };\n };\n\n #clickHandler = (row: Row, event: Event) => {\n assert(\n `expected event.target to be an instance of HTMLElement`,\n event.target instanceof HTMLElement || event.target instanceof SVGElement\n );\n\n let selection = document.getSelection();\n\n if (selection) {\n let { type, anchorNode } = selection;\n let isSelectingText = type === 'Range' && event.target?.contains(anchorNode);\n\n if (isSelectingText) {\n event.stopPropagation();\n\n return;\n }\n }\n\n // Ignore clicks on interactive elements within the row\n let inputParent = event.target.closest('input, button, label, a, select');\n\n if (inputParent) {\n return;\n }\n\n let rowMeta = meta.forRow(row, RowSelection);\n\n rowMeta.toggle();\n };\n}\n\nclass TableMeta {\n #table: Table;\n\n constructor(table: Table) {\n this.#table = table;\n }\n\n @cached\n get selection(): Set<unknown> {\n let passedSelection = options.forTable(this.#table, RowSelection).selection;\n\n assert(`Cannot access selection because it is undefined`, passedSelection);\n\n if (passedSelection instanceof Set) {\n return passedSelection;\n }\n\n return new Set(passedSelection);\n }\n}\n\nclass RowMeta {\n #row: Row<any>;\n\n constructor(row: Row<any>) {\n this.#row = row;\n }\n\n get isSelected(): boolean {\n let tableMeta = meta.forTable(this.#row.table, RowSelection);\n let pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n let compareWith = pluginOptions.key(this.#row.data);\n\n return tableMeta.selection.has(compareWith);\n }\n\n let compareWith = this.#row.data;\n\n return tableMeta.selection.has(compareWith);\n }\n\n toggle = () => {\n if (this.isSelected) {\n this.deselect();\n\n return;\n }\n\n this.select();\n };\n\n select = () => {\n let pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n let key = pluginOptions.key(this.#row.data);\n\n pluginOptions.onSelect?.(key, this.#row);\n\n return;\n }\n\n pluginOptions.onSelect?.(this.#row.data, this.#row);\n };\n\n deselect = () => {\n let pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n let key = pluginOptions.key(this.#row.data);\n\n pluginOptions.onDeselect?.(key, this.#row);\n\n return;\n }\n\n pluginOptions.onDeselect?.(this.#row.data, this.#row);\n };\n}\n"],"names":["_classApplyDescriptorSet","receiver","descriptor","value","set","call","writable","TypeError","_classPrivateFieldSet","privateMap","classExtractFieldDescriptor","classApplyDescriptorSet","RowSelection","BasePlugin","constructor","table","row","RowMeta","TableMeta","element","handler","event","addEventListener","removeEventListener","assert","target","HTMLElement","SVGElement","selection","document","getSelection","type","anchorNode","isSelectingText","contains","stopPropagation","inputParent","closest","rowMeta","meta","forRow","toggle","pluginOptions","options","forTable","onSelect","onDeselect","passedSelection","Set","cached","isSelected","deselect","select","key","data","tableMeta","compareWith","has"],"mappings":";;;;;;;;AAAe,SAASA,wBAAwB,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GAAG,CAACD,WAAW,CAAC,CAAA;AAC7C,KAAA;AAEA,IAAA,IAAIA,WAAW,GAAG,qBAAI,CAAA,IAAA,EAAA,IAAA,CAAA,CAAMF,IAAI,CAAA;AAEhC,IAAA,OAAOC,SAAS,CAAC3B,SAAS,CAAC6B,GAAG,CAACD,WAAW,CAAC,CAAA;AAC7C,GAAA;AAuCF;;;;"}
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../../node_modules/.pnpm/@babel+runtime@7.21.0/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js","../../../../node_modules/.pnpm/@babel+runtime@7.21.0/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js","../../../src/plugins/row-selection/plugin.ts"],"sourcesContent":["export default function _classApplyDescriptorSet(receiver, descriptor, value) {\n if (descriptor.set) {\n descriptor.set.call(receiver, value);\n } else {\n if (!descriptor.writable) {\n throw new TypeError(\"attempted to set read only private field\");\n }\n descriptor.value = value;\n }\n}","import classApplyDescriptorSet from \"./classApplyDescriptorSet.js\";\nimport classExtractFieldDescriptor from \"./classExtractFieldDescriptor.js\";\nexport default function _classPrivateFieldSet(receiver, privateMap, value) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"set\");\n classApplyDescriptorSet(receiver, descriptor, value);\n return value;\n}","import { cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\n\nimport { BasePlugin, meta, options } from '../-private/base';\n\nimport type { Row, Table } from '[public-types]';\nimport type { PluginSignature, RowApi } from '#interfaces';\n\nexport interface Signature<DataType = any, Key = DataType> extends PluginSignature {\n Meta: {\n Table: TableMeta;\n Row: RowMeta;\n };\n Options: {\n Plugin: {\n /**\n * A set of selected things using the same type of Identifier\n * returned from `key`\n */\n selection: Set<Key> | Array<Key>;\n } & (\n | {\n /**\n * For a given row's data, how should the key be determined?\n * this could be a remote id from a database, or some other attribute\n *\n * This could be useful for indicating in UI if a particular item is selected.\n *\n * If not provided, the row's data will be used as the key\n */\n key: (data: DataType) => Key;\n /**\n * When a row is clicked, this will be invoked,\n * allowing you to update your selection object\n */\n onSelect: (item: Key, row: Row<DataType>) => void;\n /**\n * When a row is clicked (and the row is selected), this will be invoked,\n * allowing you to update your selection object\n */\n onDeselect: (item: Key, row: Row<DataType>) => void;\n }\n | {\n /**\n * When a row is clicked (and the row is not selected), this will be invoked,\n * allowing you to update your selection object\n */\n onSelect: (item: DataType | any, row: Row<DataType>) => void;\n /**\n * When a row is clicked (and the row is selected), this will be invoked,\n * allowing you to update your selection object\n */\n onDeselect: (item: DataType | any, row: Row<DataType>) => void;\n }\n );\n };\n}\n\n/**\n * This plugin provides a means of managing selection of a single row in a table.\n *\n * The state of what is actually selected is managed by you, but this plugin\n * will wire up the click listeners as well as let you know which *data* is clicked.\n */\nexport class RowSelection<DataType = any, Key = DataType> extends BasePlugin<\n Signature<DataType, Key>\n> {\n name = 'row-selection';\n\n meta = {\n row: RowMeta,\n table: TableMeta,\n };\n\n constructor(table: Table) {\n super(table);\n\n let pluginOptions = options.forTable(this.table, RowSelection);\n\n assert(\n `selection, onSelect, and onDeselect are all required arguments for the RowSelection plugin. ` +\n `Specify these options via \\`RowSelection.with(() => ({ selection, onSelect, onDeselect }))\\``,\n pluginOptions.selection && pluginOptions.onSelect && pluginOptions.onDeselect\n );\n }\n\n rowModifier = (element: HTMLElement, { row }: RowApi<Table<any>>) => {\n let handler = (event: Event) => {\n this.#clickHandler(row, event);\n };\n\n element.addEventListener('click', handler);\n\n return () => {\n element.removeEventListener('click', handler);\n };\n };\n\n #clickHandler = (row: Row, event: Event) => {\n assert(\n `expected event.target to be an instance of HTMLElement`,\n event.target instanceof HTMLElement || event.target instanceof SVGElement\n );\n\n let selection = document.getSelection();\n\n if (selection) {\n let { type, anchorNode } = selection;\n let isSelectingText = type === 'Range' && event.target?.contains(anchorNode);\n\n if (isSelectingText) {\n event.stopPropagation();\n\n return;\n }\n }\n\n // Ignore clicks on interactive elements within the row\n let inputParent = event.target.closest('input, button, label, a, select');\n\n if (inputParent) {\n return;\n }\n\n let rowMeta = meta.forRow(row, RowSelection);\n\n rowMeta.toggle();\n };\n}\n\nclass TableMeta {\n #table: Table;\n\n constructor(table: Table) {\n this.#table = table;\n }\n\n @cached\n get selection(): Set<unknown> {\n let passedSelection = options.forTable(this.#table, RowSelection).selection;\n\n assert(`Cannot access selection because it is undefined`, passedSelection);\n\n if (passedSelection instanceof Set) {\n return passedSelection;\n }\n\n return new Set(passedSelection);\n }\n}\n\nclass RowMeta {\n #row: Row<any>;\n\n constructor(row: Row<any>) {\n this.#row = row;\n }\n\n get isSelected(): boolean {\n let tableMeta = meta.forTable(this.#row.table, RowSelection);\n let pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n let compareWith = pluginOptions.key(this.#row.data);\n\n return tableMeta.selection.has(compareWith);\n }\n\n let compareWith = this.#row.data;\n\n return tableMeta.selection.has(compareWith);\n }\n\n toggle = () => {\n if (this.isSelected) {\n this.deselect();\n\n return;\n }\n\n this.select();\n };\n\n select = () => {\n let pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n let key = pluginOptions.key(this.#row.data);\n\n pluginOptions.onSelect?.(key, this.#row);\n\n return;\n }\n\n pluginOptions.onSelect?.(this.#row.data, this.#row);\n };\n\n deselect = () => {\n let pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n let key = pluginOptions.key(this.#row.data);\n\n pluginOptions.onDeselect?.(key, this.#row);\n\n return;\n }\n\n pluginOptions.onDeselect?.(this.#row.data, this.#row);\n };\n}\n"],"names":["_classApplyDescriptorSet","receiver","descriptor","value","set","call","writable","TypeError","_classPrivateFieldSet","privateMap","classExtractFieldDescriptor","classApplyDescriptorSet","cached","macroCondition","dependencySatisfies","importSync","_clickHandler","WeakMap","RowSelection","BasePlugin","constructor","table","_defineProperty","row","RowMeta","TableMeta","element","handler","event","_classPrivateFieldGet","addEventListener","removeEventListener","_classPrivateFieldInitSpec","assert","target","HTMLElement","SVGElement","selection","document","getSelection","type","anchorNode","isSelectingText","contains","stopPropagation","inputParent","closest","rowMeta","meta","forRow","toggle","pluginOptions","options","forTable","onSelect","onDeselect","_class","_table","passedSelection","Set","_applyDecoratedDescriptor","prototype","Object","getOwnPropertyDescriptor","_row","isSelected","deselect","select","key","data","tableMeta","compareWith","has"],"mappings":";;;;;;;;AAAe,SAASA,wBAAwBA,CAACC,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAE;EAC5E,IAAID,UAAU,CAACE,GAAG,EAAE;IAClBF,UAAU,CAACE,GAAG,CAACC,IAAI,CAACJ,QAAQ,EAAEE,KAAK,CAAC,CAAA;AACtC,GAAC,MAAM;AACL,IAAA,IAAI,CAACD,UAAU,CAACI,QAAQ,EAAE;AACxB,MAAA,MAAM,IAAIC,SAAS,CAAC,0CAA0C,CAAC,CAAA;AACjE,KAAA;IACAL,UAAU,CAACC,KAAK,GAAGA,KAAK,CAAA;AAC1B,GAAA;AACF;;ACPe,SAASK,qBAAqBA,CAACP,QAAQ,EAAEQ,UAAU,EAAEN,KAAK,EAAE;EACzE,IAAID,UAAU,GAAGQ,4BAA2B,CAACT,QAAQ,EAAEQ,UAAU,EAAE,KAAK,CAAC,CAAA;AACzEE,EAAAA,wBAAuB,CAACV,QAAQ,EAAEC,UAAU,EAAEC,KAAK,CAAC,CAAA;AACpD,EAAA,OAAOA,KAAK,CAAA;AACd;;;;;ACN2C,IAAAS,MAAA,GAAAC,cAAA,CAAAC,mBAAA,CAAA,cAAA,EAAA,kBAAA,CAAA,CAAA,GAAAC,UAAA,CAAA,mBAAA,CAAA,CAAAH,MAAA,GAAAG,UAAA,CAAA,iCAAA,CAAA,CAAAH,MAAA,CAAA;AAGkB,IAAAI,aAAA,oBAAAC,OAAA,EAAA,CAAA;AAuD7D;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAAyCC,UAAU,CAE1E;EAQAC,WA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AAA;AAC5D,IAAA,IAAIiC,aAAa,GAAGC,OAAO,CAACC,QAAQ,CAACxB,qBAAA,CAAI,IAAA,EAAAmC,IAAA,CAAA,CAAM3C,KAAK,EAAEH,YAAY,CAAC,CAAA;AAEnE,IAAA,IAAI,KAAK,IAAIiC,aAAa,IAAIA,aAAa,CAACiB,GAAG,EAAE;AAC/C,MAAA,IAAIG,WAAW,GAAGpB,aAAa,CAACiB,GAAG,CAACvC,qBAAA,CAAA,IAAI,EAAAmC,IAAA,CAAMK,CAAAA,IAAI,CAAC,CAAA;AAEnD,MAAA,OAAOC,SAAS,CAACjC,SAAS,CAACmC,GAAG,CAACD,WAAW,CAAC,CAAA;AAC7C,KAAA;AAEA,IAAA,IAAIA,WAAW,GAAG1C,qBAAA,KAAI,EAAAmC,IAAA,EAAMK,IAAI,CAAA;AAEhC,IAAA,OAAOC,SAAS,CAACjC,SAAS,CAACmC,GAAG,CAACD,WAAW,CAAC,CAAA;AAC7C,GAAA;AAuCF;;;;","x_google_ignoreList":[0,1]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { htmlSafe } from '@ember/template';
|
2
|
-
import { Column } from "../../index";
|
2
|
+
import { Column } from "../../index.js";
|
3
3
|
declare const isSticky: <DataType = unknown>(column: Column<DataType>) => boolean;
|
4
4
|
declare const styleFor: <DataType = unknown>(column: Column<DataType>) => Partial<CSSStyleDeclaration>;
|
5
5
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base';\nimport { StickyColumns } from './plugin';\n\nimport type { Column } from '[public-types]';\n\nexport const isSticky = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, StickyColumns).isSticky;\n\nexport const styleFor = <DataType = unknown>(\n column: Column<DataType>\n): Partial<CSSStyleDeclaration> => meta.forColumn(column, StickyColumns).style;\n\n/**\n * In this plugin, both header and cells have the same styles,\n * if applicable.\n *\n * Until this RFC https://github.com/emberjs/rfcs/pull/883\n * is merged and implemented, we can't performantly\n * use modifiers for apply styles.\n *\n * In the mean time, we'll need to append style strings, which is more work\n * for consumers, but is a reasonable trade-off for now.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>\n): ReturnType<typeof htmlSafe> => {\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n let result = '';\n\n if (columnMeta.isSticky) {\n for (let [key, value] of Object.entries(columnMeta.style)) {\n result += `${toStyle(key)}:${value};`;\n }\n\n result = ';' + result;\n }\n\n return htmlSafe(result);\n};\n\n/**\n * the JS API for styles is camel case,\n * but CSS is kebab-case. To save on complexity and\n * amount of code, we have a super small conversion function\n * for only the properties relevant to the sticky plugin.\n */\nconst toStyle = (key: string): string => {\n switch (key) {\n case 'zIndex':\n return 'z-index';\n default:\n return key;\n }\n};\n"],"names":["isSticky","column","meta","forColumn","StickyColumns","styleFor","style","styleStringFor","columnMeta","result","key","value","Object","entries","toStyle","htmlSafe"],"mappings":";;;;AAOaA,MAAAA,QAAQ,GAAwBC,MAAwB,IACnEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACJ,SAAQ;AAEnCK,MAAAA,QAAQ,GACnBJ,MAAwB,IACSC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACE,MAAK;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GACzBN,MAAwB,IACQ;EAChC,IAAIO,UAAU,GAAGN,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAAA;EAEtD,IAAIK,MAAM,GAAG,EAAE,CAAA;EAEf,IAAID,UAAU,CAACR,QAAQ,EAAE;AACvB,IAAA,KAAK,IAAI,CAACU,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACF,KAAK,CAAC,EAAE;MACzDG,MAAM,IAAK,GAAEK,OAAO,CAACJ,GAAG,CAAE,CAAA,CAAA,EAAGC,KAAM,CAAE,CAAA,CAAA,CAAA;AACvC,KAAA;IAEAF,MAAM,GAAG,GAAG,GAAGA,MAAM,CAAA;AACvB,GAAA;EAEA,OAAOM,QAAQ,CAACN,MAAM,CAAC,CAAA;AACzB,EAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,OAAO,GAAIJ,GAAW,IAAa;AACvC,EAAA,QAAQA,GAAG;AACT,IAAA,KAAK,QAAQ;AACX,MAAA,OAAO,SAAS,CAAA;AAClB,IAAA;AACE,MAAA,OAAOA,GAAG,CAAA;AAAC,GAAA;AAEjB,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base';\nimport { StickyColumns } from './plugin';\n\nimport type { Column } from '[public-types]';\n\nexport const isSticky = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, StickyColumns).isSticky;\n\nexport const styleFor = <DataType = unknown>(\n column: Column<DataType>\n): Partial<CSSStyleDeclaration> => meta.forColumn(column, StickyColumns).style;\n\n/**\n * In this plugin, both header and cells have the same styles,\n * if applicable.\n *\n * Until this RFC https://github.com/emberjs/rfcs/pull/883\n * is merged and implemented, we can't performantly\n * use modifiers for apply styles.\n *\n * In the mean time, we'll need to append style strings, which is more work\n * for consumers, but is a reasonable trade-off for now.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>\n): ReturnType<typeof htmlSafe> => {\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n let result = '';\n\n if (columnMeta.isSticky) {\n for (let [key, value] of Object.entries(columnMeta.style)) {\n result += `${toStyle(key)}:${value};`;\n }\n\n result = ';' + result;\n }\n\n return htmlSafe(result);\n};\n\n/**\n * the JS API for styles is camel case,\n * but CSS is kebab-case. To save on complexity and\n * amount of code, we have a super small conversion function\n * for only the properties relevant to the sticky plugin.\n */\nconst toStyle = (key: string): string => {\n switch (key) {\n case 'zIndex':\n return 'z-index';\n case 'minWidth':\n return 'min-width';\n default:\n return key;\n }\n};\n"],"names":["isSticky","column","meta","forColumn","StickyColumns","styleFor","style","styleStringFor","columnMeta","result","key","value","Object","entries","toStyle","htmlSafe"],"mappings":";;;;AAOaA,MAAAA,QAAQ,GAAwBC,MAAwB,IACnEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACJ,SAAQ;AAEnCK,MAAAA,QAAQ,GACnBJ,MAAwB,IACSC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACE,MAAK;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GACzBN,MAAwB,IACQ;EAChC,IAAIO,UAAU,GAAGN,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAAA;EAEtD,IAAIK,MAAM,GAAG,EAAE,CAAA;EAEf,IAAID,UAAU,CAACR,QAAQ,EAAE;AACvB,IAAA,KAAK,IAAI,CAACU,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACF,KAAK,CAAC,EAAE;MACzDG,MAAM,IAAK,GAAEK,OAAO,CAACJ,GAAG,CAAE,CAAA,CAAA,EAAGC,KAAM,CAAE,CAAA,CAAA,CAAA;AACvC,KAAA;IAEAF,MAAM,GAAG,GAAG,GAAGA,MAAM,CAAA;AACvB,GAAA;EAEA,OAAOM,QAAQ,CAACN,MAAM,CAAC,CAAA;AACzB,EAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,OAAO,GAAIJ,GAAW,IAAa;AACvC,EAAA,QAAQA,GAAG;AACT,IAAA,KAAK,QAAQ;AACX,MAAA,OAAO,SAAS,CAAA;AAClB,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,WAAW,CAAA;AACpB,IAAA;AACE,MAAA,OAAOA,GAAG,CAAA;AAAC,GAAA;AAEjB,CAAC;;;;"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from "./helpers";
|
2
|
-
export { StickyColumns, StickyColumns as Plugin } from "./plugin";
|
3
|
-
export type { Signature } from "./plugin";
|
1
|
+
export * from "./helpers.js";
|
2
|
+
export { StickyColumns, StickyColumns as Plugin } from "./plugin.js";
|
3
|
+
export type { Signature } from "./plugin.js";
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { BasePlugin } from "../-private/base";
|
2
|
-
import { ColumnApi } from "../index";
|
3
|
-
import { Column } from "../../index";
|
1
|
+
import { BasePlugin } from "../-private/base.js";
|
2
|
+
import { ColumnApi } from "../index.js";
|
3
|
+
import { Column } from "../../index.js";
|
4
4
|
interface ColumnOptions {
|
5
5
|
/**
|
6
6
|
* Whether or not to enable stickiness on the column
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { _ as _applyDecoratedDescriptor } from '../../applyDecoratedDescriptor-6b986a67.js';
|
2
|
-
import { _ as _defineProperty } from '../../defineProperty-
|
2
|
+
import { _ as _defineProperty } from '../../defineProperty-4f0781e1.js';
|
3
3
|
import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
|
4
4
|
import '@glimmer/tracking';
|
5
5
|
import { assert } from '@ember/debug';
|
@@ -45,6 +45,11 @@ class StickyColumns extends BasePlugin {
|
|
45
45
|
this.conditionallyRemoveStyles(element);
|
46
46
|
}
|
47
47
|
});
|
48
|
+
/**
|
49
|
+
* Not yet supported. Pending Ember RFC #883
|
50
|
+
*
|
51
|
+
* TODO: switch ColumnApi to "RowApi", add the row's data
|
52
|
+
*/
|
48
53
|
_defineProperty(this, "cellModifier", (element, {
|
49
54
|
column,
|
50
55
|
table
|
@@ -67,6 +72,13 @@ class StickyColumns extends BasePlugin {
|
|
67
72
|
*
|
68
73
|
* Contains state and behaviors for the sticiness
|
69
74
|
*/
|
75
|
+
/**
|
76
|
+
* This plugin requires that the resizing plugin be present, because the resizing plugin is
|
77
|
+
* what manages the base width of the columns.
|
78
|
+
*
|
79
|
+
* Other width-management plugins can be used instead of ColumnResizing, but they must declare
|
80
|
+
* that they manage the width of the columns.
|
81
|
+
*/
|
70
82
|
_defineProperty(StickyColumns, "requires", ['columnWidth']);
|
71
83
|
let ColumnMeta = (_class = class ColumnMeta {
|
72
84
|
constructor(column) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/sticky-columns/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\n\nimport { BasePlugin, columns, meta, options } from '../-private/base';\nimport { applyStyles } from '../-private/utils';\n\nimport type { ColumnApi } from '[public-plugin-types]';\nimport type { Column } from '[public-types]';\n\nconst DEFAULT_Z_INDEX = '8';\n\ninterface ColumnOptions {\n /**\n * Whether or not to enable stickiness on the column\n * (default is false)\n *\n * valid values: 'left', 'right', false\n */\n sticky?: boolean | string;\n}\n\nexport interface Signature {\n Options: {\n Column: ColumnOptions;\n Plugin: {\n /**\n * Opts this plugin out of engaging in the modifier system\n * and instead requires setting a `style` attribute on\n * th / td tags for getting the \"position: sticky\" behovior\n * on columns.\n */\n workaroundForModifierTimingUpdateRFC883?: boolean;\n };\n };\n Meta: {\n Table: TableMeta;\n Column: ColumnMeta;\n };\n}\n\nexport class StickyColumns extends BasePlugin<Signature> {\n name = 'sticky-columns';\n\n /**\n * This plugin requires that the resizing plugin be present, because the resizing plugin is\n * what manages the base width of the columns.\n *\n * Other width-management plugins can be used instead of ColumnResizing, but they must declare\n * that they manage the width of the columns.\n */\n static requires = ['columnWidth'];\n\n meta = {\n table: TableMeta,\n column: ColumnMeta,\n };\n\n conditionallyRemoveStyles = (element: HTMLElement) => {\n if (element.style.getPropertyValue('position') === 'sticky') {\n element.style.removeProperty('position');\n }\n\n if (element.style.getPropertyValue('left')) {\n element.style.left = '';\n }\n\n if (element.style.getPropertyValue('right')) {\n element.style.right = '';\n }\n\n if (element.style.zIndex === DEFAULT_Z_INDEX) {\n element.style.zIndex = '';\n }\n };\n\n headerCellModifier = (element: HTMLElement, { column, table }: ColumnApi) => {\n if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {\n return;\n }\n\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n if (columnMeta.isSticky) {\n applyStyles(element, columnMeta.style);\n } else {\n this.conditionallyRemoveStyles(element);\n }\n };\n\n /**\n * Not yet supported. Pending Ember RFC #883\n *\n * TODO: switch ColumnApi to \"RowApi\", add the row's data\n */\n cellModifier = (element: HTMLElement, { column, table }: ColumnApi) => {\n if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {\n return;\n }\n\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n if (columnMeta.isSticky) {\n applyStyles(element, columnMeta.style);\n } else {\n this.conditionallyRemoveStyles(element);\n }\n };\n}\n\n/**\n * @private\n *\n * Contains state and behaviors for the sticiness\n */\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n get isSticky() {\n return this.position !== 'none';\n }\n\n get position(): 'left' | 'right' | 'none' {\n let sticky = options.forColumn(this.column, StickyColumns)?.sticky;\n\n assert(\n `Invalid sticky value, ${sticky}. Valid values: 'left', 'right', false`,\n sticky === 'left' || sticky === 'right' || sticky === false || sticky === undefined\n );\n\n return sticky || 'none';\n }\n\n @cached\n get offset() {\n if (!this.isSticky) {\n return;\n }\n\n if (this.position === 'left') {\n let leftColumns = columns.before(this.column);\n let left = leftColumns.reduce((acc, column) => {\n let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');\n\n if (hasWidth(columnMeta)) {\n return acc + (columnMeta.width ?? 0);\n }\n\n return acc;\n }, 0);\n\n return `${left}px`;\n }\n\n if (this.position === 'right') {\n let rightColumns = columns.after(this.column);\n let right = rightColumns.reduce((acc, column) => {\n let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');\n\n if (hasWidth(columnMeta)) {\n return acc + (columnMeta.width ?? 0);\n }\n\n return acc;\n }, 0);\n\n return `${right}px`;\n }\n\n return;\n }\n\n get style(): Partial<Pick<CSSStyleDeclaration, 'position' | 'left' | 'right' | 'zIndex'>> {\n if (this.isSticky) {\n return {\n position: 'sticky',\n [this.position]: this.offset,\n zIndex: DEFAULT_Z_INDEX,\n };\n }\n\n return {};\n }\n}\n\nfunction hasWidth(obj: any): obj is { width?: number } {\n return typeof obj === 'object' && obj && 'width' in obj;\n}\n\n/* This Plugin does not need table state */\nexport class TableMeta {}\n"],"names":["DEFAULT_Z_INDEX","StickyColumns","BasePlugin","table","TableMeta","column","ColumnMeta","element","style","getPropertyValue","removeProperty","left","right","zIndex","options","forTable","workaroundForModifierTimingUpdateRFC883","columnMeta","meta","forColumn","isSticky","applyStyles","conditionallyRemoveStyles","constructor","position","sticky","assert","undefined","offset","leftColumns","columns","before","reduce","acc","withFeature","hasWidth","width","rightColumns","after","cached","obj"],"mappings":";;;;;;;;;AAA2C,IAAA,MAAA,GAAA,cAAA,CAAA,mBAAA,CAAA,cAAA,EAAA,kBAAA,CAAA,CAAA,GAAA,UAAA,CAAA,mBAAA,CAAA,CAAA,MAAA,GAAA,UAAA,CAAA,iCAAA,CAAA,CAAA,MAAA,CAAA;AAS3C,MAAMA,eAAe,GAAG,GAAG,CAAA;AA+BpB,MAAMC,aAAa,SAASC,UAAU,CAAY;AAAA,EAAA,WAAA,CAAA,GAAA,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAChD,gBAAgB,CAAA,CAAA;IAAA,eAWhB,CAAA,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,KAAK,EAAEC,SAAS;AAChBC,MAAAA,MAAM,EAAEC,UAAAA;KACT,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,2BAAA,EAE4BC,OAAoB,IAAK;MACpD,IAAIA,O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AEA,IAAA,OAAA;AACF,GAAA;AAEA,EAAA,IAAIJ,KAAK,GAAiF;IACxF,IAAI,IAAI,CAACY,QAAQ,EAAE;MACjB,OAAO;AACLI,QAAAA,QAAQ,EAAE,QAAQ;AAClB,QAAA,CAAC,IAAI,CAACA,QAAQ,GAAG,IAAI,CAACI,MAAM;AAC5Bf,QAAAA,MAAM,EAAEb,eAAAA;OACT,CAAA;AACH,KAAA;AAEA,IAAA,OAAO,EAAE,CAAA;AACX,GAAA;AACF,CAAC,0DAlDEuC,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,QAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,GAAA,MAAA,EAAA;AAoDT,SAASJ,QAAQ,CAACK,GAAQ,EAA6B;EACrD,OAAO,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,IAAI,OAAO,IAAIA,GAAG,CAAA;AACzD,CAAA;;AAEA;AACO,MAAMpC,SAAS,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/sticky-columns/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\n\nimport { BasePlugin, columns, meta, options } from '../-private/base';\nimport { applyStyles } from '../-private/utils';\n\nimport type { ColumnApi } from '[public-plugin-types]';\nimport type { Column } from '[public-types]';\n\nconst DEFAULT_Z_INDEX = '8';\n\ninterface ColumnOptions {\n /**\n * Whether or not to enable stickiness on the column\n * (default is false)\n *\n * valid values: 'left', 'right', false\n */\n sticky?: boolean | string;\n}\n\nexport interface Signature {\n Options: {\n Column: ColumnOptions;\n Plugin: {\n /**\n * Opts this plugin out of engaging in the modifier system\n * and instead requires setting a `style` attribute on\n * th / td tags for getting the \"position: sticky\" behovior\n * on columns.\n */\n workaroundForModifierTimingUpdateRFC883?: boolean;\n };\n };\n Meta: {\n Table: TableMeta;\n Column: ColumnMeta;\n };\n}\n\nexport class StickyColumns extends BasePlugin<Signature> {\n name = 'sticky-columns';\n\n /**\n * This plugin requires that the resizing plugin be present, because the resizing plugin is\n * what manages the base width of the columns.\n *\n * Other width-management plugins can be used instead of ColumnResizing, but they must declare\n * that they manage the width of the columns.\n */\n static requires = ['columnWidth'];\n\n meta = {\n table: TableMeta,\n column: ColumnMeta,\n };\n\n conditionallyRemoveStyles = (element: HTMLElement) => {\n if (element.style.getPropertyValue('position') === 'sticky') {\n element.style.removeProperty('position');\n }\n\n if (element.style.getPropertyValue('left')) {\n element.style.left = '';\n }\n\n if (element.style.getPropertyValue('right')) {\n element.style.right = '';\n }\n\n if (element.style.zIndex === DEFAULT_Z_INDEX) {\n element.style.zIndex = '';\n }\n };\n\n headerCellModifier = (element: HTMLElement, { column, table }: ColumnApi) => {\n if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {\n return;\n }\n\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n if (columnMeta.isSticky) {\n applyStyles(element, columnMeta.style);\n } else {\n this.conditionallyRemoveStyles(element);\n }\n };\n\n /**\n * Not yet supported. Pending Ember RFC #883\n *\n * TODO: switch ColumnApi to \"RowApi\", add the row's data\n */\n cellModifier = (element: HTMLElement, { column, table }: ColumnApi) => {\n if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {\n return;\n }\n\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n if (columnMeta.isSticky) {\n applyStyles(element, columnMeta.style);\n } else {\n this.conditionallyRemoveStyles(element);\n }\n };\n}\n\n/**\n * @private\n *\n * Contains state and behaviors for the sticiness\n */\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n get isSticky() {\n return this.position !== 'none';\n }\n\n get position(): 'left' | 'right' | 'none' {\n let sticky = options.forColumn(this.column, StickyColumns)?.sticky;\n\n assert(\n `Invalid sticky value, ${sticky}. Valid values: 'left', 'right', false`,\n sticky === 'left' || sticky === 'right' || sticky === false || sticky === undefined\n );\n\n return sticky || 'none';\n }\n\n @cached\n get offset() {\n if (!this.isSticky) {\n return;\n }\n\n if (this.position === 'left') {\n let leftColumns = columns.before(this.column);\n let left = leftColumns.reduce((acc, column) => {\n let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');\n\n if (hasWidth(columnMeta)) {\n return acc + (columnMeta.width ?? 0);\n }\n\n return acc;\n }, 0);\n\n return `${left}px`;\n }\n\n if (this.position === 'right') {\n let rightColumns = columns.after(this.column);\n let right = rightColumns.reduce((acc, column) => {\n let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');\n\n if (hasWidth(columnMeta)) {\n return acc + (columnMeta.width ?? 0);\n }\n\n return acc;\n }, 0);\n\n return `${right}px`;\n }\n\n return;\n }\n\n get style(): Partial<Pick<CSSStyleDeclaration, 'position' | 'left' | 'right' | 'zIndex'>> {\n if (this.isSticky) {\n return {\n position: 'sticky',\n [this.position]: this.offset,\n zIndex: DEFAULT_Z_INDEX,\n };\n }\n\n return {};\n }\n}\n\nfunction hasWidth(obj: any): obj is { width?: number } {\n return typeof obj === 'object' && obj && 'width' in obj;\n}\n\n/* This Plugin does not need table state */\nexport class TableMeta {}\n"],"names":["cached","macroCondition","dependencySatisfies","importSync","DEFAULT_Z_INDEX","StickyColumns","BasePlugin","constructor","args","_defineProperty","table","TableMeta","column","ColumnMeta","element","style","getPropertyValue","removeProperty","left","right","zIndex","options","forTable","workaroundForModifierTimingUpdateRFC883","columnMeta","meta","forColumn","isSticky","applyStyles","conditionallyRemoveStyles","_class","position","sticky","assert","undefined","offset","leftColumns","columns","before","reduce","acc","withFeature","hasWidth","width","rightColumns","after","_applyDecoratedDescriptor","prototype","Object","getOwnPropertyDescriptor","obj"],"mappings":";;;;;;;;;AAA2C,IAAAA,MAAA,GAAAC,cAAA,CAAAC,mBAAA,CAAA,cAAA,EAAA,kBAAA,CAAA,CAAA,GAAAC,UAAA,CAAA,mBAAA,CAAA,CAAAH,MAAA,GAAAG,UAAA,CAAA,iCAAA,CAAA,CAAAH,MAAA,CAAA;AAS3C,MA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"./-private/column";
|
3
|
-
import { TablePreferences } from "./-private/preferences";
|
4
|
-
import { Row } from "./-private/row";
|
5
|
-
import { BasePlugin, Plugin } from "./plugins/index";
|
6
|
-
import { Class } from "./-private/private-types";
|
7
|
-
import { TableConfig } from "./-private/interfaces/index";
|
2
|
+
import { Column } from "./-private/column.js";
|
3
|
+
import { TablePreferences } from "./-private/preferences.js";
|
4
|
+
import { Row } from "./-private/row.js";
|
5
|
+
import { BasePlugin, Plugin } from "./plugins/index.js";
|
6
|
+
import { Class } from "./-private/private-types.js";
|
7
|
+
import { TableConfig } from "./-private/interfaces/index.js";
|
8
8
|
interface Signature<DataType> {
|
9
9
|
Named: TableConfig<DataType>;
|
10
10
|
}
|
@@ -18,11 +18,26 @@ interface Signature<DataType> {
|
|
18
18
|
* ember-resources.
|
19
19
|
*/
|
20
20
|
declare const TABLE_KEY: unique symbol;
|
21
|
+
declare const TABLE_META_KEY: unique symbol;
|
22
|
+
declare const COLUMN_META_KEY: unique symbol;
|
23
|
+
declare const ROW_META_KEY: unique symbol;
|
21
24
|
declare class Table<DataType = unknown> extends Resource<Signature<DataType>> {
|
22
25
|
/**
|
23
26
|
* @private
|
24
27
|
*/
|
25
28
|
[TABLE_KEY]: string;
|
29
|
+
/**
|
30
|
+
* @private
|
31
|
+
*/
|
32
|
+
[TABLE_META_KEY]: Map<Class<unknown>, any>;
|
33
|
+
/**
|
34
|
+
* @private
|
35
|
+
*/
|
36
|
+
[COLUMN_META_KEY]: WeakMap<Column<unknown>, Map<Class<unknown>, any>>;
|
37
|
+
/**
|
38
|
+
* @private
|
39
|
+
*/
|
40
|
+
[ROW_META_KEY]: WeakMap<Row<Record<string, unknown>>, Map<Class<unknown>, any>>;
|
26
41
|
/**
|
27
42
|
* @private
|
28
43
|
*
|
@@ -126,4 +141,4 @@ declare class Table<DataType = unknown> extends Resource<Signature<DataType>> {
|
|
126
141
|
resetScrollContainer(): void;
|
127
142
|
resetToDefaults(): void;
|
128
143
|
}
|
129
|
-
export { TABLE_KEY, Table };
|
144
|
+
export { TABLE_KEY, TABLE_META_KEY, COLUMN_META_KEY, ROW_META_KEY, Table };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _defineProperty } from './defineProperty-
|
1
|
+
import { _ as _defineProperty } from './defineProperty-4f0781e1.js';
|
2
2
|
import { _ as _applyDecoratedDescriptor } from './applyDecoratedDescriptor-6b986a67.js';
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
4
4
|
import { getOwner, setOwner } from '@ember/application';
|
@@ -41,6 +41,9 @@ const DEFAULT_COLUMN_CONFIG = {
|
|
41
41
|
* ember-resources.
|
42
42
|
*/
|
43
43
|
const TABLE_KEY = Symbol('__TABLE_KEY__');
|
44
|
+
const TABLE_META_KEY = Symbol('__TABLE_META__');
|
45
|
+
const COLUMN_META_KEY = Symbol('__COLUMN_META__');
|
46
|
+
const ROW_META_KEY = Symbol('__ROW_META__');
|
44
47
|
const attachContainer = (element, table) => {
|
45
48
|
assert('Must be installed on an HTMLElement', element instanceof HTMLElement);
|
46
49
|
table.scrollContainerElement = element;
|
@@ -48,11 +51,56 @@ const attachContainer = (element, table) => {
|
|
48
51
|
let Table = (_class = class Table extends Resource {
|
49
52
|
constructor(...args) {
|
50
53
|
super(...args);
|
54
|
+
/**
|
55
|
+
* @private
|
56
|
+
*/
|
51
57
|
_defineProperty(this, TABLE_KEY, guidFor(this));
|
58
|
+
/**
|
59
|
+
* @private
|
60
|
+
*/
|
61
|
+
_defineProperty(this, TABLE_META_KEY, new Map());
|
62
|
+
/**
|
63
|
+
* @private
|
64
|
+
*/
|
65
|
+
_defineProperty(this, COLUMN_META_KEY, new WeakMap());
|
66
|
+
/**
|
67
|
+
* @private
|
68
|
+
*/
|
69
|
+
_defineProperty(this, ROW_META_KEY, new WeakMap());
|
70
|
+
/**
|
71
|
+
* @private
|
72
|
+
*
|
73
|
+
* Unused for now, may be used in the future.
|
74
|
+
* This data is collected along with the scrollContainerWidth, (which is currently in use)
|
75
|
+
*/
|
52
76
|
_initializerDefineProperty(this, "scrollContainerHeight", _descriptor, this);
|
77
|
+
/**
|
78
|
+
* @private
|
79
|
+
*
|
80
|
+
* Used to help determine how much space we can give to columns.
|
81
|
+
* As we generate widths for columns, the columns' widths must
|
82
|
+
* add up to about this number.
|
83
|
+
*/
|
53
84
|
_initializerDefineProperty(this, "scrollContainerWidth", _descriptor2, this);
|
85
|
+
/**
|
86
|
+
* @private
|
87
|
+
*
|
88
|
+
* Lazy way to delay consuming arguments until they are needed.
|
89
|
+
*/
|
54
90
|
_initializerDefineProperty(this, "args", _descriptor3, this);
|
91
|
+
/**
|
92
|
+
* @private
|
93
|
+
*/
|
55
94
|
_defineProperty(this, "scrollContainerElement", void 0);
|
95
|
+
/**
|
96
|
+
* Collection of utility modifiers that are the result of composing modifiers
|
97
|
+
* from plugins.
|
98
|
+
*
|
99
|
+
* Using this is optional, and you can "just" use modifiers from specific plugins
|
100
|
+
* in specific places if you wish -- but these exists as a "convenience".
|
101
|
+
*
|
102
|
+
* These are all no-use, no-cost utilities
|
103
|
+
*/
|
56
104
|
_defineProperty(this, "modifiers", {
|
57
105
|
container: modifier(element => {
|
58
106
|
let modifiers = this.plugins.map(plugin => plugin.containerModifier);
|
@@ -128,6 +176,11 @@ let Table = (_class = class Table extends Resource {
|
|
128
176
|
}
|
129
177
|
}));
|
130
178
|
}
|
179
|
+
/**
|
180
|
+
* Interact with, save, modify, etc the preferences for the table,
|
181
|
+
* plugins, columns, etc
|
182
|
+
*/
|
183
|
+
|
131
184
|
/**
|
132
185
|
* @private
|
133
186
|
*/
|
@@ -152,17 +205,6 @@ let Table = (_class = class Table extends Resource {
|
|
152
205
|
this.resetScrollContainer();
|
153
206
|
}
|
154
207
|
}
|
155
|
-
|
156
|
-
/**
|
157
|
-
* Collection of utility modifiers that are the result of composing modifiers
|
158
|
-
* from plugins.
|
159
|
-
*
|
160
|
-
* Using this is optional, and you can "just" use modifiers from specific plugins
|
161
|
-
* in specific places if you wish -- but these exists as a "convenience".
|
162
|
-
*
|
163
|
-
* These are all no-use, no-cost utilities
|
164
|
-
*/
|
165
|
-
|
166
208
|
/**
|
167
209
|
* @private
|
168
210
|
*
|
@@ -243,5 +285,5 @@ let Table = (_class = class Table extends Resource {
|
|
243
285
|
initializer: null
|
244
286
|
}), _applyDecoratedDescriptor(_class.prototype, "plugins", [cached], Object.getOwnPropertyDescriptor(_class.prototype, "plugins"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetScrollContainer", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetScrollContainer"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetToDefaults", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetToDefaults"), _class.prototype)), _class);
|
245
287
|
|
246
|
-
export {
|
247
|
-
//# sourceMappingURL=table-
|
288
|
+
export { COLUMN_META_KEY as C, ROW_META_KEY as R, Table as T, _initializerDefineProperty as _, TABLE_META_KEY as a, TABLE_KEY as b };
|
289
|
+
//# sourceMappingURL=table-443deac1.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table-443deac1.js","sources":["../../node_modules/.pnpm/@babel+runtime@7.21.0/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../src/-private/table.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","import { cached, tracked } from '@glimmer/tracking';\nimport { getOwner, setOwner } from '@ember/application';\nimport { assert } from '@ember/debug';\nimport { action } from '@ember/object';\nimport { guidFor } from '@ember/object/internals';\n\nimport { isDevelopingApp, macroCondition } from '@embroider/macros';\nimport { modifier } from 'ember-modifier';\nimport { Resource } from 'ember-resources/core';\nimport { map } from 'ember-resources/util/map';\n\nimport { normalizePluginsConfig, verifyPlugins } from '../plugins/-private/utils';\nimport { Column } from './column';\nimport { TablePreferences } from './preferences';\nimport { Row } from './row';\nimport { composeFunctionModifiers } from './utils';\n\nimport type { BasePlugin, Plugin } from '../plugins';\nimport type { Class } from '[private-types]';\nimport type { Destructor, TableConfig } from '#interfaces';\n\nconst DEFAULT_COLUMN_CONFIG = {\n isVisible: true,\n minWidth: 128,\n};\n\ninterface Signature<DataType> {\n Named: TableConfig<DataType>;\n}\n\n/**\n * Because the table is our entry-point object to all the table behaviors,\n * we need a stable way to know which table we have.\n * Normally, this could be done with referential integrity / identity.\n * However, due to how resources are implemented, if the consumer opts to\n * not use the `@use` decorator, then proxies get involved.\n * The proxies don't maintain instanceof checks, which may be a bug in\n * ember-resources.\n */\nexport const TABLE_KEY = Symbol('__TABLE_KEY__');\nexport const TABLE_META_KEY = Symbol('__TABLE_META__');\nexport const COLUMN_META_KEY = Symbol('__COLUMN_META__');\nexport const ROW_META_KEY = Symbol('__ROW_META__');\n\nconst attachContainer = (element: Element, table: Table) => {\n assert('Must be installed on an HTMLElement', element instanceof HTMLElement);\n\n table.scrollContainerElement = element;\n};\n\nexport class Table<DataType = unknown> extends Resource<Signature<DataType>> {\n /**\n * @private\n */\n [TABLE_KEY] = guidFor(this);\n /**\n * @private\n */\n [TABLE_META_KEY] = new Map<Class<unknown>, any>();\n /**\n * @private\n */\n [COLUMN_META_KEY] = new WeakMap<Column, Map<Class<unknown>, any>>();\n /**\n * @private\n */\n [ROW_META_KEY] = new WeakMap<Row, Map<Class<unknown>, any>>();\n\n /**\n * @private\n *\n * Unused for now, may be used in the future.\n * This data is collected along with the scrollContainerWidth, (which is currently in use)\n */\n @tracked scrollContainerHeight?: number;\n\n /**\n * @private\n *\n * Used to help determine how much space we can give to columns.\n * As we generate widths for columns, the columns' widths must\n * add up to about this number.\n */\n @tracked scrollContainerWidth?: number;\n\n /**\n * @private\n *\n * Lazy way to delay consuming arguments until they are needed.\n */\n @tracked declare args: { named: Signature<DataType>['Named'] };\n\n /**\n * @private\n */\n scrollContainerElement?: HTMLElement;\n\n /**\n * Interact with, save, modify, etc the preferences for the table,\n * plugins, columns, etc\n */\n declare preferences: TablePreferences;\n\n /**\n * @private\n */\n modify(_: [] | undefined, named: Signature<DataType>['Named']) {\n this.args = { named };\n\n // only set the preferences once\n if (!this.preferences) {\n let { key = guidFor(this), adapter } = named?.preferences ?? {};\n\n // TODO: when no key is present,\n // use \"local-storage\" preferences.\n // it does not make sense to use a guid in a user's preferences\n this.preferences = new TablePreferences(key, adapter);\n } else {\n // subsequent updates to args\n this.resetScrollContainer();\n }\n }\n\n /**\n * Collection of utility modifiers that are the result of composing modifiers\n * from plugins.\n *\n * Using this is optional, and you can \"just\" use modifiers from specific plugins\n * in specific places if you wish -- but these exists as a \"convenience\".\n *\n * These are all no-use, no-cost utilities\n */\n modifiers = {\n container: modifier(\n (element: HTMLElement): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.containerModifier);\n let composed = composeFunctionModifiers([attachContainer, ...modifiers]);\n\n return composed(element, this);\n },\n { eager: false }\n ),\n\n // resize: ResizeModifier,\n // TODO: switch to composing real modifiers once \"curry\" and \"compose\"\n // RFCs are accepted and implemented\n //\n // Atm the moment, if _any_ header modifier's tracked data changes,\n // all the functions for all of the plugins run again.\n //\n // With curried+composed modifiers, only the plugin's headerModifier\n // that has tracked changes would run, leaving the other modifiers alone\n columnHeader: modifier(\n (element: HTMLElement, [column]: [Column<DataType>]): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.headerCellModifier);\n let composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { column, table: this });\n },\n { eager: false }\n ),\n\n row: modifier(\n (element: HTMLElement, [row]: [Row<DataType>]): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.rowModifier);\n let composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { row, table: this });\n },\n { eager: false }\n ),\n };\n\n /**\n * @private\n *\n * For all configured plugins, instantiates each one.\n * If the plugins argument changes to the Table (either directly or through\n * headlessTable, all state is lost and re-created)\n */\n @cached\n get plugins(): Plugin[] {\n let plugins = normalizePluginsConfig(this.args.named?.plugins);\n\n verifyPlugins(plugins);\n\n return plugins.map((tuple) => {\n // We don't need the options here\n let [PluginClass] = tuple;\n\n if (typeof PluginClass === 'function') {\n let plugin = new PluginClass(this);\n\n let owner = getOwner(this);\n\n assert(`The Table does not have an owner. cannot create a plugin without an owner`, owner);\n setOwner(plugin, owner);\n\n return plugin;\n }\n\n // This is a plugin object, rather than a class\n // TODO: add test coverage around using classless plugins\n return PluginClass;\n });\n }\n\n /**\n * Get the active plugin instance for the given plugin class\n */\n pluginOf<Instance extends BasePlugin<any>>(klass: Class<Instance>): Instance | undefined {\n let result = this.plugins.find((plugin) => plugin instanceof klass);\n\n /**\n * This is an unsafe cast, because Instance could be unrelated to any of the types\n * that matches Plugin[]\n *\n * For example, `table.pluginOf(MyCustomPlugin)`, where MyCustomPlugin isn't in the\n * `plugins` list. This partially a problem with how Array.prototype.find doesn't\n * effectively narrow for what we want (combined with TS being clunky around\n * comparing Instance and Class types).\n */\n return result as unknown as Instance | undefined;\n }\n\n /**\n * @private\n *\n * used by other private APIs\n */\n get config() {\n return this.args.named;\n }\n\n rows = map(this, {\n data: () => {\n let dataFn = this.args.named?.data;\n\n if (!dataFn) return [];\n\n return dataFn() ?? [];\n },\n map: (datum) => new Row(this, datum),\n });\n\n columns = map(this, {\n data: () => {\n let configFn = this.args.named?.columns;\n\n if (!configFn) return [];\n\n let result = configFn() ?? [];\n\n if (macroCondition(isDevelopingApp())) {\n /**\n * Assertions for a column config to be valid:\n * - every key must be unique\n */\n let keys = new Set();\n let allKeys = result.map((columnConfig) => columnConfig.key);\n\n result.forEach((columnConfig) => {\n if (keys.has(columnConfig.key)) {\n throw new Error(\n `Every column key in the table's column config must be unique. ` +\n `Found duplicate entry: ${columnConfig.key}. ` +\n `All keys used: ${allKeys}`\n );\n }\n\n keys.add(columnConfig.key);\n });\n }\n\n return result;\n },\n map: (config) => {\n return new Column<DataType>(this, { ...DEFAULT_COLUMN_CONFIG, ...config });\n },\n });\n\n /**\n * @private\n */\n @action\n resetScrollContainer() {\n if (!this.scrollContainerElement) return;\n\n this.scrollContainerElement.scrollTop = 0;\n }\n\n @action\n resetToDefaults() {\n this.plugins.forEach((plugin) => plugin.reset?.());\n }\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","cached","macroCondition","dependencySatisfies","importSync","DEFAULT_COLUMN_CONFIG","isVisible","minWidth","TABLE_KEY","Symbol","TABLE_META_KEY","COLUMN_META_KEY","ROW_META_KEY","attachContainer","element","table","assert","HTMLElement","scrollContainerElement","Table","_class","Resource","constructor","args","_defineProperty","guidFor","Map","WeakMap","_descriptor","_descriptor2","_descriptor3","container","modifier","modifiers","plugins","map","plugin","containerModifier","composed","composeFunctionModifiers","eager","columnHeader","column","headerCellModifier","row","rowModifier","data","dataFn","named","datum","Row","configFn","columns","result","isDevelopingApp","keys","Set","allKeys","columnConfig","key","forEach","has","Error","add","config","Column","modify","_","preferences","adapter","TablePreferences","resetScrollContainer","normalizePluginsConfig","verifyPlugins","tuple","PluginClass","owner","getOwner","setOwner","pluginOf","klass","find","scrollTop","resetToDefaults","reset","_applyDecoratedDescriptor","prototype","tracked","getOwnPropertyDescriptor","action"],"mappings":";;;;;;;;;;;;;;;;;AAAe,SAASA,0BAA0BA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACxF,IAAI,CAACD,UAAU,EAAE,OAAA;AACjBE,EAAAA,MAAM,CAACC,cAAc,CAACL,MAAM,EAAEC,QAAQ,EAAE;IACtCK,UAAU,EAAEJ,UAAU,CAACI,UAAU;IACjCC,YAAY,EAAEL,UAAU,CAACK,YAAY;IACrCC,QAAQ,EAAEN,UAAU,CAACM,QAAQ;AAC7BC,IAAAA,KAAK,EAAEP,UAAU,CAACQ,WAAW,GAAGR,UAAU,CAACQ,WAAW,CAACC,IAAI,CAACR,OAAO,CAAC,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