ember-headless-table 1.1.0 → 1.2.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 (93) hide show
  1. package/LICENSE.md +9 -0
  2. package/dist/-private/-type-tests/plugin-properties.test.js +4 -8
  3. package/dist/-private/-type-tests/plugin-properties.test.js.map +1 -1
  4. package/dist/-private/-type-tests/plugin-with.test.js.map +1 -1
  5. package/dist/-private/-type-tests/plugins-accessors.test.js +12 -11
  6. package/dist/-private/-type-tests/plugins-accessors.test.js.map +1 -1
  7. package/dist/-private/-type-tests/plugins-signature-from.test.js +7 -6
  8. package/dist/-private/-type-tests/plugins-signature-from.test.js.map +1 -1
  9. package/dist/-private/-type-tests/plugins-signature-utils.test.js.map +1 -1
  10. package/dist/-private/-type-tests/table-api.test.js +3 -2
  11. package/dist/-private/-type-tests/table-api.test.js.map +1 -1
  12. package/dist/-private/-type-tests/table-config.test.js +8 -11
  13. package/dist/-private/-type-tests/table-config.test.js.map +1 -1
  14. package/dist/-private/column.d.ts +1 -1
  15. package/dist/-private/column.js +7 -15
  16. package/dist/-private/column.js.map +1 -1
  17. package/dist/-private/js-helper.d.ts +1 -1
  18. package/dist/-private/js-helper.js +2 -3
  19. package/dist/-private/js-helper.js.map +1 -1
  20. package/dist/-private/preferences.js +7 -39
  21. package/dist/-private/preferences.js.map +1 -1
  22. package/dist/-private/row.d.ts +1 -1
  23. package/dist/-private/row.js +4 -15
  24. package/dist/-private/row.js.map +1 -1
  25. package/dist/-private/table.js +3 -3
  26. package/dist/-private/utils.js +0 -2
  27. package/dist/-private/utils.js.map +1 -1
  28. package/dist/{applyDecoratedDescriptor-e0489e2f.js → applyDecoratedDescriptor-6b986a67.js} +1 -6
  29. package/dist/applyDecoratedDescriptor-6b986a67.js.map +1 -0
  30. package/dist/{classPrivateFieldGet-af59a8ea.js → classPrivateFieldGet-b4d7d334.js} +1 -3
  31. package/dist/{classPrivateFieldGet-af59a8ea.js.map → classPrivateFieldGet-b4d7d334.js.map} +1 -1
  32. package/dist/{defineProperty-a0196711.js → defineProperty-35ce617b.js} +1 -2
  33. package/dist/defineProperty-35ce617b.js.map +1 -0
  34. package/dist/index.d.ts +1 -1
  35. package/dist/plugins/-private/base.d.ts +1 -1
  36. package/dist/plugins/-private/base.js +18 -59
  37. package/dist/plugins/-private/base.js.map +1 -1
  38. package/dist/plugins/-private/utils.js +5 -20
  39. package/dist/plugins/-private/utils.js.map +1 -1
  40. package/dist/plugins/column-reordering/helpers.d.ts +9 -4
  41. package/dist/plugins/column-reordering/helpers.js +13 -6
  42. package/dist/plugins/column-reordering/helpers.js.map +1 -1
  43. package/dist/plugins/column-reordering/index.js +1 -1
  44. package/dist/plugins/column-reordering/plugin.d.ts +57 -11
  45. package/dist/plugins/column-reordering/plugin.js +109 -130
  46. package/dist/plugins/column-reordering/plugin.js.map +1 -1
  47. package/dist/plugins/column-reordering/utils.js +0 -7
  48. package/dist/plugins/column-reordering/utils.js.map +1 -1
  49. package/dist/plugins/column-resizing/handle.js +4 -33
  50. package/dist/plugins/column-resizing/handle.js.map +1 -1
  51. package/dist/plugins/column-resizing/helpers.js +2 -2
  52. package/dist/plugins/column-resizing/helpers.js.map +1 -1
  53. package/dist/plugins/column-resizing/plugin.js +15 -64
  54. package/dist/plugins/column-resizing/plugin.js.map +1 -1
  55. package/dist/plugins/column-resizing/resize-observer.js +1 -3
  56. package/dist/plugins/column-resizing/resize-observer.js.map +1 -1
  57. package/dist/plugins/column-resizing/utils.js +0 -2
  58. package/dist/plugins/column-resizing/utils.js.map +1 -1
  59. package/dist/plugins/column-visibility/helpers.js +3 -3
  60. package/dist/plugins/column-visibility/helpers.js.map +1 -1
  61. package/dist/plugins/column-visibility/plugin.js +6 -26
  62. package/dist/plugins/column-visibility/plugin.js.map +1 -1
  63. package/dist/plugins/data-sorting/helpers.js +7 -7
  64. package/dist/plugins/data-sorting/helpers.js.map +1 -1
  65. package/dist/plugins/data-sorting/plugin.js +2 -32
  66. package/dist/plugins/data-sorting/plugin.js.map +1 -1
  67. package/dist/plugins/data-sorting/types.js +0 -3
  68. package/dist/plugins/data-sorting/types.js.map +1 -1
  69. package/dist/plugins/metadata/helpers.d.ts +4 -0
  70. package/dist/plugins/metadata/helpers.js +12 -0
  71. package/dist/plugins/metadata/helpers.js.map +1 -0
  72. package/dist/plugins/metadata/index.d.ts +3 -0
  73. package/dist/plugins/metadata/index.js +3 -0
  74. package/dist/plugins/metadata/index.js.map +1 -0
  75. package/dist/plugins/metadata/plugin.d.ts +24 -0
  76. package/dist/plugins/metadata/plugin.js +25 -0
  77. package/dist/plugins/metadata/plugin.js.map +1 -0
  78. package/dist/plugins/row-selection/helpers.js.map +1 -1
  79. package/dist/plugins/row-selection/plugin.js +5 -42
  80. package/dist/plugins/row-selection/plugin.js.map +1 -1
  81. package/dist/plugins/sticky-columns/helpers.js.map +1 -1
  82. package/dist/plugins/sticky-columns/plugin.js +4 -28
  83. package/dist/plugins/sticky-columns/plugin.js.map +1 -1
  84. package/dist/{table-8e46554b.d.ts → table-222f44e7.d.ts} +0 -0
  85. package/dist/{table-8e46554b.js → table-222f44e7.js} +17 -33
  86. package/dist/{table-8e46554b.js.map → table-222f44e7.js.map} +1 -1
  87. package/dist/test-support/index.js +2 -6
  88. package/dist/test-support/index.js.map +1 -1
  89. package/dist/utils.js +2 -5
  90. package/dist/utils.js.map +1 -1
  91. package/package.json +18 -32
  92. package/dist/applyDecoratedDescriptor-e0489e2f.js.map +0 -1
  93. package/dist/defineProperty-a0196711.js.map +0 -1
