ember-headless-table 1.2.0 → 1.3.0

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.
@@ -7,6 +7,7 @@ import { ColumnResizing } from '../../plugins/column-resizing/plugin.js';
7
7
  import { ColumnVisibility } from '../../plugins/column-visibility/plugin.js';
8
8
  import { Sorting } from '../../plugins/data-sorting/plugin.js';
9
9
  import '../../plugins/data-sorting/types.js';
10
+ import '@ember/template';
10
11
  import { StickyColumns } from '../../plugins/sticky-columns/plugin.js';
11
12
 
12
13
  /////////////////////////////////////////////
@@ -1 +1 @@
1
- {"version":3,"file":"table-config.test.js","sources":["../../../src/-private/-type-tests/table-config.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins/-private/base';\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { ColumnVisibility } from '../../plugins/column-visibility';\nimport { DataSorting } from '../../plugins/data-sorting';\nimport { StickyColumns } from '../../plugins/sticky-columns';\n\nimport type { Plugins } from '../../plugins/-private/utils';\nimport type { SortItem } from '../../plugins/data-sorting';\nimport type { Plugin } from '[public-plugin-types]';\nimport type { TableConfig } from '[public-types]';\nimport type { Constructor } from '#private-types';\n\ntype TablePluginConfig = NonNullable<TableConfig<unknown>['plugins']>;\n\n/////////////////////////////////////////////\n// Sanity checks\nexpectTypeOf<Plugins>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<Plugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>, Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<BasePlugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<BasePlugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<\n [Constructor<BasePlugin>, Constructor<BasePlugin>]\n>().toMatchTypeOf<TablePluginConfig>();\n\nclass SomeClass {\n foo = 'bar';\n}\nclass LocalPlugin extends BasePlugin<{ Meta: { Table: SomeClass } }> {\n name = 'local-plugin';\n}\n\nexpectTypeOf([LocalPlugin]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// Making sure all plugins are subclassed appropriately\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<Plugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<Plugin<any>>>();\n\n// Actual plugins match the actual table config\nexpectTypeOf([DataSorting]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnResizing]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnVisibility]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([StickyColumns]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// The various ways to define plugins\nexpectTypeOf([DataSorting, ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\n\nconst onSort = (_sorts: SortItem<number>[]) => {\n /* intentionally empty */\n};\nconst sorts: SortItem<number>[] = [];\n\nexpectTypeOf([DataSorting.with(() => ({}))]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([DataSorting.with(() => ({ onSort, sorts }))]).toMatchTypeOf<TablePluginConfig>();\n"],"names":["expectTypeOf","toMatchTypeOf","LocalPlugin","BasePlugin","ColumnReordering","DataSorting","ColumnResizing","ColumnVisibility","StickyColumns","onSort","_sorts","sorts","with"],"mappings":";;;;;;;;;;;AAiBA;AACA;AACAA,YAAY,EAAW,CAACC,aAAa,EAAqB,CAAA;AAC1DD,YAAY,EAAyB,CAACC,aAAa,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MQ,MAAM,GAAIC,MAA0B,IAAK;AAC7C;AAAA,CACD,CAAA;AACD,MAAMC,KAAyB,GAAG,EAAE,CAAA;AAEpCX,YAAY,CAAC,CAACK,OAAW,CAACO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAACX,aAAa,EAAqB,CAAA;AAC/ED,YAAY,CAAC,CAACK,OAAW,CAACO,IAAI,CAAC,OAAO;EAAEH,MAAM;AAAEE,EAAAA,KAAAA;AAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAACV,aAAa,EAAqB"}
1
+ {"version":3,"file":"table-config.test.js","sources":["../../../src/-private/-type-tests/table-config.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins/-private/base';\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { ColumnVisibility } from '../../plugins/column-visibility';\nimport { DataSorting } from '../../plugins/data-sorting';\nimport { StickyColumns } from '../../plugins/sticky-columns';\n\nimport type { Plugins } from '../../plugins/-private/utils';\nimport type { SortItem } from '../../plugins/data-sorting';\nimport type { Plugin } from '[public-plugin-types]';\nimport type { TableConfig } from '[public-types]';\nimport type { Constructor } from '#private-types';\n\ntype TablePluginConfig = NonNullable<TableConfig<unknown>['plugins']>;\n\n/////////////////////////////////////////////\n// Sanity checks\nexpectTypeOf<Plugins>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<Plugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>, Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<BasePlugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<BasePlugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<\n [Constructor<BasePlugin>, Constructor<BasePlugin>]\n>().toMatchTypeOf<TablePluginConfig>();\n\nclass SomeClass {\n foo = 'bar';\n}\nclass LocalPlugin extends BasePlugin<{ Meta: { Table: SomeClass } }> {\n name = 'local-plugin';\n}\n\nexpectTypeOf([LocalPlugin]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// Making sure all plugins are subclassed appropriately\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<Plugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<Plugin<any>>>();\n\n// Actual plugins match the actual table config\nexpectTypeOf([DataSorting]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnResizing]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnVisibility]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([StickyColumns]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// The various ways to define plugins\nexpectTypeOf([DataSorting, ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\n\nconst onSort = (_sorts: SortItem<number>[]) => {\n /* intentionally empty */\n};\nconst sorts: SortItem<number>[] = [];\n\nexpectTypeOf([DataSorting.with(() => ({}))]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([DataSorting.with(() => ({ onSort, sorts }))]).toMatchTypeOf<TablePluginConfig>();\n"],"names":["expectTypeOf","toMatchTypeOf","LocalPlugin","BasePlugin","ColumnReordering","DataSorting","ColumnResizing","ColumnVisibility","StickyColumns","onSort","_sorts","sorts","with"],"mappings":";;;;;;;;;;;;AAiBA;AACA;AACAA,YAAY,EAAW,CAACC,aAAa,EAAqB,CAAA;AAC1DD,YAAY,EAAyB,CAACC,aAAa,EAAqB,CAAA;AACxED,YAAY,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IAAK;AAC7C;AAAA,CACD,CAAA;AACD,MAAMC,KAAyB,GAAG,EAAE,CAAA;AAEpCX,YAAY,CAAC,CAACK,OAAW,CAACO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAACX,aAAa,EAAqB,CAAA;AAC/ED,YAAY,CAAC,CAACK,OAAW,CAACO,IAAI,CAAC,OAAO;EAAEH,MAAM;AAAEE,EAAAA,KAAAA;AAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAACV,aAAa,EAAqB"}
@@ -1,5 +1,5 @@
1
1
  import { Row } from "./row";
