ajo-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +126 -0
  3. package/dist/accordion.js +130 -0
  4. package/dist/avatar.js +54 -0
  5. package/dist/calendar.js +2 -0
  6. package/dist/carousel.js +239 -0
  7. package/dist/chart.js +790 -0
  8. package/dist/checkbox-group.js +70 -0
  9. package/dist/checkbox.js +77 -0
  10. package/dist/chunks/bar-CVafh6C1.js +99 -0
  11. package/dist/chunks/calendar-q8jZ8Cxr.js +1923 -0
  12. package/dist/chunks/collection-DtRB63U4.js +111 -0
  13. package/dist/chunks/data-table-DpkWv4y4.js +1039 -0
  14. package/dist/chunks/menu-B45IyHHC.js +704 -0
  15. package/dist/chunks/native-BJdhd9XJ.js +20 -0
  16. package/dist/chunks/popup-C8Bb3l_g.js +459 -0
  17. package/dist/chunks/popup-surface-BDCgtVU0.js +18 -0
  18. package/dist/chunks/position-D6_i_SRn.js +434 -0
  19. package/dist/chunks/virtual-list-B7hjGkjk.js +413 -0
  20. package/dist/collapsible.js +106 -0
  21. package/dist/command.js +263 -0
  22. package/dist/context-menu.js +112 -0
  23. package/dist/data-table.js +5 -0
  24. package/dist/dialog.js +207 -0
  25. package/dist/direction.js +22 -0
  26. package/dist/drawer.js +139 -0
  27. package/dist/field.js +26 -0
  28. package/dist/index.js +38 -0
  29. package/dist/input-date.js +994 -0
  30. package/dist/input-group.js +52 -0
  31. package/dist/input-otp.js +179 -0
  32. package/dist/menu.js +2 -0
  33. package/dist/menubar.js +236 -0
  34. package/dist/message-scroller.js +446 -0
  35. package/dist/navigation-menu.js +330 -0
  36. package/dist/popover.js +307 -0
  37. package/dist/progress.js +39 -0
  38. package/dist/radio-group.js +107 -0
  39. package/dist/resizable.js +172 -0
  40. package/dist/select.js +961 -0
  41. package/dist/sidebar.js +343 -0
  42. package/dist/slider.js +259 -0
  43. package/dist/switch.js +53 -0
  44. package/dist/tabs.js +182 -0
  45. package/dist/toast.js +492 -0
  46. package/dist/toggle-group.js +111 -0
  47. package/dist/toggle.js +52 -0
  48. package/dist/toolbar.js +127 -0
  49. package/dist/tooltip.js +196 -0
  50. package/dist/utils.js +104 -0
  51. package/dist/virtual-list.js +2 -0
  52. package/package.json +250 -0
  53. package/src/accordion.tsx +261 -0
  54. package/src/availability.ts +261 -0
  55. package/src/avatar.tsx +99 -0
  56. package/src/bar.ts +156 -0
  57. package/src/calendar.tsx +1441 -0
  58. package/src/carousel.tsx +424 -0
  59. package/src/chart.tsx +1194 -0
  60. package/src/checkbox-group.tsx +132 -0
  61. package/src/checkbox.tsx +130 -0
  62. package/src/collapsible.tsx +188 -0
  63. package/src/collection.ts +154 -0
  64. package/src/command.tsx +511 -0
  65. package/src/context-menu.tsx +233 -0
  66. package/src/data-table-contract.ts +143 -0
  67. package/src/data-table-model.ts +760 -0
  68. package/src/data-table.tsx +475 -0
  69. package/src/dialog.tsx +393 -0
  70. package/src/direction.tsx +45 -0
  71. package/src/drawer.tsx +251 -0
  72. package/src/field.tsx +61 -0
  73. package/src/index.ts +37 -0
  74. package/src/input-date.tsx +1539 -0
  75. package/src/input-group.tsx +142 -0
  76. package/src/input-otp.tsx +324 -0
  77. package/src/menu-cluster.ts +124 -0
  78. package/src/menu.tsx +1095 -0
  79. package/src/menubar.tsx +459 -0
  80. package/src/message-scroller.tsx +732 -0
  81. package/src/native.ts +26 -0
  82. package/src/navigation-menu.tsx +578 -0
  83. package/src/popover.tsx +519 -0
  84. package/src/popup-surface.tsx +31 -0
  85. package/src/popup.ts +569 -0
  86. package/src/position.ts +523 -0
  87. package/src/progress.tsx +70 -0
  88. package/src/radio-group.tsx +186 -0
  89. package/src/resizable.tsx +310 -0
  90. package/src/segments.ts +922 -0
  91. package/src/select.tsx +1501 -0
  92. package/src/sidebar.tsx +683 -0
  93. package/src/slider.tsx +424 -0
  94. package/src/switch.tsx +104 -0
  95. package/src/tabs.tsx +314 -0
  96. package/src/toast.tsx +923 -0
  97. package/src/toggle-group.tsx +249 -0
  98. package/src/toggle.tsx +91 -0
  99. package/src/toolbar.tsx +212 -0
  100. package/src/tooltip.tsx +359 -0
  101. package/src/utils.ts +204 -0
  102. package/src/virtual-list.tsx +205 -0
  103. package/src/virtual.ts +385 -0
