viewkitjs 0.36.0 → 0.38.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 +75 -0
- package/package.json +1 -1
- package/views/dist/atoms/types.d.ts +32 -4
- package/views/dist/contract.d.ts +18 -9
- package/views/dist/contract.js +18 -1
- package/views/dist/controls/button/own-look-moved.d.ts +11 -0
- package/views/dist/controls/button/own-look-moved.js +3 -0
- package/views/dist/controls/date-editor/date-behaviour.d.ts +80 -0
- package/views/dist/controls/date-editor/date-behaviour.js +187 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -2
- package/views/dist/controls/date-editor/date-editor.js +29 -166
- package/views/dist/controls/field/field.d.ts +3 -2
- package/views/dist/controls/field/field.js +7 -2
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +7 -4
- package/views/dist/controls/field.css +64 -1
- package/views/dist/controls/filter-editor/filter-editor.js +2 -2
- package/views/dist/controls/filter-editor/parts.d.ts +2 -0
- package/views/dist/controls/filter-editor/parts.js +1 -1
- package/views/dist/controls/glyphs/glyphs.js +2 -0
- package/views/dist/controls/index.d.ts +3 -1
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/inline-input.css +10 -0
- package/views/dist/controls/internal/phone.d.ts +1 -1
- package/views/dist/controls/internal/phone.js +3 -2
- package/views/dist/controls/internal/read-token.d.ts +2 -1
- package/views/dist/controls/internal/read-token.js +2 -1
- package/views/dist/controls/list/tokens.d.ts +1 -1
- package/views/dist/controls/list/tokens.js +1 -1
- package/views/dist/controls/list.css +5 -2
- package/views/dist/controls/menu-list/menu-list.js +3 -2
- package/views/dist/controls/menu.css +4 -4
- package/views/dist/controls/number-editor/tokens.d.ts +8 -0
- package/views/dist/controls/number-editor/tokens.js +2 -0
- package/views/dist/controls/number-editor.css +20 -0
- package/views/dist/controls/pane.css +1 -1
- package/views/dist/controls/picker.css +5 -3
- package/views/dist/controls/popover/looks.d.ts +1 -1
- package/views/dist/controls/popover/looks.js +5 -0
- package/views/dist/controls/popover/tokens.d.ts +13 -1
- package/views/dist/controls/popover/tokens.js +4 -1
- package/views/dist/controls/popover.css +59 -8
- package/views/dist/controls/select/select.js +1 -1
- package/views/dist/controls/sort-editor.css +4 -2
- package/views/dist/controls/text-editor/tokens.d.ts +8 -0
- package/views/dist/controls/text-editor/tokens.js +2 -0
- package/views/dist/controls/text-editor.css +28 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +7 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +1 -1
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +1 -1
- package/views/dist/controls/tooltip/tokens.js +1 -1
- package/views/dist/controls/tooltip/tooltip.js +2 -1
- package/views/dist/controls/tooltip.css +5 -3
- package/views/dist/controls/values-editor.css +20 -5
- package/views/dist/display/entity-chip.d.ts +7 -1
- package/views/dist/display/entity-chip.js +2 -1
- package/views/dist/field-row/FieldRow.js +25 -12
- package/views/dist/field-row/field-row-button.d.ts +12 -0
- package/views/dist/field-row/field-row-button.js +5 -0
- package/views/dist/fields/binding.d.ts +4 -0
- package/views/dist/grid/chrome/GridCellEditors.d.ts +4 -1
- package/views/dist/grid/chrome/GridCellEditors.js +3 -2
- package/views/dist/grid/chrome/GridCellOutline.d.ts +15 -5
- package/views/dist/grid/chrome/GridCellOutline.js +20 -5
- package/views/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridDateEditor.js +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.js +8 -5
- package/views/dist/grid/chrome/GridNameEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNameEditor.js +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +3 -2
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridPlaceEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +2 -2
- package/views/dist/grid/chrome/GridRangeEditor.js +1 -1
- package/views/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +6 -5
- package/views/dist/grid/chrome/GridSelectEditor.js +1 -1
- package/views/dist/grid/chrome/GridStructure.js +3 -3
- package/views/dist/grid/chrome/GridTable.d.ts +2 -1
- package/views/dist/grid/chrome/GridTable.js +7 -2
- package/views/dist/grid/chrome/GridTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridTextEditor.js +4 -2
- package/views/dist/grid/chrome/GridValueListEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +7 -2
- package/views/dist/grid/chrome/grid-body-place.js +9 -4
- package/views/dist/grid/chrome/grid-cell-classes.js +2 -2
- package/views/dist/grid/chrome/grid-edit-session.d.ts +8 -0
- package/views/dist/grid/chrome/grid-edit-session.js +21 -3
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +11 -0
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +4 -4
- package/views/dist/grid/chrome/grid-fitted-box.js +1 -3
- package/views/dist/grid/chrome/grid-hover.d.ts +3 -3
- package/views/dist/grid/chrome/grid-hover.js +2 -3
- package/views/dist/grid/chrome/grid-row-props.d.ts +6 -2
- package/views/dist/grid/chrome/grid-styles.d.ts +1 -5
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +5 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +11 -15
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +3 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +30 -2
- package/views/dist/grid/core/useGridEditing.d.ts +3 -0
- package/views/dist/grid/core/useGridEditing.js +2 -0
- package/views/dist/grid/grid.css +4 -19
- package/views/dist/internal/length.d.ts +2 -0
- package/views/dist/internal/length.js +16 -0
- package/views/dist/internal/screen-forms.d.ts +11 -0
- package/views/dist/internal/screen-forms.js +31 -0
- package/views/dist/list/list.js +2 -1
- package/views/dist/list/parts.d.ts +8 -2
- package/views/dist/list/parts.js +31 -7
- package/views/dist/list/toolbar.js +7 -3
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/panels/react/popover.d.ts +3 -1
- package/views/dist/panels/react/popover.js +2 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +6 -3
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +28 -20
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +3 -2
- package/views/dist/panels/react/views-row/FoldingViewRow.js +24 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +1 -1
- package/views/dist/panels/react/views-row/more-views.d.ts +2 -0
- package/views/dist/panels/react/views-row/more-views.js +3 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/toolbar/model.d.ts +2 -2
- package/views/dist/provider/components.d.ts +8 -7
- package/views/dist/provider/desktop.d.ts +2 -1
- package/views/dist/provider/desktop.js +5 -2
- package/views/dist/selection/bar-overflow.d.ts +2 -0
- package/views/dist/selection/bar-overflow.js +2 -1
- package/views/dist/selection/bar-props.d.ts +1 -1
- package/views/dist/selection/verbs.d.ts +2 -2
- package/views/dist/styles.css +341 -80
- package/views/dist/styles.unlayered.css +341 -80
- package/views/docs/contract.md +77 -23
- package/views/docs/controls/list.md +2 -0
- package/views/docs/controls/menu.md +2 -0
- package/views/docs/controls/number-editor.md +2 -0
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/popover.md +7 -0
- package/views/docs/controls/text-editor.md +2 -0
- package/views/docs/controls/tooltip.md +2 -0
- package/views/docs/guides/atoms.md +11 -10
- package/views/docs/guides/selection.md +1 -1
- package/views/docs/guides/the-grid.md +7 -5
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/reference/controls.md +11 -6
- package/views/docs/reference/display.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/list.md +5 -6
- package/views/docs/reference/looks.md +4 -1
- package/views/docs/reference/panels-react.md +5 -4
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +6 -6
- package/views/docs/reference/selection.md +1 -1
- package/views/docs/reference/views.md +3 -3
- package/views/docs/reshaping.md +2 -2
- package/views/skills/views/SKILL.md +1 -1
|
@@ -31,12 +31,13 @@ export function GridRowCells({ props }) {
|
|
|
31
31
|
const booleanCheckbox = components.Checkbox;
|
|
32
32
|
const hoverStore = useContext(GridHoverContext);
|
|
33
33
|
const highlight = useContext(GridRowHighlightContext);
|
|
34
|
-
const { row, id, rowKey, columns, selected, checkColumnId, toggle, rowActions, rowIcon, verticalBorders = true, optionColors, dateStyles, durationStyles, numberFormats, showTimeOverrides, percentDisplays, editingEnabled, focusedColId, editingColId, pendingByCol, settlementByCol, writeStateByCol, selectValues, rowRange, frozenCount = 0, frozenLeft, listConfig, rowWritable = true, onStartEdit, onEditorTab,
|
|
34
|
+
const { row, id, rowKey, columns, selected, checkColumnId, toggle, rowActions, rowIcon, verticalBorders = true, optionColors, dateStyles, durationStyles, numberFormats, showTimeOverrides, percentDisplays, editingEnabled, focusedColId, editingColId, editClosing = false, pendingByCol, settlementByCol, writeStateByCol, selectValues, rowRange, frozenCount = 0, frozenLeft, listConfig, rowWritable = true, onStartEdit, onEditorTab, onFocusCell, onEditorClosing, editSeed, editWhole = false, editByKey = false, onCommitCell, onCancelEdit, onOpenRelation: onOpenRelationValue, entityIcon, commands, ariaColOffset = 0, } = props;
|
|
35
35
|
const writes = (column) => editingEnabled && rowWritable && columnEffectiveWritable(column, listConfig);
|
|
36
36
|
const canEdit = (column) => writes(column) && gridColumnHasEditor(column);
|
|
37
37
|
const editBaseline = (column) => cellEditBaseline(column, row, pendingByCol);
|
|
38
38
|
return columns.map((col, i) => {
|
|
39
39
|
const editing = editingColId === col.id;
|
|
40
|
+
const open = editing && !editClosing;
|
|
40
41
|
const focused = focusedColId === col.id;
|
|
41
42
|
const span = rowRange?.find((s) => i >= s.startCol && i <= s.endCol);
|
|
42
43
|
const spanLeft = !!span && i === span.startCol;
|
|
@@ -86,7 +87,6 @@ export function GridRowCells({ props }) {
|
|
|
86
87
|
? col.render(row, { value: col.accessor?.(row), code: shownCodeOf(col, row) })
|
|
87
88
|
: typedCell();
|
|
88
89
|
const tabTo = (backwards) => onEditorTab(rowKey, col.id, backwards);
|
|
89
|
-
const enterAdvance = () => onEditorEnter(rowKey, col.id);
|
|
90
90
|
const frozen = i < frozenCount;
|
|
91
91
|
const settlement = settlementByCol?.[col.id];
|
|
92
92
|
const write = writeStateByCol?.[col.id];
|
|
@@ -113,12 +113,13 @@ export function GridRowCells({ props }) {
|
|
|
113
113
|
listConfig,
|
|
114
114
|
onCommitCell,
|
|
115
115
|
onCancel: () => onCancelEdit(rowKey, col.id),
|
|
116
|
+
onClosing: (reason, popover) => onEditorClosing?.(rowKey, col.id, reason, popover),
|
|
116
117
|
onTab: tabTo,
|
|
117
|
-
onEnter:
|
|
118
|
+
onEnter: () => onFocusCell(rowKey, col.id),
|
|
118
119
|
};
|
|
119
120
|
return (_jsxs("div", { "data-slot": "vk-grid-cell", "data-col-id": col.id, tabIndex: -1, role: "gridcell", "aria-colindex": ariaColOffset + i + 1, "aria-readonly": writes(col) ? undefined : true, "aria-selected": span ? true : undefined, "data-settlement": settlement, ...gridCellStates({
|
|
120
121
|
focused,
|
|
121
|
-
editing,
|
|
122
|
+
editing: open,
|
|
122
123
|
range: span && { top: !!span.top, right: spanRight, bottom: !!span.bottom, left: spanLeft },
|
|
123
124
|
write,
|
|
124
125
|
empty,
|
|
@@ -141,7 +142,7 @@ export function GridRowCells({ props }) {
|
|
|
141
142
|
verticalBorders,
|
|
142
143
|
highlight,
|
|
143
144
|
settlement,
|
|
144
|
-
}), children: [span && (_jsx("span", { "aria-hidden": true, className: GRID_RANGE_TINT_CLASS })), span?.top && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { top: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), span?.bottom && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { bottom: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), spanLeft && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { left: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), spanRight && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { right: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), span && span.dotCol === i && !editing && (_jsx(FillDot, { enabled: editingEnabled })),
|
|
145
|
+
}), children: [span && (_jsx("span", { "aria-hidden": true, className: GRID_RANGE_TINT_CLASS })), span?.top && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { top: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), span?.bottom && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { bottom: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), spanLeft && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { left: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), spanRight && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { right: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), span && span.dotCol === i && !editing && (_jsx(FillDot, { enabled: editingEnabled })), focused && !open && (_jsx(GridCellOutline, {})), focused && !editing && !span && (_jsx(FillDot, { enabled: editingEnabled })), col.id === checkColumnId && !editing && (_jsx(GridNameCheck, { children: _jsx(SelectCheckbox, { checked: selected, revealed: true, onChange: (next) => toggle(id, next), "aria-label": messages({ key: "views.grid.select-row" }), tabIndex: -1 }) })), col.type === "title" && rowIcon && !editing && (_jsx("span", { className: "mr-2.5 flex shrink-0 items-center", children: _jsx(GridRowGlyph, { row: row, rowIcon: rowIcon }) })), editing ? _jsx(GridCellInlineEditor, { ctx: editorCtx }) : null, editing &&
|
|
145
146
|
(editorKind === "number" || (editorKind === "text" && !gridTextOpensBox(col, whole, writable))) ? (_jsx(GridValueUnderEditor, { children: cellValue() })) : (cellValue()), editing ? _jsx(GridCellAnchoredEditor, { ctx: editorCtx }) : null, hoverStore && col.type === "title" && !editing && (_jsx(GridRowHoverActions, { views: views, rowKey: rowKey, row: row, selected: selected, actions: [
|
|
146
147
|
...(rowActions ?? []),
|
|
147
148
|
...(canEdit(col)
|
|
@@ -54,5 +54,5 @@ export function GridSelectEditor({ column, title, values, current, clearable = f
|
|
|
54
54
|
label: optionLabel(value),
|
|
55
55
|
color: resolveCategoryColor(value, column.options, optionColors),
|
|
56
56
|
});
|
|
57
|
-
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: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(SelectEditor, { ref: editorRef, options: pickerOptions, steps: field ? statusSteps(field) : undefined, initial: initial, clearable: clearable, creatable: !!column.field && isOpenVocabulary(column.field), seed: seed, focusSearch: !sheet, focusList: openedByKey && !sheet, onRequestClose: close, label: typeof title === "string" ? title : undefined, addOption: field?.type === "select" && !country ? column.addOption : undefined }) })] }));
|
|
57
|
+
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: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(SelectEditor, { ref: editorRef, options: pickerOptions, steps: field ? statusSteps(field) : undefined, initial: initial, clearable: clearable, creatable: !!column.field && isOpenVocabulary(column.field), seed: seed, focusSearch: !sheet, focusList: openedByKey && !sheet, onRequestClose: close, label: typeof title === "string" ? title : undefined, addOption: field?.type === "select" && !country ? column.addOption : undefined }) })] }));
|
|
58
58
|
}
|
|
@@ -20,9 +20,9 @@ function GridRowsSlot({ children }) {
|
|
|
20
20
|
const { RowsWait, pending } = slot;
|
|
21
21
|
return _jsx(RowsWait, { pending: pending, children: children });
|
|
22
22
|
}
|
|
23
|
-
function GridCollapseRegion({ collapsed, children, }) {
|
|
23
|
+
function GridCollapseRegion({ collapsed, rows = false, children, }) {
|
|
24
24
|
const { Collapse } = useViews().components;
|
|
25
|
-
return (_jsx(Collapse, { open: !collapsed, clipClassName: "pt-[2px] mt-[-2px] pb-2 -mb-2", children: children }));
|
|
25
|
+
return (_jsx(Collapse, { open: !collapsed, clipClassName: rows ? "pt-[2px] mt-[-2px] pb-2 -mb-2" : undefined, children: children }));
|
|
26
26
|
}
|
|
27
27
|
function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks = false, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, groupMenu, menus, figures, countNoun, renderHeader, renderGroupCheckbox, selectGroup, renderRow, wrapRows, renderFooter, keptFor, barIndex, ariaColCount, oneHead, first, }) {
|
|
28
28
|
const views = useViews();
|
|
@@ -68,7 +68,7 @@ function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks
|
|
|
68
68
|
canToggleFigures: !!onGroupSummaryChange,
|
|
69
69
|
canHide: !!onHideGroup,
|
|
70
70
|
canSelect: !!select,
|
|
71
|
-
}).open && (_jsx(GridGroupMenu, { groupMenu: groupMenu, reshape: menus?.group && ((items) => menus.group(items, { group })), sort: sort, sortOptions: sortOptions ?? [], summary: summaryParts, onSummaryChange: onGroupSummaryChange, figures: figures, onHide: onHideGroup ? () => onHideGroup(group.key) : undefined, select: select }))] }) }), !oneHead && (_jsx(GridCollapseRegion, { collapsed: collapsed, children: renderHeader(selectable ? renderGroupCheckbox(group.items) : undefined, group.key) }))] }), _jsxs(GridCollapseRegion, { collapsed: collapsed, children: [wrapRows(_jsx(GridWindowRows, { groupKey: group.key, items: group.items, collapsed: collapsed, kept: keptFor(group.key), renderRow: renderRow })), renderFooter(group)] })] }));
|
|
71
|
+
}).open && (_jsx(GridGroupMenu, { groupMenu: groupMenu, reshape: menus?.group && ((items) => menus.group(items, { group })), sort: sort, sortOptions: sortOptions ?? [], summary: summaryParts, onSummaryChange: onGroupSummaryChange, figures: figures, onHide: onHideGroup ? () => onHideGroup(group.key) : undefined, select: select }))] }) }), !oneHead && (_jsx(GridCollapseRegion, { collapsed: collapsed, children: renderHeader(selectable ? renderGroupCheckbox(group.items) : undefined, group.key) }))] }), _jsxs(GridCollapseRegion, { collapsed: collapsed, rows: true, children: [wrapRows(_jsx(GridWindowRows, { groupKey: group.key, items: group.items, collapsed: collapsed, kept: keptFor(group.key), renderRow: renderRow })), renderFooter(group)] })] }));
|
|
72
72
|
}
|
|
73
73
|
export function GridBody({ empty, emptyState, grouped, oneHead, groups, rows, selectable, selecting, phoneChecks = false, foldOverChecks = false, allSelected, someSelected, selectAll, clearSelection, isCollapsed, countOf, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, groupMenu, menus, figures, countNoun, renderHeader, renderGroupCheckbox, selectGroup, renderRow, wrapRows, renderFooter, keptFor, barIndexOf, ariaColCount, }) {
|
|
74
74
|
const { messages } = useViews();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GridTableProps } from "./grid-table-props.js";
|
|
2
2
|
export type { GridTableProps } from "./grid-table-props.js";
|
|
3
|
-
/** Spreadsheet sibling to ListView, including editing and synchronized grouped rails.
|
|
3
|
+
/** Spreadsheet sibling to ListView, including editing and synchronized grouped rails. Server-rendered, it draws its phone's
|
|
4
|
+
* and its computer's forms, CSS showing the screen's until the page comes alive (`ScreenForms`). */
|
|
4
5
|
export declare function GridTable<Row>(props: GridTableProps<Row>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -40,7 +40,11 @@ import { GridPager } from "./GridPager.js";
|
|
|
40
40
|
import { useGridHeldMenuReport } from "./grid-menu-focus.js";
|
|
41
41
|
import { EditLeaveContext, useEditLeaveScope } from "../../editors/leave-scope.js";
|
|
42
42
|
import { GridRowsSlotContext, GridWaitContext } from "./grid-wait.js";
|
|
43
|
+
import { ScreenForms } from "../../internal/screen-forms.js";
|
|
43
44
|
export function GridTable(props) {
|
|
45
|
+
return (_jsx(ScreenForms, { children: _jsx(GridTableOnScreen, { ...props }) }));
|
|
46
|
+
}
|
|
47
|
+
function GridTableOnScreen(props) {
|
|
44
48
|
const { atoms, messages, components } = useViews();
|
|
45
49
|
const { Loading } = atoms;
|
|
46
50
|
const deferredKey = useDeferredValue(props.transitionKey);
|
|
@@ -233,7 +237,7 @@ function GridTableContent(given) {
|
|
|
233
237
|
}), [flat, footerKey, grouped, oneHead, selectable, visibleColIds, more]);
|
|
234
238
|
const ariaTailIndex = aria.colCount + 1;
|
|
235
239
|
const ariaColOffset = selectable ? 1 : 0;
|
|
236
|
-
const { rowSpansMap, selectValuesByColumn, onRangeCopy, onRangeCut, onRangeClear, onRangePaste, onPasteAtCell, inActiveRange, rangeCanClear, editingEnabled, focusedCell, editingCell, pendingByRow, settlementByRow, writeStateByRow, editSeed, editWhole, editByKey, focusCellSync, startEditSync, cancelEdit, commitEdit, commitBatch, refuseEdit, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, onEditorTab,
|
|
240
|
+
const { rowSpansMap, selectValuesByColumn, onRangeCopy, onRangeCut, onRangeClear, onRangePaste, onPasteAtCell, inActiveRange, rangeCanClear, editingEnabled, focusedCell, editingCell, pendingByRow, settlementByRow, writeStateByRow, editSeed, editWhole, editByKey, editClosing, onEditorClosing, focusCellSync, startEditSync, cancelEdit, commitEdit, commitBatch, refuseEdit, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, onEditorTab, enterGrid, revealCell, focus, } = useGridTableInteractionModel({
|
|
237
241
|
rootRef,
|
|
238
242
|
props,
|
|
239
243
|
rows: flatRows,
|
|
@@ -346,8 +350,9 @@ function GridTableContent(given) {
|
|
|
346
350
|
editSeed: editingCell?.rowId === rowKey ? editSeed : null,
|
|
347
351
|
editWhole: editingCell?.rowId === rowKey && editWhole,
|
|
348
352
|
editByKey: editingCell?.rowId === rowKey && editByKey,
|
|
353
|
+
editClosing: editingCell?.rowId === rowKey && editClosing,
|
|
354
|
+
onEditorClosing,
|
|
349
355
|
onEditorTab,
|
|
350
|
-
onEditorEnter,
|
|
351
356
|
pendingByCol: pendingByRow.get(rowId),
|
|
352
357
|
settlementByCol: settlementByRow.get(rowId),
|
|
353
358
|
writeStateByCol: writeStateByRow.get(rowId),
|
|
@@ -39,7 +39,7 @@ export declare function GridTextEditor({ initial, seed, type, paragraph, region,
|
|
|
39
39
|
onCancel: () => void;
|
|
40
40
|
/** Commit happened via Tab — move to the next cell in reading order. */
|
|
41
41
|
onTab?: (backwards: boolean) => void;
|
|
42
|
-
/** Commit happened via Enter
|
|
42
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
43
43
|
onEnter?: () => void;
|
|
44
44
|
/** The grid's judgement of a value before it is written: its reason when it would refuse it.
|
|
45
45
|
* A refused value stays in the box with that reason. */
|
|
@@ -5,8 +5,10 @@ import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
|
5
5
|
import { OpenValueAction } from "../../editors/open-value.js";
|
|
6
6
|
import { TextEditorHost, } from "../../editors/TextEditor.js";
|
|
7
7
|
import { GridRefusal, useGridEditSession } from "./grid-edit-session.js";
|
|
8
|
-
import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER } from "./grid-editor-layer.js";
|
|
8
|
+
import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER, GRID_TYPE_IN } from "./grid-editor-layer.js";
|
|
9
9
|
import { GridFittedBox } from "./grid-fitted-box.js";
|
|
10
|
+
import { GRID_TYPED_RING } from "./GridCellOutline.js";
|
|
11
|
+
import { cx } from "../../internal/cx.js";
|
|
10
12
|
const TEXT_TYPES = new Set([
|
|
11
13
|
"text",
|
|
12
14
|
"url",
|
|
@@ -33,6 +35,6 @@ export function GridTextEditor({ initial, seed, type = "text", paragraph = false
|
|
|
33
35
|
const [stored, setStored] = useState(seed === undefined);
|
|
34
36
|
return (_jsx(EditorPanel, { session: session, title: title ?? "", anchor: null, inPlace: true, sheetOnPhone: true, children: (surface) => {
|
|
35
37
|
const editor = (_jsx(TextEditorHost, { ref: editorRef, type: type, initial: initial, seed: seed, closeOnBlur: surface === "in-place", ...(paragraph ? { multiline: true } : {}), label: typeof title === "string" ? title : undefined, check: refuse, region: region, escapeKeeps: session.keeps ?? false, form: surface === "sheet" ? "phone" : "computer", place: "cell", onRequestClose: close }));
|
|
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", { "data-grown": "", className: GRID_EDITOR_LAYER, children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, 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", { "data-grown": "", ...GRID_TYPE_IN, className: cx(GRID_EDITOR_LAYER, GRID_TYPED_RING.text), children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
|
|
37
39
|
} }));
|
|
38
40
|
}
|
|
@@ -28,7 +28,7 @@ export declare function GridValueListEditor({ field, title, initial, labels, all
|
|
|
28
28
|
onCommit: (payload: ValuesPayload) => void;
|
|
29
29
|
onCancel: () => void;
|
|
30
30
|
onTab?: (backwards: boolean) => void;
|
|
31
|
-
/** Commit happened via Enter
|
|
31
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
32
32
|
onEnter?: () => void;
|
|
33
33
|
/** `one`: a single value opened as a list of one; `initial`, `refuse` and `onCommit` take its string. */
|
|
34
34
|
holds?: "one" | "several";
|
|
@@ -25,5 +25,5 @@ export function GridValueListEditor({ field, title, initial, labels, allowEmpty
|
|
|
25
25
|
onTab,
|
|
26
26
|
onEnter,
|
|
27
27
|
});
|
|
28
|
-
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: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: () => (_jsx(ValueListEditor, { ref: listRef, field: field, label: typeof title === "string" ? title : undefined, initial: one ? listOfOne(initial) : initial, labels: labels && !one, holds: holds, seed: one ? seed : undefined, allowEmpty: allowEmpty, region: region, escapeKeeps: session.keeps ?? false, onRequestClose: close })) })] }));
|
|
28
|
+
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: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: () => (_jsx(ValueListEditor, { ref: listRef, field: field, label: typeof title === "string" ? title : undefined, initial: one ? listOfOne(initial) : initial, labels: labels && !one, holds: holds, seed: one ? seed : undefined, allowEmpty: allowEmpty, region: region, escapeKeeps: session.keeps ?? false, onRequestClose: close })) })] }));
|
|
29
29
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { type RefObject } from "react";
|
|
2
|
-
/** The
|
|
3
|
-
export
|
|
2
|
+
/** The offsets a grid editor hands the popover around the app's body. */
|
|
3
|
+
export type GridBodyPlace = {
|
|
4
|
+
sideOffset: number;
|
|
5
|
+
alignOffset: number;
|
|
6
|
+
};
|
|
7
|
+
/** The offsets a grid editor hands its panel around the app's body: over the cell, a step up and a step left of it. */
|
|
8
|
+
export declare function useGridBodyPlace(anchor: RefObject<HTMLElement | null>): GridBodyPlace;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLayoutEffect, useState } from "react";
|
|
3
|
+
import { lengthPx } from "../../internal/length.js";
|
|
3
4
|
const UNDER = 4;
|
|
5
|
+
const stepOf = (el) => lengthPx(el, "--vk-spacing");
|
|
4
6
|
export function useGridBodyPlace(anchor) {
|
|
5
|
-
const [
|
|
7
|
+
const [at, setAt] = useState(null);
|
|
6
8
|
useLayoutEffect(() => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
const el = anchor.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
const height = el.getBoundingClientRect().height, step = stepOf(el);
|
|
13
|
+
setAt((now) => (now && now.height === height && now.step === step ? now : { height, step }));
|
|
9
14
|
}, [anchor]);
|
|
10
|
-
return
|
|
15
|
+
return at ? { sideOffset: -(at.height + at.step), alignOffset: -at.step } : { sideOffset: UNDER, alignOffset: 0 };
|
|
11
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ROW_NO_TEXT_SELECT } from "../../selection/row-click.js";
|
|
2
2
|
import { cx } from "../../internal/cx.js";
|
|
3
3
|
import { GRID_CELL_HOVER_RING, GRID_CELL_HOVER_SHADOW, gridFrozenBg } from "./GridCellOutline.js";
|
|
4
|
-
import {
|
|
4
|
+
import { GRID_ONE_LINE } from "./grid-styles.js";
|
|
5
5
|
const GRID_CELL_REQUESTED = "italic opacity-80";
|
|
6
6
|
export const GRID_TITLE_LINK_CLASS = "**:data-cell-open:underline-offset-(--vk-underline-offset,2px) [&_[data-cell-open]:hover]:text-(color:--vk-fg-brand) [&_[data-cell-open]:hover]:underline";
|
|
7
7
|
export const GRID_TITLE_DATA = { "data-slot": "vk-grid-title" };
|
|
@@ -55,7 +55,7 @@ export function gridCellClassName(state) {
|
|
|
55
55
|
: "z-5"
|
|
56
56
|
: inRange
|
|
57
57
|
? "z-4"
|
|
58
|
-
: undefined, frozen && gridFrozenBg(selected,
|
|
58
|
+
: undefined, frozen && gridFrozenBg(selected, "while-scrolled", state.highlight), !focused &&
|
|
59
59
|
!editing &&
|
|
60
60
|
!inRange &&
|
|
61
61
|
!state.isTitle &&
|
|
@@ -7,6 +7,14 @@ export declare const GRID_SHEET_EXIT_MS = 500;
|
|
|
7
7
|
type Handle<P> = {
|
|
8
8
|
resolveClose: (reason: CloseReason) => CloseResolution<P>;
|
|
9
9
|
};
|
|
10
|
+
/** The cell around a grid editor, told the moment the editor starts to close: its session accepted an answer, and the
|
|
11
|
+
* popover or the sheet begins its exit. With the reason the session closed by (null where it names none), and whether
|
|
12
|
+
* the editor stood in a computer's popover, which holds the focus until its exit ends. The cell stops wearing the
|
|
13
|
+
* editing state then, not once the exit is over; a press away lets its pick go, and a close that keeps the cell takes
|
|
14
|
+
* the focus back from the popover at once. */
|
|
15
|
+
export declare const GridEditClosingContext: import("react").Context<((reason: CloseReason | null, popover: boolean) => void) | null>;
|
|
16
|
+
/** Writes every kept answer still waiting out its popover's exit, so an undo heard now takes back the answer just given. */
|
|
17
|
+
export declare function flushGridKeptAnswers(): void;
|
|
10
18
|
export type GridEditSessionArgs<P> = {
|
|
11
19
|
editorRef: RefObject<Handle<P> | null>;
|
|
12
20
|
/** Reshapes a commit before it is judged and written (a day field's timestamp trimmed to its day). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useContext, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { useAnchoredEditSession } from "../../editors/edit-session.js";
|
|
5
5
|
import { EditFieldTypeContext, EditOpensListContext, useEscapeRule } from "../../editors/escape-rule.js";
|
|
6
6
|
import { registerGridEditEscape } from "./grid-edit-escape.js";
|
|
@@ -8,25 +8,38 @@ import { useKeepInside } from "../../editors/keep-inside.js";
|
|
|
8
8
|
import { useViews } from "../../provider/context.js";
|
|
9
9
|
import { useDesktop } from "../../provider/desktop.js";
|
|
10
10
|
export const GRID_SHEET_EXIT_MS = 500;
|
|
11
|
+
export const GridEditClosingContext = createContext(null);
|
|
12
|
+
const keptFlushes = new Set();
|
|
13
|
+
export function flushGridKeptAnswers() {
|
|
14
|
+
for (const flush of [...keptFlushes])
|
|
15
|
+
flush();
|
|
16
|
+
}
|
|
17
|
+
const KEY_CLOSES = new Set(["enter", "tab", "shift-tab", "escape", "pick"]);
|
|
11
18
|
export function useGridEditSession(args) {
|
|
12
19
|
const { editorRef, mapPayload, inPlace = false } = args;
|
|
13
20
|
const desktop = useDesktop();
|
|
14
21
|
const { ports } = useViews();
|
|
22
|
+
const closing = useContext(GridEditClosingContext);
|
|
15
23
|
const [sheet] = useState(!desktop);
|
|
16
24
|
const escape = useEscapeRule(useContext(EditFieldTypeContext), useContext(EditOpensListContext));
|
|
17
25
|
const latest = useRef(args);
|
|
26
|
+
const closingRef = useRef(closing);
|
|
18
27
|
useEffect(() => {
|
|
19
28
|
latest.current = args;
|
|
29
|
+
closingRef.current = closing;
|
|
20
30
|
});
|
|
21
31
|
const viaRef = useRef(null);
|
|
32
|
+
const reasonRef = useRef(null);
|
|
22
33
|
const keptRef = useRef(null);
|
|
23
34
|
const refusedRef = useRef(null);
|
|
24
35
|
const movedRef = useRef(false);
|
|
25
36
|
const flushRef = useRef(null);
|
|
26
37
|
const leavingRef = useRef(false);
|
|
27
38
|
const stopFlush = () => {
|
|
28
|
-
if (flushRef.current)
|
|
39
|
+
if (flushRef.current) {
|
|
29
40
|
document.removeEventListener("keydown", flushRef.current, true);
|
|
41
|
+
keptFlushes.delete(flushRef.current);
|
|
42
|
+
}
|
|
30
43
|
flushRef.current = null;
|
|
31
44
|
};
|
|
32
45
|
const move = () => {
|
|
@@ -53,7 +66,7 @@ export function useGridEditSession(args) {
|
|
|
53
66
|
keptRef.current = answer;
|
|
54
67
|
if (leavingRef.current)
|
|
55
68
|
return;
|
|
56
|
-
if (sheet || (
|
|
69
|
+
if (sheet || !KEY_CLOSES.has(reasonRef.current))
|
|
57
70
|
return;
|
|
58
71
|
movedRef.current = true;
|
|
59
72
|
move();
|
|
@@ -64,6 +77,7 @@ export function useGridEditSession(args) {
|
|
|
64
77
|
stopFlush();
|
|
65
78
|
};
|
|
66
79
|
flushRef.current = flush;
|
|
80
|
+
keptFlushes.add(flush);
|
|
67
81
|
document.addEventListener("keydown", flush, true);
|
|
68
82
|
};
|
|
69
83
|
const session = useAnchoredEditSession({
|
|
@@ -81,6 +95,8 @@ export function useGridEditSession(args) {
|
|
|
81
95
|
refusedRef.current = reason;
|
|
82
96
|
if (reason !== null)
|
|
83
97
|
return { accepted: false, reason };
|
|
98
|
+
if (!leavingRef.current)
|
|
99
|
+
closingRef.current?.(reasonRef.current, !sheet && !inPlace);
|
|
84
100
|
if (inPlace && !sheet)
|
|
85
101
|
write(answer, true);
|
|
86
102
|
else
|
|
@@ -104,6 +120,7 @@ export function useGridEditSession(args) {
|
|
|
104
120
|
return;
|
|
105
121
|
leavingRef.current = false;
|
|
106
122
|
viaRef.current = reason;
|
|
123
|
+
reasonRef.current = reason;
|
|
107
124
|
session.close(reason);
|
|
108
125
|
};
|
|
109
126
|
const closeRef = useRef(close);
|
|
@@ -119,6 +136,7 @@ export function useGridEditSession(args) {
|
|
|
119
136
|
leavingRef.current = false;
|
|
120
137
|
if (session.open)
|
|
121
138
|
viaRef.current = null;
|
|
139
|
+
reasonRef.current = reason;
|
|
122
140
|
session.close(reason);
|
|
123
141
|
};
|
|
124
142
|
return { session: { ...session, close: closeFromPanel }, close, sheet };
|
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
* the cell, leftward in a right-aligned column, when its unit or country leaves the value too little room.
|
|
7
7
|
*/
|
|
8
8
|
export declare const GRID_EDITOR_LAYER = "absolute -inset-px z-2 flex min-w-0";
|
|
9
|
+
/**
|
|
10
|
+
* What a cell typed in shows: the selected cell's ring round the caret and what is typed. The layer tells ViewKit's Inline
|
|
11
|
+
* input it stands in a cell (`data-inline-input-place`, inline-input.css): no edge, ring or ground of its own, so the cell
|
|
12
|
+
* shows as it was; grown past its cell, the plain ground, never lifted. The layer's `GRID_TYPED_RING` puts the grid's own
|
|
13
|
+
* selected ring on the box, so it goes round the box as it grows. A text grows from the cell as the "In the cell" look grows
|
|
14
|
+
* it, whatever the page's text look (`data-text-editor-box`). An app's own body draws its own look.
|
|
15
|
+
*/
|
|
16
|
+
export declare const GRID_TYPE_IN: {
|
|
17
|
+
readonly "data-inline-input-place": "cell";
|
|
18
|
+
readonly "data-text-editor-box": "cell";
|
|
19
|
+
};
|
|
9
20
|
/** The least room a body's value keeps beside its unit's button or a phone's country, empty or not: a few digits and
|
|
10
21
|
* the caret. */
|
|
11
22
|
export declare const BODY_FIGURE_ROOM_PX = 48;
|
|
@@ -7,14 +7,14 @@ import { type ReactNode, type RefObject } from "react";
|
|
|
7
7
|
* cell: the grid's visible edge on that side. Past it, the value scrolls in its box.
|
|
8
8
|
* Measured as it opens, before the panel brings it into view (a child's layout effect runs first), and
|
|
9
9
|
* again at every keystroke: the input says by how much its text overflows it, and the box takes that
|
|
10
|
-
* much more. Grown, it
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* much more. Grown, it lays the plain ground (the overlay's) under itself, with no edge and no lift, so what it stands
|
|
11
|
+
* over doesn't show through, and the cell rises over the frozen columns (`data-grown`, `gridCellClassName`).
|
|
12
|
+
* A body (`edge={false}`) draws its own ground, which grows with the box, so the box lays none; its value shares the
|
|
13
13
|
* box with a unit or a country, so it keeps `room` to type in even when empty.
|
|
14
14
|
*/
|
|
15
15
|
export declare function GridFittedBox({ boxRef, edge, room, grows, children, }: {
|
|
16
16
|
boxRef: RefObject<HTMLSpanElement | null>;
|
|
17
|
-
/** The
|
|
17
|
+
/** The plain ground under the grown box: false where what it holds draws its own. */
|
|
18
18
|
edge?: boolean;
|
|
19
19
|
/** The pixels the input keeps at least, its value or not: a box that shares the cell with a unit's button. */
|
|
20
20
|
room?: number;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useLayoutEffect } from "react";
|
|
4
|
-
import { cx } from "../../internal/cx.js";
|
|
5
|
-
import { GRID_EDITING_SHADOW, GRID_GROUND } from "./grid-styles.js";
|
|
6
4
|
function roomBeside(box, grows) {
|
|
7
5
|
const at = box.getBoundingClientRect();
|
|
8
6
|
if (at.width === 0 && at.height === 0)
|
|
@@ -32,5 +30,5 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, grows = "right",
|
|
|
32
30
|
}
|
|
33
31
|
}, [boxRef, room, grows]);
|
|
34
32
|
useLayoutEffect(fit, [fit]);
|
|
35
|
-
return (_jsxs("span", { ref: boxRef, onInput: fit, className: "group/fitted relative flex h-full w-full min-w-0 shrink-0 data-grown:z-2", children: [edge && (_jsx("span", { "aria-hidden": true, className:
|
|
33
|
+
return (_jsxs("span", { ref: boxRef, onInput: fit, className: "group/fitted relative flex h-full w-full min-w-0 shrink-0 data-grown:z-2", children: [edge && (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-y-0 -inset-x-(--vk-px) -z-1 hidden rounded-sm bg-(color:--vk-overlay) group-data-grown/fitted:block" })), children] }));
|
|
36
34
|
}
|
|
@@ -69,9 +69,9 @@ export declare function GridRowHoverActions<Row>({ views, rowKey, row, selected,
|
|
|
69
69
|
* A pick-list's ▾: the cue that the value is a choice, and its one-click
|
|
70
70
|
* opener. A real button (the row's click contract lets real controls win), so
|
|
71
71
|
* clicking it opens the picker directly, with no select-first step. Drawn on the
|
|
72
|
-
* cell under the pointer,
|
|
73
|
-
*
|
|
74
|
-
* lands during the exit
|
|
72
|
+
* cell under the pointer, the same whether its picker is open or not: an open
|
|
73
|
+
* picker leaves its cell as it was. A click on it while its picker
|
|
74
|
+
* is open opens nothing (it lands during the exit and can't reopen). Never drawn on a phone,
|
|
75
75
|
* where a tap selects the cell and a second opens its editor in a sheet.
|
|
76
76
|
*/
|
|
77
77
|
export declare function GridPickerCaret({ rowKey, colId, editing, onOpen, }: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useEffect, useRef, useSyncExternalStore, } from "react";
|
|
4
|
-
import { cx } from "../../internal/cx.js";
|
|
5
4
|
import { gridRowIdFromKey } from "../core/coordinates.js";
|
|
6
5
|
import { useDesktop } from "../../provider/desktop.js";
|
|
7
6
|
import { useViews } from "../../provider/context.js";
|
|
@@ -134,7 +133,7 @@ export function GridRowHoverActions({ views, rowKey, row, selected, actions, })
|
|
|
134
133
|
}
|
|
135
134
|
export function GridPickerCaret({ rowKey, colId, editing, onOpen, }) {
|
|
136
135
|
const hovered = useGridCellHovered(rowKey, colId);
|
|
137
|
-
if (!hovered
|
|
136
|
+
if (!hovered)
|
|
138
137
|
return null;
|
|
139
138
|
return _jsx(PickerCaretButton, { editing: editing, onOpen: onOpen });
|
|
140
139
|
}
|
|
@@ -154,6 +153,6 @@ function PickerCaretButton({ editing, onOpen }) {
|
|
|
154
153
|
frame: "absolute right-1 top-1/2 h-5 w-5 -translate-y-1/2",
|
|
155
154
|
variant: "ghost",
|
|
156
155
|
size: "icon",
|
|
157
|
-
children: _jsx(icons.caretDown, { className:
|
|
156
|
+
children: _jsx(icons.caretDown, { className: "h-3 w-3" }),
|
|
158
157
|
});
|
|
159
158
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GridMenus } from "./grid-table-props.js";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { CloseReason } from "viewkitjs/fields";
|
|
3
4
|
import type { ViewsRowMenuItem } from "../../atoms/types.js";
|
|
4
5
|
import type { FieldMenus } from "../../fields/menus.js";
|
|
5
6
|
import type { ListSettingsConfig } from "../../model/column-capabilities.js";
|
|
@@ -71,6 +72,11 @@ export type GridRowProps<Row> = {
|
|
|
71
72
|
/** Told this row's key on a press anywhere on it, under `rowHighlight: "active"`; absent otherwise. */
|
|
72
73
|
onActivate?: (rowKey: string) => void;
|
|
73
74
|
editingColId: string | null;
|
|
75
|
+
/** THIS row's open editor has started to close (it accepted an answer and plays its exit): its cell stands as
|
|
76
|
+
* picked again, no longer `data-editing`. False on every row but the editing one. */
|
|
77
|
+
editClosing?: boolean;
|
|
78
|
+
/** Told when THIS row's open editor starts to close, with the reason it closed by (null where its panel names none). */
|
|
79
|
+
onEditorClosing?: (rowId: string, columnId: string, reason: CloseReason | null, popover: boolean) => void;
|
|
74
80
|
/** columnId → optimistic pending value (undefined when this row has none). */
|
|
75
81
|
pendingByCol?: Record<string, unknown>;
|
|
76
82
|
/** columnId → `requested` for a pending value saved here but not yet accepted
|
|
@@ -118,8 +124,6 @@ export type GridRowProps<Row> = {
|
|
|
118
124
|
/** Tab out of an editor → next/prev cell in reading order (grid-owned so it
|
|
119
125
|
* matches Tab-while-focused; wraps rows). */
|
|
120
126
|
onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
|
|
121
|
-
/** Enter out of an editor → advance one row down. */
|
|
122
|
-
onEditorEnter: (rowId: string, columnId: string) => void;
|
|
123
127
|
/** Type-to-replace seed: the character that opened THIS row's editor, or null.
|
|
124
128
|
* Used as the editor's initial value in place of the cell's own. */
|
|
125
129
|
editSeed?: string | null;
|
|
@@ -5,7 +5,7 @@ export declare const GRID_ONE_LINE = "grid-rows-[auto] auto-rows-[0px]";
|
|
|
5
5
|
export declare const GRID_ROW_PAD = "px-(--vk-gutter,0px)";
|
|
6
6
|
export declare const GRID_CONTENT_PAD = "pl-[calc(var(--vk-gutter,0px)+var(--vk-indent,0px))] pr-(--vk-gutter,0px)";
|
|
7
7
|
/** A part that paints the ground at every scroll, because it always stands over something — the
|
|
8
|
-
*
|
|
8
|
+
* box a type-in grows into past its cell, the header's drag ghost. The page's ground, without
|
|
9
9
|
* re-declaring its states: every host the grid mounts in carries the page's own. */
|
|
10
10
|
export declare const GRID_GROUND = "bg-(color:--vk-ground)";
|
|
11
11
|
/** The ground, only while the table is scrolled sideways (`--vk-scrolled`, 0 or 1): a pinned part covers what passes
|
|
@@ -14,10 +14,6 @@ export declare const GRID_GROUND_WHILE_SCROLLED = "bg-[color-mix(in_oklab,_var(-
|
|
|
14
14
|
/** The keyboard's mark on a part that isn't a data cell (a column name, a footer cell, a bar's name): the cells'
|
|
15
15
|
* brand ring, inset, only for focus a key put there, so a click draws nothing new. */
|
|
16
16
|
export declare const GRID_CHROME_FOCUS = "outline-none focus-visible:shadow-[var(--vk-focus-ring,inset_0_0_0_2px_var(--vk-brand))]";
|
|
17
|
-
/** THE OPEN EDITOR'S LIFT: the shadow under the picked cell's ring while it is edited, and under the box a value wider
|
|
18
|
-
* than its cell grows into. One whole `box-shadow` value, the app's `--vk-editing-shadow` (`none` turns it off);
|
|
19
|
-
* undeclared, what `shadow-lg shadow-black/20 dark:shadow-black/50` drew. */
|
|
20
|
-
export declare const GRID_EDITING_SHADOW = "shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.2),0_4px_6px_-4px_rgb(0_0_0/0.2))] dark:shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.5),0_4px_6px_-4px_rgb(0_0_0/0.5))]";
|
|
21
17
|
/**
|
|
22
18
|
* A FROZEN header cell's OWN paint — the ground down to a 2px sliver at its
|
|
23
19
|
* foot, alpha-gated on `--vk-scrolled` (0/1, from the scroll area), like the
|
|
@@ -5,6 +5,5 @@ export const GRID_CONTENT_PAD = "pl-[calc(var(--vk-gutter,0px)+var(--vk-indent,0
|
|
|
5
5
|
export const GRID_GROUND = "bg-(color:--vk-ground)";
|
|
6
6
|
export const GRID_GROUND_WHILE_SCROLLED = "bg-[color-mix(in_oklab,_var(--vk-ground)_calc(var(--vk-scrolled,0)*100%),_transparent)]";
|
|
7
7
|
export const GRID_CHROME_FOCUS = "outline-none focus-visible:shadow-[var(--vk-focus-ring,inset_0_0_0_2px_var(--vk-brand))]";
|
|
8
|
-
export const GRID_EDITING_SHADOW = "shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.2),0_4px_6px_-4px_rgb(0_0_0/0.2))] dark:shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.5),0_4px_6px_-4px_rgb(0_0_0/0.5))]";
|
|
9
8
|
export const GRID_HEADER_BG_FROZEN = "bg-[linear-gradient(to_bottom,color-mix(in_oklab,_var(--vk-ground)_calc(var(--vk-scrolled,0)*100%),_transparent)_calc(100%-2px),transparent_calc(100%-2px))]";
|
|
10
9
|
export const GRID_HEADER_BG_FROZEN_HOVER = "hover:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered)),linear-gradient(to_bottom,color-mix(in_oklab,_var(--vk-ground)_calc(var(--vk-scrolled,0)*100%),_transparent)_calc(100%-2px),transparent_calc(100%-2px))]";
|
|
@@ -6,7 +6,7 @@ import type { ListColumn } from "../../model/column-schema.js";
|
|
|
6
6
|
import { type GridEditsState } from "../core/edits-sink.js";
|
|
7
7
|
import type { GridRangeVerbs } from "./useGridRangeActions.js";
|
|
8
8
|
import { type GridChromeTarget, type GridFocusShape } from "../core/grid-focus.js";
|
|
9
|
-
export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome, setChrome, shape, toggleGroup, }: {
|
|
9
|
+
export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell, editClosing, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome, setChrome, shape, toggleGroup, }: {
|
|
10
10
|
rootRef: RefObject<HTMLDivElement | null>;
|
|
11
11
|
/** A column name, a footer cell, a bar or a checkbox holding the focus (`useGridFocus`); null: a data cell, or
|
|
12
12
|
* nothing. */
|
|
@@ -26,6 +26,10 @@ export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell
|
|
|
26
26
|
revealCell: (pos: GridCellPos, behavior: ScrollBehavior) => void;
|
|
27
27
|
focusedCell: GridCellPos | null;
|
|
28
28
|
editingCell: GridCellPos | null;
|
|
29
|
+
/** The open editor has started to close and plays its exit (`useGridTableInteractionModel`): the cell stands as
|
|
30
|
+
* picked, and the keys that move or let go of the pick are its own again. A key that opens or writes still waits for
|
|
31
|
+
* the exit, so a cell can't reopen under its closing editor. */
|
|
32
|
+
editClosing?: boolean;
|
|
29
33
|
editingEnabled: boolean;
|
|
30
34
|
/** Workspace-settings capability config — the keyboard routes ask the same effective
|
|
31
35
|
* write gate the cells do, so a lock holds here too. */
|
|
@@ -68,6 +72,5 @@ export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell
|
|
|
68
72
|
editsState?: () => GridEditsState;
|
|
69
73
|
}): {
|
|
70
74
|
onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
|
|
71
|
-
onEditorEnter: (rowId: string, columnId: string) => void;
|
|
72
75
|
enterGrid: (_which: "start" | "end", from: Element | null) => void;
|
|
73
76
|
};
|