ember-headless-table 1.4.2 → 1.4.3
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/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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/plugins/-private/base.d.ts +1 -1
- package/dist/plugins/-private/base.js +30 -20
- 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/{table-0cbd2720.d.ts → table-dde25960.d.ts} +16 -1
- package/dist/{table-0cbd2720.js → table-dde25960.js} +8 -2
- package/dist/{table-0cbd2720.js.map → table-dde25960.js.map} +1 -1
- package/package.json +1 -1
package/dist/-private/row.d.ts
CHANGED
package/dist/-private/table.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export {
|
1
|
+
export { C as COLUMN_META_KEY, R as ROW_META_KEY, a as TABLE_KEY, T as TABLE_META_KEY, b as Table } from '../table-dde25960.js';
|
2
2
|
import '../defineProperty-35ce617b.js';
|
3
3
|
import '../applyDecoratedDescriptor-6b986a67.js';
|
4
4
|
import '@glimmer/tracking';
|
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-dde25960";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Table } from "../../table-
|
1
|
+
import { Table } from "../../table-dde25960";
|
2
2
|
import { ColumnReordering } from "../column-reordering/index";
|
3
3
|
import { ColumnVisibility } from "../column-visibility/index";
|
4
4
|
import { Class, Constructor } from "../../-private/private-types";
|
@@ -1,11 +1,8 @@
|
|
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 { C as COLUMN_META_KEY, R as ROW_META_KEY, T as TABLE_META_KEY, a as TABLE_KEY } from '../../table-dde25960.js';
|
4
4
|
import { normalizePluginsConfig } from './utils.js';
|
5
5
|
|
6
|
-
const TABLE_META = new Map();
|
7
|
-
const COLUMN_META = new WeakMap();
|
8
|
-
const ROW_META = new WeakMap();
|
9
6
|
/**
|
10
7
|
* @public
|
11
8
|
*
|
@@ -285,7 +282,8 @@ const meta = {
|
|
285
282
|
* Note that this requires the column instance to exist on the table.
|
286
283
|
*/
|
287
284
|
forColumn(column, klass) {
|
288
|
-
|
285
|
+
let columnMeta = column.table[COLUMN_META_KEY];
|
286
|
+
return getPluginInstance(columnMeta, column, klass, () => {
|
289
287
|
let plugin = column.table.pluginOf(klass);
|
290
288
|
assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);
|
291
289
|
assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);
|
@@ -302,7 +300,8 @@ const meta = {
|
|
302
300
|
* Note that this requires the row instance to exist on the table.
|
303
301
|
*/
|
304
302
|
forRow(row, klass) {
|
305
|
-
|
303
|
+
let rowMeta = row.table[ROW_META_KEY];
|
304
|
+
return getPluginInstance(rowMeta, row, klass, () => {
|
306
305
|
let plugin = row.table.pluginOf(klass);
|
307
306
|
assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);
|
308
307
|
assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);
|
@@ -317,12 +316,13 @@ const meta = {
|
|
317
316
|
* plugin<->table instance pair.
|
318
317
|
*/
|
319
318
|
forTable(table, klass) {
|
320
|
-
|
319
|
+
let tableMeta = table[TABLE_META_KEY];
|
320
|
+
return getPluginInstance(tableMeta, klass, () => {
|
321
321
|
let plugin = table.pluginOf(klass);
|
322
322
|
assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);
|
323
323
|
assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);
|
324
324
|
assert(`<#${plugin.name}> plugin does not specify table meta`, plugin.meta.table);
|
325
|
-
assert(`<#${plugin.name}> plugin already exists for the table. ` + `A plugin may only be instantiated once per table.`, ![...
|
325
|
+
assert(`<#${plugin.name}> plugin already exists for the table. ` + `A plugin may only be instantiated once per table.`, ![...tableMeta.keys()].includes(klass));
|
326
326
|
return new plugin.meta.table(table);
|
327
327
|
});
|
328
328
|
},
|
@@ -422,26 +422,36 @@ const options = {
|
|
422
422
|
return fn() ?? {};
|
423
423
|
}
|
424
424
|
};
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
425
|
+
function getPluginInstance(...args) {
|
426
|
+
let map;
|
427
|
+
let mapKey;
|
428
|
+
let rootKey;
|
429
|
+
let factory;
|
430
|
+
if (args.length === 3) {
|
431
|
+
map = args[0];
|
432
|
+
mapKey = args[1];
|
433
|
+
factory = args[2];
|
434
|
+
} else if (args.length === 4) {
|
435
|
+
map = args[0];
|
436
|
+
rootKey = args[1];
|
437
|
+
mapKey = args[2];
|
438
|
+
factory = args[3];
|
439
|
+
} else {
|
440
|
+
throw new Error(
|
441
|
+
// TS says args is of type "never", but TS can't protect against general misuse
|
442
|
+
// (esp without TS)
|
443
|
+
`Incorrect arity passed to getPluginInstance. Expected 3 or 4, received ${args.length}`);
|
444
|
+
}
|
430
445
|
let bucket;
|
431
446
|
if (map instanceof WeakMap) {
|
432
|
-
assert(`
|
447
|
+
assert(`rootKey is missing`, rootKey);
|
433
448
|
bucket = map.get(rootKey);
|
434
449
|
if (!bucket) {
|
435
450
|
bucket = new Map();
|
436
451
|
map.set(rootKey, bucket);
|
437
452
|
}
|
438
453
|
} else {
|
439
|
-
|
440
|
-
bucket = map.get(rootKey);
|
441
|
-
if (!bucket) {
|
442
|
-
bucket = new Map();
|
443
|
-
map.set(rootKey, bucket);
|
444
|
-
}
|
454
|
+
bucket = map;
|
445
455
|
}
|
446
456
|
let instance = bucket.get(mapKey);
|
447
457
|
if (instance) {
|
@@ -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\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,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,GAAG,CAAC1C,GAAG,CAACuD,OAAO,CAAC,CAAA;IAEzB,IAAI,CAACG,MAAM,EAAE;MACXA,MAAM,GAAG,IAAInF,GAAG,EAAE,CAAA;AAElBmE,MAAAA,GAAG,CAACzC,GAAG,CAACsD,OAAO,EAAEG,MAAM,CAAC,CAAA;AAC1B,KAAA;AACF,GAAA;AAEA,EAAA,IAAIC,QAAQ,GAAGD,MAAM,CAAC1D,GAAG,CAACwD,MAAM,CAAC,CAAA;AAEjC,EAAA,IAAIG,QAAQ,EAAE;AACZ,IAAA,OAAOA,QAAQ,CAAA;AACjB,GAAA;EAEAA,QAAQ,GAAGF,OAAO,EAAE,CAAA;AAEpBC,EAAAA,MAAM,CAACzD,GAAG,CAACuD,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 { COLUMN_META_KEY, ROW_META_KEY, TABLE_KEY, TABLE_META_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\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 let columnMeta = column.table[COLUMN_META_KEY];\n\n return getPluginInstance(columnMeta, 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 let rowMeta = row.table[ROW_META_KEY];\n\n return getPluginInstance(rowMeta, 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 let tableMeta = table[TABLE_META_KEY];\n\n return getPluginInstance(tableMeta, 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 ![...tableMeta.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\ntype FactoryMap<Instance> = Map<Class<Instance>, Instance>;\n\n/**\n * @private\n */\nfunction getPluginInstance<Instance>(\n map: Map<Class<Instance>, Instance>,\n mapKey: Class<Instance>,\n factory: () => Instance\n): Instance;\nfunction getPluginInstance<RootKey extends Column<any> | Row<any>, Instance>(\n map: WeakMap<Column | Row, Map<Class<Instance>, Instance>>,\n rootKey: RootKey,\n mapKey: Class<Instance>,\n factory: () => Instance\n): Instance;\nfunction getPluginInstance<RootKey extends Column<any> | Row<any>, Instance>(\n ...args:\n | [FactoryMap<Instance>, Class<Instance>, () => Instance]\n | [WeakMap<Column | Row, FactoryMap<Instance>>, RootKey, Class<Instance>, () => Instance]\n): Instance {\n let map: WeakMap<Column | Row, FactoryMap<Instance>> | FactoryMap<Instance>;\n let mapKey: Class<Instance>;\n let rootKey: RootKey | undefined;\n let factory: () => Instance;\n\n if (args.length === 3) {\n map = args[0];\n mapKey = args[1];\n factory = args[2];\n } else if (args.length === 4) {\n map = args[0];\n rootKey = args[1];\n mapKey = args[2];\n factory = args[3];\n } else {\n throw new Error(\n // TS says args is of type \"never\", but TS can't protect against general misuse\n // (esp without TS)\n `Incorrect arity passed to getPluginInstance. Expected 3 or 4, received ${\n (args as any).length\n }`\n );\n }\n\n let bucket: FactoryMap<Instance> | undefined;\n\n if (map instanceof WeakMap) {\n assert(`rootKey is missing`, rootKey);\n\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n } else {\n bucket = map;\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":["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","columnMeta","COLUMN_META_KEY","getPluginInstance","forRow","row","rowMeta","ROW_META_KEY","tableMeta","TABLE_META_KEY","keys","includes","withFeature","featureName","provider","availableFeatures","find","features","allFeatures","map","flat","filter","join","options","normalized","normalizePluginsConfig","config","tuple","option","t","fn","pluginOptions","args","mapKey","rootKey","factory","Error","bucket","WeakMap","Map","instance"],"mappings":";;;;;AAyEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAeA,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,CAAC,CAAC,CAAA;AACvC,CAAA;AAEO,MAAMG,WAAW,GAAG;AACzB;AACF;AACA;AACA;AACA;AAC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,CAAA;AAElBpB,MAAAA,GAAG,CAAC/C,GAAG,CAAC8D,OAAO,EAAEG,MAAM,CAAC,CAAA;AAC1B,KAAA;AACF,GAAC,MAAM;AACLA,IAAAA,MAAM,GAAGlB,GAAG,CAAA;AACd,GAAA;AAEA,EAAA,IAAIqB,QAAQ,GAAGH,MAAM,CAAClE,GAAG,CAAC8D,MAAM,CAAC,CAAA;AAEjC,EAAA,IAAIO,QAAQ,EAAE;AACZ,IAAA,OAAOA,QAAQ,CAAA;AACjB,GAAA;EAEAA,QAAQ,GAAGL,OAAO,EAAE,CAAA;AAEpBE,EAAAA,MAAM,CAACjE,GAAG,CAAC6D,MAAM,EAAEO,QAAQ,CAAC,CAAA;AAE5B,EAAA,OAAOA,QAAQ,CAAA;AACjB;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _initializerDefineProperty } from '../../table-
|
1
|
+
import { _ as _initializerDefineProperty } from '../../table-dde25960.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-dde25960.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';
|
@@ -18,11 +18,26 @@ interface Signature<DataType> {
|
|
18
18
|
* ember-resources.
|
19
19
|
*/
|
20
20
|
declare const TABLE_KEY: unique symbol;
|
21
|
+
declare const TABLE_META_KEY: unique symbol;
|
22
|
+
declare const COLUMN_META_KEY: unique symbol;
|
23
|
+
declare const ROW_META_KEY: unique symbol;
|
21
24
|
declare class Table<DataType = unknown> extends Resource<Signature<DataType>> {
|
22
25
|
/**
|
23
26
|
* @private
|
24
27
|
*/
|
25
28
|
[TABLE_KEY]: string;
|
29
|
+
/**
|
30
|
+
* @private
|
31
|
+
*/
|
32
|
+
[TABLE_META_KEY]: Map<Class<unknown>, any>;
|
33
|
+
/**
|
34
|
+
* @private
|
35
|
+
*/
|
36
|
+
[COLUMN_META_KEY]: WeakMap<Column<unknown>, Map<Class<unknown>, any>>;
|
37
|
+
/**
|
38
|
+
* @private
|
39
|
+
*/
|
40
|
+
[ROW_META_KEY]: WeakMap<Row<Record<string, unknown>>, Map<Class<unknown>, any>>;
|
26
41
|
/**
|
27
42
|
* @private
|
28
43
|
*
|
@@ -126,4 +141,4 @@ declare class Table<DataType = unknown> extends Resource<Signature<DataType>> {
|
|
126
141
|
resetScrollContainer(): void;
|
127
142
|
resetToDefaults(): void;
|
128
143
|
}
|
129
|
-
export { TABLE_KEY, Table };
|
144
|
+
export { TABLE_KEY, TABLE_META_KEY, COLUMN_META_KEY, ROW_META_KEY, Table };
|
@@ -41,6 +41,9 @@ const DEFAULT_COLUMN_CONFIG = {
|
|
41
41
|
* ember-resources.
|
42
42
|
*/
|
43
43
|
const TABLE_KEY = Symbol('__TABLE_KEY__');
|
44
|
+
const TABLE_META_KEY = Symbol('__TABLE_META__');
|
45
|
+
const COLUMN_META_KEY = Symbol('__COLUMN_META__');
|
46
|
+
const ROW_META_KEY = Symbol('__ROW_META__');
|
44
47
|
const attachContainer = (element, table) => {
|
45
48
|
assert('Must be installed on an HTMLElement', element instanceof HTMLElement);
|
46
49
|
table.scrollContainerElement = element;
|
@@ -49,6 +52,9 @@ let Table = (_class = class Table extends Resource {
|
|
49
52
|
constructor(...args) {
|
50
53
|
super(...args);
|
51
54
|
_defineProperty(this, TABLE_KEY, guidFor(this));
|
55
|
+
_defineProperty(this, TABLE_META_KEY, new Map());
|
56
|
+
_defineProperty(this, COLUMN_META_KEY, new WeakMap());
|
57
|
+
_defineProperty(this, ROW_META_KEY, new WeakMap());
|
52
58
|
_initializerDefineProperty(this, "scrollContainerHeight", _descriptor, this);
|
53
59
|
_initializerDefineProperty(this, "scrollContainerWidth", _descriptor2, this);
|
54
60
|
_initializerDefineProperty(this, "args", _descriptor3, this);
|
@@ -243,5 +249,5 @@ let Table = (_class = class Table extends Resource {
|
|
243
249
|
initializer: null
|
244
250
|
}), _applyDecoratedDescriptor(_class.prototype, "plugins", [cached], Object.getOwnPropertyDescriptor(_class.prototype, "plugins"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetScrollContainer", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetScrollContainer"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetToDefaults", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetToDefaults"), _class.prototype)), _class);
|
245
251
|
|
246
|
-
export {
|
247
|
-
//# sourceMappingURL=table-
|
252
|
+
export { COLUMN_META_KEY as C, ROW_META_KEY as R, TABLE_META_KEY as T, _initializerDefineProperty as _, TABLE_KEY as a, Table as b };
|
253
|
+
//# sourceMappingURL=table-dde25960.js.map
|
@@ -1 +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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,CAAA,EAAA;AAAA,EAAA,YAAA,EAAA,IAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,QAAA,EAAA,IAAA;AAAA,EAAA,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,EAAA,YAAA,GAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,MAAA,EAAA,CAOPA,OAAO,CAAA,EAAA;AAAA,EAAA,YAAA,EAAA,IAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,QAAA,EAAA,IAAA;AAAA,EAAA,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,SAAA,EAAA,CA0FPC,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,sBAAA,EAAA,CAwGNC,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,sBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,CAONA,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,iBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,GAAA,MAAA;;;;"}
|
1
|
+
{"version":3,"file":"table-dde25960.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__');\nexport const TABLE_META_KEY = Symbol('__TABLE_META__');\nexport const COLUMN_META_KEY = Symbol('__COLUMN_META__');\nexport const ROW_META_KEY = Symbol('__ROW_META__');\n\nconst attachContainer = (element: Element, table: Table) => {\n assert('Must be installed on an HTMLElement', element instanceof HTMLElement);\n\n table.scrollContainerElement = element;\n};\n\nexport class Table<DataType = unknown> extends Resource<Signature<DataType>> {\n /**\n * @private\n */\n [TABLE_KEY] = guidFor(this);\n /**\n * @private\n */\n [TABLE_META_KEY] = new Map<Class<unknown>, any>();\n /**\n * @private\n */\n [COLUMN_META_KEY] = new WeakMap<Column, Map<Class<unknown>, any>>();\n /**\n * @private\n */\n [ROW_META_KEY] = new WeakMap<Row, Map<Class<unknown>, any>>();\n\n /**\n * @private\n *\n * Unused for now, may be used in the future.\n * This data is collected along with the scrollContainerWidth, (which is currently in use)\n */\n @tracked scrollContainerHeight?: number;\n\n /**\n * @private\n *\n * Used to help determine how much space we can give to columns.\n * As we generate widths for columns, the columns' widths must\n * add up to about this number.\n */\n @tracked scrollContainerWidth?: number;\n\n /**\n * @private\n *\n * Lazy way to delay consuming arguments until they are needed.\n */\n @tracked declare args: { named: Signature<DataType>['Named'] };\n\n /**\n * @private\n */\n scrollContainerElement?: HTMLElement;\n\n /**\n * Interact with, save, modify, etc the preferences for the table,\n * plugins, columns, etc\n */\n declare preferences: TablePreferences;\n\n /**\n * @private\n */\n modify(_: [] | undefined, named: Signature<DataType>['Named']) {\n this.args = { named };\n\n // only set the preferences once\n if (!this.preferences) {\n let { key = guidFor(this), adapter } = named?.preferences ?? {};\n\n // TODO: when no key is present,\n // use \"local-storage\" preferences.\n // it does not make sense to use a guid in a user's preferences\n this.preferences = new TablePreferences(key, adapter);\n } else {\n // subsequent updates to args\n this.resetScrollContainer();\n }\n }\n\n /**\n * Collection of utility modifiers that are the result of composing modifiers\n * from plugins.\n *\n * Using this is optional, and you can \"just\" use modifiers from specific plugins\n * in specific places if you wish -- but these exists as a \"convenience\".\n *\n * These are all no-use, no-cost utilities\n */\n modifiers = {\n container: modifier(\n (element: HTMLElement): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.containerModifier);\n let composed = composeFunctionModifiers([attachContainer, ...modifiers]);\n\n return composed(element, this);\n },\n { eager: false }\n ),\n\n // resize: ResizeModifier,\n // TODO: switch to composing real modifiers once \"curry\" and \"compose\"\n // RFCs are accepted and implemented\n //\n // Atm the moment, if _any_ header modifier's tracked data changes,\n // all the functions for all of the plugins run again.\n //\n // With curried+composed modifiers, only the plugin's headerModifier\n // that has tracked changes would run, leaving the other modifiers alone\n columnHeader: modifier(\n (element: HTMLElement, [column]: [Column<DataType>]): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.headerCellModifier);\n let composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { column, table: this });\n },\n { eager: false }\n ),\n\n row: modifier(\n (element: HTMLElement, [row]: [Row<DataType>]): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.rowModifier);\n let composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { row, table: this });\n },\n { eager: false }\n ),\n };\n\n /**\n * @private\n *\n * For all configured plugins, instantiates each one.\n * If the plugins argument changes to the Table (either directly or through\n * headlessTable, all state is lost and re-created)\n */\n @cached\n get plugins(): Plugin[] {\n let plugins = normalizePluginsConfig(this.args.named?.plugins);\n\n verifyPlugins(plugins);\n\n return plugins.map((tuple) => {\n // We don't need the options here\n let [PluginClass] = tuple;\n\n if (typeof PluginClass === 'function') {\n let plugin = new PluginClass(this);\n\n let owner = getOwner(this);\n\n assert(`The Table does not have an owner. cannot create a plugin without an owner`, owner);\n setOwner(plugin, owner);\n\n return plugin;\n }\n\n // This is a plugin object, rather than a class\n // TODO: add test coverage around using classless plugins\n return PluginClass;\n });\n }\n\n /**\n * Get the active plugin instance for the given plugin class\n */\n pluginOf<Instance extends BasePlugin<any>>(klass: Class<Instance>): Instance | undefined {\n let result = this.plugins.find((plugin) => plugin instanceof klass);\n\n /**\n * This is an unsafe cast, because Instance could be unrelated to any of the types\n * that matches Plugin[]\n *\n * For example, `table.pluginOf(MyCustomPlugin)`, where MyCustomPlugin isn't in the\n * `plugins` list. This partially a problem with how Array.prototype.find doesn't\n * effectively narrow for what we want (combined with TS being clunky around\n * comparing Instance and Class types).\n */\n return result as unknown as Instance | undefined;\n }\n\n /**\n * @private\n *\n * used by other private APIs\n */\n get config() {\n return this.args.named;\n }\n\n rows = map(this, {\n data: () => {\n let dataFn = this.args.named?.data;\n\n if (!dataFn) return [];\n\n return dataFn() ?? [];\n },\n map: (datum) => new Row(this, datum),\n });\n\n columns = map(this, {\n data: () => {\n let configFn = this.args.named?.columns;\n\n if (!configFn) return [];\n\n let result = configFn() ?? [];\n\n if (macroCondition(isDevelopingApp())) {\n /**\n * Assertions for a column config to be valid:\n * - every key must be unique\n */\n let keys = new Set();\n let allKeys = result.map((columnConfig) => columnConfig.key);\n\n result.forEach((columnConfig) => {\n if (keys.has(columnConfig.key)) {\n throw new Error(\n `Every column key in the table's column config must be unique. ` +\n `Found duplicate entry: ${columnConfig.key}. ` +\n `All keys used: ${allKeys}`\n );\n }\n\n keys.add(columnConfig.key);\n });\n }\n\n return result;\n },\n map: (config) => {\n return new Column<DataType>(this, { ...DEFAULT_COLUMN_CONFIG, ...config });\n },\n });\n\n /**\n * @private\n */\n @action\n resetScrollContainer() {\n if (!this.scrollContainerElement) return;\n\n this.scrollContainerElement.scrollTop = 0;\n }\n\n @action\n resetToDefaults() {\n this.plugins.forEach((plugin) => plugin.reset?.());\n }\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","DEFAULT_COLUMN_CONFIG","isVisible","minWidth","TABLE_KEY","Symbol","TABLE_META_KEY","COLUMN_META_KEY","ROW_META_KEY","attachContainer","element","table","assert","HTMLElement","scrollContainerElement","Table","Resource","guidFor","Map","WeakMap","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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