2
- import { Table } from "../table-222f44e7";
2
+ import { Table } from "../table-0cbd2720";
3
3
  import { ContentValue } from '@glint/template';
4
4
  import { ColumnConfig } from "./interfaces/index";
5
5
  declare class Column<T = unknown> {
@@ -1,4 +1,4 @@
1
- import { Table } from "../table-222f44e7";
1
+ import { Table } from "../table-0cbd2720";
2
2
  import { TableConfig } from "./interfaces/index";
3
3
  /**
4
4
  * Represents a UI-less version of a table
@@ -1,4 +1,4 @@
1
- import { a as Table } from '../table-222f44e7.js';
1
+ import { a as Table } from '../table-0cbd2720.js';
2
2
 
3
3
  function headlessTable(...args) {
4
4
  if (args.length === 2) {
@@ -1,4 +1,4 @@
1
- import { Table } from "../table-222f44e7";
1
+ import { Table } from "../table-0cbd2720";
2
2
  declare class Row<DataType = Record<string, unknown>> {
3
3
  data: DataType;
4
4
  table: Table<DataType>;
@@ -1,12 +1,12 @@
1
- export { T as TABLE_KEY, a as Table } from '../table-222f44e7.js';
1
+ export { T as TABLE_KEY, a as Table } from '../table-0cbd2720.js';
2
2
  import '../defineProperty-35ce617b.js';
3
3
  import '../applyDecoratedDescriptor-6b986a67.js';
4
- import '@embroider/macros';
5
4
  import '@glimmer/tracking';
6
5
  import '@ember/application';
7
6
  import '@ember/debug';
8
7
  import '@ember/object';
9
8
  import '@ember/object/internals';
9
+ import '@embroider/macros';
10
10
  import 'ember-modifier';
11
11
  import 'ember-resources/core';
12
12
  import 'ember-resources/util/map';
package/dist/index.d.ts CHANGED
@@ -10,4 +10,4 @@ export { deserializeSorts, serializeSorts } from "./utils";
10
10
  export type { Column } from "./-private/column";
11
11
  export type { ColumnConfig, ColumnKey, Pagination, PreferencesAdapter, TablePreferencesData as PreferencesData, Selection, TableConfig, TableMeta } from "./-private/interfaces/index";
12
12
  export type { Row } from "./-private/row";
13
- export type { Table } from "./table-222f44e7";
13
+ export type { Table } from "./table-0cbd2720";
@@ -1,4 +1,4 @@
1
- import { Table } from "../../table-222f44e7";
1
+ import { Table } from "../../table-0cbd2720";
2
2
  import { ColumnReordering } from "../column-reordering/index";
3
3
  import { ColumnVisibility } from "../column-visibility/index";
4
4
  import { Class, Constructor } from "../../-private/private-types";
@@ -1,6 +1,6 @@
1
1
  import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
2
2
  import { assert } from '@ember/debug';
3
- import { T as TABLE_KEY } from '../../table-222f44e7.js';
3
+ import { T as TABLE_KEY } from '../../table-0cbd2720.js';
4
4
  import { normalizePluginsConfig } from './utils.js';
5
5
 
6
6
  const TABLE_META = new Map();
@@ -1,4 +1,4 @@
1
- import { _ as _initializerDefineProperty } from '../../table-222f44e7.js';
1
+ import { _ as _initializerDefineProperty } from '../../table-0cbd2720.js';
2
2
  import { _ as _applyDecoratedDescriptor } from '../../applyDecoratedDescriptor-6b986a67.js';
3
3
  import { a as _classPrivateFieldGet } from '../../classPrivateFieldGet-b4d7d334.js';
4
4
  import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
@@ -1,5 +1,5 @@
1
1
  import { a as _classPrivateFieldGet } from '../../classPrivateFieldGet-b4d7d334.js';
2
- import { _ as _initializerDefineProperty } from '../../table-222f44e7.js';
2
+ import { _ as _initializerDefineProperty } from '../../table-0cbd2720.js';
3
3
  import { _ as _applyDecoratedDescriptor } from '../../applyDecoratedDescriptor-6b986a67.js';
4
4
  import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
5
5
  import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
@@ -1,4 +1,17 @@
1
+ import { htmlSafe } from '@ember/template';
1
2
  import { Column } from "../../index";
2
3
  declare const isSticky: <DataType = unknown>(column: Column<DataType>) => boolean;
3
4
  declare const styleFor: <DataType = unknown>(column: Column<DataType>) => Partial<CSSStyleDeclaration>;
4
- export { isSticky, styleFor };
5
+ /**
6
+ * In this plugin, buth header and cells have the same styles,
7
+ * if applicable.
8
+ *
9
+ * Until this RFC https://github.com/emberjs/rfcs/pull/883
10
+ * is merged and implemented, we can't performantly
11
+ * use modifiers for apply styles.
12
+ *
13
+ * In the mean time, we'll need to append style strings, which is more work
14
+ * for consumers, but is a reasonable trade-off for now.
15
+ */
16
+ declare const styleStringFor: <DataType = unknown>(column: Column<DataType>) => ReturnType<typeof htmlSafe>;
17
+ export { isSticky, styleFor, styleStringFor };
@@ -1,8 +1,47 @@
1
+ import { htmlSafe } from '@ember/template';
1
2
  import { meta } from '../-private/base.js';
2
3
  import { StickyColumns } from './plugin.js';
3
4
 
4
5
  const isSticky = column => meta.forColumn(column, StickyColumns).isSticky;
5
6
  const styleFor = column => meta.forColumn(column, StickyColumns).style;
6
7
 
7
- export { isSticky, styleFor };
8
+ /**
9
+ * In this plugin, buth header and cells have the same styles,
10
+ * if applicable.
11
+ *
12
+ * Until this RFC https://github.com/emberjs/rfcs/pull/883
13
+ * is merged and implemented, we can't performantly
14
+ * use modifiers for apply styles.
15
+ *
16
+ * In the mean time, we'll need to append style strings, which is more work
17
+ * for consumers, but is a reasonable trade-off for now.
18
+ */
19
+ const styleStringFor = column => {
20
+ let columnMeta = meta.forColumn(column, StickyColumns);
21
+ let result = '';
22
+ if (columnMeta.isSticky) {
23
+ for (let [key, value] of Object.entries(columnMeta.style)) {
24
+ result += `${toStyle(key)}:${value};`;
25
+ }
26
+ result = ';' + result;
27
+ }
28
+ return htmlSafe(result);
29
+ };
30
+
31
+ /**
32
+ * the JS API for styles is camel case,
33
+ * but CSS is kebab-case. To save on complexity and
34
+ * amount of code, we have a super small conversion function
35
+ * for only the properties relevant to the sticky plugin.
36
+ */
37
+ const toStyle = key => {
38
+ switch (key) {
39
+ case 'zIndex':
40
+ return 'z-index';
41
+ default:
42
+ return key;
43
+ }
44
+ };
45
+
46
+ export { isSticky, styleFor, styleStringFor };
8
47
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { 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"],"names":["isSticky","column","meta","forColumn","StickyColumns","styleFor","style"],"mappings":";;;AAKaA,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;;;;"}
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, buth 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,3 +1,3 @@
1
- export { isSticky, styleFor } from './helpers.js';
1
+ export { isSticky, styleFor, styleStringFor } from './helpers.js';
2
2
  export { StickyColumns as Plugin, StickyColumns } from './plugin.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -13,6 +13,15 @@ interface ColumnOptions {
13
13
  interface Signature {
14
14
  Options: {
15
15
  Column: ColumnOptions;
16
+ Plugin: {
17
+ /**
18
+ * Opts this plugin out of engaging in the modifier system
19
+ * and instead requires setting a `style` attribute on
20
+ * th / td tags for getting the "position: sticky" behovior
21
+ * on columns.
22
+ */
23
+ workaroundForModifierTimingUpdateRFC883?: boolean;
24
+ };
16
25
  };
17
26
  Meta: {
18
27
  Table: TableMeta;
@@ -33,7 +42,14 @@ declare class StickyColumns extends BasePlugin<Signature> {
33
42
  table: typeof TableMeta;
34
43
  column: typeof ColumnMeta;
35
44
  };
36
- headerCellModifier: (element: HTMLElement, { column }: ColumnApi) => void;
45
+ conditionallyRemoveStyles: (element: HTMLElement) => void;
46
+ headerCellModifier: (element: HTMLElement, { column, table }: ColumnApi) => void;
47
+ /**
48
+ * Not yet supported. Pending Ember RFC #883
49
+ *
50
+ * TODO: switch ColumnApi to "RowApi", add the row's data
51
+ */
52
+ cellModifier: (element: HTMLElement, { column, table }: ColumnApi) => void;
37
53
  }
38
54
  /**
39
55
  * @private
@@ -3,11 +3,12 @@ import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
3
3
  import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
4
4
  import '@glimmer/tracking';
5
5
  import { assert } from '@ember/debug';
6
- import { BasePlugin, meta, options, columns } from '../-private/base.js';
6
+ import { BasePlugin, options, meta, columns } from '../-private/base.js';
7
7
  import { applyStyles } from '../-private/utils.js';
8
8
 
9
9
  var _class;
10
10
  let cached = macroCondition(dependencySatisfies('ember-source', '>= 4.1.0-alpha.0')) ? importSync('@glimmer/tracking').cached : importSync('ember-cached-decorator-polyfill').cached;
11
+ const DEFAULT_Z_INDEX = '8';
11
12
  class StickyColumns extends BasePlugin {
12
13
  constructor(...args) {
13
14
  super(...args);
@@ -16,25 +17,46 @@ class StickyColumns extends BasePlugin {
16
17
  table: TableMeta,
17
18
  column: ColumnMeta
18
19
  });
20
+ _defineProperty(this, "conditionallyRemoveStyles", element => {
21
+ if (element.style.getPropertyValue('position') === 'sticky') {
22
+ element.style.removeProperty('position');
23
+ }
24
+ if (element.style.getPropertyValue('left')) {
25
+ element.style.left = '';
26
+ }
27
+ if (element.style.getPropertyValue('right')) {
28
+ element.style.right = '';
29
+ }
30
+ if (element.style.zIndex === DEFAULT_Z_INDEX) {
31
+ element.style.zIndex = '';
32
+ }
33
+ });
19
34
  _defineProperty(this, "headerCellModifier", (element, {
20
- column
35
+ column,
36
+ table
21
37
  }) => {
38
+ if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {
39
+ return;
40
+ }
22
41
  let columnMeta = meta.forColumn(column, StickyColumns);
23
42
  if (columnMeta.isSticky) {
24
43
  applyStyles(element, columnMeta.style);
25
44
  } else {
26
- if (element.style.getPropertyValue('position') === 'sticky') {
27
- element.style.removeProperty('position');
28
- }
29
- if (element.style.getPropertyValue('left')) {
30
- element.style.left = '';
31
- }
32
- if (element.style.getPropertyValue('right')) {
33
- element.style.right = '';
34
- }
35
- if (element.style.zIndex === '8') {
36
- element.style.zIndex = '';
37
- }
45
+ this.conditionallyRemoveStyles(element);
46
+ }
47
+ });
48
+ _defineProperty(this, "cellModifier", (element, {
49
+ column,
50
+ table
51
+ }) => {
52
+ if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {
53
+ return;
54
+ }
55
+ let columnMeta = meta.forColumn(column, StickyColumns);
56
+ if (columnMeta.isSticky) {
57
+ applyStyles(element, columnMeta.style);
58
+ } else {
59
+ this.conditionallyRemoveStyles(element);
38
60
  }
39
61
  });
40
62
  }
@@ -91,7 +113,7 @@ let ColumnMeta = (_class = class ColumnMeta {
91
113
  return {
92
114
  position: 'sticky',
93
115
  [this.position]: this.offset,
94
- zIndex: '8'
116
+ zIndex: DEFAULT_Z_INDEX
95
117
  };
96
118
  }
97
119
  return {};
@@ -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\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 };\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 headerCellModifier = (element: HTMLElement, { column }: ColumnApi) => {\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n if (columnMeta.isSticky) {\n applyStyles(element, columnMeta.style);\n } else {\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 === '8') {\n element.style.zIndex = '';\n }\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: '8',\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":["StickyColumns","BasePlugin","table","TableMeta","column","ColumnMeta","element","columnMeta","meta","forColumn","isSticky","applyStyles","style","getPropertyValue","removeProperty","left","right","zIndex","constructor","position","sticky","options","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;AA6BpC,MAAMA,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;IAAA,eAEoB,CAAA,IAAA,EAAA,oBAAA,EAAA,CAACC,OAAoB,EAAE;AAAEF,MAAAA,MAAAA;AAAkB,KAAC,KAAK;MACpE,IAAIG,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACL,MAAM,EAAEJ,aAAa,CAAC,CAAA;MAEtD,IAAIO,UAAU,CAACG,QAAQ,EAAE;AACvBC,QAAAA,WAAW,CAACL,OAAO,EAAEC,UAAU,CAACK,KAAK,CAAC,CAAA;AACxC,OAAC,MAAM;QACL,IAAIN,OAAO,CAACM,KAAK,CAACC,gBAAgB,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE;AAC3DP,UAAAA,OAAO,CAACM,KAAK,CAACE,cAAc,CAAC,UAAU,CAAC,CAAA;AAC1C,SAAA;QAEA,IAAIR,OAAO,CAACM,KAAK,CAACC,gBAAgB,CAAC,MAAM,CAAC,EAAE;AAC1CP,UAAAA,OAAO,CAACM,KAAK,CAACG,IAAI,GAAG,EAAE,CAAA;AACzB,SAAA;QA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AAA,QAAQ,EAAE,QAAQ;AAClB,QAAA,CAAC,IAAI,CAACA,QAAQ,GAAG,IAAI,CAACK,MAAM;AAC5BP,QAAAA,MAAM,EAAE,GAAA;OACT,CAAA;AACH,KAAA;AAEA,IAAA,OAAO,EAAE,CAAA;AACX,GAAA;AACF,CAAC,0DAlDEkB,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,MAAMjC,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":["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,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ACxB,UAAA,OAAOgB,GAAG,IAAIhB,UAAU,CAACmB,KAAK,IAAI,CAAC,CAAC,CAAA;AACtC,SAAA;AAEA,QAAA,OAAOH,GAAG,CAAA;OACX,EAAE,CAAC,CAAC,CAAA;MAEL,OAAQ,CAAA,EAAErB,KAAM,CAAG,EAAA,CAAA,CAAA;AACrB,KAAA;AAEA,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;;;;"}
@@ -25,25 +25,27 @@ declare class Table<DataType = unknown> extends Resource<Signature<DataType>> {
25
25
  [TABLE_KEY]: string;
26
26
  /**
27
27
  * @private
28
+ *
29
+ * Unused for now, may be used in the future.
30
+ * This data is collected along with the scrollContainerWidth, (which is currently in use)
28
31
  */
29
32
  scrollContainerHeight?: number;
30
33
  /**
31
34
  * @private
35
+ *
36
+ * Used to help determine how much space we can give to columns.
37
+ * As we generate widths for columns, the columns' widths must
38
+ * add up to about this number.
32
39
  */
33
40
  scrollContainerWidth?: number;
34
41
  /**
35
42
  * @private
43
+ *
44
+ * Lazy way to delay consuming arguments until they are needed.
36
45
  */
37
46
  args: {
38
47
  named: Signature<DataType>['Named'];
39
48
  };
40
- /**
41
- * @private
42
- */
43
- defaultColumnConfig: {
44
- isVisible: boolean;
45
- minWidth: number;
46
- };
47
49
  /**
48
50
  * @private
49
51
  */
@@ -1,11 +1,11 @@
1
1
  import { _ as _defineProperty } from './defineProperty-35ce617b.js';
2
2
  import { _ as _applyDecoratedDescriptor } from './applyDecoratedDescriptor-6b986a67.js';
3
- import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
4
3
  import { tracked } from '@glimmer/tracking';
5
4
  import { getOwner, setOwner } from '@ember/application';
6
5
  import { assert } from '@ember/debug';
7
6
  import { action } from '@ember/object';
8
7
  import { guidFor } from '@ember/object/internals';
8
+ import { macroCondition, dependencySatisfies, importSync, isDevelopingApp } from '@embroider/macros';
9
9
  import { modifier } from 'ember-modifier';
10
10
  import { Resource } from 'ember-resources/core';
11
11
  import { map } from 'ember-resources/util/map';
@@ -52,7 +52,6 @@ let Table = (_class = class Table extends Resource {
52
52
  _initializerDefineProperty(this, "scrollContainerHeight", _descriptor, this);
53
53
  _initializerDefineProperty(this, "scrollContainerWidth", _descriptor2, this);
54
54
  _initializerDefineProperty(this, "args", _descriptor3, this);
55
- _defineProperty(this, "defaultColumnConfig", DEFAULT_COLUMN_CONFIG);
56
55
  _defineProperty(this, "scrollContainerElement", void 0);
57
56
  _defineProperty(this, "modifiers", {
58
57
  container: modifier(element => {
@@ -104,11 +103,26 @@ let Table = (_class = class Table extends Resource {
104
103
  data: () => {
105
104
  let configFn = this.args.named?.columns;
106
105
  if (!configFn) return [];
107
- return configFn() ?? [];
106
+ let result = configFn() ?? [];
107
+ if (macroCondition(isDevelopingApp())) {
108
+ /**
109
+ * Assertions for a column config to be valid:
110
+ * - every key must be unique
111
+ */
112
+ let keys = new Set();
113
+ let allKeys = result.map(columnConfig => columnConfig.key);
114
+ result.forEach(columnConfig => {
115
+ if (keys.has(columnConfig.key)) {
116
+ throw new Error(`Every column key in the table's column config must be unique. ` + `Found duplicate entry: ${columnConfig.key}. ` + `All keys used: ${allKeys}`);
117
+ }
118
+ keys.add(columnConfig.key);
119
+ });
120
+ }
121
+ return result;
108
122
  },
109
123
  map: config => {
110
124
  return new Column(this, {
111
- ...this.defaultColumnConfig,
125
+ ...DEFAULT_COLUMN_CONFIG,
112
126
  ...config
113
127
  });
114
128
  }
@@ -230,4 +244,4 @@ let Table = (_class = class Table extends Resource {
230
244
  }), _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);
231
245
 
232
246
  export { TABLE_KEY as T, _initializerDefineProperty as _, Table as a };
233
- //# sourceMappingURL=table-222f44e7.js.map
247
+ //# sourceMappingURL=table-0cbd2720.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-0cbd2720.js","sources":["../../node_modules/.pnpm/@babel+runtime@7.20.1/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__');\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 /**\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","DEFAULT_COLUMN_CONFIG","isVisible","minWidth","TABLE_KEY","Symbol","attachContainer","element","table","assert","HTMLElement","scrollContainerElement","Table","Resource","guidFor","container","modifier","modifiers","plugins","map","plugin","containerModifier","composed","composeFunctionModifiers","eager","columnHeader","column","headerCellModifier","row","rowModifier","data","dataFn","args","named","datum","Row","configFn","columns","result","macroCondition","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","tracked","cached","action"],"mappings":";;;;;;;;;;;;;;;;;AAAe,SAASA,0BAA0B,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,GAAG,KAAK,CAAA;AAC9E,GAAC,CAAC,CAAA;AACJ;;;ACRoD,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;AAqBpD,MAAMS,qBAAqB,GAAG;AAC5BC,EAAAA,SAAS,EAAE,IAAI;AACfC,EAAAA,QAAQ,EAAE,GAAA;AACZ,CAAC,CAAA;AAMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaC,SAAS,GAAGC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A;AAAA,EAAA,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,EAAA,YAAA,GAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,MAAA,EAAA,CAOPA,OAAO,CAAA,EAAA;AAAA,EAAA,YAAA,EAAA,IAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,QAAA,EAAA,IAAA;AAAA,EAAA,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,SAAA,EAAA,CA0FPC,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,sBAAA,EAAA,CAwGNC,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,sBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,CAONA,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,iBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,GAAA,MAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-headless-table",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "An implementation of table behaviors for driving any table or table-like UI -- all without a UI (headless)",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -81,6 +81,7 @@
81
81
  "@babel/runtime": "^7.17.8",
82
82
  "@ember/string": "^3.0.0",
83
83
  "@embroider/addon-shim": "^1.0.0",
84
+ "@embroider/macros": "1.10.0",
84
85
  "ember-modifier": "^3.2.7",
85
86
  "ember-resources": "^5.4.0",
86
87
  "ember-tracked-storage-polyfill": "^1.0.0",
@@ -97,7 +98,7 @@
97
98
  "@babel/preset-typescript": "^7.18.6",
98
99
  "@ember/test-helpers": "^2.6.0",
99
100
  "@ember/test-waiters": "^3.0.0",
100
- "@embroider/addon-dev": "^2.0.0",
101
+ "@embroider/addon-dev": "^3.0.0",
101
102
  "@glimmer/component": "^1.1.2",
102
103
  "@glimmer/tracking": "^1.1.2",
103
104
  "@glint/template": "^0.9.4",
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-222f44e7.js","sources":["../../node_modules/.pnpm/@babel+runtime@7.20.1/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 { 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__');\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 /**\n * @private\n */\n @tracked scrollContainerHeight?: number;\n\n /**\n * @private\n */\n @tracked scrollContainerWidth?: number;\n\n /**\n * @private\n */\n @tracked declare args: { named: Signature<DataType>['Named'] };\n\n /**\n * @private\n */\n defaultColumnConfig = DEFAULT_COLUMN_CONFIG;\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 return configFn() ?? [];\n },\n map: (config) => {\n return new Column<DataType>(this, { ...this.defaultColumnConfig, ...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","DEFAULT_COLUMN_CONFIG","isVisible","minWidth","TABLE_KEY","Symbol","attachContainer","element","table","assert","HTMLElement","scrollContainerElement","Table","Resource","guidFor","container","modifier","modifiers","plugins","map","plugin","containerModifier","composed","composeFunctionModifiers","eager","columnHeader","column","headerCellModifier","row","rowModifier","data","dataFn","args","named","datum","Row","configFn","columns","config","Column","defaultColumnConfig","modify","_","preferences","key","adapter","TablePreferences","resetScrollContainer","normalizePluginsConfig","verifyPlugins","tuple","PluginClass","owner","getOwner","setOwner","pluginOf","klass","result","find","scrollTop","resetToDefaults","forEach","reset","tracked","cached","action"],"mappings":";;;;;;;;;;;;;;;;;AAAe,SAASA,0BAA0B,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,GAAG,KAAK,CAAA;AAC9E,GAAC,CAAC,CAAA;AACJ;;;ACRoD,IAAA,MA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