ember-headless-table 0.0.0 → 1.0.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.
Files changed (169) hide show
  1. package/addon-main.js +5 -0
  2. package/dist/-private/-type-tests/plugin-properties.test.d.ts +2 -0
  3. package/dist/-private/-type-tests/plugin-properties.test.d.ts.map +1 -0
  4. package/dist/-private/-type-tests/plugin-properties.test.js +31 -0
  5. package/dist/-private/-type-tests/plugin-properties.test.js.map +1 -0
  6. package/dist/-private/-type-tests/plugin-with.test.d.ts +1 -0
  7. package/dist/-private/-type-tests/plugin-with.test.js +21 -0
  8. package/dist/-private/-type-tests/plugin-with.test.js.map +1 -0
  9. package/dist/-private/-type-tests/plugins-accessors.test.d.ts +1 -0
  10. package/dist/-private/-type-tests/plugins-accessors.test.js +36 -0
  11. package/dist/-private/-type-tests/plugins-accessors.test.js.map +1 -0
  12. package/dist/-private/-type-tests/plugins-signature-from.test.d.ts +1 -0
  13. package/dist/-private/-type-tests/plugins-signature-from.test.js +14 -0
  14. package/dist/-private/-type-tests/plugins-signature-from.test.js.map +1 -0
  15. package/dist/-private/-type-tests/plugins-signature-utils.test.d.ts +1 -0
  16. package/dist/-private/-type-tests/plugins-signature-utils.test.js +36 -0
  17. package/dist/-private/-type-tests/plugins-signature-utils.test.js.map +1 -0
  18. package/dist/-private/-type-tests/table-api.test.d.ts +1 -0
  19. package/dist/-private/-type-tests/table-api.test.js +16 -0
  20. package/dist/-private/-type-tests/table-api.test.js.map +1 -0
  21. package/dist/-private/-type-tests/table-config.test.d.ts +1 -0
  22. package/dist/-private/-type-tests/table-config.test.js +58 -0
  23. package/dist/-private/-type-tests/table-config.test.js.map +1 -0
  24. package/dist/-private/column.d.ts +18 -0
  25. package/dist/-private/column.js +70 -0
  26. package/dist/-private/column.js.map +1 -0
  27. package/dist/-private/interfaces/column.d.ts +57 -0
  28. package/dist/-private/interfaces/column.js +2 -0
  29. package/dist/-private/interfaces/column.js.map +1 -0
  30. package/dist/-private/interfaces/index.d.ts +7 -0
  31. package/dist/-private/interfaces/index.js +2 -0
  32. package/dist/-private/interfaces/index.js.map +1 -0
  33. package/dist/-private/interfaces/modifier.d.ts +7 -0
  34. package/dist/-private/interfaces/modifier.js +2 -0
  35. package/dist/-private/interfaces/modifier.js.map +1 -0
  36. package/dist/-private/interfaces/pagination.d.ts +17 -0
  37. package/dist/-private/interfaces/pagination.js +2 -0
  38. package/dist/-private/interfaces/pagination.js.map +1 -0
  39. package/dist/-private/interfaces/plugins.d.ts +314 -0
  40. package/dist/-private/interfaces/plugins.js +2 -0
  41. package/dist/-private/interfaces/plugins.js.map +1 -0
  42. package/dist/-private/interfaces/preferences.d.ts +74 -0
  43. package/dist/-private/interfaces/preferences.js +2 -0
  44. package/dist/-private/interfaces/preferences.js.map +1 -0
  45. package/dist/-private/interfaces/selection.d.ts +35 -0
  46. package/dist/-private/interfaces/selection.js +2 -0
  47. package/dist/-private/interfaces/selection.js.map +1 -0
  48. package/dist/-private/interfaces/table.d.ts +109 -0
  49. package/dist/-private/interfaces/table.js +2 -0
  50. package/dist/-private/interfaces/table.js.map +1 -0
  51. package/dist/-private/js-helper.d.ts +39 -0
  52. package/dist/-private/js-helper.js +20 -0
  53. package/dist/-private/js-helper.js.map +1 -0
  54. package/dist/-private/preferences.d.ts +56 -0
  55. package/dist/-private/preferences.js +175 -0
  56. package/dist/-private/preferences.js.map +1 -0
  57. package/dist/-private/private-types.d.ts +6 -0
  58. package/dist/-private/private-types.js +2 -0
  59. package/dist/-private/private-types.js.map +1 -0
  60. package/dist/-private/row.d.ts +12 -0
  61. package/dist/-private/row.js +63 -0
  62. package/dist/-private/row.js.map +1 -0
  63. package/dist/-private/table.d.ts +0 -0
  64. package/dist/-private/table.js +18 -0
  65. package/dist/-private/table.js.map +1 -0
  66. package/dist/-private/utils.d.ts +3 -0
  67. package/dist/-private/utils.js +17 -0
  68. package/dist/-private/utils.js.map +1 -0
  69. package/dist/applyDecoratedDescriptor-e0489e2f.js +31 -0
  70. package/dist/applyDecoratedDescriptor-e0489e2f.js.map +1 -0
  71. package/dist/classPrivateFieldGet-af59a8ea.js +23 -0
  72. package/dist/classPrivateFieldGet-af59a8ea.js.map +1 -0
  73. package/dist/defineProperty-a0196711.js +17 -0
  74. package/dist/defineProperty-a0196711.js.map +1 -0
  75. package/dist/index.d.ts +13 -0
  76. package/dist/index.js +4 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/plugins/-private/base.d.ts +267 -0
  79. package/dist/plugins/-private/base.js +486 -0
  80. package/dist/plugins/-private/base.js.map +1 -0
  81. package/dist/plugins/-private/utils.d.ts +21 -0
  82. package/dist/plugins/-private/utils.js +118 -0
  83. package/dist/plugins/-private/utils.js.map +1 -0
  84. package/dist/plugins/column-reordering/helpers.d.ts +28 -0
  85. package/dist/plugins/column-reordering/helpers.js +37 -0
  86. package/dist/plugins/column-reordering/helpers.js.map +1 -0
  87. package/dist/plugins/column-reordering/index.d.ts +3 -0
  88. package/dist/plugins/column-reordering/index.js +3 -0
  89. package/dist/plugins/column-reordering/index.js.map +1 -0
  90. package/dist/plugins/column-reordering/plugin.d.ts +133 -0
  91. package/dist/plugins/column-reordering/plugin.js +392 -0
  92. package/dist/plugins/column-reordering/plugin.js.map +1 -0
  93. package/dist/plugins/column-reordering/utils.d.ts +7 -0
  94. package/dist/plugins/column-reordering/utils.js +41 -0
  95. package/dist/plugins/column-reordering/utils.js.map +1 -0
  96. package/dist/plugins/column-resizing/handle.d.ts +116 -0
  97. package/dist/plugins/column-resizing/handle.js +251 -0
  98. package/dist/plugins/column-resizing/handle.js.map +1 -0
  99. package/dist/plugins/column-resizing/helpers.d.ts +17 -0
  100. package/dist/plugins/column-resizing/helpers.js +22 -0
  101. package/dist/plugins/column-resizing/helpers.js.map +1 -0
  102. package/dist/plugins/column-resizing/index.d.ts +4 -0
  103. package/dist/plugins/column-resizing/index.js +4 -0
  104. package/dist/plugins/column-resizing/index.js.map +1 -0
  105. package/dist/plugins/column-resizing/plugin.d.ts +144 -0
  106. package/dist/plugins/column-resizing/plugin.js +352 -0
  107. package/dist/plugins/column-resizing/plugin.js.map +1 -0
  108. package/dist/plugins/column-resizing/resize-observer.d.ts +14 -0
  109. package/dist/plugins/column-resizing/resize-observer.js +46 -0
  110. package/dist/plugins/column-resizing/resize-observer.js.map +1 -0
  111. package/dist/plugins/column-resizing/utils.d.ts +22 -0
  112. package/dist/plugins/column-resizing/utils.js +46 -0
  113. package/dist/plugins/column-resizing/utils.js.map +1 -0
  114. package/dist/plugins/column-visibility/helpers.d.ts +18 -0
  115. package/dist/plugins/column-visibility/helpers.js +25 -0
  116. package/dist/plugins/column-visibility/helpers.js.map +1 -0
  117. package/dist/plugins/column-visibility/index.d.ts +3 -0
  118. package/dist/plugins/column-visibility/index.js +3 -0
  119. package/dist/plugins/column-visibility/index.js.map +1 -0
  120. package/dist/plugins/column-visibility/plugin.d.ts +62 -0
  121. package/dist/plugins/column-visibility/plugin.js +124 -0
  122. package/dist/plugins/column-visibility/plugin.js.map +1 -0
  123. package/dist/plugins/data-sorting/helpers.d.ts +38 -0
  124. package/dist/plugins/data-sorting/helpers.js +49 -0
  125. package/dist/plugins/data-sorting/helpers.js.map +1 -0
  126. package/dist/plugins/data-sorting/index.d.ts +5 -0
  127. package/dist/plugins/data-sorting/index.js +4 -0
  128. package/dist/plugins/data-sorting/index.js.map +1 -0
  129. package/dist/plugins/data-sorting/plugin.d.ts +99 -0
  130. package/dist/plugins/data-sorting/plugin.js +165 -0
  131. package/dist/plugins/data-sorting/plugin.js.map +1 -0
  132. package/dist/plugins/data-sorting/types.d.ts +23 -0
  133. package/dist/plugins/data-sorting/types.js +17 -0
  134. package/dist/plugins/data-sorting/types.js.map +1 -0
  135. package/dist/plugins/index.d.ts +5 -0
  136. package/dist/plugins/index.js +3 -0
  137. package/dist/plugins/index.js.map +1 -0
  138. package/dist/plugins/row-selection/helpers.d.ts +6 -0
  139. package/dist/plugins/row-selection/helpers.js +10 -0
  140. package/dist/plugins/row-selection/helpers.js.map +1 -0
  141. package/dist/plugins/row-selection/index.d.ts +3 -0
  142. package/dist/plugins/row-selection/index.js +3 -0
  143. package/dist/plugins/row-selection/index.js.map +1 -0
  144. package/dist/plugins/row-selection/plugin.d.ts +79 -0
  145. package/dist/plugins/row-selection/plugin.js +187 -0
  146. package/dist/plugins/row-selection/plugin.js.map +1 -0
  147. package/dist/plugins/sticky-columns/helpers.d.ts +4 -0
  148. package/dist/plugins/sticky-columns/helpers.js +8 -0
  149. package/dist/plugins/sticky-columns/helpers.js.map +1 -0
  150. package/dist/plugins/sticky-columns/index.d.ts +3 -0
  151. package/dist/plugins/sticky-columns/index.js +3 -0
  152. package/dist/plugins/sticky-columns/index.js.map +1 -0
  153. package/dist/plugins/sticky-columns/plugin.d.ts +53 -0
  154. package/dist/plugins/sticky-columns/plugin.js +132 -0
  155. package/dist/plugins/sticky-columns/plugin.js.map +1 -0
  156. package/dist/table-8e46554b.d.ts +127 -0
  157. package/dist/table-8e46554b.js +249 -0
  158. package/dist/table-8e46554b.js.map +1 -0
  159. package/dist/test-support/index.d.ts +14 -0
  160. package/dist/test-support/index.js +72 -0
  161. package/dist/test-support/index.js.map +1 -0
  162. package/dist/utils.d.ts +26 -0
  163. package/dist/utils.js +77 -0
  164. package/dist/utils.js.map +1 -0
  165. package/package.json +147 -51
  166. package/LICENSE.md +0 -9
  167. package/README.md +0 -38
  168. package/config/environment.js +0 -5
  169. package/index.js +0 -5
