@universal-ember/table 3.0.0 → 3.0.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 (168) hide show
  1. package/dist/-private/-type-tests/plugin-properties.test.js +27 -0
  2. package/dist/-private/-type-tests/plugin-properties.test.js.map +1 -0
  3. package/dist/-private/-type-tests/plugin-with.test.js +20 -0
  4. package/dist/-private/-type-tests/plugin-with.test.js.map +1 -0
  5. package/dist/-private/-type-tests/plugins-accessors.test.js +36 -0
  6. package/dist/-private/-type-tests/plugins-accessors.test.js.map +1 -0
  7. package/dist/-private/-type-tests/plugins-signature-from.test.js +15 -0
  8. package/dist/-private/-type-tests/plugins-signature-from.test.js.map +1 -0
  9. package/dist/-private/-type-tests/plugins-signature-utils.test.js +36 -0
  10. package/dist/-private/-type-tests/plugins-signature-utils.test.js.map +1 -0
  11. package/dist/-private/-type-tests/table-api.test.js +17 -0
  12. package/dist/-private/-type-tests/table-api.test.js.map +1 -0
  13. package/dist/-private/-type-tests/table-config.test.js +55 -0
  14. package/dist/-private/-type-tests/table-config.test.js.map +1 -0
  15. package/dist/-private/column.js +62 -0
  16. package/dist/-private/column.js.map +1 -0
  17. package/dist/-private/ember-compat.js +17 -0
  18. package/dist/-private/ember-compat.js.map +1 -0
  19. package/dist/-private/interfaces/column.js +2 -0
  20. package/dist/-private/interfaces/column.js.map +1 -0
  21. package/dist/-private/interfaces/index.js +2 -0
  22. package/dist/-private/interfaces/index.js.map +1 -0
  23. package/dist/-private/interfaces/modifier.js +2 -0
  24. package/dist/-private/interfaces/modifier.js.map +1 -0
  25. package/dist/-private/interfaces/pagination.js +2 -0
  26. package/dist/-private/interfaces/pagination.js.map +1 -0
  27. package/dist/-private/interfaces/plugins.js +2 -0
  28. package/dist/-private/interfaces/plugins.js.map +1 -0
  29. package/dist/-private/interfaces/preferences.js +2 -0
  30. package/dist/-private/interfaces/preferences.js.map +1 -0
  31. package/dist/-private/interfaces/selection.js +2 -0
  32. package/dist/-private/interfaces/selection.js.map +1 -0
  33. package/dist/-private/interfaces/table.js +2 -0
  34. package/dist/-private/interfaces/table.js.map +1 -0
  35. package/dist/-private/js-helper.js +55 -0
  36. package/dist/-private/js-helper.js.map +1 -0
  37. package/dist/-private/preferences.js +143 -0
  38. package/dist/-private/preferences.js.map +1 -0
  39. package/dist/-private/private-types.js +2 -0
  40. package/dist/-private/private-types.js.map +1 -0
  41. package/dist/-private/row.js +51 -0
  42. package/dist/-private/row.js.map +1 -0
  43. package/dist/-private/table.js +273 -0
  44. package/dist/-private/table.js.map +1 -0
  45. package/dist/-private/utils.js +15 -0
  46. package/dist/-private/utils.js.map +1 -0
  47. package/dist/_rollupPluginBabelHelpers-BpiaYhlf.js +63 -0
  48. package/dist/_rollupPluginBabelHelpers-BpiaYhlf.js.map +1 -0
  49. package/dist/index.js +4 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/plugins/-private/base.js +524 -0
  52. package/dist/plugins/-private/base.js.map +1 -0
  53. package/dist/plugins/-private/utils.js +103 -0
  54. package/dist/plugins/-private/utils.js.map +1 -0
  55. package/dist/plugins/column-reordering/helpers.js +44 -0
  56. package/dist/plugins/column-reordering/helpers.js.map +1 -0
  57. package/dist/plugins/column-reordering/index.js +3 -0
  58. package/dist/plugins/column-reordering/index.js.map +1 -0
  59. package/dist/plugins/column-reordering/plugin.js +359 -0
  60. package/dist/plugins/column-reordering/plugin.js.map +1 -0
  61. package/dist/plugins/column-reordering/utils.js +34 -0
  62. package/dist/plugins/column-reordering/utils.js.map +1 -0
  63. package/dist/plugins/column-resizing/handle.js +241 -0
  64. package/dist/plugins/column-resizing/handle.js.map +1 -0
  65. package/dist/plugins/column-resizing/helpers.js +71 -0
  66. package/dist/plugins/column-resizing/helpers.js.map +1 -0
  67. package/dist/plugins/column-resizing/index.js +4 -0
  68. package/dist/plugins/column-resizing/index.js.map +1 -0
  69. package/dist/plugins/column-resizing/plugin.js +328 -0
  70. package/dist/plugins/column-resizing/plugin.js.map +1 -0
  71. package/dist/plugins/column-resizing/resize-observer.js +44 -0
  72. package/dist/plugins/column-resizing/resize-observer.js.map +1 -0
  73. package/dist/plugins/column-resizing/utils.js +44 -0
  74. package/dist/plugins/column-resizing/utils.js.map +1 -0
  75. package/dist/plugins/column-visibility/helpers.js +25 -0
  76. package/dist/plugins/column-visibility/helpers.js.map +1 -0
  77. package/dist/plugins/column-visibility/index.js +3 -0
  78. package/dist/plugins/column-visibility/index.js.map +1 -0
  79. package/dist/plugins/column-visibility/plugin.js +92 -0
  80. package/dist/plugins/column-visibility/plugin.js.map +1 -0
  81. package/dist/plugins/data-sorting/helpers.js +49 -0
  82. package/dist/plugins/data-sorting/helpers.js.map +1 -0
  83. package/dist/plugins/data-sorting/index.js +4 -0
  84. package/dist/plugins/data-sorting/index.js.map +1 -0
  85. package/dist/plugins/data-sorting/plugin.js +132 -0
  86. package/dist/plugins/data-sorting/plugin.js.map +1 -0
  87. package/dist/plugins/data-sorting/types.js +14 -0
  88. package/dist/plugins/data-sorting/types.js.map +1 -0
  89. package/dist/plugins/index.js +3 -0
  90. package/dist/plugins/index.js.map +1 -0
  91. package/dist/plugins/metadata/helpers.js +12 -0
  92. package/dist/plugins/metadata/helpers.js.map +1 -0
  93. package/dist/plugins/metadata/index.js +3 -0
  94. package/dist/plugins/metadata/index.js.map +1 -0
  95. package/dist/plugins/metadata/plugin.js +25 -0
  96. package/dist/plugins/metadata/plugin.js.map +1 -0
  97. package/dist/plugins/row-selection/helpers.js +10 -0
  98. package/dist/plugins/row-selection/helpers.js.map +1 -0
  99. package/dist/plugins/row-selection/index.js +3 -0
  100. package/dist/plugins/row-selection/index.js.map +1 -0
  101. package/dist/plugins/row-selection/plugin.js +118 -0
  102. package/dist/plugins/row-selection/plugin.js.map +1 -0
  103. package/dist/plugins/sticky-columns/helpers.js +49 -0
  104. package/dist/plugins/sticky-columns/helpers.js.map +1 -0
  105. package/dist/plugins/sticky-columns/index.js +3 -0
  106. package/dist/plugins/sticky-columns/index.js.map +1 -0
  107. package/dist/plugins/sticky-columns/plugin.js +139 -0
  108. package/dist/plugins/sticky-columns/plugin.js.map +1 -0
  109. package/dist/test-support/index.js +62 -0
  110. package/dist/test-support/index.js.map +1 -0
  111. package/dist/utils.js +77 -0
  112. package/dist/utils.js.map +1 -0
  113. package/package.json +3 -2
  114. package/src/-private/-type-tests/plugin-properties.test.ts +38 -0
  115. package/src/-private/-type-tests/plugin-with.test.ts +23 -0
  116. package/src/-private/-type-tests/plugins-accessors.test.ts +86 -0
  117. package/src/-private/-type-tests/plugins-signature-from.test.ts +66 -0
  118. package/src/-private/-type-tests/plugins-signature-utils.test.ts +154 -0
  119. package/src/-private/-type-tests/table-api.test.ts +20 -0
  120. package/src/-private/-type-tests/table-config.test.ts +70 -0
  121. package/src/-private/column.ts +67 -0
  122. package/src/-private/ember-compat.ts +26 -0
  123. package/src/-private/interfaces/column.ts +73 -0
  124. package/src/-private/interfaces/index.ts +7 -0
  125. package/src/-private/interfaces/modifier.ts +7 -0
  126. package/src/-private/interfaces/pagination.ts +13 -0
  127. package/src/-private/interfaces/plugins.ts +349 -0
  128. package/src/-private/interfaces/preferences.ts +82 -0
  129. package/src/-private/interfaces/selection.ts +38 -0
  130. package/src/-private/interfaces/table.ts +121 -0
  131. package/src/-private/js-helper.ts +65 -0
  132. package/src/-private/preferences.ts +176 -0
  133. package/src/-private/private-types.ts +8 -0
  134. package/src/-private/row.ts +66 -0
  135. package/src/-private/table.ts +310 -0
  136. package/src/-private/utils.ts +21 -0
  137. package/src/index.ts +25 -0
  138. package/src/plugins/-private/base.ts +836 -0
  139. package/src/plugins/-private/utils.ts +166 -0
  140. package/src/plugins/column-reordering/helpers.ts +50 -0
  141. package/src/plugins/column-reordering/index.ts +6 -0
  142. package/src/plugins/column-reordering/plugin.ts +489 -0
  143. package/src/plugins/column-reordering/utils.ts +48 -0
  144. package/src/plugins/column-resizing/handle.ts +280 -0
  145. package/src/plugins/column-resizing/helpers.ts +79 -0
  146. package/src/plugins/column-resizing/index.ts +7 -0
  147. package/src/plugins/column-resizing/plugin.ts +490 -0
  148. package/src/plugins/column-resizing/resize-observer.ts +48 -0
  149. package/src/plugins/column-resizing/utils.ts +54 -0
  150. package/src/plugins/column-visibility/helpers.ts +28 -0
  151. package/src/plugins/column-visibility/index.ts +6 -0
  152. package/src/plugins/column-visibility/plugin.ts +155 -0
  153. package/src/plugins/data-sorting/helpers.ts +56 -0
  154. package/src/plugins/data-sorting/index.ts +8 -0
  155. package/src/plugins/data-sorting/plugin.ts +222 -0
  156. package/src/plugins/data-sorting/types.ts +26 -0
  157. package/src/plugins/index.ts +20 -0
  158. package/src/plugins/metadata/helpers.ts +12 -0
  159. package/src/plugins/metadata/index.ts +7 -0
  160. package/src/plugins/metadata/plugin.ts +26 -0
  161. package/src/plugins/row-selection/helpers.ts +13 -0
  162. package/src/plugins/row-selection/index.ts +7 -0
  163. package/src/plugins/row-selection/plugin.ts +218 -0
  164. package/src/plugins/sticky-columns/helpers.ts +59 -0
  165. package/src/plugins/sticky-columns/index.ts +7 -0
  166. package/src/plugins/sticky-columns/plugin.ts +201 -0
  167. package/src/test-support/index.ts +76 -0
  168. package/src/utils.ts +85 -0
