@universal-ember/table 3.6.0 → 3.6.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.
Files changed (224) hide show
  1. package/package.json +1 -1
  2. package/src/plugins/column-reordering/plugin.ts +4 -6
  3. package/declarations/-private/-type-tests/plugin-properties.test.d.ts +0 -2
  4. package/declarations/-private/-type-tests/plugin-properties.test.d.ts.map +0 -1
  5. package/declarations/-private/-type-tests/plugin-with.test.d.ts +0 -2
  6. package/declarations/-private/-type-tests/plugin-with.test.d.ts.map +0 -1
  7. package/declarations/-private/-type-tests/plugins-accessors.test.d.ts +0 -2
  8. package/declarations/-private/-type-tests/plugins-accessors.test.d.ts.map +0 -1
  9. package/declarations/-private/-type-tests/plugins-signature-from.test.d.ts +0 -2
  10. package/declarations/-private/-type-tests/plugins-signature-from.test.d.ts.map +0 -1
  11. package/declarations/-private/-type-tests/plugins-signature-utils.test.d.ts +0 -2
  12. package/declarations/-private/-type-tests/plugins-signature-utils.test.d.ts.map +0 -1
  13. package/declarations/-private/-type-tests/table-api.test.d.ts +0 -2
  14. package/declarations/-private/-type-tests/table-api.test.d.ts.map +0 -1
  15. package/declarations/-private/-type-tests/table-config.test.d.ts +0 -2
  16. package/declarations/-private/-type-tests/table-config.test.d.ts.map +0 -1
  17. package/declarations/-private/column.d.ts +0 -18
  18. package/declarations/-private/column.d.ts.map +0 -1
  19. package/declarations/-private/ember-compat.d.ts +0 -8
  20. package/declarations/-private/ember-compat.d.ts.map +0 -1
  21. package/declarations/-private/interfaces/column.d.ts +0 -63
  22. package/declarations/-private/interfaces/column.d.ts.map +0 -1
  23. package/declarations/-private/interfaces/index.d.ts +0 -8
  24. package/declarations/-private/interfaces/index.d.ts.map +0 -1
  25. package/declarations/-private/interfaces/modifier.d.ts +0 -7
  26. package/declarations/-private/interfaces/modifier.d.ts.map +0 -1
  27. package/declarations/-private/interfaces/pagination.d.ts +0 -17
  28. package/declarations/-private/interfaces/pagination.d.ts.map +0 -1
  29. package/declarations/-private/interfaces/plugins.d.ts +0 -315
  30. package/declarations/-private/interfaces/plugins.d.ts.map +0 -1
  31. package/declarations/-private/interfaces/preferences.d.ts +0 -74
  32. package/declarations/-private/interfaces/preferences.d.ts.map +0 -1
  33. package/declarations/-private/interfaces/selection.d.ts +0 -36
  34. package/declarations/-private/interfaces/selection.d.ts.map +0 -1
  35. package/declarations/-private/interfaces/table.d.ts +0 -127
  36. package/declarations/-private/interfaces/table.d.ts.map +0 -1
  37. package/declarations/-private/js-helper.d.ts +0 -39
  38. package/declarations/-private/js-helper.d.ts.map +0 -1
  39. package/declarations/-private/preferences.d.ts +0 -47
  40. package/declarations/-private/preferences.d.ts.map +0 -1
  41. package/declarations/-private/private-types.d.ts +0 -6
  42. package/declarations/-private/private-types.d.ts.map +0 -1
  43. package/declarations/-private/row.d.ts +0 -12
  44. package/declarations/-private/row.d.ts.map +0 -1
  45. package/declarations/-private/table.d.ts +0 -136
  46. package/declarations/-private/table.d.ts.map +0 -1
  47. package/declarations/-private/utils.d.ts +0 -3
  48. package/declarations/-private/utils.d.ts.map +0 -1
  49. package/declarations/index.d.ts +0 -14
  50. package/declarations/index.d.ts.map +0 -1
  51. package/declarations/plugins/-private/base.d.ts +0 -281
  52. package/declarations/plugins/-private/base.d.ts.map +0 -1
  53. package/declarations/plugins/-private/utils.d.ts +0 -22
  54. package/declarations/plugins/-private/utils.d.ts.map +0 -1
  55. package/declarations/plugins/column-reordering/helpers.d.ts +0 -54
  56. package/declarations/plugins/column-reordering/helpers.d.ts.map +0 -1
  57. package/declarations/plugins/column-reordering/index.d.ts +0 -5
  58. package/declarations/plugins/column-reordering/index.d.ts.map +0 -1
  59. package/declarations/plugins/column-reordering/plugin.d.ts +0 -196
  60. package/declarations/plugins/column-reordering/plugin.d.ts.map +0 -1
  61. package/declarations/plugins/column-reordering/utils.d.ts +0 -8
  62. package/declarations/plugins/column-reordering/utils.d.ts.map +0 -1
  63. package/declarations/plugins/column-resizing/handle.d.ts +0 -128
  64. package/declarations/plugins/column-resizing/handle.d.ts.map +0 -1
  65. package/declarations/plugins/column-resizing/helpers.d.ts +0 -40
  66. package/declarations/plugins/column-resizing/helpers.d.ts.map +0 -1
  67. package/declarations/plugins/column-resizing/index.d.ts +0 -6
  68. package/declarations/plugins/column-resizing/index.d.ts.map +0 -1
  69. package/declarations/plugins/column-resizing/plugin.d.ts +0 -172
  70. package/declarations/plugins/column-resizing/plugin.d.ts.map +0 -1
  71. package/declarations/plugins/column-resizing/resize-observer.d.ts +0 -14
  72. package/declarations/plugins/column-resizing/resize-observer.d.ts.map +0 -1
  73. package/declarations/plugins/column-resizing/utils.d.ts +0 -22
  74. package/declarations/plugins/column-resizing/utils.d.ts.map +0 -1
  75. package/declarations/plugins/column-visibility/helpers.d.ts +0 -18
  76. package/declarations/plugins/column-visibility/helpers.d.ts.map +0 -1
  77. package/declarations/plugins/column-visibility/index.d.ts +0 -5
  78. package/declarations/plugins/column-visibility/index.d.ts.map +0 -1
  79. package/declarations/plugins/column-visibility/plugin.d.ts +0 -64
  80. package/declarations/plugins/column-visibility/plugin.d.ts.map +0 -1
  81. package/declarations/plugins/data-sorting/helpers.d.ts +0 -38
  82. package/declarations/plugins/data-sorting/helpers.d.ts.map +0 -1
  83. package/declarations/plugins/data-sorting/index.d.ts +0 -7
  84. package/declarations/plugins/data-sorting/index.d.ts.map +0 -1
  85. package/declarations/plugins/data-sorting/plugin.d.ts +0 -102
  86. package/declarations/plugins/data-sorting/plugin.d.ts.map +0 -1
  87. package/declarations/plugins/data-sorting/types.d.ts +0 -23
  88. package/declarations/plugins/data-sorting/types.d.ts.map +0 -1
  89. package/declarations/plugins/index.d.ts +0 -6
  90. package/declarations/plugins/index.d.ts.map +0 -1
  91. package/declarations/plugins/metadata/helpers.d.ts +0 -4
  92. package/declarations/plugins/metadata/helpers.d.ts.map +0 -1
  93. package/declarations/plugins/metadata/index.d.ts +0 -5
  94. package/declarations/plugins/metadata/index.d.ts.map +0 -1
  95. package/declarations/plugins/metadata/plugin.d.ts +0 -25
  96. package/declarations/plugins/metadata/plugin.d.ts.map +0 -1
  97. package/declarations/plugins/row-selection/helpers.d.ts +0 -6
  98. package/declarations/plugins/row-selection/helpers.d.ts.map +0 -1
  99. package/declarations/plugins/row-selection/index.d.ts +0 -5
  100. package/declarations/plugins/row-selection/index.d.ts.map +0 -1
  101. package/declarations/plugins/row-selection/plugin.d.ts +0 -80
  102. package/declarations/plugins/row-selection/plugin.d.ts.map +0 -1
  103. package/declarations/plugins/sticky-columns/helpers.d.ts +0 -17
  104. package/declarations/plugins/sticky-columns/helpers.d.ts.map +0 -1
  105. package/declarations/plugins/sticky-columns/index.d.ts +0 -5
  106. package/declarations/plugins/sticky-columns/index.d.ts.map +0 -1
  107. package/declarations/plugins/sticky-columns/plugin.d.ts +0 -70
  108. package/declarations/plugins/sticky-columns/plugin.d.ts.map +0 -1
  109. package/declarations/test-support/index.d.ts +0 -15
  110. package/declarations/test-support/index.d.ts.map +0 -1
  111. package/declarations/utils.d.ts +0 -26
  112. package/declarations/utils.d.ts.map +0 -1
  113. package/dist/-private/-type-tests/plugin-properties.test.js +0 -27
  114. package/dist/-private/-type-tests/plugin-properties.test.js.map +0 -1
  115. package/dist/-private/-type-tests/plugin-with.test.js +0 -20
  116. package/dist/-private/-type-tests/plugin-with.test.js.map +0 -1
  117. package/dist/-private/-type-tests/plugins-accessors.test.js +0 -36
  118. package/dist/-private/-type-tests/plugins-accessors.test.js.map +0 -1
  119. package/dist/-private/-type-tests/plugins-signature-from.test.js +0 -15
  120. package/dist/-private/-type-tests/plugins-signature-from.test.js.map +0 -1
  121. package/dist/-private/-type-tests/plugins-signature-utils.test.js +0 -36
  122. package/dist/-private/-type-tests/plugins-signature-utils.test.js.map +0 -1
  123. package/dist/-private/-type-tests/table-api.test.js +0 -17
  124. package/dist/-private/-type-tests/table-api.test.js.map +0 -1
  125. package/dist/-private/-type-tests/table-config.test.js +0 -55
  126. package/dist/-private/-type-tests/table-config.test.js.map +0 -1
  127. package/dist/-private/column.js +0 -62
  128. package/dist/-private/column.js.map +0 -1
  129. package/dist/-private/ember-compat.js +0 -17
  130. package/dist/-private/ember-compat.js.map +0 -1
  131. package/dist/-private/interfaces/column.js +0 -2
  132. package/dist/-private/interfaces/column.js.map +0 -1
  133. package/dist/-private/interfaces/index.js +0 -2
  134. package/dist/-private/interfaces/index.js.map +0 -1
  135. package/dist/-private/interfaces/modifier.js +0 -2
  136. package/dist/-private/interfaces/modifier.js.map +0 -1
  137. package/dist/-private/interfaces/pagination.js +0 -2
  138. package/dist/-private/interfaces/pagination.js.map +0 -1
  139. package/dist/-private/interfaces/plugins.js +0 -2
  140. package/dist/-private/interfaces/plugins.js.map +0 -1
  141. package/dist/-private/interfaces/preferences.js +0 -2
  142. package/dist/-private/interfaces/preferences.js.map +0 -1
  143. package/dist/-private/interfaces/selection.js +0 -2
  144. package/dist/-private/interfaces/selection.js.map +0 -1
  145. package/dist/-private/interfaces/table.js +0 -2
  146. package/dist/-private/interfaces/table.js.map +0 -1
  147. package/dist/-private/js-helper.js +0 -55
  148. package/dist/-private/js-helper.js.map +0 -1
  149. package/dist/-private/preferences.js +0 -149
  150. package/dist/-private/preferences.js.map +0 -1
  151. package/dist/-private/private-types.js +0 -2
  152. package/dist/-private/private-types.js.map +0 -1
  153. package/dist/-private/row.js +0 -51
  154. package/dist/-private/row.js.map +0 -1
  155. package/dist/-private/table.js +0 -276
  156. package/dist/-private/table.js.map +0 -1
  157. package/dist/-private/utils.js +0 -15
  158. package/dist/-private/utils.js.map +0 -1
  159. package/dist/_rollupPluginBabelHelpers-CjaRjJZX.js +0 -63
  160. package/dist/_rollupPluginBabelHelpers-CjaRjJZX.js.map +0 -1
  161. package/dist/index.js +0 -4
  162. package/dist/index.js.map +0 -1
  163. package/dist/plugins/-private/base.js +0 -532
  164. package/dist/plugins/-private/base.js.map +0 -1
  165. package/dist/plugins/-private/utils.js +0 -103
  166. package/dist/plugins/-private/utils.js.map +0 -1
  167. package/dist/plugins/column-reordering/helpers.js +0 -81
  168. package/dist/plugins/column-reordering/helpers.js.map +0 -1
  169. package/dist/plugins/column-reordering/index.js +0 -3
  170. package/dist/plugins/column-reordering/index.js.map +0 -1
  171. package/dist/plugins/column-reordering/plugin.js +0 -453
  172. package/dist/plugins/column-reordering/plugin.js.map +0 -1
  173. package/dist/plugins/column-reordering/utils.js +0 -34
  174. package/dist/plugins/column-reordering/utils.js.map +0 -1
  175. package/dist/plugins/column-resizing/handle.js +0 -243
  176. package/dist/plugins/column-resizing/handle.js.map +0 -1
  177. package/dist/plugins/column-resizing/helpers.js +0 -77
  178. package/dist/plugins/column-resizing/helpers.js.map +0 -1
  179. package/dist/plugins/column-resizing/index.js +0 -4
  180. package/dist/plugins/column-resizing/index.js.map +0 -1
  181. package/dist/plugins/column-resizing/plugin.js +0 -365
  182. package/dist/plugins/column-resizing/plugin.js.map +0 -1
  183. package/dist/plugins/column-resizing/resize-observer.js +0 -44
  184. package/dist/plugins/column-resizing/resize-observer.js.map +0 -1
  185. package/dist/plugins/column-resizing/utils.js +0 -44
  186. package/dist/plugins/column-resizing/utils.js.map +0 -1
  187. package/dist/plugins/column-visibility/helpers.js +0 -25
  188. package/dist/plugins/column-visibility/helpers.js.map +0 -1
  189. package/dist/plugins/column-visibility/index.js +0 -3
  190. package/dist/plugins/column-visibility/index.js.map +0 -1
  191. package/dist/plugins/column-visibility/plugin.js +0 -92
  192. package/dist/plugins/column-visibility/plugin.js.map +0 -1
  193. package/dist/plugins/data-sorting/helpers.js +0 -49
  194. package/dist/plugins/data-sorting/helpers.js.map +0 -1
  195. package/dist/plugins/data-sorting/index.js +0 -4
  196. package/dist/plugins/data-sorting/index.js.map +0 -1
  197. package/dist/plugins/data-sorting/plugin.js +0 -132
  198. package/dist/plugins/data-sorting/plugin.js.map +0 -1
  199. package/dist/plugins/data-sorting/types.js +0 -14
  200. package/dist/plugins/data-sorting/types.js.map +0 -1
  201. package/dist/plugins/index.js +0 -3
  202. package/dist/plugins/index.js.map +0 -1
  203. package/dist/plugins/metadata/helpers.js +0 -12
  204. package/dist/plugins/metadata/helpers.js.map +0 -1
  205. package/dist/plugins/metadata/index.js +0 -3
  206. package/dist/plugins/metadata/index.js.map +0 -1
  207. package/dist/plugins/metadata/plugin.js +0 -25
  208. package/dist/plugins/metadata/plugin.js.map +0 -1
  209. package/dist/plugins/row-selection/helpers.js +0 -10
  210. package/dist/plugins/row-selection/helpers.js.map +0 -1
  211. package/dist/plugins/row-selection/index.js +0 -3
  212. package/dist/plugins/row-selection/index.js.map +0 -1
  213. package/dist/plugins/row-selection/plugin.js +0 -118
  214. package/dist/plugins/row-selection/plugin.js.map +0 -1
  215. package/dist/plugins/sticky-columns/helpers.js +0 -49
  216. package/dist/plugins/sticky-columns/helpers.js.map +0 -1
  217. package/dist/plugins/sticky-columns/index.js +0 -3
  218. package/dist/plugins/sticky-columns/index.js.map +0 -1
  219. package/dist/plugins/sticky-columns/plugin.js +0 -139
  220. package/dist/plugins/sticky-columns/plugin.js.map +0 -1
  221. package/dist/test-support/index.js +0 -62
  222. package/dist/test-support/index.js.map +0 -1
  223. package/dist/utils.js +0 -77
  224. package/dist/utils.js.map +0 -1
