@entifix/react-controls 0.20.2 → 0.21.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.
- package/dist/i18n/catalog/en.d.ts.map +1 -1
- package/dist/i18n/catalog/en.js +3 -0
- package/dist/i18n/catalog/en.js.map +1 -1
- package/dist/i18n/catalog/es.d.ts +3 -0
- package/dist/i18n/catalog/es.d.ts.map +1 -1
- package/dist/i18n/catalog/es.js +3 -0
- package/dist/i18n/catalog/es.js.map +1 -1
- package/dist/i18n/catalog/index.d.ts +6 -0
- package/dist/i18n/catalog/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ui/actions/action-surfaces.d.ts +13 -0
- package/dist/ui/actions/action-surfaces.d.ts.map +1 -1
- package/dist/ui/actions/action-surfaces.js +15 -0
- package/dist/ui/actions/action-surfaces.js.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.d.ts +6 -0
- package/dist/ui/atoms/cell-value/cell-value.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.js +97 -14
- package/dist/ui/atoms/cell-value/cell-value.js.map +1 -1
- package/dist/ui/atoms/cell-value/index.d.ts +1 -0
- package/dist/ui/atoms/cell-value/index.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/index.js +1 -0
- package/dist/ui/atoms/cell-value/index.js.map +1 -1
- package/dist/ui/atoms/cell-value/use-record-label.d.ts +16 -0
- package/dist/ui/atoms/cell-value/use-record-label.d.ts.map +1 -0
- package/dist/ui/atoms/cell-value/use-record-label.js +55 -0
- package/dist/ui/atoms/cell-value/use-record-label.js.map +1 -0
- package/dist/ui/atoms/table/table.d.ts +4 -2
- package/dist/ui/atoms/table/table.d.ts.map +1 -1
- package/dist/ui/atoms/table/table.js +3 -1
- package/dist/ui/atoms/table/table.js.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.d.ts +1 -1
- package/dist/ui/organisms/entity-form/entity-form.d.ts.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.js +19 -10
- package/dist/ui/organisms/entity-form/entity-form.js.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.types.d.ts +0 -8
- package/dist/ui/organisms/entity-form/entity-form.types.d.ts.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.types.js.map +1 -1
- package/dist/ui/organisms/entity-table/card-roles.d.ts +10 -0
- package/dist/ui/organisms/entity-table/card-roles.d.ts.map +1 -0
- package/dist/ui/organisms/entity-table/card-roles.js +14 -0
- package/dist/ui/organisms/entity-table/card-roles.js.map +1 -0
- package/dist/ui/organisms/entity-table/entity-table-slots.d.ts +2 -0
- package/dist/ui/organisms/entity-table/entity-table-slots.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table-slots.js.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.js +242 -173
- package/dist/ui/organisms/entity-table/entity-table.js.map +1 -1
- package/dist/ui/organisms/entity-table/pivot.d.ts +32 -5
- package/dist/ui/organisms/entity-table/pivot.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/pivot.js +42 -9
- package/dist/ui/organisms/entity-table/pivot.js.map +1 -1
- package/dist/ui/organisms/entity-table/use-entity-table-columns.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/use-entity-table-columns.js +6 -3
- package/dist/ui/organisms/entity-table/use-entity-table-columns.js.map +1 -1
- package/dist/ui/utils/reference-labels.d.ts +59 -0
- package/dist/ui/utils/reference-labels.d.ts.map +1 -0
- package/dist/ui/utils/reference-labels.js +49 -0
- package/dist/ui/utils/reference-labels.js.map +1 -0
- package/dist/ui/utils/use-focus-on-arrival.d.ts +11 -0
- package/dist/ui/utils/use-focus-on-arrival.d.ts.map +1 -1
- package/dist/ui/utils/use-focus-on-arrival.js +33 -1
- package/dist/ui/utils/use-focus-on-arrival.js.map +1 -1
- package/package.json +11 -11
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { emptySelection, extractMetaEntity, hierarchyOf, isSelected, queryPropertyFor, selectionSize, toggleSelected } from '@entifix/core';
|
|
3
|
+
import { canNameRecord, emptySelection, extractMetaEntity, hierarchyOf, isSelected, queryPropertyFor, recordLabel, selectionSize, toggleSelected } from '@entifix/core';
|
|
4
4
|
import { Fragment, useId, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { useEntityNoun, useLocale, useT, useTranslateKey } from '../../../i18n/index.js';
|
|
6
|
-
import { renderAnchor, useCasesForSurface } from '../../actions/index.js';
|
|
6
|
+
import { availableUseCases, renderAnchor, useCasesForSurface } from '../../actions/index.js';
|
|
7
7
|
import { useVerbInvoker } from '../../actions/use-verb-invoker.js';
|
|
8
8
|
import { Button, button } from '../../atoms/button/index.js';
|
|
9
|
-
import { CellValue } from '../../atoms/cell-value/index.js';
|
|
9
|
+
import { CellValue, useRecordLabel } from '../../atoms/cell-value/index.js';
|
|
10
10
|
import { Checkbox } from '../../atoms/field/index.js';
|
|
11
11
|
import { Skeleton } from '../../atoms/skeleton/index.js';
|
|
12
12
|
import { Table, TableBody, TableCell, TableHead, TableHeaderCell, TableMessageRow, TableRow } from '../../atoms/table/index.js';
|
|
@@ -23,10 +23,12 @@ import { Pagination } from '../../molecules/pagination/index.js';
|
|
|
23
23
|
import { RegionState } from '../../molecules/region-state/index.js';
|
|
24
24
|
import { SortBuilder } from '../../molecules/sort-builder/index.js';
|
|
25
25
|
import { TableToolbar } from '../../molecules/table-toolbar/index.js';
|
|
26
|
+
import { useFocusOnLoss } from '../../utils/use-focus-on-arrival.js';
|
|
27
|
+
import { cardRoles } from './card-roles.js';
|
|
26
28
|
import { readEntityTableSlots } from './entity-table-slots.js';
|
|
27
29
|
import { shownTreeRows, TreeCell, treeRows } from './entity-table-tree.js';
|
|
28
30
|
import { nextHeaderSorting, sortKeys } from './header-sort.js';
|
|
29
|
-
import { ACTIONS_WIDTH, pivotClasses,
|
|
31
|
+
import { ACTIONS_WIDTH, columnWidth, pivotClasses, pivotWidths, SELECTION_WIDTH } from './pivot.js';
|
|
30
32
|
import { useEntityTableColumns } from './use-entity-table-columns.js';
|
|
31
33
|
import { useResultAnnouncement } from './use-result-announcement.js';
|
|
32
34
|
/**
|
|
@@ -39,7 +41,7 @@ import { useResultAnnouncement } from './use-result-announcement.js';
|
|
|
39
41
|
*/ const SKELETON_ROW_CAP = 5;
|
|
40
42
|
/** How many members a card shows as meta when none declares a `card` role. */ const UNDECLARED_META_CAP = 3;
|
|
41
43
|
export function EntityTable({ entityConstructor, isLoading, skeleton = true, error, items, totalItems, currentPage, pageSize, onPageChange, onPageSizeChange, hrefFor, newHref, renderLink = renderAnchor, onSelect, preferencesKey, showControls = true, pivotBreakpoint, filtering, sorting, onFilteringChange, onSortingChange, facets, selection, onSelectionChange, metadata, isMetadataLoading = false, onBulkUseCase, onUseCase, onRetry, bulkOutcomes, onBulkDismiss, onBulkRetry, isBulkRunning = false, children }) {
|
|
42
|
-
var _ref, _ref1;
|
|
44
|
+
var _ref, _ref1, _visibleColumns_find, _ref2;
|
|
43
45
|
const t = useT();
|
|
44
46
|
// A descriptor's label is a runtime catalog key — the typed gate cannot see
|
|
45
47
|
// it, which is why a host's catalog check is what catches a typo.
|
|
@@ -93,12 +95,30 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
93
95
|
* table's own box picks one — at the width its visible columns need. A
|
|
94
96
|
* viewport breakpoint was wrong inside a split view, a drawer or a wizard
|
|
95
97
|
* step, and a JS measurement would guess during SSR and correct after mount.
|
|
96
|
-
*/
|
|
98
|
+
*/ /**
|
|
99
|
+
* The column every row reads as — the entity's `labelMember`, else its
|
|
100
|
+
* declared card title, else the first that can name a record — held in view
|
|
101
|
+
* at the inline start while a grid wider than its container scrolls.
|
|
102
|
+
*/ const stickyTitle = (_ref1 = (_visibleColumns_find = visibleColumns.find((column)=>column.name === metaEntity.labelMember)) != null ? _visibleColumns_find : visibleColumns.find((column)=>column.card === 'title')) != null ? _ref1 : visibleColumns.find(canNameRecord);
|
|
103
|
+
const widths = pivotWidths({
|
|
104
|
+
columns: visibleColumns,
|
|
105
|
+
title: stickyTitle,
|
|
106
|
+
roleOf: cardRoles(visibleColumns),
|
|
107
|
+
extra: (selectable ? SELECTION_WIDTH : 0) + (hasRowAction ? ACTIONS_WIDTH : 0),
|
|
108
|
+
breakpoint: pivotBreakpoint
|
|
109
|
+
});
|
|
110
|
+
const pivot = pivotClasses(widths.essential);
|
|
111
|
+
/**
|
|
112
|
+
* The sticky title's cells: opaque, so the columns scrolling under it never
|
|
113
|
+
* show through — a header cell on the header's surface, a row's on the
|
|
114
|
+
* row's, following its hover.
|
|
115
|
+
*/ const stickyClass = (column, part)=>column !== stickyTitle ? undefined : part === 'header' ? 'sticky start-0 z-2 bg-surface' : 'sticky start-0 z-1 bg-surface-elevated group-hover/row:bg-surface';
|
|
97
116
|
/**
|
|
98
117
|
* The first load has nothing to show and is held with a skeleton; a refetch
|
|
99
118
|
* already has rows, so it keeps them and only marks the region busy. Splitting
|
|
100
119
|
* the two is what stops every pagination click flashing grey.
|
|
101
120
|
*/ const isFirstLoad = isLoading && items.length === 0;
|
|
121
|
+
/** Loaded, nothing came back, and nothing failed: there are no rows to lay out. */ const settledEmpty = items.length === 0 && !isLoading && error === undefined;
|
|
102
122
|
/** `true`/omitted → the built-in default; a node → that node; `false` → none. */ const customSkeleton = typeof skeleton === 'boolean' ? undefined : skeleton;
|
|
103
123
|
const showSkeleton = isFirstLoad && skeleton !== false;
|
|
104
124
|
const skeletonRows = Array.from({
|
|
@@ -109,23 +129,28 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
109
129
|
* dimming them through opacity took the text under the contrast a reader
|
|
110
130
|
* needs, on every page change.
|
|
111
131
|
*/ const busy = isLoading || undefined;
|
|
112
|
-
|
|
113
|
-
|
|
132
|
+
const nameOf = useRecordLabel();
|
|
133
|
+
/**
|
|
134
|
+
* The column a row reads *as*: the member `recordLabel()` names it by, when
|
|
135
|
+
* the reader has not hidden that column; else one declared `card: 'title'`;
|
|
136
|
+
* else the first visible one it filled in that is not a key — an id, a
|
|
137
|
+
* reference or a link names a row no better than its position does.
|
|
138
|
+
*/ const declaredTitle = visibleColumns.find((column)=>column.card === 'title');
|
|
139
|
+
const linkColumn = (item)=>{
|
|
140
|
+
var _ref;
|
|
141
|
+
const label = recordLabel(entityConstructor, item);
|
|
142
|
+
const named = label.kind === 'fallback' ? undefined : visibleColumns.find((column)=>column.name === label.member.name);
|
|
143
|
+
return (_ref = named != null ? named : declaredTitle) != null ? _ref : visibleColumns.find((column)=>{
|
|
114
144
|
const value = item[column.name];
|
|
115
|
-
return value != null && String(value) !== '';
|
|
145
|
+
return canNameRecord(column) && value != null && String(value) !== '';
|
|
116
146
|
});
|
|
117
|
-
|
|
118
|
-
const linkColumn = (item)=>declaredTitle != null ? declaredTitle : titleColumn(item);
|
|
147
|
+
};
|
|
119
148
|
/**
|
|
120
149
|
* What a record's card shows, by each member's declared `card` role or the
|
|
121
150
|
* default: an id is hidden, the first enum is the badge, and up to
|
|
122
151
|
* {@link UNDECLARED_META_CAP} more members are meta — a card is a summary,
|
|
123
152
|
* and the grid holds the rest.
|
|
124
|
-
*/ const
|
|
125
|
-
const roleOf = (column)=>{
|
|
126
|
-
var _column_card;
|
|
127
|
-
return (_column_card = column.card) != null ? _column_card : column.type === 'id' ? 'hidden' : column === firstEnum ? 'badge' : 'meta';
|
|
128
|
-
};
|
|
153
|
+
*/ const roleOf = cardRoles(visibleColumns);
|
|
129
154
|
const cardParts = (item)=>{
|
|
130
155
|
const title = linkColumn(item);
|
|
131
156
|
const rest = visibleColumns.filter((column)=>column !== title);
|
|
@@ -232,26 +257,11 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
232
257
|
setSelection(next);
|
|
233
258
|
};
|
|
234
259
|
/**
|
|
235
|
-
* How a row names itself to a screen reader
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
|
|
240
|
-
*/ const rowLabel = (item)=>{
|
|
241
|
-
// The first non-identifier column **that this row actually filled in**.
|
|
242
|
-
//
|
|
243
|
-
// An id names a row the way "row 3" does: it repeats what the user can
|
|
244
|
-
// already see. But skipping only the id is not enough — measured against
|
|
245
|
-
// the seeded catalog, where `code` is the first non-id column and is empty
|
|
246
|
-
// on every brand, so the label fell straight through to the id and never
|
|
247
|
-
// reached `name`. A column that is blank on this row names it no better
|
|
248
|
-
// than its position does, so the search continues past it.
|
|
249
|
-
//
|
|
250
|
-
// The id remains the last resort, because a row with nothing rendered
|
|
251
|
-
// still has to announce itself.
|
|
252
|
-
const named = titleColumn(item);
|
|
253
|
-
return named ? String(item[named.name]) : String(item.id);
|
|
254
|
-
};
|
|
260
|
+
* How a row names itself — to a screen reader on its checkbox, in a confirm
|
|
261
|
+
* dialog, a bulk result, a tree toggle: what the reader reads the row *as*
|
|
262
|
+
* ("Seleccionar Acme", never "Seleccionar fila 3" and never a whole id),
|
|
263
|
+
* through the one derivation every surface shares.
|
|
264
|
+
*/ const rowLabel = (item)=>nameOf(entityConstructor, item);
|
|
255
265
|
const selectionCell = (item, index, // Passed in rather than closed over: this is only ever called under
|
|
256
266
|
// `selectable`, which already proves the selection exists, and reading the
|
|
257
267
|
// optional prop here would add a fallback arm that nothing can reach.
|
|
@@ -279,8 +289,15 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
279
289
|
busy: isBulkRunning,
|
|
280
290
|
served: metadata == null ? void 0 : metadata.useCases
|
|
281
291
|
});
|
|
292
|
+
// The row a verb last ran on. Its menu trigger unmounts when the verb moved
|
|
293
|
+
// the record out of every state a row verb applies to, and focus then goes
|
|
294
|
+
// to that row's own link or control rather than `<body>`.
|
|
295
|
+
const rowScope = useId();
|
|
296
|
+
const [lastRow, setLastRow] = useState(undefined);
|
|
297
|
+
useFocusOnLoss(()=>lastRow === undefined ? undefined : focusableIn(`${rowScope}${lastRow}`), shown.map(({ item })=>availableUseCases(rowUseCases, item).map(({ key })=>key).join(',')).join(' '));
|
|
282
298
|
const invoke = (useCase, target)=>{
|
|
283
299
|
if (target.kind === 'row') {
|
|
300
|
+
setLastRow(String(target.item.id));
|
|
284
301
|
verbs.invoke({
|
|
285
302
|
descriptor: useCase,
|
|
286
303
|
target,
|
|
@@ -307,7 +324,7 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
307
324
|
menuLabel: t('actions.forRecord', {
|
|
308
325
|
record: rowLabel(item)
|
|
309
326
|
}),
|
|
310
|
-
items: itemsForUseCases(rowUseCases, translateKey, (useCase)=>invoke(useCase, {
|
|
327
|
+
items: itemsForUseCases(availableUseCases(rowUseCases, item), translateKey, (useCase)=>invoke(useCase, {
|
|
311
328
|
kind: 'row',
|
|
312
329
|
item
|
|
313
330
|
}))
|
|
@@ -361,7 +378,7 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
361
378
|
const locale = useLocale();
|
|
362
379
|
const panelId = useId();
|
|
363
380
|
const keys = sortKeys(sorting, columns);
|
|
364
|
-
const activeFilters = (
|
|
381
|
+
const activeFilters = (_ref2 = filtering == null ? void 0 : filtering.values.length) != null ? _ref2 : 0;
|
|
365
382
|
const results = t('table.results', {
|
|
366
383
|
count: totalItems
|
|
367
384
|
});
|
|
@@ -394,11 +411,13 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
394
411
|
var _keys_position;
|
|
395
412
|
const label = (_column_header = column.header) != null ? _column_header : column.label;
|
|
396
413
|
if (!column.sortable || onSortingChange === undefined) return /*#__PURE__*/ _jsx(TableHeaderCell, {
|
|
414
|
+
className: stickyClass(column, 'header'),
|
|
397
415
|
children: label
|
|
398
416
|
}, column.name);
|
|
399
417
|
const position = keys.findIndex((key)=>key.member === column.name);
|
|
400
418
|
const type = (_keys_position = keys[position]) == null ? void 0 : _keys_position.type;
|
|
401
419
|
return /*#__PURE__*/ _jsx(TableHeaderCell, {
|
|
420
|
+
className: stickyClass(column, 'header'),
|
|
402
421
|
"aria-sort": position === 0 ? type === 'asc' ? 'ascending' : 'descending' : undefined,
|
|
403
422
|
children: /*#__PURE__*/ _jsxs("button", {
|
|
404
423
|
type: "button",
|
|
@@ -424,6 +443,7 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
424
443
|
};
|
|
425
444
|
/** A panel toggle: its state said by `aria-expanded`, and its count shown. */ const panelToggle = (which, count)=>/*#__PURE__*/ _jsxs(Button, {
|
|
426
445
|
type: "button",
|
|
446
|
+
id: `${panelId}-${which}`,
|
|
427
447
|
variant: panel === which ? 'primary' : 'secondary',
|
|
428
448
|
size: "sm",
|
|
429
449
|
"aria-expanded": panel === which,
|
|
@@ -527,12 +547,19 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
527
547
|
hasStaleData: items.length > 0,
|
|
528
548
|
isEmpty: items.length === 0,
|
|
529
549
|
isFiltered: activeFilters > 0,
|
|
530
|
-
onClearFilters: onFilteringChange === undefined ? undefined : ()=>
|
|
550
|
+
onClearFilters: onFilteringChange === undefined ? undefined : ()=>{
|
|
551
|
+
var // The button goes with the empty state it sits in, so focus
|
|
552
|
+
// moves first to the control that filters — still there, and
|
|
553
|
+
// where a reader would go next — never to `<body>`.
|
|
554
|
+
_document_getElementById;
|
|
555
|
+
(_document_getElementById = document.getElementById(`${panelId}-filters`)) == null ? void 0 : _document_getElementById.focus();
|
|
556
|
+
onFilteringChange({
|
|
531
557
|
// Only offered under a filter, so there is one to keep the
|
|
532
558
|
// logic of.
|
|
533
559
|
operator: filtering.operator,
|
|
534
560
|
values: []
|
|
535
|
-
})
|
|
561
|
+
});
|
|
562
|
+
},
|
|
536
563
|
emptyAction: mayCreate ? renderLink({
|
|
537
564
|
href: newHref,
|
|
538
565
|
className: button({
|
|
@@ -544,150 +571,177 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
544
571
|
}
|
|
545
572
|
}) : undefined
|
|
546
573
|
}),
|
|
547
|
-
/*#__PURE__*/
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
visibleColumns.map(headerCell),
|
|
567
|
-
hasRowAction && /*#__PURE__*/ _jsx(TableHeaderCell, {
|
|
568
|
-
children: t('table.actions')
|
|
569
|
-
})
|
|
570
|
-
]
|
|
571
|
-
})
|
|
572
|
-
}),
|
|
573
|
-
/*#__PURE__*/ _jsxs(TableBody, {
|
|
574
|
+
!settledEmpty && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
575
|
+
children: [
|
|
576
|
+
/*#__PURE__*/ _jsx("div", {
|
|
577
|
+
className: pivot.grid,
|
|
578
|
+
"aria-busy": busy,
|
|
579
|
+
children: /*#__PURE__*/ _jsxs(Table, {
|
|
580
|
+
caption: caption,
|
|
581
|
+
containerClassName: "max-h-(--table-max-block) scroll-pt-12",
|
|
582
|
+
// Never narrower than its columns side by side: between the
|
|
583
|
+
// essential width and that, the grid scrolls rather than crushing
|
|
584
|
+
// every column into an unreadable sliver.
|
|
585
|
+
style: {
|
|
586
|
+
minWidth: `${widths.full}rem`
|
|
587
|
+
},
|
|
588
|
+
// A focused cell scrolled sideways is never left under the
|
|
589
|
+
// sticky title column (WCAG 2.4.11).
|
|
590
|
+
containerStyle: stickyTitle === undefined ? undefined : {
|
|
591
|
+
scrollPaddingInlineStart: `${columnWidth(stickyTitle)}rem`
|
|
592
|
+
},
|
|
574
593
|
children: [
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
children: customSkeleton
|
|
578
|
-
}) : skeletonRows.map((row)=>/*#__PURE__*/ _jsxs(TableRow, {
|
|
594
|
+
/*#__PURE__*/ _jsx(TableHead, {
|
|
595
|
+
children: slots.header ? slots.header.render(visibleColumns) : /*#__PURE__*/ _jsxs("tr", {
|
|
579
596
|
children: [
|
|
580
|
-
selectable && /*#__PURE__*/ _jsx(
|
|
581
|
-
children: /*#__PURE__*/ _jsx(
|
|
582
|
-
|
|
583
|
-
|
|
597
|
+
selectable && /*#__PURE__*/ _jsx(TableHeaderCell, {
|
|
598
|
+
children: /*#__PURE__*/ _jsx(Checkbox, {
|
|
599
|
+
"aria-label": t('table.selectAllOnPage'),
|
|
600
|
+
checked: allOnPageSelected,
|
|
601
|
+
indeterminate: someOnPageSelected,
|
|
602
|
+
disabled: isBulkRunning || items.length === 0,
|
|
603
|
+
onChange: (event)=>toggleAllOnPage(event.currentTarget.checked, selectionState)
|
|
584
604
|
})
|
|
585
605
|
}),
|
|
586
|
-
visibleColumns.map(
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
className: "w-full"
|
|
590
|
-
})
|
|
591
|
-
}, column.name)),
|
|
592
|
-
hasRowAction && /*#__PURE__*/ _jsx(TableCell, {
|
|
593
|
-
children: /*#__PURE__*/ _jsx(Skeleton, {
|
|
594
|
-
shape: "line",
|
|
595
|
-
className: "w-16"
|
|
596
|
-
})
|
|
597
|
-
})
|
|
598
|
-
]
|
|
599
|
-
}, row))),
|
|
600
|
-
shown.map(({ item, depth, hasChildren }, index)=>{
|
|
601
|
-
var _item_id, _item_id1;
|
|
602
|
-
return slots.row ? // A Fragment carries the key without wrapping the custom row in
|
|
603
|
-
// an element `<tbody>` would reject.
|
|
604
|
-
/*#__PURE__*/ _jsx(Fragment, {
|
|
605
|
-
children: slots.row.render(item, visibleColumns)
|
|
606
|
-
}, String((_item_id = item.id) != null ? _item_id : index)) : /*#__PURE__*/ _jsxs(TableRow, {
|
|
607
|
-
children: [
|
|
608
|
-
selectionState && /*#__PURE__*/ _jsx(TableCell, {
|
|
609
|
-
children: selectionCell(item, index, selectionState)
|
|
610
|
-
}),
|
|
611
|
-
visibleColumns.map((column, columnIndex)=>/*#__PURE__*/ _jsx(TableCell, {
|
|
612
|
-
children: treeKeys !== undefined && columnIndex === 0 ? /*#__PURE__*/ _jsx(TreeCell, {
|
|
613
|
-
depth: depth,
|
|
614
|
-
hasChildren: hasChildren,
|
|
615
|
-
expanded: !collapsed.has(treeKeys.idOf(item)),
|
|
616
|
-
label: t(collapsed.has(treeKeys.idOf(item)) ? 'table.expandRow' : 'table.collapseRow', {
|
|
617
|
-
record: rowLabel(item)
|
|
618
|
-
}),
|
|
619
|
-
onToggle: ()=>toggleCollapsed(treeKeys.idOf(item)),
|
|
620
|
-
children: renderCell(column, item)
|
|
621
|
-
}) : renderCell(column, item)
|
|
622
|
-
}, column.name)),
|
|
623
|
-
hasRowAction && /*#__PURE__*/ _jsx(TableCell, {
|
|
624
|
-
children: recordAction(item)
|
|
606
|
+
visibleColumns.map(headerCell),
|
|
607
|
+
hasRowAction && /*#__PURE__*/ _jsx(TableHeaderCell, {
|
|
608
|
+
children: t('table.actions')
|
|
625
609
|
})
|
|
626
610
|
]
|
|
627
|
-
}
|
|
611
|
+
})
|
|
612
|
+
}),
|
|
613
|
+
/*#__PURE__*/ _jsxs(TableBody, {
|
|
614
|
+
children: [
|
|
615
|
+
showSkeleton && (customSkeleton ? /*#__PURE__*/ _jsx(TableMessageRow, {
|
|
616
|
+
colSpan: columnCount,
|
|
617
|
+
children: customSkeleton
|
|
618
|
+
}) : skeletonRows.map((row)=>/*#__PURE__*/ _jsxs(TableRow, {
|
|
619
|
+
children: [
|
|
620
|
+
selectable && /*#__PURE__*/ _jsx(TableCell, {
|
|
621
|
+
children: /*#__PURE__*/ _jsx(Skeleton, {
|
|
622
|
+
shape: "line",
|
|
623
|
+
className: "w-4"
|
|
624
|
+
})
|
|
625
|
+
}),
|
|
626
|
+
visibleColumns.map((column)=>/*#__PURE__*/ _jsx(TableCell, {
|
|
627
|
+
children: /*#__PURE__*/ _jsx(Skeleton, {
|
|
628
|
+
shape: "line",
|
|
629
|
+
className: "w-full"
|
|
630
|
+
})
|
|
631
|
+
}, column.name)),
|
|
632
|
+
hasRowAction && /*#__PURE__*/ _jsx(TableCell, {
|
|
633
|
+
children: /*#__PURE__*/ _jsx(Skeleton, {
|
|
634
|
+
shape: "line",
|
|
635
|
+
className: "w-16"
|
|
636
|
+
})
|
|
637
|
+
})
|
|
638
|
+
]
|
|
639
|
+
}, row))),
|
|
640
|
+
shown.map(({ item, depth, hasChildren }, index)=>{
|
|
641
|
+
var _item_id, _item_id1;
|
|
642
|
+
return slots.row ? // A Fragment carries the key without wrapping the custom row in
|
|
643
|
+
// an element `<tbody>` would reject.
|
|
644
|
+
/*#__PURE__*/ _jsx(Fragment, {
|
|
645
|
+
children: slots.row.render(item, visibleColumns)
|
|
646
|
+
}, String((_item_id = item.id) != null ? _item_id : index)) : /*#__PURE__*/ _jsxs(TableRow, {
|
|
647
|
+
"data-record-id": `${rowScope}${String(item.id)}`,
|
|
648
|
+
className: "group/row",
|
|
649
|
+
children: [
|
|
650
|
+
selectionState && /*#__PURE__*/ _jsx(TableCell, {
|
|
651
|
+
children: selectionCell(item, index, selectionState)
|
|
652
|
+
}),
|
|
653
|
+
visibleColumns.map((column, columnIndex)=>/*#__PURE__*/ _jsx(TableCell, {
|
|
654
|
+
className: stickyClass(column, 'body'),
|
|
655
|
+
children: treeKeys !== undefined && columnIndex === 0 ? /*#__PURE__*/ _jsx(TreeCell, {
|
|
656
|
+
depth: depth,
|
|
657
|
+
hasChildren: hasChildren,
|
|
658
|
+
expanded: !collapsed.has(treeKeys.idOf(item)),
|
|
659
|
+
label: t(collapsed.has(treeKeys.idOf(item)) ? 'table.expandRow' : 'table.collapseRow', {
|
|
660
|
+
record: rowLabel(item)
|
|
661
|
+
}),
|
|
662
|
+
onToggle: ()=>toggleCollapsed(treeKeys.idOf(item)),
|
|
663
|
+
children: renderCell(column, item)
|
|
664
|
+
}) : renderCell(column, item)
|
|
665
|
+
}, column.name)),
|
|
666
|
+
hasRowAction && /*#__PURE__*/ _jsx(TableCell, {
|
|
667
|
+
children: recordAction(item)
|
|
668
|
+
})
|
|
669
|
+
]
|
|
670
|
+
}, String((_item_id1 = item.id) != null ? _item_id1 : index));
|
|
671
|
+
})
|
|
672
|
+
]
|
|
628
673
|
})
|
|
629
674
|
]
|
|
630
675
|
})
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
children: /*#__PURE__*/ _jsx(EntityRecordCard, {
|
|
643
|
-
title: /*#__PURE__*/ _jsx(Skeleton, {
|
|
644
|
-
shape: "line",
|
|
645
|
-
className: "w-32"
|
|
646
|
-
}),
|
|
647
|
-
meta: visibleColumns.slice(1).map((column)=>({
|
|
648
|
-
key: column.name,
|
|
649
|
-
label: column.label,
|
|
650
|
-
value: /*#__PURE__*/ _jsx(Skeleton, {
|
|
676
|
+
}),
|
|
677
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
678
|
+
className: pivot.cards,
|
|
679
|
+
"aria-busy": busy,
|
|
680
|
+
children: [
|
|
681
|
+
showSkeleton && (customSkeleton != null ? customSkeleton : /*#__PURE__*/ _jsx("ul", {
|
|
682
|
+
role: "list",
|
|
683
|
+
className: "m-0 p-0 flex list-none flex-col gap-2xs",
|
|
684
|
+
children: skeletonRows.map((row)=>/*#__PURE__*/ _jsx("li", {
|
|
685
|
+
children: /*#__PURE__*/ _jsx(EntityRecordCard, {
|
|
686
|
+
title: /*#__PURE__*/ _jsx(Skeleton, {
|
|
651
687
|
shape: "line",
|
|
652
|
-
className: "w-
|
|
653
|
-
})
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
"
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
+
className: "w-32"
|
|
689
|
+
}),
|
|
690
|
+
meta: visibleColumns.slice(1).map((column)=>({
|
|
691
|
+
key: column.name,
|
|
692
|
+
label: column.label,
|
|
693
|
+
value: /*#__PURE__*/ _jsx(Skeleton, {
|
|
694
|
+
shape: "line",
|
|
695
|
+
className: "w-24"
|
|
696
|
+
})
|
|
697
|
+
}))
|
|
698
|
+
})
|
|
699
|
+
}, row))
|
|
700
|
+
})),
|
|
701
|
+
shown.length > 0 && /*#__PURE__*/ _jsx("ul", {
|
|
702
|
+
role: "list",
|
|
703
|
+
className: "m-0 p-0 flex list-none flex-col gap-2xs",
|
|
704
|
+
children: shown.map(({ item, depth }, index)=>{
|
|
705
|
+
var _item_id;
|
|
706
|
+
const parts = cardParts(item);
|
|
707
|
+
return /*#__PURE__*/ _jsx("li", {
|
|
708
|
+
"data-record-id": `${rowScope}${String(item.id)}`,
|
|
709
|
+
// A tree's card says how deep it sits, as its row does.
|
|
710
|
+
"aria-level": treeKeys === undefined ? undefined : depth + 1,
|
|
711
|
+
style: treeKeys === undefined ? undefined : {
|
|
712
|
+
marginInlineStart: `${depth * 1.5}rem`
|
|
713
|
+
},
|
|
714
|
+
children: /*#__PURE__*/ _jsx(EntityRecordCard, {
|
|
715
|
+
// The same renderers as the grid, so the two layouts agree.
|
|
716
|
+
title: parts.title === undefined ? hrefFor === undefined || onSelect !== undefined ? rowLabel(item) : renderLink({
|
|
717
|
+
href: hrefFor(item.id),
|
|
718
|
+
className: linkClassName,
|
|
719
|
+
children: rowLabel(item),
|
|
720
|
+
intent: {
|
|
721
|
+
kind: 'open',
|
|
722
|
+
id: item.id
|
|
723
|
+
}
|
|
724
|
+
}) : renderCell(parts.title, item),
|
|
725
|
+
subtitle: parts.subtitle === undefined ? undefined : renderCell(parts.subtitle, item),
|
|
726
|
+
badges: parts.badges.map((column)=>({
|
|
727
|
+
key: column.name,
|
|
728
|
+
value: renderCell(column, item)
|
|
729
|
+
})),
|
|
730
|
+
meta: parts.meta.map((column)=>{
|
|
731
|
+
var _column_header;
|
|
732
|
+
return {
|
|
733
|
+
key: column.name,
|
|
734
|
+
label: (_column_header = column.header) != null ? _column_header : column.label,
|
|
735
|
+
value: renderCell(column, item)
|
|
736
|
+
};
|
|
737
|
+
}),
|
|
738
|
+
leading: selectionState ? selectionCell(item, index, selectionState) : undefined,
|
|
739
|
+
actions: recordAction(item)
|
|
740
|
+
})
|
|
741
|
+
}, String((_item_id = item.id) != null ? _item_id : index));
|
|
688
742
|
})
|
|
689
|
-
}
|
|
690
|
-
|
|
743
|
+
})
|
|
744
|
+
]
|
|
691
745
|
})
|
|
692
746
|
]
|
|
693
747
|
}),
|
|
@@ -702,5 +756,20 @@ export function EntityTable({ entityConstructor, isLoading, skeleton = true, err
|
|
|
702
756
|
]
|
|
703
757
|
});
|
|
704
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* The first control in a record's row or card that the reader can see. Both
|
|
761
|
+
* layouts are in the DOM and CSS shows one, so a control inside the hidden
|
|
762
|
+
* one is skipped. `scoped` is the record's id under this table's own prefix,
|
|
763
|
+
* so a second table on the page holding the same record is never reached.
|
|
764
|
+
*/ function focusableIn(scoped) {
|
|
765
|
+
return [
|
|
766
|
+
...document.querySelectorAll(`[data-record-id="${CSS.escape(scoped)}"] :is(a[href], button)`)
|
|
767
|
+
].find((control)=>{
|
|
768
|
+
var _ref;
|
|
769
|
+
return (_ref = // `checkVisibility` is recent; a browser without it is asked for the
|
|
770
|
+
// boxes the control lays out, which a `display: none` layout has none of.
|
|
771
|
+
control.checkVisibility == null ? void 0 : control.checkVisibility.call(control)) != null ? _ref : control.getClientRects().length > 0;
|
|
772
|
+
});
|
|
773
|
+
}
|
|
705
774
|
|
|
706
775
|
//# sourceMappingURL=entity-table.js.map
|