@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,49 @@
1
+ import { meta } from '../-private/base.js';
2
+ import { Sorting } from './plugin.js';
3
+
4
+ /**
5
+ * Query a specific column's current sort direction
6
+ */
7
+ const sortDirection = column => meta.forColumn(column, Sorting).sortDirection;
8
+
9
+ /**
10
+ * Ask if a column is sortable
11
+ */
12
+ const isSortable = column => meta.forColumn(column, Sorting).isSortable;
13
+
14
+ /**
15
+ * Ask if a column is ascending
16
+ */
17
+ const isAscending = column => meta.forColumn(column, Sorting).isAscending;
18
+
19
+ /**
20
+ * Ask if a column is sorted descending
21
+ */
22
+ const isDescending = column => meta.forColumn(column, Sorting).isDescending;
23
+
24
+ /**
25
+ * Ask if a column is not sorted
26
+ */
27
+ const isUnsorted = column => meta.forColumn(column, Sorting).isUnsorted;
28
+
29
+ /**
30
+ * Sort the specified column's data using a tri-toggle.
31
+ *
32
+ * States go in this order:
33
+ * Ascending => None => Descending
34
+ * ⬑ ---------- <= ---------- ↲
35
+ */
36
+ const sort = column => meta.forTable(column.table, Sorting).handleSort(column);
37
+
38
+ /**
39
+ * Toggle a column between descending and not unsorted states
40
+ */
41
+ const sortDescending = column => meta.forTable(column.table, Sorting).toggleDescending(column);
42
+
43
+ /**
44
+ * Toggle a column between ascending and not unsorted states
45
+ */
46
+ const sortAscending = column => meta.forTable(column.table, Sorting).toggleAscending(column);
47
+
48
+ export { isAscending, isDescending, isSortable, isUnsorted, sort, sortAscending, sortDescending, sortDirection };
49
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/plugins/data-sorting/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base.ts';\nimport { Sorting } from './plugin.ts';\n\nimport type { Column } from '../../index.ts';\n\n/**\n * Query a specific column's current sort direction\n */\nexport const sortDirection = (column: Column) =>\n meta.forColumn(column, Sorting).sortDirection;\n\n/**\n * Ask if a column is sortable\n */\nexport const isSortable = (column: Column) =>\n meta.forColumn(column, Sorting).isSortable;\n\n/**\n * Ask if a column is ascending\n */\nexport const isAscending = (column: Column) =>\n meta.forColumn(column, Sorting).isAscending;\n\n/**\n * Ask if a column is sorted descending\n */\nexport const isDescending = (column: Column) =>\n meta.forColumn(column, Sorting).isDescending;\n\n/**\n * Ask if a column is not sorted\n */\nexport const isUnsorted = (column: Column) =>\n meta.forColumn(column, Sorting).isUnsorted;\n\n/**\n * Sort the specified column's data using a tri-toggle.\n *\n * States go in this order:\n * Ascending => None => Descending\n * ⬑ ---------- <= ---------- ↲\n */\nexport const sort = (column: Column) =>\n meta.forTable(column.table, Sorting).handleSort(column);\n\n/**\n * Toggle a column between descending and not unsorted states\n */\nexport const sortDescending = (column: Column) =>\n meta.forTable(column.table, Sorting).toggleDescending(column);\n\n/**\n * Toggle a column between ascending and not unsorted states\n */\nexport const sortAscending = (column: Column) =>\n meta.forTable(column.table, Sorting).toggleAscending(column);\n"],"names":["sortDirection","column","meta","forColumn","Sorting","isSortable","isAscending","isDescending","isUnsorted","sort","forTable","table","handleSort","sortDescending","toggleDescending","sortAscending","toggleAscending"],"mappings":";;;AAKA;AACA;AACA;AACaA,MAAAA,aAAa,GAAIC,MAAc,IAC1CC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,OAAO,CAAC,CAACJ;;AAElC;AACA;AACA;AACaK,MAAAA,UAAU,GAAIJ,MAAc,IACvCC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,OAAO,CAAC,CAACC;;AAElC;AACA;AACA;AACaC,MAAAA,WAAW,GAAIL,MAAc,IACxCC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,OAAO,CAAC,CAACE;;AAElC;AACA;AACA;AACaC,MAAAA,YAAY,GAAIN,MAAc,IACzCC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,OAAO,CAAC,CAACG;;AAElC;AACA;AACA;AACaC,MAAAA,UAAU,GAAIP,MAAc,IACvCC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,OAAO,CAAC,CAACI;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;MACaC,IAAI,GAAIR,MAAc,IACjCC,IAAI,CAACQ,QAAQ,CAACT,MAAM,CAACU,KAAK,EAAEP,OAAO,CAAC,CAACQ,UAAU,CAACX,MAAM;;AAExD;AACA;AACA;MACaY,cAAc,GAAIZ,MAAc,IAC3CC,IAAI,CAACQ,QAAQ,CAACT,MAAM,CAACU,KAAK,EAAEP,OAAO,CAAC,CAACU,gBAAgB,CAACb,MAAM;;AAE9D;AACA;AACA;MACac,aAAa,GAAId,MAAc,IAC1CC,IAAI,CAACQ,QAAQ,CAACT,MAAM,CAACU,KAAK,EAAEP,OAAO,CAAC,CAACY,eAAe,CAACf,MAAM;;;;"}
@@ -0,0 +1,4 @@
1
+ export { isAscending, isDescending, isSortable, isUnsorted, sort, sortAscending, sortDescending, sortDirection } from './helpers.js';
2
+ export { Sorting as DataSorting, Sorting as Plugin } from './plugin.js';
3
+ export { SortDirection } from './types.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,132 @@
1
+ import { a as _applyDecoratedDescriptor, _ as _defineProperty } from '../../_rollupPluginBabelHelpers-BpiaYhlf.js';
2
+ import { cached } from '@glimmer/tracking';
3
+ import { action } from '@ember/object';
4
+ import { BasePlugin, meta, options } from '../-private/base.js';
5
+ import { SortDirection } from './types.js';
6
+
7
+ var _class, _class2;
8
+ /**
9
+ * Manages basic data-sorting behaviors. Ascending -> Descending -> None
10
+ *
11
+ * This plugin requires a table plugin configuration, `onSort` for handling *how* sorting happens.
12
+ * communicating back to the table that sorting has succeeded can be done by setting the `sorts`
13
+ * property in the table plugin configuration.
14
+ *
15
+ * Note that this plugin doesn't actually sort the data, as data management is not the responsibility
16
+ * of the table, but of the surrounding context providing the data to the table. So sorting can happen
17
+ * client-side still, just in a component -- much the same way you'd handel sorting via API requests.
18
+ *
19
+ * This plugin is for *conveying* what the current sorts are, rather than _doing_ the sorting.
20
+ */
21
+ class Sorting extends BasePlugin {
22
+ constructor(...args) {
23
+ super(...args);
24
+ _defineProperty(this, "name", 'data-sorting');
25
+ _defineProperty(this, "meta", {
26
+ column: ColumnMeta,
27
+ table: TableMeta
28
+ });
29
+ _defineProperty(this, "headerCellModifier", (element, {
30
+ column
31
+ }) => {
32
+ const columnMeta = meta.forColumn(column, Sorting);
33
+ element.setAttribute('data-test-is-sortable', `${columnMeta.isSortable}`);
34
+ element.setAttribute('aria-sort', `${columnMeta.sortDirection}`);
35
+ });
36
+ }
37
+ }
38
+ let ColumnMeta = (_class = class ColumnMeta {
39
+ constructor(column) {
40
+ this.column = column;
41
+ }
42
+ get options() {
43
+ return options.forColumn(this.column, Sorting);
44
+ }
45
+ get isSortable() {
46
+ return this.options?.isSortable ?? this.tableMeta.isSortable;
47
+ }
48
+ get tableMeta() {
49
+ return meta.forTable(this.column.table, Sorting);
50
+ }
51
+ get sortDirection() {
52
+ const sort = this.tableMeta.sorts.find(sort => sort.property === this.sortProperty);
53
+ return sort?.direction ?? SortDirection.None;
54
+ }
55
+ get isAscending() {
56
+ return this.sortDirection === SortDirection.Ascending;
57
+ }
58
+ get isDescending() {
59
+ return this.sortDirection === SortDirection.Descending;
60
+ }
61
+ get isUnsorted() {
62
+ return this.sortDirection === SortDirection.None;
63
+ }
64
+ get sortProperty() {
65
+ return this.options?.sortProperty ?? this.column.config.key;
66
+ }
67
+ }, _applyDecoratedDescriptor(_class.prototype, "options", [cached], Object.getOwnPropertyDescriptor(_class.prototype, "options"), _class.prototype), _class);
68
+ let TableMeta = (_class2 = class TableMeta {
69
+ constructor(table) {
70
+ this.table = table;
71
+ }
72
+ get options() {
73
+ return options.forTable(this.table, Sorting);
74
+ }
75
+ get sorts() {
76
+ return this.options?.sorts ?? [];
77
+ }
78
+ get isSortable() {
79
+ return Boolean(this.options?.onSort) && Boolean(this.options?.sorts);
80
+ }
81
+ get onSort() {
82
+ return this.options?.onSort;
83
+ }
84
+ handleSort(column) {
85
+ const columnMeta = meta.forColumn(column, Sorting);
86
+ if (!columnMeta.sortProperty) {
87
+ return;
88
+ }
89
+ if (columnMeta.sortDirection === SortDirection.Ascending) {
90
+ this.onSort?.([]);
91
+ } else if (columnMeta.sortDirection === SortDirection.Descending) {
92
+ this.onSort?.([{
93
+ direction: SortDirection.Ascending,
94
+ property: columnMeta.sortProperty
95
+ }]);
96
+ } else {
97
+ this.onSort?.([{
98
+ direction: SortDirection.Descending,
99
+ property: columnMeta.sortProperty
100
+ }]);
101
+ }
102
+ }
103
+ toggleAscending(column) {
104
+ const columnMeta = meta.forColumn(column, Sorting);
105
+ if (!columnMeta.sortProperty) {
106
+ return;
107
+ }
108
+ if (columnMeta.sortDirection === SortDirection.Ascending) {
109
+ return this.onSort?.([]);
110
+ }
111
+ this.onSort?.([{
112
+ direction: SortDirection.Ascending,
113
+ property: columnMeta.sortProperty
114
+ }]);
115
+ }
116
+ toggleDescending(column) {
117
+ const columnMeta = meta.forColumn(column, Sorting);
118
+ if (!columnMeta.sortProperty) {
119
+ return;
120
+ }
121
+ if (columnMeta.sortDirection === SortDirection.Descending) {
122
+ return this.onSort?.([]);
123
+ }
124
+ this.onSort?.([{
125
+ direction: SortDirection.Descending,
126
+ property: columnMeta.sortProperty
127
+ }]);
128
+ }
129
+ }, _applyDecoratedDescriptor(_class2.prototype, "options", [cached], Object.getOwnPropertyDescriptor(_class2.prototype, "options"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSort", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSort"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "toggleAscending", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "toggleAscending"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "toggleDescending", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "toggleDescending"), _class2.prototype), _class2);
130
+
131
+ export { ColumnMeta, Sorting, TableMeta };
132
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["../../../src/plugins/data-sorting/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { action } from '@ember/object';\n\nimport { BasePlugin, meta, options } from '../-private/base.ts';\nimport { SortDirection } from './types.ts';\n\nimport type { Sort, SortItem } from './types.ts';\nimport type { ColumnApi, PluginPreferences } from '../../plugins/index.ts';\nimport type { Column, Table } from '../../index.ts';\n\ninterface SortingPreferences extends PluginPreferences {\n table: {\n sorts?: Sort[];\n };\n}\n\ndeclare module '@universal-ember/table/plugins' {\n interface Registry {\n Sorting?: SortingPreferences;\n sorting?: SortingPreferences;\n }\n}\n\nexport interface Signature<DataType = unknown> {\n Meta: {\n Column: ColumnMeta;\n Table: TableMeta;\n };\n Options: {\n Plugin: Options<DataType>;\n Column: ColumnOptions;\n };\n}\n\ninterface Options<DataType = unknown> {\n /**\n * Handler for interpreting sort requests from the headless table.\n *\n * Does not actually do the sorting.\n *\n * if omitted, the DataSorting plugin will disable itself\n */\n onSort?: (sorts: SortItem<DataType>[]) => void;\n /**\n * Provided sorts that the table should assume are true.\n *\n * if omitted, the DataSorting plugin will disable itself\n */\n sorts?: SortItem<DataType>[];\n}\n\ninterface ColumnOptions {\n /**\n * Opt in or out of sorting for a particular column.\n * Default is true.\n */\n isSortable?: boolean;\n /**\n * Use this key instead of the `key` on the column config.\n * This has no bearing on any behavior in the plugin, *other than*,\n * swapping out the `property`'s value on the `SortItem`s passed to\n * the table plugin config's `onSort` callback\n */\n sortProperty?: string;\n}\n\n/**\n * Manages basic data-sorting behaviors. Ascending -> Descending -> None\n *\n * This plugin requires a table plugin configuration, `onSort` for handling *how* sorting happens.\n * communicating back to the table that sorting has succeeded can be done by setting the `sorts`\n * property in the table plugin configuration.\n *\n * Note that this plugin doesn't actually sort the data, as data management is not the responsibility\n * of the table, but of the surrounding context providing the data to the table. So sorting can happen\n * client-side still, just in a component -- much the same way you'd handel sorting via API requests.\n *\n * This plugin is for *conveying* what the current sorts are, rather than _doing_ the sorting.\n */\nexport class Sorting<DataType = unknown> extends BasePlugin<\n Signature<DataType>\n> {\n name = 'data-sorting';\n\n meta = {\n column: ColumnMeta,\n table: TableMeta,\n };\n\n headerCellModifier = (element: HTMLElement, { column }: ColumnApi) => {\n const columnMeta = meta.forColumn(column, Sorting);\n\n element.setAttribute('data-test-is-sortable', `${columnMeta.isSortable}`);\n element.setAttribute('aria-sort', `${columnMeta.sortDirection}`);\n };\n}\n\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n @cached\n get options() {\n return options.forColumn(this.column, Sorting);\n }\n\n get isSortable() {\n return this.options?.isSortable ?? this.tableMeta.isSortable;\n }\n\n get tableMeta() {\n return meta.forTable(this.column.table, Sorting);\n }\n\n get sortDirection() {\n const sort = this.tableMeta.sorts.find(\n (sort) => sort.property === this.sortProperty,\n );\n\n return sort?.direction ?? SortDirection.None;\n }\n\n get isAscending() {\n return this.sortDirection === SortDirection.Ascending;\n }\n\n get isDescending() {\n return this.sortDirection === SortDirection.Descending;\n }\n\n get isUnsorted() {\n return this.sortDirection === SortDirection.None;\n }\n\n get sortProperty() {\n return this.options?.sortProperty ?? this.column.config.key;\n }\n}\n\nexport class TableMeta {\n constructor(private table: Table) {}\n\n @cached\n get options() {\n return options.forTable(this.table, Sorting);\n }\n\n get sorts() {\n return this.options?.sorts ?? [];\n }\n\n get isSortable() {\n return Boolean(this.options?.onSort) && Boolean(this.options?.sorts);\n }\n\n get onSort() {\n return this.options?.onSort;\n }\n\n @action\n handleSort(column: Column) {\n const columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Ascending) {\n this.onSort?.([]);\n } else if (columnMeta.sortDirection === SortDirection.Descending) {\n this.onSort?.([\n {\n direction: SortDirection.Ascending,\n property: columnMeta.sortProperty,\n },\n ]);\n } else {\n this.onSort?.([\n {\n direction: SortDirection.Descending,\n property: columnMeta.sortProperty,\n },\n ]);\n }\n }\n\n @action\n toggleAscending(column: Column) {\n const columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Ascending) {\n return this.onSort?.([]);\n }\n\n this.onSort?.([\n { direction: SortDirection.Ascending, property: columnMeta.sortProperty },\n ]);\n }\n\n @action\n toggleDescending(column: Column) {\n const columnMeta = meta.forColumn(column, Sorting);\n\n if (!columnMeta.sortProperty) {\n return;\n }\n\n if (columnMeta.sortDirection === SortDirection.Descending) {\n return this.onSort?.([]);\n }\n\n this.onSort?.([\n {\n direction: SortDirection.Descending,\n property: columnMeta.sortProperty,\n },\n ]);\n }\n}\n"],"names":["Sorting","BasePlugin","constructor","args","_defineProperty","column","ColumnMeta","table","TableMeta","element","columnMeta","meta","forColumn","setAttribute","isSortable","sortDirection","_class","options","tableMeta","forTable","sort","sorts","find","property","sortProperty","direction","SortDirection","None","isAscending","Ascending","isDescending","Descending","isUnsorted","config","key","_applyDecoratedDescriptor","prototype","cached","Object","getOwnPropertyDescriptor","_class2","Boolean","onSort","handleSort","toggleAscending","toggleDescending","action"],"mappings":";;;;;;;AAkEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,OAAO,SAA6BC,UAAU,CAEzD;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,eAAA,eACO,cAAc,CAAA;AAAAA,IAAAA,eAAA,CAEd,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,MAAM,EAAEC,UAAU;AAClBC,MAAAA,KAAK,EAAEC;KACR,CAAA;IAAAJ,eAAA,CAAA,IAAA,EAAA,oBAAA,EAEoB,CAACK,OAAoB,EAAE;AAAEJ,MAAAA;AAAkB,KAAC,KAAK;MACpE,MAAMK,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACP,MAAM,EAAEL,OAAO,CAAC;MAElDS,OAAO,CAACI,YAAY,CAAC,uBAAuB,EAAE,GAAGH,UAAU,CAACI,UAAU,CAAA,CAAE,CAAC;MACzEL,OAAO,CAACI,YAAY,CAAC,WAAW,EAAE,GAAGH,UAAU,CAACK,aAAa,CAAA,CAAE,CAAC;KACjE,CAAA;AAAA;AACH;AAEA,IAAaT,UAAU,IAAAU,MAAA,GAAhB,MAAMV,UAAU,CAAC;EACtBJ,WAAWA,CAASG,MAAc,EAAE;IAAA,IAAhBA,CAAAA,MAAc,GAAdA,MAAc;AAAG;EAErC,IACIY,OAAOA,GAAG;IACZ,OAAOA,OAAO,CAACL,SAAS,CAAC,IAAI,CAACP,MAAM,EAAEL,OAAO,CAAC;AAChD;EAEA,IAAIc,UAAUA,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EAAAI,iBAAAA,CAAAA,EAAAA,OAAA,CAAAJ,SAAA,CAAA,EAAAD,yBAAA,CAAAK,OAAA,CAAAJ,SAAA,uBAiBNU,MAAM,CAAA,EAAAR,MAAA,CAAAC,wBAAA,CAAAC,OAAA,CAAAJ,SAAA,EAAA,kBAAA,CAAA,EAAAI,OAAA,CAAAJ,SAAA,GAAAI,OAAA;;;;"}
@@ -0,0 +1,14 @@
1
+ let SortDirection = /*#__PURE__*/function (SortDirection) {
2
+ SortDirection["Ascending"] = "ascending";
3
+ SortDirection["Descending"] = "descending";
4
+ SortDirection["None"] = "none";
5
+ return SortDirection;
6
+ }({});
7
+ let SortTransform = /*#__PURE__*/function (SortTransform) {
8
+ SortTransform["Underscore"] = "underscore";
9
+ SortTransform["Camelize"] = "camelize";
10
+ return SortTransform;
11
+ }({});
12
+
13
+ export { SortDirection, SortTransform };
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/plugins/data-sorting/types.ts"],"sourcesContent":["import type { ColumnKey } from '../../-private/interfaces';\n\nexport enum SortDirection {\n Ascending = 'ascending',\n Descending = 'descending',\n None = 'none',\n}\n\nexport interface Sort {\n property: string;\n direction: SortDirection;\n}\n\nexport enum SortTransform {\n Underscore = 'underscore',\n Camelize = 'camelize',\n}\nexport interface SortsOptions {\n separator: string;\n transform: string | null;\n}\n\nexport interface SortItem<T> {\n direction: SortDirection;\n property: ColumnKey<T>;\n}\n"],"names":["SortDirection","SortTransform"],"mappings":"AAEYA,IAAAA,aAAa,0BAAbA,aAAa,EAAA;EAAbA,aAAa,CAAA,WAAA,CAAA,GAAA,WAAA;EAAbA,aAAa,CAAA,YAAA,CAAA,GAAA,YAAA;EAAbA,aAAa,CAAA,MAAA,CAAA,GAAA,MAAA;AAAA,EAAA,OAAbA,aAAa;AAAA,CAAA,CAAA,EAAA;AAWbC,IAAAA,aAAa,0BAAbA,aAAa,EAAA;EAAbA,aAAa,CAAA,YAAA,CAAA,GAAA,YAAA;EAAbA,aAAa,CAAA,UAAA,CAAA,GAAA,UAAA;AAAA,EAAA,OAAbA,aAAa;AAAA,CAAA,CAAA,EAAA;;;;"}
@@ -0,0 +1,3 @@
1
+ export { BasePlugin, columns, hasPlugin, meta, options, preferences } from './-private/base.js';
2
+ export { applyStyles, removeStyles } from './-private/utils.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,12 @@
1
+ import { options } from '../-private/base.js';
2
+ import { Metadata } from './plugin.js';
3
+
4
+ const forColumn = (column, key) => {
5
+ return options.forColumn(column, Metadata)[key];
6
+ };
7
+ const forTable = (table, key) => {
8
+ return options.forTable(table, Metadata)[key];
9
+ };
10
+
11
+ export { forColumn, forTable };
12
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/plugins/metadata/helpers.ts"],"sourcesContent":["import { options } from '../-private/base.ts';\nimport { Metadata } from './plugin.ts';\n\nimport type { Column, Table } from '../../index.ts';\n\nexport const forColumn = (column: Column<any>, key: string) => {\n return options.forColumn(column, Metadata)[key];\n};\n\nexport const forTable = (table: Table<any>, key: string) => {\n return options.forTable(table, Metadata)[key];\n};\n"],"names":["forColumn","column","key","options","Metadata","forTable","table"],"mappings":";;;MAKaA,SAAS,GAAGA,CAACC,MAAmB,EAAEC,GAAW,KAAK;EAC7D,OAAOC,OAAO,CAACH,SAAS,CAACC,MAAM,EAAEG,QAAQ,CAAC,CAACF,GAAG,CAAC;AACjD;MAEaG,QAAQ,GAAGA,CAACC,KAAiB,EAAEJ,GAAW,KAAK;EAC1D,OAAOC,OAAO,CAACE,QAAQ,CAACC,KAAK,EAAEF,QAAQ,CAAC,CAACF,GAAG,CAAC;AAC/C;;;;"}
@@ -0,0 +1,3 @@
1
+ export { forColumn, forTable } from './helpers.js';
2
+ export { Metadata, Metadata as Plugin } from './plugin.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,25 @@
1
+ import { _ as _defineProperty } from '../../_rollupPluginBabelHelpers-BpiaYhlf.js';
2
+ import { BasePlugin } from '../-private/base.js';
3
+
4
+ /**
5
+ * Data stored per column or table can be arbitrary
6
+ *
7
+ */
8
+
9
+ /**
10
+ * This plugin does noting,
11
+ * but gives consumer of it a safe way to store and associate "any" data with columns
12
+ * (and have a generic top-level bucket of data as well)
13
+ *
14
+ * This "metadata" stored per column per table is managed via the "options" part of the Signature, as
15
+ * "meta" is a term used for plugins for plugin authors.
16
+ */
17
+ class Metadata extends BasePlugin {
18
+ constructor(...args) {
19
+ super(...args);
20
+ _defineProperty(this, "name", 'metadata');
21
+ }
22
+ }
23
+
24
+ export { Metadata };
25
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["../../../src/plugins/metadata/plugin.ts"],"sourcesContent":["import { BasePlugin } from '../-private/base.ts';\n\n/**\n * Data stored per column or table can be arbitrary\n *\n */\ntype ArbitraryData = Record<string, any>;\n\nexport interface Signature<Data = ArbitraryData> {\n Options: {\n Column: Data;\n Plugin: Data;\n };\n}\n\n/**\n * This plugin does noting,\n * but gives consumer of it a safe way to store and associate \"any\" data with columns\n * (and have a generic top-level bucket of data as well)\n *\n * This \"metadata\" stored per column per table is managed via the \"options\" part of the Signature, as\n * \"meta\" is a term used for plugins for plugin authors.\n */\nexport class Metadata<S extends Signature> extends BasePlugin<S> {\n name = 'metadata';\n}\n"],"names":["Metadata","BasePlugin","constructor","args","_defineProperty"],"mappings":";;;AAEA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,SAA8BC,UAAU,CAAI;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,eAAA,eACxD,UAAU,CAAA;AAAA;AACnB;;;;"}
@@ -0,0 +1,10 @@
1
+ import { meta } from '../-private/base.js';
2
+ import { RowSelection } from './plugin.js';
3
+
4
+ const isSelected = row => meta.forRow(row, RowSelection).isSelected;
5
+ const select = row => meta.forRow(row, RowSelection).select();
6
+ const deselect = row => meta.forRow(row, RowSelection).deselect();
7
+ const toggle = row => meta.forRow(row, RowSelection).toggle();
8
+
9
+ export { deselect, isSelected, select, toggle };
10
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/plugins/row-selection/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base.ts';\nimport { RowSelection } from './plugin.ts';\n\nimport type { Row } from '../../-private/row.ts';\n\nexport const isSelected = (row: Row<any>) =>\n meta.forRow(row, RowSelection).isSelected;\nexport const select = (row: Row<any>) =>\n meta.forRow(row, RowSelection).select();\nexport const deselect = (row: Row<any>) =>\n meta.forRow(row, RowSelection).deselect();\nexport const toggle = (row: Row<any>) =>\n meta.forRow(row, RowSelection).toggle();\n"],"names":["isSelected","row","meta","forRow","RowSelection","select","deselect","toggle"],"mappings":";;;AAKaA,MAAAA,UAAU,GAAIC,GAAa,IACtCC,IAAI,CAACC,MAAM,CAACF,GAAG,EAAEG,YAAY,CAAC,CAACJ;MACpBK,MAAM,GAAIJ,GAAa,IAClCC,IAAI,CAACC,MAAM,CAACF,GAAG,EAAEG,YAAY,CAAC,CAACC,MAAM;MAC1BC,QAAQ,GAAIL,GAAa,IACpCC,IAAI,CAACC,MAAM,CAACF,GAAG,EAAEG,YAAY,CAAC,CAACE,QAAQ;MAC5BC,MAAM,GAAIN,GAAa,IAClCC,IAAI,CAACC,MAAM,CAACF,GAAG,EAAEG,YAAY,CAAC,CAACG,MAAM;;;;"}
@@ -0,0 +1,3 @@
1
+ export { deselect, isSelected, select, toggle } from './helpers.js';
2
+ export { RowSelection as Plugin, RowSelection } from './plugin.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,118 @@
1
+ import { a as _applyDecoratedDescriptor, _ as _defineProperty, e as _classPrivateFieldGet2, f as _classPrivateFieldInitSpec, g as _classPrivateFieldSet2 } from '../../_rollupPluginBabelHelpers-BpiaYhlf.js';
2
+ import { cached } from '@glimmer/tracking';
3
+ import { assert } from '@ember/debug';
4
+ import { BasePlugin, options, meta } from '../-private/base.js';
5
+
6
+ var _class, _table;
7
+ var _clickHandler = /*#__PURE__*/new WeakMap();
8
+ /**
9
+ * This plugin provides a means of managing selection of a single row in a table.
10
+ *
11
+ * The state of what is actually selected is managed by you, but this plugin
12
+ * will wire up the click listeners as well as let you know which *data* is clicked.
13
+ */
14
+ class RowSelection extends BasePlugin {
15
+ constructor(table) {
16
+ super(table);
17
+ _defineProperty(this, "name", 'row-selection');
18
+ _defineProperty(this, "meta", {
19
+ row: RowMeta,
20
+ table: TableMeta
21
+ });
22
+ _defineProperty(this, "rowModifier", (element, {
23
+ row
24
+ }) => {
25
+ const handler = event => {
26
+ _classPrivateFieldGet2(_clickHandler, this).call(this, row, event);
27
+ };
28
+ element.addEventListener('click', handler);
29
+ return () => {
30
+ element.removeEventListener('click', handler);
31
+ };
32
+ });
33
+ _classPrivateFieldInitSpec(this, _clickHandler, (row, event) => {
34
+ assert(`expected event.target to be an instance of HTMLElement`, event.target instanceof HTMLElement || event.target instanceof SVGElement);
35
+ const selection = document.getSelection();
36
+ if (selection) {
37
+ const {
38
+ type,
39
+ anchorNode
40
+ } = selection;
41
+ const isSelectingText = type === 'Range' && event.target?.contains(anchorNode);
42
+ if (isSelectingText) {
43
+ event.stopPropagation();
44
+ return;
45
+ }
46
+ }
47
+
48
+ // Ignore clicks on interactive elements within the row
49
+ const inputParent = event.target.closest('input, button, label, a, select');
50
+ if (inputParent) {
51
+ return;
52
+ }
53
+ const rowMeta = meta.forRow(row, RowSelection);
54
+ rowMeta.toggle();
55
+ });
56
+ const pluginOptions = options.forTable(this.table, RowSelection);
57
+ assert(`selection, onSelect, and onDeselect are all required arguments for the RowSelection plugin. ` + `Specify these options via \`RowSelection.with(() => ({ selection, onSelect, onDeselect }))\``, pluginOptions.selection && pluginOptions.onSelect && pluginOptions.onDeselect);
58
+ }
59
+ }
60
+ let TableMeta = (_class = (_table = /*#__PURE__*/new WeakMap(), class TableMeta {
61
+ constructor(table) {
62
+ _classPrivateFieldInitSpec(this, _table, void 0);
63
+ _classPrivateFieldSet2(_table, this, table);
64
+ }
65
+ get selection() {
66
+ const passedSelection = options.forTable(_classPrivateFieldGet2(_table, this), RowSelection).selection;
67
+ assert(`Cannot access selection because it is undefined`, passedSelection);
68
+ if (passedSelection instanceof Set) {
69
+ return passedSelection;
70
+ }
71
+ return new Set(passedSelection);
72
+ }
73
+ }), _applyDecoratedDescriptor(_class.prototype, "selection", [cached], Object.getOwnPropertyDescriptor(_class.prototype, "selection"), _class.prototype), _class);
74
+ var _row = /*#__PURE__*/new WeakMap();
75
+ class RowMeta {
76
+ constructor(row) {
77
+ _classPrivateFieldInitSpec(this, _row, void 0);
78
+ _defineProperty(this, "toggle", () => {
79
+ if (this.isSelected) {
80
+ this.deselect();
81
+ return;
82
+ }
83
+ this.select();
84
+ });
85
+ _defineProperty(this, "select", () => {
86
+ const pluginOptions = options.forTable(_classPrivateFieldGet2(_row, this).table, RowSelection);
87
+ if ('key' in pluginOptions && pluginOptions.key) {
88
+ const key = pluginOptions.key(_classPrivateFieldGet2(_row, this).data);
89
+ pluginOptions.onSelect?.(key, _classPrivateFieldGet2(_row, this));
90
+ return;
91
+ }
92
+ pluginOptions.onSelect?.(_classPrivateFieldGet2(_row, this).data, _classPrivateFieldGet2(_row, this));
93
+ });
94
+ _defineProperty(this, "deselect", () => {
95
+ const pluginOptions = options.forTable(_classPrivateFieldGet2(_row, this).table, RowSelection);
96
+ if ('key' in pluginOptions && pluginOptions.key) {
97
+ const key = pluginOptions.key(_classPrivateFieldGet2(_row, this).data);
98
+ pluginOptions.onDeselect?.(key, _classPrivateFieldGet2(_row, this));
99
+ return;
100
+ }
101
+ pluginOptions.onDeselect?.(_classPrivateFieldGet2(_row, this).data, _classPrivateFieldGet2(_row, this));
102
+ });
103
+ _classPrivateFieldSet2(_row, this, row);
104
+ }
105
+ get isSelected() {
106
+ const tableMeta = meta.forTable(_classPrivateFieldGet2(_row, this).table, RowSelection);
107
+ const pluginOptions = options.forTable(_classPrivateFieldGet2(_row, this).table, RowSelection);
108
+ if ('key' in pluginOptions && pluginOptions.key) {
109
+ const compareWith = pluginOptions.key(_classPrivateFieldGet2(_row, this).data);
110
+ return tableMeta.selection.has(compareWith);
111
+ }
112
+ const compareWith = _classPrivateFieldGet2(_row, this).data;
113
+ return tableMeta.selection.has(compareWith);
114
+ }
115
+ }
116
+
117
+ export { RowSelection };
118
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["../../../src/plugins/row-selection/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\n\nimport { BasePlugin, meta, options } from '../-private/base.ts';\n\nimport type { Row, Table } from '../../index.ts';\nimport type { PluginSignature, RowApi } from '../../-private/interfaces';\n\nexport interface Signature<DataType = any, Key = DataType>\n extends PluginSignature {\n Meta: {\n Table: TableMeta;\n Row: RowMeta;\n };\n Options: {\n Plugin: {\n /**\n * A set of selected things using the same type of Identifier\n * returned from `key`\n */\n selection: Set<Key> | Array<Key>;\n } & (\n | {\n /**\n * For a given row's data, how should the key be determined?\n * this could be a remote id from a database, or some other attribute\n *\n * This could be useful for indicating in UI if a particular item is selected.\n *\n * If not provided, the row's data will be used as the key\n */\n key: (data: DataType) => Key;\n /**\n * When a row is clicked, this will be invoked,\n * allowing you to update your selection object\n */\n onSelect: (item: Key, row: Row<DataType>) => void;\n /**\n * When a row is clicked (and the row is selected), this will be invoked,\n * allowing you to update your selection object\n */\n onDeselect: (item: Key, row: Row<DataType>) => void;\n }\n | {\n /**\n * When a row is clicked (and the row is not selected), this will be invoked,\n * allowing you to update your selection object\n */\n onSelect: (item: DataType | any, row: Row<DataType>) => void;\n /**\n * When a row is clicked (and the row is selected), this will be invoked,\n * allowing you to update your selection object\n */\n onDeselect: (item: DataType | any, row: Row<DataType>) => void;\n }\n );\n };\n}\n\n/**\n * This plugin provides a means of managing selection of a single row in a table.\n *\n * The state of what is actually selected is managed by you, but this plugin\n * will wire up the click listeners as well as let you know which *data* is clicked.\n */\nexport class RowSelection<DataType = any, Key = DataType> extends BasePlugin<\n Signature<DataType, Key>\n> {\n name = 'row-selection';\n\n meta = {\n row: RowMeta,\n table: TableMeta,\n };\n\n constructor(table: Table) {\n super(table);\n\n const pluginOptions = options.forTable(this.table, RowSelection);\n\n assert(\n `selection, onSelect, and onDeselect are all required arguments for the RowSelection plugin. ` +\n `Specify these options via \\`RowSelection.with(() => ({ selection, onSelect, onDeselect }))\\``,\n pluginOptions.selection &&\n pluginOptions.onSelect &&\n pluginOptions.onDeselect,\n );\n }\n\n rowModifier = (element: HTMLElement, { row }: RowApi<Table<any>>) => {\n const handler = (event: Event) => {\n this.#clickHandler(row, event);\n };\n\n element.addEventListener('click', handler);\n\n return () => {\n element.removeEventListener('click', handler);\n };\n };\n\n #clickHandler = (row: Row, event: Event) => {\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 const rowMeta = meta.forRow(row, RowSelection);\n\n rowMeta.toggle();\n };\n}\n\nclass TableMeta {\n #table: Table;\n\n constructor(table: Table) {\n this.#table = table;\n }\n\n @cached\n get selection(): Set<unknown> {\n const passedSelection = options.forTable(\n this.#table,\n RowSelection,\n ).selection;\n\n assert(`Cannot access selection because it is undefined`, passedSelection);\n\n if (passedSelection instanceof Set) {\n return passedSelection;\n }\n\n return new Set(passedSelection);\n }\n}\n\nclass RowMeta {\n #row: Row<any>;\n\n constructor(row: Row<any>) {\n this.#row = row;\n }\n\n get isSelected(): boolean {\n const tableMeta = meta.forTable(this.#row.table, RowSelection);\n const pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n const compareWith = pluginOptions.key(this.#row.data);\n\n return tableMeta.selection.has(compareWith);\n }\n\n const compareWith = this.#row.data;\n\n return tableMeta.selection.has(compareWith);\n }\n\n toggle = () => {\n if (this.isSelected) {\n this.deselect();\n\n return;\n }\n\n this.select();\n };\n\n select = () => {\n const pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n const key = pluginOptions.key(this.#row.data);\n\n pluginOptions.onSelect?.(key, this.#row);\n\n return;\n }\n\n pluginOptions.onSelect?.(this.#row.data, this.#row);\n };\n\n deselect = () => {\n const pluginOptions = options.forTable(this.#row.table, RowSelection);\n\n if ('key' in pluginOptions && pluginOptions.key) {\n const key = pluginOptions.key(this.#row.data);\n\n pluginOptions.onDeselect?.(key, this.#row);\n\n return;\n }\n\n pluginOptions.onDeselect?.(this.#row.data, this.#row);\n };\n}\n"],"names":["_clickHandler","WeakMap","RowSelection","BasePlugin","constructor","table","_defineProperty","row","RowMeta","TableMeta","element","handler","event","_classPrivateFieldGet","call","addEventListener","removeEventListener","_classPrivateFieldInitSpec","assert","target","HTMLElement","SVGElement","selection","document","getSelection","type","anchorNode","isSelectingText","contains","stopPropagation","inputParent","closest","rowMeta","meta","forRow","toggle","pluginOptions","options","forTable","onSelect","onDeselect","_class","_table","_classPrivateFieldSet","passedSelection","Set","_applyDecoratedDescriptor","prototype","cached","Object","getOwnPropertyDescriptor","_row","isSelected","deselect","select","key","data","tableMeta","compareWith","has"],"mappings":";;;;;;AAGgE,IAAAA,aAAA,oBAAAC,OAAA,EAAA;AAwDhE;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAAyCC,UAAU,CAE1E;EAQAC,WAAWA,CAACC,KAAY,EAAE;IACxB,KAAK,CAACA,KAAK,CAAC;AAACC,IAAAA,eAAA,eARR,eAAe,CAAA;AAAAA,IAAAA,eAAA,CAEf,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,GAAG,EAAEC,OAAO;AACZH,MAAAA,KAAK,EAAEI;KACR,CAAA;IAAAH,eAAA,CAAA,IAAA,EAAA,aAAA,EAgBa,CAACI,OAAoB,EAAE;AAAEH,MAAAA;AAAwB,KAAC,KAAK;MACnE,MAAMI,OAAO,GAAIC,KAAY,IAAK;AAChCC,QAAAA,sBAAA,CAAKb,aAAa,EAAlB,IAAiB,CAAC,CAAAc,IAAA,CAAlB,IAAI,EAAeP,GAAG,EAAEK,KAAK,CAAA;OAC9B;AAEDF,MAAAA,OAAO,CAACK,gBAAgB,CAAC,OAAO,EAAEJ,OAAO,CAAC;AAE1C,MAAA,OAAO,MAAM;AACXD,QAAAA,OAAO,CAACM,mBAAmB,CAAC,OAAO,EAAEL,OAAO,CAAC;OAC9C;KACF,CAAA;AAEDM,IAAAA,0BAAA,OAAAjB,aAAa,EAAG,CAACO,GAAQ,EAAEK,KAAY,KAAK;AAC1CM,MAAAA,MAAM,CACJ,CAAA,sDAAA,CAAwD,EACxDN,KAAK,CAACO,MAAM,YAAYC,WAAW,IAAIR,KAAK,CAACO,MAAM,YAAYE,UACjE,CAAC;AAED,MAAA,MAAMC,SAAS,GAAGC,QAAQ,CAACC,YAAY,EAAE;AAEzC,MAAA,IAAIF,SAAS,EAAE;QACb,MAAM;UAAEG,IAAI;AAAEC,UAAAA;AAAW,SAAC,GAAGJ,S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AErD,MAAA,OAAOC,SAAS,CAACnC,SAAS,CAACqC,GAAG,CAACD,WAAW,CAAC;AAC7C;IAEA,MAAMA,WAAW,GAAG7C,sBAAA,CAAKsC,IAAI,EAAT,IAAQ,CAAC,CAACK,IAAI;AAElC,IAAA,OAAOC,SAAS,CAACnC,SAAS,CAACqC,GAAG,CAACD,WAAW,CAAC;AAC7C;AAuCF;;;;"}
@@ -0,0 +1,49 @@
1
+ import { htmlSafe } from '@ember/template';
2
+ import { meta } from '../-private/base.js';
3
+ import { StickyColumns } from './plugin.js';
4
+
5
+ const isSticky = column => meta.forColumn(column, StickyColumns).isSticky;
6
+ const styleFor = column => meta.forColumn(column, StickyColumns).style;
7
+
8
+ /**
9
+ * In this plugin, both header and cells have the same styles,
10
+ * if applicable.
11
+ *
12
+ * Until this RFC https://github.com/emberjs/rfcs/pull/883
13
+ * is merged and implemented, we can't performantly
14
+ * use modifiers for apply styles.
15
+ *
16
+ * In the mean time, we'll need to append style strings, which is more work
17
+ * for consumers, but is a reasonable trade-off for now.
18
+ */
19
+ const styleStringFor = column => {
20
+ const columnMeta = meta.forColumn(column, StickyColumns);
21
+ let result = '';
22
+ if (columnMeta.isSticky) {
23
+ for (const [key, value] of Object.entries(columnMeta.style)) {
24
+ result += `${toStyle(key)}:${value};`;
25
+ }
26
+ result = ';' + result;
27
+ }
28
+ return htmlSafe(result);
29
+ };
30
+
31
+ /**
32
+ * the JS API for styles is camel case,
33
+ * but CSS is kebab-case. To save on complexity and
34
+ * amount of code, we have a super small conversion function
35
+ * for only the properties relevant to the sticky plugin.
36
+ */
37
+ const toStyle = key => {
38
+ switch (key) {
39
+ case 'zIndex':
40
+ return 'z-index';
41
+ case 'minWidth':
42
+ return 'min-width';
43
+ default:
44
+ return key;
45
+ }
46
+ };
47
+
48
+ export { isSticky, styleFor, styleStringFor };
49
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base.ts';\nimport { StickyColumns } from './plugin.ts';\n\nimport type { Column } from '../../index.ts';\n\nexport const isSticky = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, StickyColumns).isSticky;\n\nexport const styleFor = <DataType = unknown>(\n column: Column<DataType>,\n): Partial<CSSStyleDeclaration> => meta.forColumn(column, StickyColumns).style;\n\n/**\n * In this plugin, both header and cells have the same styles,\n * if applicable.\n *\n * Until this RFC https://github.com/emberjs/rfcs/pull/883\n * is merged and implemented, we can't performantly\n * use modifiers for apply styles.\n *\n * In the mean time, we'll need to append style strings, which is more work\n * for consumers, but is a reasonable trade-off for now.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>,\n): ReturnType<typeof htmlSafe> => {\n const columnMeta = meta.forColumn(column, StickyColumns);\n\n let result = '';\n\n if (columnMeta.isSticky) {\n for (const [key, value] of Object.entries(columnMeta.style)) {\n result += `${toStyle(key)}:${value};`;\n }\n\n result = ';' + result;\n }\n\n return htmlSafe(result);\n};\n\n/**\n * the JS API for styles is camel case,\n * but CSS is kebab-case. To save on complexity and\n * amount of code, we have a super small conversion function\n * for only the properties relevant to the sticky plugin.\n */\nconst toStyle = (key: string): string => {\n switch (key) {\n case 'zIndex':\n return 'z-index';\n case 'minWidth':\n return 'min-width';\n default:\n return key;\n }\n};\n"],"names":["isSticky","column","meta","forColumn","StickyColumns","styleFor","style","styleStringFor","columnMeta","result","key","value","Object","entries","toStyle","htmlSafe"],"mappings":";;;;AAOaA,MAAAA,QAAQ,GAAwBC,MAAwB,IACnEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACJ;AAE3BK,MAAAA,QAAQ,GACnBJ,MAAwB,IACSC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACE;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GACzBN,MAAwB,IACQ;EAChC,MAAMO,UAAU,GAAGN,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC;EAExD,IAAIK,MAAM,GAAG,EAAE;EAEf,IAAID,UAAU,CAACR,QAAQ,EAAE;AACvB,IAAA,KAAK,MAAM,CAACU,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACF,KAAK,CAAC,EAAE;MAC3DG,MAAM,IAAI,GAAGK,OAAO,CAACJ,GAAG,CAAC,CAAA,CAAA,EAAIC,KAAK,CAAG,CAAA,CAAA;AACvC;IAEAF,MAAM,GAAG,GAAG,GAAGA,MAAM;AACvB;EAEA,OAAOM,QAAQ,CAACN,MAAM,CAAC;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,OAAO,GAAIJ,GAAW,IAAa;AACvC,EAAA,QAAQA,GAAG;AACT,IAAA,KAAK,QAAQ;AACX,MAAA,OAAO,SAAS;AAClB,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,WAAW;AACpB,IAAA;AACE,MAAA,OAAOA,GAAG;AACd;AACF,CAAC;;;;"}
@@ -0,0 +1,3 @@
1
+ export { isSticky, styleFor, styleStringFor } from './helpers.js';
2
+ export { StickyColumns as Plugin, StickyColumns } from './plugin.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}