@@ -0,0 +1,1039 @@
1
+ import { syncCheckedState } from "../utils.js";
2
+ import { Checkbox } from "../checkbox.js";
3
+ import { l as MenuSeparator, m as MenuTrigger, n as MenuCheckboxItem, o as MenuLabel, r as MenuContent, t as Menu } from "./menu-B45IyHHC.js";
4
+ import { Select, SelectContent, SelectItem, SelectList, SelectTrigger, SelectValue } from "../select.js";
5
+ import { Toolbar } from "../toolbar.js";
6
+ import { announce, dom, statefulRootAttrs } from "ajo-cloves";
7
+ import { Fragment, jsx, jsxs } from "ajo/jsx-runtime";
8
+ import { columnFilteringFeature, columnVisibilityFeature, constructTable, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, tableFeatures } from "@tanstack/table-core";
9
+ import { storeReactivityBindings } from "@tanstack/table-core/store-reactivity-bindings";
10
+ //#region packages/ajo-ui/src/data-table-model.ts
11
+ var dataTableStrategy = tableFeatures({
12
+ columnFilteringFeature,
13
+ columnVisibilityFeature,
14
+ globalFilteringFeature,
15
+ rowPaginationFeature,
16
+ rowSelectionFeature,
17
+ rowSortingFeature,
18
+ filteredRowModel: createFilteredRowModel(),
19
+ paginatedRowModel: createPaginatedRowModel(),
20
+ sortedRowModel: createSortedRowModel()
21
+ });
22
+ var DEFAULT_SIZES = [
23
+ 10,
24
+ 25,
25
+ 50
26
+ ];
27
+ var dataTableDefaultLabels = {
28
+ columns: "Columns",
29
+ deselectPage: "Deselect page",
30
+ deselectResults: "Deselect filtered results",
31
+ deselectRow: (row) => `Deselect ${row}`,
32
+ firstPage: "First page",
33
+ lastPage: "Last page",
34
+ nextPage: "Next page",
35
+ page: (page, pages) => `Page ${page} of ${pages}`,
36
+ pagination: (table) => `${table} pagination`,
37
+ previousPage: "Previous page",
38
+ reset: "Reset",
39
+ results: (count) => `${count} result${count === 1 ? "" : "s"}`,
40
+ rowsPerPage: "Rows per page",
41
+ search: "Search",
42
+ selectPage: "Select page",
43
+ selectResults: "Select filtered results",
44
+ selectRow: (row) => `Select ${row}`,
45
+ selected: (selected, total) => `${selected} of ${total} ${total === 1 ? "row" : "rows"} selected.`,
46
+ sort: (column, next) => `Sort ${column} ${next}`,
47
+ toolbar: (table) => `${table} controls`
48
+ };
49
+ var assertText = (value, name) => {
50
+ if (typeof value !== "string" || !value.trim()) throw new TypeError(`DataTable invalid ${name}`);
51
+ return value;
52
+ };
53
+ var encodeKey = (key, index) => {
54
+ if (typeof key === "string") {
55
+ if (!key) throw new TypeError(`DataTable invalid row key${index === void 0 ? "" : ` at ${index}`}`);
56
+ return `s:${key}`;
57
+ }
58
+ if (!Number.isFinite(key)) throw new TypeError(`DataTable invalid row key${index === void 0 ? "" : ` at ${index}`}`);
59
+ return `n:${Object.is(key, -0) ? 0 : key}`;
60
+ };
61
+ var columnId = (column) => {
62
+ return assertText(column.id ?? (typeof column.value === "string" ? column.value : void 0), "column id");
63
+ };
64
+ var scalarText = (value, column, index) => {
65
+ if (value == null) return "";
66
+ if (typeof value === "string" || typeof value === "boolean") return String(value);
67
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
68
+ throw new TypeError(`DataTable invalid searchable value ${column} at ${index}`);
69
+ };
70
+ var facetValues = (model, row, index) => {
71
+ const raw = model.column.facet?.values?.(row, index);
72
+ if (raw !== void 0) return (Array.isArray(raw) ? raw : [raw]).map((value) => assertText(value, `facet value ${model.id}`));
73
+ return [scalarText(model.read?.(row, index), model.id, index)];
74
+ };
75
+ var compareValues = (left, right, leftRow, rightRow, columnId, alphanumeric) => {
76
+ const leftMissing = left == null;
77
+ const rightMissing = right == null;
78
+ if (leftMissing || rightMissing) return leftMissing === rightMissing ? 0 : leftMissing ? 1 : -1;
79
+ if (typeof left !== typeof right) throw new TypeError(`DataTable mixed sort values ${columnId}`);
80
+ if (typeof left === "string") return alphanumeric();
81
+ if (typeof left === "number" && typeof right === "number") {
82
+ if (!Number.isFinite(left) || !Number.isFinite(right)) throw new TypeError(`DataTable invalid sort value ${columnId} at ${!Number.isFinite(left) ? leftRow.index : rightRow.index}`);
83
+ return left === right ? 0 : left < right ? -1 : 1;
84
+ }
85
+ if (typeof left === "boolean" && typeof right === "boolean") return left === right ? 0 : left ? 1 : -1;
86
+ throw new TypeError(`DataTable invalid sort value ${columnId}`);
87
+ };
88
+ var paginationConfig = (pagination) => {
89
+ const sizes = pagination === false ? DEFAULT_SIZES : pagination?.sizes ?? DEFAULT_SIZES;
90
+ if (!sizes.length) throw new RangeError("DataTable empty page sizes");
91
+ const seen = /* @__PURE__ */ new Set();
92
+ for (const size of sizes) {
93
+ if (!Number.isInteger(size) || size <= 0 || seen.has(size)) throw new RangeError("DataTable invalid page sizes");
94
+ seen.add(size);
95
+ }
96
+ const size = pagination === false ? sizes[0] : pagination?.defaultSize ?? sizes[0];
97
+ if (!seen.has(size)) throw new RangeError("DataTable default page size is unavailable");
98
+ return {
99
+ enabled: pagination !== false,
100
+ size,
101
+ sizes
102
+ };
103
+ };
104
+ var dataTableReactivity = (host) => {
105
+ const subscriptions = /* @__PURE__ */ new Set();
106
+ let disposed = false;
107
+ const dispose = () => {
108
+ if (disposed) return;
109
+ disposed = true;
110
+ for (const subscription of subscriptions) subscription.unsubscribe();
111
+ subscriptions.clear();
112
+ };
113
+ const add = (subscription) => {
114
+ if (disposed) subscription.unsubscribe();
115
+ else subscriptions.add(subscription);
116
+ return subscription;
117
+ };
118
+ const bindings = {
119
+ ...storeReactivityBindings(),
120
+ addSubscription: (subscription) => {
121
+ add(subscription);
122
+ },
123
+ createOptionsStore: false,
124
+ schedule: (fn) => queueMicrotask(() => {
125
+ if (disposed || host.signal.aborted) return;
126
+ try {
127
+ fn();
128
+ } catch (error) {
129
+ host.throw(error);
130
+ }
131
+ }),
132
+ unmount: dispose,
133
+ wrapExternalAtoms: false
134
+ };
135
+ host.signal.addEventListener("abort", dispose, { once: true });
136
+ return {
137
+ add,
138
+ bindings
139
+ };
140
+ };
141
+ var createDataTableModel = (host, initialArgs) => {
142
+ const reactive = dataTableReactivity(host);
143
+ const features = tableFeatures({
144
+ ...dataTableStrategy,
145
+ coreReactivityFeature: reactive.bindings
146
+ });
147
+ let args = initialArgs;
148
+ let actionEvent;
149
+ let syncing = false;
150
+ let stateVersion = 0;
151
+ let renderedVersion = 0;
152
+ let requestedVersion = 0;
153
+ let queued = false;
154
+ let optionsInitialized = false;
155
+ let rowsRef;
156
+ let rowsLength = 0;
157
+ let keyGetter;
158
+ let tableData = initialArgs.rows;
159
+ let rowIds = [];
160
+ let rowKeys = [];
161
+ let rowById = /* @__PURE__ */ new Map();
162
+ let columnsRef;
163
+ let columnsLength = 0;
164
+ let models = [];
165
+ let modelById = /* @__PURE__ */ new Map();
166
+ let definitions = [];
167
+ let knownColumns = /* @__PURE__ */ new Map();
168
+ let selectionEnabled = Boolean(initialArgs.selection);
169
+ let selectionControlled = initialArgs.selection?.value !== void 0;
170
+ let searchEnabled = Boolean(initialArgs.search);
171
+ let searchValue = "";
172
+ let pageConfig = paginationConfig(initialArgs.pagination);
173
+ const snapshotRows = (current) => {
174
+ if (current.rows === rowsRef && current.getRowKey === keyGetter) {
175
+ if (current.rows.length !== rowsLength) throw new TypeError("DataTable mutated rows");
176
+ if (rowsLength) {
177
+ const last = rowsLength - 1;
178
+ if (encodeKey(current.getRowKey(current.rows[0], 0)) !== rowIds[0] || encodeKey(current.getRowKey(current.rows[last], last)) !== rowIds[last]) throw new TypeError("DataTable mutated rows");
179
+ }
180
+ return false;
181
+ }
182
+ const replaced = current.rows !== rowsRef;
183
+ rowsRef = current.rows;
184
+ rowsLength = current.rows.length;
185
+ keyGetter = current.getRowKey;
186
+ tableData = replaced ? current.rows : [...current.rows];
187
+ rowIds = [];
188
+ rowKeys = [];
189
+ rowById = /* @__PURE__ */ new Map();
190
+ current.rows.forEach((row, index) => {
191
+ const key = current.getRowKey(row, index);
192
+ const id = encodeKey(key, index);
193
+ const previous = rowById.get(id);
194
+ if (previous !== void 0) throw new TypeError(`DataTable duplicate row key ${JSON.stringify(key)} ${previous}/${index}`);
195
+ rowById.set(id, index);
196
+ rowIds.push(id);
197
+ rowKeys.push(key);
198
+ });
199
+ return true;
200
+ };
201
+ const snapshotColumns = (current) => {
202
+ if (current.columns === columnsRef) {
203
+ if (current.columns.length !== columnsLength) throw new TypeError("DataTable mutated columns");
204
+ return false;
205
+ }
206
+ if (!current.columns.length) throw new TypeError("DataTable needs columns");
207
+ columnsRef = current.columns;
208
+ columnsLength = current.columns.length;
209
+ models = [];
210
+ modelById = /* @__PURE__ */ new Map();
211
+ for (const column of current.columns) {
212
+ assertText(column.label, "column label");
213
+ const id = columnId(column);
214
+ if (modelById.has(id)) throw new TypeError(`DataTable duplicate column ${JSON.stringify(id)}`);
215
+ const read = column.value === void 0 ? void 0 : typeof column.value === "function" ? column.value : (row) => row[column.value];
216
+ if (!read && !column.cell) throw new TypeError(`DataTable display column ${JSON.stringify(id)} needs a cell`);
217
+ if (!read && column.facet) throw new TypeError(`DataTable display column ${JSON.stringify(id)} cannot define a facet`);
218
+ if (column.facet) {
219
+ assertText(column.facet.label, `facet label ${id}`);
220
+ const options = /* @__PURE__ */ new Set();
221
+ for (const option of column.facet.options) {
222
+ assertText(option.label, `facet option label ${id}`);
223
+ assertText(option.value, `facet option value ${id}`);
224
+ if (options.has(option.value)) throw new TypeError(`DataTable duplicate facet option ${id}/${option.value}`);
225
+ options.add(option.value);
226
+ }
227
+ }
228
+ const model = {
229
+ column,
230
+ id,
231
+ read
232
+ };
233
+ models.push(model);
234
+ modelById.set(id, model);
235
+ }
236
+ if (models.every(({ column }) => column.defaultHidden)) throw new TypeError("DataTable needs a visible column");
237
+ definitions = models.map((model) => {
238
+ const { column, id, read } = model;
239
+ const definition = {
240
+ enableGlobalFilter: Boolean(read && column.search !== false),
241
+ enableHiding: column.hideable !== false,
242
+ enableSorting: Boolean(read && column.sort !== false),
243
+ filterFn: (row, _columnId, active) => {
244
+ const selected = active;
245
+ return !selected.length || facetValues(model, row.original, row.index).some((value) => selected.includes(value));
246
+ },
247
+ header: column.label,
248
+ id,
249
+ sortFn: (left, right, columnId) => {
250
+ if (typeof column.sort === "function") {
251
+ const result = column.sort(left.original, right.original);
252
+ if (!Number.isFinite(result)) throw new TypeError(`DataTable invalid comparator ${columnId}`);
253
+ return result;
254
+ }
255
+ return compareValues(left.getValue(columnId), right.getValue(columnId), left, right, columnId, () => sortFn_alphanumeric(left, right, columnId));
256
+ },
257
+ sortUndefined: false
258
+ };
259
+ return read ? {
260
+ ...definition,
261
+ accessorFn: read
262
+ } : definition;
263
+ });
264
+ return true;
265
+ };
266
+ const selectionState = (keys) => {
267
+ const state = Object.create(null);
268
+ const seen = /* @__PURE__ */ new Set();
269
+ for (const key of keys ?? []) {
270
+ const id = encodeKey(key);
271
+ if (seen.has(id)) throw new TypeError(`DataTable duplicate selection key ${JSON.stringify(key)}`);
272
+ seen.add(id);
273
+ if (rowById.has(id)) state[id] = true;
274
+ }
275
+ return state;
276
+ };
277
+ const selectionInput = (selection) => {
278
+ const fallback = selectionState(selection?.defaultValue);
279
+ return selection?.value === void 0 ? fallback : selectionState(selection.value);
280
+ };
281
+ const sameSelection = (left, right) => {
282
+ for (const id of Object.keys(left)) if (Boolean(left[id]) !== Boolean(right[id])) return false;
283
+ for (const id of Object.keys(right)) if (Boolean(left[id]) !== Boolean(right[id])) return false;
284
+ return true;
285
+ };
286
+ snapshotRows(initialArgs);
287
+ snapshotColumns(initialArgs);
288
+ knownColumns = new Map(modelById);
289
+ assertText(initialArgs.label, "label");
290
+ const initialSelection = selectionInput(initialArgs.selection);
291
+ const initialVisibility = Object.fromEntries(models.map(({ column, id }) => [id, column.hideable === false || !column.defaultHidden]));
292
+ const table = constructTable({
293
+ autoResetPageIndex: false,
294
+ columns: definitions,
295
+ data: tableData,
296
+ enableMultiSort: false,
297
+ enableRowRangeSelection: false,
298
+ enableRowSelection: selectionEnabled,
299
+ features,
300
+ getColumnCanGlobalFilter: (column) => column.columnDef.enableGlobalFilter === true,
301
+ getRowId: (_row, index) => rowIds[index],
302
+ globalFilterFn: (row, columnId) => {
303
+ const model = modelById.get(columnId);
304
+ if (!model?.read || model.column.search === false) return false;
305
+ return scalarText(typeof model.column.search === "function" ? model.column.search(row.original, row.index) : row.getValue(columnId), columnId, row.index).toLowerCase().includes(searchValue);
306
+ },
307
+ initialState: {
308
+ columnFilters: [],
309
+ columnVisibility: initialVisibility,
310
+ globalFilter: "",
311
+ pagination: {
312
+ pageIndex: 0,
313
+ pageSize: pageConfig.size
314
+ },
315
+ rowSelection: initialSelection,
316
+ sorting: []
317
+ }
318
+ });
319
+ const defaultSelectionUpdater = table.options.onRowSelectionChange;
320
+ const selectedKeys = (state = table.atoms.rowSelection.get()) => {
321
+ const indexes = [];
322
+ for (const id of Object.keys(state)) {
323
+ const index = rowById.get(id);
324
+ if (state[id] && index !== void 0) indexes.push(index);
325
+ }
326
+ indexes.sort((left, right) => left - right);
327
+ return indexes.map((index) => rowKeys[index]);
328
+ };
329
+ const countSelected = (state = table.atoms.rowSelection.get()) => {
330
+ let count = 0;
331
+ for (const id of Object.keys(state)) if (state[id] && rowById.has(id)) count++;
332
+ return count;
333
+ };
334
+ const pageSelection = () => {
335
+ const rows = pageConfig.enabled ? table.getRowModel().rows : table.getPrePaginatedRowModel().rows;
336
+ let selected = 0;
337
+ for (const row of rows) if (row.getIsSelected()) selected++;
338
+ const all = rows.length > 0 && selected === rows.length;
339
+ return {
340
+ all,
341
+ some: selected > 0 && !all
342
+ };
343
+ };
344
+ const invalidate = (version) => {
345
+ requestedVersion = Math.max(requestedVersion, version);
346
+ if (queued || host.signal.aborted) return;
347
+ queued = true;
348
+ queueMicrotask(() => {
349
+ queued = false;
350
+ if (host.signal.aborted || renderedVersion >= requestedVersion) return;
351
+ try {
352
+ host.next();
353
+ } catch (error) {
354
+ if (!host.signal.aborted) host.throw(error);
355
+ }
356
+ });
357
+ };
358
+ const selectionUpdater = (updater) => {
359
+ const selection = args.selection;
360
+ if (!selection) return;
361
+ if (selection.value !== void 0) {
362
+ const current = selectionState(selection.value);
363
+ const next = typeof updater === "function" ? updater(current) : updater;
364
+ selection.onValueChange(selectedKeys(next), actionEvent);
365
+ return;
366
+ }
367
+ defaultSelectionUpdater(updater);
368
+ selection.onValueChange?.(selectedKeys(), actionEvent);
369
+ };
370
+ reactive.add(table.store.subscribe(() => {
371
+ const version = ++stateVersion;
372
+ if (!syncing) invalidate(version);
373
+ }));
374
+ const withAction = (event, action) => {
375
+ if (host.signal.aborted) return;
376
+ const previous = actionEvent;
377
+ actionEvent = event;
378
+ try {
379
+ action();
380
+ } finally {
381
+ actionEvent = previous;
382
+ }
383
+ };
384
+ const firstPage = () => {
385
+ if (!host.signal.aborted && pageConfig.enabled) table.firstPage();
386
+ };
387
+ const resetPage = () => {
388
+ if (pageConfig.enabled) table.setPageIndex(0);
389
+ };
390
+ const reconcileColumns = (changed) => {
391
+ if (!changed) return;
392
+ const visibility = table.atoms.columnVisibility.get();
393
+ const nextVisibility = {};
394
+ for (const model of models) {
395
+ const previous = knownColumns.get(model.id);
396
+ nextVisibility[model.id] = model.column.hideable === false ? true : previous ? visibility[model.id] !== false : !model.column.defaultHidden;
397
+ }
398
+ if (!Object.values(nextVisibility).some(Boolean)) nextVisibility[models[0].id] = true;
399
+ table.baseAtoms.columnVisibility.set(nextVisibility);
400
+ let reset = false;
401
+ if (table.atoms.sorting.get().some((sort) => {
402
+ const model = modelById.get(sort.id);
403
+ return !model?.read || model.column.sort === false;
404
+ })) {
405
+ table.baseAtoms.sorting.set([]);
406
+ reset = true;
407
+ }
408
+ const currentFilters = table.atoms.columnFilters.get();
409
+ const filters = currentFilters.flatMap((filter) => {
410
+ const facet = modelById.get(filter.id)?.column.facet;
411
+ if (!facet) return [];
412
+ const allowed = new Set(facet.options.map((option) => option.value));
413
+ const values = filter.value.filter((value) => allowed.has(value));
414
+ return values.length ? [{
415
+ id: filter.id,
416
+ value: values
417
+ }] : [];
418
+ });
419
+ if (filters.length !== currentFilters.length || filters.some((filter, index) => {
420
+ const current = currentFilters[index];
421
+ const values = filter.value;
422
+ const currentValues = current?.value;
423
+ return !current || current.id !== filter.id || values.length !== currentValues?.length || values.some((value, valueIndex) => value !== currentValues[valueIndex]);
424
+ })) {
425
+ table.baseAtoms.columnFilters.set(filters);
426
+ reset = true;
427
+ }
428
+ knownColumns = new Map(modelById);
429
+ if (reset) resetPage();
430
+ };
431
+ const sync = (nextArgs) => {
432
+ args = nextArgs;
433
+ assertText(args.label, "label");
434
+ const rowsChanged = snapshotRows(args);
435
+ const columnsChanged = snapshotColumns(args);
436
+ if (columnsChanged && !rowsChanged) tableData = [...args.rows];
437
+ const nextPage = paginationConfig(args.pagination);
438
+ const nextSelection = Boolean(args.selection);
439
+ const nextSelectionState = selectionInput(args.selection);
440
+ const nextSelectionControlled = args.selection?.value !== void 0;
441
+ const nextSearch = Boolean(args.search);
442
+ const optionsChanged = !optionsInitialized || rowsChanged || columnsChanged || selectionEnabled !== nextSelection || searchEnabled !== nextSearch || selectionControlled !== nextSelectionControlled || nextSelectionControlled && !sameSelection(table.atoms.rowSelection.get(), nextSelectionState);
443
+ syncing = true;
444
+ try {
445
+ if (selectionEnabled !== nextSelection) table.baseAtoms.rowSelection.set(nextSelection ? nextSelectionState : {});
446
+ if (searchEnabled !== nextSearch) {
447
+ searchValue = "";
448
+ table.baseAtoms.globalFilter.set("");
449
+ }
450
+ if (pageConfig.enabled !== nextPage.enabled) table.baseAtoms.pagination.set({
451
+ pageIndex: 0,
452
+ pageSize: nextPage.size
453
+ });
454
+ else if (!nextPage.sizes.includes(table.atoms.pagination.get().pageSize)) table.baseAtoms.pagination.set({
455
+ pageIndex: 0,
456
+ pageSize: nextPage.size
457
+ });
458
+ selectionEnabled = nextSelection;
459
+ selectionControlled = nextSelectionControlled;
460
+ searchEnabled = nextSearch;
461
+ pageConfig = nextPage;
462
+ if (optionsChanged) {
463
+ table.setOptions((previous) => ({
464
+ ...previous,
465
+ columns: definitions,
466
+ data: tableData,
467
+ enableGlobalFilter: searchEnabled,
468
+ enableRowSelection: selectionEnabled,
469
+ onRowSelectionChange: selectionUpdater,
470
+ state: selectionControlled ? { rowSelection: nextSelectionState } : void 0
471
+ }));
472
+ optionsInitialized = true;
473
+ }
474
+ reconcileColumns(columnsChanged);
475
+ if (rowsChanged && args.selection?.value === void 0) {
476
+ const current = table.atoms.rowSelection.get();
477
+ const pruned = Object.create(null);
478
+ for (const id of Object.keys(current)) if (rowById.has(id)) pruned[id] = true;
479
+ if (Object.keys(pruned).length !== Object.keys(current).length) table.baseAtoms.rowSelection.set(pruned);
480
+ }
481
+ if (pageConfig.enabled) {
482
+ const pageCount = Math.max(1, table.getPageCount());
483
+ const current = table.atoms.pagination.get();
484
+ if (current.pageIndex >= pageCount) table.baseAtoms.pagination.set({
485
+ ...current,
486
+ pageIndex: pageCount - 1
487
+ });
488
+ }
489
+ } finally {
490
+ syncing = false;
491
+ }
492
+ const pagination = table.atoms.pagination.get();
493
+ const pageCount = pageConfig.enabled ? Math.max(1, table.getPageCount()) : 1;
494
+ const sourceRows = pageConfig.enabled ? table.getRowModel().rows : table.getPrePaginatedRowModel().rows;
495
+ const allColumns = models.map((model) => ({
496
+ ...model,
497
+ active: table.getColumn(model.id).getFilterValue() ?? [],
498
+ sorted: table.getColumn(model.id).getIsSorted(),
499
+ visible: table.getColumn(model.id).getIsVisible()
500
+ }));
501
+ const visibleRows = sourceRows.map((row) => ({
502
+ cells: row.getVisibleCells().map((cell) => ({
503
+ column: modelById.get(cell.column.id),
504
+ value: cell.getValue()
505
+ })),
506
+ id: row.id,
507
+ key: rowKeys[row.index],
508
+ original: row.original,
509
+ selected: row.getIsSelected(),
510
+ sourceIndex: row.index
511
+ }));
512
+ const selected = countSelected();
513
+ const pageSelected = pageSelection();
514
+ const filters = table.atoms.columnFilters.get();
515
+ const query = searchEnabled ? String(table.atoms.globalFilter.get() ?? "") : "";
516
+ renderedVersion = stateVersion;
517
+ return {
518
+ columns: allColumns,
519
+ filteredCount: table.getFilteredRowModel().rows.length,
520
+ hasFilters: Boolean(query || filters.length),
521
+ page: {
522
+ count: pageCount,
523
+ enabled: pageConfig.enabled,
524
+ index: pageConfig.enabled ? pagination.pageIndex : 0,
525
+ size: pagination.pageSize,
526
+ sizes: pageConfig.sizes
527
+ },
528
+ query,
529
+ rows: visibleRows,
530
+ selectedCount: selected,
531
+ selection: {
532
+ enabled: selectionEnabled,
533
+ ...pageSelected
534
+ },
535
+ sourceCount: args.rows.length,
536
+ visibility: models.length > 1 && models.some((model) => model.column.hideable !== false)
537
+ };
538
+ };
539
+ return {
540
+ cell(cell, row) {
541
+ if (cell.column.column.cell) return cell.column.column.cell(row.original, {
542
+ columnId: cell.column.id,
543
+ sourceIndex: row.sourceIndex,
544
+ value: cell.value
545
+ });
546
+ if (cell.value == null) return "";
547
+ if ([
548
+ "bigint",
549
+ "boolean",
550
+ "number",
551
+ "string"
552
+ ].includes(typeof cell.value)) return String(cell.value);
553
+ throw new TypeError(`DataTable cannot render ${cell.column.id} at ${row.sourceIndex}`);
554
+ },
555
+ firstPage,
556
+ lastPage: () => {
557
+ if (!host.signal.aborted && pageConfig.enabled) table.lastPage();
558
+ },
559
+ nextPage: () => {
560
+ if (!host.signal.aborted && pageConfig.enabled) table.nextPage();
561
+ },
562
+ previousPage: () => {
563
+ if (!host.signal.aborted && pageConfig.enabled) table.previousPage();
564
+ },
565
+ reset(event) {
566
+ withAction(event, () => {
567
+ searchValue = "";
568
+ table.setGlobalFilter("");
569
+ table.setColumnFilters([]);
570
+ resetPage();
571
+ });
572
+ },
573
+ selected: (id) => table.atoms.rowSelection.get()[id] === true,
574
+ selection: pageSelection,
575
+ setFacet(id, value, checked, event) {
576
+ if (!(modelById.get(id)?.column.facet)?.options.some((option) => option.value === value)) return;
577
+ withAction(event, () => {
578
+ const column = table.getColumn(id);
579
+ const active = new Set(column?.getFilterValue());
580
+ if (active.has(value) === checked) return;
581
+ if (checked) active.add(value);
582
+ else active.delete(value);
583
+ column?.setFilterValue(active.size ? [...active] : void 0);
584
+ resetPage();
585
+ });
586
+ },
587
+ setPageSize(size) {
588
+ if (host.signal.aborted || !pageConfig.enabled || !pageConfig.sizes.includes(size)) return;
589
+ table.setPagination({
590
+ pageIndex: 0,
591
+ pageSize: size
592
+ });
593
+ },
594
+ setQuery(query, event) {
595
+ if (!searchEnabled) return;
596
+ withAction(event, () => {
597
+ const value = query.trim();
598
+ searchValue = value.toLowerCase();
599
+ table.setGlobalFilter(value);
600
+ resetPage();
601
+ });
602
+ },
603
+ sort(id, event) {
604
+ const model = modelById.get(id);
605
+ if (!model?.read || model.column.sort === false) return;
606
+ withAction(event, () => {
607
+ const current = table.atoms.sorting.get()[0];
608
+ const next = current?.id !== id ? [{
609
+ id,
610
+ desc: false
611
+ }] : !current.desc ? [{
612
+ id,
613
+ desc: true
614
+ }] : [];
615
+ table.setSorting(next);
616
+ resetPage();
617
+ });
618
+ },
619
+ sync,
620
+ toggleColumn(id, visible) {
621
+ if (host.signal.aborted) return;
622
+ const column = table.getColumn(id);
623
+ if (!column?.getCanHide()) return;
624
+ if (!visible && table.getVisibleLeafColumns().length <= 1) return;
625
+ column.toggleVisibility(visible);
626
+ },
627
+ togglePage(checked, event) {
628
+ if (!selectionEnabled) return;
629
+ withAction(event, () => {
630
+ const state = { ...table.atoms.rowSelection.get() };
631
+ const rows = pageConfig.enabled ? table.getRowModel().rows : table.getPrePaginatedRowModel().rows;
632
+ for (const row of rows) if (checked) state[row.id] = true;
633
+ else delete state[row.id];
634
+ table.setRowSelection(state);
635
+ });
636
+ },
637
+ toggleRow(id, checked, event) {
638
+ if (!selectionEnabled || !rowById.has(id)) return;
639
+ withAction(event, () => {
640
+ const state = { ...table.atoms.rowSelection.get() };
641
+ if (checked) state[id] = true;
642
+ else delete state[id];
643
+ table.setRowSelection(state);
644
+ });
645
+ }
646
+ };
647
+ };
648
+ //#endregion
649
+ //#region packages/ajo-ui/src/data-table.tsx
650
+ var validLabel = (value, name) => {
651
+ if (typeof value !== "string" || !value.trim()) throw new TypeError(`DataTable invalid ${name}`);
652
+ return value;
653
+ };
654
+ var align = (value) => value ?? "left";
655
+ var activeElement = (host) => {
656
+ const active = host.ownerDocument.activeElement;
657
+ return active instanceof HTMLElement && host.contains(active) ? active : null;
658
+ };
659
+ var coordinate = (host) => {
660
+ let node = activeElement(host);
661
+ let column;
662
+ while (node && node !== host) {
663
+ column ??= node.dataset.columnId;
664
+ if (node.dataset.rowId) return {
665
+ column,
666
+ row: node.dataset.rowId
667
+ };
668
+ node = node.parentElement;
669
+ }
670
+ };
671
+ var findCoordinate = (host, target) => {
672
+ for (const row of host.querySelectorAll("[data-row-id]")) {
673
+ if (row.dataset.rowId !== target.row) continue;
674
+ if (!target.column) return row;
675
+ for (const cell of row.querySelectorAll("[data-column-id]")) if (cell.dataset.columnId === target.column) return cell.querySelector("button,input,[tabindex]:not([tabindex=\"-1\"])") ?? cell;
676
+ }
677
+ };
678
+ var restoreCheckbox = (event, checked, indeterminate = false) => {
679
+ const input = event.currentTarget;
680
+ input.checked = checked;
681
+ input.indeterminate = indeterminate;
682
+ syncCheckedState(input, input.closest("[data-slot=\"checkbox\"]"));
683
+ };
684
+ var DataTableRoot = function* () {
685
+ let model;
686
+ let table = null;
687
+ let resultsTimer;
688
+ let composing = false;
689
+ let announceAfterRender;
690
+ const live = announce(this);
691
+ const preserveFocus = () => {
692
+ const active = dom(this) ? activeElement(this) : null;
693
+ const target = active ? coordinate(this) : void 0;
694
+ if (!active) return;
695
+ queueMicrotask(() => {
696
+ if (!dom(this) || this.signal.aborted) return;
697
+ const current = this.ownerDocument.activeElement;
698
+ if (current && current !== this.ownerDocument.body && current !== this.ownerDocument.documentElement && !current.matches(":disabled")) return;
699
+ ((target ? findCoordinate(this, target) : void 0) ?? table)?.focus({ preventScroll: true });
700
+ });
701
+ };
702
+ this.signal.addEventListener("abort", () => {
703
+ if (resultsTimer !== void 0) clearTimeout(resultsTimer);
704
+ table = null;
705
+ model = void 0;
706
+ }, { once: true });
707
+ for (const args of this) {
708
+ preserveFocus();
709
+ model ??= createDataTableModel(this, args);
710
+ const view = model.sync(args);
711
+ const labels = {
712
+ ...dataTableDefaultLabels,
713
+ ...args.labels
714
+ };
715
+ const text = (name) => validLabel(labels[name], `label ${name}`);
716
+ const call = (name, ...values) => validLabel(labels[name](...values), `label ${name}`);
717
+ const visibleColumns = view.columns.filter((column) => column.visible);
718
+ const visibleCount = visibleColumns.length;
719
+ const controlledSelection = args.selection?.value !== void 0;
720
+ const selectAllLabel = () => view.selection.all ? text(view.page.enabled ? "deselectPage" : "deselectResults") : text(view.page.enabled ? "selectPage" : "selectResults");
721
+ if (announceAfterRender) {
722
+ const message = call("results", view.filteredCount);
723
+ if (resultsTimer !== void 0) clearTimeout(resultsTimer);
724
+ if (announceAfterRender === "immediate") live.polite(message);
725
+ else resultsTimer = setTimeout(() => live.polite(message), 200);
726
+ announceAfterRender = void 0;
727
+ }
728
+ const announceResults = (mode) => {
729
+ announceAfterRender = mode;
730
+ };
731
+ const selectLabel = (row) => {
732
+ const selection = args.selection;
733
+ const rowLabel = validLabel(selection.getRowLabel(row.original, row.sourceIndex), "row label");
734
+ return row.selected ? call("deselectRow", rowLabel) : call("selectRow", rowLabel);
735
+ };
736
+ yield /* @__PURE__ */ jsxs(Fragment, { children: [
737
+ args.search || view.columns.some((column) => column.column.facet?.options.length) || view.visibility ? /* @__PURE__ */ jsxs(Toolbar, {
738
+ "aria-label": call("toolbar", args.label),
739
+ "data-slot": "data-table-toolbar",
740
+ children: [/* @__PURE__ */ jsxs("div", {
741
+ "data-slot": "data-table-toolbar-controls",
742
+ children: [
743
+ args.search ? /* @__PURE__ */ jsx("input", {
744
+ "aria-label": text("search"),
745
+ "data-slot": "data-table-search",
746
+ placeholder: args.search.placeholder ?? text("search"),
747
+ "set:oncompositionend": (event) => {
748
+ composing = false;
749
+ announceResults("deferred");
750
+ model.setQuery(event.currentTarget.value, event);
751
+ },
752
+ "set:oncompositionstart": () => {
753
+ composing = true;
754
+ },
755
+ "set:oninput": (event) => {
756
+ if (!composing) announceResults("deferred");
757
+ model.setQuery(event.currentTarget.value, event);
758
+ },
759
+ "set:onkeydown": (event) => {
760
+ if (event.key !== "Enter" || event.isComposing) return;
761
+ announceAfterRender = void 0;
762
+ if (resultsTimer !== void 0) clearTimeout(resultsTimer);
763
+ resultsTimer = void 0;
764
+ live.polite(call("results", view.filteredCount));
765
+ },
766
+ "set:value": view.query,
767
+ type: "search"
768
+ }) : null,
769
+ view.columns.flatMap((column) => {
770
+ const facet = column.column.facet;
771
+ if (!facet?.options.length) return [];
772
+ return [/* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsxs(MenuTrigger, {
773
+ "data-slot": "data-table-facet",
774
+ children: [
775
+ /* @__PURE__ */ jsx("span", {
776
+ "aria-hidden": "true",
777
+ "data-slot": "data-table-facet-icon"
778
+ }),
779
+ facet.label,
780
+ column.active.length ? /* @__PURE__ */ jsx("span", {
781
+ "data-slot": "data-table-facet-count",
782
+ children: column.active.length
783
+ }) : null
784
+ ]
785
+ }), /* @__PURE__ */ jsxs(MenuContent, {
786
+ "data-slot": "data-table-facet-content",
787
+ children: [
788
+ /* @__PURE__ */ jsx(MenuLabel, { children: facet.label }),
789
+ /* @__PURE__ */ jsx(MenuSeparator, {}),
790
+ facet.options.map((option) => /* @__PURE__ */ jsxs(MenuCheckboxItem, {
791
+ checked: column.active.includes(option.value),
792
+ onCheckedChange: (checked, event) => {
793
+ announceResults("immediate");
794
+ model.setFacet(column.id, option.value, checked, event);
795
+ },
796
+ textValue: option.label,
797
+ children: [option.icon ? /* @__PURE__ */ jsx("span", {
798
+ "aria-hidden": "true",
799
+ "data-slot": "data-table-facet-option-icon",
800
+ children: option.icon
801
+ }) : null, option.label]
802
+ }, option.value))
803
+ ]
804
+ })] }, column.id)];
805
+ }),
806
+ view.hasFilters ? /* @__PURE__ */ jsxs("button", {
807
+ "data-slot": "data-table-reset",
808
+ "set:onclick": (event) => {
809
+ announceResults("immediate");
810
+ model.reset(event);
811
+ },
812
+ type: "button",
813
+ children: [text("reset"), /* @__PURE__ */ jsx("span", {
814
+ "aria-hidden": "true",
815
+ "data-slot": "data-table-reset-icon"
816
+ })]
817
+ }) : null
818
+ ]
819
+ }), view.visibility ? /* @__PURE__ */ jsxs(Menu, {
820
+ placement: "bottom-end",
821
+ children: [/* @__PURE__ */ jsxs(MenuTrigger, {
822
+ "data-slot": "data-table-columns",
823
+ children: [text("columns"), /* @__PURE__ */ jsx("span", {
824
+ "aria-hidden": "true",
825
+ "data-slot": "data-table-columns-icon"
826
+ })]
827
+ }), /* @__PURE__ */ jsxs(MenuContent, {
828
+ "data-slot": "data-table-columns-content",
829
+ children: [
830
+ /* @__PURE__ */ jsx(MenuLabel, { children: text("columns") }),
831
+ /* @__PURE__ */ jsx(MenuSeparator, {}),
832
+ view.columns.filter((column) => column.column.hideable !== false).map((column) => /* @__PURE__ */ jsx(MenuCheckboxItem, {
833
+ checked: column.visible,
834
+ disabled: column.visible && visibleCount === 1,
835
+ onCheckedChange: (checked) => model.toggleColumn(column.id, checked),
836
+ textValue: column.column.label,
837
+ children: column.column.label
838
+ }, column.id))
839
+ ]
840
+ })]
841
+ }) : null]
842
+ }) : null,
843
+ /* @__PURE__ */ jsx("div", {
844
+ "data-slot": "data-table-container",
845
+ children: /* @__PURE__ */ jsxs("table", {
846
+ "aria-label": args.label,
847
+ "data-slot": "table",
848
+ ref: (element) => table = element,
849
+ tabindex: -1,
850
+ children: [/* @__PURE__ */ jsx("thead", {
851
+ "data-slot": "table-header",
852
+ children: /* @__PURE__ */ jsxs("tr", {
853
+ "data-slot": "table-row",
854
+ children: [view.selection.enabled ? /* @__PURE__ */ jsx("th", {
855
+ "data-slot": "table-head",
856
+ scope: "col",
857
+ children: /* @__PURE__ */ jsx(Checkbox, {
858
+ "aria-label": selectAllLabel(),
859
+ disabled: !view.rows.length,
860
+ "set:checked": view.selection.all,
861
+ "set:indeterminate": view.selection.some,
862
+ onCheckedChange: (checked, event) => {
863
+ try {
864
+ model.togglePage(checked, event);
865
+ } finally {
866
+ if (controlledSelection && model) {
867
+ const selection = model.selection();
868
+ restoreCheckbox(event, selection.all, selection.some);
869
+ }
870
+ }
871
+ }
872
+ })
873
+ }) : null, visibleColumns.map((column) => {
874
+ const next = column.sorted === false ? "ascending" : column.sorted === "asc" ? "descending" : "none";
875
+ const sortable = column.column.value !== void 0 && column.column.sort !== false;
876
+ return /* @__PURE__ */ jsx("th", {
877
+ "aria-sort": column.sorted === "asc" ? "ascending" : column.sorted === "desc" ? "descending" : void 0,
878
+ "data-align": align(column.column.align),
879
+ "data-column-id": column.id,
880
+ "data-slot": "table-head",
881
+ scope: "col",
882
+ children: sortable ? /* @__PURE__ */ jsxs("button", {
883
+ "aria-label": call("sort", column.column.label, next),
884
+ "data-slot": "data-table-sort-trigger",
885
+ "set:onclick": (event) => model.sort(column.id, event),
886
+ type: "button",
887
+ children: [/* @__PURE__ */ jsx("span", { children: column.column.header ?? column.column.label }), /* @__PURE__ */ jsx("span", {
888
+ "aria-hidden": "true",
889
+ "data-slot": "data-table-sort-icon",
890
+ "data-sort": column.sorted || "none"
891
+ })]
892
+ }) : column.column.header ?? column.column.label
893
+ }, column.id);
894
+ })]
895
+ })
896
+ }), /* @__PURE__ */ jsx("tbody", {
897
+ "data-slot": "table-body",
898
+ children: view.rows.length ? view.rows.map((row) => /* @__PURE__ */ jsxs("tr", {
899
+ "data-row-id": row.id,
900
+ "data-slot": "table-row",
901
+ "data-state": row.selected ? "selected" : void 0,
902
+ children: [view.selection.enabled ? /* @__PURE__ */ jsx("td", {
903
+ "data-column-id": "\\0selection",
904
+ "data-slot": "table-cell",
905
+ children: /* @__PURE__ */ jsx(Checkbox, {
906
+ "aria-label": selectLabel(row),
907
+ "set:checked": row.selected,
908
+ onCheckedChange: (checked, event) => {
909
+ try {
910
+ model.toggleRow(row.id, checked, event);
911
+ } finally {
912
+ if (controlledSelection && model) restoreCheckbox(event, model.selected(row.id));
913
+ }
914
+ }
915
+ })
916
+ }) : null, row.cells.map((cell) => /* @__PURE__ */ jsx("td", {
917
+ "data-align": align(cell.column.column.align),
918
+ "data-column-id": cell.column.id,
919
+ "data-slot": "table-cell",
920
+ children: model.cell(cell, row)
921
+ }, cell.column.id))]
922
+ }, row.id)) : /* @__PURE__ */ jsx("tr", {
923
+ "data-slot": "table-row",
924
+ children: /* @__PURE__ */ jsx("td", {
925
+ colspan: visibleCount + (view.selection.enabled ? 1 : 0),
926
+ "data-slot": "data-table-empty",
927
+ children: args.empty ?? "No results."
928
+ })
929
+ })
930
+ })]
931
+ })
932
+ }),
933
+ view.selection.enabled || view.page.enabled ? /* @__PURE__ */ jsxs("div", {
934
+ "data-slot": "data-table-footer",
935
+ children: [view.selection.enabled ? /* @__PURE__ */ jsx("div", {
936
+ "aria-live": "polite",
937
+ "data-slot": "data-table-selection-summary",
938
+ role: "status",
939
+ children: call("selected", view.selectedCount, view.sourceCount)
940
+ }) : null, view.page.enabled ? /* @__PURE__ */ jsxs("nav", {
941
+ "aria-label": call("pagination", args.label),
942
+ "data-slot": "data-table-pagination",
943
+ children: [
944
+ /* @__PURE__ */ jsxs("div", {
945
+ "data-slot": "data-table-page-size",
946
+ children: [/* @__PURE__ */ jsx("span", { children: text("rowsPerPage") }), /* @__PURE__ */ jsxs(Select, {
947
+ value: view.page.size,
948
+ onValueChange: (value) => {
949
+ if (value !== null) model.setPageSize(value);
950
+ },
951
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
952
+ "aria-label": text("rowsPerPage"),
953
+ children: /* @__PURE__ */ jsx(SelectValue, {})
954
+ }), /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsx(SelectList, { children: view.page.sizes.map((size) => /* @__PURE__ */ jsx(SelectItem, {
955
+ value: size,
956
+ children: size
957
+ }, size)) }) })]
958
+ })]
959
+ }),
960
+ /* @__PURE__ */ jsx("div", {
961
+ "data-slot": "data-table-page-indicator",
962
+ children: call("page", view.page.index + 1, view.page.count)
963
+ }),
964
+ /* @__PURE__ */ jsxs("div", {
965
+ "data-slot": "data-table-pagination-actions",
966
+ children: [
967
+ /* @__PURE__ */ jsx("button", {
968
+ "aria-label": text("firstPage"),
969
+ "data-action": "first",
970
+ "data-slot": "data-table-pagination-action",
971
+ disabled: view.page.index === 0,
972
+ "set:onclick": () => model.firstPage(),
973
+ type: "button",
974
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true" })
975
+ }),
976
+ /* @__PURE__ */ jsx("button", {
977
+ "aria-label": text("previousPage"),
978
+ "data-action": "previous",
979
+ "data-slot": "data-table-pagination-action",
980
+ disabled: view.page.index === 0,
981
+ "set:onclick": () => model.previousPage(),
982
+ type: "button",
983
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true" })
984
+ }),
985
+ /* @__PURE__ */ jsx("button", {
986
+ "aria-label": text("nextPage"),
987
+ "data-action": "next",
988
+ "data-slot": "data-table-pagination-action",
989
+ disabled: view.page.index >= view.page.count - 1,
990
+ "set:onclick": () => model.nextPage(),
991
+ type: "button",
992
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true" })
993
+ }),
994
+ /* @__PURE__ */ jsx("button", {
995
+ "aria-label": text("lastPage"),
996
+ "data-action": "last",
997
+ "data-slot": "data-table-pagination-action",
998
+ disabled: view.page.index >= view.page.count - 1,
999
+ "set:onclick": () => model.lastPage(),
1000
+ type: "button",
1001
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true" })
1002
+ })
1003
+ ]
1004
+ })
1005
+ ]
1006
+ }) : null]
1007
+ }) : null
1008
+ ] });
1009
+ }
1010
+ };
1011
+ var safeRootAttrs = (attrs) => {
1012
+ const result = { ...statefulRootAttrs(attrs) };
1013
+ for (const name of [
1014
+ "aria-label",
1015
+ "aria-labelledby",
1016
+ "attr:aria-label",
1017
+ "attr:aria-labelledby",
1018
+ "set:ariaLabel",
1019
+ "set:ariaLabelledByElements"
1020
+ ]) delete result[name];
1021
+ return result;
1022
+ };
1023
+ /** Native, Ajo-owned client DataTable powered by a private TanStack Table v9 model. */
1024
+ var DataTable = ({ children: _children, class: classes, columns, empty, getRowKey, label, labels, pagination, rows, search, selection, ...attrs }) => /* @__PURE__ */ jsx(DataTableRoot, {
1025
+ ...safeRootAttrs(attrs),
1026
+ columns,
1027
+ empty,
1028
+ getRowKey,
1029
+ label,
1030
+ labels,
1031
+ pagination,
1032
+ rows,
1033
+ search,
1034
+ selection,
1035
+ "attr:class": classes,
1036
+ "attr:data-slot": "data-table"
1037
+ });
1038
+ //#endregion
1039
+ export { DataTable as t };