@viewkitjs/views 0.3.0 → 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/CHANGELOG.md +641 -0
- package/README.md +3 -3
- package/dist/atoms/CommandMenu.d.ts +1 -1
- package/dist/atoms/CommandMenu.js +7 -3
- package/dist/atoms/DrillRows.d.ts +3 -0
- package/dist/atoms/DrillRows.js +25 -0
- package/dist/atoms/PanelRows.d.ts +5 -0
- package/dist/atoms/PanelRows.js +40 -0
- package/dist/atoms/PanelSearch.d.ts +2 -0
- package/dist/atoms/PanelSearch.js +21 -0
- package/dist/atoms/RelationRoles.d.ts +2 -0
- package/dist/atoms/RelationRoles.js +6 -0
- package/dist/atoms/Row.js +2 -1
- package/dist/atoms/RowMenu.js +2 -1
- package/dist/atoms/SelectionSheet.d.ts +3 -0
- package/dist/atoms/SelectionSheet.js +30 -0
- package/dist/atoms/StatusMarker.js +3 -1
- package/dist/atoms/Tag.js +2 -1
- package/dist/atoms/defaults.js +14 -0
- package/dist/atoms/types.d.ts +146 -8
- package/dist/cells/cell-values.js +4 -2
- package/dist/cells/relation-wrap.js +3 -1
- package/dist/contract.d.ts +212 -17
- package/dist/contract.js +208 -6
- package/dist/display/boolean.js +3 -1
- package/dist/display/date.d.ts +1 -1
- package/dist/display/date.js +4 -2
- package/dist/display/format.js +20 -4
- package/dist/display/link.js +4 -3
- package/dist/display/multi-value.js +2 -1
- package/dist/display/percent.js +2 -1
- package/dist/display/phone.js +2 -1
- package/dist/display/range.js +3 -13
- package/dist/display/relation.js +23 -8
- package/dist/display/rich-text.js +2 -1
- package/dist/editors/ChipsEditor.d.ts +5 -1
- package/dist/editors/ChipsEditor.js +15 -2
- package/dist/editors/DateEditor.d.ts +2 -0
- package/dist/editors/DateEditor.js +76 -10
- package/dist/editors/EditorPanel.d.ts +14 -4
- package/dist/editors/EditorPanel.js +21 -4
- package/dist/editors/LocationEditor.js +35 -3
- package/dist/editors/NumberEditor.js +3 -2
- package/dist/editors/RangeEditor.d.ts +8 -0
- package/dist/editors/RangeEditor.js +3 -2
- package/dist/editors/RelationEditor.d.ts +2 -0
- package/dist/editors/RelationEditor.js +16 -2
- package/dist/editors/RelationSetEditor.d.ts +4 -2
- package/dist/editors/RelationSetEditor.js +36 -2
- package/dist/editors/SelectEditor.d.ts +5 -2
- package/dist/editors/SelectEditor.js +31 -4
- package/dist/editors/TextEditor.js +3 -1
- package/dist/editors/ValueListEditor.d.ts +3 -0
- package/dist/editors/ValueListEditor.js +10 -4
- package/dist/editors/edit-session.d.ts +14 -2
- package/dist/editors/edit-session.js +13 -5
- package/dist/editors/escape-rule.d.ts +12 -0
- package/dist/editors/escape-rule.js +8 -0
- package/dist/editors/open-value.js +2 -1
- package/dist/editors/picker-slot.d.ts +25 -0
- package/dist/editors/picker-slot.js +37 -0
- package/dist/editors/relation-picker.d.ts +44 -0
- package/dist/editors/relation-picker.js +49 -0
- package/dist/editors/relation-source.d.ts +1 -0
- package/dist/editors/relation-source.js +7 -1
- package/dist/field-row/FieldNoteLine.js +2 -1
- package/dist/field-row/FieldRow.js +41 -6
- package/dist/field-row/FieldRowLane.js +3 -1
- package/dist/field-row/editors/RowChipsEditor.js +1 -1
- package/dist/field-row/editors/RowDateEditor.js +1 -1
- package/dist/field-row/editors/RowEditor.js +2 -1
- package/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/dist/field-row/editors/RowRelationEditor.js +2 -2
- package/dist/field-row/editors/RowSelectEditor.d.ts +1 -1
- package/dist/field-row/editors/RowSelectEditor.js +2 -2
- package/dist/field-row/editors/RowValueListEditor.js +1 -1
- package/dist/field-row/editors/host.d.ts +3 -0
- package/dist/field-row/editors/row-session.js +4 -1
- package/dist/fields/menus.d.ts +2 -0
- package/dist/fields/range-unit.d.ts +7 -0
- package/dist/fields/range-unit.js +13 -0
- package/dist/figures.d.ts +5 -48
- package/dist/figures.js +1 -63
- package/dist/grid/chrome/GridAddColumn.d.ts +8 -0
- package/dist/grid/chrome/GridAddColumn.js +66 -9
- package/dist/grid/chrome/GridAggregateMenu.d.ts +5 -2
- package/dist/grid/chrome/GridAggregateMenu.js +33 -4
- package/dist/grid/chrome/GridCellEditors.d.ts +9 -2
- package/dist/grid/chrome/GridCellEditors.js +24 -5
- package/dist/grid/chrome/GridCellOutline.d.ts +3 -2
- package/dist/grid/chrome/GridCellOutline.js +11 -1
- package/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/dist/grid/chrome/GridColumnColorSection.d.ts +2 -0
- package/dist/grid/chrome/GridColumnColorSection.js +2 -2
- package/dist/grid/chrome/GridColumnDateSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnDateSection.js +2 -2
- package/dist/grid/chrome/GridColumnDurationSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnDurationSection.js +2 -2
- package/dist/grid/chrome/GridColumnMenu.d.ts +10 -6
- package/dist/grid/chrome/GridColumnMenu.js +62 -24
- package/dist/grid/chrome/GridColumnNumberSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnNumberSection.js +2 -2
- package/dist/grid/chrome/GridColumnPercentSection.d.ts +1 -0
- package/dist/grid/chrome/GridColumnPercentSection.js +1 -1
- package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
- package/dist/grid/chrome/GridDateEditor.js +1 -1
- package/dist/grid/chrome/GridFooter.js +7 -48
- package/dist/grid/chrome/GridGroupMenu.d.ts +11 -5
- package/dist/grid/chrome/GridGroupMenu.js +28 -13
- package/dist/grid/chrome/GridHeader.d.ts +3 -1
- package/dist/grid/chrome/GridHeader.js +8 -8
- package/dist/grid/chrome/GridNumberEditor.js +3 -24
- package/dist/grid/chrome/GridRangeEditor.js +3 -2
- package/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/dist/grid/chrome/GridRow.d.ts +2 -1
- package/dist/grid/chrome/GridRow.js +13 -37
- package/dist/grid/chrome/GridRowActions.js +2 -1
- package/dist/grid/chrome/GridRowCells.js +9 -4
- package/dist/grid/chrome/GridSelectEditor.js +30 -20
- package/dist/grid/chrome/GridStructure.d.ts +11 -4
- package/dist/grid/chrome/GridStructure.js +19 -7
- package/dist/grid/chrome/GridTable.js +138 -16
- package/dist/grid/chrome/GridTableSurface.d.ts +25 -12
- package/dist/grid/chrome/GridTableSurface.js +13 -6
- package/dist/grid/chrome/GridTextEditor.js +3 -1
- package/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/dist/grid/chrome/cell-clipboard.d.ts +1 -1
- package/dist/grid/chrome/cell-clipboard.js +1 -1
- package/dist/grid/chrome/checks.d.ts +10 -2
- package/dist/grid/chrome/checks.js +17 -11
- package/dist/grid/chrome/column-glyph.d.ts +2 -2
- package/dist/grid/chrome/column-glyph.js +4 -0
- package/dist/grid/chrome/grid-add-column-items.d.ts +13 -0
- package/dist/grid/chrome/grid-add-column-items.js +40 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +2 -0
- package/dist/grid/chrome/grid-cell-classes.js +10 -4
- package/dist/grid/chrome/grid-column-menu-items.d.ts +75 -0
- package/dist/grid/chrome/grid-column-menu-items.js +263 -0
- package/dist/grid/chrome/grid-edit-escape.d.ts +4 -0
- package/dist/grid/chrome/grid-edit-escape.js +12 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +2 -1
- package/dist/grid/chrome/grid-edit-session.js +14 -1
- package/dist/grid/chrome/grid-figure-value.d.ts +25 -0
- package/dist/grid/chrome/grid-figure-value.js +40 -0
- package/dist/grid/chrome/grid-fitted-box.d.ts +15 -0
- package/dist/grid/chrome/grid-fitted-box.js +26 -0
- package/dist/grid/chrome/grid-group-menu-items.d.ts +31 -0
- package/dist/grid/chrome/grid-group-menu-items.js +75 -0
- package/dist/grid/chrome/grid-group-menu-parts.d.ts +27 -0
- package/dist/grid/chrome/grid-group-menu-parts.js +19 -0
- package/dist/grid/chrome/grid-hover.d.ts +1 -0
- package/dist/grid/chrome/grid-hover.js +13 -1
- package/dist/grid/chrome/grid-lab.d.ts +7 -0
- package/dist/grid/chrome/grid-lab.js +7 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +12 -0
- package/dist/grid/chrome/grid-menu-focus.js +13 -0
- package/dist/grid/chrome/{useGridRowContextMenu.d.ts → grid-row-menu-items.d.ts} +15 -4
- package/dist/grid/chrome/{useGridRowContextMenu.js → grid-row-menu-items.js} +15 -18
- package/dist/grid/chrome/grid-row-props.d.ts +3 -1
- package/dist/grid/chrome/grid-row-window.d.ts +15 -5
- package/dist/grid/chrome/grid-row-window.js +44 -10
- package/dist/grid/chrome/grid-rows-menu.d.ts +38 -0
- package/dist/grid/chrome/grid-rows-menu.js +83 -0
- package/dist/grid/chrome/grid-table-props.d.ts +53 -8
- package/dist/grid/chrome/useGridBandFigures.d.ts +26 -0
- package/dist/grid/chrome/useGridBandFigures.js +50 -0
- package/dist/grid/chrome/useGridBoxes.d.ts +22 -0
- package/dist/grid/chrome/useGridBoxes.js +22 -0
- package/dist/grid/chrome/useGridColumnLayout.js +29 -4
- package/dist/grid/chrome/useGridKeyboard.js +7 -2
- package/dist/grid/chrome/useGridPartColumns.d.ts +5 -0
- package/dist/grid/chrome/useGridPartColumns.js +9 -0
- package/dist/grid/chrome/useGridRangeGestures.js +2 -1
- package/dist/grid/chrome/useGridRecorder.d.ts +16 -0
- package/dist/grid/chrome/useGridRecorder.js +144 -0
- package/dist/grid/chrome/useGridRowOpener.d.ts +41 -0
- package/dist/grid/chrome/useGridRowOpener.js +83 -0
- package/dist/grid/chrome/useGridScrollArea.d.ts +38 -12
- package/dist/grid/chrome/useGridScrollArea.js +70 -17
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +67 -9
- package/dist/grid/core/clipboard-model.d.ts +11 -3
- package/dist/grid/core/clipboard-model.js +9 -4
- package/dist/grid/core/commit-model.d.ts +7 -0
- package/dist/grid/core/editing-controller.d.ts +31 -1
- package/dist/grid/core/editing-controller.js +65 -0
- package/dist/grid/core/grid-recorder.d.ts +111 -0
- package/dist/grid/core/grid-recorder.js +223 -0
- package/dist/grid/core/part-edits.d.ts +18 -0
- package/dist/grid/core/part-edits.js +48 -0
- package/dist/grid/core/pending-reconciliation.js +12 -3
- package/dist/grid/core/refusal-sentence.d.ts +3 -0
- package/dist/grid/core/refusal-sentence.js +15 -0
- package/dist/grid/core/row-opened-from.d.ts +21 -0
- package/dist/grid/core/row-opened-from.js +11 -0
- package/dist/grid/core/useGridEditing.d.ts +16 -2
- package/dist/grid/core/useGridEditing.js +10 -4
- package/dist/grid/core/value-equality.d.ts +19 -1
- package/dist/grid/core/value-equality.js +24 -0
- package/dist/grid/index.d.ts +4 -1
- package/dist/grid/index.js +1 -0
- package/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/dist/grid-lab.d.ts +18 -0
- package/dist/grid-lab.js +16 -0
- package/dist/grouping/sort-groups.d.ts +6 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/reset.d.ts +9 -0
- package/dist/internal/reset.js +1 -0
- package/dist/model/aggregates.d.ts +3 -3
- package/dist/model/aggregates.js +17 -71
- package/dist/model/column-capabilities.d.ts +29 -2
- package/dist/model/column-capabilities.js +27 -3
- package/dist/model/column-filters.js +24 -4
- package/dist/model/column-inspect.d.ts +2 -1
- package/dist/model/column-order.d.ts +2 -2
- package/dist/model/column-schema.d.ts +18 -7
- package/dist/model/column-state.d.ts +9 -20
- package/dist/model/column-state.js +1 -4
- package/dist/model/column-types.d.ts +1 -15
- package/dist/model/column-types.js +1 -1
- package/dist/model/part-columns.d.ts +17 -0
- package/dist/model/part-columns.js +67 -0
- package/dist/model/part-rows.d.ts +3 -10
- package/dist/model/part-rows.js +6 -11
- package/dist/model/part-write.d.ts +11 -0
- package/dist/model/part-write.js +52 -0
- package/dist/model/preferences.d.ts +3 -23
- package/dist/model/preferences.js +1 -17
- package/dist/model/prefs-buckets.d.ts +0 -27
- package/dist/model/prefs-buckets.js +1 -1
- package/dist/model/relation-filters.d.ts +0 -1
- package/dist/model/relation-filters.js +1 -1
- package/dist/model/row-icon.d.ts +5 -9
- package/dist/model/view-rules.d.ts +32 -6
- package/dist/model/view-rules.js +101 -21
- package/dist/provider/ViewsProvider.d.ts +22 -2
- package/dist/provider/ViewsProvider.js +21 -2
- package/dist/provider/components.d.ts +197 -9
- package/dist/provider/context.d.ts +12 -1
- package/dist/provider/desktop.d.ts +3 -0
- package/dist/provider/desktop.js +7 -4
- package/dist/provider/menu-groups.d.ts +3 -2
- package/dist/provider/menu-groups.js +13 -7
- package/dist/provider/missing-slot.d.ts +10 -0
- package/dist/provider/missing-slot.js +15 -0
- package/dist/provider/plain-input.d.ts +3 -2
- package/dist/provider/plain-input.js +3 -1
- package/dist/react.d.ts +3 -2
- package/dist/selection/SelectionBar.d.ts +18 -0
- package/dist/selection/SelectionBar.js +92 -0
- package/dist/selection/SelectionBarPhone.d.ts +3 -0
- package/dist/selection/SelectionBarPhone.js +14 -0
- package/dist/selection/bar-overflow.d.ts +12 -0
- package/dist/selection/bar-overflow.js +42 -0
- package/dist/selection/bar-parts.d.ts +15 -0
- package/dist/selection/bar-parts.js +17 -0
- package/dist/selection/index.d.ts +2 -0
- package/dist/selection/index.js +1 -0
- package/dist/selection/types.d.ts +3 -2
- package/dist/selection/verbs.d.ts +34 -0
- package/dist/selection/verbs.js +1 -0
- package/docs/contract.md +142 -39
- package/docs/getting-started.md +1 -1
- package/docs/guides/atoms.md +32 -4
- package/docs/guides/columns.md +1 -1
- package/docs/guides/display.md +1 -1
- package/docs/guides/editors.md +3 -3
- package/docs/guides/ports.md +1 -1
- package/docs/guides/selection.md +32 -20
- package/docs/guides/the-grid.md +43 -21
- package/docs/guides/the-provider.md +14 -4
- package/docs/index.md +2 -0
- package/docs/install.md +8 -1
- package/docs/reference/editors-date.md +2 -0
- package/docs/reference/editors-panel.md +4 -4
- package/docs/reference/editors-range.md +1 -1
- package/docs/reference/editors-relation.md +3 -3
- package/docs/reference/editors-select.md +1 -1
- package/docs/reference/editors-session.md +3 -2
- package/docs/reference/editors-value-list.md +1 -1
- package/docs/reference/field-row.md +2 -2
- package/docs/reference/grid.md +25 -6
- package/docs/reference/react.md +30 -8
- package/docs/reference/selection.md +10 -2
- package/docs/reference/views.md +42 -36
- package/package.json +22 -3
- package/skills/views/SKILL.md +3 -3
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useDeferredValue, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { createGridHoverStore, GridHoverContext } from "./grid-hover.js";
|
|
4
|
+
import { createGridHoverStore, GridHoverContext, useAnyHover } from "./grid-hover.js";
|
|
5
5
|
import { useViews } from "../../provider/context.js";
|
|
6
6
|
import { GridRailProbe, useGridRailReveal } from "./useGridRailReveal.js";
|
|
7
7
|
import { useGridBatchApi } from "./useGridBatchApi.js";
|
|
8
8
|
import { gridRowKey } from "../core/coordinates.js";
|
|
9
9
|
import { useDesktop } from "../../provider/desktop.js";
|
|
10
10
|
import { GridRow } from "./GridRow.js";
|
|
11
|
+
import { GridRowsMenu } from "./grid-rows-menu.js";
|
|
11
12
|
import { GridHeadCheck } from "./checks.js";
|
|
12
13
|
import { useGridColumnLayout } from "./useGridColumnLayout.js";
|
|
13
14
|
import { useGridScrollArea } from "./useGridScrollArea.js";
|
|
15
|
+
import { useGridBoxes } from "./useGridBoxes.js";
|
|
14
16
|
import { GridHeader } from "./GridHeader.js";
|
|
17
|
+
import { gridAddColumnDrawn } from "./GridAddColumn.js";
|
|
18
|
+
import { useGridPartColumns } from "./useGridPartColumns.js";
|
|
15
19
|
import { GridFooter, gridFooterShown } from "./GridFooter.js";
|
|
20
|
+
import { useGridBandFigures } from "./useGridBandFigures.js";
|
|
21
|
+
import { groupMenuParts } from "./grid-group-menu-parts.js";
|
|
16
22
|
import { gridAriaLayout } from "../core/grid-aria.js";
|
|
17
23
|
import { GridBody } from "./GridStructure.js";
|
|
18
24
|
import { useGridScaleStyles } from "./useGridScaleStyles.js";
|
|
19
25
|
import { useGridTableInteractionModel } from "./useGridTableInteractionModel.js";
|
|
26
|
+
import { useGridRowOpener } from "./useGridRowOpener.js";
|
|
20
27
|
import { useGridTableSelection } from "./useGridTableSelection.js";
|
|
21
28
|
import { useGridHeaderDrag } from "./useGridHeaderDrag.js";
|
|
22
29
|
import { GridTableSurface } from "./GridTableSurface.js";
|
|
23
30
|
import { gridFlatRows } from "../core/flat-rows.js";
|
|
24
31
|
import { GridRowWindowContext, useGridRowWindow } from "./grid-row-window.js";
|
|
32
|
+
import { useGridLab } from "./grid-lab.js";
|
|
33
|
+
import { useGridRecorder } from "./useGridRecorder.js";
|
|
25
34
|
import { GRID_ROW_PX } from "./useGridScaleStyles.js";
|
|
26
35
|
export function GridTable(props) {
|
|
27
36
|
const { atoms, messages } = useViews();
|
|
@@ -34,23 +43,27 @@ export function GridTable(props) {
|
|
|
34
43
|
}
|
|
35
44
|
function GridTableContent(props) {
|
|
36
45
|
const { groups, grouped, getRowId, columns, isCollapsed, onToggleGroup, renderGroupLabel, onHideGroup, renderAggregate, countOf, onOpenRow, onPrefetchRow, rowHref, rowClassName, onRowDelete, rowActions, rowIcon, showRowIcon = true, freezeIdentity = true, selection, loadMore, emptyState, sort, groupBy, sortOptions, groupSummary, aggregates, onAggregateChange, onGroupSummaryChange, groupFigures, countNoun, optionColors, onOptionColorChange, dateStyles, onDateStyleChange, durationStyles, onDurationStyleChange, numberFormats, onNumberFormatChange, showTimeOverrides, onShowTimeChange, percentDisplays, onPercentDisplayChange, columnState, onColumnStateChange, listConfig, } = props;
|
|
37
|
-
const { atoms, messages } = useViews();
|
|
46
|
+
const { atoms, messages, desktopQuery } = useViews();
|
|
38
47
|
const { LoadMore } = atoms;
|
|
39
48
|
const verticalBorders = props.verticalBorders ?? true;
|
|
40
49
|
const scale = props.scale ?? 1;
|
|
41
50
|
const phone = !useDesktop();
|
|
42
51
|
const rootRef = useRef(null);
|
|
43
|
-
const
|
|
52
|
+
const laidOut = useGridPartColumns(columns, props.parts);
|
|
53
|
+
const [madeHoverStore] = useState(createGridHoverStore);
|
|
54
|
+
const hoverStore = useAnyHover() ? madeHoverStore : null;
|
|
44
55
|
const { visibleColumns, widthVarsStyle, frozenCount, frozenLeft, columnManager, gridTemplate, minWidth, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, } = useGridColumnLayout({
|
|
45
56
|
rootRef,
|
|
46
|
-
columns,
|
|
57
|
+
columns: laidOut,
|
|
47
58
|
columnState,
|
|
48
59
|
onColumnStateChange,
|
|
49
60
|
scale,
|
|
50
61
|
freezeIdentity,
|
|
51
62
|
viewBacked: props.viewBacked,
|
|
52
63
|
});
|
|
53
|
-
const showAddColumn = !!columnManager &&
|
|
64
|
+
const showAddColumn = !!columnManager &&
|
|
65
|
+
(!phone || !!props.addColumnOnPhone) &&
|
|
66
|
+
gridAddColumnDrawn(props.renderAddColumn, columnManager);
|
|
54
67
|
const scaleVarsStyle = useGridScaleStyles(scale, grouped, phone, showAddColumn);
|
|
55
68
|
const flatRows = useMemo(() => groups.flatMap((g) => g.items), [groups]);
|
|
56
69
|
const shutKey = JSON.stringify(grouped ? groups.filter((g) => isCollapsed?.(g.key)).map((g) => g.key) : []);
|
|
@@ -70,7 +83,16 @@ function GridTableContent(props) {
|
|
|
70
83
|
return byKey;
|
|
71
84
|
}, [flat, getRowId]);
|
|
72
85
|
const visibleRowKeys = flat.visible;
|
|
73
|
-
const
|
|
86
|
+
const total = useMemo(() => groups.reduce((n, g) => n + g.items.length, 0), [groups]);
|
|
87
|
+
const lab = useGridLab();
|
|
88
|
+
const boxes = useGridBoxes();
|
|
89
|
+
const recorderRef = useGridRecorder({
|
|
90
|
+
rootRef,
|
|
91
|
+
lab,
|
|
92
|
+
boxes,
|
|
93
|
+
grid: () => ({ rows: total, groups: flat.sections.length, rowHeight: GRID_ROW_PX * scale, boxes }),
|
|
94
|
+
});
|
|
95
|
+
const rowWindow = useGridRowWindow({ rootRef, flat, rowHeight: GRID_ROW_PX * scale, recorderRef, boxes });
|
|
74
96
|
const { selectable, selecting, selectionState: sel, checkDrag, groupSelection, } = useGridTableSelection({
|
|
75
97
|
rootRef,
|
|
76
98
|
groups,
|
|
@@ -89,7 +111,21 @@ function GridTableContent(props) {
|
|
|
89
111
|
const hostCells = visibleColumns.map((column) => renderAggregate?.(column.id, group) ?? null);
|
|
90
112
|
return gridFooterShown({ interactive: !!onAggregateChange, hostCells });
|
|
91
113
|
};
|
|
92
|
-
const
|
|
114
|
+
const bandFigures = useGridBandFigures(groupFigures, {
|
|
115
|
+
columns,
|
|
116
|
+
numberFormats,
|
|
117
|
+
defaultCurrency: props.defaultCurrency,
|
|
118
|
+
renderAggregate,
|
|
119
|
+
});
|
|
120
|
+
const barMenu = grouped &&
|
|
121
|
+
groupMenuParts({
|
|
122
|
+
groupMenu: props.groupMenu,
|
|
123
|
+
hasSort: !!sort,
|
|
124
|
+
sortCount: sortOptions?.length ?? 0,
|
|
125
|
+
figureCount: bandFigures.length,
|
|
126
|
+
canToggleFigures: !!onGroupSummaryChange,
|
|
127
|
+
canHide: !!onHideGroup,
|
|
128
|
+
}).open;
|
|
93
129
|
const footerKey = flat.sections.map((s) => (!s.collapsed && footerShown(s.groupKey) ? "1" : "0")).join("");
|
|
94
130
|
const focusShape = useMemo(() => ({
|
|
95
131
|
grouped,
|
|
@@ -120,7 +156,7 @@ function GridTableContent(props) {
|
|
|
120
156
|
}), [flat, footerKey, grouped, selectable, visibleColIds, more]);
|
|
121
157
|
const ariaTailIndex = aria.colCount + 1;
|
|
122
158
|
const ariaColOffset = selectable ? 1 : 0;
|
|
123
|
-
const { rowSpansMap, selectValuesByColumn, onRangeCopy, onRangeCut, onRangeClear, onRangePaste, onPasteAtCell, inActiveRange, rangeCanClear, editingEnabled, focusedCell, editingCell, pendingByRow, settlementByRow, editSeed, editWhole, focusCellSync, startEditSync, cancelEdit, commitEdit, commitBatch, refuseEdit, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, onEditorTab, onEditorEnter, enterGrid, focus, } = useGridTableInteractionModel({
|
|
159
|
+
const { rowSpansMap, selectValuesByColumn, onRangeCopy, onRangeCut, onRangeClear, onRangePaste, onPasteAtCell, inActiveRange, rangeCanClear, editingEnabled, focusedCell, editingCell, pendingByRow, settlementByRow, editSeed, editWhole, focusCellSync, startEditSync, cancelEdit, commitEdit, commitBatch, refuseEdit, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, onEditorTab, onEditorEnter, enterGrid, revealCell, focus, } = useGridTableInteractionModel({
|
|
124
160
|
rootRef,
|
|
125
161
|
props,
|
|
126
162
|
rows: flatRows,
|
|
@@ -133,6 +169,15 @@ function GridTableContent(props) {
|
|
|
133
169
|
selecting,
|
|
134
170
|
revealRow: rowWindow.revealRow,
|
|
135
171
|
});
|
|
172
|
+
const { openRow, settling: settlingFrom } = useGridRowOpener({
|
|
173
|
+
rootRef,
|
|
174
|
+
onOpenRow,
|
|
175
|
+
visibleRowKeys,
|
|
176
|
+
visibleColIds,
|
|
177
|
+
focusCell: focusCellSync,
|
|
178
|
+
revealCell,
|
|
179
|
+
desktopQuery,
|
|
180
|
+
});
|
|
136
181
|
const railRow = focus.chrome?.kind === "rail" ? focus.chrome.rowKey : undefined;
|
|
137
182
|
const keptFor = (groupKey) => {
|
|
138
183
|
const kept = [];
|
|
@@ -143,8 +188,7 @@ function GridTableContent(props) {
|
|
|
143
188
|
}
|
|
144
189
|
return kept;
|
|
145
190
|
};
|
|
146
|
-
const { areaRef, scrollXRef, getScroller } = useGridScrollArea(rootRef);
|
|
147
|
-
const total = useMemo(() => groups.reduce((n, g) => n + g.items.length, 0), [groups]);
|
|
191
|
+
const { areaRef, panRef, scrollXRef, getScroller } = useGridScrollArea(rootRef, boxes, recorderRef);
|
|
148
192
|
const empty = grouped ? groups.length === 0 : total === 0;
|
|
149
193
|
const rail = useGridRailReveal({ rootRef, earned: selecting || !!props.alwaysCheckboxes });
|
|
150
194
|
const batchApi = useGridBatchApi({
|
|
@@ -157,7 +201,7 @@ function GridTableContent(props) {
|
|
|
157
201
|
commitBatch,
|
|
158
202
|
});
|
|
159
203
|
const headerDrag = useGridHeaderDrag({
|
|
160
|
-
columns,
|
|
204
|
+
columns: laidOut,
|
|
161
205
|
columnState,
|
|
162
206
|
onColumnStateChange,
|
|
163
207
|
visibleColumnIds: visibleColIds,
|
|
@@ -166,16 +210,91 @@ function GridTableContent(props) {
|
|
|
166
210
|
viewBacked: props.viewBacked,
|
|
167
211
|
});
|
|
168
212
|
const rowRangeFor = (rowKey) => rowSpansMap.get(rowKey);
|
|
169
|
-
const
|
|
213
|
+
const rowProps = (row, index, items, groupKey) => {
|
|
170
214
|
const rowId = getRowId(row);
|
|
171
215
|
const rowKey = gridRowKey(groupKey, rowId);
|
|
172
216
|
const above = index > 0 ? items[index - 1] : null;
|
|
173
|
-
return
|
|
217
|
+
return {
|
|
218
|
+
row,
|
|
219
|
+
id: rowId,
|
|
220
|
+
rowKey,
|
|
221
|
+
columns: visibleColumns,
|
|
222
|
+
selectable,
|
|
223
|
+
selected: sel.isSelected(rowId),
|
|
224
|
+
selectedAbove: above != null && sel.isSelected(getRowId(above)),
|
|
225
|
+
selecting,
|
|
226
|
+
toggle: sel.toggle,
|
|
227
|
+
toggleRange: sel.toggleRange,
|
|
228
|
+
contextMenu: props.contextMenu ?? props.rowMenu,
|
|
229
|
+
rowClassName,
|
|
230
|
+
rowHref,
|
|
231
|
+
onOpenRow: openRow,
|
|
232
|
+
onPrefetchRow,
|
|
233
|
+
onOpenRelation: props.onOpenRelation,
|
|
234
|
+
entityIcon: props.entityIcon,
|
|
235
|
+
commands: props.commands,
|
|
236
|
+
onRowDelete,
|
|
237
|
+
deleteLabel: props.deleteLabel,
|
|
238
|
+
rowActions,
|
|
239
|
+
rowIcon: showRowIcon ? rowIcon : undefined,
|
|
240
|
+
frozenCount,
|
|
241
|
+
frozenLeft,
|
|
242
|
+
verticalBorders,
|
|
243
|
+
optionColors,
|
|
244
|
+
dateStyles,
|
|
245
|
+
durationStyles,
|
|
246
|
+
numberFormats,
|
|
247
|
+
showTimeOverrides,
|
|
248
|
+
percentDisplays,
|
|
249
|
+
editingEnabled,
|
|
250
|
+
listConfig,
|
|
251
|
+
focusedColId: focusedCell?.rowId === rowKey ? focusedCell.columnId : null,
|
|
252
|
+
editingColId: editingCell?.rowId === rowKey ? editingCell.columnId : null,
|
|
253
|
+
editSeed: editingCell?.rowId === rowKey ? editSeed : null,
|
|
254
|
+
editWhole: editingCell?.rowId === rowKey && editWhole,
|
|
255
|
+
onEditorTab,
|
|
256
|
+
onEditorEnter,
|
|
257
|
+
pendingByCol: pendingByRow.get(rowId),
|
|
258
|
+
settlementByCol: settlementByRow.get(rowId),
|
|
259
|
+
selectValues: selectValuesByColumn,
|
|
260
|
+
rowRange: rowRangeFor(rowKey),
|
|
261
|
+
ariaRowIndex: aria.rowIndex(groupKey, index),
|
|
262
|
+
ariaLevel: grouped ? 2 : undefined,
|
|
263
|
+
ariaPosInSet: grouped ? index + 1 : undefined,
|
|
264
|
+
ariaSetSize: grouped ? items.length : undefined,
|
|
265
|
+
ariaColOffset,
|
|
266
|
+
ariaTailIndex,
|
|
267
|
+
onFocusCell: focusCellSync,
|
|
268
|
+
onStartEdit: startEditSync,
|
|
269
|
+
onRefuseEdit: refuseEdit,
|
|
270
|
+
onExtendCell,
|
|
271
|
+
onAddCell,
|
|
272
|
+
onCommitCell: commitEdit,
|
|
273
|
+
onCancelEdit: cancelEdit,
|
|
274
|
+
inActiveRange,
|
|
275
|
+
rangeCanClear,
|
|
276
|
+
onRangeCopy,
|
|
277
|
+
onRangeCut,
|
|
278
|
+
onRangePaste,
|
|
279
|
+
onRangeClear,
|
|
280
|
+
onPasteAtCell,
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
const renderRow = (row, index, items, groupKey) => {
|
|
284
|
+
const drawn = rowProps(row, index, items, groupKey);
|
|
285
|
+
return _jsx(GridRow, { ...drawn }, drawn.rowKey);
|
|
286
|
+
};
|
|
287
|
+
const rowPropsFor = (rowKey) => {
|
|
288
|
+
const place = flat.place.get(rowKey);
|
|
289
|
+
const section = place ? flat.sections.find((each) => each.groupKey === place.groupKey) : undefined;
|
|
290
|
+
const row = place && section ? section.items[place.index] : undefined;
|
|
291
|
+
return place && section && row !== undefined ? rowProps(row, place.index, section.items, place.groupKey) : null;
|
|
174
292
|
};
|
|
175
|
-
const
|
|
293
|
+
const wrapRows = (rows) => (_jsx(GridRowsMenu, { rowPropsFor: rowPropsFor, selectable: selectable, children: rows }));
|
|
294
|
+
const header = (checkbox, groupKey) => (_jsx(GridHeader, { showAddColumn: showAddColumn, checkbox: checkbox, groupKey: groupKey, ariaRowIndex: empty ? 1 : groupKey != null ? aria.headIndex(groupKey) : undefined, ariaLevel: grouped ? 2 : undefined, ariaColOffset: ariaColOffset, ariaTailIndex: ariaTailIndex, columns: visibleColumns, columnManager: columnManager, minWidth: minWidth, sort: sort, selectValues: selectValuesByColumn, optionColors: optionColors, onOptionColorChange: onOptionColorChange, dateStyles: dateStyles, onDateStyleChange: onDateStyleChange, durationStyles: durationStyles, onDurationStyleChange: onDurationStyleChange, numberFormats: numberFormats, onNumberFormatChange: onNumberFormatChange, showTimeOverrides: showTimeOverrides, onShowTimeChange: onShowTimeChange, percentDisplays: percentDisplays, onPercentDisplayChange: onPercentDisplayChange, columnStateEnabled: !!onColumnStateChange, listConfig: listConfig, groupBy: groupBy, viewBacked: props.viewBacked, formatsWritable: props.formatsWritable, renderAddColumn: props.renderAddColumn, renderColumnMenuRows: props.renderColumnMenuRows, columnMenuItems: props.columnMenuItems, resizingId: resizingId, startResize: startResize, moveResize: moveResize, endResize: endResize, resetColumnWidth: resetColumnWidth, hideColumn: hideColumn, moveColumn: moveColumn, headerDrag: headerDrag, frozenCount: frozenCount, frozenLeft: frozenLeft }));
|
|
176
295
|
const footer = (group) => (_jsx(GridFooter, { group: group, ariaRowIndex: aria.footIndex(grouped ? group.key : (flat.sections[0]?.groupKey ?? group.key)), ariaLevel: grouped ? 2 : undefined, ariaColOffset: ariaColOffset, columns: visibleColumns, selecting: selecting, aggregates: aggregates, numberFormats: numberFormats, renderAggregate: renderAggregate, onAggregateChange: onAggregateChange, viewBacked: props.viewBacked, frozenCount: frozenCount, frozenLeft: frozenLeft, continuation: props.renderGroupFooter?.(group), defaultCurrency: props.defaultCurrency }));
|
|
177
296
|
const groupCheckbox = (items) => (_jsx(GridHeadCheck, { selecting: selecting, ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) }));
|
|
178
|
-
return (_jsx(GridHoverContext.Provider, { value: hoverStore, children: _jsx(GridRowWindowContext.Provider, { value: rowWindow.store, children: _jsx(GridTableSurface, { rootRef: rootRef, areaRef: areaRef, minWidth: minWidth, columnsTemplate: gridTemplate, gridAria: empty
|
|
297
|
+
return (_jsx(GridHoverContext.Provider, { value: hoverStore, children: _jsx(GridRowWindowContext.Provider, { value: rowWindow.store, children: _jsx(GridTableSurface, { rootRef: rootRef, areaRef: areaRef, panRef: panRef, boxes: boxes, minWidth: minWidth, columnsTemplate: gridTemplate, gridAria: empty
|
|
179
298
|
? { role: "grid", rowCount: 2, colCount: ariaTailIndex }
|
|
180
299
|
: { role: aria.role, rowCount: aria.rowCount, colCount: ariaTailIndex }, style: { ...widthVarsStyle, ...scaleVarsStyle }, selecting: selecting, railRootProps: rail.rootProps, onPointerDown: (event) => {
|
|
181
300
|
if (checkDrag.tryArm(event))
|
|
@@ -188,5 +307,8 @@ function GridTableContent(props) {
|
|
|
188
307
|
return;
|
|
189
308
|
}
|
|
190
309
|
handleRootClickCapture(event);
|
|
191
|
-
}, railProbe: _jsx(GridRailProbe, { probeRef: rail.probeRef }), onGuardFocus:
|
|
310
|
+
}, railProbe: _jsx(GridRailProbe, { probeRef: rail.probeRef }), onGuardFocus: (which, from) => {
|
|
311
|
+
if (!settlingFrom())
|
|
312
|
+
enterGrid(which, from);
|
|
313
|
+
}, body: _jsx(GridBody, { empty: empty, emptyState: emptyState, grouped: grouped, groups: groups, rows: flatRows, selectable: selectable, selecting: selecting, allSelected: sel.allSelected, someSelected: sel.someSelected, selectAll: sel.selectAll, clearSelection: sel.clear, isCollapsed: isCollapsed, countOf: countOf, sort: sort, sortOptions: sortOptions, groupSummary: groupSummary, onToggleGroup: onToggleGroup, onGroupSummaryChange: onGroupSummaryChange, renderGroupLabel: renderGroupLabel, onHideGroup: onHideGroup, groupMenu: props.groupMenu, figures: bandFigures, countNoun: countNoun, renderHeader: header, renderGroupCheckbox: groupCheckbox, renderRow: renderRow, wrapRows: wrapRows, renderFooter: footer, keptFor: keptFor, barIndexOf: aria.barIndex, ariaColCount: ariaTailIndex }), loadMore: loadMore?.hasMore ? _jsx(LoadMore, { onReveal: loadMore.onReveal, label: loadMore.label }) : undefined, selectionBar: selection?.renderBar?.(sel, batchApi) }) }) }));
|
|
192
314
|
}
|
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
import type { CSSProperties, HTMLAttributes, PointerEventHandler, MouseEventHandler, ReactNode, RefCallback, RefObject } from "react";
|
|
2
|
+
import type { GridBoxes } from "./useGridBoxes.js";
|
|
2
3
|
/**
|
|
3
|
-
* The grid's frame and its
|
|
4
|
+
* The grid's frame and its scroll boxes.
|
|
4
5
|
*
|
|
5
6
|
* The FRAME (`data-slot="vk-grid"`) fills the box its app gives it: `height: 100%` where the app
|
|
6
7
|
* gives a definite height, `flex: 1 1 0` where the app is a flex column, `min-height: 0` either way so
|
|
7
8
|
* the box can shrink below its rows. It doesn't scroll. It holds the CSS variables, the rail's
|
|
8
9
|
* signal, the pointer handlers, the selection bar and the rail probe.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* the rows run edge to edge and their content lines up with the page.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
11
|
+
* Inside it, the ROWS' box (`data-slot="vk-grid-scroll"`) holds every head, row and footer: every group's head pins at
|
|
12
|
+
* its top, so a head and its rows never part on a vertical scroll. By default it is the one element that scrolls,
|
|
13
|
+
* both ways: every frozen cell sticks to its left because it sits in the same scrollport as the rows. It bleeds into
|
|
14
|
+
* the page's side padding (`--vk-gutter`), so the rows run edge to edge and their content lines up with the page.
|
|
15
|
+
* `@container` lets a group's label keep to the visible width (`100cqw`) while the table is wider.
|
|
16
|
+
*
|
|
17
|
+
* Where the page's lab asks for two boxes on a touch screen (`useGridBoxes`), an OUTER box (`data-slot="vk-grid-pan"`)
|
|
18
|
+
* takes the bleed and the container and scrolls the table sideways only, and the rows' box inside it, as wide as the
|
|
19
|
+
* table, scrolls up and down only, so iOS hands each flick to the box of its direction. The frozen cells are then held
|
|
20
|
+
* at the left by the scroll area's hold (`useGridScrollArea`), since a sticky left can't hold against a box that
|
|
21
|
+
* doesn't scroll sideways.
|
|
22
|
+
*
|
|
23
|
+
* Their overflow is inline, both axes spelled out: it is the property the grid's working rests on, under any
|
|
24
|
+
* stylesheet. The box that scrolls sideways is `overscroll-behavior-x: contain`: a sideways scroll that reaches the
|
|
25
|
+
* table's edge stops there and never swipes the browser back a page. Only that box: a contained rows' box in two
|
|
26
|
+
* boxes would stop a sideways swipe on the rows from reaching the outer box. Down and up chain as usual, so where the
|
|
27
|
+
* app gives the grid no height a wheel over it still scrolls the page.
|
|
19
28
|
*
|
|
20
29
|
* A frame with no height (an app that hasn't given one) grows to its rows: the page scrolls it, and
|
|
21
30
|
* its heads don't pin.
|
|
22
31
|
*/
|
|
23
|
-
export declare function GridTableSurface({ rootRef, areaRef, style, selecting, minWidth, columnsTemplate, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, selectionBar, onGuardFocus, gridAria, }: {
|
|
32
|
+
export declare function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selecting, minWidth, columnsTemplate, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, selectionBar, onGuardFocus, gridAria, }: {
|
|
24
33
|
/** What a screen reader is told of the whole table: a grid (a tree grid when grouped), its rows (-1 while more
|
|
25
34
|
* remain to load) and its columns. */
|
|
26
35
|
gridAria?: {
|
|
@@ -32,8 +41,12 @@ export declare function GridTableSurface({ rootRef, areaRef, style, selecting, m
|
|
|
32
41
|
/** A guard took the focus: `from` is where it came from (the browser's Tab from before or after the grid, or the
|
|
33
42
|
* grid itself handing focus on as it is left). */
|
|
34
43
|
onGuardFocus?: (which: "start" | "end", from: Element | null) => void;
|
|
35
|
-
/** The
|
|
44
|
+
/** The rows' box's ref (`useGridScrollArea`). */
|
|
36
45
|
areaRef: RefCallback<HTMLDivElement>;
|
|
46
|
+
/** The outer box's ref (`useGridScrollArea`), drawn only in two boxes. */
|
|
47
|
+
panRef: RefCallback<HTMLDivElement>;
|
|
48
|
+
/** One box both ways, or the rows up and down inside a box that scrolls sideways (`useGridBoxes`). */
|
|
49
|
+
boxes: GridBoxes;
|
|
37
50
|
style: CSSProperties;
|
|
38
51
|
selecting: boolean;
|
|
39
52
|
/** The table's minimum width: the content box is never narrower, so every head spans the table. */
|
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cx } from "../../internal/cx.js";
|
|
4
4
|
import { GRID_BLEED } from "./grid-styles.js";
|
|
5
|
-
export function GridTableSurface({ rootRef, areaRef, style, selecting, minWidth, columnsTemplate, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, selectionBar, onGuardFocus, gridAria, }) {
|
|
6
|
-
|
|
5
|
+
export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selecting, minWidth, columnsTemplate, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, selectionBar, onGuardFocus, gridAria, }) {
|
|
6
|
+
const content = (_jsxs("div", { className: "relative", role: gridAria?.role, "aria-rowcount": gridAria?.rowCount, "aria-colcount": gridAria?.colCount, "aria-multiselectable": gridAria ? true : undefined, style: {
|
|
7
|
+
minWidth,
|
|
8
|
+
paddingBottom: `calc(${selecting ? "3.5rem" : "0.5rem"} + var(--vk-scroll-inset-bottom,0px))`,
|
|
9
|
+
}, children: [body, loadMore ? (_jsx("div", { role: "row", children: _jsx("div", { role: "gridcell", "aria-colspan": gridAria?.colCount, children: loadMore }) })) : null] }));
|
|
10
|
+
return (_jsxs("div", { ref: rootRef, style: style, tabIndex: -1, className: "group/gridtable relative isolate flex h-full min-h-0 flex-1 flex-col animate-fade-in outline-none", "data-slot": "vk-grid", ...railRootProps, onPointerDown: onPointerDown, onPointerDownCapture: onPointerDownCapture, onClickCapture: onClickCapture, children: [_jsx("span", { "data-grid-guard": "start", tabIndex: 0, className: "absolute size-0 overflow-hidden outline-none", onFocus: (event) => onGuardFocus?.("start", event.relatedTarget) }), boxes === 2 ? (_jsx("div", { ref: panRef, "data-slot": "vk-grid-pan", className: cx("@container flex min-h-0 flex-1 flex-col", GRID_BLEED), style: { overflowX: "auto", overflowY: "hidden", overscrollBehaviorX: "contain" }, children: _jsx("div", { ref: areaRef, "data-slot": "vk-grid-scroll", className: "min-h-0 flex-1", style: {
|
|
11
|
+
overflowX: "hidden",
|
|
12
|
+
overflowY: "auto",
|
|
13
|
+
minWidth,
|
|
14
|
+
scrollPaddingBottom: "var(--vk-scroll-inset-bottom,0px)",
|
|
15
|
+
"--vk-cols": columnsTemplate,
|
|
16
|
+
}, children: content }) })) : (_jsx("div", { ref: areaRef, "data-slot": "vk-grid-scroll", className: cx("@container min-h-0 flex-1 overscroll-x-contain", GRID_BLEED), style: {
|
|
7
17
|
overflowX: "auto",
|
|
8
18
|
overflowY: "auto",
|
|
9
19
|
scrollPaddingBottom: "var(--vk-scroll-inset-bottom,0px)",
|
|
10
20
|
"--vk-cols": columnsTemplate,
|
|
11
|
-
}, children:
|
|
12
|
-
minWidth,
|
|
13
|
-
paddingBottom: `calc(${selecting ? "3.5rem" : "0.5rem"} + var(--vk-scroll-inset-bottom,0px))`,
|
|
14
|
-
}, children: [body, loadMore ? (_jsx("div", { role: "row", children: _jsx("div", { role: "gridcell", "aria-colspan": gridAria?.colCount, children: loadMore }) })) : null] }) }), _jsx("span", { "data-grid-guard": "end", tabIndex: 0, className: "absolute size-0 overflow-hidden outline-none", onFocus: (event) => onGuardFocus?.("end", event.relatedTarget) }), selectionBar, railProbe] }));
|
|
21
|
+
}, children: content })), _jsx("span", { "data-grid-guard": "end", tabIndex: 0, className: "absolute size-0 overflow-hidden outline-none", onFocus: (event) => onGuardFocus?.("end", event.relatedTarget) }), selectionBar, railProbe] }));
|
|
15
22
|
}
|
|
@@ -6,6 +6,7 @@ import { OpenValueAction } from "../../editors/open-value.js";
|
|
|
6
6
|
import { TextEditor, } from "../../editors/TextEditor.js";
|
|
7
7
|
import { cx } from "../../internal/cx.js";
|
|
8
8
|
import { GridRefusal, useGridEditSession } from "./grid-edit-session.js";
|
|
9
|
+
import { GridFittedBox } from "./grid-fitted-box.js";
|
|
9
10
|
const TEXT_TYPES = new Set([
|
|
10
11
|
"text",
|
|
11
12
|
"url",
|
|
@@ -19,6 +20,7 @@ export function gridTextEditorType(colType) {
|
|
|
19
20
|
}
|
|
20
21
|
export function GridTextEditor({ initial, seed, type = "text", title, strong = false, open, refuse, onCommit, onCancel, onTab, onEnter, }) {
|
|
21
22
|
const editorRef = useRef(null);
|
|
23
|
+
const boxRef = useRef(null);
|
|
22
24
|
const { session, close } = useGridEditSession({
|
|
23
25
|
editorRef,
|
|
24
26
|
inPlace: true,
|
|
@@ -33,6 +35,6 @@ export function GridTextEditor({ initial, seed, type = "text", title, strong = f
|
|
|
33
35
|
const editor = (_jsx(TextEditor, { ref: editorRef, type: type, initial: initial, seed: seed, closeOnBlur: surface === "in-place", chrome: surface === "sheet" ? "field" : "bare", boxData: { "data-slot": "vk-grid-editor", "data-grid-editor": "" }, onRequestClose: close, className: surface === "sheet"
|
|
34
36
|
? "w-full min-w-0 select-text"
|
|
35
37
|
: cx("h-full w-full min-w-0 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtlest)", strong && "font-medium") }));
|
|
36
|
-
return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : (_jsxs("span", { className: "relative flex h-full w-full min-w-0", children: [editor, _jsx(GridRefusal, { reason: session.refusal })] }));
|
|
38
|
+
return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : (_jsxs("span", { className: "relative flex h-full w-full min-w-0", children: [_jsx(GridFittedBox, { boxRef: boxRef, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
|
|
37
39
|
} }));
|
|
38
40
|
}
|
|
@@ -15,5 +15,5 @@ export function GridValueListEditor({ field, title, initial, labels, allowEmpty
|
|
|
15
15
|
onTab,
|
|
16
16
|
onEnter,
|
|
17
17
|
});
|
|
18
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-96 p-2", children: (surface) => (_jsx(ValueListEditor, { ref: editorRef, field: field, initial: initial, labels: labels, allowEmpty: allowEmpty, region: region, openLinks: surface === "sheet", onRequestClose: close })) })] }));
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-96 p-2", children: (surface) => (_jsx(ValueListEditor, { ref: editorRef, field: field, initial: initial, labels: labels, allowEmpty: allowEmpty, region: region, openLinks: surface === "sheet", escapeKeeps: session.keeps ?? false, onRequestClose: close })) })] }));
|
|
19
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ViewsClipboardPort } from "../../provider/ports.js";
|
|
2
2
|
import { type GridCellClipboard, type GridClipboardCell } from "../core/clipboard-model.js";
|
|
3
3
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
4
|
-
export { cellClearPrev, cellEditBaseline, cellPrevPayload, rowHoldsCurrency, coercePaste, parseTsvText, type GridPasteSource, } from "../core/clipboard-model.js";
|
|
4
|
+
export { cellClearPrev, cellEditBaseline, cellPrevPayload, rowHoldsCurrency, coercePaste, gridDateDrawsAtOnce, parseTsvText, type GridPasteSource, } from "../core/clipboard-model.js";
|
|
5
5
|
export declare function getGridClipboard(): GridCellClipboard | null;
|
|
6
6
|
/** Puts one cell's text on the system clipboard through the app's port, and keeps the typed entry
|
|
7
7
|
* the grid pastes from — which survives a refused system write. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cellCopyText, serializeClipboardMatrix, } from "../core/clipboard-model.js";
|
|
2
|
-
export { cellClearPrev, cellEditBaseline, cellPrevPayload, rowHoldsCurrency, coercePaste, parseTsvText, } from "../core/clipboard-model.js";
|
|
2
|
+
export { cellClearPrev, cellEditBaseline, cellPrevPayload, rowHoldsCurrency, coercePaste, gridDateDrawsAtOnce, parseTsvText, } from "../core/clipboard-model.js";
|
|
3
3
|
let clipboard = null;
|
|
4
4
|
export function getGridClipboard() {
|
|
5
5
|
return clipboard;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frozen block's shadow down one group's rows: one box for all of them, the last child of the group's rows box
|
|
3
|
+
* (`vk-grid-rows`, `position: relative`). A lane over the whole box, padded like a row, so the box inside it starts
|
|
4
|
+
* where a row's rail slot does and holds where the slot holds.
|
|
5
|
+
*/
|
|
6
|
+
export declare function GridFrozenEdge(): import("react/jsx-runtime").JSX.Element;
|
|
1
7
|
/** Empty rail segment — keeps the opaque lane continuous across the header and
|
|
2
8
|
* footer rows, which have no checkbox of their own. `bordered` follows whether
|
|
3
9
|
* that surface's own cells draw a bottom rule: the header's do, the footer's
|
|
4
10
|
* don't. */
|
|
5
|
-
export declare function GridRailSpacer({ selecting, bordered, }: {
|
|
11
|
+
export declare function GridRailSpacer({ selecting, bordered, shadow, }: {
|
|
6
12
|
selecting: boolean;
|
|
7
13
|
bordered?: boolean;
|
|
14
|
+
/** Off for a row's spacer: its group's edge draws the frozen block's shadow. */
|
|
15
|
+
shadow?: boolean;
|
|
8
16
|
}): import("react/jsx-runtime").JSX.Element;
|
|
9
17
|
/** Row checkbox — reveals while the row (`group/gridrow`) is hovered. */
|
|
10
18
|
export declare function GridRowCheck({ selecting, checked, revealed, onChange, "aria-label": ariaLabel, }: {
|
|
@@ -18,7 +26,7 @@ export declare function GridRowCheck({ selecting, checked, revealed, onChange, "
|
|
|
18
26
|
* Select-all / group checkbox — the SAME rail slot the rows use, mounted as the
|
|
19
27
|
* header's leading track rather than as an overlay beside it.
|
|
20
28
|
*
|
|
21
|
-
* The header sits in the grid's
|
|
29
|
+
* The header sits in the grid's rows' box with the rows, so its rail slot
|
|
22
30
|
* travels and parks exactly as theirs do. An overlay would be the one piece of
|
|
23
31
|
* leading chrome that didn't move — parked at a fixed x while every row's
|
|
24
32
|
* checkbox slid away from it and stopped somewhere else.
|
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useViews } from "../../provider/context.js";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
5
|
import { gridFrozenBg } from "./GridCellOutline.js";
|
|
6
|
-
import { GRID_GROUND } from "./grid-styles.js";
|
|
6
|
+
import { GRID_CONTENT_PAD, GRID_GROUND } from "./grid-styles.js";
|
|
7
7
|
import { SelectCheckbox } from "../../selection/SelectCheckbox.js";
|
|
8
8
|
const HOVER_RAISE = {
|
|
9
9
|
row: {
|
|
10
|
-
backing: "group-hover/gridrow:opacity-[max(var(--vk-frozen-on,0),var(--vk-parked,0))]",
|
|
11
|
-
rule: "group-hover/gridrow:opacity-(--vk-parked,0)",
|
|
10
|
+
backing: "group-hover/gridrow:before:opacity-[max(var(--vk-frozen-on,0),var(--vk-parked,0))]",
|
|
11
|
+
rule: "group-hover/gridrow:after:opacity-(--vk-parked,0)",
|
|
12
12
|
},
|
|
13
13
|
head: {
|
|
14
|
-
backing: "group-hover/gridhead:opacity-[max(var(--vk-frozen-on,0),var(--vk-parked,0))]",
|
|
15
|
-
rule: "group-hover/gridhead:opacity-(--vk-parked,0)",
|
|
14
|
+
backing: "group-hover/gridhead:before:opacity-[max(var(--vk-frozen-on,0),var(--vk-parked,0))]",
|
|
15
|
+
rule: "group-hover/gridhead:after:opacity-(--vk-parked,0)",
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const RAIL_HOLD = "[position:var(--vk-pin,sticky)] left-[calc(var(--vk-stick,1)*var(--vk-rail-w)+var(--vk-hold-x,0px))] z-10 h-full";
|
|
19
|
+
const FROZEN_SHADOW = cx("after:pointer-events-none after:absolute after:inset-y-0 after:left-(--vk-frozen-w,0px) after:w-1.5 after:content-['']", "after:bg-linear-to-r after:from-black/15 after:to-transparent dark:after:from-black/60", "after:opacity-[calc(var(--vk-parked,0)*var(--vk-frozen-on,0))] after:transition-opacity after:duration-150");
|
|
20
|
+
export function GridFrozenEdge() {
|
|
21
|
+
return (_jsx("div", { "aria-hidden": true, className: cx("pointer-events-none absolute inset-0", GRID_CONTENT_PAD), children: _jsx("div", { className: cx(RAIL_HOLD, "w-0", FROZEN_SHADOW) }) }));
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
return _jsx(
|
|
23
|
+
function RailSlot({ shadow = true, selecting, selected = false, bordered = false, reveal, children, }) {
|
|
24
|
+
return (_jsx("div", { "data-slot": "vk-grid-rail", role: children ? (reveal === "head" ? "columnheader" : "gridcell") : undefined, "aria-colindex": children ? 1 : undefined, "aria-hidden": children ? undefined : true, className: cx(RAIL_HOLD, shadow && FROZEN_SHADOW), "data-action-menu": true, onClick: (e) => e.stopPropagation(), children: _jsx("div", { "data-row-check": selecting ? "" : undefined, className: cx("relative flex h-full w-[calc(var(--vk-gutter,0px)+var(--vk-indent,0px))] -translate-x-full items-start justify-end", "pr-[calc(var(--vk-rail-gap)+((var(--vk-rail-w)-16px)/2-var(--vk-rail-gap))*var(--vk-parked,0)*(1-var(--vk-frozen-on,0)))]", "transition-[padding-right] duration-150", "before:pointer-events-none before:absolute before:inset-0 before:content-['']", gridFrozenBg(selected, "before"), "before:opacity-(--vk-frozen-on,0) before:transition-opacity before:duration-150", reveal && HOVER_RAISE[reveal].backing, "group-data-[rail=on]/gridtable:before:opacity-100", bordered &&
|
|
25
|
+
cx("after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:content-[''] after:bg-(color:--vk-border-subtle)", "after:opacity-[calc(var(--vk-parked,0)*var(--vk-frozen-on,0))] after:transition-opacity after:duration-150", reveal && HOVER_RAISE[reveal].rule, "group-data-[rail=on]/gridtable:after:opacity-(--vk-parked,0)")), children: children ? (_jsx("span", { "data-row-check": true, className: "relative flex h-full items-center", children: children })) : null }) }));
|
|
26
|
+
}
|
|
27
|
+
export function GridRailSpacer({ selecting, bordered = false, shadow = true, }) {
|
|
28
|
+
return _jsx(RailSlot, { selecting: selecting, bordered: bordered, shadow: shadow });
|
|
23
29
|
}
|
|
24
30
|
export function GridRowCheck({ selecting, checked, revealed, onChange, "aria-label": ariaLabel, }) {
|
|
25
|
-
return (_jsx(RailSlot, { selecting: selecting, selected: checked, bordered: true, reveal: "row", children: _jsx(SelectCheckbox, { checked: checked, revealed: revealed, onChange: onChange, "aria-label": ariaLabel, tabIndex: -1, className: cx(GRID_GROUND, "transition-opacity duration-150 group-hover/gridrow:opacity-100 group-data-[rail=on]/gridtable:opacity-100 focus-visible:opacity-100") }) }));
|
|
31
|
+
return (_jsx(RailSlot, { selecting: selecting, selected: checked, bordered: true, reveal: "row", shadow: false, children: _jsx(SelectCheckbox, { checked: checked, revealed: revealed, onChange: onChange, "aria-label": ariaLabel, tabIndex: -1, className: cx(GRID_GROUND, "transition-opacity duration-150 group-hover/gridrow:opacity-100 group-data-[rail=on]/gridtable:opacity-100 focus-visible:opacity-100") }) }));
|
|
26
32
|
}
|
|
27
33
|
export function GridHeadCheck({ selecting, allSelected, someSelected, onToggle, "aria-label": ariaLabel, }) {
|
|
28
34
|
const { Checkbox } = useViews().components;
|
|
@@ -8,7 +8,7 @@ type GridGlyphs = {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
}>;
|
|
10
10
|
};
|
|
11
|
-
/** The column's glyph: its explicit `icon` → its binding's glyph → its field's
|
|
12
|
-
* column's mark → its list type's → nothing. */
|
|
11
|
+
/** The column's glyph: its explicit `icon` → its binding's glyph → its whole field's, for a part column → its
|
|
12
|
+
* field's type → a computed column's mark → its list type's → nothing. */
|
|
13
13
|
export declare function gridColumnGlyph<Row>({ icons, AppIcon }: GridGlyphs, col: ListColumn<Row>, className?: string): ReactNode;
|
|
14
14
|
export {};
|
|
@@ -29,6 +29,10 @@ export function gridColumnGlyph({ icons, AppIcon }, col, className = "h-3.5 w-3.
|
|
|
29
29
|
return col.icon;
|
|
30
30
|
if (col.binding?.icon)
|
|
31
31
|
return _jsx(AppIcon, { name: col.binding.icon, className: className });
|
|
32
|
+
if (col.partOf) {
|
|
33
|
+
const Glyph = icons[col.partOf.field.type];
|
|
34
|
+
return _jsx(Glyph, { className: className });
|
|
35
|
+
}
|
|
32
36
|
if (col.field) {
|
|
33
37
|
const Glyph = icons[col.field.type];
|
|
34
38
|
return _jsx(Glyph, { className: className });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ViewsMessageResolver } from "../../contract.js";
|
|
2
|
+
import type { ListColumnsConfig } from "../../model/column-state.js";
|
|
3
|
+
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
4
|
+
/**
|
|
5
|
+
* Each hidden column a row; each field with parts (`parts`) a group beside the menu, its count as `detail`, holding
|
|
6
|
+
* the field itself when hidden and then each hidden part by its word; a fixed column never. There is no search: a
|
|
7
|
+
* menu finds a row by its first letters, and a part by opening its field. With nothing to add, one disabled row says
|
|
8
|
+
* all columns are shown.
|
|
9
|
+
*/
|
|
10
|
+
export declare function gridAddColumnItems(columns: ListColumnsConfig, deps: {
|
|
11
|
+
messages: ViewsMessageResolver;
|
|
12
|
+
close: () => void;
|
|
13
|
+
}): ViewsMenuItem[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export function gridAddColumnItems(columns, deps) {
|
|
3
|
+
const { items } = columns;
|
|
4
|
+
const offered = (item) => item.hidden && !item.fixed;
|
|
5
|
+
const pick = (item, label) => ({
|
|
6
|
+
key: `add:${item.id}`,
|
|
7
|
+
label,
|
|
8
|
+
...(item.icon !== undefined && { icon: item.icon }),
|
|
9
|
+
onSelect: () => {
|
|
10
|
+
columns.onToggleHidden(item.id, false);
|
|
11
|
+
deps.close();
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const rows = items
|
|
15
|
+
.filter((item) => !item.partOf && !item.fixed)
|
|
16
|
+
.flatMap((whole) => {
|
|
17
|
+
const parts = items.filter((item) => item.partOf?.column === whole.id);
|
|
18
|
+
if (parts.length === 0)
|
|
19
|
+
return offered(whole) ? [pick(whole, whole.label)] : [];
|
|
20
|
+
const children = [
|
|
21
|
+
...(offered(whole) ? [pick(whole, whole.label)] : []),
|
|
22
|
+
...parts.filter(offered).map((item) => pick(item, item.partOf?.label ?? item.label)),
|
|
23
|
+
];
|
|
24
|
+
if (children.length === 0)
|
|
25
|
+
return [];
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
key: `field:${whole.id}`,
|
|
29
|
+
label: whole.label,
|
|
30
|
+
...(whole.icon !== undefined && { icon: whole.icon }),
|
|
31
|
+
beside: true,
|
|
32
|
+
detail: String(children.length),
|
|
33
|
+
children,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
});
|
|
37
|
+
if (rows.length > 0)
|
|
38
|
+
return rows;
|
|
39
|
+
return [{ key: "all-shown", label: deps.messages({ key: "views.menus.add-column-all-shown" }), disabled: true }];
|
|
40
|
+
}
|
|
@@ -20,6 +20,8 @@ export type GridCellClassState = {
|
|
|
20
20
|
inRange: boolean;
|
|
21
21
|
/** The row is selected (frozen cells repaint the selection tint). */
|
|
22
22
|
selected: boolean;
|
|
23
|
+
/** The cell opens a pick-list (select, relation, chips): its ▾ is placed by the cell's edges. */
|
|
24
|
+
picker?: boolean;
|
|
23
25
|
/** Last visible column — its right border is always transparent. */
|
|
24
26
|
lastColumn: boolean;
|
|
25
27
|
verticalBorders: boolean;
|