@@ -1,103 +0,0 @@
1
- import { assert } from '@ember/debug';
2
-
3
- function normalizePluginsConfig(plugins) {
4
- if (!plugins) return [];
5
- const result = [];
6
- for (const plugin of plugins) {
7
- if (!Array.isArray(plugin)) {
8
- result.push([plugin, () => ({})]);
9
- continue;
10
- }
11
- if (plugin.length === 2) {
12
- result.push([plugin[0], plugin[1]]);
13
- continue;
14
- }
15
- result.push([plugin[0], () => ({})]);
16
- }
17
- assert(`Every entry in the plugins config must be invokable`, result.every(tuple => typeof tuple[0] === 'function' && typeof tuple[1] === 'function'));
18
- return result;
19
- }
20
-
21
- /**
22
- * Creates a map of featureName => [plugins providing said feature name]
23
- */
24
- function collectFeatures(plugins) {
25
- const result = {};
26
- for (const [plugin] of plugins) {
27
- if ('features' in plugin) {
28
- for (const feature of plugin.features || []) {
29
- result[feature] = [...(result[feature] || []), plugin];
30
- }
31
- }
32
- }
33
- return result;
34
- }
35
-
36
- /**
37
- * Creates a map of requirement => [plugins requesting the feature / requirement]
38
- */
39
- function collectRequirements(plugins) {
40
- const result = {};
41
- for (const [plugin] of plugins) {
42
- if ('requires' in plugin) {
43
- for (const requirement of plugin.requires || []) {
44
- result[requirement] = [...(result[requirement] || []), plugin];
45
- }
46
- }
47
- }
48
- return result;
49
- }
50
- function verifyPlugins(plugins) {
51
- const features = collectFeatures(plugins);
52
- const requirements = collectRequirements(plugins);
53
- const allFeatures = Object.keys(features);
54
- const errors = [];
55
-
56
- // Only one plugin can provide each feature
57
- for (const [feature, providingPlugins] of Object.entries(features)) {
58
- if (providingPlugins.length > 1) {
59
- errors.push(`More than one plugin is providing the feature: ${feature}. ` + `Please remove one of ${providingPlugins.map(p => p.name).join(', ')}`);
60
- }
61
- }
62
- for (const [requirement, requestingPlugins] of Object.entries(requirements)) {
63
- if (!allFeatures.includes(requirement)) {
64
- errors.push(`Configuration is missing requirement: ${requirement}, ` + `And is requested by ${requestingPlugins.map(p => p.name).join(', ')}. ` + `Please add a plugin with the ${requirement} feature`);
65
- }
66
- }
67
- if (errors.length > 0) {
68
- throw new Error(errors.join('\n'));
69
- }
70
- }
71
- /**
72
- * @public
73
- *
74
- * Utility that helps safely apply styles to an element
75
- */
76
- function applyStyles(element, styles) {
77
- for (const [name, value] of Object.entries(styles)) {
78
- if (name in element.style) {
79
- assignStyle(element, name, value);
80
- }
81
- }
82
- }
83
- function assignStyle(element, styleName, value) {
84
- element.style[styleName] = value;
85
- }
86
- function removeStyle(element, styleName) {
87
- element.style.removeProperty(styleName);
88
- }
89
-
90
- /**
91
- * @public
92
- *
93
- * Utility that helps safely remove styles from an element
94
- */
95
- function removeStyles(element, styles) {
96
- for (const name of styles) {
97
- if (typeof name !== 'string') continue;
98
- removeStyle(element, name);
99
- }
100
- }
101
-
102
- export { applyStyles, normalizePluginsConfig, removeStyles, verifyPlugins };
103
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
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/private-types';\nimport type { Plugin } from '../../plugins';\n\ntype PluginOption =\n | Constructor<Plugin<any>>\n | [Constructor<Plugin<any>>, () => any];\n\ntype ExpandedPluginOption = [Constructor<Plugin<any>>, () => any];\n\nexport type Plugins = PluginOption[];\n\nexport function normalizePluginsConfig(\n plugins?: Plugins,\n): ExpandedPluginOption[] {\n if (!plugins) return [];\n\n const result: ExpandedPluginOption[] = [];\n\n for (const 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(\n (tuple) =>\n typeof tuple[0] === 'function' && typeof tuple[1] === 'function',\n ),\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 const result: Record<string, { name: string }[]> = {};\n\n for (const [plugin] of plugins) {\n if ('features' in plugin) {\n for (const feature of (plugin as unknown as typeof BasePlugin).features ||\n []) {\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 const result: Record<string, { name: string }[]> = {};\n\n for (const [plugin] of plugins) {\n if ('requires' in plugin) {\n for (const requirement of (plugin as unknown as typeof BasePlugin)\n .requires || []) {\n result[requirement] = [...(result[requirement] || []), plugin];\n }\n }\n }\n\n return result;\n}\n\nexport function verifyPlugins(plugins: ExpandedPluginOption[]) {\n const features = collectFeatures(plugins);\n const requirements = collectRequirements(plugins);\n const allFeatures = Object.keys(features);\n const errors: string[] = [];\n\n // Only one plugin can provide each feature\n for (const [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 (const [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(\n element: HTMLElement | SVGElement,\n styles: Partial<AssignableStyles>,\n) {\n for (const [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> =\n MaybeStyle extends keyof CSSStyleDeclaration ? MaybeStyle : 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 (const 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":"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"}
@@ -1,81 +0,0 @@
1
- import { meta } from '../-private/base.js';
2
- import { ColumnReordering } from './plugin.js';
3
-
4
- /**
5
- * Move the column one position to the left.
6
- * If the column is first, nothing will happen.
7
- */
8
- const moveLeft = column => meta.forColumn(column, ColumnReordering).moveLeft();
9
-
10
- /**
11
- * Move the column one position to the right.
12
- * If the column is last, nothing will happen.
13
- */
14
- const moveRight = column => meta.forColumn(column, ColumnReordering).moveRight();
15
-
16
- /**
17
- * Override all column positions at once.
18
- */
19
- const setColumnOrder = (table, order) => {
20
- // Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.
21
- // We use a type assertion here to match the expected types.
22
- const tableMeta = meta.forTable(table, ColumnReordering);
23
- return tableMeta.setOrder(order);
24
- };
25
-
26
- /**
27
- * Ask if the column cannot move to the left
28
- */
29
- const cannotMoveLeft = column => meta.forColumn(column, ColumnReordering).cannotMoveLeft;
30
-
31
- /**
32
- * Ask if the column cannot move to the right
33
- */
34
- const cannotMoveRight = column => meta.forColumn(column, ColumnReordering).cannotMoveRight;
35
-
36
- /**
37
- * Ask if the column can move to the left
38
- * (If your plugin doesn't expose `canMoveLeft`, use `!cannotMoveLeft`.)
39
- */
40
- const canMoveLeft = column =>
41
- // Prefer this if available:
42
- // meta.forColumn(column, ColumnReordering).canMoveLeft
43
- !meta.forColumn(column, ColumnReordering).cannotMoveLeft;
44
-
45
- /**
46
- * Ask if the column can move to the right
47
- * (If your plugin doesn't expose `canMoveRight`, use `!cannotMoveRight`.)
48
- */
49
- const canMoveRight = column =>
50
- // Prefer this if available:
51
- // meta.forColumn(column, ColumnReordering).canMoveRight
52
- !meta.forColumn(column, ColumnReordering).cannotMoveRight;
53
-
54
- /**
55
- * Get the columns in their current display order.
56
- *
57
- * This returns an array of columns sorted according to any reordering
58
- * that has been applied via the ColumnReordering plugin. If no reordering
59
- * has been applied, columns are returned in their original order.
60
- *
61
- * @param table - The table instance to get ordered columns from
62
- * @returns Array of columns in their current display order
63
- *
64
- * @example
65
- * ```ts
66
- * import { orderedColumnsFor } from '@universal-ember/table/plugins/column-reordering';
67
- *
68
- * const columns = orderedColumnsFor(table);
69
- * // Use the ordered columns for rendering or other operations
70
- * ```
71
- */
72
- const orderedColumnsFor = table => {
73
- // Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.
74
- // This is a limitation of the current plugin meta system architecture.
75
- // We use a type assertion here because we know the columns come from the same table.
76
- const tableMeta = meta.forTable(table, ColumnReordering);
77
- return tableMeta.columnOrder.orderedColumns;
78
- };
79
-
80
- export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight, orderedColumnsFor, setColumnOrder };
81
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-reordering/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base.ts';\nimport { ColumnReordering } from './plugin.ts';\n\nimport type { ColumnOrder, TableMeta } from './plugin.ts';\nimport type { Column, Table } from '../../index.ts';\n\n/**\n * Move the column one position to the left.\n * If the column is first, nothing will happen.\n */\nexport const moveLeft = <DataType = unknown>(column: Column<DataType>) =>\n 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 = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).moveRight();\n\n/**\n * Override all column positions at once.\n */\nexport const setColumnOrder = <DataType = unknown>(\n table: Table<DataType>,\n order: ColumnOrder<DataType>,\n) => {\n // Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.\n // We use a type assertion here to match the expected types.\n const tableMeta = meta.forTable(\n table,\n ColumnReordering,\n ) as TableMeta<DataType>;\n return tableMeta.setOrder(order);\n};\n\n/**\n * Ask if the column cannot move to the left\n */\nexport const cannotMoveLeft = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column cannot move to the right\n */\nexport const cannotMoveRight = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).cannotMoveRight;\n\n/**\n * Ask if the column can move to the left\n * (If your plugin doesn't expose `canMoveLeft`, use `!cannotMoveLeft`.)\n */\nexport const canMoveLeft = <DataType = unknown>(column: Column<DataType>) =>\n // Prefer this if available:\n // meta.forColumn(column, ColumnReordering).canMoveLeft\n !meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column can move to the right\n * (If your plugin doesn't expose `canMoveRight`, use `!cannotMoveRight`.)\n */\nexport const canMoveRight = <DataType = unknown>(column: Column<DataType>) =>\n // Prefer this if available:\n // meta.forColumn(column, ColumnReordering).canMoveRight\n !meta.forColumn(column, ColumnReordering).cannotMoveRight;\n\n/**\n * Get the columns in their current display order.\n *\n * This returns an array of columns sorted according to any reordering\n * that has been applied via the ColumnReordering plugin. If no reordering\n * has been applied, columns are returned in their original order.\n *\n * @param table - The table instance to get ordered columns from\n * @returns Array of columns in their current display order\n *\n * @example\n * ```ts\n * import { orderedColumnsFor } from '@universal-ember/table/plugins/column-reordering';\n *\n * const columns = orderedColumnsFor(table);\n * // Use the ordered columns for rendering or other operations\n * ```\n */\nexport const orderedColumnsFor = <DataType = unknown>(\n table: Table<DataType>,\n): Column<DataType>[] => {\n // Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.\n // This is a limitation of the current plugin meta system architecture.\n // We use a type assertion here because we know the columns come from the same table.\n const tableMeta = meta.forTable(\n table,\n ColumnReordering,\n ) as TableMeta<DataType>;\n return tableMeta.columnOrder.orderedColumns;\n};\n"],"names":["moveLeft","column","meta","forColumn","ColumnReordering","moveRight","setColumnOrder","table","order","tableMeta","forTable","setOrder","cannotMoveLeft","cannotMoveRight","canMoveLeft","canMoveRight","orderedColumnsFor","columnOrder","orderedColumns"],"mappings":";;;AAMA;AACA;AACA;AACA;MACaA,QAAQ,GAAwBC,MAAwB,IACnEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACJ,QAAQ;;AAEnD;AACA;AACA;AACA;MACaK,SAAS,GAAwBJ,MAAwB,IACpEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACC,SAAS;;AAEpD;AACA;AACA;MACaC,cAAc,GAAGA,CAC5BC,KAAsB,EACtBC,KAA4B,KACzB;AACH;AACA;EACA,MAAMC,SAAS,GAAGP,IAAI,CAACQ,QAAQ,CAC7BH,KAAK,EACLH,gBACF,CAAwB;AACxB,EAAA,OAAOK,SAAS,CAACE,QAAQ,CAACH,KAAK,CAAC;AAClC;;AAEA;AACA;AACA;AACaI,MAAAA,cAAc,GAAwBX,MAAwB,IACzEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACQ;;AAE3C;AACA;AACA;AACaC,MAAAA,eAAe,GAAwBZ,MAAwB,IAC1EC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACS;;AAE3C;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAwBb,MAAwB;AACtE;AACA;AACA,CAACC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACQ;;AAE5C;AACA;AACA;AACA;AACO,MAAMG,YAAY,GAAwBd,MAAwB;AACvE;AACA;AACA,CAACC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACS;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaG,MAAAA,iBAAiB,GAC5BT,KAAsB,IACC;AACvB;AACA;AACA;EACA,MAAME,SAAS,GAAGP,IAAI,CAACQ,QAAQ,CAC7BH,KAAK,EACLH,gBACF,CAAwB;AACxB,EAAA,OAAOK,SAAS,CAACQ,WAAW,CAACC,cAAc;AAC7C;;;;"}
@@ -1,3 +0,0 @@
1
- export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight, orderedColumnsFor, setColumnOrder } from './helpers.js';
2
- export { ColumnOrder, ColumnReordering, ColumnReordering as Plugin, orderOf } from './plugin.js';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,453 +0,0 @@
1
- import { _ as _defineProperty, a as _applyDecoratedDescriptor, b as _initializerDefineProperty, c as _classPrivateMethodInitSpec, d as _classPrivateGetter } from '../../_rollupPluginBabelHelpers-CjaRjJZX.js';
2
- import { tracked, cached } from '@glimmer/tracking';
3
- import { assert } from '@ember/debug';
4
- import { action } from '@ember/object';
5
- import { TrackedMap } from 'tracked-built-ins';
6
- import { BasePlugin, meta, preferences, columns } from '../-private/base.js';
7
-
8
- var _class, _descriptor, _class2;
9
- class ColumnReordering extends BasePlugin {
10
- constructor(...args) {
11
- super(...args);
12
- _defineProperty(this, "name", 'column-reordering');
13
- _defineProperty(this, "meta", {
14
- column: ColumnMeta,
15
- table: TableMeta
16
- });
17
- }
18
- reset() {
19
- const tableMeta = meta.forTable(this.table, ColumnReordering);
20
- tableMeta.reset();
21
- }
22
- get columns() {
23
- return meta.forTable(this.table, ColumnReordering).columns;
24
- }
25
- }
26
- _defineProperty(ColumnReordering, "features", ['columnOrder']);
27
- var _ColumnMeta_brand = /*#__PURE__*/new WeakSet();
28
- class ColumnMeta {
29
- constructor(column) {
30
- _classPrivateMethodInitSpec(this, _ColumnMeta_brand);
31
- /**
32
- * Move the column one spot to the left
33
- */
34
- _defineProperty(this, "moveLeft", () => {
35
- _classPrivateGetter(_ColumnMeta_brand, this, _get_tableMeta).columnOrder.moveLeft(this.column.key);
36
- });
37
- /**
38
- * Move the column one spot to the right
39
- */
40
- _defineProperty(this, "moveRight", () => {
41
- _classPrivateGetter(_ColumnMeta_brand, this, _get_tableMeta).columnOrder.moveRight(this.column.key);
42
- });
43
- this.column = column;
44
- }
45
- get position() {
46
- return _classPrivateGetter(_ColumnMeta_brand, this, _get_tableMeta).getPosition(this.column);
47
- }
48
-
49
- // Swaps this column with the column in the new position
50
- set position(value) {
51
- _classPrivateGetter(_ColumnMeta_brand, this, _get_tableMeta).setPosition(this.column, value);
52
- }
53
- get canMoveLeft() {
54
- return _classPrivateGetter(_ColumnMeta_brand, this, _get_tableMeta).getPosition(this.column) !== 0;
55
- }
56
- get canMoveRight() {
57
- return _classPrivateGetter(_ColumnMeta_brand, this, _get_tableMeta).getPosition(this.column) !== _classPrivateGetter(_ColumnMeta_brand, this, _get_tableMeta).columns.length - 1;
58
- }
59
- get cannotMoveLeft() {
60
- return !this.canMoveLeft;
61
- }
62
- get cannotMoveRight() {
63
- return !this.canMoveRight;
64
- }
65
- }
66
- function _get_tableMeta(_this) {
67
- return meta.forTable(_this.column.table, ColumnReordering);
68
- }
69
- let TableMeta = (_class = class TableMeta {
70
- constructor(table) {
71
- /**
72
- * @private
73
- *
74
- * We want to maintain the instance of this ColumnOrder class because
75
- * we allow the consumer of the table to swap out columns at any time.
76
- * When they do this, we want to maintain the order of the table, best we can.
77
- * This is also why the order of the columns is maintained via column key
78
- */
79
- _initializerDefineProperty(this, "columnOrder", _descriptor, this);
80
- /**
81
- * Using a `ColumnOrder` instance, set the order of all columns
82
- */
83
- _defineProperty(this, "setOrder", order => {
84
- this.columnOrder.setAll(order.map);
85
- });
86
- this.table = table;
87
- }
88
- /**
89
- * Get the curret order/position of a column
90
- */
91
- getPosition(column) {
92
- return this.columnOrder.get(column.key);
93
- }
94
-
95
- /**
96
- * Swap the column with the column at `newPosition`
97
- */
98
- setPosition(column, newPosition) {
99
- return this.columnOrder.swapWith(column.key, newPosition);
100
- }
101
- /**
102
- * Revert to default config, delete preferences,
103
- * and clear the columnOrder
104
- */
105
- reset() {
106
- preferences.forTable(this.table, ColumnReordering).delete('order');
107
- this.columnOrder = new ColumnOrder({
108
- columns: () => this.allColumns,
109
- visibleColumns: () => this.visibleColumns,
110
- save: this.save
111
- });
112
- }
113
-
114
- /**
115
- * @private
116
- */
117
- save(map) {
118
- const order = {};
119
- for (const [key, position] of map.entries()) {
120
- order[key] = position;
121
- }
122
- preferences.forTable(this.table, ColumnReordering).set('order', order);
123
- }
124
-
125
- /**
126
- * @private
127
- */
128
- read() {
129
- const order = preferences.forTable(this.table, ColumnReordering).get('order');
130
- if (!order) return;
131
- return new Map(Object.entries(order));
132
- }
133
- get columns() {
134
- return this.columnOrder.orderedColumns.filter(column => this.visibleColumns[column.key]);
135
- }
136
-
137
- /**
138
- * @private
139
- * This isn't our data to expose, but it is useful to alias
140
- */
141
- get visibleColumns() {
142
- return columns.for(this.table, ColumnReordering).reduce((acc, column) => {
143
- acc[column.key] = true;
144
- return acc;
145
- }, {});
146
- }
147
- get allColumns() {
148
- return this.table.columns.values();
149
- }
150
- }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "columnOrder", [tracked], {
151
- configurable: true,
152
- enumerable: true,
153
- writable: true,
154
- initializer: function () {
155
- return new ColumnOrder({
156
- columns: () => this.allColumns,
157
- visibleColumns: () => this.visibleColumns,
158
- save: this.save,
159
- read: () => this.read()
160
- });
161
- }
162
- }), _applyDecoratedDescriptor(_class.prototype, "getPosition", [action], Object.getOwnPropertyDescriptor(_class.prototype, "getPosition"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "setPosition", [action], Object.getOwnPropertyDescriptor(_class.prototype, "setPosition"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "reset", [action], Object.getOwnPropertyDescriptor(_class.prototype, "reset"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "save", [action], Object.getOwnPropertyDescriptor(_class.prototype, "save"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "read", [action], Object.getOwnPropertyDescriptor(_class.prototype, "read"), _class.prototype), _class);
163
-
164
- /**
165
- * @private
166
- * Used for keeping track of and updating column order
167
- */
168
- let ColumnOrder = (_class2 = class ColumnOrder {
169
- constructor(args) {
170
- /**
171
- * This map will be empty until we re-order something.
172
- */
173
- _defineProperty(this, "map", new TrackedMap());
174
- _defineProperty(this, "setAll", map => {
175
- let allColumns = this.args.columns();
176
- addMissingColumnsToMap(allColumns, map);
177
- removeExtraColumnsFromMap(allColumns, map);
178
- this.map.clear();
179
- for (const [key, value] of map.entries()) {
180
- this.map.set(key, value);
181
- }
182
- this.args.save?.(map);
183
- });
184
- this.args = args;
185
- // Initialize map from existingOrder for backwards compatibility
186
- // The reactive `read` callback will override this in orderedMap
187
- let _allColumns = this.args.columns();
188
- const initialOrder = args.existingOrder ?? args.read?.();
189
- if (initialOrder) {
190
- let newOrder = new Map(initialOrder.entries());
191
- addMissingColumnsToMap(_allColumns, newOrder);
192
- removeExtraColumnsFromMap(_allColumns, newOrder);
193
- this.map = new TrackedMap(newOrder);
194
- } else {
195
- this.map = new TrackedMap(_allColumns.map((column, i) => [column.key, i]));
196
- }
197
- }
198
-
199
- /**
200
- * @private
201
- * Helper to get visible columns, defaulting to all columns if not specified
202
- */
203
- getVisibleColumns() {
204
- if (this.args.visibleColumns) {
205
- return this.args.visibleColumns();
206
- }
207
-
208
- // Default: all columns are visible
209
- return this.args.columns().reduce((acc, col) => {
210
- acc[col.key] = true;
211
- return acc;
212
- }, {});
213
- }
214
-
215
- /**
216
- * To account for columnVisibilty, we need to:
217
- * - get the list of visible columns
218
- * - get the column order (which preserves the order of hidden columns)
219
- * - skip over non-visible columns when determining the previous "index"
220
- * - set the position to whatever that is.
221
- */
222
- moveLeft(key) {
223
- const orderedColumns = this.orderedColumns;
224
- if (this.map.get(key) === 0) {
225
- return;
226
- }
227
- let found = false;
228
- for (const column of orderedColumns.reverse()) {
229
- if (found) {
230
- // Shift moved column left
231
- let currentPosition = this.map.get(key);
232
- assert('current key must exist in map', currentPosition !== undefined);
233
- this.map.set(key, currentPosition - 1);
234
-
235
- // Shift displayed column right
236
- let displayedColumnPosition = this.map.get(column.key);
237
- assert('displaced key must exist in map', displayedColumnPosition !== undefined);
238
- this.map.set(column.key, displayedColumnPosition + 1);
239
- if (this.getVisibleColumns()[column.key]) {
240
- break;
241
- }
242
- }
243
- if (column.key === key) {
244
- found = true;
245
- }
246
- }
247
- this.args.save?.(this.map);
248
- }
249
- /**
250
- * To account for columnVisibilty, we need to:
251
- * - get the list of visible columns
252
- * - get the column order (which preserves the order of hidden columns)
253
- * - skip over non-visible columns when determining the next "index"
254
- * - set the position to whatever that is.
255
- */
256
- moveRight(key) {
257
- const orderedColumns = this.orderedColumns;
258
- let found = false;
259
- for (const column of orderedColumns) {
260
- if (found) {
261
- // Shift moved column right
262
- let currentPosition = this.map.get(key);
263
- assert('current key must exist in map', currentPosition !== undefined);
264
- this.map.set(key, currentPosition + 1);
265
-
266
- // Shift displaced column left
267
- let displayedColumnPosition = this.map.get(column.key);
268
- assert('displaced key must exist in map', displayedColumnPosition !== undefined);
269
- this.map.set(column.key, displayedColumnPosition - 1);
270
- if (this.getVisibleColumns()[column.key]) {
271
- break;
272
- }
273
- }
274
- if (column.key === key) {
275
- found = true;
276
- }
277
- }
278
- this.args.save?.(this.map);
279
- }
280
-
281
- /**
282
- * Performs a swap of the column's position with the column at position
283
- */
284
- swapWith(key, position) {
285
- const validPositions = [...this.orderedMap.values()];
286
-
287
- /**
288
- * Position to swap to must exist
289
- */
290
- if (!validPositions.includes(position)) {
291
- return;
292
- }
293
-
294
- /**
295
- * Where did this column `key` come from? we can find out
296
- * by reading orderedMap
297
- */
298
- const currentPosition = this.orderedMap.get(key);
299
- assert(`Pre-existing position for ${key} could not be found. Does the column exist? ` + `The current positions are: ` + [...this.orderedMap.entries()].map(entry => entry.join(' => ')).join(', ') + ` and the visibleColumns are: ` + Object.keys(this.getVisibleColumns()).join(', ') + ` and current "map" (${this.map.size}) is: ` + [...this.map.entries()].map(entry => entry.join(' => ')).join(', '), undefined !== currentPosition);
300
-
301
- /**
302
- * No need to change anything if the position is the same
303
- * This helps reduce @tracked invalidations, which in turn reduces DOM thrashing.
304
- */
305
- if (currentPosition === position) {
306
- return false;
307
- }
308
- const keyByPosition = new Map([...this.orderedMap.entries()].map(entry => entry.reverse()));
309
- for (const [existingPosition, key] of keyByPosition.entries()) {
310
- if (existingPosition === position) {
311
- /**
312
- * We swap positions because the positions are not incremental
313
- * meaning we can have gaps, intentionally, due to hidden columns
314
- */
315
- this.map.set(key, currentPosition);
316
- break;
317
- }
318
- }
319
-
320
- /**
321
- * Finally, set the position for the requested column
322
- */
323
- this.map.set(key, position);
324
-
325
- /**
326
- * Now that we've set the value for one column,
327
- * we need to make sure that all columns have a recorded position.
328
- */
329
- for (const [key, position] of this.orderedMap.entries()) {
330
- if (this.map.has(key)) continue;
331
- this.map.set(key, position);
332
- }
333
- this.args.save?.(this.map);
334
- }
335
- get(key) {
336
- const result = this.orderedMap.get(key);
337
- assert(`No position found for ${key}. Is the column used within this table?`, /* 0 is falsey, but it's a valid value for position */
338
- undefined !== result);
339
- return result;
340
- }
341
-
342
- /**
343
- * The same as this.map, but with all the columns' information.
344
- * Prefers preferences (via read callback) when available for reactivity.
345
- */
346
- get orderedMap() {
347
- // Prefer preferences for reactivity, fall back to local map
348
- const savedOrder = this.args.read?.();
349
- const baseMap = savedOrder ?? this.map;
350
- return orderOf(this.args.columns(), baseMap);
351
- }
352
- get orderedColumns() {
353
- const allColumns = this.args.columns();
354
- const columnsByKey = allColumns.reduce((keyMap, column) => {
355
- keyMap[column.key] = column;
356
- return keyMap;
357
- }, {});
358
- // Use orderedMap which is reactive to preferences
359
- const mergedOrder = this.orderedMap;
360
- const result = Array.from({
361
- length: allColumns.length
362
- });
363
- for (const [key, position] of mergedOrder.entries()) {
364
- const column = columnsByKey[key];
365
-
366
- // Skip columns that no longer exist (they've been removed from the columns array)
367
- if (!column) {
368
- continue;
369
- }
370
- result[position] = column;
371
- }
372
-
373
- // Filter out undefined entries (from removed columns or gaps in positions)
374
- return result.filter(Boolean);
375
- }
376
- }, _applyDecoratedDescriptor(_class2.prototype, "moveLeft", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "moveLeft"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "moveRight", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "moveRight"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "swapWith", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "swapWith"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "get", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "get"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "orderedMap", [cached], Object.getOwnPropertyDescriptor(_class2.prototype, "orderedMap"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "orderedColumns", [cached], Object.getOwnPropertyDescriptor(_class2.prototype, "orderedColumns"), _class2.prototype), _class2);
377
-
378
- /**
379
- * @private
380
- *
381
- * Utility for helping determine the percieved order of a set of columns
382
- * given the original (default) ordering, and then user-configurations.
383
- *
384
- * This function adds missing columns but preserves extra columns in the map
385
- * (they might be hidden, not deleted).
386
- */
387
- function orderOf(columns, currentOrder) {
388
- // Create a copy to avoid mutating the input
389
- let workingOrder = new Map(currentOrder);
390
-
391
- // Add any missing columns to the end
392
- addMissingColumnsToMap(columns, workingOrder);
393
-
394
- // DON'T remove extra columns - they might be hidden columns, not deleted ones
395
- // The ColumnOrder constructor handles removal of truly deleted columns
396
-
397
- // Ensure positions are consecutive and zero based
398
- let inOrder = Array.from(workingOrder.entries()).sort(([_keyA, positionA], [_keyB, positionB]) => positionA - positionB);
399
- let orderedColumns = new Map();
400
- let position = 0;
401
- for (let [key] of inOrder) {
402
- orderedColumns.set(key, position++);
403
- }
404
- return orderedColumns;
405
- }
406
-
407
- /**
408
- * @private
409
- *
410
- * Utility to add any missing columns to the position map. By calling this whenever
411
- * data is passed in to the system we can simplify the code within the system because
412
- * we know we are dealing with a full set of positions.
413
- *
414
- * @param columns - A list of all columns available to the table
415
- * @param map - A Map of `key` to position (as a zero based integer)
416
- */
417
- function addMissingColumnsToMap(columns, map) {
418
- if (map.size < columns.length) {
419
- let maxAssignedColumn = Math.max(...map.values());
420
- for (let column of columns) {
421
- if (map.get(column.key) === undefined) {
422
- map.set(column.key, ++maxAssignedColumn);
423
- }
424
- }
425
- }
426
- }
427
-
428
- /**
429
- * @private
430
- *
431
- * Utility to remove any extra columns from the position map. By calling this whenever
432
- * data is passed in to the system we can simplify the code within the system because
433
- * we know we are dealing with a full set of positions.
434
- *
435
- * @param columns - A list of all columns available to the table
436
- * @param map - A Map of `key` to position (as a zero based integer)
437
- */
438
- function removeExtraColumnsFromMap(columns, map) {
439
- let columnsLookup = columns.reduce(function (acc, {
440
- key
441
- }) {
442
- acc[key] = true;
443
- return acc;
444
- }, {});
445
- for (let key of map.keys()) {
446
- if (!columnsLookup[key]) {
447
- map.delete(key);
448
- }
449
- }
450
- }
451
-
452
- export { ColumnMeta, ColumnOrder, ColumnReordering, TableMeta, orderOf };
453
- //# sourceMappingURL=plugin.js.map