@@ -1,12 +1,11 @@
1
- import { _ as _defineProperty } from '../../defineProperty-a0196711.js';
1
+ import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
2
2
  import { assert } from '@ember/debug';
3
- import { T as TABLE_KEY } from '../../table-8e46554b.js';
3
+ import { T as TABLE_KEY } from '../../table-222f44e7.js';
4
4
  import { normalizePluginsConfig } from './utils.js';
5
5
 
6
6
  const TABLE_META = new Map();
7
7
  const COLUMN_META = new WeakMap();
8
8
  const ROW_META = new WeakMap();
9
-
10
9
  /**
11
10
  * @public
12
11
  *
@@ -19,9 +18,9 @@ const ROW_META = new WeakMap();
19
18
  class BasePlugin {
20
19
  constructor(table) {
21
20
  _defineProperty(this, "name", void 0);
22
-
23
21
  this.table = table;
24
22
  }
23
+
25
24
  /**
26
25
  * @private (secret)
27
26
  *
@@ -32,29 +31,23 @@ class BasePlugin {
32
31
  * with the SignatureFrom utility above
33
32
  */
34
33
 
35
-
36
34
  /**
37
35
  * Helper for specifying plugins on `headlessTable` with the plugin-level options
38
36
  */
39
37
  static with(configFn) {
40
38
  return [this, configFn];
41
39
  }
40
+
42
41
  /**
43
42
  * Helper for specifying column-level configurations for a plugin on `headlessTable`'s
44
43
  * columns option
45
44
  */
46
-
47
-
48
45
  static forColumn(configFn) {
49
46
  return [this, configFn];
50
47
  }
51
-
52
48
  }
53
-
54
49
  _defineProperty(BasePlugin, "features", void 0);
55
-
56
50
  _defineProperty(BasePlugin, "requires", void 0);
57
-
58
51
  const preferences = {
59
52
  /**
60
53
  * @public
@@ -78,7 +71,6 @@ const preferences = {
78
71
  columnPrefs.delete(key);
79
72
  return prefs.persist();
80
73
  },
81
-
82
74
  /**
83
75
  * get an entry on the underlying `Map` used for this column-plugin pair
84
76
  */
@@ -88,7 +80,6 @@ const preferences = {
88
80
  let columnPrefs = existing.forColumn(column.key);
89
81
  return columnPrefs.get(key);
90
82
  },
91
-
92
83
  /**
93
84
  * set an entry on the underlying `Map` used for this column-plugin pair
94
85
  */
@@ -99,10 +90,8 @@ const preferences = {
99
90
  columnPrefs.set(key, value);
100
91
  prefs.persist();
101
92
  }
102
-
103
93
  };
104
94
  },
105
-
106
95
  /**
107
96
  * @public
108
97
  *
@@ -124,7 +113,6 @@ const preferences = {
124
113
  existing.table.delete(key);
125
114
  return prefs.persist();
126
115
  },
127
-
128
116
  /**
129
117
  * get an entry on the underlying `Map` used for this column-plugin pair
130
118
  */
@@ -133,7 +121,6 @@ const preferences = {
133
121
  let existing = prefs.storage.forPlugin(klass.name);
134
122
  return existing.table.get(key);
135
123
  },
136
-
137
124
  /**
138
125
  * set an entry on the underlying `Map` used for this column-plugin pair
139
126
  */
@@ -143,11 +130,10 @@ const preferences = {
143
130
  existing.table.set(key, value);
144
131
  return prefs.persist();
145
132
  }
146
-
147
133
  };
148
134
  }
149
-
150
135
  };
136
+
151
137
  /**
152
138
  * if a `requester` is not provided,
153
139
  * Get the columns for the table, considering any and all plugins that could modify columns.
@@ -165,63 +151,54 @@ const preferences = {
165
151
  * This works recursively up the plugin tree up until a plugin has no requirements, and then
166
152
  * all columns from the table are returned.
167
153
  */
168
-
169
154
  function columnsFor(table, requester) {
170
155
  assert(`First argument passed to columns.for must be an instance of Table`, table[TABLE_KEY]);
171
156
  let visibility = findPlugin(table.plugins, 'columnVisibility');
172
- let reordering = findPlugin(table.plugins, 'columnOrder'); // TODO: actually resolve the graph, rather than use the hardcoded feature names
157
+ let reordering = findPlugin(table.plugins, 'columnOrder');
158
+
159
+ // TODO: actually resolve the graph, rather than use the hardcoded feature names
173
160
  // atm, this only "happens" to work based on expectations of
174
161
  // of the currently implemented plugins' capabilities and implied hierarchy.
175
162
 
176
163
  if (requester) {
177
164
  assert(`[${requester.name}] requested columns from the table, but the plugin, ${requester.name}, ` + `is not used in this table`, table.plugins.some(plugin => plugin instanceof requester));
178
-
179
165
  if (visibility && visibility.constructor === requester) {
180
166
  return table.columns.values();
181
167
  }
182
-
183
168
  if (reordering && reordering.constructor === requester) {
184
169
  if (visibility) {
185
170
  assert(`<#${visibility.name}> defined a 'columns' property, but did not return valid data.`, visibility.columns && Array.isArray(visibility.columns));
186
171
  return visibility.columns;
187
172
  }
188
-
189
173
  return table.columns.values();
190
174
  }
191
-
192
175
  if (reordering) {
193
176
  assert(`<#${reordering.name}> defined a 'columns' property, but did not return valid data.`, reordering.columns && Array.isArray(reordering.columns));
194
177
  return reordering.columns;
195
178
  }
196
-
197
179
  if (visibility) {
198
180
  assert(`<#${visibility.name}> defined a 'columns' property, but did not return valid data.`, visibility.columns && Array.isArray(visibility.columns));
199
181
  return visibility.columns;
200
182
  }
201
-
202
183
  return table.columns.values();
203
184
  }
185
+
204
186
  /**
205
187
  * This flow is the inverse of when we have a requester
206
188
  */
207
189
 
208
-
209
190
  if (reordering) {
210
191
  assert(`<#${reordering.name}> defined a 'columns' property, but did not return valid data.`, reordering.columns && Array.isArray(reordering.columns));
211
192
  return reordering.columns;
212
193
  }
213
-
214
194
  if (visibility) {
215
195
  assert(`<#${visibility.name}> defined a 'columns' property, but did not return valid data.`, visibility.columns && Array.isArray(visibility.columns));
216
196
  return visibility.columns;
217
197
  }
218
-
219
198
  return table.columns.values();
220
199
  }
