ember-headless-table 1.2.0 → 1.4.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.
- package/dist/-private/-type-tests/table-config.test.js +1 -0
- package/dist/-private/-type-tests/table-config.test.js.map +1 -1
- package/dist/-private/column.d.ts +1 -1
- package/dist/-private/js-helper.d.ts +1 -1
- package/dist/-private/js-helper.js +1 -1
- package/dist/-private/row.d.ts +1 -1
- package/dist/-private/table.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/plugins/-private/base.d.ts +10 -2
- package/dist/plugins/-private/base.js +13 -2
- package/dist/plugins/-private/base.js.map +1 -1
- package/dist/plugins/column-reordering/plugin.js +1 -1
- package/dist/plugins/column-resizing/plugin.js +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/sticky-columns/helpers.d.ts +14 -1
- package/dist/plugins/sticky-columns/helpers.js +40 -1
- package/dist/plugins/sticky-columns/helpers.js.map +1 -1
- package/dist/plugins/sticky-columns/index.js +1 -1
- package/dist/plugins/sticky-columns/plugin.d.ts +17 -1
- package/dist/plugins/sticky-columns/plugin.js +37 -15
- package/dist/plugins/sticky-columns/plugin.js.map +1 -1
- package/dist/{table-222f44e7.d.ts → table-0cbd2720.d.ts} +9 -7
- package/dist/{table-222f44e7.js → table-0cbd2720.js} +19 -5
- package/dist/table-0cbd2720.js.map +1 -0
- package/dist/utils.js +4 -1
- package/dist/utils.js.map +1 -1
- package/package.json +5 -4
- package/dist/table-222f44e7.js.map +0 -1
@@ -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":"
|
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,EAAyB,CAACC,aAAa,EAAqB,CAAA;AACxED,YAAY,EAA8C,CAACC,aAAa,EAAqB,CAAA;AAC7FD,YAAY,EAA6B,CAACC,aAAa,EAAqB,CAAA;AAC5ED,YAAY,EAA6B,CAACC,aAAa,EAAqB,CAAA;AAC5ED,YAAY,EAET,CAACC,aAAa,EAAqB,CAAA;AAKtC,MAAMC,WAAW,SAASC,UAAU,CAAiC;AAAA,EAAA,WAAA,CAAA,GAAA,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAC5D,cAAc,CAAA,CAAA;AAAA,GAAA;AACvB,CAAA;AAEAH,YAAY,CAAC,CAACE,WAAW,CAAC,CAAC,CAACD,aAAa,EAAqB,CAAA;;AAE9D;AACA;AACAD,YAAY,CAACE,WAAW,CAAC,CAACD,aAAa,EAAgC,CAAA;AACvED,YAAY,CAACI,gBAAgB,CAAC,CAACH,aAAa,EAAgC,CAAA;AAC5ED,YAAY,CAACE,WAAW,CAAC,CAACD,aAAa,EAA4B,CAAA;AACnED,YAAY,CAACI,gBAAgB,CAAC,CAACH,aAAa,EAA4B,CAAA;;AAExE;AACAD,YAAY,CAAC,CAACK,OAAW,CAAC,CAAC,CAACJ,aAAa,EAAqB,CAAA;AAC9DD,YAAY,CAAC,CAACI,gBAAgB,CAAC,CAAC,CAACH,aAAa,EAAqB,CAAA;AACnED,YAAY,CAAC,CAACM,cAAc,CAAC,CAAC,CAACL,aAAa,EAAqB,CAAA;AACjED,YAAY,CAAC,CAACO,gBAAgB,CAAC,CAAC,CAACN,aAAa,EAAqB,CAAA;AACnED,YAAY,CAAC,CAACQ,aAAa,CAAC,CAAC,CAACP,aAAa,EAAqB,CAAA;;AAEhE;AACA;AACAD,YAAY,CAAC,CAACK,OAAW,EAAED,gBAAgB,CAAC,CAAC,CAACH,aAAa,EAAqB,CAAA;AAEhF,MAAMQ,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"}
|
package/dist/-private/row.d.ts
CHANGED
package/dist/-private/table.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
export { T as TABLE_KEY, a as Table } from '../table-
|
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-
|
13
|
+
export type { Table } from "./table-0cbd2720";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Table } from "../../table-
|
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";
|
@@ -98,6 +98,14 @@ declare abstract class BasePlugin<Signature = unknown> implements Plugin<Signatu
|
|
98
98
|
static features?: string[];
|
99
99
|
static requires?: string[];
|
100
100
|
}
|
101
|
+
/**
|
102
|
+
* @public
|
103
|
+
*
|
104
|
+
* returns boolean if the passed table has an instance of the configured passed plugin class.
|
105
|
+
* This can be used to help guard against accessing public-specific APIs if those plugins
|
106
|
+
* are not configured for a particular table instance
|
107
|
+
*/
|
108
|
+
declare function hasPlugin<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>): boolean;
|
101
109
|
declare const preferences: {
|
102
110
|
/**
|
103
111
|
* @public
|
@@ -264,4 +272,4 @@ declare const options: {
|
|
264
272
|
forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>): Partial<OptionsFor<SignatureFrom<P>>>;
|
265
273
|
forColumn<P_1 extends BasePlugin<any>, Data_1 = unknown>(column: Column<Data_1>, klass: Class<P_1>): Partial<ColumnOptionsFor<SignatureFrom<P_1>>>;
|
266
274
|
};
|
267
|
-
export { TableFeatures, ColumnFeatures, SignatureFrom, BasePlugin, preferences, columns, meta, options };
|
275
|
+
export { TableFeatures, ColumnFeatures, SignatureFrom, BasePlugin, hasPlugin, preferences, columns, meta, options };
|
@@ -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-
|
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();
|
@@ -46,8 +46,19 @@ class BasePlugin {
|
|
46
46
|
return [this, configFn];
|
47
47
|
}
|
48
48
|
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @public
|
52
|
+
*
|
53
|
+
* returns boolean if the passed table has an instance of the configured passed plugin class.
|
54
|
+
* This can be used to help guard against accessing public-specific APIs if those plugins
|
55
|
+
* are not configured for a particular table instance
|
56
|
+
*/
|
49
57
|
_defineProperty(BasePlugin, "features", void 0);
|
50
58
|
_defineProperty(BasePlugin, "requires", void 0);
|
59
|
+
function hasPlugin(table, klass) {
|
60
|
+
return Boolean(table.pluginOf(klass));
|
61
|
+
}
|
51
62
|
const preferences = {
|
52
63
|
/**
|
53
64
|
* @public
|
@@ -441,5 +452,5 @@ function getPluginInstance(map, rootKey, mapKey, factory) {
|
|
441
452
|
return instance;
|
442
453
|
}
|
443
454
|
|
444
|
-
export { BasePlugin, columns, meta, options, preferences };
|
455
|
+
export { BasePlugin, columns, hasPlugin, meta, options, preferences };
|
445
456
|
//# sourceMappingURL=base.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base.js","sources":["../../../src/plugins/-private/base.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { TABLE_KEY } from '../../-private/table';\nimport { normalizePluginsConfig } from './utils';\n\nimport type { Table } from '../../-private/table';\nimport type { ColumnReordering } from '../column-reordering';\nimport type { ColumnVisibility } from '../column-visibility';\nimport type { Class, Constructor } from '[private-types]';\nimport type { Column, Row } from '[public-types]';\nimport type {\n ColumnMetaFor,\n ColumnOptionsFor,\n OptionsFor,\n Plugin,\n RowMetaFor,\n TableMetaFor,\n} from '#interfaces';\n\nconst TABLE_META = new Map<string, Map<Class<unknown>, any>>();\nconst COLUMN_META = new WeakMap<Column, Map<Class<unknown>, any>>();\nconst ROW_META = new WeakMap<Row, Map<Class<unknown>, any>>();\n\ntype InstanceOf<T> = T extends Class<infer Instance> ? Instance : T;\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface TableFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the table meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['table']>;\n /**\n * @public\n *\n * interface for the table meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['table']>;\n}\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface ColumnFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the column meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['column']>;\n /**\n * @public\n *\n * interface for the column meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['column']>;\n}\n\n/**\n * @private utility type\n *\n */\nexport type SignatureFrom<Klass extends BasePlugin<any>> = Klass extends BasePlugin<infer Signature>\n ? Signature\n : never;\n\ndeclare const __Signature__: unique symbol;\n\n/**\n * @public\n *\n * If your table plugin is a class, you may extend from BasePlugin, which provides\n * small utility methods and properties for getting the metadata for your plugin\n * for the table and each column\n *\n * One instance of a plugin exists per table\n */\nexport abstract class BasePlugin<Signature = unknown> implements Plugin<Signature> {\n constructor(protected table: Table) {}\n\n /**\n * @private (secret)\n *\n * Because classes are kind of like interfaces,\n * we need \"something\" to help TS know what a Resource is.\n *\n * This isn't a real API, but does help with type inference\n * with the SignatureFrom utility above\n */\n declare [__Signature__]: Signature;\n\n /**\n * Helper for specifying plugins on `headlessTable` with the plugin-level options\n */\n static with<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => OptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => OptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n /**\n * Helper for specifying column-level configurations for a plugin on `headlessTable`'s\n * columns option\n */\n static forColumn<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => ColumnOptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => ColumnOptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n declare meta?: {\n column?: Constructor<ColumnMetaFor<Signature>>;\n table?: Constructor<TableMetaFor<Signature>>;\n row?: Constructor<RowMetaFor<Signature>>;\n };\n\n abstract name: string;\n static features?: string[];\n static requires?: string[];\n}\n\nexport const preferences = {\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the column (scoped to key)\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(column: Column<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n return columnPrefs.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.set(key, value);\n\n prefs.persist();\n },\n };\n },\n\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the table (scoped to the key: \"table\")\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n return existing.table.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.set(key, value);\n\n return prefs.persist();\n },\n };\n },\n};\n\n/**\n * if a `requester` is not provided,\n * Get the columns for the table, considering any and all plugins that could modify columns.\n *\n * If you are an end-consumer of ember-headless-table, this is the function to use.\n * If you are a plugin-author, you'll want to pass your plugin class as the second parameter.\n *\n * For a given plugin, `requester`, determine what columns should be returned.\n * Since multiple plugins could be used in a table, there is an implicit hierarchy of\n * column modifications that can occur from each of those plugins.\n *\n * If a plugin defines other plugins as either *requirements* or *optional requirements*,\n * and that upstream plugin defines a `columns` property, then those columns will be returned here.\n *\n * This works recursively up the plugin tree up until a plugin has no requirements, and then\n * all columns from the table are returned.\n */\nfunction columnsFor<DataType = any>(\n table: Table<DataType>,\n requester?: Plugin<any> | undefined\n): Column<DataType>[] {\n assert(`First argument passed to columns.for must be an instance of Table`, table[TABLE_KEY]);\n\n let visibility = findPlugin(table.plugins, 'columnVisibility');\n let reordering = findPlugin(table.plugins, 'columnOrder');\n\n // TODO: actually resolve the graph, rather than use the hardcoded feature names\n // atm, this only \"happens\" to work based on expectations of\n // of the currently implemented plugins' capabilities and implied hierarchy.\n\n if (requester) {\n assert(\n `[${requester.name}] requested columns from the table, but the plugin, ${requester.name}, ` +\n `is not used in this table`,\n table.plugins.some((plugin) => plugin instanceof (requester as Class<Plugin>))\n );\n\n if (visibility && visibility.constructor === requester) {\n return table.columns.values();\n }\n\n if (reordering && reordering.constructor === requester) {\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n /**\n * This flow is the inverse of when we have a requester\n */\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n}\n\nexport const columns = {\n for: columnsFor,\n\n /**\n * for a given current or reference column, return the column that\n * is immediately next, or to the right of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n next: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing after the last column\n */\n if (referenceIndex >= columns.length - 1) {\n return undefined;\n }\n\n return columns[referenceIndex + 1];\n },\n\n /**\n * for a given current or reference column, return the column that\n * is immediately previous, or to the left of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n previous: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing before the first column\n */\n if (referenceIndex === 0) {\n return undefined;\n }\n\n return columns[referenceIndex - 1];\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear before, or to the left of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n before: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(0, referenceIndex);\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear after, or to the right of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n after: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(referenceIndex + 1);\n },\n};\n\nexport const meta = {\n /**\n * @public\n *\n * For a given column and plugin, return the meta / state bucket for the\n * plugin<->column instance pair.\n *\n * Note that this requires the column instance to exist on the table.\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): ColumnMetaFor<SignatureFrom<P>> {\n return getPluginInstance(COLUMN_META, column, klass, () => {\n let plugin = column.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify column meta`, plugin.meta.column);\n\n return new plugin.meta.column(column);\n });\n },\n\n /**\n * @public\n *\n * For a given row and plugin, return the meta / state bucket for the\n * plugin<->row instance pair.\n *\n * Note that this requires the row instance to exist on the table.\n */\n forRow<P extends BasePlugin<any>, Data = unknown>(\n row: Row<Data>,\n klass: Class<P>\n ): RowMetaFor<SignatureFrom<P>> {\n return getPluginInstance(ROW_META, row, klass, () => {\n let plugin = row.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify row meta`, plugin.meta.row);\n\n return new plugin.meta.row(row);\n });\n },\n\n /**\n * @public\n *\n * For a given table and plugin, return the meta / state bucket for the\n * plugin<->table instance pair.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): TableMetaFor<SignatureFrom<P>> {\n return getPluginInstance(TABLE_META, table[TABLE_KEY], klass, () => {\n let plugin = table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify table meta`, plugin.meta.table);\n assert(\n `<#${plugin.name}> plugin already exists for the table. ` +\n `A plugin may only be instantiated once per table.`,\n ![...(TABLE_META.get(table[TABLE_KEY])?.keys() ?? [])].includes(klass)\n );\n\n return new plugin.meta.table(table);\n });\n },\n\n /**\n * Instead of finding meta based on column or table instances,\n * you can search for meta based on feature strings, such as `columnWidth`\n */\n withFeature: {\n /**\n * @public\n *\n * for a given column and feature name, return the \"ColumnMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care which\n * plugin is providing what behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility\n */\n forColumn<FeatureName extends string, Data = unknown>(\n column: Column<Data>,\n featureName: FeatureName\n ): ColumnFeatures[FeatureName] {\n let { plugins } = column.table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forColumn(column, (provider as any).constructor);\n },\n\n /**\n * @public\n *\n * for a given table and feature name, return the \"TableMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care\n * which plugin is providing that behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility.\n */\n forTable<FeatureName extends string, Data = unknown>(\n table: Table<Data>,\n featureName: FeatureName\n ): TableFeatures[FeatureName] {\n let { plugins } = table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forTable(table, (provider as any).constructor);\n },\n },\n};\n\nfunction findPlugin(plugins: Plugin[], featureName: string) {\n let provider = plugins.find((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features?.includes(featureName);\n });\n\n return provider;\n}\n\nfunction availableFeatures(plugins: Plugin[]): string {\n let allFeatures = plugins\n .map((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features;\n })\n .flat()\n .filter(Boolean);\n\n return allFeatures.length > 0 ? allFeatures.join(', ') : '[none]';\n}\n\nexport const options = {\n /**\n * @public\n *\n * For a given table and plugin, return the options, if any were given from the user\n * during construction of the table.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): Partial<OptionsFor<SignatureFrom<P>>> {\n let normalized = normalizePluginsConfig(table?.config?.plugins);\n let tuple = normalized?.find((option) => option[0] === klass);\n let t = tuple as [Class<P>, () => OptionsFor<SignatureFrom<P>>];\n\n // Plugin not provided, likely\n if (!t) return {};\n\n let fn = t[1];\n\n return fn() ?? {};\n },\n\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): Partial<ColumnOptionsFor<SignatureFrom<P>>> {\n let tuple = column.config.pluginOptions?.find((option) => option[0] === klass);\n let t = tuple as [unknown, () => ColumnOptionsFor<SignatureFrom<P>>];\n\n let fn = t?.[1];\n\n if (!fn) return {};\n\n return fn() ?? {};\n },\n};\n\n/**\n * @private\n */\nfunction getPluginInstance<RootKey extends string | Column<any> | Row<any>, Instance>(\n map: RootKey extends string\n ? Map<string, Map<Class<Instance>, Instance>>\n : WeakMap<Column | Row, Map<Class<Instance>, Instance>>,\n rootKey: RootKey,\n mapKey: Class<Instance>,\n factory: () => Instance\n): Instance {\n let bucket: Map<Class<Instance>, Instance> | undefined;\n\n if (map instanceof WeakMap) {\n assert(`Cannot use string key with WeakMap`, typeof rootKey !== 'string');\n\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n } else {\n assert(`Cannot use object key with Map`, typeof rootKey === 'string');\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n }\n\n let instance = bucket.get(mapKey);\n\n if (instance) {\n return instance;\n }\n\n instance = factory();\n\n bucket.set(mapKey, instance);\n\n return instance;\n}\n"],"names":["TABLE_META","Map","COLUMN_META","WeakMap","ROW_META","BasePlugin","constructor","table","with","configFn","forColumn","preferences","column","klass","delete","key","prefs","existing","storage","forPlugin","name","columnPrefs","persist","get","set","value","forTable","columnsFor","requester","assert","TABLE_KEY","visibility","findPlugin","plugins","reordering","some","plugin","columns","values","Array","isArray","for","next","current","referenceIndex","indexOf","length","undefined","previous","before","slice","after","meta","getPluginInstance","pluginOf","forRow","row","keys","includes","withFeature","featureName","provider","availableFeatures","find","features","allFeatures","map","flat","filter","Boolean","join","options","normalized","normalizePluginsConfig","config","tuple","option","t","fn","pluginOptions","rootKey","mapKey","factory","bucket","instance"],"mappings":";;;;;AAmBA,MAAMA,UAAU,GAAG,IAAIC,GAAG,EAAoC,CAAA;AAC9D,MAAMC,WAAW,GAAG,IAAIC,OAAO,EAAoC,CAAA;AACnE,MAAMC,QAAQ,GAAG,IAAID,OAAO,EAAiC,CAAA;AAwD7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAeE,UAAU,CAAmD;EACjFC,WAAW,CAAWC,KAAY,EAAE;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAAA,IAAdA,CAAAA,KAAY,GAAZA,KAAY,CAAA;AAAG,GAAA;;AAErC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;EACE,OAAOC,IAAI,CAETC,QAA4C,EACU;AACtD,IAAA,OAAO,CAAC,IAAI,EAAEA,QAAQ,CAAC,CAAA;AACzB,GAAA;;AAEA;AACF;AACA;AACA;EACE,OAAOC,SAAS,CAEdD,QAAkD,EACU;AAC5D,IAAA,OAAO,CAAC,IAAI,EAAEA,QAAQ,CAAC,CAAA;AACzB,GAAA;AAWF,CAAA;AAAC,eAAA,CA5CqBJ,UAAU,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAAA,eAAA,CAAVA,UAAU,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AA8CzB,MAAMM,WAAW,GAAG;AACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACED,EAAAA,SAAS,CAA4CE,MAAoB,EAAEC,KAAe,EAAE;IAC1F,OAAO;AACL;AACN;AACA;MACMC,MAAM,CAACC,GAAW,EAAE;AAClB,QAAA,IAAIC,KAAK,GAAGJ,MAAM,CAACL,KAAK,CAACI,WAAW,CAAA;QACpC,IAAIM,QAAQ,GAAGD,KAAK,CAACE,OAAO,CAACC,SAAS,CAACN,K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,CAAA;AAEzEG,IAAAA,MAAM,GAAGjB,GAAG,CAAC3C,GAAG,CAACyD,OAAO,CAAC,CAAA;IAEzB,IAAI,CAACG,MAAM,EAAE;MACXA,MAAM,GAAG,IAAIlF,GAAG,EAAE,CAAA;AAElBiE,MAAAA,GAAG,CAAC1C,GAAG,CAACwD,OAAO,EAAEG,MAAM,CAAC,CAAA;AAC1B,KAAA;AACF,GAAC,MAAM;AACLtD,IAAAA,MAAM,CAAE,CAA+B,8BAAA,CAAA,EAAE,OAAOmD,OAAO,KAAK,QAAQ,CAAC,CAAA;AACrEG,IAAAA,MAAM,GAAGjB,GAAG,CAAC3C,GAAG,CAACyD,OAAO,CAAC,CAAA;IAEzB,IAAI,CAACG,MAAM,EAAE;MACXA,MAAM,GAAG,IAAIlF,GAAG,EAAE,CAAA;AAElBiE,MAAAA,GAAG,CAAC1C,GAAG,CAACwD,OAAO,EAAEG,MAAM,CAAC,CAAA;AAC1B,KAAA;AACF,GAAA;AAEA,EAAA,IAAIC,QAAQ,GAAGD,MAAM,CAAC5D,GAAG,CAAC0D,MAAM,CAAC,CAAA;AAEjC,EAAA,IAAIG,QAAQ,EAAE;AACZ,IAAA,OAAOA,QAAQ,CAAA;AACjB,GAAA;EAEAA,QAAQ,GAAGF,OAAO,EAAE,CAAA;AAEpBC,EAAAA,MAAM,CAAC3D,GAAG,CAACyD,MAAM,EAAEG,QAAQ,CAAC,CAAA;AAE5B,EAAA,OAAOA,QAAQ,CAAA;AACjB;;;;"}
|
1
|
+
{"version":3,"file":"base.js","sources":["../../../src/plugins/-private/base.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { TABLE_KEY } from '../../-private/table';\nimport { normalizePluginsConfig } from './utils';\n\nimport type { Table } from '../../-private/table';\nimport type { ColumnReordering } from '../column-reordering';\nimport type { ColumnVisibility } from '../column-visibility';\nimport type { Class, Constructor } from '[private-types]';\nimport type { Column, Row } from '[public-types]';\nimport type {\n ColumnMetaFor,\n ColumnOptionsFor,\n OptionsFor,\n Plugin,\n RowMetaFor,\n TableMetaFor,\n} from '#interfaces';\n\nconst TABLE_META = new Map<string, Map<Class<unknown>, any>>();\nconst COLUMN_META = new WeakMap<Column, Map<Class<unknown>, any>>();\nconst ROW_META = new WeakMap<Row, Map<Class<unknown>, any>>();\n\ntype InstanceOf<T> = T extends Class<infer Instance> ? Instance : T;\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface TableFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the table meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['table']>;\n /**\n * @public\n *\n * interface for the table meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['table']>;\n}\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface ColumnFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the column meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['column']>;\n /**\n * @public\n *\n * interface for the column meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['column']>;\n}\n\n/**\n * @private utility type\n *\n */\nexport type SignatureFrom<Klass extends BasePlugin<any>> = Klass extends BasePlugin<infer Signature>\n ? Signature\n : never;\n\ndeclare const __Signature__: unique symbol;\n\n/**\n * @public\n *\n * If your table plugin is a class, you may extend from BasePlugin, which provides\n * small utility methods and properties for getting the metadata for your plugin\n * for the table and each column\n *\n * One instance of a plugin exists per table\n */\nexport abstract class BasePlugin<Signature = unknown> implements Plugin<Signature> {\n constructor(protected table: Table) {}\n\n /**\n * @private (secret)\n *\n * Because classes are kind of like interfaces,\n * we need \"something\" to help TS know what a Resource is.\n *\n * This isn't a real API, but does help with type inference\n * with the SignatureFrom utility above\n */\n declare [__Signature__]: Signature;\n\n /**\n * Helper for specifying plugins on `headlessTable` with the plugin-level options\n */\n static with<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => OptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => OptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n /**\n * Helper for specifying column-level configurations for a plugin on `headlessTable`'s\n * columns option\n */\n static forColumn<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => ColumnOptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => ColumnOptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n declare meta?: {\n column?: Constructor<ColumnMetaFor<Signature>>;\n table?: Constructor<TableMetaFor<Signature>>;\n row?: Constructor<RowMetaFor<Signature>>;\n };\n\n abstract name: string;\n static features?: string[];\n static requires?: string[];\n}\n\n/**\n * @public\n *\n * returns boolean if the passed table has an instance of the configured passed plugin class.\n * This can be used to help guard against accessing public-specific APIs if those plugins\n * are not configured for a particular table instance\n */\nexport function hasPlugin<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n) {\n return Boolean(table.pluginOf(klass));\n}\n\nexport const preferences = {\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the column (scoped to key)\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(column: Column<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n return columnPrefs.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.set(key, value);\n\n prefs.persist();\n },\n };\n },\n\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the table (scoped to the key: \"table\")\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n return existing.table.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.set(key, value);\n\n return prefs.persist();\n },\n };\n },\n};\n\n/**\n * if a `requester` is not provided,\n * Get the columns for the table, considering any and all plugins that could modify columns.\n *\n * If you are an end-consumer of ember-headless-table, this is the function to use.\n * If you are a plugin-author, you'll want to pass your plugin class as the second parameter.\n *\n * For a given plugin, `requester`, determine what columns should be returned.\n * Since multiple plugins could be used in a table, there is an implicit hierarchy of\n * column modifications that can occur from each of those plugins.\n *\n * If a plugin defines other plugins as either *requirements* or *optional requirements*,\n * and that upstream plugin defines a `columns` property, then those columns will be returned here.\n *\n * This works recursively up the plugin tree up until a plugin has no requirements, and then\n * all columns from the table are returned.\n */\nfunction columnsFor<DataType = any>(\n table: Table<DataType>,\n requester?: Plugin<any> | undefined\n): Column<DataType>[] {\n assert(`First argument passed to columns.for must be an instance of Table`, table[TABLE_KEY]);\n\n let visibility = findPlugin(table.plugins, 'columnVisibility');\n let reordering = findPlugin(table.plugins, 'columnOrder');\n\n // TODO: actually resolve the graph, rather than use the hardcoded feature names\n // atm, this only \"happens\" to work based on expectations of\n // of the currently implemented plugins' capabilities and implied hierarchy.\n\n if (requester) {\n assert(\n `[${requester.name}] requested columns from the table, but the plugin, ${requester.name}, ` +\n `is not used in this table`,\n table.plugins.some((plugin) => plugin instanceof (requester as Class<Plugin>))\n );\n\n if (visibility && visibility.constructor === requester) {\n return table.columns.values();\n }\n\n if (reordering && reordering.constructor === requester) {\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n /**\n * This flow is the inverse of when we have a requester\n */\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n}\n\nexport const columns = {\n for: columnsFor,\n\n /**\n * for a given current or reference column, return the column that\n * is immediately next, or to the right of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n next: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing after the last column\n */\n if (referenceIndex >= columns.length - 1) {\n return undefined;\n }\n\n return columns[referenceIndex + 1];\n },\n\n /**\n * for a given current or reference column, return the column that\n * is immediately previous, or to the left of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n previous: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing before the first column\n */\n if (referenceIndex === 0) {\n return undefined;\n }\n\n return columns[referenceIndex - 1];\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear before, or to the left of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n before: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(0, referenceIndex);\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear after, or to the right of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n after: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(referenceIndex + 1);\n },\n};\n\nexport const meta = {\n /**\n * @public\n *\n * For a given column and plugin, return the meta / state bucket for the\n * plugin<->column instance pair.\n *\n * Note that this requires the column instance to exist on the table.\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): ColumnMetaFor<SignatureFrom<P>> {\n return getPluginInstance(COLUMN_META, column, klass, () => {\n let plugin = column.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify column meta`, plugin.meta.column);\n\n return new plugin.meta.column(column);\n });\n },\n\n /**\n * @public\n *\n * For a given row and plugin, return the meta / state bucket for the\n * plugin<->row instance pair.\n *\n * Note that this requires the row instance to exist on the table.\n */\n forRow<P extends BasePlugin<any>, Data = unknown>(\n row: Row<Data>,\n klass: Class<P>\n ): RowMetaFor<SignatureFrom<P>> {\n return getPluginInstance(ROW_META, row, klass, () => {\n let plugin = row.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify row meta`, plugin.meta.row);\n\n return new plugin.meta.row(row);\n });\n },\n\n /**\n * @public\n *\n * For a given table and plugin, return the meta / state bucket for the\n * plugin<->table instance pair.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): TableMetaFor<SignatureFrom<P>> {\n return getPluginInstance(TABLE_META, table[TABLE_KEY], klass, () => {\n let plugin = table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify table meta`, plugin.meta.table);\n assert(\n `<#${plugin.name}> plugin already exists for the table. ` +\n `A plugin may only be instantiated once per table.`,\n ![...(TABLE_META.get(table[TABLE_KEY])?.keys() ?? [])].includes(klass)\n );\n\n return new plugin.meta.table(table);\n });\n },\n\n /**\n * Instead of finding meta based on column or table instances,\n * you can search for meta based on feature strings, such as `columnWidth`\n */\n withFeature: {\n /**\n * @public\n *\n * for a given column and feature name, return the \"ColumnMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care which\n * plugin is providing what behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility\n */\n forColumn<FeatureName extends string, Data = unknown>(\n column: Column<Data>,\n featureName: FeatureName\n ): ColumnFeatures[FeatureName] {\n let { plugins } = column.table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forColumn(column, (provider as any).constructor);\n },\n\n /**\n * @public\n *\n * for a given table and feature name, return the \"TableMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care\n * which plugin is providing that behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility.\n */\n forTable<FeatureName extends string, Data = unknown>(\n table: Table<Data>,\n featureName: FeatureName\n ): TableFeatures[FeatureName] {\n let { plugins } = table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forTable(table, (provider as any).constructor);\n },\n },\n};\n\nfunction findPlugin(plugins: Plugin[], featureName: string) {\n let provider = plugins.find((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features?.includes(featureName);\n });\n\n return provider;\n}\n\nfunction availableFeatures(plugins: Plugin[]): string {\n let allFeatures = plugins\n .map((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features;\n })\n .flat()\n .filter(Boolean);\n\n return allFeatures.length > 0 ? allFeatures.join(', ') : '[none]';\n}\n\nexport const options = {\n /**\n * @public\n *\n * For a given table and plugin, return the options, if any were given from the user\n * during construction of the table.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): Partial<OptionsFor<SignatureFrom<P>>> {\n let normalized = normalizePluginsConfig(table?.config?.plugins);\n let tuple = normalized?.find((option) => option[0] === klass);\n let t = tuple as [Class<P>, () => OptionsFor<SignatureFrom<P>>];\n\n // Plugin not provided, likely\n if (!t) return {};\n\n let fn = t[1];\n\n return fn() ?? {};\n },\n\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): Partial<ColumnOptionsFor<SignatureFrom<P>>> {\n let tuple = column.config.pluginOptions?.find((option) => option[0] === klass);\n let t = tuple as [unknown, () => ColumnOptionsFor<SignatureFrom<P>>];\n\n let fn = t?.[1];\n\n if (!fn) return {};\n\n return fn() ?? {};\n },\n};\n\n/**\n * @private\n */\nfunction getPluginInstance<RootKey extends string | Column<any> | Row<any>, Instance>(\n map: RootKey extends string\n ? Map<string, Map<Class<Instance>, Instance>>\n : WeakMap<Column | Row, Map<Class<Instance>, Instance>>,\n rootKey: RootKey,\n mapKey: Class<Instance>,\n factory: () => Instance\n): Instance {\n let bucket: Map<Class<Instance>, Instance> | undefined;\n\n if (map instanceof WeakMap) {\n assert(`Cannot use string key with WeakMap`, typeof rootKey !== 'string');\n\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n } else {\n assert(`Cannot use object key with Map`, typeof rootKey === 'string');\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n }\n\n let instance = bucket.get(mapKey);\n\n if (instance) {\n return instance;\n }\n\n instance = factory();\n\n bucket.set(mapKey, instance);\n\n return instance;\n}\n"],"names":["TABLE_META","Map","COLUMN_META","WeakMap","ROW_META","BasePlugin","constructor","table","with","configFn","forColumn","hasPlugin","klass","Boolean","pluginOf","preferences","column","delete","key","prefs","existing","storage","forPlugin","name","columnPrefs","persist","get","set","value","forTable","columnsFor","requester","assert","TABLE_KEY","visibility","findPlugin","plugins","reordering","some","plugin","columns","values","Array","isArray","for","next","current","referenceIndex","indexOf","length","undefined","previous","before","slice","after","meta","getPluginInstance","forRow","row","keys","includes","withFeature","featureName","provider","availableFeatures","find","features","allFeatures","map","flat","filter","join","options","normalized","normalizePluginsConfig","config","tuple","option","t","fn","pluginOptions","rootKey","mapKey","factory","bucket","instance"],"mappings":";;;;;AAmBA,MAAMA,UAAU,GAAG,IAAIC,GAAG,EAAoC,CAAA;AAC9D,MAAMC,WAAW,GAAG,IAAIC,OAAO,EAAoC,CAAA;AACnE,MAAMC,QAAQ,GAAG,IAAID,OAAO,EAAiC,CAAA;AAwD7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAeE,UAAU,CAAmD;EACjFC,WAAW,CAAWC,KAAY,EAAE;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAAA,IAAdA,CAAAA,KAAY,GAAZA,KAAY,CAAA;AAAG,GAAA;;AAErC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;EACE,OAAOC,IAAI,CAETC,QAA4C,EACU;AACtD,IAAA,OAAO,CAAC,IAAI,EAAEA,QAAQ,CAAC,CAAA;AACzB,GAAA;;AAEA;AACF;AACA;AACA;EACE,OAAOC,SAAS,CAEdD,QAAkD,EACU;AAC5D,IAAA,OAAO,CAAC,IAAI,EAAEA,QAAQ,CAAC,CAAA;AACzB,GAAA;AAWF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,eAAA,CA9CsBJ,UAAU,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAAA,eAAA,CAAVA,UAAU,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAqDzB,SAASM,SAAS,CACvBJ,KAAkB,EAClBK,KAAe,EACf;EACA,OAAOC,OAAO,CAACN,KAAK,CAACO,QAAQ,CAACF,KAAK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,OAAOA,QAAQ,CAAA;AACjB;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _initializerDefineProperty } from '../../table-
|
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-
|
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';
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { BasePlugin, columns, meta, options, preferences } from "./-private/base";
|
1
|
+
export { BasePlugin, columns, hasPlugin, meta, options, preferences } from "./-private/base";
|
2
2
|
export { applyStyles, removeStyles } from "./-private/utils";
|
3
3
|
export type { ColumnFeatures, TableFeatures } from "./-private/base";
|
4
4
|
export type { ColumnApi, Plugin, PluginPreferences, Registry } from "../-private/interfaces/index";
|
package/dist/plugins/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export { BasePlugin, columns, meta, options, preferences } from './-private/base.js';
|
1
|
+
export { BasePlugin, columns, hasPlugin, meta, options, preferences } from './-private/base.js';
|
2
2
|
export { applyStyles, removeStyles } from './-private/utils.js';
|
3
3
|
//# sourceMappingURL=index.js.map
|
@@ -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
|
-
|
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
|
-
|
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":"
|
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;;;;"}
|
@@ -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
|
-
|
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,
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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:
|
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
|
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,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE;AAC3DF,QAAAA,OAAO,CAACC,KAAK,CAACE,cAAc,CAAC,UAAU,CAAC,CAAA;AAC1C,OAAA;MAEA,IAAIH,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,MAAM,CAAC,EAAE;AAC1CF,QAAAA,OAAO,CAACC,KAAK,CAACG,IAAI,GAAG,EAAE,CAAA;AACzB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AAA;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
|
-
|
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
|
-
...
|
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-
|
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,MAAM,CAAC,eAAe,EAAC;AAEhD,MAAMC,eAAe,GAAG,CAACC,OAAgB,EAAEC,KAAY,KAAK;AAC1DC,EAAAA,MAAM,CAAC,qCAAqC,EAAEF,OAAO,YAAY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AAA;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/dist/utils.js
CHANGED
package/dist/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { camelize, underscore } from '@ember/string';\n\nimport { SortDirection } from './plugins/data-sorting/types';\n\nimport type { Sort, SortsOptions } from './plugins/data-sorting/types';\n\n/**\n * @example\n *\n * ```ts\n * deserializeSorts('first_name.asc', { separator: '.', transform: 'camelize' });\n * // => [{ property: 'firstName', direction: 'ascending' }]\n *\n * deserializeSorts('last_name.desc', { separator: '.', transform: 'camelize' });\n * // => [{ property: 'lastName', direction: 'descending' }]\n * ```\n */\n\nexport const deserializeSorts = (\n sortString: string,\n options: SortsOptions = { separator: '.', transform: 'camelize' }\n): Sort[] => {\n
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { camelize, underscore } from '@ember/string';\n\nimport { SortDirection } from './plugins/data-sorting/types';\n\nimport type { Sort, SortsOptions } from './plugins/data-sorting/types';\n\n/**\n * @example\n *\n * ```ts\n * deserializeSorts('first_name.asc', { separator: '.', transform: 'camelize' });\n * // => [{ property: 'firstName', direction: 'ascending' }]\n *\n * deserializeSorts('last_name.desc', { separator: '.', transform: 'camelize' });\n * // => [{ property: 'lastName', direction: 'descending' }]\n * ```\n */\n\nexport const deserializeSorts = (\n sortString: string,\n options: SortsOptions = { separator: '.', transform: 'camelize' }\n): Sort[] => {\n if (!sortString) {\n return [];\n }\n\n let { transform, separator } = options;\n let [key, direction] = sortString.split(separator);\n\n assert(`No key found for input: \\`${sortString}\\` using \\`${separator}\\` as a separator`, key);\n\n if (transform === 'camelize') {\n key = camelize(key);\n } else if (transform === 'underscore') {\n key = underscore(key);\n }\n\n return [\n {\n property: key,\n direction: direction === 'asc' ? SortDirection.Ascending : SortDirection.Descending,\n },\n ];\n};\n\n/**\n * @example\n *\n * ```ts\n * serializeSorts([{ property: 'firstName', direction: 'ascending' }],{ separator: '.', transform: 'camelize' });\n * // => 'first_name.asc'\n *\n * serializeSorts([{ property: 'lastName', direction: 'descending' }],{ separator: '.', transform: 'camelize' });\n * // => 'last_name.desc'\n * ```\n */\nexport function serializeSorts(\n sorts: Sort[],\n options: SortsOptions = { separator: '.', transform: 'underscore' }\n): string {\n const { transform, separator } = options;\n\n let sortParameters = sorts.map(({ direction, property }) => {\n let shortDirection = direction === 'ascending' ? 'asc' : 'desc';\n\n let sortField = property;\n\n if (transform === 'underscore') {\n sortField = underscore(property);\n } else if (transform === 'camelize') {\n sortField = camelize(property);\n }\n\n return `${sortField}${separator}${shortDirection}`;\n });\n\n return sortParameters.join('+');\n}\n"],"names":["deserializeSorts","sortString","options","separator","transform","key","direction","split","assert","camelize","underscore","property","SortDirection","Ascending","Descending","serializeSorts","sorts","sortParameters","map","shortDirection","sortField","join"],"mappings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c,GAAGD,KAAK,CAACE,GAAG,CAAC,CAAC;IAAEZ,SAAS;AAAEK,IAAAA,QAAAA;AAAS,GAAC,KAAK;IAC1D,IAAIQ,cAAc,GAAGb,SAAS,KAAK,WAAW,GAAG,KAAK,GAAG,MAAM,CAAA;IAE/D,IAAIc,SAAS,GAAGT,QAAQ,CAAA;IAExB,IAAIP,SAAS,KAAK,YAAY,EAAE;AAC9BgB,MAAAA,SAAS,GAAGV,UAAU,CAACC,QAAQ,CAAC,CAAA;AAClC,KAAC,MAAM,IAAIP,SAAS,KAAK,UAAU,EAAE;AACnCgB,MAAAA,SAAS,GAAGX,QAAQ,CAACE,QAAQ,CAAC,CAAA;AAChC,KAAA;AAEA,IAAA,OAAQ,GAAES,SAAU,CAAA,EAAEjB,SAAU,CAAA,EAAEgB,cAAe,CAAC,CAAA,CAAA;AACpD,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOF,cAAc,CAACI,IAAI,CAAC,GAAG,CAAC,CAAA;AACjC;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ember-headless-table",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.4.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,13 +98,13 @@
|
|
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": "^
|
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",
|
104
105
|
"@nullvoxpopuli/eslint-configs": "~2.2.57",
|
105
106
|
"@rollup/plugin-babel": "^6.0.0",
|
106
|
-
"@tsconfig/ember": "^
|
107
|
+
"@tsconfig/ember": "^2.0.0",
|
107
108
|
"@types/ember__application": "^4.0.1",
|
108
109
|
"@types/ember__debug": "^4.0.1",
|
109
110
|
"@types/ember__destroyable": "^4.0.0",
|
@@ -124,7 +125,7 @@
|
|
124
125
|
"eslint-plugin-ember": "^11.0.6",
|
125
126
|
"eslint-plugin-node": "^11.1.0",
|
126
127
|
"eslint-plugin-prettier": "^4.0.0",
|
127
|
-
"expect-type": "^0.
|
128
|
+
"expect-type": "^0.15.0",
|
128
129
|
"prettier": "^2.5.1",
|
129
130
|
"rollup": "^3.2.2",
|
130
131
|
"rollup-plugin-copy": "^3.4.0",
|
@@ -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,EAAE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