ember-headless-table 1.3.0 → 1.4.1
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-api.test.js +1 -0
- package/dist/-private/-type-tests/table-api.test.js.map +1 -1
- package/dist/-private/-type-tests/table-config.test.js +1 -1
- package/dist/-private/interfaces/column.d.ts +6 -1
- package/dist/plugins/-private/base.d.ts +9 -1
- package/dist/plugins/-private/base.js +12 -1
- package/dist/plugins/-private/base.js.map +1 -1
- package/dist/plugins/column-resizing/helpers.d.ts +11 -1
- package/dist/plugins/column-resizing/helpers.js +26 -1
- package/dist/plugins/column-resizing/helpers.js.map +1 -1
- package/dist/plugins/column-resizing/index.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 +1 -1
- package/dist/plugins/sticky-columns/helpers.js +1 -1
- package/dist/plugins/sticky-columns/helpers.js.map +1 -1
- package/dist/utils.js +4 -1
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
@@ -2,6 +2,7 @@ import { expectTypeOf } from 'expect-type';
|
|
2
2
|
import '../../plugins/-private/base.js';
|
3
3
|
import { ColumnReordering } from '../../plugins/column-reordering/plugin.js';
|
4
4
|
import '../../plugins/column-resizing/handle.js';
|
5
|
+
import '@ember/template';
|
5
6
|
import { ColumnResizing } from '../../plugins/column-resizing/plugin.js';
|
6
7
|
import { Sorting } from '../../plugins/data-sorting/plugin.js';
|
7
8
|
import '../../plugins/data-sorting/types.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table-api.test.js","sources":["../../../src/-private/-type-tests/table-api.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { DataSorting } from '../../plugins/data-sorting';\n\nimport type { Table } from '[public-types]';\n\n// We're testing types, not behaviors\nconst x = 0 as unknown as Table<{ x: number }>;\n\n//////////////////////////////\n// <Table>#pluginOf\nexpectTypeOf(x.pluginOf(DataSorting)).toEqualTypeOf<DataSorting | undefined>();\nexpectTypeOf(x.pluginOf(ColumnReordering)).toEqualTypeOf<ColumnReordering | undefined>();\nexpectTypeOf(x.pluginOf(ColumnResizing)).toEqualTypeOf<ColumnResizing | undefined>();\n"],"names":["x","expectTypeOf","pluginOf","DataSorting","toEqualTypeOf","ColumnReordering","ColumnResizing"],"mappings":"
|
1
|
+
{"version":3,"file":"table-api.test.js","sources":["../../../src/-private/-type-tests/table-api.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { DataSorting } from '../../plugins/data-sorting';\n\nimport type { Table } from '[public-types]';\n\n// We're testing types, not behaviors\nconst x = 0 as unknown as Table<{ x: number }>;\n\n//////////////////////////////\n// <Table>#pluginOf\nexpectTypeOf(x.pluginOf(DataSorting)).toEqualTypeOf<DataSorting | undefined>();\nexpectTypeOf(x.pluginOf(ColumnReordering)).toEqualTypeOf<ColumnReordering | undefined>();\nexpectTypeOf(x.pluginOf(ColumnResizing)).toEqualTypeOf<ColumnResizing | undefined>();\n"],"names":["x","expectTypeOf","pluginOf","DataSorting","toEqualTypeOf","ColumnReordering","ColumnResizing"],"mappings":";;;;;;;;;AAQA;AACA,MAAMA,CAAC,GAAG,CAAoC,CAAA;;AAE9C;AACA;AACAC,YAAY,CAACD,CAAC,CAACE,QAAQ,CAACC,OAAW,CAAC,CAAC,CAACC,aAAa,EAA2B,CAAA;AAC9EH,YAAY,CAACD,CAAC,CAACE,QAAQ,CAACG,gBAAgB,CAAC,CAAC,CAACD,aAAa,EAAgC,CAAA;AACxFH,YAAY,CAACD,CAAC,CAACE,QAAQ,CAACI,cAAc,CAAC,CAAC,CAACF,aAAa,EAA8B"}
|
@@ -3,11 +3,11 @@ import { expectTypeOf } from 'expect-type';
|
|
3
3
|
import { BasePlugin } from '../../plugins/-private/base.js';
|
4
4
|
import { ColumnReordering } from '../../plugins/column-reordering/plugin.js';
|
5
5
|
import '../../plugins/column-resizing/handle.js';
|
6
|
+
import '@ember/template';
|
6
7
|
import { ColumnResizing } from '../../plugins/column-resizing/plugin.js';
|
7
8
|
import { ColumnVisibility } from '../../plugins/column-visibility/plugin.js';
|
8
9
|
import { Sorting } from '../../plugins/data-sorting/plugin.js';
|
9
10
|
import '../../plugins/data-sorting/types.js';
|
10
|
-
import '@ember/template';
|
11
11
|
import { StickyColumns } from '../../plugins/sticky-columns/plugin.js';
|
12
12
|
|
13
13
|
/////////////////////////////////////////////
|
@@ -9,7 +9,12 @@ interface CellContext<T> {
|
|
9
9
|
row: Row<T>;
|
10
10
|
}
|
11
11
|
type ColumnPluginOption<P = Plugin> = P extends BasePlugin ? [Constructor<P>, () => ColumnOptionsFor<SignatureFrom<P>>] : [P | Constructor<P>, () => unknown];
|
12
|
-
type CellOptions =
|
12
|
+
type CellOptions = {
|
13
|
+
/**
|
14
|
+
* when no value is present for a given set of data for the given column config
|
15
|
+
*/
|
16
|
+
defaultValue?: string;
|
17
|
+
} & Record<string, unknown>;
|
13
18
|
interface ColumnConfig<T = unknown> {
|
14
19
|
/**
|
15
20
|
* the `key` is required for preferences storage, as well as
|
@@ -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 };
|
@@ -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,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B0B,IAAAA,MAAM,CAAE,CAAmC,kCAAA,CAAA,EAAE,OAAOmD,OAAO,KAAK,QAAQ,CAAC,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,CACvB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pBC,EAAAA,MAAM,CAACzD,GAAG,CAACuD,MAAM,EAAEG,QAAQ,CAAC,CAAA;AAE5B,EAAA,OAAOA,QAAQ,CAAA;AACjB;;;;"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { htmlSafe } from '@ember/template';
|
1
2
|
import { Column } from "../../index";
|
2
3
|
/**
|
3
4
|
* The column actively being resized by the user.
|
@@ -22,4 +23,13 @@ declare const canShrink: (column: Column) => boolean | 0;
|
|
22
23
|
* - or if we're asking about the first column (resize handles may only be "between" columns)
|
23
24
|
*/
|
24
25
|
declare const hasResizeHandle: (column: Column) => boolean;
|
25
|
-
|
26
|
+
/**
|
27
|
+
* In this plugin (by default), styles are only applied to the headers automatically.
|
28
|
+
* in <Table> UIs, the header cells control the widths of all cells in that column.
|
29
|
+
* There are other kinds of tabular-like markup that may want to grab the widths of columns,
|
30
|
+
* because The Platform does not manage that automatically (like if divs and roles were used manually)
|
31
|
+
*
|
32
|
+
* This utility is meant to be applied to the `style` attribute of a particular td-like element.
|
33
|
+
*/
|
34
|
+
declare const styleStringFor: <DataType = unknown>(column: Column<DataType>) => ReturnType<typeof htmlSafe>;
|
35
|
+
export { isResizing, canShrink, hasResizeHandle, styleStringFor };
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { htmlSafe } from '@ember/template';
|
1
2
|
import { meta } from '../-private/base.js';
|
2
3
|
import { ColumnResizing } from './plugin.js';
|
3
4
|
|
@@ -27,5 +28,29 @@ const canShrink = column => meta.forColumn(column, ColumnResizing).canShrink;
|
|
27
28
|
*/
|
28
29
|
const hasResizeHandle = column => meta.forColumn(column, ColumnResizing).hasResizeHandle;
|
29
30
|
|
30
|
-
|
31
|
+
/**
|
32
|
+
* In this plugin (by default), styles are only applied to the headers automatically.
|
33
|
+
* in <Table> UIs, the header cells control the widths of all cells in that column.
|
34
|
+
* There are other kinds of tabular-like markup that may want to grab the widths of columns,
|
35
|
+
* because The Platform does not manage that automatically (like if divs and roles were used manually)
|
36
|
+
*
|
37
|
+
* This utility is meant to be applied to the `style` attribute of a particular td-like element.
|
38
|
+
*/
|
39
|
+
const styleStringFor = column => {
|
40
|
+
let columnMeta = meta.forColumn(column, ColumnResizing);
|
41
|
+
let result = '';
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Styles are applied regardless of the "table" being resizable or not
|
45
|
+
* because in non-<table> UIs, we need to ensure that all cells in a column
|
46
|
+
* have the same width
|
47
|
+
*/
|
48
|
+
for (let [key, value] of Object.entries(columnMeta.style)) {
|
49
|
+
result += `${key}:${value};`;
|
50
|
+
}
|
51
|
+
result = ';' + result;
|
52
|
+
return htmlSafe(result);
|
53
|
+
};
|
54
|
+
|
55
|
+
export { canShrink, hasResizeHandle, isResizing, styleStringFor };
|
31
56
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-resizing/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base';\nimport { ColumnResizing } from './plugin';\n\nimport type { Column } from '[public-types]';\n\n/**\n * The column actively being resized by the user.\n *\n * Note that during resizing, multiple columns are resized at once,\n * dependending on the boundaries of the resize events.\n *\n * The other columns being resized as a consequence of \"this\" column will not\n * be marked as isResizing, because this is a user-scoped question:\n * \"Is the user directly resizing this column?\"\n */\nexport const isResizing = (column: Column) => meta.forColumn(column, ColumnResizing).isResizing;\n\n/**\n * Does the column have room to shrink?\n */\nexport const canShrink = (column: Column) => meta.forColumn(column, ColumnResizing).canShrink;\n\n/**\n * Does the column have a resize handle?\n * The return value of this function can be determined by\n * - if resizing is enabled for the column\n * - if resizing is enabled for the whole table\n * - or if we're asking about the first column (resize handles may only be \"between\" columns)\n */\nexport const hasResizeHandle = (column: Column) =>\n meta.forColumn(column, ColumnResizing).hasResizeHandle;\n"],"names":["isResizing","column","meta","forColumn","ColumnResizing","canShrink","hasResizeHandle"],"mappings":"
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-resizing/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base';\nimport { ColumnResizing } from './plugin';\n\nimport type { Column } from '[public-types]';\n\n/**\n * The column actively being resized by the user.\n *\n * Note that during resizing, multiple columns are resized at once,\n * dependending on the boundaries of the resize events.\n *\n * The other columns being resized as a consequence of \"this\" column will not\n * be marked as isResizing, because this is a user-scoped question:\n * \"Is the user directly resizing this column?\"\n */\nexport const isResizing = (column: Column) => meta.forColumn(column, ColumnResizing).isResizing;\n\n/**\n * Does the column have room to shrink?\n */\nexport const canShrink = (column: Column) => meta.forColumn(column, ColumnResizing).canShrink;\n\n/**\n * Does the column have a resize handle?\n * The return value of this function can be determined by\n * - if resizing is enabled for the column\n * - if resizing is enabled for the whole table\n * - or if we're asking about the first column (resize handles may only be \"between\" columns)\n */\nexport const hasResizeHandle = (column: Column) =>\n meta.forColumn(column, ColumnResizing).hasResizeHandle;\n\n/**\n * In this plugin (by default), styles are only applied to the headers automatically.\n * in <Table> UIs, the header cells control the widths of all cells in that column.\n * There are other kinds of tabular-like markup that may want to grab the widths of columns,\n * because The Platform does not manage that automatically (like if divs and roles were used manually)\n *\n * This utility is meant to be applied to the `style` attribute of a particular td-like element.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>\n): ReturnType<typeof htmlSafe> => {\n let columnMeta = meta.forColumn(column, ColumnResizing);\n\n let result = '';\n\n /**\n * Styles are applied regardless of the \"table\" being resizable or not\n * because in non-<table> UIs, we need to ensure that all cells in a column\n * have the same width\n */\n for (let [key, value] of Object.entries(columnMeta.style)) {\n result += `${key}:${value};`;\n }\n\n result = ';' + result;\n\n return htmlSafe(result);\n};\n"],"names":["isResizing","column","meta","forColumn","ColumnResizing","canShrink","hasResizeHandle","styleStringFor","columnMeta","result","key","value","Object","entries","style","htmlSafe"],"mappings":";;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,MAAAA,UAAU,GAAIC,MAAc,IAAKC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAACJ,WAAU;;AAE/F;AACA;AACA;AACaK,MAAAA,SAAS,GAAIJ,MAAc,IAAKC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAACC,UAAS;;AAE7F;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,eAAe,GAAIL,MAAc,IAC5CC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAACE,gBAAe;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GACzBN,MAAwB,IACQ;EAChC,IAAIO,UAAU,GAAGN,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAAA;EAEvD,IAAIK,MAAM,GAAG,EAAE,CAAA;;AAEf;AACF;AACA;AACA;AACA;AACE,EAAA,KAAK,IAAI,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACM,KAAK,CAAC,EAAE;AACzDL,IAAAA,MAAM,IAAK,CAAA,EAAEC,GAAI,CAAA,CAAA,EAAGC,KAAM,CAAE,CAAA,CAAA,CAAA;AAC9B,GAAA;EAEAF,MAAM,GAAG,GAAG,GAAGA,MAAM,CAAA;EAErB,OAAOM,QAAQ,CAACN,MAAM,CAAC,CAAA;AACzB;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { resizeHandle } from './handle.js';
|
2
|
-
export { canShrink, hasResizeHandle, isResizing } from './helpers.js';
|
2
|
+
export { canShrink, hasResizeHandle, isResizing, styleStringFor } from './helpers.js';
|
3
3
|
export { ColumnResizing, ColumnResizing as Plugin } from './plugin.js';
|
4
4
|
//# sourceMappingURL=index.js.map
|
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
|
@@ -3,7 +3,7 @@ import { Column } from "../../index";
|
|
3
3
|
declare const isSticky: <DataType = unknown>(column: Column<DataType>) => boolean;
|
4
4
|
declare const styleFor: <DataType = unknown>(column: Column<DataType>) => Partial<CSSStyleDeclaration>;
|
5
5
|
/**
|
6
|
-
* In this plugin,
|
6
|
+
* In this plugin, both header and cells have the same styles,
|
7
7
|
* if applicable.
|
8
8
|
*
|
9
9
|
* Until this RFC https://github.com/emberjs/rfcs/pull/883
|
@@ -6,7 +6,7 @@ const isSticky = column => meta.forColumn(column, StickyColumns).isSticky;
|
|
6
6
|
const styleFor = column => meta.forColumn(column, StickyColumns).style;
|
7
7
|
|
8
8
|
/**
|
9
|
-
* In this plugin,
|
9
|
+
* In this plugin, both header and cells have the same styles,
|
10
10
|
* if applicable.
|
11
11
|
*
|
12
12
|
* Until this RFC https://github.com/emberjs/rfcs/pull/883
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base';\nimport { StickyColumns } from './plugin';\n\nimport type { Column } from '[public-types]';\n\nexport const isSticky = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, StickyColumns).isSticky;\n\nexport const styleFor = <DataType = unknown>(\n column: Column<DataType>\n): Partial<CSSStyleDeclaration> => meta.forColumn(column, StickyColumns).style;\n\n/**\n * In this plugin,
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base';\nimport { StickyColumns } from './plugin';\n\nimport type { Column } from '[public-types]';\n\nexport const isSticky = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, StickyColumns).isSticky;\n\nexport const styleFor = <DataType = unknown>(\n column: Column<DataType>\n): Partial<CSSStyleDeclaration> => meta.forColumn(column, StickyColumns).style;\n\n/**\n * In this plugin, both header and cells have the same styles,\n * if applicable.\n *\n * Until this RFC https://github.com/emberjs/rfcs/pull/883\n * is merged and implemented, we can't performantly\n * use modifiers for apply styles.\n *\n * In the mean time, we'll need to append style strings, which is more work\n * for consumers, but is a reasonable trade-off for now.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>\n): ReturnType<typeof htmlSafe> => {\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n let result = '';\n\n if (columnMeta.isSticky) {\n for (let [key, value] of Object.entries(columnMeta.style)) {\n result += `${toStyle(key)}:${value};`;\n }\n\n result = ';' + result;\n }\n\n return htmlSafe(result);\n};\n\n/**\n * the JS API for styles is camel case,\n * but CSS is kebab-case. To save on complexity and\n * amount of code, we have a super small conversion function\n * for only the properties relevant to the sticky plugin.\n */\nconst toStyle = (key: string): string => {\n switch (key) {\n case 'zIndex':\n return 'z-index';\n default:\n return key;\n }\n};\n"],"names":["isSticky","column","meta","forColumn","StickyColumns","styleFor","style","styleStringFor","columnMeta","result","key","value","Object","entries","toStyle","htmlSafe"],"mappings":";;;;AAOaA,MAAAA,QAAQ,GAAwBC,MAAwB,IACnEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACJ,SAAQ;AAEnCK,MAAAA,QAAQ,GACnBJ,MAAwB,IACSC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACE,MAAK;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GACzBN,MAAwB,IACQ;EAChC,IAAIO,UAAU,GAAGN,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAAA;EAEtD,IAAIK,MAAM,GAAG,EAAE,CAAA;EAEf,IAAID,UAAU,CAACR,QAAQ,EAAE;AACvB,IAAA,KAAK,IAAI,CAACU,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACF,KAAK,CAAC,EAAE;MACzDG,MAAM,IAAK,GAAEK,OAAO,CAACJ,GAAG,CAAE,CAAA,CAAA,EAAGC,KAAM,CAAE,CAAA,CAAA,CAAA;AACvC,KAAA;IAEAF,MAAM,GAAG,GAAG,GAAGA,MAAM,CAAA;AACvB,GAAA;EAEA,OAAOM,QAAQ,CAACN,MAAM,CAAC,CAAA;AACzB,EAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,OAAO,GAAIJ,GAAW,IAAa;AACvC,EAAA,QAAQA,GAAG;AACT,IAAA,KAAK,QAAQ;AACX,MAAA,OAAO,SAAS,CAAA;AAClB,IAAA;AACE,MAAA,OAAOA,GAAG,CAAA;AAAC,GAAA;AAEjB,CAAC;;;;"}
|
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":";;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAEaA,gBAAgB,GAAG,CAC9BC,UAAkB,EAClBC,OAAqB,GAAG;AAAEC,EAAAA,SAAS,EAAE,GAAG;AAAEC,EAAAA,SAAS,EAAE,UAAA;AAAW,CAAC,KACtD;EACX,IAAI,CAACH,UAAU,EAAE;AACf,IAAA,OAAO,EAAE,CAAA;AACX,GAAA;EAEA,IAAI;IAAEG,SAAS;AAAED,IAAAA,SAAAA;AAAU,GAAC,GAAGD,OAAO,CAAA;EACtC,IAAI,CAACG,GAAG,EAAEC,SAAS,CAAC,GAAGL,UAAU,CAACM,KAAK,CAACJ,SAAS,CAAC,CAAA;EAElDK,MAAM,CAAE,6BAA4BP,UAAW,CAAA,WAAA,EAAaE,SAAU,CAAkB,iBAAA,CAAA,EAAEE,GAAG,CAAC,CAAA;EAE9F,IAAID,SAAS,KAAK,UAAU,EAAE;AAC5BC,IAAAA,GAAG,GAAGI,QAAQ,CAACJ,GAAG,CAAC,CAAA;AACrB,GAAC,MAAM,IAAID,SAAS,KAAK,YAAY,EAAE;AACrCC,IAAAA,GAAG,GAAGK,UAAU,CAACL,GAAG,CAAC,CAAA;AACvB,GAAA;AAEA,EAAA,OAAO,CACL;AACEM,IAAAA,QAAQ,EAAEN,GAAG;IACbC,SAAS,EAAEA,SAAS,KAAK,KAAK,GAAGM,aAAa,CAACC,SAAS,GAAGD,aAAa,CAACE,UAAAA;AAC3E,GAAC,CACF,CAAA;AACH,EAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAc,CAC5BC,KAAa,EACbd,OAAqB,GAAG;AAAEC,EAAAA,SAAS,EAAE,GAAG;AAAEC,EAAAA,SAAS,EAAE,YAAA;AAAa,CAAC,EAC3D;EACR,MAAM;IAAEA,SAAS;AAAED,IAAAA,SAAAA;AAAU,GAAC,GAAGD,OAAO,CAAA;AAExC,EAAA,IAAIe,cAAc,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.1",
|
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",
|
@@ -104,7 +104,7 @@
|
|
104
104
|
"@glint/template": "^0.9.4",
|
105
105
|
"@nullvoxpopuli/eslint-configs": "~2.2.57",
|
106
106
|
"@rollup/plugin-babel": "^6.0.0",
|
107
|
-
"@tsconfig/ember": "^
|
107
|
+
"@tsconfig/ember": "^2.0.0",
|
108
108
|
"@types/ember__application": "^4.0.1",
|
109
109
|
"@types/ember__debug": "^4.0.1",
|
110
110
|
"@types/ember__destroyable": "^4.0.0",
|
@@ -125,7 +125,7 @@
|
|
125
125
|
"eslint-plugin-ember": "^11.0.6",
|
126
126
|
"eslint-plugin-node": "^11.1.0",
|
127
127
|
"eslint-plugin-prettier": "^4.0.0",
|
128
|
-
"expect-type": "^0.
|
128
|
+
"expect-type": "^0.15.0",
|
129
129
|
"prettier": "^2.5.1",
|
130
130
|
"rollup": "^3.2.2",
|
131
131
|
"rollup-plugin-copy": "^3.4.0",
|