221
-
222
200
  const columns = {
223
201
  for: columnsFor,
224
-
225
202
  /**
226
203
  * for a given current or reference column, return the column that
227
204
  * is immediately next, or to the right of that column.
@@ -233,17 +210,15 @@ const columns = {
233
210
  let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);
234
211
  let referenceIndex = columns.indexOf(current);
235
212
  assert(`index of reference column must be >= 0. column likely not a part of the table`, referenceIndex >= 0);
213
+
236
214
  /**
237
215
  * There can be nothing after the last column
238
216
  */
239
-
240
217
  if (referenceIndex >= columns.length - 1) {
241
218
  return undefined;
242
219
  }
243
-
244
220
  return columns[referenceIndex + 1];
245
221
  },
246
-
247
222
  /**
248
223
  * for a given current or reference column, return the column that
249
224
  * is immediately previous, or to the left of that column.
@@ -255,17 +230,15 @@ const columns = {
255
230
  let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);
256
231
  let referenceIndex = columns.indexOf(current);
257
232
  assert(`index of reference column must be >= 0. column likely not a part of the table`, referenceIndex >= 0);
233
+
258
234
  /**
259
235
  * There can be nothing before the first column
260
236
  */
261
-
262
237
  if (referenceIndex === 0) {
263
238
  return undefined;
264
239
  }
265
-
266
240
  return columns[referenceIndex - 1];
267
241
  },
268
-
269
242
  /**
270
243
  * for a given current or reference column, return the columns that
271
244
  * should appear before, or to the left of that column.
@@ -278,7 +251,6 @@ const columns = {
278
251
  let referenceIndex = columns.indexOf(current);
279
252
  return columns.slice(0, referenceIndex);
280
253
  },
281
-
282
254
  /**
283
255
  * for a given current or reference column, return the columns that
284
256
  * should appear after, or to the right of that column.
@@ -310,7 +282,6 @@ const meta = {
310
282
  return new plugin.meta.column(column);
311
283
  });
312
284
  },
313
-
314
285
  /**
315
286
  * @public
316
287
  *
@@ -328,7 +299,6 @@ const meta = {
328
299
  return new plugin.meta.row(row);
329
300
  });
330
301
  },
331
-
332
302
  /**
333
303
  * @public
334
304
  *
@@ -345,7 +315,6 @@ const meta = {
345
315
  return new plugin.meta.table(table);
346
316
  });
347
317
  },
348
-
349
318
  /**
350
319
  * Instead of finding meta based on column or table instances,
351
320
  * you can search for meta based on feature strings, such as `columnWidth`
@@ -365,11 +334,11 @@ const meta = {
365
334
  plugins
366
335
  } = column.table;
367
336
  let provider = findPlugin(plugins, featureName);
368
- assert(`Could not find plugin with feature: ${featureName}. ` + `Available features: ${availableFeatures(plugins)}`, provider); // TS doesn't believe in the constructor property?
337
+ assert(`Could not find plugin with feature: ${featureName}. ` + `Available features: ${availableFeatures(plugins)}`, provider);
369
338
 
339
+ // TS doesn't believe in the constructor property?
370
340
  return meta.forColumn(column, provider.constructor);
371
341
  },
372
-
373
342
  /**
374
343
  * @public
375
344
  *
@@ -384,14 +353,13 @@ const meta = {
384
353
  plugins
385
354
  } = table;
386
355
  let provider = findPlugin(plugins, featureName);
387
- assert(`Could not find plugin with feature: ${featureName}. ` + `Available features: ${availableFeatures(plugins)}`, provider); // TS doesn't believe in the constructor property?
356
+ assert(`Could not find plugin with feature: ${featureName}. ` + `Available features: ${availableFeatures(plugins)}`, provider);
388
357
 
358
+ // TS doesn't believe in the constructor property?
389
359
  return meta.forTable(table, provider.constructor);
390
360
  }
391
-
392
361
  }
393
362
  };
394
-
395
363
  function findPlugin(plugins, featureName) {
396
364
  let provider = plugins.find(plugin => {
397
365
  /*
@@ -405,7 +373,6 @@ function findPlugin(plugins, featureName) {
405
373
  });
406
374
  return provider;
407
375
  }
408
-
409
376
  function availableFeatures(plugins) {
410
377
  let allFeatures = plugins.map(plugin => {
411
378
  /*
@@ -419,7 +386,6 @@ function availableFeatures(plugins) {
419
386
  }).flat().filter(Boolean);
420
387
  return allFeatures.length > 0 ? allFeatures.join(', ') : '[none]';
421
388
  }
422
-
423
389
  const options = {
424
390
  /**
425
391
  * @public
@@ -430,13 +396,13 @@ const options = {
430
396
  forTable(table, klass) {
431
397
  let normalized = normalizePluginsConfig(table?.config?.plugins);
432
398
  let tuple = normalized?.find(option => option[0] === klass);
433
- let t = tuple; // Plugin not provided, likely
399
+ let t = tuple;
434
400
 
401
+ // Plugin not provided, likely
435
402
  if (!t) return {};
436
403
  let fn = t[1];
437
404
  return fn() ?? {};
438
405
  },
439
-
440
406
  forColumn(column, klass) {
441
407
  let tuple = column.config.pluginOptions?.find(option => option[0] === klass);
442
408
  let t = tuple;
@@ -444,19 +410,16 @@ const options = {
444
410
  if (!fn) return {};
445
411
  return fn() ?? {};
446
412
  }
447
-
448
413
  };
414
+
449
415
  /**
450
416
  * @private
451
417
  */
