ember-headless-table 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/dist/-private/-type-tests/plugin-properties.test.js +4 -8
- package/dist/-private/-type-tests/plugin-properties.test.js.map +1 -1
- package/dist/-private/-type-tests/plugin-with.test.js.map +1 -1
- package/dist/-private/-type-tests/plugins-accessors.test.js +12 -11
- package/dist/-private/-type-tests/plugins-accessors.test.js.map +1 -1
- package/dist/-private/-type-tests/plugins-signature-from.test.js +7 -6
- package/dist/-private/-type-tests/plugins-signature-from.test.js.map +1 -1
- package/dist/-private/-type-tests/plugins-signature-utils.test.js.map +1 -1
- package/dist/-private/-type-tests/table-api.test.js +3 -2
- package/dist/-private/-type-tests/table-api.test.js.map +1 -1
- package/dist/-private/-type-tests/table-config.test.js +9 -11
- package/dist/-private/-type-tests/table-config.test.js.map +1 -1
- package/dist/-private/column.d.ts +1 -1
- package/dist/-private/column.js +7 -15
- package/dist/-private/column.js.map +1 -1
- package/dist/-private/js-helper.d.ts +1 -1
- package/dist/-private/js-helper.js +2 -3
- package/dist/-private/js-helper.js.map +1 -1
- package/dist/-private/preferences.js +7 -39
- package/dist/-private/preferences.js.map +1 -1
- package/dist/-private/row.d.ts +1 -1
- package/dist/-private/row.js +4 -15
- package/dist/-private/row.js.map +1 -1
- package/dist/-private/table.js +4 -4
- package/dist/-private/utils.js +0 -2
- package/dist/-private/utils.js.map +1 -1
- package/dist/{applyDecoratedDescriptor-e0489e2f.js → applyDecoratedDescriptor-6b986a67.js} +1 -6
- package/dist/applyDecoratedDescriptor-6b986a67.js.map +1 -0
- package/dist/{classPrivateFieldGet-af59a8ea.js → classPrivateFieldGet-b4d7d334.js} +1 -3
- package/dist/{classPrivateFieldGet-af59a8ea.js.map → classPrivateFieldGet-b4d7d334.js.map} +1 -1
- package/dist/{defineProperty-a0196711.js → defineProperty-35ce617b.js} +1 -2
- package/dist/defineProperty-35ce617b.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/plugins/-private/base.d.ts +1 -1
- package/dist/plugins/-private/base.js +18 -59
- package/dist/plugins/-private/base.js.map +1 -1
- package/dist/plugins/-private/utils.js +5 -20
- package/dist/plugins/-private/utils.js.map +1 -1
- package/dist/plugins/column-reordering/helpers.d.ts +9 -4
- package/dist/plugins/column-reordering/helpers.js +13 -6
- package/dist/plugins/column-reordering/helpers.js.map +1 -1
- package/dist/plugins/column-reordering/index.js +1 -1
- package/dist/plugins/column-reordering/plugin.d.ts +57 -11
- package/dist/plugins/column-reordering/plugin.js +109 -130
- package/dist/plugins/column-reordering/plugin.js.map +1 -1
- package/dist/plugins/column-reordering/utils.js +0 -7
- package/dist/plugins/column-reordering/utils.js.map +1 -1
- package/dist/plugins/column-resizing/handle.js +4 -33
- package/dist/plugins/column-resizing/handle.js.map +1 -1
- package/dist/plugins/column-resizing/helpers.js +2 -2
- package/dist/plugins/column-resizing/helpers.js.map +1 -1
- package/dist/plugins/column-resizing/plugin.js +15 -64
- package/dist/plugins/column-resizing/plugin.js.map +1 -1
- package/dist/plugins/column-resizing/resize-observer.js +1 -3
- package/dist/plugins/column-resizing/resize-observer.js.map +1 -1
- package/dist/plugins/column-resizing/utils.js +0 -2
- package/dist/plugins/column-resizing/utils.js.map +1 -1
- package/dist/plugins/column-visibility/helpers.js +3 -3
- package/dist/plugins/column-visibility/helpers.js.map +1 -1
- package/dist/plugins/column-visibility/plugin.js +6 -26
- package/dist/plugins/column-visibility/plugin.js.map +1 -1
- package/dist/plugins/data-sorting/helpers.js +7 -7
- package/dist/plugins/data-sorting/helpers.js.map +1 -1
- package/dist/plugins/data-sorting/plugin.js +2 -32
- package/dist/plugins/data-sorting/plugin.js.map +1 -1
- package/dist/plugins/data-sorting/types.js +0 -3
- package/dist/plugins/data-sorting/types.js.map +1 -1
- package/dist/plugins/metadata/helpers.d.ts +4 -0
- package/dist/plugins/metadata/helpers.js +12 -0
- package/dist/plugins/metadata/helpers.js.map +1 -0
- package/dist/plugins/metadata/index.d.ts +3 -0
- package/dist/plugins/metadata/index.js +3 -0
- package/dist/plugins/metadata/index.js.map +1 -0
- package/dist/plugins/metadata/plugin.d.ts +24 -0
- package/dist/plugins/metadata/plugin.js +25 -0
- package/dist/plugins/metadata/plugin.js.map +1 -0
- package/dist/plugins/row-selection/helpers.js.map +1 -1
- package/dist/plugins/row-selection/plugin.js +5 -42
- package/dist/plugins/row-selection/plugin.js.map +1 -1
- package/dist/plugins/sticky-columns/helpers.d.ts +14 -1
- package/dist/plugins/sticky-columns/helpers.js +40 -1
- package/dist/plugins/sticky-columns/helpers.js.map +1 -1
- package/dist/plugins/sticky-columns/index.js +1 -1
- package/dist/plugins/sticky-columns/plugin.d.ts +17 -1
- package/dist/plugins/sticky-columns/plugin.js +41 -43
- package/dist/plugins/sticky-columns/plugin.js.map +1 -1
- package/dist/{table-8e46554b.d.ts → table-0cbd2720.d.ts} +9 -7
- package/dist/{table-8e46554b.js → table-0cbd2720.js} +34 -36
- package/dist/table-0cbd2720.js.map +1 -0
- package/dist/test-support/index.js +2 -6
- package/dist/test-support/index.js.map +1 -1
- package/dist/utils.js +2 -5
- package/dist/utils.js.map +1 -1
- package/package.json +20 -33
- package/dist/applyDecoratedDescriptor-e0489e2f.js.map +0 -1
- package/dist/defineProperty-a0196711.js.map +0 -1
- package/dist/table-8e46554b.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/plugins/-private/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport type { BasePlugin } from './base';\nimport type { Constructor } from '[private-types]';\nimport type { Plugin } from '[public-plugin-types]';\n\ntype PluginOption = Constructor<Plugin<any>> | [Constructor<Plugin<any>>, () => any];\n\ntype ExpandedPluginOption = [Constructor<Plugin<any>>, () => any];\n\nexport type Plugins = PluginOption[];\n\nexport function normalizePluginsConfig(plugins?: Plugins): ExpandedPluginOption[] {\n if (!plugins) return [];\n\n let result: ExpandedPluginOption[] = [];\n\n for (let plugin of plugins) {\n if (!Array.isArray(plugin)) {\n result.push([plugin, () => ({})]);\n\n continue;\n }\n\n if (plugin.length === 2) {\n result.push([plugin[0], plugin[1]]);\n\n continue;\n }\n\n result.push([plugin[0], () => ({})]);\n }\n\n assert(\n `Every entry in the plugins config must be invokable`,\n result.every((tuple) => typeof tuple[0] === 'function' && typeof tuple[1] === 'function')\n );\n\n return result;\n}\n\n/**\n * Creates a map of featureName => [plugins providing said feature name]\n */\nfunction collectFeatures(plugins: ExpandedPluginOption[]) {\n let result: Record<string, { name: string }[]> = {};\n\n for (let [plugin] of plugins) {\n if ('features' in plugin) {\n for (let feature of (plugin as unknown as typeof BasePlugin).features || []) {\n result[feature] = [...(result[feature] || []), plugin];\n }\n }\n }\n\n return result;\n}\n\n/**\n * Creates a map of requirement => [plugins requesting the feature / requirement]\n */\nfunction collectRequirements(plugins: ExpandedPluginOption[]) {\n let result: Record<string, { name: string }[]> = {};\n\n for (let [plugin] of plugins) {\n if ('requires' in plugin) {\n for (let requirement of (plugin as unknown as typeof BasePlugin).requires || []) {\n result[requirement] = [...(result[requirement] || []), plugin];\n }\n }\n }\n\n return result;\n}\n\nexport function verifyPlugins(plugins: ExpandedPluginOption[]) {\n let features = collectFeatures(plugins);\n let requirements = collectRequirements(plugins);\n let allFeatures = Object.keys(features);\n let errors: string[] = [];\n\n // Only one plugin can provide each feature\n for (let [feature, providingPlugins] of Object.entries(features)) {\n if (providingPlugins.length > 1) {\n errors.push(\n `More than one plugin is providing the feature: ${feature}. ` +\n `Please remove one of ${providingPlugins.map((p) => p.name).join(', ')}`\n );\n }\n }\n\n for (let [requirement, requestingPlugins] of Object.entries(requirements)) {\n if (!allFeatures.includes(requirement)) {\n errors.push(\n `Configuration is missing requirement: ${requirement}, ` +\n `And is requested by ${requestingPlugins.map((p) => p.name).join(', ')}. ` +\n `Please add a plugin with the ${requirement} feature`\n );\n }\n }\n\n if (errors.length > 0) {\n throw new Error(errors.join('\\n'));\n }\n}\n\ntype AssignableStyles = Omit<CSSStyleDeclaration, 'length' | 'parentRule'>;\n\n/**\n * @public\n *\n * Utility that helps safely apply styles to an element\n */\nexport function applyStyles(element: HTMLElement | SVGElement, styles: Partial<AssignableStyles>) {\n for (let [name, value] of Object.entries(styles)) {\n if (name in element.style) {\n assignStyle(\n element,\n name as keyof CSSStyleDeclaration,\n value as CSSStyleDeclaration[keyof CSSStyleDeclaration]\n );\n }\n }\n}\n\ntype StyleDeclarationFor<MaybeStyle> = MaybeStyle extends keyof CSSStyleDeclaration\n ? MaybeStyle\n : never;\n\nfunction assignStyle<StyleName>(\n element: HTMLElement | SVGElement,\n styleName: StyleDeclarationFor<StyleName>,\n value: CSSStyleDeclaration[StyleDeclarationFor<StyleName>]\n) {\n element.style[styleName] = value;\n}\n\nfunction removeStyle(element: HTMLElement | SVGElement, styleName: string) {\n element.style.removeProperty(styleName);\n}\n\n/**\n * @public\n *\n * Utility that helps safely remove styles from an element\n */\nexport function removeStyles(\n element: HTMLElement | SVGElement,\n styles: Array<keyof AssignableStyles>\n) {\n for (let name of styles) {\n if (typeof name !== 'string') continue;\n removeStyle(element, name);\n }\n}\n"],"names":["normalizePluginsConfig","plugins","result","plugin","Array","isArray","push","length","assert","every","tuple","collectFeatures","feature","features","collectRequirements","requirement","requires","verifyPlugins","requirements","allFeatures","Object","keys","errors","providingPlugins","entries","map","p","name","join","requestingPlugins","includes","Error","applyStyles","element","styles","value","style","assignStyle","styleName","removeStyle","removeProperty","removeStyles"],"mappings":";;AAYO,SAASA,
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/plugins/-private/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport type { BasePlugin } from './base';\nimport type { Constructor } from '[private-types]';\nimport type { Plugin } from '[public-plugin-types]';\n\ntype PluginOption = Constructor<Plugin<any>> | [Constructor<Plugin<any>>, () => any];\n\ntype ExpandedPluginOption = [Constructor<Plugin<any>>, () => any];\n\nexport type Plugins = PluginOption[];\n\nexport function normalizePluginsConfig(plugins?: Plugins): ExpandedPluginOption[] {\n if (!plugins) return [];\n\n let result: ExpandedPluginOption[] = [];\n\n for (let plugin of plugins) {\n if (!Array.isArray(plugin)) {\n result.push([plugin, () => ({})]);\n\n continue;\n }\n\n if (plugin.length === 2) {\n result.push([plugin[0], plugin[1]]);\n\n continue;\n }\n\n result.push([plugin[0], () => ({})]);\n }\n\n assert(\n `Every entry in the plugins config must be invokable`,\n result.every((tuple) => typeof tuple[0] === 'function' && typeof tuple[1] === 'function')\n );\n\n return result;\n}\n\n/**\n * Creates a map of featureName => [plugins providing said feature name]\n */\nfunction collectFeatures(plugins: ExpandedPluginOption[]) {\n let result: Record<string, { name: string }[]> = {};\n\n for (let [plugin] of plugins) {\n if ('features' in plugin) {\n for (let feature of (plugin as unknown as typeof BasePlugin).features || []) {\n result[feature] = [...(result[feature] || []), plugin];\n }\n }\n }\n\n return result;\n}\n\n/**\n * Creates a map of requirement => [plugins requesting the feature / requirement]\n */\nfunction collectRequirements(plugins: ExpandedPluginOption[]) {\n let result: Record<string, { name: string }[]> = {};\n\n for (let [plugin] of plugins) {\n if ('requires' in plugin) {\n for (let requirement of (plugin as unknown as typeof BasePlugin).requires || []) {\n result[requirement] = [...(result[requirement] || []), plugin];\n }\n }\n }\n\n return result;\n}\n\nexport function verifyPlugins(plugins: ExpandedPluginOption[]) {\n let features = collectFeatures(plugins);\n let requirements = collectRequirements(plugins);\n let allFeatures = Object.keys(features);\n let errors: string[] = [];\n\n // Only one plugin can provide each feature\n for (let [feature, providingPlugins] of Object.entries(features)) {\n if (providingPlugins.length > 1) {\n errors.push(\n `More than one plugin is providing the feature: ${feature}. ` +\n `Please remove one of ${providingPlugins.map((p) => p.name).join(', ')}`\n );\n }\n }\n\n for (let [requirement, requestingPlugins] of Object.entries(requirements)) {\n if (!allFeatures.includes(requirement)) {\n errors.push(\n `Configuration is missing requirement: ${requirement}, ` +\n `And is requested by ${requestingPlugins.map((p) => p.name).join(', ')}. ` +\n `Please add a plugin with the ${requirement} feature`\n );\n }\n }\n\n if (errors.length > 0) {\n throw new Error(errors.join('\\n'));\n }\n}\n\ntype AssignableStyles = Omit<CSSStyleDeclaration, 'length' | 'parentRule'>;\n\n/**\n * @public\n *\n * Utility that helps safely apply styles to an element\n */\nexport function applyStyles(element: HTMLElement | SVGElement, styles: Partial<AssignableStyles>) {\n for (let [name, value] of Object.entries(styles)) {\n if (name in element.style) {\n assignStyle(\n element,\n name as keyof CSSStyleDeclaration,\n value as CSSStyleDeclaration[keyof CSSStyleDeclaration]\n );\n }\n }\n}\n\ntype StyleDeclarationFor<MaybeStyle> = MaybeStyle extends keyof CSSStyleDeclaration\n ? MaybeStyle\n : never;\n\nfunction assignStyle<StyleName>(\n element: HTMLElement | SVGElement,\n styleName: StyleDeclarationFor<StyleName>,\n value: CSSStyleDeclaration[StyleDeclarationFor<StyleName>]\n) {\n element.style[styleName] = value;\n}\n\nfunction removeStyle(element: HTMLElement | SVGElement, styleName: string) {\n element.style.removeProperty(styleName);\n}\n\n/**\n * @public\n *\n * Utility that helps safely remove styles from an element\n */\nexport function removeStyles(\n element: HTMLElement | SVGElement,\n styles: Array<keyof AssignableStyles>\n) {\n for (let name of styles) {\n if (typeof name !== 'string') continue;\n removeStyle(element, name);\n }\n}\n"],"names":["normalizePluginsConfig","plugins","result","plugin","Array","isArray","push","length","assert","every","tuple","collectFeatures","feature","features","collectRequirements","requirement","requires","verifyPlugins","requirements","allFeatures","Object","keys","errors","providingPlugins","entries","map","p","name","join","requestingPlugins","includes","Error","applyStyles","element","styles","value","style","assignStyle","styleName","removeStyle","removeProperty","removeStyles"],"mappings":";;AAYO,SAASA,sBAAsB,CAACC,OAAiB,EAA0B;AAChF,EAAA,IAAI,CAACA,OAAO,EAAE,OAAO,EAAE,CAAA;EAEvB,IAAIC,MAA8B,GAAG,EAAE,CAAA;AAEvC,EAAA,KAAK,IAAIC,MAAM,IAAIF,OAAO,EAAE;AAC1B,IAAA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,OAAiC,EACjCC,MAAqC,EACrC;AACA,EAAA,KAAK,IAAIP,IAAI,IAAIO,MAAM,EAAE;AACvB,IAAA,IAAI,OAAOP,IAAI,KAAK,QAAQ,EAAE,SAAA;AAC9BY,IAAAA,WAAW,CAACN,OAAO,EAAEN,IAAI,CAAC,CAAA;AAC5B,GAAA;AACF;;;;"}
|
@@ -1,14 +1,19 @@
|
|
1
|
-
import {
|
1
|
+
import { ColumnOrder } from "./plugin";
|
2
|
+
import { Column, Table } from "../../index";
|
2
3
|
/**
|
3
4
|
* Move the column one position to the left.
|
4
5
|
* If the column is first, nothing will happen.
|
5
6
|
*/
|
6
|
-
declare const moveLeft: (column: Column) =>
|
7
|
+
declare const moveLeft: (column: Column) => void;
|
7
8
|
/**
|
8
9
|
* Move the column one position to the right.
|
9
10
|
* If the column is last, nothing will happen.
|
10
11
|
*/
|
11
|
-
declare const moveRight: (column: Column) =>
|
12
|
+
declare const moveRight: (column: Column) => void;
|
13
|
+
/**
|
14
|
+
* Override all column positions at once.
|
15
|
+
*/
|
16
|
+
declare const setColumnOrder: (table: Table, order: ColumnOrder) => void;
|
12
17
|
/**
|
13
18
|
* Ask if the column cannot move to the left
|
14
19
|
*/
|
@@ -25,4 +30,4 @@ declare const canMoveLeft: (column: Column) => boolean;
|
|
25
30
|
* Ask if the column can move to the right
|
26
31
|
*/
|
27
32
|
declare const canMoveRight: (column: Column) => boolean;
|
28
|
-
export { moveLeft, moveRight, cannotMoveLeft, cannotMoveRight, canMoveLeft, canMoveRight };
|
33
|
+
export { moveLeft, moveRight, setColumnOrder, cannotMoveLeft, cannotMoveRight, canMoveLeft, canMoveRight };
|
@@ -6,32 +6,39 @@ import { ColumnReordering } from './plugin.js';
|
|
6
6
|
* If the column is first, nothing will happen.
|
7
7
|
*/
|
8
8
|
const moveLeft = column => meta.forColumn(column, ColumnReordering).moveLeft();
|
9
|
+
|
9
10
|
/**
|
10
11
|
* Move the column one position to the right.
|
11
12
|
* If the column is last, nothing will happen.
|
12
13
|
*/
|
13
|
-
|
14
14
|
const moveRight = column => meta.forColumn(column, ColumnReordering).moveRight();
|
15
|
+
|
15
16
|
/**
|
16
|
-
*
|
17
|
+
* Override all column positions at once.
|
17
18
|
*/
|
19
|
+
const setColumnOrder = (table, order) => {
|
20
|
+
return meta.forTable(table, ColumnReordering).setOrder(order);
|
21
|
+
};
|
18
22
|
|
23
|
+
/**
|
24
|
+
* Ask if the column cannot move to the left
|
25
|
+
*/
|
19
26
|
const cannotMoveLeft = column => meta.forColumn(column, ColumnReordering).cannotMoveLeft;
|
27
|
+
|
20
28
|
/**
|
21
29
|
* Ask if the column cannot move to the right
|
22
30
|
*/
|
23
|
-
|
24
31
|
const cannotMoveRight = column => meta.forColumn(column, ColumnReordering).cannotMoveRight;
|
32
|
+
|
25
33
|
/**
|
26
34
|
* Ask if the column can move to the left
|
27
35
|
*/
|
28
|
-
|
29
36
|
const canMoveLeft = column => meta.forColumn(column, ColumnReordering).cannotMoveLeft;
|
37
|
+
|
30
38
|
/**
|
31
39
|
* Ask if the column can move to the right
|
32
40
|
*/
|
33
|
-
|
34
41
|
const canMoveRight = column => meta.forColumn(column, ColumnReordering).cannotMoveRight;
|
35
42
|
|
36
|
-
export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight };
|
43
|
+
export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight, setColumnOrder };
|
37
44
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-reordering/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base';\nimport { ColumnReordering } from './plugin';\n\nimport type { Column } from '[public-types]';\n\n/**\n * Move the column one position to the left.\n * If the column is first, nothing will happen.\n */\nexport const moveLeft = (column: Column) => meta.forColumn(column, ColumnReordering).moveLeft();\n\n/**\n * Move the column one position to the right.\n * If the column is last, nothing will happen.\n */\nexport const moveRight = (column: Column) => meta.forColumn(column, ColumnReordering).moveRight();\n\n/**\n * Ask if the column cannot move to the left\n */\nexport const cannotMoveLeft = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column cannot move to the right\n */\nexport const cannotMoveRight = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveRight;\n\n/**\n * Ask if the column can move to the left\n */\nexport const canMoveLeft = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column can move to the right\n */\nexport const canMoveRight = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveRight;\n"],"names":["moveLeft","column","meta","forColumn","ColumnReordering","moveRight","cannotMoveLeft","cannotMoveRight","canMoveLeft","canMoveRight"],"mappings":";;;
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-reordering/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base';\nimport { ColumnReordering } from './plugin';\n\nimport type { ColumnOrder } from './plugin';\nimport type { Column, Table } from '[public-types]';\n\n/**\n * Move the column one position to the left.\n * If the column is first, nothing will happen.\n */\nexport const moveLeft = (column: Column) => meta.forColumn(column, ColumnReordering).moveLeft();\n\n/**\n * Move the column one position to the right.\n * If the column is last, nothing will happen.\n */\nexport const moveRight = (column: Column) => meta.forColumn(column, ColumnReordering).moveRight();\n\n/**\n * Override all column positions at once.\n */\nexport const setColumnOrder = (table: Table, order: ColumnOrder) => {\n return meta.forTable(table, ColumnReordering).setOrder(order);\n};\n\n/**\n * Ask if the column cannot move to the left\n */\nexport const cannotMoveLeft = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column cannot move to the right\n */\nexport const cannotMoveRight = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveRight;\n\n/**\n * Ask if the column can move to the left\n */\nexport const canMoveLeft = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column can move to the right\n */\nexport const canMoveRight = (column: Column) =>\n meta.forColumn(column, ColumnReordering).cannotMoveRight;\n"],"names":["moveLeft","column","meta","forColumn","ColumnReordering","moveRight","setColumnOrder","table","order","forTable","setOrder","cannotMoveLeft","cannotMoveRight","canMoveLeft","canMoveRight"],"mappings":";;;AAMA;AACA;AACA;AACA;AACaA,MAAAA,QAAQ,GAAIC,MAAc,IAAKC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACJ,QAAQ,GAAE;;AAE/F;AACA;AACA;AACA;AACaK,MAAAA,SAAS,GAAIJ,MAAc,IAAKC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACC,SAAS,GAAE;;AAEjG;AACA;AACA;MACaC,cAAc,GAAG,CAACC,KAAY,EAAEC,KAAkB,KAAK;AAClE,EAAA,OAAON,IAAI,CAACO,QAAQ,CAACF,KAAK,EAAEH,gBAAgB,CAAC,CAACM,QAAQ,CAACF,KAAK,CAAC,CAAA;AAC/D,EAAC;;AAED;AACA;AACA;AACaG,MAAAA,cAAc,GAAIV,MAAc,IAC3CC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACO,eAAc;;AAEzD;AACA;AACA;AACaC,MAAAA,eAAe,GAAIX,MAAc,IAC5CC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACQ,gBAAe;;AAE1D;AACA;AACA;AACaC,MAAAA,WAAW,GAAIZ,MAAc,IACxCC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACO,eAAc;;AAEzD;AACA;AACA;AACaG,MAAAA,YAAY,GAAIb,MAAc,IACzCC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACQ;;;;"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight } from './helpers.js';
|
1
|
+
export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight, setColumnOrder } from './helpers.js';
|
2
2
|
export { ColumnOrder, ColumnReordering, ColumnReordering as Plugin, orderOf } from './plugin.js';
|
3
3
|
//# sourceMappingURL=index.js.map
|
@@ -41,11 +41,11 @@ declare class ColumnMeta {
|
|
41
41
|
/**
|
42
42
|
* Move the column one spot to the left
|
43
43
|
*/
|
44
|
-
moveLeft: () =>
|
44
|
+
moveLeft: () => void;
|
45
45
|
/**
|
46
46
|
* Move the column one spot to the right
|
47
47
|
*/
|
48
|
-
moveRight: () =>
|
48
|
+
moveRight: () => void;
|
49
49
|
}
|
50
50
|
declare class TableMeta {
|
51
51
|
private table;
|
@@ -59,8 +59,24 @@ declare class TableMeta {
|
|
59
59
|
* This is also why the order of the columns is maintained via column key
|
60
60
|
*/
|
61
61
|
columnOrder: ColumnOrder;
|
62
|
+
/**
|
63
|
+
* Get the curret order/position of a column
|
64
|
+
*/
|
65
|
+
/**
|
66
|
+
* Get the curret order/position of a column
|
67
|
+
*/
|
62
68
|
getPosition(column: Column): number;
|
69
|
+
/**
|
70
|
+
* Swap the column with the column at `newPosition`
|
71
|
+
*/
|
72
|
+
/**
|
73
|
+
* Swap the column with the column at `newPosition`
|
74
|
+
*/
|
63
75
|
setPosition(column: Column, newPosition: number): false | undefined;
|
76
|
+
/**
|
77
|
+
* Using a `ColumnOrder` instance, set the order of all columns
|
78
|
+
*/
|
79
|
+
setOrder: (order: ColumnOrder) => void;
|
64
80
|
/**
|
65
81
|
* Revert to default config, delete preferences,
|
66
82
|
* and clear the columnOrder
|
@@ -103,22 +119,52 @@ declare class ColumnOrder {
|
|
103
119
|
map: TrackedMap<string, number>;
|
104
120
|
constructor(args: {
|
105
121
|
columns: () => Column[];
|
106
|
-
save
|
122
|
+
save?: (order: Map<string, number>) => void;
|
107
123
|
existingOrder?: Map<string, number>;
|
108
124
|
});
|
109
|
-
|
125
|
+
/**
|
126
|
+
* To account for columnVisibilty, we need to:
|
127
|
+
* - get the list of visible columns
|
128
|
+
* - get the column order (which preserves the order of hidden columns)
|
129
|
+
* - skip over non-visible columns when determining the previous "index"
|
130
|
+
* - set the position to whatever that is.
|
131
|
+
*/
|
132
|
+
/**
|
133
|
+
* To account for columnVisibilty, we need to:
|
134
|
+
* - get the list of visible columns
|
135
|
+
* - get the column order (which preserves the order of hidden columns)
|
136
|
+
* - skip over non-visible columns when determining the previous "index"
|
137
|
+
* - set the position to whatever that is.
|
138
|
+
*/
|
139
|
+
moveLeft(key: string): void;
|
140
|
+
setAll: (map: Map<string, number>) => void;
|
141
|
+
/**
|
142
|
+
* To account for columnVisibilty, we need to:
|
143
|
+
* - get the list of visible columns
|
144
|
+
* - get the column order (which preserves the order of hidden columns)
|
145
|
+
* - skip over non-visible columns when determining the next "index"
|
146
|
+
* - set the position to whatever that is.
|
147
|
+
*/
|
148
|
+
/**
|
149
|
+
* To account for columnVisibilty, we need to:
|
150
|
+
* - get the list of visible columns
|
151
|
+
* - get the column order (which preserves the order of hidden columns)
|
152
|
+
* - skip over non-visible columns when determining the next "index"
|
153
|
+
* - set the position to whatever that is.
|
154
|
+
*/
|
155
|
+
moveRight(key: string): void;
|
156
|
+
/**
|
157
|
+
* Performs a swap of the column's position with the column at position
|
158
|
+
*/
|
159
|
+
/**
|
160
|
+
* Performs a swap of the column's position with the column at position
|
161
|
+
*/
|
162
|
+
swapWith(key: string, position: number): false | undefined;
|
110
163
|
get(key: string): number;
|
111
164
|
/**
|
112
165
|
* The same as this.map, but with all the columns' information
|
113
166
|
*/
|
114
167
|
get orderedMap(): ReadonlyMap<string, number>;
|
115
|
-
/**
|
116
|
-
* When columns are removed or hidden, our positions don't change
|
117
|
-
* but when doing the math, we want to adjust things based on 0-indexed counting
|
118
|
-
*
|
119
|
-
* TODO: figure out if we need this??
|
120
|
-
*/
|
121
|
-
get adjustedColumns(): Column[];
|
122
168
|
get orderedColumns(): Column[];
|
123
169
|
}
|
124
170
|
/**
|