@jsudc/react 0.3.1 → 0.5.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/README.md +1137 -22
- package/dist/actions/RowActionsMenu.d.ts +45 -0
- package/dist/actions/RowActionsMenu.js +161 -0
- package/dist/actions/RowActionsMenu.js.map +1 -0
- package/dist/actions/bulk.d.ts +81 -0
- package/dist/actions/bulk.js +54 -0
- package/dist/actions/bulk.js.map +1 -0
- package/dist/actions/row.d.ts +50 -0
- package/dist/actions/row.js +34 -0
- package/dist/actions/row.js.map +1 -0
- package/dist/actions/useRowActionRunner.d.ts +26 -0
- package/dist/actions/useRowActionRunner.js +198 -0
- package/dist/actions/useRowActionRunner.js.map +1 -0
- package/dist/calendar/CalendarRenderer.js +5 -4
- package/dist/calendar/CalendarRenderer.js.map +1 -1
- package/dist/calendar/EventDetail.js +1 -1
- package/dist/calendar.js +1 -1
- package/dist/cards/CardRenderer.d.ts +8 -1
- package/dist/cards/CardRenderer.js +179 -110
- package/dist/cards/CardRenderer.js.map +1 -1
- package/dist/cells/registry.d.ts +60 -0
- package/dist/cells/registry.js +47 -0
- package/dist/cells/registry.js.map +1 -0
- package/dist/chart/ChartRenderer.js +6 -4
- package/dist/chart/ChartRenderer.js.map +1 -1
- package/dist/chart/ChartWindowControl.js +2 -2
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/dialog.js +4 -3
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js +2 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/popover.js +2 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/select.js +2 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/toast.js +3 -2
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/tooltip.js +2 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/data-view/BulkBar.d.ts +36 -0
- package/dist/data-view/BulkBar.js +239 -0
- package/dist/data-view/BulkBar.js.map +1 -0
- package/dist/data-view/FilePreview.js +1 -1
- package/dist/data-view/FilterBuilder.js +2 -2
- package/dist/data-view/FilterChips.js +2 -2
- package/dist/data-view/Freshness.js +1 -1
- package/dist/data-view/LiveIndicator.d.ts +10 -0
- package/dist/data-view/LiveIndicator.js +33 -0
- package/dist/data-view/LiveIndicator.js.map +1 -0
- package/dist/data-view/SearchBox.js +1 -1
- package/dist/data-view/UdcDataView.d.ts +110 -1
- package/dist/data-view/UdcDataView.js +237 -90
- package/dist/data-view/UdcDataView.js.map +1 -1
- package/dist/data-view/useDataViewState.d.ts +8 -0
- package/dist/data-view/useDataViewState.js +2 -1
- package/dist/data-view/useDataViewState.js.map +1 -1
- package/dist/headless.d.ts +9 -0
- package/dist/headless.js +12 -2
- package/dist/i18n/translations.js +136 -0
- package/dist/i18n/translations.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.js +17 -4
- package/dist/kanban/KanbanCard.js +1 -1
- package/dist/kanban/KanbanColumn.js +1 -1
- package/dist/kanban/KanbanRenderer.js +6 -5
- package/dist/kanban/KanbanRenderer.js.map +1 -1
- package/dist/lib/scope.d.ts +8 -0
- package/dist/lib/scope.js +12 -0
- package/dist/lib/scope.js.map +1 -0
- package/dist/lookup/LookupCombobox.js +1 -1
- package/dist/lookup/batch.js +1 -1
- package/dist/lookup/options.js +4 -1
- package/dist/lookup/options.js.map +1 -1
- package/dist/lookup/useUdcLookup.js +9 -3
- package/dist/lookup/useUdcLookup.js.map +1 -1
- package/dist/map/MapRenderer.js +4 -3
- package/dist/map/MapRenderer.js.map +1 -1
- package/dist/renderers/types.d.ts +44 -1
- package/dist/renderers/types.js.map +1 -1
- package/dist/rows/useRowActivation.d.ts +91 -0
- package/dist/rows/useRowActivation.js +257 -0
- package/dist/rows/useRowActivation.js.map +1 -0
- package/dist/rows/useRowSelection.d.ts +92 -0
- package/dist/rows/useRowSelection.js +156 -0
- package/dist/rows/useRowSelection.js.map +1 -0
- package/dist/schema-editor/DeleteFieldDialog.js +2 -2
- package/dist/schema-editor/FieldFormDialog.js +2 -2
- package/dist/schema-editor/TagInput.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.scoped.css +2 -0
- package/dist/table/CellEditor.js +2 -1
- package/dist/table/CellEditor.js.map +1 -1
- package/dist/table/SelectCheckbox.d.ts +15 -0
- package/dist/table/SelectCheckbox.js +37 -0
- package/dist/table/SelectCheckbox.js.map +1 -0
- package/dist/table/TableRenderer.d.ts +15 -1
- package/dist/table/TableRenderer.js +305 -114
- package/dist/table/TableRenderer.js.map +1 -1
- package/dist/table/cells.d.ts +13 -2
- package/dist/table/cells.js +15 -2
- package/dist/table/cells.js.map +1 -1
- package/dist/table/index.d.ts +1 -0
- package/dist/table/states.d.ts +6 -0
- package/dist/table/states.js +14 -1
- package/dist/table/states.js.map +1 -1
- package/dist/table/useRowWindow.d.ts +82 -0
- package/dist/table/useRowWindow.js +182 -0
- package/dist/table/useRowWindow.js.map +1 -0
- package/dist/table.js.map +1 -1
- package/dist/tree/TreeNode.js +1 -1
- package/dist/tree/TreeRenderer.d.ts +2 -0
- package/dist/tree/TreeRenderer.js +16 -10
- package/dist/tree/TreeRenderer.js.map +1 -1
- package/dist/udc/changeFeed.d.ts +94 -0
- package/dist/udc/changeFeed.js +250 -0
- package/dist/udc/changeFeed.js.map +1 -0
- package/dist/udc/changes.d.ts +34 -0
- package/dist/udc/changes.js +79 -0
- package/dist/udc/changes.js.map +1 -0
- package/dist/udc/client.d.ts +15 -1
- package/dist/udc/client.js +34 -10
- package/dist/udc/client.js.map +1 -1
- package/dist/udc/hooks.d.ts +94 -16
- package/dist/udc/hooks.js +113 -10
- package/dist/udc/hooks.js.map +1 -1
- package/dist/udc/keys.d.ts +2 -0
- package/dist/udc/keys.js.map +1 -1
- package/dist/udc/listCache.d.ts +11 -0
- package/dist/udc/listCache.js +38 -0
- package/dist/udc/listCache.js.map +1 -0
- package/dist/udc/provider.d.ts +21 -3
- package/dist/udc/provider.js +23 -2
- package/dist/udc/provider.js.map +1 -1
- package/dist/udc/unauthenticated.d.ts +4 -0
- package/dist/udc/unauthenticated.js +17 -0
- package/dist/udc/unauthenticated.js.map +1 -0
- package/dist/ui-kit/types.d.ts +14 -0
- package/dist/ui-kit/ui.d.ts +1 -0
- package/dist/ui.js +2 -1
- package/dist/url-state/adapters.d.ts +23 -0
- package/dist/url-state/adapters.js +57 -0
- package/dist/url-state/adapters.js.map +1 -0
- package/dist/url-state/index.d.ts +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/table/SelectCheckbox.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The selection checkbox of a row, a card or the page: a native checkbox (it
|
|
7
|
+
* has the indeterminate state and reports a shift-click), labelled for screen
|
|
8
|
+
* readers. `onToggle(range)`: `range` is true for a shift-click. The label
|
|
9
|
+
* around it widens the hit area to the whole cell.
|
|
10
|
+
*/
|
|
11
|
+
function SelectCheckbox({ checked, indeterminate = false, disabled = false, label, onToggle, className, "data-testid": testId }) {
|
|
12
|
+
const ref = useRef(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (ref.current) ref.current.indeterminate = indeterminate;
|
|
15
|
+
}, [indeterminate]);
|
|
16
|
+
return /* @__PURE__ */ jsx("label", {
|
|
17
|
+
className: cn("udc-select udc:flex udc:h-full udc:w-full udc:cursor-pointer udc:items-center udc:justify-center", className),
|
|
18
|
+
onMouseDown: (e) => {
|
|
19
|
+
if (e.shiftKey) e.preventDefault();
|
|
20
|
+
},
|
|
21
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
22
|
+
ref,
|
|
23
|
+
type: "checkbox",
|
|
24
|
+
"data-testid": testId,
|
|
25
|
+
"aria-label": label,
|
|
26
|
+
"aria-checked": indeterminate ? "mixed" : checked,
|
|
27
|
+
checked,
|
|
28
|
+
disabled,
|
|
29
|
+
onChange: () => {},
|
|
30
|
+
onClick: (e) => onToggle(e.shiftKey),
|
|
31
|
+
className: "udc:size-4 udc:cursor-pointer udc:accent-primary udc:disabled:cursor-default"
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export { SelectCheckbox };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=SelectCheckbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectCheckbox.js","names":[],"sources":["../../src/table/SelectCheckbox.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { cn } from \"../lib/utils.js\";\n\n/**\n * The selection checkbox of a row, a card or the page: a native checkbox (it\n * has the indeterminate state and reports a shift-click), labelled for screen\n * readers. `onToggle(range)`: `range` is true for a shift-click. The label\n * around it widens the hit area to the whole cell.\n */\nexport function SelectCheckbox({\n checked,\n indeterminate = false,\n disabled = false,\n label,\n onToggle,\n className,\n \"data-testid\": testId,\n}: {\n checked: boolean;\n indeterminate?: boolean;\n disabled?: boolean;\n label: string;\n onToggle: (range: boolean) => void;\n className?: string;\n \"data-testid\"?: string;\n}) {\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (ref.current) ref.current.indeterminate = indeterminate;\n }, [indeterminate]);\n return (\n <label\n className={cn(\n \"udc-select udc:flex udc:h-full udc:w-full udc:cursor-pointer udc:items-center udc:justify-center\",\n className,\n )}\n // A shift-click selects a range: keep the browser from selecting text on the way.\n onMouseDown={(e) => {\n if (e.shiftKey) e.preventDefault();\n }}\n >\n <input\n ref={ref}\n type=\"checkbox\"\n data-testid={testId}\n aria-label={label}\n aria-checked={indeterminate ? \"mixed\" : checked}\n checked={checked}\n disabled={disabled}\n onChange={() => {}}\n onClick={(e) => onToggle(e.shiftKey)}\n className=\"udc:size-4 udc:cursor-pointer udc:accent-primary udc:disabled:cursor-default\"\n />\n </label>\n );\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,eAAe,EAC7B,SACA,gBAAgB,OAChB,WAAW,OACX,OACA,UACA,WACA,eAAe,UASd;CACD,MAAM,MAAM,OAAyB,IAAI;CACzC,gBAAgB;EACd,IAAI,IAAI,SAAS,IAAI,QAAQ,gBAAgB;CAC/C,GAAG,CAAC,aAAa,CAAC;CAClB,OACE,oBAAC,SAAD;EACE,WAAW,GACT,oGACA,SACF;EAEA,cAAc,MAAM;GAClB,IAAI,EAAE,UAAU,EAAE,eAAe;EACnC;EAEA,UAAA,oBAAC,SAAD;GACO;GACL,MAAK;GACL,eAAa;GACb,cAAY;GACZ,gBAAc,gBAAgB,UAAU;GAC/B;GACC;GACV,gBAAgB,CAAC;GACjB,UAAU,MAAM,SAAS,EAAE,QAAQ;GACnC,WAAU;EACX,CAAA;CACI,CAAA;AAEX"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { type DescribeResponse, type SortKey, type UdcError } from "@jsudc/core";
|
|
2
|
+
import type { RowActions } from "../actions/row.js";
|
|
2
3
|
import type { FolderNav } from "../renderers/types.js";
|
|
4
|
+
import { type RowActivationProps } from "../rows/useRowActivation.js";
|
|
5
|
+
import type { RowSelection } from "../rows/useRowSelection.js";
|
|
3
6
|
import type { SchemaAction } from "../schema-editor/fieldForm.js";
|
|
4
7
|
import type { UdcCollectionResult } from "../udc/hooks.js";
|
|
5
8
|
import type { PagingMode } from "../udc/keys.js";
|
|
9
|
+
import { type TableVirtualizeProp } from "./useRowWindow.js";
|
|
6
10
|
/** The message a `validation_error` carries for one field, else its overall message. */
|
|
7
11
|
export declare function fieldProblem(err: UdcError, field: string): string;
|
|
8
|
-
export interface TableRendererProps {
|
|
12
|
+
export interface TableRendererProps extends RowActivationProps {
|
|
9
13
|
collection: string;
|
|
10
14
|
describe: DescribeResponse;
|
|
11
15
|
data: UdcCollectionResult;
|
|
@@ -23,5 +27,15 @@ export interface TableRendererProps {
|
|
|
23
27
|
onSchemaAction?: ((a: SchemaAction) => void) | undefined;
|
|
24
28
|
/** A folder listing: the label column opens folders and previews files. */
|
|
25
29
|
folder?: FolderNav | undefined;
|
|
30
|
+
/** Row selection (0.5.0): a checkbox column pinned at the start; Space toggles the active row. */
|
|
31
|
+
selection?: RowSelection | undefined;
|
|
32
|
+
/** Row actions (0.5.0): a trailing column pinned at the end, inline buttons or a "more" menu. */
|
|
33
|
+
rowActions?: RowActions | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Long lists (0.5.0): infinite mode mounts only the rows near the viewport. Left out, or
|
|
36
|
+
* `{ enabled: "auto" }`: once more than `threshold` (200) rows are loaded. `true` / `false`
|
|
37
|
+
* force it on or off. Pages mode is never windowed. See README "Long lists".
|
|
38
|
+
*/
|
|
39
|
+
virtualize?: TableVirtualizeProp | undefined;
|
|
26
40
|
}
|
|
27
41
|
export declare function TableRenderer(props: TableRendererProps): import("react").JSX.Element;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
+
import { RowActionsControls, rowActionsColumnWidth, rowMenuHandlers, useRowMenu } from "../actions/RowActionsMenu.js";
|
|
2
|
+
import { useCellRegistry } from "../cells/registry.js";
|
|
1
3
|
import { FolderEntry } from "../data-view/FolderEntry.js";
|
|
2
4
|
import { tableSection, useI18n } from "../i18n/i18n.js";
|
|
3
5
|
import { cn } from "../lib/utils.js";
|
|
4
6
|
import { UdcLookupBatch, useLookupBatch } from "../lookup/batch.js";
|
|
5
7
|
import { filterHref, followLink, useUdcLinks } from "../lookup/links.js";
|
|
8
|
+
import { useRowActivation } from "../rows/useRowActivation.js";
|
|
6
9
|
import { ColumnHeaderMenu } from "../schema-editor/ColumnHeaderMenu.js";
|
|
7
10
|
import { useUdcMutate } from "../udc/hooks.js";
|
|
8
11
|
import { useUiKit } from "../ui-kit/context.js";
|
|
9
12
|
import { CellEditor, editorKind, fromEditorValue, sameValue } from "./CellEditor.js";
|
|
10
13
|
import { CellValue } from "./cells.js";
|
|
11
14
|
import { Pager } from "./Pager.js";
|
|
15
|
+
import { SelectCheckbox } from "./SelectCheckbox.js";
|
|
12
16
|
import { EmptyState, ErrorState } from "./states.js";
|
|
13
17
|
import { BG_COLOR, TEXT_COLOR, resolveRowColor } from "./style.js";
|
|
14
18
|
import { useInfiniteSentinel } from "./useInfiniteSentinel.js";
|
|
15
|
-
import {
|
|
16
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
19
|
+
import { bodySlices, resolveVirtualization, useRowWindow, virtualizationApplies } from "./useRowWindow.js";
|
|
17
20
|
import { isUdcError, isVersionConflict, rowLinkCondition } from "@jsudc/core";
|
|
21
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
22
|
+
import { ArrowDown, ArrowUp, ChevronsUpDown, Plus } from "lucide-react";
|
|
18
23
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
24
|
import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
|
20
25
|
// src/table/TableRenderer.tsx
|
|
@@ -23,6 +28,8 @@ var SKELETON_ROWS = 12;
|
|
|
23
28
|
var DEFAULT_ROW_HEIGHT = 40;
|
|
24
29
|
/** The trailing `+` header cell that adds a column at the end. */
|
|
25
30
|
var ADD_COLUMN_WIDTH = 44;
|
|
31
|
+
/** The checkbox column pinned at the start while the view selects. */
|
|
32
|
+
var SELECT_COLUMN_WIDTH = 40;
|
|
26
33
|
/** The message a `validation_error` carries for one field, else its overall message. */
|
|
27
34
|
function fieldProblem(err, field) {
|
|
28
35
|
const problems = err.details?.problems;
|
|
@@ -42,11 +49,14 @@ function TableRenderer(props) {
|
|
|
42
49
|
const mutate = useUdcMutate(collection);
|
|
43
50
|
const section = tableSection(collection);
|
|
44
51
|
const links = useUdcLinks();
|
|
52
|
+
const cells = useCellRegistry();
|
|
45
53
|
const rowLink = view.row_link;
|
|
46
54
|
const lookupFields = useMemo(() => view.columns.map((c) => c.field), [view.columns]);
|
|
47
55
|
const lookups = useLookupBatch(data.rows, schema, lookupFields);
|
|
48
56
|
const scrollRef = useRef(null);
|
|
49
57
|
const sentinelRef = useRef(null);
|
|
58
|
+
const headerRef = useRef(null);
|
|
59
|
+
const bodyRef = useRef(null);
|
|
50
60
|
const [edges, setEdges] = useState({
|
|
51
61
|
left: false,
|
|
52
62
|
right: false
|
|
@@ -86,6 +96,11 @@ function TableRenderer(props) {
|
|
|
86
96
|
}))
|
|
87
97
|
}
|
|
88
98
|
});
|
|
99
|
+
const selection = props.selection;
|
|
100
|
+
const selectWidth = selection ? SELECT_COLUMN_WIDTH : 0;
|
|
101
|
+
const rowActions = props.rowActions;
|
|
102
|
+
const rowMenu = useRowMenu();
|
|
103
|
+
const actionsWidth = rowActions ? rowActionsColumnWidth(rowActions) : 0;
|
|
89
104
|
const left = table.getLeftLeafColumns();
|
|
90
105
|
const center = table.getCenterLeafColumns();
|
|
91
106
|
const right = table.getRightLeafColumns();
|
|
@@ -95,8 +110,27 @@ function TableRenderer(props) {
|
|
|
95
110
|
...right
|
|
96
111
|
];
|
|
97
112
|
const schemaEdit = capabilities.schema_edit && props.onSchemaAction !== void 0;
|
|
98
|
-
const totalWidth = ordered.reduce((sum, c) => sum + c.getSize(), 0) + (schemaEdit ? ADD_COLUMN_WIDTH : 0);
|
|
113
|
+
const totalWidth = ordered.reduce((sum, c) => sum + c.getSize(), 0) + (schemaEdit ? ADD_COLUMN_WIDTH : 0) + selectWidth + actionsWidth;
|
|
99
114
|
const rowHeight = view.row_height ?? DEFAULT_ROW_HEIGHT;
|
|
115
|
+
const showSkeleton = data.isLoading && data.rows.length === 0;
|
|
116
|
+
const virtual = !showSkeleton && virtualizationApplies(props.virtualize, mode, data.rows.length);
|
|
117
|
+
const virtualOpts = resolveVirtualization(props.virtualize);
|
|
118
|
+
const [measuredHeight, setMeasuredHeight] = useState(null);
|
|
119
|
+
const windowRowHeight = virtual && measuredHeight ? measuredHeight : rowHeight;
|
|
120
|
+
const win = useRowWindow({
|
|
121
|
+
on: virtual,
|
|
122
|
+
count: data.rows.length,
|
|
123
|
+
rowHeight: windowRowHeight,
|
|
124
|
+
overscan: virtualOpts.overscan,
|
|
125
|
+
scrollRef,
|
|
126
|
+
headerRef
|
|
127
|
+
});
|
|
128
|
+
useLayoutEffect(() => {
|
|
129
|
+
if (!virtual) return;
|
|
130
|
+
const h = (bodyRef.current?.querySelector("tr[data-row-id]"))?.getBoundingClientRect().height ?? 0;
|
|
131
|
+
if (h > 0 && Math.abs(h - (measuredHeight ?? rowHeight)) > .5) setMeasuredHeight(h);
|
|
132
|
+
});
|
|
133
|
+
const [focusedRowId, setFocusedRowId] = useState(null);
|
|
100
134
|
const canEdit = (c) => capabilities.mutate && meta(c).config.editable === true && meta(c).def !== void 0;
|
|
101
135
|
const editableIds = ordered.filter(canEdit).map((c) => c.id);
|
|
102
136
|
const measureEdges = () => {
|
|
@@ -114,10 +148,27 @@ function TableRenderer(props) {
|
|
|
114
148
|
return () => window.removeEventListener("resize", measureEdges);
|
|
115
149
|
});
|
|
116
150
|
useEffect(() => {
|
|
117
|
-
if (props.resetKey && scrollRef.current)
|
|
151
|
+
if (props.resetKey && scrollRef.current) {
|
|
152
|
+
scrollRef.current.scrollTop = 0;
|
|
153
|
+
win.onScroll();
|
|
154
|
+
}
|
|
118
155
|
}, [props.resetKey]);
|
|
119
156
|
const { hasNextPage, isFetchingNextPage } = data;
|
|
120
157
|
useInfiniteSentinel(mode === "infinite", scrollRef, sentinelRef, data);
|
|
158
|
+
const activation = useRowActivation({
|
|
159
|
+
rows: data.rows,
|
|
160
|
+
activeRowId: props.activeRowId,
|
|
161
|
+
onRowActivate: props.onRowActivate,
|
|
162
|
+
onActiveRowChange: props.onActiveRowChange,
|
|
163
|
+
hasNextPage: mode === "infinite" && hasNextPage,
|
|
164
|
+
isFetchingNextPage,
|
|
165
|
+
fetchNextPage: data.fetchNextPage,
|
|
166
|
+
...virtual ? { reveal: (_row, index) => win.scrollToIndex(index) } : {},
|
|
167
|
+
...selection ? {
|
|
168
|
+
isSelected: selection.isSelected,
|
|
169
|
+
onToggleSelect: (row, range) => selection.toggle(row.__meta.id, { range })
|
|
170
|
+
} : {}
|
|
171
|
+
});
|
|
121
172
|
const rowLinkHref = (row) => rowLink ? filterHref(links, rowLink.collection, rowLinkCondition(row, rowLink)) : "";
|
|
122
173
|
/**
|
|
123
174
|
* A click on a row of a view with `row_link` opens the linked collection;
|
|
@@ -130,6 +181,18 @@ function TableRenderer(props) {
|
|
|
130
181
|
if (e.target.closest("a,button,input,select,textarea,label,[data-editable]")) return;
|
|
131
182
|
followLink(e, rowLinkHref(row), links);
|
|
132
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* With `onRowActivate` a plain click activates the row; Cmd / Ctrl-click and
|
|
186
|
+
* the middle button (`onAuxClick`) still follow a `row_link`. Without it a
|
|
187
|
+
* `row_link` view navigates as before.
|
|
188
|
+
*/
|
|
189
|
+
const onRowClick = (e, row) => {
|
|
190
|
+
if (rowLink && (!props.onRowActivate || e.metaKey || e.ctrlKey || e.shiftKey)) {
|
|
191
|
+
onRowLinkClick(e, row);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
activation.handleClick(e, row);
|
|
195
|
+
};
|
|
133
196
|
const focusCell = (target) => requestAnimationFrame(() => {
|
|
134
197
|
const sel = `[data-cell="${CSS.escape(`${target.rowId}:${target.colId}`)}"]`;
|
|
135
198
|
scrollRef.current?.querySelector(sel)?.focus();
|
|
@@ -204,11 +267,11 @@ function TableRenderer(props) {
|
|
|
204
267
|
const width = c.getSize();
|
|
205
268
|
if (pin === "left") return {
|
|
206
269
|
width,
|
|
207
|
-
left: c.getStart("left")
|
|
270
|
+
left: c.getStart("left") + selectWidth
|
|
208
271
|
};
|
|
209
272
|
if (pin === "right") return {
|
|
210
273
|
width,
|
|
211
|
-
right: c.getAfter("right")
|
|
274
|
+
right: c.getAfter("right") + actionsWidth
|
|
212
275
|
};
|
|
213
276
|
return { width };
|
|
214
277
|
};
|
|
@@ -222,7 +285,6 @@ function TableRenderer(props) {
|
|
|
222
285
|
const a = meta(c).config.align;
|
|
223
286
|
return a === "right" ? "udc:text-right udc:justify-end" : a === "center" ? "udc:text-center udc:justify-center" : "";
|
|
224
287
|
};
|
|
225
|
-
const showSkeleton = data.isLoading && data.rows.length === 0;
|
|
226
288
|
const showError = data.error !== null && data.rows.length === 0;
|
|
227
289
|
const showEmpty = !showSkeleton && !showError && data.rows.length === 0;
|
|
228
290
|
const total = data.total ?? data.rows.length;
|
|
@@ -295,11 +357,195 @@ function TableRenderer(props) {
|
|
|
295
357
|
"aria-hidden": true,
|
|
296
358
|
className: cn("udc:p-0", className)
|
|
297
359
|
}, key);
|
|
360
|
+
const selectClass = cn("udc:sticky udc:left-0 udc:z-[5] udc:border-b udc:border-border udc:p-0", left.length === 0 && "udc:after:pointer-events-none udc:after:absolute udc:after:inset-y-0 udc:after:-right-3 udc:after:w-3 udc:after:bg-gradient-to-r udc:after:from-[var(--shadow-pin)] udc:after:to-transparent udc:after:opacity-0 udc:after:transition-opacity", left.length === 0 && edges.left && "udc:after:opacity-100");
|
|
361
|
+
const pageState = selection?.pageState ?? "none";
|
|
362
|
+
const selectHeader = selection ? /* @__PURE__ */ jsx("th", {
|
|
363
|
+
scope: "col",
|
|
364
|
+
"data-testid": "th-select",
|
|
365
|
+
style: { width: SELECT_COLUMN_WIDTH },
|
|
366
|
+
className: cn(selectClass, "udc:z-[15] udc:h-9 udc:bg-muted"),
|
|
367
|
+
children: /* @__PURE__ */ jsx(SelectCheckbox, {
|
|
368
|
+
"data-testid": "select-page",
|
|
369
|
+
label: t("APP", "SELECT_PAGE"),
|
|
370
|
+
checked: pageState === "all",
|
|
371
|
+
indeterminate: pageState === "some",
|
|
372
|
+
disabled: data.rows.length === 0,
|
|
373
|
+
onToggle: () => selection.setPage(pageState !== "all")
|
|
374
|
+
})
|
|
375
|
+
}, "__select") : null;
|
|
376
|
+
const selectCell = (row, className) => selection ? /* @__PURE__ */ jsx("td", {
|
|
377
|
+
"data-testid": "cell-select",
|
|
378
|
+
style: { width: SELECT_COLUMN_WIDTH },
|
|
379
|
+
className: cn(selectClass, className),
|
|
380
|
+
children: /* @__PURE__ */ jsx(SelectCheckbox, {
|
|
381
|
+
"data-testid": "select-row",
|
|
382
|
+
label: t("APP", "SELECT_ROW"),
|
|
383
|
+
checked: selection.isSelected(row.__meta.id),
|
|
384
|
+
onToggle: (range) => selection.toggle(row.__meta.id, { range })
|
|
385
|
+
})
|
|
386
|
+
}, "__select") : null;
|
|
387
|
+
const actionsClass = cn("udc:sticky udc:right-0 udc:z-[5] udc:border-b udc:border-border udc:p-0", right.length === 0 && "udc:before:pointer-events-none udc:before:absolute udc:before:inset-y-0 udc:before:-left-3 udc:before:w-3 udc:before:bg-gradient-to-l udc:before:from-[var(--shadow-pin)] udc:before:to-transparent udc:before:opacity-0 udc:before:transition-opacity", right.length === 0 && edges.right && "udc:before:opacity-100");
|
|
388
|
+
const actionsHeader = rowActions ? /* @__PURE__ */ jsx("th", {
|
|
389
|
+
scope: "col",
|
|
390
|
+
"data-testid": "th-actions",
|
|
391
|
+
style: { width: actionsWidth },
|
|
392
|
+
className: cn(actionsClass, "udc:z-[15] udc:h-9 udc:bg-muted"),
|
|
393
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
394
|
+
className: "udc:sr-only",
|
|
395
|
+
children: t("APP", "ROW_ACTIONS")
|
|
396
|
+
})
|
|
397
|
+
}, "__actions") : null;
|
|
398
|
+
const actionsCell = (row, className) => rowActions ? /* @__PURE__ */ jsx("td", {
|
|
399
|
+
"data-testid": "cell-actions",
|
|
400
|
+
style: { width: actionsWidth },
|
|
401
|
+
className: cn(actionsClass, "udc:px-1.5", className),
|
|
402
|
+
children: /* @__PURE__ */ jsx(RowActionsControls, {
|
|
403
|
+
row,
|
|
404
|
+
rowActions,
|
|
405
|
+
menu: rowMenu
|
|
406
|
+
})
|
|
407
|
+
}, "__actions") : null;
|
|
408
|
+
const renderRow = (r, index) => {
|
|
409
|
+
const row = r.original;
|
|
410
|
+
const tone = resolveRowColor(row, view.row_color);
|
|
411
|
+
const active = activation.activeRowId === row.__meta.id;
|
|
412
|
+
const checked = selection?.isSelected(row.__meta.id) === true;
|
|
413
|
+
const rowProps = activation.rowProps(row);
|
|
414
|
+
const menuKeys = rowMenuHandlers(rowActions, rowMenu, row, { contextMenu: rowActions?.display === "menu" });
|
|
415
|
+
const cell = (c) => {
|
|
416
|
+
const { config, def } = meta(c);
|
|
417
|
+
const editable = canEdit(c);
|
|
418
|
+
const id = `${row.__meta.id}:${c.id}`;
|
|
419
|
+
const editing = edit?.rowId === row.__meta.id && edit.colId === c.id;
|
|
420
|
+
const color = config.color ?? tone?.color;
|
|
421
|
+
const bg = config.bg ?? tone?.bg;
|
|
422
|
+
return /* @__PURE__ */ jsxs("td", {
|
|
423
|
+
"data-cell": id,
|
|
424
|
+
"data-testid": `cell-${config.field}`,
|
|
425
|
+
"data-editable": editable || void 0,
|
|
426
|
+
tabIndex: editable ? 0 : void 0,
|
|
427
|
+
title: editable && !editing ? t("APP", "EDIT_HINT") : void 0,
|
|
428
|
+
onDoubleClick: editable ? () => startEdit({
|
|
429
|
+
rowId: row.__meta.id,
|
|
430
|
+
colId: c.id
|
|
431
|
+
}) : void 0,
|
|
432
|
+
onKeyDown: editable && !editing ? (e) => {
|
|
433
|
+
if (e.key === "Enter" || e.key === "F2") {
|
|
434
|
+
e.preventDefault();
|
|
435
|
+
startEdit({
|
|
436
|
+
rowId: row.__meta.id,
|
|
437
|
+
colId: c.id
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
} : void 0,
|
|
441
|
+
style: pinStyle(c),
|
|
442
|
+
className: cn("udc-cell", "udc:relative udc:border-b udc:border-border udc:px-3 udc:align-middle udc:outline-none", active || checked ? "udc:bg-selected" : bg && bg !== "default" ? BG_COLOR[bg] : "udc:bg-surface udc:group-hover/row:bg-hover", color ? TEXT_COLOR[color] : "", color === "info" || color === "accent" ? "udc:font-medium" : "", editable && "udc:cursor-text udc:focus-visible:ring-2 udc:focus-visible:ring-ring udc:focus-visible:ring-inset udc:hover:shadow-[inset_0_0_0_1px_var(--border-strong)]", pinClass(c), editing && "udc:z-[25]"),
|
|
443
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
444
|
+
className: cn("udc:flex udc:min-w-0 udc:items-center", alignClass(c)),
|
|
445
|
+
children: props.folder && config.field === props.folder.options.label_field ? /* @__PURE__ */ jsx(FolderEntry, {
|
|
446
|
+
row,
|
|
447
|
+
nav: props.folder,
|
|
448
|
+
children: /* @__PURE__ */ jsx(CellValue, {
|
|
449
|
+
value: row[config.field],
|
|
450
|
+
column: config,
|
|
451
|
+
def,
|
|
452
|
+
locale,
|
|
453
|
+
intlLocale,
|
|
454
|
+
cells,
|
|
455
|
+
row,
|
|
456
|
+
collection
|
|
457
|
+
})
|
|
458
|
+
}) : /* @__PURE__ */ jsx(CellValue, {
|
|
459
|
+
value: row[config.field],
|
|
460
|
+
column: config,
|
|
461
|
+
def,
|
|
462
|
+
locale,
|
|
463
|
+
intlLocale,
|
|
464
|
+
editable,
|
|
465
|
+
cells,
|
|
466
|
+
row,
|
|
467
|
+
collection
|
|
468
|
+
})
|
|
469
|
+
}), editing ? /* @__PURE__ */ jsx(CellEditor, {
|
|
470
|
+
def,
|
|
471
|
+
initial: row[config.field],
|
|
472
|
+
saving,
|
|
473
|
+
error: editError?.message ?? null,
|
|
474
|
+
errorSeq: editError?.seq ?? 0,
|
|
475
|
+
align: config.align,
|
|
476
|
+
onCommit: (raw, reason) => void commit(row, c, raw, reason),
|
|
477
|
+
onCancel: () => {
|
|
478
|
+
setEdit(null);
|
|
479
|
+
setEditError(null);
|
|
480
|
+
focusCell({
|
|
481
|
+
rowId: row.__meta.id,
|
|
482
|
+
colId: c.id
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}) : null]
|
|
486
|
+
}, c.id);
|
|
487
|
+
};
|
|
488
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
489
|
+
"data-testid": "row",
|
|
490
|
+
"data-row-id": row.__meta.id,
|
|
491
|
+
"aria-rowindex": virtual ? index + 1 : void 0,
|
|
492
|
+
"data-row-link": rowLink ? rowLinkHref(row) : void 0,
|
|
493
|
+
"data-selected": checked ? "true" : void 0,
|
|
494
|
+
...rowProps,
|
|
495
|
+
...rowActions ? {
|
|
496
|
+
onKeyDown: (e) => {
|
|
497
|
+
if (!menuKeys.keyDown(e)) rowProps.onKeyDown?.(e);
|
|
498
|
+
},
|
|
499
|
+
onContextMenu: menuKeys.contextMenu
|
|
500
|
+
} : {},
|
|
501
|
+
className: cn("udc-row udc:group/row", (rowLink || activation.enabled) && "udc:cursor-pointer", activation.enabled && "udc:outline-none udc:focus-visible:outline-2 udc:focus-visible:-outline-offset-2 udc:focus-visible:outline-ring"),
|
|
502
|
+
style: { height: rowHeight },
|
|
503
|
+
onClick: rowLink || activation.enabled ? (e) => onRowClick(e, row) : void 0,
|
|
504
|
+
onAuxClick: rowLink ? (e) => onRowLinkClick(e, row) : void 0,
|
|
505
|
+
children: [
|
|
506
|
+
selectCell(row, active || checked ? "udc:bg-selected" : "udc:bg-surface udc:group-hover/row:bg-hover"),
|
|
507
|
+
[...left, ...center].map(cell),
|
|
508
|
+
addColumnCell("a", active || checked ? "udc:bg-selected" : "udc:bg-surface udc:group-hover/row:bg-hover"),
|
|
509
|
+
filler("f", active || checked ? "udc:border-b udc:border-border udc:bg-selected" : "udc:border-b udc:border-border udc:bg-surface udc:group-hover/row:bg-hover"),
|
|
510
|
+
right.map(cell),
|
|
511
|
+
actionsCell(row, active || checked ? "udc:bg-selected" : "udc:bg-surface udc:group-hover/row:bg-hover")
|
|
512
|
+
]
|
|
513
|
+
}, r.id);
|
|
514
|
+
};
|
|
515
|
+
const modelRows = table.getRowModel().rows;
|
|
516
|
+
const columnCount = (selection ? 1 : 0) + left.length + center.length + (schemaEdit ? 1 : 0) + 1 + right.length + (rowActions ? 1 : 0);
|
|
517
|
+
let bodyRows;
|
|
518
|
+
if (!virtual) bodyRows = modelRows.map((r, i) => renderRow(r, i));
|
|
519
|
+
else {
|
|
520
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
521
|
+
modelRows.forEach((r, i) => {
|
|
522
|
+
indexOf.set(r.id, i);
|
|
523
|
+
});
|
|
524
|
+
const pinned = [
|
|
525
|
+
edit?.rowId,
|
|
526
|
+
rowMenu.openId,
|
|
527
|
+
focusedRowId,
|
|
528
|
+
activation.activeRowId,
|
|
529
|
+
activation.tabStopId
|
|
530
|
+
].map((id) => id == null ? -1 : indexOf.get(id) ?? -1).filter((i) => i >= 0);
|
|
531
|
+
bodyRows = bodySlices(modelRows.length, win.range, pinned).flatMap((slice) => slice.kind === "gap" ? /* @__PURE__ */ jsx("tr", {
|
|
532
|
+
"aria-hidden": true,
|
|
533
|
+
"data-testid": "row-spacer",
|
|
534
|
+
style: { height: slice.rows * windowRowHeight },
|
|
535
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
536
|
+
colSpan: columnCount,
|
|
537
|
+
className: "udc:p-0"
|
|
538
|
+
})
|
|
539
|
+
}, `gap-${slice.from}`) : modelRows.slice(slice.from, slice.to).map((r, i) => renderRow(r, slice.from + i)));
|
|
540
|
+
}
|
|
298
541
|
return /* @__PURE__ */ jsxs("div", {
|
|
299
542
|
className: "udc:flex udc:min-h-0 udc:flex-1 udc:flex-col",
|
|
300
543
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
301
544
|
ref: scrollRef,
|
|
302
|
-
onScroll:
|
|
545
|
+
onScroll: () => {
|
|
546
|
+
measureEdges();
|
|
547
|
+
win.onScroll();
|
|
548
|
+
},
|
|
303
549
|
"data-testid": "table-scroll",
|
|
304
550
|
className: "udc-scroll-thin udc:relative udc:min-h-0 udc:flex-1 udc:overflow-auto",
|
|
305
551
|
children: [
|
|
@@ -313,7 +559,9 @@ function TableRenderer(props) {
|
|
|
313
559
|
/* @__PURE__ */ jsxs("table", {
|
|
314
560
|
"data-testid": "udc-table",
|
|
315
561
|
"aria-busy": data.isFetching,
|
|
316
|
-
"aria-rowcount": total,
|
|
562
|
+
"aria-rowcount": virtual ? data.rows.length : total,
|
|
563
|
+
role: activation.enabled ? "grid" : void 0,
|
|
564
|
+
"aria-multiselectable": activation.enabled && selection ? true : void 0,
|
|
317
565
|
className: "udc-table udc:border-separate udc:border-spacing-0 udc:text-[13px]",
|
|
318
566
|
style: {
|
|
319
567
|
width: totalWidth,
|
|
@@ -322,131 +570,74 @@ function TableRenderer(props) {
|
|
|
322
570
|
},
|
|
323
571
|
children: [
|
|
324
572
|
/* @__PURE__ */ jsxs("colgroup", { children: [
|
|
573
|
+
selection ? /* @__PURE__ */ jsx("col", { style: { width: SELECT_COLUMN_WIDTH } }) : null,
|
|
325
574
|
[...left, ...center].map((c) => /* @__PURE__ */ jsx("col", { style: { width: c.getSize() } }, c.id)),
|
|
326
575
|
schemaEdit ? /* @__PURE__ */ jsx("col", { style: { width: ADD_COLUMN_WIDTH } }) : null,
|
|
327
576
|
/* @__PURE__ */ jsx("col", {}),
|
|
328
|
-
right.map((c) => /* @__PURE__ */ jsx("col", { style: { width: c.getSize() } }, c.id))
|
|
577
|
+
right.map((c) => /* @__PURE__ */ jsx("col", { style: { width: c.getSize() } }, c.id)),
|
|
578
|
+
rowActions ? /* @__PURE__ */ jsx("col", { style: { width: actionsWidth } }) : null
|
|
329
579
|
] }),
|
|
330
580
|
/* @__PURE__ */ jsx("thead", {
|
|
581
|
+
ref: headerRef,
|
|
331
582
|
className: "udc:sticky udc:top-0 udc:z-30",
|
|
332
583
|
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
584
|
+
selectHeader,
|
|
333
585
|
[...left, ...center].map(header),
|
|
334
586
|
addColumnHeader,
|
|
335
587
|
/* @__PURE__ */ jsx("th", {
|
|
336
588
|
"aria-hidden": true,
|
|
337
589
|
className: "udc:border-b udc:border-border udc:bg-muted udc:p-0"
|
|
338
590
|
}),
|
|
339
|
-
right.map(header)
|
|
591
|
+
right.map(header),
|
|
592
|
+
actionsHeader
|
|
340
593
|
] })
|
|
341
594
|
}),
|
|
342
595
|
/* @__PURE__ */ jsx(UdcLookupBatch, {
|
|
343
596
|
value: lookups,
|
|
344
|
-
children: /* @__PURE__ */ jsxs("tbody", {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
right.map((c) => /* @__PURE__ */ jsx("td", {
|
|
359
|
-
style: pinStyle(c),
|
|
360
|
-
className: cn("udc:border-b udc:border-border udc:bg-surface udc:px-3", pinClass(c)),
|
|
361
|
-
children: /* @__PURE__ */ jsx(Skeleton, { className: "udc:h-3 udc:w-2/3" })
|
|
362
|
-
}, c.id))
|
|
363
|
-
]
|
|
364
|
-
}, i)) : null, table.getRowModel().rows.map((r) => {
|
|
365
|
-
const row = r.original;
|
|
366
|
-
const tone = resolveRowColor(row, view.row_color);
|
|
367
|
-
const cell = (c) => {
|
|
368
|
-
const { config, def } = meta(c);
|
|
369
|
-
const editable = canEdit(c);
|
|
370
|
-
const id = `${row.__meta.id}:${c.id}`;
|
|
371
|
-
const editing = edit?.rowId === row.__meta.id && edit.colId === c.id;
|
|
372
|
-
const color = config.color ?? tone?.color;
|
|
373
|
-
const bg = config.bg ?? tone?.bg;
|
|
374
|
-
return /* @__PURE__ */ jsxs("td", {
|
|
375
|
-
"data-cell": id,
|
|
376
|
-
"data-testid": `cell-${config.field}`,
|
|
377
|
-
"data-editable": editable || void 0,
|
|
378
|
-
tabIndex: editable ? 0 : void 0,
|
|
379
|
-
title: editable && !editing ? t("APP", "EDIT_HINT") : void 0,
|
|
380
|
-
onDoubleClick: editable ? () => startEdit({
|
|
381
|
-
rowId: row.__meta.id,
|
|
382
|
-
colId: c.id
|
|
383
|
-
}) : void 0,
|
|
384
|
-
onKeyDown: editable && !editing ? (e) => {
|
|
385
|
-
if (e.key === "Enter" || e.key === "F2") {
|
|
386
|
-
e.preventDefault();
|
|
387
|
-
startEdit({
|
|
388
|
-
rowId: row.__meta.id,
|
|
389
|
-
colId: c.id
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
} : void 0,
|
|
393
|
-
style: pinStyle(c),
|
|
394
|
-
className: cn("udc-cell", "udc:relative udc:border-b udc:border-border udc:px-3 udc:align-middle udc:outline-none", bg && bg !== "default" ? BG_COLOR[bg] : "udc:bg-surface udc:group-hover/row:bg-hover", color ? TEXT_COLOR[color] : "", color === "info" || color === "accent" ? "udc:font-medium" : "", editable && "udc:cursor-text udc:focus-visible:ring-2 udc:focus-visible:ring-ring udc:focus-visible:ring-inset udc:hover:shadow-[inset_0_0_0_1px_var(--border-strong)]", pinClass(c), editing && "udc:z-[25]"),
|
|
395
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
396
|
-
className: cn("udc:flex udc:min-w-0 udc:items-center", alignClass(c)),
|
|
397
|
-
children: props.folder && config.field === props.folder.options.label_field ? /* @__PURE__ */ jsx(FolderEntry, {
|
|
398
|
-
row,
|
|
399
|
-
nav: props.folder,
|
|
400
|
-
children: /* @__PURE__ */ jsx(CellValue, {
|
|
401
|
-
value: row[config.field],
|
|
402
|
-
column: config,
|
|
403
|
-
def,
|
|
404
|
-
locale,
|
|
405
|
-
intlLocale
|
|
406
|
-
})
|
|
407
|
-
}) : /* @__PURE__ */ jsx(CellValue, {
|
|
408
|
-
value: row[config.field],
|
|
409
|
-
column: config,
|
|
410
|
-
def,
|
|
411
|
-
locale,
|
|
412
|
-
intlLocale,
|
|
413
|
-
editable
|
|
414
|
-
})
|
|
415
|
-
}), editing ? /* @__PURE__ */ jsx(CellEditor, {
|
|
416
|
-
def,
|
|
417
|
-
initial: row[config.field],
|
|
418
|
-
saving,
|
|
419
|
-
error: editError?.message ?? null,
|
|
420
|
-
errorSeq: editError?.seq ?? 0,
|
|
421
|
-
align: config.align,
|
|
422
|
-
onCommit: (raw, reason) => void commit(row, c, raw, reason),
|
|
423
|
-
onCancel: () => {
|
|
424
|
-
setEdit(null);
|
|
425
|
-
setEditError(null);
|
|
426
|
-
focusCell({
|
|
427
|
-
rowId: row.__meta.id,
|
|
428
|
-
colId: c.id
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
}) : null]
|
|
432
|
-
}, c.id);
|
|
433
|
-
};
|
|
434
|
-
return /* @__PURE__ */ jsxs("tr", {
|
|
435
|
-
"data-testid": "row",
|
|
436
|
-
"data-row-id": row.__meta.id,
|
|
437
|
-
"data-row-link": rowLink ? rowLinkHref(row) : void 0,
|
|
438
|
-
className: cn("udc-row udc:group/row", rowLink && "udc:cursor-pointer"),
|
|
597
|
+
children: /* @__PURE__ */ jsxs("tbody", {
|
|
598
|
+
ref: bodyRef,
|
|
599
|
+
...virtual ? {
|
|
600
|
+
onFocus: (e) => {
|
|
601
|
+
const tr = e.target.closest?.("tr[data-row-id]");
|
|
602
|
+
setFocusedRowId(tr?.getAttribute("data-row-id") ?? null);
|
|
603
|
+
},
|
|
604
|
+
onBlur: (e) => {
|
|
605
|
+
const next = e.relatedTarget;
|
|
606
|
+
if (!next || !e.currentTarget.contains(next)) setFocusedRowId(null);
|
|
607
|
+
}
|
|
608
|
+
} : {},
|
|
609
|
+
children: [showSkeleton ? Array.from({ length: SKELETON_ROWS }, (_, i) => /* @__PURE__ */ jsxs("tr", {
|
|
610
|
+
"data-testid": "skeleton-row",
|
|
439
611
|
style: { height: rowHeight },
|
|
440
|
-
onClick: rowLink ? (e) => onRowLinkClick(e, row) : void 0,
|
|
441
|
-
onAuxClick: rowLink ? (e) => onRowLinkClick(e, row) : void 0,
|
|
442
612
|
children: [
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
613
|
+
selection ? /* @__PURE__ */ jsx("td", {
|
|
614
|
+
"aria-hidden": true,
|
|
615
|
+
style: { width: SELECT_COLUMN_WIDTH },
|
|
616
|
+
className: cn(selectClass, "udc:bg-surface")
|
|
617
|
+
}) : null,
|
|
618
|
+
[...left, ...center].map((c, j) => /* @__PURE__ */ jsx("td", {
|
|
619
|
+
style: pinStyle(c),
|
|
620
|
+
className: cn("udc:border-b udc:border-border udc:bg-surface udc:px-3", pinClass(c)),
|
|
621
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
622
|
+
className: "udc:h-3",
|
|
623
|
+
style: { width: `${45 + (i * 7 + j * 13) % 45}%` }
|
|
624
|
+
})
|
|
625
|
+
}, c.id)),
|
|
626
|
+
addColumnCell("a", "udc:bg-surface"),
|
|
627
|
+
filler("f", "udc:border-b udc:border-border udc:bg-surface"),
|
|
628
|
+
right.map((c) => /* @__PURE__ */ jsx("td", {
|
|
629
|
+
style: pinStyle(c),
|
|
630
|
+
className: cn("udc:border-b udc:border-border udc:bg-surface udc:px-3", pinClass(c)),
|
|
631
|
+
children: /* @__PURE__ */ jsx(Skeleton, { className: "udc:h-3 udc:w-2/3" })
|
|
632
|
+
}, c.id)),
|
|
633
|
+
rowActions ? /* @__PURE__ */ jsx("td", {
|
|
634
|
+
"aria-hidden": true,
|
|
635
|
+
style: { width: actionsWidth },
|
|
636
|
+
className: cn(actionsClass, "udc:bg-surface")
|
|
637
|
+
}) : null
|
|
447
638
|
]
|
|
448
|
-
},
|
|
449
|
-
})
|
|
639
|
+
}, i)) : null, bodyRows]
|
|
640
|
+
})
|
|
450
641
|
})
|
|
451
642
|
]
|
|
452
643
|
}),
|