@frontile/collections 0.18.0-alpha.10 → 0.18.0-alpha.12
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.
- package/package.json +13 -13
- package/declarations/components/dropdown.d.ts +0 -99
- package/declarations/components/listbox/item.d.ts +0 -51
- package/declarations/components/listbox/listbox.d.ts +0 -75
- package/declarations/components/listbox.d.ts +0 -2
- package/declarations/components/simple-table/body.d.ts +0 -428
- package/declarations/components/simple-table/cell.d.ts +0 -427
- package/declarations/components/simple-table/column.d.ts +0 -419
- package/declarations/components/simple-table/footer.d.ts +0 -430
- package/declarations/components/simple-table/header.d.ts +0 -430
- package/declarations/components/simple-table/index.d.ts +0 -446
- package/declarations/components/simple-table/row.d.ts +0 -430
- package/declarations/components/table/cell-default.d.ts +0 -43
- package/declarations/components/table/cell-for.d.ts +0 -38
- package/declarations/components/table/cell-rendering-context.d.ts +0 -24
- package/declarations/components/table/checkbox.d.ts +0 -50
- package/declarations/components/table/column-visibility.d.ts +0 -416
- package/declarations/components/table/icons.d.ts +0 -11
- package/declarations/components/table/index.d.ts +0 -4
- package/declarations/components/table/sort-button.d.ts +0 -413
- package/declarations/components/table/table.d.ts +0 -555
- package/declarations/components/table/types.d.ts +0 -46
- package/declarations/components/table/utils.d.ts +0 -6
- package/declarations/components/table.d.ts +0 -2
- package/declarations/utils/listManager.d.ts +0 -74
- package/dist/listManager-CKsOd2zS.js +0 -438
- package/dist/listManager-CKsOd2zS.js.map +0 -1
- package/dist/listbox-CkGwpiDp.js +0 -203
- package/dist/listbox-CkGwpiDp.js.map +0 -1
- package/dist/listbox-Czwb-jUT.js +0 -203
- package/dist/listbox-Czwb-jUT.js.map +0 -1
- package/dist/table-3uScDwoD.js +0 -877
- package/dist/table-3uScDwoD.js.map +0 -1
- package/dist/table-DvivyvLm.js +0 -877
- package/dist/table-DvivyvLm.js.map +0 -1
- package/dist/table-SVR6fEqh.js +0 -877
- package/dist/table-SVR6fEqh.js.map +0 -1
package/dist/table-DvivyvLm.js
DELETED
|
@@ -1,877 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { hash, fn } from '@ember/helper';
|
|
3
|
-
import { useStyles, twMerge } from '@frontile/theme';
|
|
4
|
-
import { modifier } from 'ember-modifier';
|
|
5
|
-
import { tracked, cached } from '@glimmer/tracking';
|
|
6
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
|
-
import { setComponentTemplate } from '@ember/component';
|
|
8
|
-
import { d as decorateMethodV2, a as decorateFieldV2, i as initializeDeferredDecorator, k as keyAndLabelForItem } from './listManager-CKsOd2zS.js';
|
|
9
|
-
import { action } from '@ember/object';
|
|
10
|
-
import { Dropdown } from './components/dropdown.js';
|
|
11
|
-
import { isVisible, show, hide, ColumnVisibility as ColumnVisibility$1 } from '@universal-ember/table/plugins/column-visibility';
|
|
12
|
-
import templateOnly from '@ember/component/template-only';
|
|
13
|
-
import { press } from '@frontile/utilities';
|
|
14
|
-
import { SortDirection, DataSorting, sort, sortDirection, isSortable } from '@universal-ember/table/plugins/data-sorting';
|
|
15
|
-
import { on } from '@ember/modifier';
|
|
16
|
-
import { headlessTable } from '@universal-ember/table';
|
|
17
|
-
import { columns } from '@universal-ember/table/plugins';
|
|
18
|
-
import { RowSelection } from '@universal-ember/table/plugins/row-selection';
|
|
19
|
-
|
|
20
|
-
class SimpleTableColumn extends Component {
|
|
21
|
-
get styles() {
|
|
22
|
-
return this.args.styleFns || useStyles().table();
|
|
23
|
-
}
|
|
24
|
-
get classNames() {
|
|
25
|
-
const options = {
|
|
26
|
-
isSticky: this.args.isSticky || false,
|
|
27
|
-
stickyPosition: this.args.isSticky ? this.args.stickyPosition || 'left' : undefined,
|
|
28
|
-
class: this.args.class
|
|
29
|
-
};
|
|
30
|
-
return this.styles.th(options);
|
|
31
|
-
}
|
|
32
|
-
static {
|
|
33
|
-
setComponentTemplate(precompileTemplate("\n <th class={{this.classNames}} data-test-id=\"table-column\" data-component=\"table-column\" ...attributes>\n {{yield}}\n </th>\n ", {
|
|
34
|
-
strictMode: true
|
|
35
|
-
}), this);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
class SimpleTableHeader extends Component {
|
|
40
|
-
get styles() {
|
|
41
|
-
return this.args.styleFns || useStyles().table();
|
|
42
|
-
}
|
|
43
|
-
get classNames() {
|
|
44
|
-
const options = {
|
|
45
|
-
isSticky: this.args.isSticky || false,
|
|
46
|
-
stickyPosition: this.args.isSticky ? 'top' : undefined,
|
|
47
|
-
class: twMerge(this.args.class, this.args.classes?.thead)
|
|
48
|
-
};
|
|
49
|
-
return this.styles.thead(options);
|
|
50
|
-
}
|
|
51
|
-
get rowClassNames() {
|
|
52
|
-
const options = {
|
|
53
|
-
class: twMerge('', this.args.classes?.tr || ''),
|
|
54
|
-
isSticky: false
|
|
55
|
-
};
|
|
56
|
-
return this.styles.tr(options);
|
|
57
|
-
}
|
|
58
|
-
get separatorClassNames() {
|
|
59
|
-
return this.styles.separator({
|
|
60
|
-
class: this.args.classes?.separator
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
static {
|
|
64
|
-
setComponentTemplate(precompileTemplate("\n <thead class={{this.classNames}} data-test-id=\"table-header\" data-component=\"table-header\" ...attributes>\n <tr class={{this.rowClassNames}}>\n {{yield (hash Column=SimpleTableColumn)}}\n </tr>\n <tr class={{this.separatorClassNames}} />\n </thead>\n ", {
|
|
65
|
-
strictMode: true,
|
|
66
|
-
scope: () => ({
|
|
67
|
-
hash,
|
|
68
|
-
SimpleTableColumn
|
|
69
|
-
})
|
|
70
|
-
}), this);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
class SimpleTableCell extends Component {
|
|
75
|
-
get styles() {
|
|
76
|
-
return this.args.styleFns || useStyles().table();
|
|
77
|
-
}
|
|
78
|
-
get classNames() {
|
|
79
|
-
const options = {
|
|
80
|
-
isSticky: this.args.isSticky || false,
|
|
81
|
-
stickyPosition: this.args.isSticky ? this.args.stickyPosition || 'left' : undefined,
|
|
82
|
-
isInStickyRow: this.args.isInStickyRow || false,
|
|
83
|
-
class: twMerge(this.args.class || '', this.args.classes?.td || '')
|
|
84
|
-
};
|
|
85
|
-
return this.styles.td(options);
|
|
86
|
-
}
|
|
87
|
-
static {
|
|
88
|
-
setComponentTemplate(precompileTemplate("\n <td class={{this.classNames}} data-test-id=\"table-cell\" data-component=\"table-cell\" ...attributes>\n {{yield}}\n </td>\n ", {
|
|
89
|
-
strictMode: true
|
|
90
|
-
}), this);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
class SimpleTableRow extends Component {
|
|
95
|
-
get styles() {
|
|
96
|
-
return this.args.styleFns || useStyles().table();
|
|
97
|
-
}
|
|
98
|
-
get classNames() {
|
|
99
|
-
const options = {
|
|
100
|
-
isSticky: this.args.isSticky || false,
|
|
101
|
-
stickyPosition: this.args.isSticky ? 'top' : undefined,
|
|
102
|
-
hasStickyHeader: this.args.hasStickyHeader || false,
|
|
103
|
-
class: twMerge(this.args.class || '', this.args.classes?.tr || '')
|
|
104
|
-
};
|
|
105
|
-
return this.styles.tr(options);
|
|
106
|
-
}
|
|
107
|
-
static {
|
|
108
|
-
setComponentTemplate(precompileTemplate("\n <tr class={{this.classNames}} data-test-id=\"table-row\" data-component=\"table-row\" ...attributes>\n {{yield (hash Cell=SimpleTableCell)}}\n </tr>\n ", {
|
|
109
|
-
strictMode: true,
|
|
110
|
-
scope: () => ({
|
|
111
|
-
hash,
|
|
112
|
-
SimpleTableCell
|
|
113
|
-
})
|
|
114
|
-
}), this);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
class SimpleTableBody extends Component {
|
|
119
|
-
get styles() {
|
|
120
|
-
return this.args.styleFns || useStyles().table();
|
|
121
|
-
}
|
|
122
|
-
get classNames() {
|
|
123
|
-
const mergedClass = twMerge(this.args.class, this.args.classes?.tbody);
|
|
124
|
-
return this.styles.tbody({
|
|
125
|
-
class: mergedClass
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
static {
|
|
129
|
-
setComponentTemplate(precompileTemplate("\n <tbody class={{this.classNames}} data-test-id=\"table-body\" data-component=\"table-body\" ...attributes>\n {{yield (hash Row=SimpleTableRow Cell=SimpleTableCell)}}\n </tbody>\n ", {
|
|
130
|
-
strictMode: true,
|
|
131
|
-
scope: () => ({
|
|
132
|
-
hash,
|
|
133
|
-
SimpleTableRow,
|
|
134
|
-
SimpleTableCell
|
|
135
|
-
})
|
|
136
|
-
}), this);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
class SimpleTableFooter extends Component {
|
|
141
|
-
get styles() {
|
|
142
|
-
return this.args.styleFns || useStyles().table();
|
|
143
|
-
}
|
|
144
|
-
get classNames() {
|
|
145
|
-
const options = {
|
|
146
|
-
isSticky: this.args.isSticky || false,
|
|
147
|
-
stickyPosition: this.args.isSticky ? 'bottom' : undefined,
|
|
148
|
-
class: twMerge(this.args.class, this.args.classes?.tfoot)
|
|
149
|
-
};
|
|
150
|
-
return this.styles.tfoot(options);
|
|
151
|
-
}
|
|
152
|
-
get rowClassNames() {
|
|
153
|
-
const options = {
|
|
154
|
-
class: twMerge('', this.args.classes?.tr || ''),
|
|
155
|
-
isSticky: false
|
|
156
|
-
};
|
|
157
|
-
return this.styles.tr(options);
|
|
158
|
-
}
|
|
159
|
-
get separatorClassNames() {
|
|
160
|
-
return this.styles.separator({
|
|
161
|
-
class: this.args.classes?.separator
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
static {
|
|
165
|
-
setComponentTemplate(precompileTemplate("\n <tfoot class={{this.classNames}} data-test-id=\"table-footer\" data-component=\"table-footer\" ...attributes>\n <tr class={{this.separatorClassNames}} />\n <tr class={{this.rowClassNames}}>\n {{yield (hash Column=SimpleTableColumn)}}\n </tr>\n </tfoot>\n ", {
|
|
166
|
-
strictMode: true,
|
|
167
|
-
scope: () => ({
|
|
168
|
-
hash,
|
|
169
|
-
SimpleTableColumn
|
|
170
|
-
})
|
|
171
|
-
}), this);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
class SimpleTable extends Component {
|
|
176
|
-
get hasWrapper() {
|
|
177
|
-
return this.args.hasWrapper ?? true;
|
|
178
|
-
}
|
|
179
|
-
get styles() {
|
|
180
|
-
const {
|
|
181
|
-
table
|
|
182
|
-
} = useStyles();
|
|
183
|
-
return table({
|
|
184
|
-
size: this.args.size,
|
|
185
|
-
layout: this.args.layout,
|
|
186
|
-
striped: this.args.isStriped,
|
|
187
|
-
isScrollable: this.args.isScrollable || false,
|
|
188
|
-
hasStickyHeader: false,
|
|
189
|
-
isLoading: this.args.hasCustomLoading ? false : this.args.isLoading || false,
|
|
190
|
-
loadingColor: this.args.loadingColor,
|
|
191
|
-
selectionColor: this.args.selectionColor,
|
|
192
|
-
class: this.args.classes?.base
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
get wrapperClassNames() {
|
|
196
|
-
return this.styles.wrapper({
|
|
197
|
-
class: this.args.classes?.wrapper
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
get tableClassNames() {
|
|
201
|
-
return this.styles.table({
|
|
202
|
-
class: this.args.classes?.table
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
static {
|
|
206
|
-
setComponentTemplate(precompileTemplate("\n {{#if this.hasWrapper}}\n <div class={{this.wrapperClassNames}} data-component=\"table-wrapper\">\n <table class={{this.tableClassNames}} data-test-id=\"table\" data-component=\"table\" data-loading={{if this.args.isLoading \"true\" \"false\"}} ...attributes>\n {{yield (hash Header=(component SimpleTableHeader styleFns=this.styles classes=this.args.classes) Body=(component SimpleTableBody styleFns=this.styles classes=this.args.classes) Footer=(component SimpleTableFooter styleFns=this.styles classes=this.args.classes) Column=(component SimpleTableColumn styleFns=this.styles) Row=(component SimpleTableRow styleFns=this.styles classes=this.args.classes) Cell=(component SimpleTableCell styleFns=this.styles classes=this.args.classes))}}\n </table>\n </div>\n {{else}}\n <table class={{this.tableClassNames}} data-test-id=\"table\" data-component=\"table\" data-loading={{if this.args.isLoading \"true\" \"false\"}} ...attributes>\n {{yield (hash Header=(component SimpleTableHeader styleFns=this.styles classes=this.args.classes) Body=(component SimpleTableBody styleFns=this.styles classes=this.args.classes) Footer=(component SimpleTableFooter styleFns=this.styles classes=this.args.classes) Column=(component SimpleTableColumn styleFns=this.styles) Row=(component SimpleTableRow styleFns=this.styles classes=this.args.classes) Cell=(component SimpleTableCell styleFns=this.styles classes=this.args.classes))}}\n </table>\n {{/if}}\n ", {
|
|
207
|
-
strictMode: true,
|
|
208
|
-
scope: () => ({
|
|
209
|
-
hash,
|
|
210
|
-
SimpleTableHeader,
|
|
211
|
-
SimpleTableBody,
|
|
212
|
-
SimpleTableFooter,
|
|
213
|
-
SimpleTableColumn,
|
|
214
|
-
SimpleTableRow,
|
|
215
|
-
SimpleTableCell
|
|
216
|
-
})
|
|
217
|
-
}), this);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Helper to extract Frontile sticky options from a universal-ember column's pluginOptions
|
|
223
|
-
*/
|
|
224
|
-
function extractFrontileOptions(column) {
|
|
225
|
-
if (!column?.config?.pluginOptions) {
|
|
226
|
-
return undefined;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Find the frontile plugin option
|
|
230
|
-
const pluginOptions = column.config.pluginOptions;
|
|
231
|
-
const frontileOption = pluginOptions.find(option => Array.isArray(option) && option[0] === 'frontile');
|
|
232
|
-
if (frontileOption && typeof frontileOption[1] === 'function') {
|
|
233
|
-
return frontileOption[1]();
|
|
234
|
-
}
|
|
235
|
-
return undefined;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Icon components used in the table component
|
|
240
|
-
*/
|
|
241
|
-
const ChevronUpIcon = setComponentTemplate(precompileTemplate("\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" ...attributes>\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"m4.5 15.75 7.5-7.5 7.5 7.5\" />\n </svg>\n", {
|
|
242
|
-
strictMode: true
|
|
243
|
-
}), templateOnly());
|
|
244
|
-
const ChevronDownIcon = setComponentTemplate(precompileTemplate("\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" ...attributes>\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"m19.5 8.25-7.5 7.5-7.5-7.5\" />\n </svg>\n", {
|
|
245
|
-
strictMode: true
|
|
246
|
-
}), templateOnly());
|
|
247
|
-
const ColumnVisibilityIcon = setComponentTemplate(precompileTemplate("\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" ...attributes>\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 4.5v15m6-15v15m-10.875 0h15.75c.621 0 1.125-.504 1.125-1.125V5.625c0-.621-.504-1.125-1.125-1.125H4.125C3.504 4.5 3 5.004 3 5.625v12.75c0 .621.504 1.125 1.125 1.125Z\" />\n </svg>\n", {
|
|
248
|
-
strictMode: true
|
|
249
|
-
}), templateOnly());
|
|
250
|
-
|
|
251
|
-
class ColumnVisibility extends Component {
|
|
252
|
-
get styles() {
|
|
253
|
-
const {
|
|
254
|
-
table
|
|
255
|
-
} = useStyles();
|
|
256
|
-
return table();
|
|
257
|
-
}
|
|
258
|
-
get size() {
|
|
259
|
-
return this.args.size ?? 'xs';
|
|
260
|
-
}
|
|
261
|
-
get columns() {
|
|
262
|
-
return this.args.tableInstance?.columns.values() || [];
|
|
263
|
-
}
|
|
264
|
-
get selectedKeys() {
|
|
265
|
-
return this.columns.filter(column => isVisible(column)).map(column => column.key);
|
|
266
|
-
}
|
|
267
|
-
get allColumnKeys() {
|
|
268
|
-
return this.columns.map(column => column.key);
|
|
269
|
-
}
|
|
270
|
-
handleSelectionChange(selectedKeys) {
|
|
271
|
-
this.columns.forEach(column => {
|
|
272
|
-
if (selectedKeys.includes(column.key)) {
|
|
273
|
-
if (!isVisible(column)) {
|
|
274
|
-
show(column);
|
|
275
|
-
}
|
|
276
|
-
} else {
|
|
277
|
-
if (isVisible(column)) {
|
|
278
|
-
hide(column);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
static {
|
|
284
|
-
decorateMethodV2(this.prototype, "handleSelectionChange", [action]);
|
|
285
|
-
}
|
|
286
|
-
static {
|
|
287
|
-
setComponentTemplate(precompileTemplate("\n <Dropdown @closeOnItemSelect={{false}} ...attributes>\n <:default as |d|>\n <d.Trigger @intent=\"default\" @size={{this.size}} @class={{(this.styles.columnVisibilityButton)}}>\n\n {{#if (has-block \"icon\")}}\n {{yield to=\"icon\"}}\n {{else}}\n <ColumnVisibilityIcon class={{(this.styles.columnVisibilityIcon)}} />\n {{/if}}\n {{yield}}\n </d.Trigger>\n\n <d.Menu @selectionMode=\"multiple\" @selectedKeys={{this.selectedKeys}} @onSelectionChange={{this.handleSelectionChange}} as |Item|>\n {{#each @tableInstance.columns as |column|}}\n <Item @key={{column.key}}>\n {{column.name}}\n </Item>\n {{/each}}\n </d.Menu>\n </:default>\n </Dropdown>\n ", {
|
|
288
|
-
strictMode: true,
|
|
289
|
-
scope: () => ({
|
|
290
|
-
Dropdown,
|
|
291
|
-
ColumnVisibilityIcon
|
|
292
|
-
})
|
|
293
|
-
}), this);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Conditional rendering component for table cells. Only renders its content
|
|
299
|
-
* when the current column key matches the specified @key argument.
|
|
300
|
-
*
|
|
301
|
-
* Usage:
|
|
302
|
-
* ```hbs
|
|
303
|
-
* <c.For @key="status">
|
|
304
|
-
* <StatusBadge @status={{c.value}} />
|
|
305
|
-
* </c.For>
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
class CellForComponent extends Component {
|
|
309
|
-
get shouldRender() {
|
|
310
|
-
const matches = this.args.column.key === this.args.key;
|
|
311
|
-
// If this component matches the current column, claim the key
|
|
312
|
-
// so that CellDefaultComponent knows not to render
|
|
313
|
-
if (matches) {
|
|
314
|
-
this.args.registry.claimKey(this.args.key);
|
|
315
|
-
}
|
|
316
|
-
return matches;
|
|
317
|
-
}
|
|
318
|
-
static {
|
|
319
|
-
setComponentTemplate(precompileTemplate("\n {{#if this.shouldRender}}\n {{yield}}\n {{/if}}\n ", {
|
|
320
|
-
strictMode: true
|
|
321
|
-
}), this);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Default/fallback rendering component for table cells. Only renders its content
|
|
327
|
-
* when no CellForComponent has claimed the current column key.
|
|
328
|
-
*
|
|
329
|
-
* Usage:
|
|
330
|
-
* ```hbs
|
|
331
|
-
* <c.Default>
|
|
332
|
-
* Default: {{c.value}}
|
|
333
|
-
* </c.Default>
|
|
334
|
-
*
|
|
335
|
-
* <!-- Or with explicit exclusions -->
|
|
336
|
-
* <c.Default @except={{array "status" "actions"}}>
|
|
337
|
-
* {{c.value}}
|
|
338
|
-
* </c.Default>
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
class CellDefaultComponent extends Component {
|
|
342
|
-
get shouldRender() {
|
|
343
|
-
const currentKey = this.args.column.key;
|
|
344
|
-
// Check explicit exclusions first
|
|
345
|
-
if (this.args.except?.includes(currentKey)) {
|
|
346
|
-
return false;
|
|
347
|
-
}
|
|
348
|
-
// Check if any CellForComponent has claimed this key
|
|
349
|
-
return !this.args.registry.isKeyClaimed(currentKey);
|
|
350
|
-
}
|
|
351
|
-
static {
|
|
352
|
-
setComponentTemplate(precompileTemplate("\n {{#if this.shouldRender}}\n {{yield}}\n {{/if}}\n ", {
|
|
353
|
-
strictMode: true
|
|
354
|
-
}), this);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
class SortButton extends Component {
|
|
359
|
-
get styles() {
|
|
360
|
-
const {
|
|
361
|
-
table
|
|
362
|
-
} = useStyles();
|
|
363
|
-
return table();
|
|
364
|
-
}
|
|
365
|
-
get showUpIcon() {
|
|
366
|
-
return this.args.sortDirection === SortDirection.Ascending;
|
|
367
|
-
}
|
|
368
|
-
static {
|
|
369
|
-
setComponentTemplate(precompileTemplate("\n <button type=\"button\" class=\"{{(this.styles.sortButton)}}\" data-sort-direction={{@sortDirection}} data-sorted=\"{{@isSorted}}\" {{press @onSort}} ...attributes>\n <span>\n {{@column.name}}\n </span>\n {{#if this.showUpIcon}}\n <ChevronUpIcon class={{(this.styles.sortIcon)}} data-sorted=\"{{@isSorted}}\" aria-hidden=\"true\" />\n {{else}}\n <ChevronDownIcon class={{(this.styles.sortIcon)}} data-sorted=\"{{@isSorted}}\" aria-hidden=\"true\" />\n {{/if}}\n </button>\n ", {
|
|
370
|
-
strictMode: true,
|
|
371
|
-
scope: () => ({
|
|
372
|
-
press,
|
|
373
|
-
ChevronUpIcon,
|
|
374
|
-
ChevronDownIcon
|
|
375
|
-
})
|
|
376
|
-
}), this);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Internal checkbox component for table selection.
|
|
382
|
-
* Simplified version without FormControl wrapper.
|
|
383
|
-
*/
|
|
384
|
-
class Checkbox extends Component {
|
|
385
|
-
get isChecked() {
|
|
386
|
-
return !!this.args.checked;
|
|
387
|
-
}
|
|
388
|
-
handleChange(event) {
|
|
389
|
-
if (this.args.disabled) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
const target = event.target;
|
|
393
|
-
const value = target.checked;
|
|
394
|
-
if (typeof this.args.onChange === 'function') {
|
|
395
|
-
this.args.onChange(value, event);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
static {
|
|
399
|
-
decorateMethodV2(this.prototype, "handleChange", [action]);
|
|
400
|
-
}
|
|
401
|
-
get classes() {
|
|
402
|
-
const {
|
|
403
|
-
checkbox
|
|
404
|
-
} = useStyles();
|
|
405
|
-
return checkbox({
|
|
406
|
-
size: this.args.size
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
setIndeterminate = modifier((element, [indeterminate]) => {
|
|
410
|
-
element.indeterminate = !!indeterminate;
|
|
411
|
-
});
|
|
412
|
-
static {
|
|
413
|
-
setComponentTemplate(precompileTemplate("\n <input {{on \"change\" this.handleChange}} {{this.setIndeterminate @indeterminate}} type=\"checkbox\" checked={{this.isChecked}} disabled={{@disabled}} class={{this.classes.input class=@classes.input}} aria-label={{@ariaLabel}} aria-labelledby={{@ariaLabelledby}} aria-checked={{if @indeterminate \"mixed\" (if this.isChecked \"true\" \"false\")}} ...attributes />\n ", {
|
|
414
|
-
strictMode: true,
|
|
415
|
-
scope: () => ({
|
|
416
|
-
on
|
|
417
|
-
})
|
|
418
|
-
}), this);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Context class to track which column keys have been claimed by CellForComponent
|
|
424
|
-
* instances during cell rendering. This enables CellDefaultComponent to only
|
|
425
|
-
* render when no specific column renderer has claimed the current column key.
|
|
426
|
-
*/
|
|
427
|
-
class CellRenderingContext {
|
|
428
|
-
claimedKeys = new Set();
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Mark a column key as claimed by a CellForComponent
|
|
432
|
-
*/
|
|
433
|
-
claimKey(key) {
|
|
434
|
-
this.claimedKeys.add(key);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Check if a column key has been claimed by any CellForComponent
|
|
439
|
-
*/
|
|
440
|
-
isKeyClaimed(key) {
|
|
441
|
-
return this.claimedKeys.has(key);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Reset the claimed keys (called between cell renders)
|
|
446
|
-
*/
|
|
447
|
-
reset() {
|
|
448
|
-
this.claimedKeys.clear();
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Get all claimed keys (useful for debugging)
|
|
453
|
-
*/
|
|
454
|
-
get claimedKeysList() {
|
|
455
|
-
return Array.from(this.claimedKeys);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const and = (a, b) => {
|
|
460
|
-
return a && b;
|
|
461
|
-
};
|
|
462
|
-
// Standalone helper functions that don't depend on component state
|
|
463
|
-
function columnIsSticky(column) {
|
|
464
|
-
const frontileOptions = extractFrontileOptions(column);
|
|
465
|
-
return frontileOptions?.isSticky ?? false;
|
|
466
|
-
}
|
|
467
|
-
function columnStickyPosition(column) {
|
|
468
|
-
const frontileOptions = extractFrontileOptions(column);
|
|
469
|
-
return frontileOptions?.stickyPosition;
|
|
470
|
-
}
|
|
471
|
-
function createCellContext(column, row) {
|
|
472
|
-
const registry = new CellRenderingContext();
|
|
473
|
-
return {
|
|
474
|
-
column,
|
|
475
|
-
row,
|
|
476
|
-
value: column.getValueForRow(row),
|
|
477
|
-
registry
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
function columnIsSorted(column) {
|
|
481
|
-
return sortDirection(column) !== 'none';
|
|
482
|
-
}
|
|
483
|
-
function isSelectionColumn(column) {
|
|
484
|
-
return column.key === '__selection__';
|
|
485
|
-
}
|
|
486
|
-
const calculateHeaderHeight = modifier((el, [isStickyHeader]) => {
|
|
487
|
-
if (isStickyHeader) {
|
|
488
|
-
const updateHeight = () => {
|
|
489
|
-
const thead = el.querySelector('thead');
|
|
490
|
-
if (thead) {
|
|
491
|
-
const headerHeight = Math.round(thead.offsetHeight);
|
|
492
|
-
el.style.setProperty('--table-header-height', `${headerHeight}px`);
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
requestAnimationFrame(updateHeight);
|
|
496
|
-
// Update on resize
|
|
497
|
-
let observer;
|
|
498
|
-
observer = new ResizeObserver(updateHeight);
|
|
499
|
-
observer.observe(el);
|
|
500
|
-
return () => {
|
|
501
|
-
if (observer) {
|
|
502
|
-
observer.disconnect();
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
class Table extends Component {
|
|
508
|
-
ColumnVisibility = ColumnVisibility;
|
|
509
|
-
CellFor = CellForComponent;
|
|
510
|
-
CellDefault = CellDefaultComponent;
|
|
511
|
-
SortButton = SortButton;
|
|
512
|
-
Checkbox = Checkbox;
|
|
513
|
-
// Tracked state for sorting
|
|
514
|
-
static {
|
|
515
|
-
decorateFieldV2(this.prototype, "sorts", [tracked], function () {
|
|
516
|
-
return [];
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
#sorts = (initializeDeferredDecorator(this, "sorts"), void 0);
|
|
520
|
-
static {
|
|
521
|
-
decorateFieldV2(this.prototype, "internalSelectedKeys", [tracked], function () {
|
|
522
|
-
return new Set();
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
#internalSelectedKeys = (initializeDeferredDecorator(this, "internalSelectedKeys"), void 0); // Tracked state for uncontrolled selection
|
|
526
|
-
constructor(owner, args) {
|
|
527
|
-
super(owner, args);
|
|
528
|
-
// Initialize sorts from initialSort if provided (only on mount)
|
|
529
|
-
if (args.initialSort) {
|
|
530
|
-
this.sorts = [args.initialSort];
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
// Selection helpers
|
|
534
|
-
get selectionMode() {
|
|
535
|
-
return this.args.selectionMode ?? 'none';
|
|
536
|
-
}
|
|
537
|
-
get hasSelection() {
|
|
538
|
-
return this.selectionMode !== 'none';
|
|
539
|
-
}
|
|
540
|
-
get selectedKeysSet() {
|
|
541
|
-
// Use controlled state if provided, otherwise use internal state
|
|
542
|
-
const isControlled = this.args.selectedKeys !== undefined;
|
|
543
|
-
const sourceKeys = isControlled ? this.args.selectedKeys : this.internalSelectedKeys;
|
|
544
|
-
if (!sourceKeys) {
|
|
545
|
-
return new Set();
|
|
546
|
-
}
|
|
547
|
-
return sourceKeys instanceof Set ? sourceKeys : new Set(sourceKeys);
|
|
548
|
-
}
|
|
549
|
-
static {
|
|
550
|
-
decorateMethodV2(this.prototype, "selectedKeysSet", [cached]);
|
|
551
|
-
}
|
|
552
|
-
get disabledKeysSet() {
|
|
553
|
-
const keys = this.args.disabledKeys;
|
|
554
|
-
return keys ? new Set(keys) : new Set();
|
|
555
|
-
}
|
|
556
|
-
// Extract actual data from row (handles both row.data and direct row)
|
|
557
|
-
static {
|
|
558
|
-
decorateMethodV2(this.prototype, "disabledKeysSet", [cached]);
|
|
559
|
-
}
|
|
560
|
-
getRowData = row => {
|
|
561
|
-
if (row.data && row.table) {
|
|
562
|
-
return row.data;
|
|
563
|
-
}
|
|
564
|
-
return row;
|
|
565
|
-
};
|
|
566
|
-
// Get key from item or row - unified method
|
|
567
|
-
getKey = itemOrRow => {
|
|
568
|
-
// Extract the actual item from row if needed
|
|
569
|
-
const item = itemOrRow.data ? this.getRowData(itemOrRow) : itemOrRow;
|
|
570
|
-
// Use provided getKey function if available
|
|
571
|
-
if (this.args.getKey) {
|
|
572
|
-
return this.args.getKey(item);
|
|
573
|
-
}
|
|
574
|
-
// Try keyAndLabelForItem helper
|
|
575
|
-
try {
|
|
576
|
-
const {
|
|
577
|
-
key
|
|
578
|
-
} = keyAndLabelForItem(item);
|
|
579
|
-
return key;
|
|
580
|
-
} catch {
|
|
581
|
-
// Final fallback
|
|
582
|
-
return String(item);
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
// Check if a key is disabled
|
|
586
|
-
isKeyDisabled = key => {
|
|
587
|
-
return this.disabledKeysSet.has(key);
|
|
588
|
-
};
|
|
589
|
-
// Selection handlers
|
|
590
|
-
handleSelect = key => {
|
|
591
|
-
if (this.isKeyDisabled(key)) return;
|
|
592
|
-
const newSelection = new Set(this.selectedKeysSet);
|
|
593
|
-
if (this.selectionMode === 'single') {
|
|
594
|
-
// Single selection: clear all and add only the new one
|
|
595
|
-
newSelection.clear();
|
|
596
|
-
newSelection.add(key);
|
|
597
|
-
} else {
|
|
598
|
-
// Multiple selection: add to existing
|
|
599
|
-
newSelection.add(key);
|
|
600
|
-
}
|
|
601
|
-
// Update internal state if uncontrolled
|
|
602
|
-
const isControlled = this.args.selectedKeys !== undefined;
|
|
603
|
-
if (!isControlled) {
|
|
604
|
-
this.internalSelectedKeys = newSelection;
|
|
605
|
-
}
|
|
606
|
-
// Always call onChange callback if provided
|
|
607
|
-
this.args.onSelectionChange?.(newSelection);
|
|
608
|
-
};
|
|
609
|
-
handleDeselect = key => {
|
|
610
|
-
if (this.isKeyDisabled(key)) return;
|
|
611
|
-
const newSelection = new Set(this.selectedKeysSet);
|
|
612
|
-
newSelection.delete(key);
|
|
613
|
-
// Update internal state if uncontrolled
|
|
614
|
-
const isControlled = this.args.selectedKeys !== undefined;
|
|
615
|
-
if (!isControlled) {
|
|
616
|
-
this.internalSelectedKeys = newSelection;
|
|
617
|
-
}
|
|
618
|
-
// Always call onChange callback if provided
|
|
619
|
-
this.args.onSelectionChange?.(newSelection);
|
|
620
|
-
};
|
|
621
|
-
// Check if a row is selected
|
|
622
|
-
isRowSelected = row => {
|
|
623
|
-
return this.selectedKeysSet.has(this.getKey(row.data));
|
|
624
|
-
};
|
|
625
|
-
// Check if a row is disabled
|
|
626
|
-
isRowDisabled = row => {
|
|
627
|
-
return this.isKeyDisabled(this.getKey(row.data));
|
|
628
|
-
};
|
|
629
|
-
// Handler for row checkbox change
|
|
630
|
-
handleRowSelectionChange = (row, checked) => {
|
|
631
|
-
const key = this.getKey(row.data);
|
|
632
|
-
if (checked) {
|
|
633
|
-
this.handleSelect(key);
|
|
634
|
-
} else {
|
|
635
|
-
this.handleDeselect(key);
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
// Handler for keyboard row selection and navigation
|
|
639
|
-
handleRowKeydown = (row, event) => {
|
|
640
|
-
if (!this.hasSelection) return;
|
|
641
|
-
// Handle arrow key navigation
|
|
642
|
-
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
643
|
-
event.preventDefault();
|
|
644
|
-
const currentElement = event.target;
|
|
645
|
-
const allRows = Array.from(currentElement.closest('tbody')?.querySelectorAll('[data-selectable="true"]') || []);
|
|
646
|
-
const currentIndex = allRows.indexOf(currentElement);
|
|
647
|
-
if (event.key === 'ArrowDown' && currentIndex < allRows.length - 1) {
|
|
648
|
-
allRows[currentIndex + 1]?.focus();
|
|
649
|
-
} else if (event.key === 'ArrowUp' && currentIndex > 0) {
|
|
650
|
-
allRows[currentIndex - 1]?.focus();
|
|
651
|
-
}
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
// Handle selection (Space/Enter)
|
|
655
|
-
if (this.isRowDisabled(row)) return;
|
|
656
|
-
// Only handle Space and Enter keys
|
|
657
|
-
if (event.key !== ' ' && event.key !== 'Enter') return;
|
|
658
|
-
// Prevent default behavior (scroll for Space, form submission for Enter)
|
|
659
|
-
event.preventDefault();
|
|
660
|
-
const key = this.getKey(row.data);
|
|
661
|
-
const isSelected = this.isRowSelected(row);
|
|
662
|
-
if (this.selectionMode === 'single') {
|
|
663
|
-
// Single selection: always select the row
|
|
664
|
-
this.handleSelect(key);
|
|
665
|
-
} else {
|
|
666
|
-
// Multiple selection: toggle
|
|
667
|
-
if (isSelected) {
|
|
668
|
-
this.handleDeselect(key);
|
|
669
|
-
} else {
|
|
670
|
-
this.handleSelect(key);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
};
|
|
674
|
-
// Modifier for row keyboard navigation
|
|
675
|
-
rowKeyboardHandler = modifier((element, [row]) => {
|
|
676
|
-
const handler = event => {
|
|
677
|
-
this.handleRowKeydown(row, event);
|
|
678
|
-
};
|
|
679
|
-
element.addEventListener('keydown', handler);
|
|
680
|
-
return () => {
|
|
681
|
-
element.removeEventListener('keydown', handler);
|
|
682
|
-
};
|
|
683
|
-
});
|
|
684
|
-
// Get all selectable (non-disabled) item keys
|
|
685
|
-
get selectableKeys() {
|
|
686
|
-
const items = this.args.items || [];
|
|
687
|
-
return items.map(item => this.getKey(item)).filter(key => !this.isKeyDisabled(key));
|
|
688
|
-
}
|
|
689
|
-
// Check if all selectable rows are selected
|
|
690
|
-
get isAllSelected() {
|
|
691
|
-
if (this.selectableKeys.length === 0) return false;
|
|
692
|
-
return this.selectableKeys.every(key => this.selectedKeysSet.has(key));
|
|
693
|
-
}
|
|
694
|
-
// Check if some (but not all) selectable rows are selected
|
|
695
|
-
get isSomeSelected() {
|
|
696
|
-
if (this.selectedKeysSet.size === 0) return false;
|
|
697
|
-
if (this.isAllSelected) return false;
|
|
698
|
-
return this.selectableKeys.some(key => this.selectedKeysSet.has(key));
|
|
699
|
-
}
|
|
700
|
-
// Handler for select all checkbox change
|
|
701
|
-
handleSelectAllChange = checked => {
|
|
702
|
-
const newSelection = new Set(this.selectedKeysSet);
|
|
703
|
-
if (checked) {
|
|
704
|
-
// Select all selectable rows
|
|
705
|
-
this.selectableKeys.forEach(key => {
|
|
706
|
-
newSelection.add(key);
|
|
707
|
-
});
|
|
708
|
-
} else {
|
|
709
|
-
// Deselect all selectable rows
|
|
710
|
-
this.selectableKeys.forEach(key => {
|
|
711
|
-
newSelection.delete(key);
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
// Update internal state if uncontrolled
|
|
715
|
-
const isControlled = this.args.selectedKeys !== undefined;
|
|
716
|
-
if (!isControlled) {
|
|
717
|
-
this.internalSelectedKeys = newSelection;
|
|
718
|
-
}
|
|
719
|
-
// Always call onChange callback if provided
|
|
720
|
-
this.args.onSelectionChange?.(newSelection);
|
|
721
|
-
};
|
|
722
|
-
// Add checkbox column for multiple selection
|
|
723
|
-
get columnsWithSelection() {
|
|
724
|
-
if (this.selectionMode !== 'multiple') {
|
|
725
|
-
return this.args.columns;
|
|
726
|
-
}
|
|
727
|
-
// Add checkbox column as the first column
|
|
728
|
-
const checkboxColumn = {
|
|
729
|
-
key: '__selection__',
|
|
730
|
-
name: '',
|
|
731
|
-
isSticky: this.args.isScrollable || false,
|
|
732
|
-
stickyPosition: 'left'
|
|
733
|
-
};
|
|
734
|
-
return [checkboxColumn, ...this.args.columns];
|
|
735
|
-
}
|
|
736
|
-
// Transform Frontile ColumnConfig to universal-ember ColumnConfig with pluginOptions
|
|
737
|
-
processColumns(columns) {
|
|
738
|
-
if (!columns) return [];
|
|
739
|
-
return columns.map(column => {
|
|
740
|
-
const {
|
|
741
|
-
isSticky,
|
|
742
|
-
stickyPosition,
|
|
743
|
-
isVisible,
|
|
744
|
-
isSortable,
|
|
745
|
-
sortProperty,
|
|
746
|
-
Cell,
|
|
747
|
-
value,
|
|
748
|
-
...baseColumn
|
|
749
|
-
} = column;
|
|
750
|
-
const pluginOptions = [];
|
|
751
|
-
// Add Frontile sticky options if present
|
|
752
|
-
if (isSticky !== undefined || stickyPosition !== undefined) {
|
|
753
|
-
const frontileOption = ['frontile', () => ({
|
|
754
|
-
isSticky,
|
|
755
|
-
stickyPosition
|
|
756
|
-
})];
|
|
757
|
-
pluginOptions.push(frontileOption);
|
|
758
|
-
}
|
|
759
|
-
// Add ColumnVisibility plugin option if isVisible is explicitly set
|
|
760
|
-
if (isVisible !== undefined) {
|
|
761
|
-
pluginOptions.push(ColumnVisibility$1.forColumn(() => ({
|
|
762
|
-
isVisible
|
|
763
|
-
})));
|
|
764
|
-
}
|
|
765
|
-
// Add DataSorting plugin option - always add it to override the default (true) with our default (false)
|
|
766
|
-
pluginOptions.push(DataSorting.forColumn(() => ({
|
|
767
|
-
isSortable: isSortable ?? false,
|
|
768
|
-
sortProperty
|
|
769
|
-
})));
|
|
770
|
-
// Create the universal-ember column configuration
|
|
771
|
-
const universalColumn = {
|
|
772
|
-
key: baseColumn.key,
|
|
773
|
-
name: baseColumn.name,
|
|
774
|
-
pluginOptions: pluginOptions.length > 0 ? pluginOptions : undefined
|
|
775
|
-
};
|
|
776
|
-
// Add value function if provided
|
|
777
|
-
if (value) {
|
|
778
|
-
universalColumn.value = value;
|
|
779
|
-
}
|
|
780
|
-
// Add Cell component if provided
|
|
781
|
-
if (Cell) {
|
|
782
|
-
universalColumn.Cell = Cell;
|
|
783
|
-
}
|
|
784
|
-
return universalColumn;
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
// Handler for sort state changes from the DataSorting plugin
|
|
788
|
-
handleSortChange = newSorts => {
|
|
789
|
-
this.sorts = newSorts;
|
|
790
|
-
};
|
|
791
|
-
tableInstance = headlessTable(this, {
|
|
792
|
-
data: () => this.sortedItems,
|
|
793
|
-
columns: () => this.processColumns(this.columnsWithSelection),
|
|
794
|
-
plugins: [ColumnVisibility$1, DataSorting.with(() => ({
|
|
795
|
-
sorts: this.sorts,
|
|
796
|
-
onSort: this.handleSortChange
|
|
797
|
-
})), ...(this.hasSelection ? [RowSelection.with(() => ({
|
|
798
|
-
selection: this.selectedKeysSet,
|
|
799
|
-
key: this.getKey,
|
|
800
|
-
onSelect: this.handleSelect,
|
|
801
|
-
onDeselect: this.handleDeselect
|
|
802
|
-
}))] : [])]
|
|
803
|
-
});
|
|
804
|
-
// Computed property that returns sorted items based on current sort state
|
|
805
|
-
get sortedItems() {
|
|
806
|
-
const items = this.args.items || [];
|
|
807
|
-
// If no onSort handler or no active sorts, return items as-is
|
|
808
|
-
if (!this.args.onSort || this.sorts.length === 0) {
|
|
809
|
-
return items;
|
|
810
|
-
}
|
|
811
|
-
// Only use the first sort item (single column sorting)
|
|
812
|
-
const sortDescriptor = this.sorts[0];
|
|
813
|
-
if (!sortDescriptor) {
|
|
814
|
-
return items;
|
|
815
|
-
}
|
|
816
|
-
return this.args.onSort(items, sortDescriptor);
|
|
817
|
-
}
|
|
818
|
-
get styles() {
|
|
819
|
-
const {
|
|
820
|
-
table
|
|
821
|
-
} = useStyles();
|
|
822
|
-
return table({
|
|
823
|
-
size: this.args.size,
|
|
824
|
-
layout: this.args.layout,
|
|
825
|
-
striped: this.args.isStriped,
|
|
826
|
-
isScrollable: this.args.isScrollable || false,
|
|
827
|
-
hasStickyHeader: this.args.isStickyHeader || false,
|
|
828
|
-
isLoading: this.args.isLoading || false,
|
|
829
|
-
loadingColor: this.args.loadingColor,
|
|
830
|
-
selectionColor: this.args.selectionColor,
|
|
831
|
-
class: this.args.classes?.base
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
get wrapperClassNames() {
|
|
835
|
-
return this.styles.wrapper({
|
|
836
|
-
class: this.args.classes?.wrapper
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
get tableClassNames() {
|
|
840
|
-
return this.styles.table({
|
|
841
|
-
class: this.args.classes?.table
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
get headlessColumns() {
|
|
845
|
-
return columns.for(this.tableInstance);
|
|
846
|
-
}
|
|
847
|
-
get headlessRows() {
|
|
848
|
-
return this.tableInstance.rows.values();
|
|
849
|
-
}
|
|
850
|
-
// Helper to check if a row is sticky
|
|
851
|
-
isRowSticky = row => {
|
|
852
|
-
return !!this.args.stickyKeys?.includes(this.getKey(row));
|
|
853
|
-
};
|
|
854
|
-
static {
|
|
855
|
-
setComponentTemplate(precompileTemplate("\n <div class={{this.wrapperClassNames}} {{calculateHeaderHeight @isStickyHeader}} {{this.tableInstance.modifiers.container}} data-component=\"table-wrapper\">\n {{#if (has-block \"toolbar\")}}\n <div class=\"table-toolbar\" data-component=\"table-toolbar\">\n {{yield (hash ColumnVisibility=(component this.ColumnVisibility tableInstance=this.tableInstance)) to=\"toolbar\"}}\n </div>\n {{/if}}\n\n <SimpleTable @classes={{this.args.classes}} @size={{@size}} @layout={{@layout}} @isStriped={{@isStriped}} @isScrollable={{@isScrollable}} @hasWrapper={{false}} @isLoading={{@isLoading}} @loadingColor={{@loadingColor}} @selectionColor={{@selectionColor}} @hasCustomLoading={{has-block \"loading\"}} as |t|>\n <t.Header @isSticky={{@isStickyHeader}}>\n {{#each this.headlessColumns as |column|}}\n <t.Column {{this.tableInstance.modifiers.columnHeader column}} @isSticky={{columnIsSticky column}} @stickyPosition={{columnStickyPosition column}} data-key={{column.key}} data-sortable=\"{{isColumnSortable column}}\">\n {{#if (isSelectionColumn column)}}\n {{!-- Selection column header - render select all checkbox if enabled (default true) --}}\n {{#if (if @showSelectAll @showSelectAll true)}}\n <this.Checkbox @checked={{this.isAllSelected}} @indeterminate={{this.isSomeSelected}} @onChange={{this.handleSelectAllChange}} @size={{@size}} @ariaLabel=\"Select all rows\" />\n {{/if}}\n {{else if (has-block \"header\")}}\n {{yield (hash column=column isSortable=(isColumnSortable column) sortDirection=(getColumnSortDirection column) isSorted=(columnIsSorted column) onSort=(fn sortColumn column)) to=\"header\"}}\n {{else if (isColumnSortable column)}}\n <this.SortButton @column={{column}} @sortDirection={{getColumnSortDirection column}} @isSorted={{columnIsSorted column}} @onSort={{fn sortColumn column}} />\n {{else}}\n {{column.name}}\n {{/if}}\n </t.Column>\n {{/each}}\n </t.Header>\n\n <t.Body>\n {{#if (has-block \"bodyTop\")}}\n {{yield to=\"bodyTop\"}}\n {{/if}}\n\n {{#each this.headlessRows as |row|}}\n <t.Row {{this.tableInstance.modifiers.row row}} {{this.rowKeyboardHandler row}} @isSticky={{this.isRowSticky row}} @hasStickyHeader={{@isStickyHeader}} data-key={{this.getKey row}} data-selected={{if (this.isRowSelected row) \"true\" \"false\"}} data-disabled={{if (this.isRowDisabled row) \"true\"}} data-selectable={{if this.hasSelection \"true\"}} tabindex={{if this.hasSelection \"0\" \"-1\"}}>\n {{#each this.headlessColumns as |column|}}\n <t.Cell @isSticky={{columnIsSticky column}} @stickyPosition={{columnStickyPosition column}} @isInStickyRow={{this.isRowSticky row}} data-column={{column.key}}>\n {{#if (isSelectionColumn column)}}\n {{!-- Selection column cell - render checkbox --}}\n <this.Checkbox @checked={{this.isRowSelected row}} @disabled={{this.isRowDisabled row}} @onChange={{fn this.handleRowSelectionChange row}} @size={{@size}} @ariaLabel=\"Select row\" />\n {{else if (has-block \"cell\")}}\n {{#let (createCellContext column row) as |cellContext|}}\n {{yield (hash column=cellContext.column value=cellContext.value row=cellContext.row For=(component this.CellFor column=column registry=cellContext.registry) Default=(component this.CellDefault column=column registry=cellContext.registry)) to=\"cell\"}}\n {{/let}}\n {{else}}\n {{#if column.Cell}}\n <column.Cell @row={{row}} @column={{column}} />\n {{else}}\n {{column.getValueForRow row}}\n {{/if}}\n {{/if}}\n </t.Cell>\n {{/each}}\n </t.Row>\n {{else}}\n {{#unless @isLoading}}\n {{#if (has-block \"empty\")}}\n <t.Row data-test-id=\"table-empty-row\">\n <t.Cell @class={{(this.styles.empty)}} colspan={{this.headlessColumns.length}} data-test-id=\"table-empty-cell\">\n {{yield to=\"empty\"}}\n </t.Cell>\n </t.Row>\n {{else if @emptyContent}}\n <t.Row data-test-id=\"table-empty-row\">\n <t.Cell @class={{(this.styles.empty)}} colspan={{this.headlessColumns.length}} data-test-id=\"table-empty-cell\">\n {{@emptyContent}}\n </t.Cell>\n </t.Row>\n {{/if}}\n {{/unless}}\n {{/each}}\n\n {{#if (and @isLoading (has-block \"loading\"))}}\n <t.Row data-test-id=\"table-loading-row\">\n <t.Cell colspan={{this.headlessColumns.length}} data-test-id=\"table-loading-cell\">\n {{yield to=\"loading\"}}\n </t.Cell>\n </t.Row>\n {{/if}}\n\n {{#if (has-block \"bodyBottom\")}}\n {{yield to=\"bodyBottom\"}}\n {{/if}}\n </t.Body>\n\n {{#if @footerColumns}}\n <t.Footer @isSticky={{@isStickyFooter}}>\n {{#each @footerColumns as |column|}}\n <t.Column data-key={{column.key}}>\n {{column.name}}\n </t.Column>\n {{/each}}\n </t.Footer>\n {{/if}}\n </SimpleTable>\n </div>\n ", {
|
|
856
|
-
strictMode: true,
|
|
857
|
-
scope: () => ({
|
|
858
|
-
calculateHeaderHeight,
|
|
859
|
-
hash,
|
|
860
|
-
SimpleTable,
|
|
861
|
-
columnIsSticky,
|
|
862
|
-
columnStickyPosition,
|
|
863
|
-
isColumnSortable: isSortable,
|
|
864
|
-
isSelectionColumn,
|
|
865
|
-
getColumnSortDirection: sortDirection,
|
|
866
|
-
columnIsSorted,
|
|
867
|
-
fn,
|
|
868
|
-
sortColumn: sort,
|
|
869
|
-
createCellContext,
|
|
870
|
-
and
|
|
871
|
-
})
|
|
872
|
-
}), this);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
export { SimpleTable as S, Table as T };
|
|
877
|
-
//# sourceMappingURL=table-DvivyvLm.js.map
|