@@ -0,0 +1,118 @@
1
+ import { assert } from '@ember/debug';
2
+
3
+ function normalizePluginsConfig(plugins) {
4
+ if (!plugins) return [];
5
+ let result = [];
6
+
7
+ for (let plugin of plugins) {
8
+ if (!Array.isArray(plugin)) {
9
+ result.push([plugin, () => ({})]);
10
+ continue;
11
+ }
12
+
13
+ if (plugin.length === 2) {
14
+ result.push([plugin[0], plugin[1]]);
15
+ continue;
16
+ }
17
+
18
+ result.push([plugin[0], () => ({})]);
19
+ }
20
+
21
+ assert(`Every entry in the plugins config must be invokable`, result.every(tuple => typeof tuple[0] === 'function' && typeof tuple[1] === 'function'));
22
+ return result;
23
+ }
24
+ /**
25
+ * Creates a map of featureName => [plugins providing said feature name]
26
+ */
27
+
28
+ function collectFeatures(plugins) {
29
+ let result = {};
30
+
31
+ for (let [plugin] of plugins) {
32
+ if ('features' in plugin) {
33
+ for (let feature of plugin.features || []) {
34
+ result[feature] = [...(result[feature] || []), plugin];
35
+ }
36
+ }
37
+ }
38
+
39
+ return result;
40
+ }
41
+ /**
42
+ * Creates a map of requirement => [plugins requesting the feature / requirement]
43
+ */
44
+
45
+
46
+ function collectRequirements(plugins) {
47
+ let result = {};
48
+
49
+ for (let [plugin] of plugins) {
50
+ if ('requires' in plugin) {
51
+ for (let requirement of plugin.requires || []) {
52
+ result[requirement] = [...(result[requirement] || []), plugin];
53
+ }
54
+ }
55
+ }
56
+
57
+ return result;
58
+ }
59
+
60
+ function verifyPlugins(plugins) {
61
+ let features = collectFeatures(plugins);
62
+ let requirements = collectRequirements(plugins);
63
+ let allFeatures = Object.keys(features);
64
+ let errors = []; // Only one plugin can provide each feature
65
+
66
+ for (let [feature, providingPlugins] of Object.entries(features)) {
67
+ if (providingPlugins.length > 1) {
68
+ errors.push(`More than one plugin is providing the feature: ${feature}. ` + `Please remove one of ${providingPlugins.map(p => p.name).join(', ')}`);
69
+ }
70
+ }
71
+
72
+ for (let [requirement, requestingPlugins] of Object.entries(requirements)) {
73
+ if (!allFeatures.includes(requirement)) {
74
+ 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`);
75
+ }
76
+ }
77
+
78
+ if (errors.length > 0) {
79
+ throw new Error(errors.join('\n'));
80
+ }
81
+ }
82
+
83
+ /**
84
+ * @public
85
+ *
86
+ * Utility that helps safely apply styles to an element
87
+ */
88
+ function applyStyles(element, styles) {
89
+ for (let [name, value] of Object.entries(styles)) {
90
+ if (name in element.style) {
91
+ assignStyle(element, name, value);
92
+ }
93
+ }
94
+ }
95
+
96
+ function assignStyle(element, styleName, value) {
97
+ element.style[styleName] = value;
98
+ }
99
+
100
+ function removeStyle(element, styleName) {
101
+ element.style.removeProperty(styleName);
102
+ }
103
+ /**
104
+ * @public
105
+ *
106
+ * Utility that helps safely remove styles from an element
107
+ */
108
+
109
+
110
+ function removeStyles(element, styles) {
111
+ for (let name of styles) {
112
+ if (typeof name !== 'string') continue;
113
+ removeStyle(element, name);
114
+ }
115
+ }
116
+
117
+ export { applyStyles, normalizePluginsConfig, removeStyles, verifyPlugins };
118
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +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,sBAAT,CAAgCC,OAAhC,EAA2E;AAChF,EAAA,IAAI,CAACA,OAAL,EAAc,OAAO,EAAP,CAAA;EAEd,IAAIC,MAA8B,GAAG,EAArC,CAAA;;AAEA,EAAA,KAAK,IAAIC,MAAT,IAAmBF,OAAnB,EAA4B;AAC1B,IAAA,IAAI,CAACG,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;MAC1BD,MAAM,CAACI,IAAP,CAAY,CAACH,MAAD,EAAS,OAAO,EAAP,CAAT,CAAZ,CAAA,CAAA;AAEA,MAAA,SAAA;AACD,KAAA;;AAED,IAAA,IAAIA,MAAM,CAACI,MAAP,KAAkB,CAAtB,EAAyB;AACvBL,MAAAA,MAAM,CAACI,IAAP,CAAY,CAACH,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,CAAZ,CAAA,CAAA;AAEA,MAAA,SAAA;AACD,KAAA;;AAEDD,IAAAA,MAAM,CAACI,IAAP,CAAY,CAACH,MAAM,CAAC,CAAD,CAAP,EAAY,OAAO,EAAP,CAAZ,CAAZ,CAAA,CAAA;AACD,GAAA;;EAEDK,MAAM,CACH,CADG,mDAAA,CAAA,EAEJN,MAAM,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AuB;IACrB,MAAM,IAAIwB,KAAJ,CAAUT,MAAM,CAACM,IAAP,CAAY,IAAZ,CAAV,CAAN,CAAA;AACD,GAAA;AACF,CAAA;;AAID;AACA;AACA;AACA;AACA;AACO,SAASI,WAAT,CAAqBC,OAArB,EAAwDC,MAAxD,EAA2F;AAChG,EAAA,KAAK,IAAI,CAACP,IAAD,EAAOQ,KAAP,CAAT,IAA0Bf,MAAM,CAACI,OAAP,CAAeU,MAAf,CAA1B,EAAkD;AAChD,IAAA,IAAIP,IAAI,IAAIM,OAAO,CAACG,KAApB,EAA2B;AACzBC,MAAAA,WAAW,CACTJ,OADS,EAETN,IAFS,EAGTQ,KAHS,CAAX,CAAA;AAKD,KAAA;AACF,GAAA;AACF,CAAA;;AAMD,SAASE,WAAT,CACEJ,OADF,EAEEK,SAFF,EAGEH,KAHF,EAIE;AACAF,EAAAA,OAAO,CAACG,KAAR,CAAcE,SAAd,IAA2BH,KAA3B,CAAA;AACD,CAAA;;AAED,SAASI,WAAT,CAAqBN,OAArB,EAAwDK,SAAxD,EAA2E;AACzEL,EAAAA,OAAO,CAACG,KAAR,CAAcI,cAAd,CAA6BF,SAA7B,CAAA,CAAA;AACD,CAAA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASG,YAAT,CACLR,OADK,EAELC,MAFK,EAGL;AACA,EAAA,KAAK,IAAIP,IAAT,IAAiBO,MAAjB,EAAyB;AACvB,IAAA,IAAI,OAAOP,IAAP,KAAgB,QAApB,EAA8B,SAAA;AAC9BY,IAAAA,WAAW,CAACN,OAAD,EAAUN,IAAV,CAAX,CAAA;AACD,GAAA;AACF;;;;"}
@@ -0,0 +1,28 @@
1
+ import { Column } from "../../index";
2
+ /**
3
+ * Move the column one position to the left.
4
+ * If the column is first, nothing will happen.
5
+ */
6
+ declare const moveLeft: (column: Column) => number;
7
+ /**
8
+ * Move the column one position to the right.
9
+ * If the column is last, nothing will happen.
10
+ */
11
+ declare const moveRight: (column: Column) => number;
12
+ /**
13
+ * Ask if the column cannot move to the left
14
+ */
15
+ declare const cannotMoveLeft: (column: Column) => boolean;
16
+ /**
17
+ * Ask if the column cannot move to the right
18
+ */
19
+ declare const cannotMoveRight: (column: Column) => boolean;
20
+ /**
21
+ * Ask if the column can move to the left
22
+ */
23
+ declare const canMoveLeft: (column: Column) => boolean;
24
+ /**
25
+ * Ask if the column can move to the right
26
+ */
27
+ declare const canMoveRight: (column: Column) => boolean;
28
+ export { moveLeft, moveRight, cannotMoveLeft, cannotMoveRight, canMoveLeft, canMoveRight };
@@ -0,0 +1,37 @@
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
+ * Move the column one position to the right.
11
+ * If the column is last, nothing will happen.
12
+ */
13
+
14
+ const moveRight = column => meta.forColumn(column, ColumnReordering).moveRight();
15
+ /**
16
+ * Ask if the column cannot move to the left
17
+ */
18
+
19
+ const cannotMoveLeft = column => meta.forColumn(column, ColumnReordering).cannotMoveLeft;
20
+ /**
21
+ * Ask if the column cannot move to the right
22
+ */
23
+
24
+ const cannotMoveRight = column => meta.forColumn(column, ColumnReordering).cannotMoveRight;
25
+ /**
26
+ * Ask if the column can move to the left
27
+ */
28
+
29
+ const canMoveLeft = column => meta.forColumn(column, ColumnReordering).cannotMoveLeft;
30
+ /**
31
+ * Ask if the column can move to the right
32
+ */
33
+
34
+ const canMoveRight = column => meta.forColumn(column, ColumnReordering).cannotMoveRight;
35
+
36
+ export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight };
37
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +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":";;;AAKA;AACA;AACA;AACA;AACaA,MAAAA,QAAQ,GAAIC,MAAD,IAAoBC,IAAI,CAACC,SAAL,CAAeF,MAAf,EAAuBG,gBAAvB,CAAA,CAAyCJ,QAAzC,GAArC;AAEP;AACA;AACA;AACA;;AACaK,MAAAA,SAAS,GAAIJ,MAAD,IAAoBC,IAAI,CAACC,SAAL,CAAeF,MAAf,EAAuBG,gBAAvB,CAAA,CAAyCC,SAAzC,GAAtC;AAEP;AACA;AACA;;AACaC,MAAAA,cAAc,GAAIL,MAAD,IAC5BC,IAAI,CAACC,SAAL,CAAeF,MAAf,EAAuBG,gBAAvB,EAAyCE,eADpC;AAGP;AACA;AACA;;AACaC,MAAAA,eAAe,GAAIN,MAAD,IAC7BC,IAAI,CAACC,SAAL,CAAeF,MAAf,EAAuBG,gBAAvB,EAAyCG,gBADpC;AAGP;AACA;AACA;;AACaC,MAAAA,WAAW,GAAIP,MAAD,IACzBC,IAAI,CAACC,SAAL,CAAeF,MAAf,EAAuBG,gBAAvB,EAAyCE,eADpC;AAGP;AACA;AACA;;AACaG,MAAAA,YAAY,GAAIR,MAAD,IAC1BC,IAAI,CAACC,SAAL,CAAeF,MAAf,EAAuBG,gBAAvB,EAAyCG;;;;"}
@@ -0,0 +1,3 @@
1
+ export * from "./helpers";
2
+ export { ColumnOrder, ColumnReordering, ColumnReordering as Plugin, orderOf } from "./plugin";
3
+ export type { Signature } from "./plugin";
@@ -0,0 +1,3 @@
1
+ export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight } from './helpers.js';
2
+ export { ColumnOrder, ColumnReordering, ColumnReordering as Plugin, orderOf } from './plugin.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,133 @@
1
+ import { TrackedMap } from 'tracked-built-ins';
2
+ import { BasePlugin } from "../-private/base";
3
+ import { PluginPreferences } from "../index";
4
+ import { Column, Table } from "../../index";
5
+ interface ColumnReorderingPreferences extends PluginPreferences {
6
+ table: {
7
+ order?: Record<string, number>;
8
+ };
9
+ }
10
+ declare module "plugins/index" {
11
+ interface Registry {
12
+ ColumnReordering?: ColumnReorderingPreferences;
13
+ }
14
+ }
15
+ interface Signature {
16
+ Meta: {
17
+ Column: ColumnMeta;
18
+ Table: TableMeta;
19
+ };
20
+ }
21
+ declare class ColumnReordering extends BasePlugin<Signature> {
22
+ name: string;
23
+ static features: string[];
24
+ meta: {
25
+ readonly column: typeof ColumnMeta;
26
+ readonly table: typeof TableMeta;
27
+ };
28
+ reset(): void;
29
+ get columns(): Column<unknown>[];
30
+ }
31
+ declare class ColumnMeta {
32
+ #private;
33
+ private column;
34
+ constructor(column: Column);
35
+ get position(): number;
36
+ set position(value: number);
37
+ get canMoveLeft(): boolean;
38
+ get canMoveRight(): boolean;
39
+ get cannotMoveLeft(): boolean;
40
+ get cannotMoveRight(): boolean;
41
+ /**
42
+ * Move the column one spot to the left
43
+ */
44
+ moveLeft: () => number;
45
+ /**
46
+ * Move the column one spot to the right
47
+ */
48
+ moveRight: () => number;
49
+ }
50
+ declare class TableMeta {
51
+ private table;
52
+ constructor(table: Table);
53
+ /**
54
+ * @private
55
+ *
56
+ * We want to maintain the instance of this ColumnOrder class because
57
+ * we allow the consumer of the table to swap out columns at any time.
58
+ * When they do this, we want to maintain the order of the table, best we can.
59
+ * This is also why the order of the columns is maintained via column key
60
+ */
61
+ columnOrder: ColumnOrder;
62
+ getPosition(column: Column): number;
63
+ setPosition(column: Column, newPosition: number): false | undefined;
64
+ /**
65
+ * Revert to default config, delete preferences,
66
+ * and clear the columnOrder
67
+ */
68
+ /**
69
+ * Revert to default config, delete preferences,
70
+ * and clear the columnOrder
71
+ */
72
+ reset(): void;
73
+ /**
74
+ * @private
75
+ */
76
+ /**
77
+ * @private
78
+ */
79
+ save(map: Map<string, number>): void;
80
+ /**
81
+ * @private
82
+ */
83
+ /**
84
+ * @private
85
+ */
86
+ private read;
87
+ get columns(): Column<unknown>[];
88
+ /**
89
+ * @private
90
+ * This isn't our data to expose, but it is useful to alias
91
+ */
92
+ private get availableColumns();
93
+ }
94
+ /**
95
+ * @private
96
+ * Used for keeping track of and updating column order
97
+ */
98
+ declare class ColumnOrder {
99
+ private args;
100
+ /**
101
+ * This map will be empty until we re-order something.
102
+ */
103
+ map: TrackedMap<string, number>;
104
+ constructor(args: {
105
+ columns: () => Column[];
106
+ save: (order: Map<string, number>) => void;
107
+ existingOrder?: Map<string, number>;
108
+ });
109
+ set(key: string, position: number): false | undefined;
110
+ get(key: string): number;
111
+ /**
112
+ * The same as this.map, but with all the columns' information
113
+ */
114
+ 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
+ get orderedColumns(): Column[];
123
+ }
124
+ /**
125
+ * @private
126
+ *
127
+ * Utility for helping determine the percieved order of a set of columns
128
+ * given the original (default) ordering, and then user-configurations
129
+ */
130
+ declare function orderOf(columns: {
131
+ key: string;
132
+ }[], currentOrder: Map<string, number>): Map<string, number>;
133
+ export { Signature, ColumnReordering, ColumnMeta, TableMeta, ColumnOrder, orderOf };