@@ -0,0 +1,143 @@
1
+ import { _ as _defineProperty } from '../_rollupPluginBabelHelpers-BpiaYhlf.js';
2
+ import { TrackedMap } from 'tracked-built-ins';
3
+
4
+ class TablePreferences {
5
+ constructor(key, adapter) {
6
+ _defineProperty(this, "storage", new TrackedPreferences());
7
+ this.key = key;
8
+ this.adapter = adapter;
9
+ if (this.adapter) {
10
+ this.restore(this.adapter);
11
+ }
12
+ }
13
+ hasAdapter() {
14
+ return this.adapter !== undefined;
15
+ }
16
+ getIsAtDefault() {
17
+ return this.storage.isAtDefault;
18
+ }
19
+
20
+ /**
21
+ * Passes a JSON-compatible structure to `adapter.persist`
22
+ *
23
+ * This structure could be stored in a remote database or
24
+ * local storage. The `adpater.restore` method can be used to restore
25
+ * this structure back in to the {@link TrackedPreferences }
26
+ */
27
+ persist() {
28
+ return this.adapter?.persist?.(this.key, {
29
+ ...this.storage.serialize()
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Using the `adapter.restore` method, convert the JSON structure
35
+ * to {@link TrackedPreferences }
36
+ */
37
+ restore(adapter) {
38
+ const data = adapter?.restore?.(this.key);
39
+ if (!data) return;
40
+ return this.storage.restore(data);
41
+ }
42
+ }
43
+
44
+ /**
45
+ * @public
46
+ *
47
+ * The API for reactively interacting with preferences
48
+ */
49
+ class TrackedPreferences {
50
+ constructor() {
51
+ _defineProperty(this, "plugins", new Map());
52
+ }
53
+ get isAtDefault() {
54
+ return [...this.plugins.values()].every(pluginPrefs => pluginPrefs.isAtDefault);
55
+ }
56
+ forPlugin(name) {
57
+ let existing = this.plugins.get(name);
58
+ if (!existing) {
59
+ existing = new TrackedPluginPrefs();
60
+ this.plugins.set(name, existing);
61
+ }
62
+ return existing;
63
+ }
64
+ serialize() {
65
+ const plugins = {};
66
+ for (const [pluginName, preferences] of this.plugins.entries()) {
67
+ /**
68
+ * This cast is dirty, and should be fixed eventually.
69
+ * We should be able to, knowing that pluginName
70
+ * will either be in the registry, or be a default PluginPreferences
71
+ * object, that we can assign the serialized structure to plugins.
72
+ */
73
+ plugins[pluginName] = preferences.serialize();
74
+ }
75
+ return {
76
+ plugins
77
+ };
78
+ }
79
+ restore(data) {
80
+ const {
81
+ plugins
82
+ } = data;
83
+ for (const [pluginName, preferences] of Object.entries(plugins || {})) {
84
+ const trackedPluginPrefs = new TrackedPluginPrefs();
85
+ trackedPluginPrefs.restore(preferences);
86
+ this.plugins.set(pluginName, trackedPluginPrefs);
87
+ }
88
+ }
89
+ }
90
+ class TrackedPluginPrefs {
91
+ constructor() {
92
+ _defineProperty(this, "table", new TrackedMap());
93
+ _defineProperty(this, "columns", new Map());
94
+ _defineProperty(this, "forColumn", key => {
95
+ let existing = this.columns.get(key);
96
+ if (!existing) {
97
+ existing = new TrackedMap();
98
+ this.columns.set(key, existing);
99
+ }
100
+ return existing;
101
+ });
102
+ }
103
+ get isAtDefault() {
104
+ return this.table.size === 0 && [...this.columns.values()].every(x => x.size === 0);
105
+ }
106
+ serialize() {
107
+ const columnsPrefs = {};
108
+ const tablePrefs = {};
109
+ for (const [columnKey, preferences] of this.columns.entries()) {
110
+ const serializedPreferences = {};
111
+ for (const [key, preference] of preferences.entries()) {
112
+ serializedPreferences[key] = preference;
113
+ }
114
+ columnsPrefs[columnKey] = serializedPreferences;
115
+ }
116
+ for (const [key, preference] of this.table.entries()) {
117
+ tablePrefs[key] = preference;
118
+ }
119
+ return {
120
+ table: tablePrefs,
121
+ columns: columnsPrefs
122
+ };
123
+ }
124
+ restore(data) {
125
+ const {
126
+ table,
127
+ columns
128
+ } = data;
129
+ for (const [key, preferences] of Object.entries(columns)) {
130
+ const trackedPluginPrefs = new TrackedMap(Object.entries(preferences));
131
+ this.columns.set(key, trackedPluginPrefs);
132
+ }
133
+
134
+ /**
135
+ * TODO: fix the inference here...
136
+ * each time there is a cast, there is a greater risk of runtime error.
137
+ */
138
+ this.table = new TrackedMap(Object.entries(table));
139
+ }
140
+ }
141
+
142
+ export { TablePreferences };
143
+ //# sourceMappingURL=preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.js","sources":["../../src/-private/preferences.ts"],"sourcesContent":["import { TrackedMap } from 'tracked-built-ins';\n\nimport type {\n PluginPreferenceFor,\n PluginPreferences,\n PreferencesAdapter as Adapter,\n PreferencesTableValues,\n TablePreferencesData,\n} from './interfaces';\n\nexport class TablePreferences {\n storage = new TrackedPreferences();\n\n constructor(\n private key: string,\n private adapter?: Adapter,\n ) {\n if (this.adapter) {\n this.restore(this.adapter);\n }\n }\n\n hasAdapter() {\n return this.adapter !== undefined;\n }\n\n getIsAtDefault() {\n return this.storage.isAtDefault;\n }\n\n /**\n * Passes a JSON-compatible structure to `adapter.persist`\n *\n * This structure could be stored in a remote database or\n * local storage. The `adpater.restore` method can be used to restore\n * this structure back in to the {@link TrackedPreferences }\n */\n persist() {\n return this.adapter?.persist?.(this.key, {\n ...this.storage.serialize(),\n });\n }\n\n /**\n * Using the `adapter.restore` method, convert the JSON structure\n * to {@link TrackedPreferences }\n */\n restore(adapter: Adapter) {\n const data = adapter?.restore?.(this.key);\n\n if (!data) return;\n\n return this.storage.restore(data);\n }\n}\n\n/**\n * @public\n *\n * The API for reactively interacting with preferences\n */\nclass TrackedPreferences {\n plugins = new Map<string, TrackedPluginPrefs>();\n\n get isAtDefault(): boolean {\n return [...this.plugins.values()].every(\n (pluginPrefs) => pluginPrefs.isAtDefault,\n );\n }\n\n forPlugin(name: string) {\n let existing = this.plugins.get(name);\n\n if (!existing) {\n existing = new TrackedPluginPrefs();\n this.plugins.set(name, existing);\n }\n\n return existing;\n }\n\n serialize(): TablePreferencesData {\n const plugins: TablePreferencesData['plugins'] = {};\n\n for (const [pluginName, preferences] of this.plugins.entries()) {\n /**\n * This cast is dirty, and should be fixed eventually.\n * We should be able to, knowing that pluginName\n * will either be in the registry, or be a default PluginPreferences\n * object, that we can assign the serialized structure to plugins.\n */\n (plugins as any)[pluginName] = preferences.serialize();\n }\n\n return {\n plugins,\n };\n }\n\n restore(data: TablePreferencesData): void {\n const { plugins } = data;\n\n for (const [pluginName, preferences] of Object.entries(plugins || {})) {\n const trackedPluginPrefs = new TrackedPluginPrefs();\n\n trackedPluginPrefs.restore(preferences);\n\n this.plugins.set(pluginName, trackedPluginPrefs);\n }\n }\n}\n\nclass TrackedPluginPrefs<PluginName = unknown> {\n table = new TrackedMap<string, unknown>();\n columns = new Map<string, TrackedMap<string, unknown>>();\n\n get isAtDefault(): boolean {\n return (\n this.table.size === 0 &&\n [...this.columns.values()].every((x) => x.size === 0)\n );\n }\n\n forColumn = (key: string): TrackedMap<string, unknown> => {\n let existing = this.columns.get(key);\n\n if (!existing) {\n existing = new TrackedMap();\n this.columns.set(key, existing);\n }\n\n return existing;\n };\n\n serialize(): PluginPreferenceFor<PluginName> {\n const columnsPrefs: PluginPreferences['columns'] = {};\n const tablePrefs: PluginPreferences['table'] = {};\n\n for (const [columnKey, preferences] of this.columns.entries()) {\n const serializedPreferences: Record<string, unknown> = {};\n\n for (const [key, preference] of preferences.entries()) {\n serializedPreferences[key] = preference;\n }\n\n columnsPrefs[columnKey] = serializedPreferences;\n }\n\n for (const [key, preference] of this.table.entries()) {\n tablePrefs[key] = preference;\n }\n\n return {\n table: tablePrefs,\n columns: columnsPrefs,\n } as PluginPreferenceFor<PluginName>;\n }\n\n restore(data: PluginPreferences): void {\n const { table, columns } = data;\n\n for (const [key, preferences] of Object.entries(columns)) {\n const trackedPluginPrefs = new TrackedMap(Object.entries(preferences));\n\n this.columns.set(key, trackedPluginPrefs);\n }\n\n /**\n * TODO: fix the inference here...\n * each time there is a cast, there is a greater risk of runtime error.\n */\n this.table = new TrackedMap<string, PreferencesTableValues<PluginName>>(\n Object.entries(table) as [string, PreferencesTableValues<PluginName>][],\n );\n }\n}\n"],"names":["TablePreferences","constructor","key","adapter","_defineProperty","TrackedPreferences","restore","hasAdapter","undefined","getIsAtDefault","storage","isAtDefault","persist","serialize","data","Map","plugins","values","every","pluginPrefs","forPlugin","name","existing","get","TrackedPluginPrefs","set","pluginName","preferences","entries","Object","trackedPluginPrefs","TrackedMap","columns","table","size","x","columnsPrefs","tablePrefs","columnKey","serializedPreferences","preference"],"mappings":";;;AAUO,MAAMA,gBAAgB,CAAC;AAG5BC,EAAAA,WAAWA,CACDC,GAAW,EACXC,OAAiB,EACzB;AAAAC,IAAAA,eAAA,CALQ,IAAA,EAAA,SAAA,EAAA,IAAIC,kBAAkB,EAAE,CAAA;IAAA,IAGxBH,CAAAA,GAAW,GAAXA,GAAW;IAAA,IACXC,CAAAA,OAAiB,GAAjBA,OAAiB;IAEzB,IAAI,IAAI,CAACA,OAAO,EAAE;AAChB,MAAA,IAAI,CAACG,OAAO,CAAC,IAAI,CAACH,OAAO,CAAC;AAC5B;AACF;AAEAI,EAAAA,UAAUA,GAAG;AACX,IAAA,OAAO,I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AAG,CAACvB,GAAG,EAAE4B,kBAAkB,CAAC;AAC3C;;AAEA;AACJ;AACA;AACA;AACI,IAAA,IAAI,CAACG,KAAK,GAAG,IAAIF,UAAU,CACzBF,MAAM,CAACD,OAAO,CAACK,KAAK,CACtB,CAAC;AACH;AACF;;;;"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=private-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ import { a as _applyDecoratedDescriptor, _ as _defineProperty } from '../_rollupPluginBabelHelpers-BpiaYhlf.js';
2
+ import { assert } from '@ember/debug';
3
+ import { action } from '@ember/object';
4
+
5
+ var _class;
6
+ let Row = (_class = class Row {
7
+ get index() {
8
+ const i = this.table.rows.values().indexOf(this);
9
+ assert(`Row is no longer a part of the table, something has gone wrong`, i >= 0);
10
+ return i;
11
+ }
12
+ get isOdd() {
13
+ return this.index % 2 !== 0;
14
+ }
15
+ get next() {
16
+ return this.table.rows[this.index + 1];
17
+ }
18
+ get prev() {
19
+ return this.table.rows[this.index - 1];
20
+ }
21
+ constructor(table, data) {
22
+ _defineProperty(this, "data", void 0);
23
+ _defineProperty(this, "table", void 0);
24
+ this.data = data;
25
+ this.table = table;
26
+ }
27
+ handleClick(event) {
28
+ assert(`expected event.target to be an instance of HTMLElement`, event.target instanceof HTMLElement || event.target instanceof SVGElement);
29
+ const selection = document.getSelection();
30
+ if (selection) {
31
+ const {
32
+ type,
33
+ anchorNode
34
+ } = selection;
35
+ const isSelectingText = type === 'Range' && event.target?.contains(anchorNode);
36
+ if (isSelectingText) {
37
+ event.stopPropagation();
38
+ return;
39
+ }
40
+ }
41
+
42
+ // Ignore clicks on interactive elements within the row
43
+ const inputParent = event.target.closest('input, button, label, a, select');
44
+ if (inputParent) {
45
+ return;
46
+ }
47
+ }
48
+ }, _applyDecoratedDescriptor(_class.prototype, "handleClick", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleClick"), _class.prototype), _class);
49
+
50
+ export { Row };
51
+ //# sourceMappingURL=row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"row.js","sources":["../../src/-private/row.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { action } from '@ember/object';\n\nimport type { Table } from './table';\n\nexport class Row<DataType = Record<string, unknown>> {\n data: DataType;\n table: Table<DataType>;\n\n get index(): number {\n const i = this.table.rows.values().indexOf(this);\n\n assert(\n `Row is no longer a part of the table, something has gone wrong`,\n i >= 0,\n );\n\n return i;\n }\n\n get isOdd() {\n return this.index % 2 !== 0;\n }\n\n get next(): Row<DataType> | undefined {\n return this.table.rows[this.index + 1];\n }\n\n get prev(): Row<DataType> | undefined {\n return this.table.rows[this.index - 1];\n }\n\n constructor(table: Table<DataType>, data: DataType) {\n this.data = data;\n this.table = table;\n }\n\n @action\n handleClick(event: MouseEvent) {\n assert(\n `expected event.target to be an instance of HTMLElement`,\n event.target instanceof HTMLElement || event.target instanceof SVGElement,\n );\n\n const selection = document.getSelection();\n\n if (selection) {\n const { type, anchorNode } = selection;\n const isSelectingText =\n type === 'Range' && event.target?.contains(anchorNode);\n\n if (isSelectingText) {\n event.stopPropagation();\n\n return;\n }\n }\n\n // Ignore clicks on interactive elements within the row\n const inputParent = event.target.closest('input, button, label, a, select');\n\n if (inputParent) {\n return;\n }\n }\n}\n"],"names":["Row","_class","index","i","table","rows","values","indexOf","assert","isOdd","next","prev","constructor","data","_defineProperty","handleClick","event","target","HTMLElement","SVGElement","selection","document","getSelection","type","anchorNode","isSelectingText","contains","stopPropagation","inputParent","closest","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;AAKA,IAAaA,GAAG,IAAAC,MAAA,GAAT,MAAMD,GAAG,CAAqC;EAInD,IAAIE,KAAKA,GAAW;AAClB,IAAA,MAAMC,CAAC,GAAG,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,MAAM,EAAE,CAACC,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AMC,WAAW,GAAGZ,KAAK,CAACC,MAAM,CAACY,OAAO,CAAC,iCAAiC,CAAC;AAE3E,IAAA,IAAID,WAAW,EAAE;AACf,MAAA;AACF;AACF;AACF,CAAC,EAAAE,yBAAA,CAAA7B,MAAA,CAAA8B,SAAA,EAAA,aAAA,EAAA,CA5BEC,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAjC,MAAA,CAAA8B,SAAA,kBAAA9B,MAAA,CAAA8B,SAAA,CAAA,EAAA9B,MAAA;;;;"}
@@ -0,0 +1,273 @@
1
+ import { a as _applyDecoratedDescriptor, _ as _defineProperty, b as _initializerDefineProperty } from '../_rollupPluginBabelHelpers-BpiaYhlf.js';
2
+ import { tracked, cached } from '@glimmer/tracking';
3
+ import { assert } from '@ember/debug';
4
+ import { action } from '@ember/object';
5
+ import { guidFor } from '@ember/object/internals';
6
+ import { macroCondition, isDevelopingApp } from '@embroider/macros';
7
+ import { modifier } from 'ember-modifier';
8
+ import { Resource } from 'ember-modify-based-class-resource';
9
+ import { map } from 'reactiveweb/map';
10
+ import { normalizePluginsConfig, verifyPlugins } from '../plugins/-private/utils.js';
11
+ import { Column } from './column.js';
12
+ import { TablePreferences } from './preferences.js';
13
+ import { Row } from './row.js';
14
+ import { composeFunctionModifiers } from './utils.js';
15
+ import { compatOwner } from './ember-compat.js';
16
+
17
+ var _class, _descriptor, _descriptor2, _descriptor3;
18
+ const getOwner = compatOwner.getOwner;
19
+ const setOwner = compatOwner.setOwner;
20
+ const DEFAULT_COLUMN_CONFIG = {
21
+ isVisible: true,
22
+ minWidth: 128
23
+ };
24
+ /**
25
+ * Because the table is our entry-point object to all the table behaviors,
26
+ * we need a stable way to know which table we have.
27
+ * Normally, this could be done with referential integrity / identity.
28
+ * However, due to how resources are implemented, if the consumer opts to
29
+ * not use the `@use` decorator, then proxies get involved.
30
+ * The proxies don't maintain instanceof checks, which may be a bug in
31
+ * ember-resources.
32
+ */
33
+ const TABLE_KEY = Symbol('__TABLE_KEY__');
34
+ const TABLE_META_KEY = Symbol('__TABLE_META__');
35
+ const COLUMN_META_KEY = Symbol('__COLUMN_META__');
36
+ const ROW_META_KEY = Symbol('__ROW_META__');
37
+ const attachContainer = (element, table) => {
38
+ assert('Must be installed on an HTMLElement', element instanceof HTMLElement);
39
+ table.scrollContainerElement = element;
40
+ };
41
+ let Table = (_class = class Table extends Resource {
42
+ constructor(...args) {
43
+ super(...args);
44
+ /**
45
+ * @private
46
+ */
47
+ _defineProperty(this, TABLE_KEY, guidFor(this));
48
+ /**
49
+ * @private
50
+ */
51
+ _defineProperty(this, TABLE_META_KEY, new Map());
52
+ /**
53
+ * @private
54
+ */
55
+ _defineProperty(this, COLUMN_META_KEY, new WeakMap());
56
+ /**
57
+ * @private
58
+ */
59
+ _defineProperty(this, ROW_META_KEY, new WeakMap());
60
+ /**
61
+ * @private
62
+ *
63
+ * Unused for now, may be used in the future.
64
+ * This data is collected along with the scrollContainerWidth, (which is currently in use)
65
+ */
66
+ _initializerDefineProperty(this, "scrollContainerHeight", _descriptor, this);
67
+ /**
68
+ * @private
69
+ *
70
+ * Used to help determine how much space we can give to columns.
71
+ * As we generate widths for columns, the columns' widths must
72
+ * add up to about this number.
73
+ */
74
+ _initializerDefineProperty(this, "scrollContainerWidth", _descriptor2, this);
75
+ /**
76
+ * @private
77
+ *
78
+ * Lazy way to delay consuming arguments until they are needed.
79
+ */
80
+ _initializerDefineProperty(this, "args", _descriptor3, this);
81
+ /**
82
+ * @private
83
+ */
84
+ _defineProperty(this, "scrollContainerElement", void 0);
85
+ /**
86
+ * Collection of utility modifiers that are the result of composing modifiers
87
+ * from plugins.
88
+ *
89
+ * Using this is optional, and you can "just" use modifiers from specific plugins
90
+ * in specific places if you wish -- but these exists as a "convenience".
91
+ *
92
+ * These are all no-use, no-cost utilities
93
+ */
94
+ _defineProperty(this, "modifiers", {
95
+ container: modifier(element => {
96
+ const modifiers = this.plugins.map(plugin => plugin.containerModifier);
97
+ const composed = composeFunctionModifiers([attachContainer, ...modifiers]);
98
+ return composed(element, this);
99
+ }),
100
+ // resize: ResizeModifier,
101
+ // TODO: switch to composing real modifiers once "curry" and "compose"
102
+ // RFCs are accepted and implemented
103
+ //
104
+ // Atm the moment, if _any_ header modifier's tracked data changes,
105
+ // all the functions for all of the plugins run again.
106
+ //
107
+ // With curried+composed modifiers, only the plugin's headerModifier
108
+ // that has tracked changes would run, leaving the other modifiers alone
109
+ columnHeader: modifier((element, [column]) => {
110
+ const modifiers = this.plugins.map(plugin => plugin.headerCellModifier);
111
+ const composed = composeFunctionModifiers(modifiers);
112
+ return composed(element, {
113
+ column,
114
+ table: this
115
+ });
116
+ }),
117
+ row: modifier((element, [row]) => {
118
+ const modifiers = this.plugins.map(plugin => plugin.rowModifier);
119
+ const composed = composeFunctionModifiers(modifiers);
120
+ return composed(element, {
121
+ row,
122
+ table: this
123
+ });
124
+ })
125
+ });
126
+ _defineProperty(this, "rows", map(this, {
127
+ data: () => {
128
+ const dataFn = this.args.named?.data;
129
+ if (!dataFn) return [];
130
+ return dataFn() ?? [];
131
+ },
132
+ map: datum => new Row(this, datum)
133
+ }));
134
+ _defineProperty(this, "columns", map(this, {
135
+ data: () => {
136
+ const configFn = this.args.named?.columns;
137
+ if (!configFn) return [];
138
+ const result = configFn() ?? [];
139
+ if (macroCondition(isDevelopingApp())) {
140
+ /**
141
+ * Assertions for a column config to be valid:
142
+ * - every key must be unique
143
+ */
144
+ const keys = new Set();
145
+ const allKeys = result.map(columnConfig => columnConfig.key);
146
+ result.forEach(columnConfig => {
147
+ if (keys.has(columnConfig.key)) {
148
+ throw new Error(`Every column key in the table's column config must be unique. ` + `Found duplicate entry: ${columnConfig.key}. ` + `All keys used: ${allKeys}`);
149
+ }
150
+ keys.add(columnConfig.key);
151
+ });
152
+ }
153
+ return result;
154
+ },
155
+ map: config => {
156
+ return new Column(this, {
157
+ ...DEFAULT_COLUMN_CONFIG,
158
+ ...config
159
+ });
160
+ }
161
+ }));
162
+ }
163
+ /**
164
+ * Interact with, save, modify, etc the preferences for the table,
165
+ * plugins, columns, etc
166
+ */
167
+
168
+ /**
169
+ * @private
170
+ */
171
+ modify(_, named) {
172
+ this.args = {
173
+ named
174
+ };
175
+
176
+ // only set the preferences once
177
+ if (!this.preferences) {
178
+ const {
179
+ key = guidFor(this),
180
+ adapter
181
+ } = named?.preferences ?? {};
182
+
183
+ // TODO: when no key is present,
184
+ // use "local-storage" preferences.
185
+ // it does not make sense to use a guid in a user's preferences
186
+ this.preferences = new TablePreferences(key, adapter);
187
+ } else {
188
+ // subsequent updates to args
189
+ this.resetScrollContainer();
190
+ }
191
+ }
192
+ /**
193
+ * @private
194
+ *
195
+ * For all configured plugins, instantiates each one.
196
+ * If the plugins argument changes to the Table (either directly or through
197
+ * headlessTable, all state is lost and re-created)
198
+ */
199
+ get plugins() {
200
+ const plugins = normalizePluginsConfig(this.args.named?.plugins);
201
+ verifyPlugins(plugins);
202
+ return plugins.map(tuple => {
203
+ // We don't need the options here
204
+ const [PluginClass] = tuple;
205
+ if (typeof PluginClass === 'function') {
206
+ const plugin = new PluginClass(this);
207
+ const owner = getOwner(this);
208
+ assert(`The Table does not have an owner. cannot create a plugin without an owner`, owner);
209
+ setOwner(plugin, owner);
210
+ return plugin;
211
+ }
212
+
213
+ // This is a plugin object, rather than a class
214
+ // TODO: add test coverage around using classless plugins
215
+ return PluginClass;
216
+ });
217
+ }
218
+
219
+ /**
220
+ * Get the active plugin instance for the given plugin class
221
+ */
222
+ pluginOf(klass) {
223
+ const result = this.plugins.find(plugin => plugin instanceof klass);
224
+
225
+ /**
226
+ * This is an unsafe cast, because Instance could be unrelated to any of the types
227
+ * that matches Plugin[]
228
+ *
229
+ * For example, `table.pluginOf(MyCustomPlugin)`, where MyCustomPlugin isn't in the
230
+ * `plugins` list. This partially a problem with how Array.prototype.find doesn't
231
+ * effectively narrow for what we want (combined with TS being clunky around
232
+ * comparing Instance and Class types).
233
+ */
234
+ return result;
235
+ }
236
+
237
+ /**
238
+ * @private
239
+ *
240
+ * used by other private APIs
241
+ */
242
+ get config() {
243
+ return this.args.named;
244
+ }
245
+ /**
246
+ * @private
247
+ */
248
+ resetScrollContainer() {
249
+ if (!this.scrollContainerElement) return;
250
+ this.scrollContainerElement.scrollTop = 0;
251
+ }
252
+ resetToDefaults() {
253
+ this.plugins.forEach(plugin => plugin.reset?.());
254
+ }
255
+ }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "scrollContainerHeight", [tracked], {
256
+ configurable: true,
257
+ enumerable: true,
258
+ writable: true,
259
+ initializer: null
260
+ }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "scrollContainerWidth", [tracked], {
261
+ configurable: true,
262
+ enumerable: true,
263
+ writable: true,
264
+ initializer: null
265
+ }), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "args", [tracked], {
266
+ configurable: true,
267
+ enumerable: true,
268
+ writable: true,
269
+ initializer: null
270
+ }), _applyDecoratedDescriptor(_class.prototype, "plugins", [cached], Object.getOwnPropertyDescriptor(_class.prototype, "plugins"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetScrollContainer", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetScrollContainer"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetToDefaults", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetToDefaults"), _class.prototype), _class);
271
+
272
+ export { COLUMN_META_KEY, ROW_META_KEY, TABLE_KEY, TABLE_META_KEY, Table };
273
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.js","sources":["../../src/-private/table.ts"],"sourcesContent":["import { cached, tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { action } from '@ember/object';\nimport { guidFor } from '@ember/object/internals';\n\nimport { isDevelopingApp, macroCondition } from '@embroider/macros';\nimport { modifier } from 'ember-modifier';\nimport { Resource } from 'ember-modify-based-class-resource';\nimport { map } from 'reactiveweb/map';\n\nimport {\n normalizePluginsConfig,\n verifyPlugins,\n} from '../plugins/-private/utils.ts';\nimport { Column } from './column.ts';\nimport { TablePreferences } from './preferences.ts';\nimport { Row } from './row.ts';\nimport { composeFunctionModifiers } from './utils.ts';\n\nimport type { BasePlugin, Plugin } from '../plugins/index.ts';\nimport type { Class } from './private-types.ts';\nimport type { Destructor, TableConfig } from './interfaces';\nimport { compatOwner } from './ember-compat.ts';\n\nconst getOwner = compatOwner.getOwner;\nconst setOwner = compatOwner.setOwner;\n\nconst DEFAULT_COLUMN_CONFIG = {\n isVisible: true,\n minWidth: 128,\n};\n\ninterface Signature<DataType> {\n Named: TableConfig<DataType>;\n}\n\n/**\n * Because the table is our entry-point object to all the table behaviors,\n * we need a stable way to know which table we have.\n * Normally, this could be done with referential integrity / identity.\n * However, due to how resources are implemented, if the consumer opts to\n * not use the `@use` decorator, then proxies get involved.\n * The proxies don't maintain instanceof checks, which may be a bug in\n * ember-resources.\n */\nexport const TABLE_KEY = Symbol('__TABLE_KEY__');\nexport const TABLE_META_KEY = Symbol('__TABLE_META__');\nexport const COLUMN_META_KEY = Symbol('__COLUMN_META__');\nexport const ROW_META_KEY = Symbol('__ROW_META__');\n\nconst attachContainer = (element: Element, table: Table) => {\n assert('Must be installed on an HTMLElement', element instanceof HTMLElement);\n\n table.scrollContainerElement = element;\n};\n\nexport class Table<DataType = unknown> extends Resource<Signature<DataType>> {\n /**\n * @private\n */\n [TABLE_KEY] = guidFor(this);\n /**\n * @private\n */\n [TABLE_META_KEY] = new Map<Class<unknown>, any>();\n /**\n * @private\n */\n [COLUMN_META_KEY] = new WeakMap<Column, Map<Class<unknown>, any>>();\n /**\n * @private\n */\n [ROW_META_KEY] = new WeakMap<Row, Map<Class<unknown>, any>>();\n\n /**\n * @private\n *\n * Unused for now, may be used in the future.\n * This data is collected along with the scrollContainerWidth, (which is currently in use)\n */\n @tracked scrollContainerHeight?: number;\n\n /**\n * @private\n *\n * Used to help determine how much space we can give to columns.\n * As we generate widths for columns, the columns' widths must\n * add up to about this number.\n */\n @tracked scrollContainerWidth?: number;\n\n /**\n * @private\n *\n * Lazy way to delay consuming arguments until they are needed.\n */\n @tracked declare args: { named: Signature<DataType>['Named'] };\n\n /**\n * @private\n */\n scrollContainerElement?: HTMLElement;\n\n /**\n * Interact with, save, modify, etc the preferences for the table,\n * plugins, columns, etc\n */\n declare preferences: TablePreferences;\n\n /**\n * @private\n */\n modify(_: [] | undefined, named: Signature<DataType>['Named']) {\n this.args = { named };\n\n // only set the preferences once\n if (!this.preferences) {\n const { key = guidFor(this), adapter } = named?.preferences ?? {};\n\n // TODO: when no key is present,\n // use \"local-storage\" preferences.\n // it does not make sense to use a guid in a user's preferences\n this.preferences = new TablePreferences(key, adapter);\n } else {\n // subsequent updates to args\n this.resetScrollContainer();\n }\n }\n\n /**\n * Collection of utility modifiers that are the result of composing modifiers\n * from plugins.\n *\n * Using this is optional, and you can \"just\" use modifiers from specific plugins\n * in specific places if you wish -- but these exists as a \"convenience\".\n *\n * These are all no-use, no-cost utilities\n */\n modifiers = {\n container: modifier((element: HTMLElement): Destructor => {\n const modifiers = this.plugins.map((plugin) => plugin.containerModifier);\n const composed = composeFunctionModifiers([\n attachContainer,\n ...modifiers,\n ]);\n\n return composed(element, this as Table<unknown>);\n }),\n\n // resize: ResizeModifier,\n // TODO: switch to composing real modifiers once \"curry\" and \"compose\"\n // RFCs are accepted and implemented\n //\n // Atm the moment, if _any_ header modifier's tracked data changes,\n // all the functions for all of the plugins run again.\n //\n // With curried+composed modifiers, only the plugin's headerModifier\n // that has tracked changes would run, leaving the other modifiers alone\n columnHeader: modifier(\n (element: HTMLElement, [column]: [Column<DataType>]): Destructor => {\n const modifiers = this.plugins.map(\n (plugin) => plugin.headerCellModifier,\n );\n const composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { column, table: this });\n },\n ),\n\n row: modifier(\n (element: HTMLElement, [row]: [Row<DataType>]): Destructor => {\n const modifiers = this.plugins.map((plugin) => plugin.rowModifier);\n const composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { row, table: this });\n },\n ),\n };\n\n /**\n * @private\n *\n * For all configured plugins, instantiates each one.\n * If the plugins argument changes to the Table (either directly or through\n * headlessTable, all state is lost and re-created)\n */\n @cached\n get plugins(): Plugin[] {\n const plugins = normalizePluginsConfig(this.args.named?.plugins);\n\n verifyPlugins(plugins);\n\n return plugins.map((tuple) => {\n // We don't need the options here\n const [PluginClass] = tuple;\n\n if (typeof PluginClass === 'function') {\n const plugin = new PluginClass(this);\n\n const owner = getOwner(this);\n\n assert(\n `The Table does not have an owner. cannot create a plugin without an owner`,\n owner,\n );\n setOwner(plugin, owner);\n\n return plugin;\n }\n\n // This is a plugin object, rather than a class\n // TODO: add test coverage around using classless plugins\n return PluginClass;\n });\n }\n\n /**\n * Get the active plugin instance for the given plugin class\n */\n pluginOf<Instance extends BasePlugin<any>>(\n klass: Class<Instance>,\n ): Instance | undefined {\n const result = this.plugins.find((plugin) => plugin instanceof klass);\n\n /**\n * This is an unsafe cast, because Instance could be unrelated to any of the types\n * that matches Plugin[]\n *\n * For example, `table.pluginOf(MyCustomPlugin)`, where MyCustomPlugin isn't in the\n * `plugins` list. This partially a problem with how Array.prototype.find doesn't\n * effectively narrow for what we want (combined with TS being clunky around\n * comparing Instance and Class types).\n */\n return result as unknown as Instance | undefined;\n }\n\n /**\n * @private\n *\n * used by other private APIs\n */\n get config() {\n return this.args.named;\n }\n\n rows = map(this, {\n data: () => {\n const dataFn = this.args.named?.data;\n\n if (!dataFn) return [];\n\n return dataFn() ?? [];\n },\n map: (datum) => new Row(this, datum),\n });\n\n columns = map(this, {\n data: () => {\n const configFn = this.args.named?.columns;\n\n if (!configFn) return [];\n\n const result = configFn() ?? [];\n\n if (macroCondition(isDevelopingApp())) {\n /**\n * Assertions for a column config to be valid:\n * - every key must be unique\n */\n const keys = new Set();\n const allKeys = result.map((columnConfig) => columnConfig.key);\n\n result.forEach((columnConfig) => {\n if (keys.has(columnConfig.key)) {\n throw new Error(\n `Every column key in the table's column config must be unique. ` +\n `Found duplicate entry: ${columnConfig.key}. ` +\n `All keys used: ${allKeys}`,\n );\n }\n\n keys.add(columnConfig.key);\n });\n }\n\n return result;\n },\n map: (config) => {\n return new Column<DataType>(this, {\n ...DEFAULT_COLUMN_CONFIG,\n ...config,\n });\n },\n });\n\n /**\n * @private\n */\n @action\n resetScrollContainer() {\n if (!this.scrollContainerElement) return;\n\n this.scrollContainerElement.scrollTop = 0;\n }\n\n @action\n resetToDefaults() {\n this.plugins.forEach((plugin) => plugin.reset?.());\n }\n}\n"],"names":["getOwner","compatOwner","setOwner","DEFAULT_COLUMN_CONFIG","isVisible","minWidth","TABLE_KEY","Symbol","TABLE_META_KEY","COLUMN_META_KEY","ROW_META_KEY","attachContainer","element","table","assert","HTMLElement","scrollContainerElement","Table","_class","Resource","constructor","args","_defineProperty","guidFor","Map","WeakMap","_initializerDefineProperty","_descriptor","_descriptor2","_descriptor3","container","modifier","modifiers","plugins","map","plugin","containerModifier","composed","composeFunctionModifiers","columnHeader","column","headerCellModifier","row","rowModifier","data","dataFn","named","datum","Row","configFn","columns","result","macroCondition","isDevelopingApp","keys","Set","allKeys","columnConfig","key","forEach","has","Error","add","config","Column","modify","_","preferences","adapter","TablePreferences","resetScrollContainer","normalizePluginsConfig","verifyPlugins","tuple","PluginClass","owner","pluginOf","klass","find","scrollTop","resetToDefaults","reset","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","cached","Object","getOwnPropertyDescriptor","action"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAMA,QAAQ,GAAGC,WAAW,CAACD,QAAQ;AACrC,MAAME,QAAQ,GAAGD,WAAW,CAACC,QAAQ;AAErC,MAAMC,qBAAqB,GAAG;AAC5BC,EAAAA,SAAS,EAAE,IAAI;AACfC,EAAAA,QAAQ,EAAE;AACZ,CAAC;AAMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaC,SAAS,GAAGC,MAAM,CAAC,eAAe;MAClCC,cAAc,GAA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AA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA,CAAA,EAAAN,yBAAA,CAAAhE,MAAA,CAAAiE,SAAA,EAAA,SAAA,EAAA,CA0FPM,MAAM,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAzE,MAAA,CAAAiE,SAAA,EAAA,SAAA,CAAA,EAAAjE,MAAA,CAAAiE,SAAA,CAAA,EAAAD,yBAAA,CAAAhE,MAAA,CAAAiE,SAAA,EAAA,sBAAA,EAAA,CAgHNS,MAAM,CAAA,EAAAF,MAAA,CAAAC,wBAAA,CAAAzE,MAAA,CAAAiE,SAAA,EAAA,sBAAA,CAAA,EAAAjE,MAAA,CAAAiE,SAAA,CAAA,EAAAD,yBAAA,CAAAhE,MAAA,CAAAiE,SAAA,EAAA,iBAAA,EAAA,CAONS,MAAM,CAAA,EAAAF,MAAA,CAAAC,wBAAA,CAAAzE,MAAA,CAAAiE,SAAA,EAAA,iBAAA,CAAA,EAAAjE,MAAA,CAAAiE,SAAA,CAAA,EAAAjE,MAAA;;;;"}
@@ -0,0 +1,15 @@
1
+ function composeFunctionModifiers(modifiers) {
2
+ const setup = modifiers.filter(Boolean);
3
+ const composed = (element, ...args) => {
4
+ const destructors = setup.map(fn => fn(element, ...args)).filter(Boolean);
5
+ return () => {
6
+ for (const destructor of destructors) {
7
+ destructor();
8
+ }
9
+ };
10
+ };
11
+ return composed;
12
+ }
13
+
14
+ export { composeFunctionModifiers };
15
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../src/-private/utils.ts"],"sourcesContent":["import type { Destructor, FunctionModifier } from './interfaces';\n\nexport function composeFunctionModifiers<Args extends unknown[]>(\n modifiers: Array<FunctionModifier<Args> | undefined>,\n) {\n const setup = modifiers.filter(Boolean) as FunctionModifier<Args>[];\n\n const composed = (element: HTMLElement, ...args: Args) => {\n const destructors = setup\n .map((fn) => fn(element, ...args))\n .filter(Boolean) as Destructor[];\n\n return () => {\n for (const destructor of destructors) {\n destructor();\n }\n };\n };\n\n return composed;\n}\n"],"names":["composeFunctionModifiers","modifiers","setup","filter","Boolean","composed","element","args","destructors","map","fn","destructor"],"mappings":"AAEO,SAASA,wBAAwBA,CACtCC,SAAoD,EACpD;AACA,EAAA,MAAMC,KAAK,GAAGD,SAAS,CAACE,MAAM,CAACC,OAAO,CAA6B;AAEnE,EAAA,MAAMC,QAAQ,GAAGA,CAACC,OAAoB,EAAE,GAAGC,IAAU,KAAK;IACxD,MAAMC,WAAW,GAAGN,KAAK,CACtBO,GAAG,CAAEC,EAAE,IAAKA,EAAE,CAACJ,OAAO,EAAE,GAAGC,IAAI,CAAC,CAAC,CACjCJ,MAAM,CAACC,OAAO,CAAiB;AAElC,IAAA,OAAO,MAAM;AACX,MAAA,KAAK,MAAMO,UAAU,IAAIH,WAAW,EAAE;AACpCG,QAAAA,UAAU,EAAE;AACd;KACD;GACF;AAED,EAAA,OAAON,QAAQ;AACjB;;;;"}
@@ -0,0 +1,63 @@
1
+ function _applyDecoratedDescriptor(i, e, r, n, l) {
2
+ var a = {};
3
+ return Object.keys(n).forEach(function (i) {
4
+ a[i] = n[i];
5
+ }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = true), a = r.slice().reverse().reduce(function (r, n) {
6
+ return n(i, e, r) || r;
7
+ }, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
8
+ }
9
+ function _assertClassBrand(e, t, n) {
10
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
11
+ throw new TypeError("Private element is not present on this object");
12
+ }
13
+ function _checkPrivateRedeclaration(e, t) {
14
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
15
+ }
16
+ function _classPrivateFieldGet2(s, a) {
17
+ return s.get(_assertClassBrand(s, a));
18
+ }
19
+ function _classPrivateFieldInitSpec(e, t, a) {
20
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
21
+ }
22
+ function _classPrivateFieldSet2(s, a, r) {
23
+ return s.set(_assertClassBrand(s, a), r), r;
24
+ }
25
+ function _classPrivateGetter(s, r, a) {
26
+ return a(_assertClassBrand(s, r));
27
+ }
28
+ function _classPrivateMethodInitSpec(e, a) {
29
+ _checkPrivateRedeclaration(e, a), a.add(e);
30
+ }
31
+ function _defineProperty(e, r, t) {
32
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
33
+ value: t,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ }) : e[r] = t, e;
38
+ }
39
+ function _initializerDefineProperty(e, i, r, l) {
40
+ r && Object.defineProperty(e, i, {
41
+ enumerable: r.enumerable,
42
+ configurable: r.configurable,
43
+ writable: r.writable,
44
+ value: r.initializer ? r.initializer.call(l) : void 0
45
+ });
46
+ }
47
+ function _toPrimitive(t, r) {
48
+ if ("object" != typeof t || !t) return t;
49
+ var e = t[Symbol.toPrimitive];
50
+ if (void 0 !== e) {
51
+ var i = e.call(t, r);
52
+ if ("object" != typeof i) return i;
53
+ throw new TypeError("@@toPrimitive must return a primitive value.");
54
+ }
55
+ return ("string" === r ? String : Number)(t);
56
+ }
57
+ function _toPropertyKey(t) {
58
+ var i = _toPrimitive(t, "string");
59
+ return "symbol" == typeof i ? i : i + "";
60
+ }
61
+
62
+ export { _defineProperty as _, _applyDecoratedDescriptor as a, _initializerDefineProperty as b, _classPrivateMethodInitSpec as c, _classPrivateGetter as d, _classPrivateFieldGet2 as e, _classPrivateFieldInitSpec as f, _classPrivateFieldSet2 as g };
63
+ //# sourceMappingURL=_rollupPluginBabelHelpers-BpiaYhlf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_rollupPluginBabelHelpers-BpiaYhlf.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { headlessTable, headlessTable as table } from './-private/js-helper.js';
2
+ export { TablePreferences } from './-private/preferences.js';
3
+ export { deserializeSorts, serializeSorts } from './utils.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}