452
-
453
418
  function getPluginInstance(map, rootKey, mapKey, factory) {
454
419
  let bucket;
455
-
456
420
  if (map instanceof WeakMap) {
457
421
  assert(`Cannot use string key with WeakMap`, typeof rootKey !== 'string');
458
422
  bucket = map.get(rootKey);
459
-
460
423
  if (!bucket) {
461
424
  bucket = new Map();
462
425
  map.set(rootKey, bucket);
@@ -464,19 +427,15 @@ function getPluginInstance(map, rootKey, mapKey, factory) {
464
427
  } else {
465
428
  assert(`Cannot use object key with Map`, typeof rootKey === 'string');
466
429
  bucket = map.get(rootKey);
467
-
468
430
  if (!bucket) {
469
431
  bucket = new Map();
470
432
  map.set(rootKey, bucket);
471
433
  }
472
434
  }
473
-
474
435
  let instance = bucket.get(mapKey);
475
-
476
436
  if (instance) {
477
437
  return instance;
478
438
  }
479
-
480
439
  instance = factory();
481
440
  bucket.set(mapKey, instance);
482
441
  return instance;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sources":["../../../src/plugins/-private/base.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { TABLE_KEY } from '../../-private/table';\nimport { normalizePluginsConfig } from './utils';\n\nimport type { Table } from '../../-private/table';\nimport type { ColumnReordering } from '../column-reordering';\nimport type { ColumnVisibility } from '../column-visibility';\nimport type { Class, Constructor } from '[private-types]';\nimport type { Column, Row } from '[public-types]';\nimport type {\n ColumnMetaFor,\n ColumnOptionsFor,\n OptionsFor,\n Plugin,\n RowMetaFor,\n TableMetaFor,\n} from '#interfaces';\n\nconst TABLE_META = new Map<string, Map<Class<unknown>, any>>();\nconst COLUMN_META = new WeakMap<Column, Map<Class<unknown>, any>>();\nconst ROW_META = new WeakMap<Row, Map<Class<unknown>, any>>();\n\ntype InstanceOf<T> = T extends Class<infer Instance> ? Instance : T;\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface TableFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the table meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['table']>;\n /**\n * @public\n *\n * interface for the table meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['table']>;\n}\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface ColumnFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the column meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['column']>;\n /**\n * @public\n *\n * interface for the column meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['column']>;\n}\n\n/**\n * @private utility type\n *\n */\nexport type SignatureFrom<Klass extends BasePlugin<any>> = Klass extends BasePlugin<infer Signature>\n ? Signature\n : never;\n\ndeclare const __Signature__: unique symbol;\n\n/**\n * @public\n *\n * If your table plugin is a class, you may extend from BasePlugin, which provides\n * small utility methods and properties for getting the metadata for your plugin\n * for the table and each column\n *\n * One instance of a plugin exists per table\n */\nexport abstract class BasePlugin<Signature = unknown> implements Plugin<Signature> {\n constructor(protected table: Table) {}\n\n /**\n * @private (secret)\n *\n * Because classes are kind of like interfaces,\n * we need \"something\" to help TS know what a Resource is.\n *\n * This isn't a real API, but does help with type inference\n * with the SignatureFrom utility above\n */\n declare [__Signature__]: Signature;\n\n /**\n * Helper for specifying plugins on `headlessTable` with the plugin-level options\n */\n static with<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => OptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => OptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n /**\n * Helper for specifying column-level configurations for a plugin on `headlessTable`'s\n * columns option\n */\n static forColumn<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => ColumnOptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => ColumnOptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n declare meta?: {\n column?: Constructor<ColumnMetaFor<Signature>>;\n table?: Constructor<TableMetaFor<Signature>>;\n row?: Constructor<RowMetaFor<Signature>>;\n };\n\n abstract name: string;\n static features?: string[];\n static requires?: string[];\n}\n\nexport const preferences = {\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the column (scoped to key)\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(column: Column<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n return columnPrefs.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.set(key, value);\n\n prefs.persist();\n },\n };\n },\n\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the table (scoped to the key: \"table\")\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n return existing.table.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.set(key, value);\n\n return prefs.persist();\n },\n };\n },\n};\n\n/**\n * if a `requester` is not provided,\n * Get the columns for the table, considering any and all plugins that could modify columns.\n *\n * If you are an end-consumer of ember-headless-table, this is the function to use.\n * If you are a plugin-author, you'll want to pass your plugin class as the second parameter.\n *\n * For a given plugin, `requester`, determine what columns should be returned.\n * Since multiple plugins could be used in a table, there is an implicit hierarchy of\n * column modifications that can occur from each of those plugins.\n *\n * If a plugin defines other plugins as either *requirements* or *optional requirements*,\n * and that upstream plugin defines a `columns` property, then those columns will be returned here.\n *\n * This works recursively up the plugin tree up until a plugin has no requirements, and then\n * all columns from the table are returned.\n */\nfunction columnsFor<DataType = any>(\n table: Table<DataType>,\n requester?: Plugin<any> | undefined\n): Column<DataType>[] {\n assert(`First argument passed to columns.for must be an instance of Table`, table[TABLE_KEY]);\n\n let visibility = findPlugin(table.plugins, 'columnVisibility');\n let reordering = findPlugin(table.plugins, 'columnOrder');\n\n // TODO: actually resolve the graph, rather than use the hardcoded feature names\n // atm, this only \"happens\" to work based on expectations of\n // of the currently implemented plugins' capabilities and implied hierarchy.\n\n if (requester) {\n assert(\n `[${requester.name}] requested columns from the table, but the plugin, ${requester.name}, ` +\n `is not used in this table`,\n table.plugins.some((plugin) => plugin instanceof (requester as Class<Plugin>))\n );\n\n if (visibility && visibility.constructor === requester) {\n return table.columns.values();\n }\n\n if (reordering && reordering.constructor === requester) {\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n /**\n * This flow is the inverse of when we have a requester\n */\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n}\n\nexport const columns = {\n for: columnsFor,\n\n /**\n * for a given current or reference column, return the column that\n * is immediately next, or to the right of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n next: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing after the last column\n */\n if (referenceIndex >= columns.length - 1) {\n return undefined;\n }\n\n return columns[referenceIndex + 1];\n },\n\n /**\n * for a given current or reference column, return the column that\n * is immediately previous, or to the left of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n previous: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing before the first column\n */\n if (referenceIndex === 0) {\n return undefined;\n }\n\n return columns[referenceIndex - 1];\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear before, or to the left of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n before: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(0, referenceIndex);\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear after, or to the right of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n after: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(referenceIndex + 1);\n },\n};\n\nexport const meta = {\n /**\n * @public\n *\n * For a given column and plugin, return the meta / state bucket for the\n * plugin<->column instance pair.\n *\n * Note that this requires the column instance to exist on the table.\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): ColumnMetaFor<SignatureFrom<P>> {\n return getPluginInstance(COLUMN_META, column, klass, () => {\n let plugin = column.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify column meta`, plugin.meta.column);\n\n return new plugin.meta.column(column);\n });\n },\n\n /**\n * @public\n *\n * For a given row and plugin, return the meta / state bucket for the\n * plugin<->row instance pair.\n *\n * Note that this requires the row instance to exist on the table.\n */\n forRow<P extends BasePlugin<any>, Data = unknown>(\n row: Row<Data>,\n klass: Class<P>\n ): RowMetaFor<SignatureFrom<P>> {\n return getPluginInstance(ROW_META, row, klass, () => {\n let plugin = row.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify row meta`, plugin.meta.row);\n\n return new plugin.meta.row(row);\n });\n },\n\n /**\n * @public\n *\n * For a given table and plugin, return the meta / state bucket for the\n * plugin<->table instance pair.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): TableMetaFor<SignatureFrom<P>> {\n return getPluginInstance(TABLE_META, table[TABLE_KEY], klass, () => {\n let plugin = table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify table meta`, plugin.meta.table);\n assert(\n `<#${plugin.name}> plugin already exists for the table. ` +\n `A plugin may only be instantiated once per table.`,\n ![...(TABLE_META.get(table[TABLE_KEY])?.keys() ?? [])].includes(klass)\n );\n\n return new plugin.meta.table(table);\n });\n },\n\n /**\n * Instead of finding meta based on column or table instances,\n * you can search for meta based on feature strings, such as `columnWidth`\n */\n withFeature: {\n /**\n * @public\n *\n * for a given column and feature name, return the \"ColumnMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care which\n * plugin is providing what behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility\n */\n forColumn<FeatureName extends string, Data = unknown>(\n column: Column<Data>,\n featureName: FeatureName\n ): ColumnFeatures[FeatureName] {\n let { plugins } = column.table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forColumn(column, (provider as any).constructor);\n },\n\n /**\n * @public\n *\n * for a given table and feature name, return the \"TableMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care\n * which plugin is providing that behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility.\n */\n forTable<FeatureName extends string, Data = unknown>(\n table: Table<Data>,\n featureName: FeatureName\n ): TableFeatures[FeatureName] {\n let { plugins } = table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forTable(table, (provider as any).constructor);\n },\n },\n};\n\nfunction findPlugin(plugins: Plugin[], featureName: string) {\n let provider = plugins.find((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features?.includes(featureName);\n });\n\n return provider;\n}\n\nfunction availableFeatures(plugins: Plugin[]): string {\n let allFeatures = plugins\n .map((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features;\n })\n .flat()\n .filter(Boolean);\n\n return allFeatures.length > 0 ? allFeatures.join(', ') : '[none]';\n}\n\nexport const options = {\n /**\n * @public\n *\n * For a given table and plugin, return the options, if any were given from the user\n * during construction of the table.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): Partial<OptionsFor<SignatureFrom<P>>> {\n let normalized = normalizePluginsConfig(table?.config?.plugins);\n let tuple = normalized?.find((option) => option[0] === klass);\n let t = tuple as [Class<P>, () => OptionsFor<SignatureFrom<P>>];\n\n // Plugin not provided, likely\n if (!t) return {};\n\n let fn = t[1];\n\n return fn() ?? {};\n },\n\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): Partial<ColumnOptionsFor<SignatureFrom<P>>> {\n let tuple = column.config.pluginOptions?.find((option) => option[0] === klass);\n let t = tuple as [unknown, () => ColumnOptionsFor<SignatureFrom<P>>];\n\n let fn = t?.[1];\n\n if (!fn) return {};\n\n return fn() ?? {};\n },\n};\n\n/**\n * @private\n */\nfunction getPluginInstance<RootKey extends string | Column<any> | Row<any>, Instance>(\n map: RootKey extends string\n ? Map<string, Map<Class<Instance>, Instance>>\n : WeakMap<Column | Row, Map<Class<Instance>, Instance>>,\n rootKey: RootKey,\n mapKey: Class<Instance>,\n factory: () => Instance\n): Instance {\n let bucket: Map<Class<Instance>, Instance> | undefined;\n\n if (map instanceof WeakMap) {\n assert(`Cannot use string key with WeakMap`, typeof rootKey !== 'string');\n\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n } else {\n assert(`Cannot use object key with Map`, typeof rootKey === 'string');\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n }\n\n let instance = bucket.get(mapKey);\n\n if (instance) {\n return instance;\n }\n\n instance = factory();\n\n bucket.set(mapKey, instance);\n\n return instance;\n}\n"],"names":["TABLE_META","Map","COLUMN_META","WeakMap","ROW_META","BasePlugin","constructor","table","with","configFn","forColumn","preferences","column","klass","delete","key","prefs","existing","storage","forPlugin","name","columnPrefs","persist","get","set","value","forTable","columnsFor","requester","assert","TABLE_KEY","visibility","findPlugin","plugins","reordering","some","plugin","columns","values","Array","isArray","for","next","current","referenceIndex","indexOf","length","undefined","previous","before","slice","after","meta","getPluginInstance","pluginOf","forRow","row","keys","includes","withFeature","featureName","provider","availableFeatures","find","features","allFeatures","map","flat","filter","Boolean","join","options","normalized","normalizePluginsConfig","config","tuple","option","t","fn","pluginOptions","rootKey","mapKey","factory","bucket","instance"],"mappings":";;;;;AAmBA,MAAMA,UAAU,GAAG,IAAIC,GAAJ,EAAnB,CAAA;AACA,MAAMC,WAAW,GAAG,IAAIC,OAAJ,EAApB,CAAA;AACA,MAAMC,QAAQ,GAAG,IAAID,OAAJ,EAAjB,CAAA;;AAwDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAeE,UAAf,CAA4E;EACjFC,WAAW,CAAWC,KAAX,EAAyB;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;;IAAA,IAAdA,CAAAA,KAAc,GAAdA,KAAc,CAAA;AAAE,GAAA;AAEtC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGE;AACF;AACA;EACa,OAAJC,IAAI,CAETC,QAFS,EAG6C;AACtD,IAAA,OAAO,CAAC,IAAD,EAAOA,QAAP,CAAP,CAAA;AACD,GAAA;AAED;AACF;AACA;AACA;;;EACkB,OAATC,SAAS,CAEdD,QAFc,EAG8C;AAC5D,IAAA,OAAO,CAAC,IAAD,EAAOA,QAAP,CAAP,CAAA;AACD,GAAA;;AAjCgF,CAAA;;gBAA7DJ;;gBAAAA;;AA8Cf,MAAMM,WAAW,GAAG;AACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACED,EAAAA,SAAS,CAA4CE,MAA5C,EAAkEC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QAAP,CAAA;AACD,GAAA;;EAEDA,QAAQ,GAAGF,OAAO,EAAlB,CAAA;AAEAC,EAAAA,MAAM,CAAC3D,GAAP,CAAWyD,MAAX,EAAmBG,QAAnB,CAAA,CAAA;AAEA,EAAA,OAAOA,QAAP,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"base.js","sources":["../../../src/plugins/-private/base.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { TABLE_KEY } from '../../-private/table';\nimport { normalizePluginsConfig } from './utils';\n\nimport type { Table } from '../../-private/table';\nimport type { ColumnReordering } from '../column-reordering';\nimport type { ColumnVisibility } from '../column-visibility';\nimport type { Class, Constructor } from '[private-types]';\nimport type { Column, Row } from '[public-types]';\nimport type {\n ColumnMetaFor,\n ColumnOptionsFor,\n OptionsFor,\n Plugin,\n RowMetaFor,\n TableMetaFor,\n} from '#interfaces';\n\nconst TABLE_META = new Map<string, Map<Class<unknown>, any>>();\nconst COLUMN_META = new WeakMap<Column, Map<Class<unknown>, any>>();\nconst ROW_META = new WeakMap<Row, Map<Class<unknown>, any>>();\n\ntype InstanceOf<T> = T extends Class<infer Instance> ? Instance : T;\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface TableFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the table meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['table']>;\n /**\n * @public\n *\n * interface for the table meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['table']>;\n}\n\n/**\n * @public\n *\n * list of interfaces by feature name that consumers may provide alternative\n * implementation for\n */\nexport interface ColumnFeatures extends Record<string, unknown | undefined> {\n /**\n * @public\n *\n * interface for the column meta of a \"column visibility plugin\"\n */\n columnVisibility: InstanceOf<ColumnVisibility['meta']['column']>;\n /**\n * @public\n *\n * interface for the column meta of a \"column order plugin\"\n */\n columnOrder: InstanceOf<ColumnReordering['meta']['column']>;\n}\n\n/**\n * @private utility type\n *\n */\nexport type SignatureFrom<Klass extends BasePlugin<any>> = Klass extends BasePlugin<infer Signature>\n ? Signature\n : never;\n\ndeclare const __Signature__: unique symbol;\n\n/**\n * @public\n *\n * If your table plugin is a class, you may extend from BasePlugin, which provides\n * small utility methods and properties for getting the metadata for your plugin\n * for the table and each column\n *\n * One instance of a plugin exists per table\n */\nexport abstract class BasePlugin<Signature = unknown> implements Plugin<Signature> {\n constructor(protected table: Table) {}\n\n /**\n * @private (secret)\n *\n * Because classes are kind of like interfaces,\n * we need \"something\" to help TS know what a Resource is.\n *\n * This isn't a real API, but does help with type inference\n * with the SignatureFrom utility above\n */\n declare [__Signature__]: Signature;\n\n /**\n * Helper for specifying plugins on `headlessTable` with the plugin-level options\n */\n static with<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => OptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => OptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n /**\n * Helper for specifying column-level configurations for a plugin on `headlessTable`'s\n * columns option\n */\n static forColumn<T extends BasePlugin<any>>(\n this: Constructor<T>,\n configFn: () => ColumnOptionsFor<SignatureFrom<T>>\n ): [Constructor<T>, () => ColumnOptionsFor<SignatureFrom<T>>] {\n return [this, configFn];\n }\n\n declare meta?: {\n column?: Constructor<ColumnMetaFor<Signature>>;\n table?: Constructor<TableMetaFor<Signature>>;\n row?: Constructor<RowMetaFor<Signature>>;\n };\n\n abstract name: string;\n static features?: string[];\n static requires?: string[];\n}\n\nexport const preferences = {\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the column (scoped to key)\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(column: Column<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n return columnPrefs.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = column.table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n let columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.set(key, value);\n\n prefs.persist();\n },\n };\n },\n\n /**\n * @public\n *\n * returns an object for getting and setting preferences data\n * based on the table (scoped to the key: \"table\")\n *\n * Only the provided plugin will have access to these preferences\n * (though, if other plugins can guess how the underlying plugin access\n * works, they can access this data, too. No security guaranteed)\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>) {\n return {\n /**\n * delete an entry on the underlying `Map` used for this column-plugin pair\n */\n delete(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.delete(key);\n\n return prefs.persist();\n },\n /**\n * get an entry on the underlying `Map` used for this column-plugin pair\n */\n get(key: string) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n return existing.table.get(key);\n },\n /**\n * set an entry on the underlying `Map` used for this column-plugin pair\n */\n set(key: string, value: unknown) {\n let prefs = table.preferences;\n let existing = prefs.storage.forPlugin(klass.name);\n\n existing.table.set(key, value);\n\n return prefs.persist();\n },\n };\n },\n};\n\n/**\n * if a `requester` is not provided,\n * Get the columns for the table, considering any and all plugins that could modify columns.\n *\n * If you are an end-consumer of ember-headless-table, this is the function to use.\n * If you are a plugin-author, you'll want to pass your plugin class as the second parameter.\n *\n * For a given plugin, `requester`, determine what columns should be returned.\n * Since multiple plugins could be used in a table, there is an implicit hierarchy of\n * column modifications that can occur from each of those plugins.\n *\n * If a plugin defines other plugins as either *requirements* or *optional requirements*,\n * and that upstream plugin defines a `columns` property, then those columns will be returned here.\n *\n * This works recursively up the plugin tree up until a plugin has no requirements, and then\n * all columns from the table are returned.\n */\nfunction columnsFor<DataType = any>(\n table: Table<DataType>,\n requester?: Plugin<any> | undefined\n): Column<DataType>[] {\n assert(`First argument passed to columns.for must be an instance of Table`, table[TABLE_KEY]);\n\n let visibility = findPlugin(table.plugins, 'columnVisibility');\n let reordering = findPlugin(table.plugins, 'columnOrder');\n\n // TODO: actually resolve the graph, rather than use the hardcoded feature names\n // atm, this only \"happens\" to work based on expectations of\n // of the currently implemented plugins' capabilities and implied hierarchy.\n\n if (requester) {\n assert(\n `[${requester.name}] requested columns from the table, but the plugin, ${requester.name}, ` +\n `is not used in this table`,\n table.plugins.some((plugin) => plugin instanceof (requester as Class<Plugin>))\n );\n\n if (visibility && visibility.constructor === requester) {\n return table.columns.values();\n }\n\n if (reordering && reordering.constructor === requester) {\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n }\n\n /**\n * This flow is the inverse of when we have a requester\n */\n\n if (reordering) {\n assert(\n `<#${reordering.name}> defined a 'columns' property, but did not return valid data.`,\n reordering.columns && Array.isArray(reordering.columns)\n );\n\n return reordering.columns;\n }\n\n if (visibility) {\n assert(\n `<#${visibility.name}> defined a 'columns' property, but did not return valid data.`,\n visibility.columns && Array.isArray(visibility.columns)\n );\n\n return visibility.columns;\n }\n\n return table.columns.values();\n}\n\nexport const columns = {\n for: columnsFor,\n\n /**\n * for a given current or reference column, return the column that\n * is immediately next, or to the right of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n next: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing after the last column\n */\n if (referenceIndex >= columns.length - 1) {\n return undefined;\n }\n\n return columns[referenceIndex + 1];\n },\n\n /**\n * for a given current or reference column, return the column that\n * is immediately previous, or to the left of that column.\n *\n * If a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n previous: <Data = unknown>(\n current: Column<Data>,\n requester?: Plugin<any>\n ): Column<Data> | undefined => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n let referenceIndex = columns.indexOf(current);\n\n assert(\n `index of reference column must be >= 0. column likely not a part of the table`,\n referenceIndex >= 0\n );\n\n /**\n * There can be nothing before the first column\n */\n if (referenceIndex === 0) {\n return undefined;\n }\n\n return columns[referenceIndex - 1];\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear before, or to the left of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n before: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(0, referenceIndex);\n },\n /**\n * for a given current or reference column, return the columns that\n * should appear after, or to the right of that column.\n *\n * if a plugin class is provided, the hierarchy of column list modifications\n * will be respected.\n */\n after: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>): Column<Data>[] => {\n let columns = requester ? columnsFor(current.table, requester) : columnsFor(current.table);\n\n let referenceIndex = columns.indexOf(current);\n\n return columns.slice(referenceIndex + 1);\n },\n};\n\nexport const meta = {\n /**\n * @public\n *\n * For a given column and plugin, return the meta / state bucket for the\n * plugin<->column instance pair.\n *\n * Note that this requires the column instance to exist on the table.\n */\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): ColumnMetaFor<SignatureFrom<P>> {\n return getPluginInstance(COLUMN_META, column, klass, () => {\n let plugin = column.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify column meta`, plugin.meta.column);\n\n return new plugin.meta.column(column);\n });\n },\n\n /**\n * @public\n *\n * For a given row and plugin, return the meta / state bucket for the\n * plugin<->row instance pair.\n *\n * Note that this requires the row instance to exist on the table.\n */\n forRow<P extends BasePlugin<any>, Data = unknown>(\n row: Row<Data>,\n klass: Class<P>\n ): RowMetaFor<SignatureFrom<P>> {\n return getPluginInstance(ROW_META, row, klass, () => {\n let plugin = row.table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify row meta`, plugin.meta.row);\n\n return new plugin.meta.row(row);\n });\n },\n\n /**\n * @public\n *\n * For a given table and plugin, return the meta / state bucket for the\n * plugin<->table instance pair.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): TableMetaFor<SignatureFrom<P>> {\n return getPluginInstance(TABLE_META, table[TABLE_KEY], klass, () => {\n let plugin = table.pluginOf(klass);\n\n assert(`[${klass.name}] cannot get plugin instance of unregistered plugin class`, plugin);\n assert(`<#${plugin.name}> plugin does not have meta specified`, plugin.meta);\n assert(`<#${plugin.name}> plugin does not specify table meta`, plugin.meta.table);\n assert(\n `<#${plugin.name}> plugin already exists for the table. ` +\n `A plugin may only be instantiated once per table.`,\n ![...(TABLE_META.get(table[TABLE_KEY])?.keys() ?? [])].includes(klass)\n );\n\n return new plugin.meta.table(table);\n });\n },\n\n /**\n * Instead of finding meta based on column or table instances,\n * you can search for meta based on feature strings, such as `columnWidth`\n */\n withFeature: {\n /**\n * @public\n *\n * for a given column and feature name, return the \"ColumnMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care which\n * plugin is providing what behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility\n */\n forColumn<FeatureName extends string, Data = unknown>(\n column: Column<Data>,\n featureName: FeatureName\n ): ColumnFeatures[FeatureName] {\n let { plugins } = column.table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forColumn(column, (provider as any).constructor);\n },\n\n /**\n * @public\n *\n * for a given table and feature name, return the \"TableMeta\" for that feature.\n * This is useful when plugins may depend on one another but may not necessarily care\n * which plugin is providing that behavior.\n *\n * For example, multiple column-focused plugins may care about width or visibility.\n */\n forTable<FeatureName extends string, Data = unknown>(\n table: Table<Data>,\n featureName: FeatureName\n ): TableFeatures[FeatureName] {\n let { plugins } = table;\n\n let provider = findPlugin(plugins, featureName);\n\n assert(\n `Could not find plugin with feature: ${featureName}. ` +\n `Available features: ${availableFeatures(plugins)}`,\n provider\n );\n\n // TS doesn't believe in the constructor property?\n return meta.forTable(table, (provider as any).constructor);\n },\n },\n};\n\nfunction findPlugin(plugins: Plugin[], featureName: string) {\n let provider = plugins.find((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features?.includes(featureName);\n });\n\n return provider;\n}\n\nfunction availableFeatures(plugins: Plugin[]): string {\n let allFeatures = plugins\n .map((plugin) => {\n /*\n * have to cast in order to get static properties, but we may not have a base plugin\n * so we must rely on nullish coalesting to protect from throwing exceptions\n *\n * (Plugin || BasePlugin).features)\n */\n let features = plugin.features || (plugin.constructor as typeof BasePlugin).features;\n\n return features;\n })\n .flat()\n .filter(Boolean);\n\n return allFeatures.length > 0 ? allFeatures.join(', ') : '[none]';\n}\n\nexport const options = {\n /**\n * @public\n *\n * For a given table and plugin, return the options, if any were given from the user\n * during construction of the table.\n */\n forTable<P extends BasePlugin<any>, Data = unknown>(\n table: Table<Data>,\n klass: Class<P>\n ): Partial<OptionsFor<SignatureFrom<P>>> {\n let normalized = normalizePluginsConfig(table?.config?.plugins);\n let tuple = normalized?.find((option) => option[0] === klass);\n let t = tuple as [Class<P>, () => OptionsFor<SignatureFrom<P>>];\n\n // Plugin not provided, likely\n if (!t) return {};\n\n let fn = t[1];\n\n return fn() ?? {};\n },\n\n forColumn<P extends BasePlugin<any>, Data = unknown>(\n column: Column<Data>,\n klass: Class<P>\n ): Partial<ColumnOptionsFor<SignatureFrom<P>>> {\n let tuple = column.config.pluginOptions?.find((option) => option[0] === klass);\n let t = tuple as [unknown, () => ColumnOptionsFor<SignatureFrom<P>>];\n\n let fn = t?.[1];\n\n if (!fn) return {};\n\n return fn() ?? {};\n },\n};\n\n/**\n * @private\n */\nfunction getPluginInstance<RootKey extends string | Column<any> | Row<any>, Instance>(\n map: RootKey extends string\n ? Map<string, Map<Class<Instance>, Instance>>\n : WeakMap<Column | Row, Map<Class<Instance>, Instance>>,\n rootKey: RootKey,\n mapKey: Class<Instance>,\n factory: () => Instance\n): Instance {\n let bucket: Map<Class<Instance>, Instance> | undefined;\n\n if (map instanceof WeakMap) {\n assert(`Cannot use string key with WeakMap`, typeof rootKey !== 'string');\n\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n } else {\n assert(`Cannot use object key with Map`, typeof rootKey === 'string');\n bucket = map.get(rootKey);\n\n if (!bucket) {\n bucket = new Map();\n\n map.set(rootKey, bucket);\n }\n }\n\n let instance = bucket.get(mapKey);\n\n if (instance) {\n return instance;\n }\n\n instance = factory();\n\n bucket.set(mapKey, instance);\n\n return instance;\n}\n"],"names":["TABLE_META","Map","COLUMN_META","WeakMap","ROW_META","BasePlugin","constructor","table","with","configFn","forColumn","preferences","column","klass","delete","key","prefs","existing","storage","forPlugin","name","columnPrefs","persist","get","set","value","forTable","columnsFor","requester","assert","TABLE_KEY","visibility","findPlugin","plugins","reordering","some","plugin","columns","values","Array","isArray","for","next","current","referenceIndex","indexOf","length","undefined","previous","before","slice","after","meta","getPluginInstance","pluginOf","forRow","row","keys","includes","withFeature","featureName","provider","availableFeatures","find","features","allFeatures","map","flat","filter","Boolean","join","options","normalized","normalizePluginsConfig","config","tuple","option","t","fn","pluginOptions","rootKey","mapKey","factory","bucket","instance"],"mappings":";;;;;AAmBA,MAAMA,UAAU,GAAG,IAAIC,GAAG,EAAoC,CAAA;AAC9D,MAAMC,WAAW,GAAG,IAAIC,OAAO,EAAoC,CAAA;AACnE,MAAMC,QAAQ,GAAG,IAAID,OAAO,EAAiC,CAAA;AAwD7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAeE,UAAU,CAAmD;EACjFC,WAAW,CAAWC,KAAY,EAAE;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAAA,IAAdA,CAAAA,KAAY,GAAZA,KAAY,CAAA;AAAG,GAAA;;AAErC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;EACE,OAAOC,IAAI,CAETC,QAA4C,EACU;AACtD,IAAA,OAAO,CAAC,IAAI,EAAEA,QAAQ,CAAC,CAAA;AACzB,GAAA;;AAEA;AACF;AACA;AACA;EACE,OAAOC,SAAS,CAEdD,QAAkD,EACU;AAC5D,IAAA,OAAO,CAAC,IAAI,EAAEA,QAAQ,CAAC,CAAA;AACzB,GAAA;AAWF,CAAA;AAA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Q,GAAGF,OAAO,EAAE,CAAA;AAEpBC,EAAAA,MAAM,CAAC3D,GAAG,CAACyD,MAAM,EAAEG,QAAQ,CAAC,CAAA;AAE5B,EAAA,OAAOA,QAAQ,CAAA;AACjB;;;;"}
@@ -3,31 +3,26 @@ import { assert } from '@ember/debug';
3
3
  function normalizePluginsConfig(plugins) {
4
4
  if (!plugins) return [];
5
5
  let result = [];
6
-
7
6
  for (let plugin of plugins) {
8
7
  if (!Array.isArray(plugin)) {
9
8
  result.push([plugin, () => ({})]);
10
9
  continue;
11
10
  }
12
-
13
11
  if (plugin.length === 2) {
14
12
  result.push([plugin[0], plugin[1]]);
15
13
  continue;
16
14
  }
17
-
18
15
  result.push([plugin[0], () => ({})]);
19
16
  }
20
-
21
17
  assert(`Every entry in the plugins config must be invokable`, result.every(tuple => typeof tuple[0] === 'function' && typeof tuple[1] === 'function'));
22
18
  return result;
23
19
  }
20
+
24
21
  /**
25
22
  * Creates a map of featureName => [plugins providing said feature name]
26
23
  */
27
-
28
24
  function collectFeatures(plugins) {
29
25
  let result = {};
30
-
31
26
  for (let [plugin] of plugins) {
32
27
  if ('features' in plugin) {
33
28
  for (let feature of plugin.features || []) {
@@ -35,17 +30,14 @@ function collectFeatures(plugins) {
35
30
  }
36
31
  }
37
32
  }
38
-
39
33
  return result;
40
34
  }
35
+
41
36
  /**
42
37
  * Creates a map of requirement => [plugins requesting the feature / requirement]
43
38
  */
44
-
45
-
46
39
  function collectRequirements(plugins) {
47
40
  let result = {};
48
-
49
41
  for (let [plugin] of plugins) {
50
42
  if ('requires' in plugin) {
51
43
  for (let requirement of plugin.requires || []) {
@@ -53,33 +45,29 @@ function collectRequirements(plugins) {
53
45
  }
54
46
  }
55
47
  }
56
-
57
48
  return result;
58
49
  }
59
-
60
50
  function verifyPlugins(plugins) {
61
51
  let features = collectFeatures(plugins);
62
52
  let requirements = collectRequirements(plugins);
63
53
  let allFeatures = Object.keys(features);
64
- let errors = []; // Only one plugin can provide each feature
54
+ let errors = [];
65
55
 
56
+ // Only one plugin can provide each feature
66
57
  for (let [feature, providingPlugins] of Object.entries(features)) {
67
58
  if (providingPlugins.length > 1) {
68
59
  errors.push(`More than one plugin is providing the feature: ${feature}. ` + `Please remove one of ${providingPlugins.map(p => p.name).join(', ')}`);
69
60
  }
70
61
  }
71
-
72
62
  for (let [requirement, requestingPlugins] of Object.entries(requirements)) {
73
63
  if (!allFeatures.includes(requirement)) {
74
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`);
75
65
  }
76
66
  }
77
-
78
67
  if (errors.length > 0) {
79
68
  throw new Error(errors.join('\n'));
80
69
  }
81
70
  }
82
-
83
71
  /**
84
72
  * @public
85
73
  *
@@ -92,21 +80,18 @@ function applyStyles(element, styles) {
92
80
  }
93
81
  }
94
82
  }
95
-
96
83
  function assignStyle(element, styleName, value) {
97
84
  element.style[styleName] = value;
98
85
  }
99
-
100
86
  function removeStyle(element, styleName) {
101
87
  element.style.removeProperty(styleName);
102
88
  }
89
+
103
90
  /**
104
91
  * @public
105
92
  *
106
93
  * Utility that helps safely remove styles from an element
107
94
  */
108
-
109
-
110
95
  function removeStyles(element, styles) {
111
96
  for (let name of styles) {
112
97
  if (typeof name !== 'string') continue;