viewkitjs 0.34.0 → 0.36.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 +173 -0
- package/MIGRATION.md +7 -0
- package/package.json +1 -1
- package/views/README.md +1 -1
- package/views/dist/atoms/Avatar.js +2 -1
- package/views/dist/atoms/RelationChip.d.ts +2 -0
- package/views/dist/atoms/RelationChip.js +5 -0
- package/views/dist/atoms/RowMenu.d.ts +1 -1
- package/views/dist/atoms/RowMenu.js +15 -3
- package/views/dist/atoms/defaults.js +2 -0
- package/views/dist/atoms/types.d.ts +40 -4
- package/views/dist/cells/relation-wrap.js +9 -2
- package/views/dist/contract.d.ts +27 -7
- package/views/dist/contract.js +25 -2
- package/views/dist/controls/avatar/avatar-mark.d.ts +4 -0
- package/views/dist/controls/avatar/avatar-mark.js +5 -0
- package/views/dist/controls/avatar/avatar.d.ts +10 -5
- package/views/dist/controls/avatar/avatar.js +12 -6
- package/views/dist/controls/avatar/looks.d.ts +1 -1
- package/views/dist/controls/avatar/looks.js +3 -0
- package/views/dist/controls/avatar/record-mark.d.ts +16 -0
- package/views/dist/controls/avatar/record-mark.js +13 -0
- package/views/dist/controls/avatar/tokens.d.ts +12 -0
- package/views/dist/controls/avatar/tokens.js +3 -0
- package/views/dist/controls/avatar.css +54 -17
- package/views/dist/controls/bulk-bar/bulk-bar.js +4 -5
- package/views/dist/controls/bulk-bar/map-selection-bar.js +2 -1
- package/views/dist/controls/compound-editor/compound-editor.d.ts +3 -0
- package/views/dist/controls/compound-editor/map-parts-body.d.ts +1 -1
- package/views/dist/controls/compound-editor/map-parts-body.js +8 -1
- package/views/dist/controls/compound-editor/name-parts.js +3 -2
- package/views/dist/controls/compound-editor/place-parts.js +3 -3
- package/views/dist/controls/compound-editor/range-parts.js +11 -10
- package/views/dist/controls/compound-editor/words.d.ts +3 -0
- package/views/dist/controls/compound-editor/words.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +22 -6
- package/views/dist/controls/customize/customize.js +154 -73
- package/views/dist/controls/customize/items.d.ts +49 -0
- package/views/dist/controls/customize/items.js +104 -0
- package/views/dist/controls/customize/map-customize-body.js +19 -15
- package/views/dist/controls/customize/words.d.ts +5 -3
- package/views/dist/controls/customize/words.js +1 -0
- package/views/dist/controls/filter-editor/block.js +5 -2
- package/views/dist/controls/filter-editor/filter-editor.d.ts +16 -1
- package/views/dist/controls/filter-editor/filter-editor.js +22 -16
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
- package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
- package/views/dist/controls/filter-editor/map-rules.js +18 -13
- package/views/dist/controls/filter-editor/parts.d.ts +1 -1
- package/views/dist/controls/filter-editor/parts.js +16 -15
- package/views/dist/controls/filter-editor/rules.d.ts +4 -4
- package/views/dist/controls/filter-editor/rules.js +6 -3
- package/views/dist/controls/filter-editor/words.d.ts +2 -0
- package/views/dist/controls/filter-editor/words.js +1 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
- package/views/dist/controls/group-editor/group-editor.js +21 -15
- package/views/dist/controls/group-editor/map-group-body.js +1 -0
- package/views/dist/controls/index.d.ts +1 -1
- package/views/dist/controls/internal/kit-words.d.ts +11 -0
- package/views/dist/controls/internal/kit-words.js +7 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
- package/views/dist/controls/internal/map-panel-controls.js +23 -6
- package/views/dist/controls/internal/menu-items.d.ts +9 -0
- package/views/dist/controls/internal/menu-items.js +97 -0
- package/views/dist/controls/internal/panel-controls.d.ts +27 -3
- package/views/dist/controls/internal/panel-controls.js +142 -13
- package/views/dist/controls/links-editor/links-editor.js +5 -7
- package/views/dist/controls/links-editor/map-links-body.d.ts +1 -1
- package/views/dist/controls/links-editor/map-links-body.js +5 -1
- package/views/dist/controls/menu/menu.d.ts +4 -1
- package/views/dist/controls/menu/menu.js +3 -2
- package/views/dist/controls/number-editor/map-number-body.js +2 -0
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/number-editor/words.d.ts +3 -0
- package/views/dist/controls/number-editor/words.js +2 -0
- package/views/dist/controls/picker/fields-frame.d.ts +5 -0
- package/views/dist/controls/picker/fields-frame.js +30 -0
- package/views/dist/controls/picker/map-fields-body.d.ts +2 -2
- package/views/dist/controls/picker/map-fields-body.js +7 -26
- package/views/dist/controls/picker/map-picker.d.ts +9 -3
- package/views/dist/controls/picker/map-picker.js +16 -3
- package/views/dist/controls/picker/picker.js +20 -10
- package/views/dist/controls/picker/rows.d.ts +9 -2
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +2 -1
- package/views/dist/controls/quick-filters/quick-filters.js +4 -4
- package/views/dist/controls/quick-filters/reminder.js +2 -2
- package/views/dist/controls/quick-filters/rules.d.ts +4 -1
- package/views/dist/controls/quick-filters/words.d.ts +2 -0
- package/views/dist/controls/quick-filters/words.js +1 -0
- package/views/dist/controls/select/map-select.d.ts +1 -1
- package/views/dist/controls/select/map-select.js +4 -1
- package/views/dist/controls/select/select.d.ts +5 -0
- package/views/dist/controls/select/select.js +11 -3
- package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
- package/views/dist/controls/sheet/bottom-sheet.js +3 -3
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
- package/views/dist/controls/sort-editor/sort-editor.js +9 -8
- package/views/dist/controls/tag/tag.js +4 -2
- package/views/dist/controls/text-editor/map-text-body.js +4 -1
- package/views/dist/controls/text-editor/text-editor.js +2 -2
- package/views/dist/controls/text-editor/words.d.ts +3 -0
- package/views/dist/controls/text-editor/words.js +1 -1
- package/views/dist/controls/toolbar/toolbar.d.ts +31 -12
- package/views/dist/controls/toolbar/toolbar.js +15 -20
- package/views/dist/controls/toolbar.css +0 -5
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +4 -2
- package/views/dist/controls/values-editor/map-values-body.d.ts +1 -2
- package/views/dist/controls/values-editor/map-values-body.js +5 -1
- package/views/dist/controls/values-editor/values-editor.js +8 -7
- package/views/dist/controls/views-list/map-views-list-body.js +9 -1
- package/views/dist/controls/views-list/rules.d.ts +1 -0
- package/views/dist/controls/views-list/rules.js +2 -2
- package/views/dist/controls/views-list/view-menu.js +2 -2
- package/views/dist/controls/views-list/words.d.ts +4 -0
- package/views/dist/controls/views-list/words.js +2 -1
- package/views/dist/display/option-badges.d.ts +17 -0
- package/views/dist/display/option-badges.js +11 -0
- package/views/dist/display/relation-link.d.ts +12 -0
- package/views/dist/display/relation-link.js +17 -0
- package/views/dist/display/relation.d.ts +1 -1
- package/views/dist/display/relation.js +10 -3
- package/views/dist/display/select.js +1 -8
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/editors/RangeEditor.d.ts +3 -0
- package/views/dist/editors/RangeEditor.js +2 -2
- package/views/dist/editors/SelectEditor.d.ts +2 -2
- package/views/dist/editors/SelectEditor.js +1 -1
- package/views/dist/editors/TextEditor.js +4 -2
- package/views/dist/editors/ValueListEditor.js +2 -1
- package/views/dist/field-row/FieldRow.js +32 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
- package/views/dist/grid/chrome/GridAddColumn.js +13 -9
- package/views/dist/grid/chrome/GridCellEditors.js +1 -1
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -1
- package/views/dist/grid/chrome/GridCellOutline.js +16 -6
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +7 -4
- package/views/dist/grid/chrome/GridFooter.d.ts +4 -1
- package/views/dist/grid/chrome/GridFooter.js +4 -4
- package/views/dist/grid/chrome/GridGroupMenu.js +39 -14
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -1
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridNumberEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +4 -1
- package/views/dist/grid/chrome/GridRangeEditor.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +11 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +4 -1
- package/views/dist/grid/chrome/GridRowActions.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +3 -2
- package/views/dist/grid/chrome/GridStructure.js +1 -1
- package/views/dist/grid/chrome/GridTable.js +32 -20
- package/views/dist/grid/chrome/GridTableSurface.js +2 -1
- package/views/dist/grid/chrome/checks.d.ts +1 -1
- package/views/dist/grid/chrome/checks.js +4 -1
- package/views/dist/grid/chrome/grid-cell-classes.d.ts +6 -2
- package/views/dist/grid/chrome/grid-cell-classes.js +10 -5
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +5 -2
- package/views/dist/grid/chrome/grid-fitted-box.js +14 -4
- package/views/dist/grid/chrome/grid-hover.d.ts +10 -2
- package/views/dist/grid/chrome/grid-hover.js +14 -4
- package/views/dist/grid/chrome/grid-row-props.d.ts +4 -0
- package/views/dist/grid/chrome/grid-rows-menu.js +9 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +16 -4
- package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
- package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
- package/views/dist/grid/grid-format-props.d.ts +1 -1
- package/views/dist/grid/grid-format-props.js +18 -5
- package/views/dist/grid/grid.css +11 -1
- package/views/dist/grid/looks.d.ts +3 -1
- package/views/dist/grid/looks.js +10 -4
- package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/views/dist/grid/useGridTableSettings.d.ts +1 -1
- package/views/dist/list/layer.d.ts +8 -0
- package/views/dist/list/layer.js +7 -0
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/menu.d.ts +5 -4
- package/views/dist/list/store.d.ts +1 -1
- package/views/dist/list/toolbar.js +47 -20
- package/views/dist/list/views.js +1 -0
- package/views/dist/panels/availability.d.ts +5 -0
- package/views/dist/panels/availability.js +4 -5
- package/views/dist/panels/customize-body.d.ts +5 -1
- package/views/dist/panels/customize-body.js +21 -12
- package/views/dist/panels/model.d.ts +14 -4
- package/views/dist/panels/react/customize-body.js +15 -3
- package/views/dist/panels/react/customize.d.ts +8 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +6 -0
- package/views/dist/panels/react/filter/FilterEditor.js +7 -0
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
- package/views/dist/panels/react/filter/filter-body.js +3 -1
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-part-body.js +2 -2
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +3 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +7 -3
- package/views/dist/panels/react/sort/SortEditor.js +3 -1
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +11 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +16 -6
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +12 -5
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +7 -3
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +18 -8
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +9 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- 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 +5 -4
- package/views/dist/panels/react/toolbar/ToolbarSort.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +6 -3
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +3 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +4 -4
- package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
- package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +3 -5
- package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
- package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +8 -3
- package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
- package/views/dist/panels/react/views-row/new-view.js +21 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/settings/layout.js +6 -38
- package/views/dist/panels/toolbar/page-resets.d.ts +17 -0
- package/views/dist/panels/toolbar/page-resets.js +62 -0
- package/views/dist/panels/toolbar/same-item.d.ts +7 -0
- package/views/dist/panels/toolbar/same-item.js +9 -0
- package/views/dist/panels/view-state.d.ts +4 -0
- package/views/dist/provider/ViewsProvider.d.ts +9 -4
- package/views/dist/provider/ViewsProvider.js +13 -2
- package/views/dist/provider/components.d.ts +109 -7
- package/views/dist/provider/components.js +1 -1
- package/views/dist/react.d.ts +2 -2
- package/views/dist/styles.css +115 -27
- package/views/dist/styles.unlayered.css +115 -27
- package/views/docs/contract.md +55 -35
- package/views/docs/controls/avatar.md +3 -0
- package/views/docs/controls/bulk-bar.md +3 -1
- package/views/docs/controls/compound-editor.md +2 -0
- package/views/docs/controls/customize.md +1 -1
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/links-editor.md +2 -0
- package/views/docs/controls/pane.md +1 -1
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/quick-filters.md +1 -1
- package/views/docs/controls/text-editor.md +1 -1
- package/views/docs/controls/values-editor.md +2 -0
- package/views/docs/guides/atoms.md +54 -3
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +4 -2
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/index.md +2 -2
- package/views/docs/install.md +198 -104
- package/views/docs/reference/controls.md +27 -24
- package/views/docs/reference/editors-range.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +6 -5
- package/views/docs/reference/list.md +27 -7
- package/views/docs/reference/looks.md +5 -5
- package/views/docs/reference/panels-react.md +15 -14
- package/views/docs/reference/panels.md +5 -5
- package/views/docs/reference/react.md +25 -11
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +22 -6
- package/views/skills/views/SKILL.md +2 -2
|
@@ -6,7 +6,7 @@ import type { RangePreset, RangeValue } from "viewkitjs/fields";
|
|
|
6
6
|
* app's parts body opens in a popover over the cell, its top on the cell's top;
|
|
7
7
|
* on a phone it opens in the sheet and the answer waits for the sheet to slide away.
|
|
8
8
|
*/
|
|
9
|
-
export declare function GridRangeEditor({ title, initial, seed, decimals, allowEmpty, suffix, bands, onCommit, onCancel, onTab, onEnter, refuse, }: {
|
|
9
|
+
export declare function GridRangeEditor({ title, initial, seed, decimals, allowEmpty, suffix, bands, min, max, onCommit, onCancel, onTab, onEnter, refuse, }: {
|
|
10
10
|
/** The field's name: the sheet's title on a phone. */
|
|
11
11
|
title: ReactNode;
|
|
12
12
|
initial: RangeValue | null;
|
|
@@ -18,6 +18,9 @@ export declare function GridRangeEditor({ title, initial, seed, decimals, allowE
|
|
|
18
18
|
suffix?: string;
|
|
19
19
|
/** The field's bands: the body lists them. */
|
|
20
20
|
bands?: readonly RangePreset[];
|
|
21
|
+
/** The field's limits (`numberBounds`): the body's ends step within them. */
|
|
22
|
+
min?: number;
|
|
23
|
+
max?: number;
|
|
21
24
|
onCommit: (payload: RangeValue) => void;
|
|
22
25
|
onCancel: () => void;
|
|
23
26
|
onTab?: (backwards: boolean) => void;
|
|
@@ -6,7 +6,7 @@ import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
|
6
6
|
import { useGridEditSession } from "./grid-edit-session.js";
|
|
7
7
|
import { bodyPanel } from "../../editors/body-panel.js";
|
|
8
8
|
import { useGridBodyPlace } from "./grid-body-place.js";
|
|
9
|
-
export function GridRangeEditor({ title, initial, seed, decimals = 0, allowEmpty = false, suffix, bands, onCommit, onCancel, onTab, onEnter, refuse, }) {
|
|
9
|
+
export function GridRangeEditor({ title, initial, seed, decimals = 0, allowEmpty = false, suffix, bands, min, max, onCommit, onCancel, onTab, onEnter, refuse, }) {
|
|
10
10
|
const panel = bodyPanel("parts", "z-90");
|
|
11
11
|
const editorRef = useRef(null);
|
|
12
12
|
const anchorRef = useRef(null);
|
|
@@ -19,6 +19,6 @@ export function GridRangeEditor({ title, initial, seed, decimals = 0, allowEmpty
|
|
|
19
19
|
onTab,
|
|
20
20
|
onEnter,
|
|
21
21
|
});
|
|
22
|
-
const editor = (_jsx(RangeEditor, { ref: editorRef, initial: initial, seed: seed, decimals: decimals, allowEmpty: allowEmpty, suffix: suffix, bands: bands, label: typeof title === "string" ? title : undefined, onRequestClose: close }));
|
|
22
|
+
const editor = (_jsx(RangeEditor, { ref: editorRef, initial: initial, seed: seed, decimals: decimals, allowEmpty: allowEmpty, suffix: suffix, bands: bands, min: min, max: max, label: typeof title === "string" ? title : undefined, onRequestClose: close }));
|
|
23
23
|
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: (surface) => (surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor) })] }));
|
|
24
24
|
}
|
|
@@ -14,7 +14,7 @@ import { gridCellCutOff } from "./cell-cut-off.js";
|
|
|
14
14
|
import { countRowRender } from "../../model/render-count.js";
|
|
15
15
|
import { GridRowCells } from "./GridRowCells.js";
|
|
16
16
|
import { gridCellLinkAt, gridControlAt } from "./grid-cell-link.js";
|
|
17
|
-
import { useGridRowHeld, useGridRowHoverHandlers } from "./grid-hover.js";
|
|
17
|
+
import { GridRowHighlightContext, useGridRowHeld, useGridRowHoverHandlers } from "./grid-hover.js";
|
|
18
18
|
import { useViews } from "../../provider/context.js";
|
|
19
19
|
import { isDesktopNow } from "../../provider/desktop.js";
|
|
20
20
|
import { gridFocusOnPress } from "./useGridFocus.js";
|
|
@@ -31,6 +31,12 @@ function GridRowInner(props) {
|
|
|
31
31
|
const More = icons.more;
|
|
32
32
|
const { row, id, columns, selectable, selected, selectedAbove, selecting, toggle, toggleRange, rowClassName, rowHref, onOpenRow, onPrefetchRow, editingEnabled, focusedColId, editingColId, onFocusCell, rowKey, onStartEdit, onRefuseEdit, rowWritable = true, onExtendCell, onAddCell, ariaRowIndex, ariaLevel, ariaPosInSet, ariaSetSize, ariaTailIndex, } = props;
|
|
33
33
|
const href = rowHref?.(row);
|
|
34
|
+
const offersMenu = selectable ||
|
|
35
|
+
!!props.contextMenu ||
|
|
36
|
+
!!props.rowMenuReshape ||
|
|
37
|
+
!!rowHref ||
|
|
38
|
+
!!props.onRowDelete ||
|
|
39
|
+
!!props.rowActions?.some((action) => !!action.onClick);
|
|
34
40
|
const canEdit = (col) => editingEnabled && rowWritable && gridColumnHasEditor(col) && columnEffectiveWritable(col, props.listConfig);
|
|
35
41
|
const refuse = (columnId) => (rowWritable ? onRefuseEdit?.(columnId) : onRefuseEdit?.(columnId, false));
|
|
36
42
|
const whole = (col, cell) => isWholeTextColumn(col) && gridCellCutOff(cell);
|
|
@@ -113,6 +119,7 @@ function GridRowInner(props) {
|
|
|
113
119
|
const handlePointerDown = (e) => {
|
|
114
120
|
if (e.button !== 0)
|
|
115
121
|
return;
|
|
122
|
+
props.onActivate?.(rowKey);
|
|
116
123
|
if (e.target.closest?.('[data-slot="vk-grid-name-check"]'))
|
|
117
124
|
return;
|
|
118
125
|
gridFocusOnPress(e, '[data-slot="vk-grid-cell"]');
|
|
@@ -126,6 +133,7 @@ function GridRowInner(props) {
|
|
|
126
133
|
const rest = useRestIntent(onPrefetchRow ? () => onPrefetchRow(row) : undefined, (target) => shouldPrefetchGridRow(target));
|
|
127
134
|
const hover = useGridRowHoverHandlers(rowKey);
|
|
128
135
|
const held = useGridRowHeld(rowKey);
|
|
136
|
+
const highlight = useContext(GridRowHighlightContext);
|
|
129
137
|
const aimMenu = useContext(GridRowMenuAimContext);
|
|
130
138
|
const handleMouseDown = (e) => {
|
|
131
139
|
if (e.button === 1) {
|
|
@@ -139,13 +147,13 @@ function GridRowInner(props) {
|
|
|
139
147
|
if (selectable)
|
|
140
148
|
preventShiftTextSelect(e);
|
|
141
149
|
};
|
|
142
|
-
return (_jsxs("div", { "data-slot": "vk-grid-row", "data-row-id": rowKey, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, "aria-posinset": ariaPosInSet, "aria-setsize": ariaSetSize, "aria-selected": selectable ? selected : undefined, "data-selected": selected ? "" : undefined, "data-hovered": held ? "" : undefined, onPointerDown: handlePointerDown, onPointerOver: (e) => {
|
|
150
|
+
return (_jsxs("div", { "data-slot": "vk-grid-row", "data-row-id": rowKey, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, "aria-posinset": ariaPosInSet, "aria-setsize": ariaSetSize, "aria-selected": selectable ? selected : undefined, "data-selected": selected ? "" : undefined, "data-hovered": held ? "" : undefined, "data-active": props.active ? "" : undefined, onPointerDown: handlePointerDown, onPointerOver: (e) => {
|
|
143
151
|
rest.onPointerOver(e);
|
|
144
152
|
hover.onPointerOver(e);
|
|
145
153
|
}, onPointerLeave: (e) => {
|
|
146
154
|
rest.onPointerLeave();
|
|
147
155
|
hover.onPointerLeave(e);
|
|
148
|
-
}, onMouseDown: handleMouseDown, onClick: handleClick, onDoubleClick: handleDoubleClick, onContextMenu: aimMenu ? (event) => aimMenu(rowKey, event) : undefined, className: gridRowClassName({ selected, selectable, hostClass: rowClassName?.(row) }), children: [selected && !selectedAbove && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("top") }), selected && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("bottom") }), selectable && props.checkColumnId != null ? (_jsx(GridRailSpacer, { selecting: selecting, bordered: true, shadow: false, cell: "row" })) : selectable ? (_jsx(GridRowCheck, { selecting: selecting, checked: selected, revealed: selected, onChange: (next, shift) => (shift ? toggleRange(id) : toggle(id, next)), "aria-label": messages({ key: "views.grid.select-row" }) })) : (_jsx(GridRailSpacer, { selecting: false, bordered: true, shadow: false })), _jsx(GridRowCells, { props: props }), _jsx("div", { "data-slot": "vk-grid-tail", role: "gridcell", "aria-colindex": ariaTailIndex, style: GRID_TAIL_PLACE, className: "flex h-(--vk-row-h) items-center border-b border-(color:--vk-border-subtle) pl-(--vk-tail-pl,var(--vk-px))", children: drawGridButton(views, {
|
|
156
|
+
}, onMouseDown: handleMouseDown, onClick: handleClick, onDoubleClick: handleDoubleClick, onContextMenu: aimMenu ? (event) => aimMenu(rowKey, event) : undefined, className: gridRowClassName({ selected, selectable, hostClass: rowClassName?.(row), highlight }), children: [selected && !selectedAbove && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("top") }), selected && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("bottom") }), selectable && props.checkColumnId != null ? (_jsx(GridRailSpacer, { selecting: selecting, bordered: true, shadow: false, cell: "row" })) : selectable ? (_jsx(GridRowCheck, { selecting: selecting, checked: selected, revealed: selected, onChange: (next, shift) => (shift ? toggleRange(id) : toggle(id, next)), "aria-label": messages({ key: "views.grid.select-row" }) })) : (_jsx(GridRailSpacer, { selecting: false, bordered: true, shadow: false })), _jsx(GridRowCells, { props: props }), _jsx("div", { "data-slot": "vk-grid-tail", role: "gridcell", "aria-colindex": ariaTailIndex, style: GRID_TAIL_PLACE, className: "flex h-(--vk-row-h) items-center border-b border-(color:--vk-border-subtle) pl-(--vk-tail-pl,var(--vk-px))", children: offersMenu && drawGridButton(views, {
|
|
149
157
|
tabIndex: -1,
|
|
150
158
|
"data-slot": "vk-grid-row-more",
|
|
151
159
|
"aria-label": messages({ key: "views.grid.row-menu" }),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MouseEvent as ReactMouseEvent, ReactNode } from "react";
|
|
2
2
|
import type { ListCellAction } from "../../model/column-schema.js";
|
|
3
|
+
import { type GridRowHighlight } from "./GridCellOutline.js";
|
|
3
4
|
import { type GridButtonViews } from "./grid-button.js";
|
|
4
5
|
/**
|
|
5
6
|
* Small icon-button affordances inside a grid row, and the lane that hosts them.
|
|
@@ -26,12 +27,14 @@ export declare function GridActionButton({ views, variant, label, onClick, tabIn
|
|
|
26
27
|
className?: string;
|
|
27
28
|
children: ReactNode;
|
|
28
29
|
}): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
29
|
-
export declare function GridRowActions<Row>({ views, row, actions, selected, }: {
|
|
30
|
+
export declare function GridRowActions<Row>({ views, row, actions, selected, highlight, }: {
|
|
30
31
|
/** The provider's Button and who draws, handed down from the row's cells. */
|
|
31
32
|
views: GridButtonViews;
|
|
32
33
|
row: Row;
|
|
33
34
|
actions: ListCellAction<Row>[];
|
|
34
35
|
/** This row is selected — the backing carries its tint. */
|
|
35
36
|
selected?: boolean;
|
|
37
|
+
/** Which row the grid tints (`rowHighlight`): the backing repaints the row's tint by the same rule. */
|
|
38
|
+
highlight?: GridRowHighlight;
|
|
36
39
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
37
40
|
export {};
|
|
@@ -19,10 +19,10 @@ export function GridActionButton({ views, variant = "bare", label, onClick, tabI
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
const LANE_RAMP = "linear-gradient(to right, transparent 0, rgb(0 0 0) 2rem)";
|
|
22
|
-
export function GridRowActions({ views, row, actions, selected = false, }) {
|
|
22
|
+
export function GridRowActions({ views, row, actions, selected = false, highlight = "hover", }) {
|
|
23
23
|
if (actions.length === 0)
|
|
24
24
|
return null;
|
|
25
|
-
return (_jsxs("span", { className: "pointer-events-none absolute inset-y-0 right-0 hidden group-data-desktop/gridtable:flex items-center gap-1 pl-8 pr-(--vk-px)", children: [_jsx("span", { "aria-hidden": true, className: cx("absolute inset-0", gridFrozenBg(selected)), style: { maskImage: LANE_RAMP, WebkitMaskImage: LANE_RAMP } }), actions.map((a) => {
|
|
25
|
+
return (_jsxs("span", { className: "pointer-events-none absolute inset-y-0 right-0 hidden group-data-desktop/gridtable:flex items-center gap-1 pl-8 pr-(--vk-px)", children: [_jsx("span", { "aria-hidden": true, className: cx("absolute inset-0", gridFrozenBg(selected, undefined, highlight)), style: { maskImage: LANE_RAMP, WebkitMaskImage: LANE_RAMP } }), actions.map((a) => {
|
|
26
26
|
const glyph = a.icon(row);
|
|
27
27
|
if (!glyph)
|
|
28
28
|
return null;
|
|
@@ -16,7 +16,7 @@ import { isEmptyValue } from "../core/value-equality.js";
|
|
|
16
16
|
import { gridBooleanMode, columnEffectiveWritable, columnLabel } from "../../model/column-capabilities.js";
|
|
17
17
|
import { gridColumnInspectable, gridTextOpensBox, isWholeTextColumn } from "../../model/column-inspect.js";
|
|
18
18
|
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
19
|
-
import { GridHoverContext, GridPickerCaret, GridRowHoverActions } from "./grid-hover.js";
|
|
19
|
+
import { GridHoverContext, GridPickerCaret, GridRowHighlightContext, GridRowHoverActions } from "./grid-hover.js";
|
|
20
20
|
import { GridRowGlyph } from "./GridRowGlyph.js";
|
|
21
21
|
import { GridNameCheck } from "./checks.js";
|
|
22
22
|
import { SelectCheckbox } from "../../selection/SelectCheckbox.js";
|
|
@@ -30,6 +30,7 @@ export function GridRowCells({ props }) {
|
|
|
30
30
|
const { conventions, icons, messages, components, oneValue } = views;
|
|
31
31
|
const booleanCheckbox = components.Checkbox;
|
|
32
32
|
const hoverStore = useContext(GridHoverContext);
|
|
33
|
+
const highlight = useContext(GridRowHighlightContext);
|
|
33
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, onEditorEnter, editSeed, editWhole = false, editByKey = false, onCommitCell, onCancelEdit, onOpenRelation: onOpenRelationValue, entityIcon, commands, ariaColOffset = 0, } = props;
|
|
34
35
|
const writes = (column) => editingEnabled && rowWritable && columnEffectiveWritable(column, listConfig);
|
|
35
36
|
const canEdit = (column) => writes(column) && gridColumnHasEditor(column);
|
|
@@ -137,8 +138,8 @@ export function GridRowCells({ props }) {
|
|
|
137
138
|
editing,
|
|
138
139
|
inRange: !!span,
|
|
139
140
|
selected,
|
|
140
|
-
lastColumn: i === columns.length - 1,
|
|
141
141
|
verticalBorders,
|
|
142
|
+
highlight,
|
|
142
143
|
settlement,
|
|
143
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 })), (focused || editing) && (_jsx(GridCellOutline, { editing: editing })), 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 &&
|
|
144
145
|
(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: [
|
|
@@ -51,7 +51,7 @@ function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks
|
|
|
51
51
|
: "mt-(--vk-group-gap,calc(var(--spacing)*5))"
|
|
52
52
|
: "mt-(--vk-group-gap,calc(var(--spacing)*5)) first:mt-0", children: [_jsx(StuckMarker, {}), _jsxs("div", { "data-slot": "vk-grid-group-head", className: oneHead
|
|
53
53
|
? "sticky top-(--vk-head-h) z-30 flow-root data-[stuck=true]:bg-(color:--vk-ground)"
|
|
54
|
-
: "sticky top-0 z-30 data-[stuck=true]:bg-(color:--vk-ground)", children: [_jsx("div", { "data-slot": "vk-grid-group-header", role: "row", "aria-rowindex": barIndex, "aria-level": 1, "aria-expanded": !collapsed, className: cx("group/gridlabel [position:var(--vk-pin,sticky)] left-(--vk-sx,0px) mb-1.5 flex h-(--vk-label-h) w-max max-w-[100cqw] select-none items-center gap-2", GRID_ROW_PAD), children: _jsxs("div", { "data-bar-name": true, tabIndex: -1, role: "gridcell", "aria-colindex": 1, "aria-colspan": ariaColCount, className: cx("flex min-w-0 items-center gap-2 rounded-sm", GRID_CHROME_FOCUS), children: [drawGridButton(views, {
|
|
54
|
+
: "sticky top-0 z-30 data-[stuck=true]:bg-(color:--vk-ground)", children: [_jsx("div", { "data-slot": "vk-grid-group-header", role: "row", "aria-rowindex": barIndex, "aria-level": 1, "aria-expanded": !collapsed, className: cx("group/gridlabel [position:var(--vk-pin,sticky)] left-(--vk-sx,0px) mb-1.5 flex h-(--vk-label-h) w-max max-w-[100cqw] select-none items-center gap-2", GRID_ROW_PAD), children: _jsxs("div", { "data-bar-name": true, tabIndex: -1, role: "gridcell", "aria-colindex": 1, "aria-colspan": ariaColCount, className: cx("relative flex min-w-0 items-center gap-2 rounded-sm", GRID_CHROME_FOCUS), children: [drawGridButton(views, {
|
|
55
55
|
frame: cx("h-6 w-6 shrink-0", foldOverChecks && "ml-(--vk-px)"),
|
|
56
56
|
variant: "ghost",
|
|
57
57
|
size: "icon",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useContext, useDeferredValue, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
4
|
-
import { createGridHoverStore, GridHoverContext, useAnyHover, useGridHeldHover } from "./grid-hover.js";
|
|
4
|
+
import { createGridHoverStore, GridHoverContext, GridRowHighlightContext, useAnyHover, useGridHeldHover } from "./grid-hover.js";
|
|
5
5
|
import { GridFitContext } from "./useGridFittedWidths.js";
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
7
|
import { GridRailProbe, useGridRailReveal } from "./useGridRailReveal.js";
|
|
@@ -255,6 +255,16 @@ function GridTableContent(given) {
|
|
|
255
255
|
revealCell,
|
|
256
256
|
desktopQuery,
|
|
257
257
|
});
|
|
258
|
+
const highlight = props.rowHighlight ?? "hover";
|
|
259
|
+
const [activeRow, setActiveRow] = useState(null);
|
|
260
|
+
const pickedRow = focusedCell?.rowId ?? null;
|
|
261
|
+
const [seenPick, setSeenPick] = useState(pickedRow);
|
|
262
|
+
if (pickedRow !== seenPick) {
|
|
263
|
+
setSeenPick(pickedRow);
|
|
264
|
+
if (pickedRow != null)
|
|
265
|
+
setActiveRow(pickedRow);
|
|
266
|
+
}
|
|
267
|
+
const onActivate = highlight === "active" ? setActiveRow : undefined;
|
|
258
268
|
const railRow = focus.chrome?.kind === "rail" ? focus.chrome.rowKey : undefined;
|
|
259
269
|
const keptFor = (groupKey) => {
|
|
260
270
|
const kept = [];
|
|
@@ -330,6 +340,8 @@ function GridTableContent(given) {
|
|
|
330
340
|
listConfig,
|
|
331
341
|
rowWritable: props.rowWritable?.(row) ?? true,
|
|
332
342
|
focusedColId: focusedCell?.rowId === rowKey ? focusedCell.columnId : null,
|
|
343
|
+
active: onActivate != null && activeRow === rowKey,
|
|
344
|
+
onActivate,
|
|
333
345
|
editingColId: editingCell?.rowId === rowKey ? editingCell.columnId : null,
|
|
334
346
|
editSeed: editingCell?.rowId === rowKey ? editSeed : null,
|
|
335
347
|
editWhole: editingCell?.rowId === rowKey && editWhole,
|
|
@@ -379,24 +391,24 @@ function GridTableContent(given) {
|
|
|
379
391
|
const pinFooter = props.pinFooter && footerKey.includes("1")
|
|
380
392
|
? { pin: grouped ? "group" : "foot", flush: footerKey.endsWith("1") }
|
|
381
393
|
: undefined;
|
|
382
|
-
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, pageOnly: paged, pin: pinFooter?.pin }));
|
|
394
|
+
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, pageOnly: paged, pin: pinFooter?.pin, verticalBorders: verticalBorders }));
|
|
383
395
|
const groupCheckbox = (items) => pickOnPhone ? (_jsx(GridHeadCheckBox, { ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) })) : (_jsx(GridHeadCheck, { selecting: selecting, ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) }));
|
|
384
|
-
return (_jsx(EditLeaveContext.Provider, { value: leaveScope, children: _jsx(GridFitContext.Provider, { value: fit, children: _jsx(GridHoverContext.Provider, { value: hoverStore, children: _jsx(GridRowWindowContext.Provider, { value: rowWindow.store, children: _jsx(GridTableSurface, { rootRef: rootRef, empty: empty, desktop: !phone, areaRef: areaRef, panRef: panRef, boxes: boxes, minWidth: minWidth, columnsTemplate: gridTemplate, gridAria: empty
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
396
|
+
return (_jsx(EditLeaveContext.Provider, { value: leaveScope, children: _jsx(GridFitContext.Provider, { value: fit, children: _jsx(GridHoverContext.Provider, { value: hoverStore, children: _jsx(GridRowHighlightContext.Provider, { value: highlight, children: _jsx(GridRowWindowContext.Provider, { value: rowWindow.store, children: _jsx(GridTableSurface, { rootRef: rootRef, empty: empty, desktop: !phone, areaRef: areaRef, panRef: panRef, boxes: boxes, minWidth: minWidth, columnsTemplate: gridTemplate, gridAria: empty
|
|
397
|
+
? { role: "grid", rowCount: 2, colCount: ariaTailIndex }
|
|
398
|
+
: { role: aria.role, rowCount: aria.rowCount, colCount: ariaTailIndex }, style: { ...widthVarsStyle, ...scaleVarsStyle }, selecting: selecting, pinFooter: pinFooter, railRootProps: rail.rootProps, onPointerDown: (event) => {
|
|
399
|
+
longPress.onPointerDown(event);
|
|
400
|
+
if (checkDrag.tryArm(event))
|
|
401
|
+
return;
|
|
402
|
+
handleRootPointerDown(event);
|
|
403
|
+
}, onPointerDownCapture: handleRootPointerDownCapture, onClickCapture: (event) => {
|
|
404
|
+
if (checkDrag.consumeDrag() || longPress.consumeClick()) {
|
|
405
|
+
event.preventDefault();
|
|
406
|
+
event.stopPropagation();
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
handleRootClickCapture(event);
|
|
410
|
+
}, railProbe: _jsx(GridRailProbe, { probeRef: rail.probeRef }), onGuardFocus: (which, from) => {
|
|
411
|
+
if (!settlingFrom())
|
|
412
|
+
enterGrid(which, from);
|
|
413
|
+
}, body: _jsx(GridBody, { empty: empty, emptyState: emptyState, grouped: grouped, oneHead: oneHead, groups: groups, rows: flatRows, selectable: selectable, selecting: selecting, phoneChecks: pickOnPhone, foldOverChecks: foldOverChecks, 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, menus: props.menus, figures: bandFigures, countNoun: countNoun, renderHeader: header, renderGroupCheckbox: groupCheckbox, selectGroup: groupSelection, renderRow: renderRow, wrapRows: wrapRows, renderFooter: footer, keptFor: keptFor, barIndexOf: aria.barIndex, ariaColCount: ariaTailIndex }), loadMore: !paged && loadMore?.hasMore ? _jsx(LoadMore, { onReveal: loadMore.onReveal, label: loadMore.label }) : undefined, pager: paged ? _jsx(GridPager, { pages: pages, rowsOnPage: total }) : undefined, selectionBar: selection?.renderBar?.(sel, batchApi) }) }) }) }) }) }));
|
|
402
414
|
}
|
|
@@ -5,6 +5,7 @@ import { cx } from "../../internal/cx.js";
|
|
|
5
5
|
import { BarRoomContext } from "../../selection/bar-room.js";
|
|
6
6
|
import { GRID_BLEED } from "./grid-styles.js";
|
|
7
7
|
import { useBarRoom } from "./useBarRoom.js";
|
|
8
|
+
import { GRID_HEIGHTS } from "./useGridScaleStyles.js";
|
|
8
9
|
export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selecting, minWidth, columnsTemplate, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, pager, selectionBar, onGuardFocus, gridAria, empty, pinFooter, desktop = true, }) {
|
|
9
10
|
const endGuardRef = useRef(null);
|
|
10
11
|
const { room, ownBarRef } = useBarRoom(selecting, rootRef, endGuardRef);
|
|
@@ -19,7 +20,7 @@ export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selec
|
|
|
19
20
|
paddingBottom: footAt && pinFooter?.flush ? footAt : `calc(${foot} + 0.5rem)`,
|
|
20
21
|
...(footAt ? { "--vk-foot-at": footAt } : {}),
|
|
21
22
|
}, children: [body, loadMore ? (_jsx("div", { role: "row", children: _jsx("div", { role: "gridcell", "aria-colspan": gridAria?.colCount, children: loadMore }) })) : null] }));
|
|
22
|
-
const frame = (_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", "data-empty": empty ? "" : undefined, "data-desktop": desktop ? "" : undefined, ...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: {
|
|
23
|
+
const frame = (_jsxs("div", { ref: rootRef, style: style, tabIndex: -1, className: cx("group/gridtable relative isolate flex h-full min-h-0 flex-1 flex-col animate-fade-in outline-none", GRID_HEIGHTS), "data-slot": "vk-grid", "data-empty": empty ? "" : undefined, "data-desktop": desktop ? "" : undefined, ...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: {
|
|
23
24
|
overflowX: "hidden",
|
|
24
25
|
overflowY: "auto",
|
|
25
26
|
minWidth,
|
|
@@ -7,7 +7,7 @@ export declare function GridFrozenEdge(): import("react/jsx-runtime").JSX.Elemen
|
|
|
7
7
|
/** Empty rail segment — keeps the opaque lane continuous across the header and
|
|
8
8
|
* footer rows, which have no checkbox of their own. `bordered` follows whether
|
|
9
9
|
* that surface's own cells draw a bottom rule: the header's do, the footer's
|
|
10
|
-
*
|
|
10
|
+
* only under the column lines (`verticalBorders`). */
|
|
11
11
|
export declare function GridRailSpacer({ selecting, bordered, shadow, cell, }: {
|
|
12
12
|
selecting: boolean;
|
|
13
13
|
bordered?: boolean;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
3
4
|
import { useViews } from "../../provider/context.js";
|
|
4
5
|
import { cx } from "../../internal/cx.js";
|
|
5
6
|
import { gridFrozenBg } from "./GridCellOutline.js";
|
|
7
|
+
import { GridRowHighlightContext } from "./grid-hover.js";
|
|
6
8
|
import { GRID_CONTENT_PAD, GRID_GROUND_WHILE_SCROLLED } from "./grid-styles.js";
|
|
7
9
|
import { GRID_RAIL_PLACE } from "./grid-columns-template.js";
|
|
8
10
|
import { SelectCheckbox } from "../../selection/SelectCheckbox.js";
|
|
@@ -23,8 +25,9 @@ export function GridFrozenEdge() {
|
|
|
23
25
|
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"), children: _jsx(FrozenShadow, {}) }) }));
|
|
24
26
|
}
|
|
25
27
|
function RailSlot({ shadow = true, selecting, selected = false, bordered = false, reveal, cell, children, }) {
|
|
28
|
+
const highlight = useContext(GridRowHighlightContext);
|
|
26
29
|
const stands = children ? (reveal === "head" ? "head" : "row") : cell;
|
|
27
|
-
return (_jsxs("div", { "data-slot": "vk-grid-rail", role: stands === "head" ? "columnheader" : stands ? "gridcell" : undefined, "aria-colindex": stands ? 1 : undefined, "aria-hidden": stands ? undefined : true, style: GRID_RAIL_PLACE, className: RAIL_HOLD, "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-(--vk-duration,150ms)", "before:pointer-events-none before:absolute before:inset-0 before:content-['']", gridFrozenBg(selected, "before"), "before:opacity-[calc(var(--vk-frozen-on,0)*var(--vk-scrolled,0))] before:transition-opacity before:duration-(--vk-duration,150ms)", reveal && HOVER_RAISE[reveal].backing, "group-data-[rail=on]/gridtable:before:opacity-(--vk-scrolled,0)", bordered &&
|
|
30
|
+
return (_jsxs("div", { "data-slot": "vk-grid-rail", role: stands === "head" ? "columnheader" : stands ? "gridcell" : undefined, "aria-colindex": stands ? 1 : undefined, "aria-hidden": stands ? undefined : true, style: GRID_RAIL_PLACE, className: RAIL_HOLD, "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-(--vk-duration,150ms)", "before:pointer-events-none before:absolute before:inset-0 before:content-['']", gridFrozenBg(selected, "before", highlight), "before:opacity-[calc(var(--vk-frozen-on,0)*var(--vk-scrolled,0))] before:transition-opacity before:duration-(--vk-duration,150ms)", reveal && HOVER_RAISE[reveal].backing, "group-data-[rail=on]/gridtable:before:opacity-(--vk-scrolled,0)", bordered &&
|
|
28
31
|
"after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:content-[''] after:bg-(color:--vk-border-subtle)"), children: children ? (_jsx("span", { "data-row-check": true, className: "relative flex h-full items-center", children: children })) : null }), shadow && _jsx(FrozenShadow, {})] }));
|
|
29
32
|
}
|
|
30
33
|
export function GridRailSpacer({ selecting, bordered = false, shadow = true, cell, }) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FieldSettlement } from "viewkitjs/fields";
|
|
2
|
+
import { type GridRowHighlight } from "./GridCellOutline.js";
|
|
2
3
|
import type { GridWriteState } from "../core/write-states.js";
|
|
3
4
|
/**
|
|
4
5
|
* One body cell's class string.
|
|
@@ -21,10 +22,11 @@ export type GridCellClassState = {
|
|
|
21
22
|
inRange: boolean;
|
|
22
23
|
/** The row is selected (frozen cells repaint the selection tint). */
|
|
23
24
|
selected: boolean;
|
|
25
|
+
/** Which row the grid tints (`rowHighlight`): a frozen cell repaints the row's tint by the same rule. */
|
|
26
|
+
highlight?: GridRowHighlight;
|
|
24
27
|
/** The cell opens a pick-list (select, relation, chips): its ▾ is placed by the cell's edges. */
|
|
25
28
|
picker?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
lastColumn: boolean;
|
|
29
|
+
/** The lines between the columns: every cell's right border, the last column's included, so the line closes the table. */
|
|
28
30
|
verticalBorders: boolean;
|
|
29
31
|
/** The value is saved here but its provider has not accepted it yet (spec
|
|
30
32
|
* §11.2) — the one pending state the grid draws, beside `data-settlement`. */
|
|
@@ -93,4 +95,6 @@ export declare function gridRowClassName(state: {
|
|
|
93
95
|
selected: boolean;
|
|
94
96
|
selectable: boolean;
|
|
95
97
|
hostClass?: string;
|
|
98
|
+
/** Which row tints (`rowHighlight`): the one under the pointer or held there, or the active row (`data-active`) alone. */
|
|
99
|
+
highlight?: GridRowHighlight;
|
|
96
100
|
}): string;
|
|
@@ -39,7 +39,7 @@ export function gridCellStates(state) {
|
|
|
39
39
|
}
|
|
40
40
|
export function gridCellClassName(state) {
|
|
41
41
|
const { focused, editing, inRange, frozen, selected } = state;
|
|
42
|
-
return cx(state.settlement === "requested" && GRID_CELL_REQUESTED, "group/gridcell", "outline-none", "data-invalid:outline-solid data-invalid:outline-(length:--vk-border-width,1px) data-invalid:-outline-offset-(--vk-border-width,1px) data-invalid:outline-(color:--vk-border-danger,var(--vk-danger))", "flex min-w-0 border-b border-r border-(color:--vk-border-subtle) px-(--vk-px) text-(length:--vk-text)", "h-(--vk-row-h) items-center whitespace-nowrap", "scroll-mt-(--vk-scroll-mt)", "scroll-ml-[calc(var(--vk-rail-w)+var(--vk-frozen-w,0px))]",
|
|
42
|
+
return cx(state.settlement === "requested" && GRID_CELL_REQUESTED, "group/gridcell", "outline-none", "data-invalid:outline-solid data-invalid:outline-(length:--vk-border-width,1px) data-invalid:-outline-offset-(--vk-border-width,1px) data-invalid:outline-(color:--vk-border-danger,var(--vk-danger))", "flex min-w-0 border-b border-r border-(color:--vk-border-subtle) px-(--vk-px) text-(length:--vk-text)", "h-(--vk-row-h) items-center whitespace-nowrap", "scroll-mt-(--vk-scroll-mt)", "scroll-ml-[calc(var(--vk-rail-w)+var(--vk-frozen-w,0px))]", !state.verticalBorders && "border-r-transparent", state.align === "right" && "justify-end text-right tabular-nums", state.align === "center" && "justify-center text-center", frozen
|
|
43
43
|
? "[position:var(--vk-pin,sticky)]"
|
|
44
44
|
: focused || editing || inRange || state.isTitle || state.picker
|
|
45
45
|
? "relative"
|
|
@@ -55,7 +55,7 @@ export function gridCellClassName(state) {
|
|
|
55
55
|
: "z-5"
|
|
56
56
|
: inRange
|
|
57
57
|
? "z-4"
|
|
58
|
-
: undefined, frozen && gridFrozenBg(selected, editing ? undefined : "while-scrolled"), editing && GRID_GROUND, !focused &&
|
|
58
|
+
: undefined, frozen && gridFrozenBg(selected, editing ? undefined : "while-scrolled", state.highlight), editing && GRID_GROUND, !focused &&
|
|
59
59
|
!editing &&
|
|
60
60
|
!inRange &&
|
|
61
61
|
!state.isTitle &&
|
|
@@ -63,8 +63,13 @@ export function gridCellClassName(state) {
|
|
|
63
63
|
}
|
|
64
64
|
export function gridRowClassName(state) {
|
|
65
65
|
const { selected, selectable, hostClass } = state;
|
|
66
|
+
const active = state.highlight === "active";
|
|
66
67
|
const hostPaintsGround = hostClass != null && /(?:^|\s)bg-/.test(hostClass);
|
|
67
|
-
return cx("group/gridrow relative grid grid-cols-(--vk-cols) cursor-pointer pl-[calc(var(--vk-gutter,0px)+var(--vk-indent,0px))] pr-(--vk-gutter,0px)", GRID_ONE_LINE, selectable && ROW_NO_TEXT_SELECT,
|
|
68
|
-
?
|
|
69
|
-
|
|
68
|
+
return cx("group/gridrow relative grid grid-cols-(--vk-cols) cursor-pointer pl-[calc(var(--vk-gutter,0px)+var(--vk-indent,0px))] pr-(--vk-gutter,0px)", GRID_ONE_LINE, selectable && ROW_NO_TEXT_SELECT, active
|
|
69
|
+
? selected
|
|
70
|
+
? "data-active:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent))]"
|
|
71
|
+
: "data-active:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))]"
|
|
72
|
+
: selected
|
|
73
|
+
? "hover:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent))] data-hovered:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent))]"
|
|
74
|
+
: "hover:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))] data-hovered:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))]", selected && !hostPaintsGround && "bg-(color:--vk-brand-subtlest)", hostClass);
|
|
70
75
|
}
|
|
@@ -3,7 +3,8 @@ import { type ReactNode, type RefObject } from "react";
|
|
|
3
3
|
* THE IN-PLACE EDITOR'S BOX, AS WIDE AS WHAT IS TYPED IN IT — an amount and its unit, or a line of
|
|
4
4
|
* text (a link, an email, a phone, a domain, plain text). It is the cell's width until the value doesn't
|
|
5
5
|
* fit; then it grows past the cell, away from the side the column aligns to (a right-aligned column's
|
|
6
|
-
* box grows left, its amount still flush with the column's edge; a text's grows right),
|
|
6
|
+
* box grows left, its amount still flush with the column's edge; a text's grows right), as far as the room beside the
|
|
7
|
+
* cell: the grid's visible edge on that side. Past it, the value scrolls in its box.
|
|
7
8
|
* Measured as it opens, before the panel brings it into view (a child's layout effect runs first), and
|
|
8
9
|
* again at every keystroke: the input says by how much its text overflows it, and the box takes that
|
|
9
10
|
* much more. Grown, it draws the editing cell's frame around itself, over the cell's own, so the editor
|
|
@@ -11,11 +12,13 @@ import { type ReactNode, type RefObject } from "react";
|
|
|
11
12
|
* An app's body (`edge={false}`) draws its own edge, which grows with the box, so the box draws none; its value shares the
|
|
12
13
|
* box with a unit or a country, so it keeps `room` to type in even when empty.
|
|
13
14
|
*/
|
|
14
|
-
export declare function GridFittedBox({ boxRef, edge, room, children, }: {
|
|
15
|
+
export declare function GridFittedBox({ boxRef, edge, room, grows, children, }: {
|
|
15
16
|
boxRef: RefObject<HTMLSpanElement | null>;
|
|
16
17
|
/** The editing cell's frame round the grown box: false where what it holds draws its own edge. */
|
|
17
18
|
edge?: boolean;
|
|
18
19
|
/** The pixels the input keeps at least, its value or not: a box that shares the cell with a unit's button. */
|
|
19
20
|
room?: number;
|
|
21
|
+
/** The side it grows to: right for a text, left for an amount in a right-aligned column (its box at the cell's end). */
|
|
22
|
+
grows?: "left" | "right";
|
|
20
23
|
children: ReactNode;
|
|
21
24
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,8 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useCallback, useLayoutEffect } from "react";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
5
|
import { GRID_EDITING_SHADOW, GRID_GROUND } from "./grid-styles.js";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
function roomBeside(box, grows) {
|
|
7
|
+
const at = box.getBoundingClientRect();
|
|
8
|
+
if (at.width === 0 && at.height === 0)
|
|
9
|
+
return Infinity;
|
|
10
|
+
const page = { left: 0, right: document.documentElement.clientWidth || window.innerWidth };
|
|
11
|
+
const area = box.closest('[data-slot="vk-grid-scroll"]');
|
|
12
|
+
const seen = area?.getBoundingClientRect();
|
|
13
|
+
const left = seen ? Math.max(page.left, seen.left + area.clientLeft) : page.left;
|
|
14
|
+
const right = seen ? Math.min(page.right, seen.left + area.clientLeft + area.clientWidth) : page.right;
|
|
15
|
+
return Math.floor(grows === "left" ? at.right - left : right - at.left);
|
|
16
|
+
}
|
|
17
|
+
export function GridFittedBox({ boxRef, edge = true, room = 0, grows = "right", children, }) {
|
|
8
18
|
const fit = useCallback(() => {
|
|
9
19
|
const box = boxRef.current;
|
|
10
20
|
const input = box?.querySelector("input");
|
|
@@ -12,7 +22,7 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, children, }) {
|
|
|
12
22
|
return;
|
|
13
23
|
box.style.minWidth = "";
|
|
14
24
|
const over = Math.max(input.scrollWidth, room) - input.clientWidth;
|
|
15
|
-
const width = over > 0 ? Math.min(box.offsetWidth + over + 1,
|
|
25
|
+
const width = over > 0 ? Math.min(box.offsetWidth + over + 1, roomBeside(box, grows)) : 0;
|
|
16
26
|
if (width > box.offsetWidth) {
|
|
17
27
|
box.style.minWidth = `${width}px`;
|
|
18
28
|
box.dataset.grown = "";
|
|
@@ -20,7 +30,7 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, children, }) {
|
|
|
20
30
|
else {
|
|
21
31
|
delete box.dataset.grown;
|
|
22
32
|
}
|
|
23
|
-
}, [boxRef, room]);
|
|
33
|
+
}, [boxRef, room, grows]);
|
|
24
34
|
useLayoutEffect(fit, [fit]);
|
|
25
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: cx("pointer-events-none absolute inset-y-0 -inset-x-(--vk-px) -z-1 hidden rounded-sm border border-(color:--vk-border-brand) group-data-grown/fitted:block", GRID_EDITING_SHADOW, GRID_GROUND) })), children] }));
|
|
26
36
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type PointerEvent as ReactPointerEvent } from "react";
|
|
2
2
|
import type { ListCellAction } from "../../model/column-schema.js";
|
|
3
|
+
import type { GridRowHighlight } from "./GridCellOutline.js";
|
|
3
4
|
import { type GridButtonViews } from "./grid-button.js";
|
|
4
5
|
/**
|
|
5
6
|
* WHERE THE POINTER IS, for the two things a row draws only there: the name's
|
|
@@ -16,20 +17,27 @@ export type GridHoverTarget = {
|
|
|
16
17
|
rowKey: string;
|
|
17
18
|
colId: string | null;
|
|
18
19
|
};
|
|
20
|
+
/** Which row the grid tints (`rowHighlight`), handed by the table to the parts of a row that repaint its tint over their
|
|
21
|
+
* own ground: the row itself, its pinned cells, its rail and the name's action lane. */
|
|
22
|
+
export declare const GridRowHighlightContext: import("react").Context<GridRowHighlight>;
|
|
19
23
|
export type GridHoverStore = {
|
|
20
24
|
get(): GridHoverTarget | null;
|
|
21
25
|
set(target: GridHoverTarget | null): void;
|
|
22
26
|
/** The record an app draws as under the pointer (`hoveredRow`), beside wherever the real pointer is. */
|
|
23
27
|
held(): string | null;
|
|
24
28
|
hold(rowId: string | null): void;
|
|
29
|
+
/** The drawn row the row menu is open on, by its key: drawn as under the pointer while the menu is open. */
|
|
30
|
+
menuRow(): string | null;
|
|
31
|
+
holdMenuRow(rowKey: string | null): void;
|
|
25
32
|
subscribe(listener: () => void): () => void;
|
|
26
33
|
};
|
|
27
34
|
export declare function createGridHoverStore(): GridHoverStore;
|
|
28
35
|
export declare const GridHoverContext: import("react").Context<GridHoverStore | null>;
|
|
29
36
|
export declare function useAnyHover(): boolean;
|
|
30
|
-
/** Whether the pointer is over this row,
|
|
37
|
+
/** Whether the pointer is over this row, the app holds it there, or the row menu is open on it. */
|
|
31
38
|
export declare function useGridRowHovered(rowKey: string): boolean;
|
|
32
|
-
/** Whether the app holds this row under the pointer (`hoveredRow`): the row's
|
|
39
|
+
/** Whether the app holds this row under the pointer (`hoveredRow`), or the row menu is open on it: the row's
|
|
40
|
+
* `data-hovered`. */
|
|
33
41
|
export declare function useGridRowHeld(rowKey: string): boolean;
|
|
34
42
|
/** Whether the pointer is over this cell. */
|
|
35
43
|
export declare function useGridCellHovered(rowKey: string, colId: string): boolean;
|
|
@@ -7,9 +7,11 @@ import { useDesktop } from "../../provider/desktop.js";
|
|
|
7
7
|
import { useViews } from "../../provider/context.js";
|
|
8
8
|
import { GridRowActions } from "./GridRowActions.js";
|
|
9
9
|
import { drawGridButton } from "./grid-button.js";
|
|
10
|
+
export const GridRowHighlightContext = createContext("hover");
|
|
10
11
|
export function createGridHoverStore() {
|
|
11
12
|
let current = null;
|
|
12
13
|
let heldId = null;
|
|
14
|
+
let menuKey = null;
|
|
13
15
|
const listeners = new Set();
|
|
14
16
|
const tell = () => {
|
|
15
17
|
for (const listener of listeners)
|
|
@@ -30,6 +32,13 @@ export function createGridHoverStore() {
|
|
|
30
32
|
heldId = rowId;
|
|
31
33
|
tell();
|
|
32
34
|
},
|
|
35
|
+
menuRow: () => menuKey,
|
|
36
|
+
holdMenuRow(rowKey) {
|
|
37
|
+
if (menuKey === rowKey)
|
|
38
|
+
return;
|
|
39
|
+
menuKey = rowKey;
|
|
40
|
+
tell();
|
|
41
|
+
},
|
|
33
42
|
subscribe(listener) {
|
|
34
43
|
listeners.add(listener);
|
|
35
44
|
return () => listeners.delete(listener);
|
|
@@ -51,13 +60,13 @@ export function useAnyHover() {
|
|
|
51
60
|
const NO_STORE = () => () => { };
|
|
52
61
|
function useHovered(answer) {
|
|
53
62
|
const store = useContext(GridHoverContext);
|
|
54
|
-
return useSyncExternalStore(store ? store.subscribe : NO_STORE, () => (store ? answer(store.get(), store.held()) : false), () => false);
|
|
63
|
+
return useSyncExternalStore(store ? store.subscribe : NO_STORE, () => (store ? answer(store.get(), store.held(), store.menuRow()) : false), () => false);
|
|
55
64
|
}
|
|
56
65
|
export function useGridRowHovered(rowKey) {
|
|
57
|
-
return useHovered((target, held) => target?.rowKey === rowKey || (held != null && gridRowIdFromKey(rowKey) === held));
|
|
66
|
+
return useHovered((target, held, menuRow) => target?.rowKey === rowKey || menuRow === rowKey || (held != null && gridRowIdFromKey(rowKey) === held));
|
|
58
67
|
}
|
|
59
68
|
export function useGridRowHeld(rowKey) {
|
|
60
|
-
return useHovered((_target, held) => held != null && gridRowIdFromKey(rowKey) === held);
|
|
69
|
+
return useHovered((_target, held, menuRow) => menuRow === rowKey || (held != null && gridRowIdFromKey(rowKey) === held));
|
|
61
70
|
}
|
|
62
71
|
export function useGridCellHovered(rowKey, colId) {
|
|
63
72
|
return useHovered((target) => target?.rowKey === rowKey && target.colId === colId);
|
|
@@ -118,9 +127,10 @@ export function useGridRowHoverHandlers(rowKey) {
|
|
|
118
127
|
};
|
|
119
128
|
}
|
|
120
129
|
export function GridRowHoverActions({ views, rowKey, row, selected, actions, }) {
|
|
130
|
+
const highlight = useContext(GridRowHighlightContext);
|
|
121
131
|
if (!useGridRowHovered(rowKey))
|
|
122
132
|
return null;
|
|
123
|
-
return _jsx(GridRowActions, { views: views, row: row, selected: selected, actions: actions });
|
|
133
|
+
return _jsx(GridRowActions, { views: views, row: row, selected: selected, highlight: highlight, actions: actions });
|
|
124
134
|
}
|
|
125
135
|
export function GridPickerCaret({ rowKey, colId, editing, onOpen, }) {
|
|
126
136
|
const hovered = useGridCellHovered(rowKey, colId);
|
|
@@ -66,6 +66,10 @@ export type GridRowProps<Row> = {
|
|
|
66
66
|
editingEnabled: boolean;
|
|
67
67
|
/** Focused/editing column id — null unless it's THIS row's cell. */
|
|
68
68
|
focusedColId: string | null;
|
|
69
|
+
/** The active row, under `rowHighlight: "active"`: it carries `data-active` and the row's tint. */
|
|
70
|
+
active?: boolean;
|
|
71
|
+
/** Told this row's key on a press anywhere on it, under `rowHighlight: "active"`; absent otherwise. */
|
|
72
|
+
onActivate?: (rowKey: string) => void;
|
|
69
73
|
editingColId: string | null;
|
|
70
74
|
/** columnId → optimistic pending value (undefined when this row has none). */
|
|
71
75
|
pendingByCol?: Record<string, unknown>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { cloneElement, createContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
3
|
+
import { cloneElement, createContext, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
4
4
|
import { useViews } from "../../provider/context.js";
|
|
5
5
|
import { gridRowMenuColumnAt, gridRowMenuItems, reshapeRowMenu, rowMenuWaiting } from "./grid-row-menu-items.js";
|
|
6
|
+
import { GridHoverContext } from "./grid-hover.js";
|
|
6
7
|
const ROW = '[data-slot="vk-grid-row"]';
|
|
7
8
|
function rowKeyAt(container, target) {
|
|
8
9
|
const row = target instanceof Element ? target.closest(ROW) : null;
|
|
@@ -14,6 +15,7 @@ const TOUCH_AIM_MS = 250;
|
|
|
14
15
|
export function GridRowsMenu({ rowPropsFor, selectable, answerHeldPress, children, }) {
|
|
15
16
|
const views = useViews();
|
|
16
17
|
const RowMenu = views.atoms.RowMenu;
|
|
18
|
+
const hoverStore = useContext(GridHoverContext);
|
|
17
19
|
const [aim, setAim] = useState(null);
|
|
18
20
|
const [menuColumnId, setMenuColumnId] = useState(null);
|
|
19
21
|
const [opening, setOpening] = useState(null);
|
|
@@ -34,9 +36,10 @@ export function GridRowsMenu({ rowPropsFor, selectable, answerHeldPress, childre
|
|
|
34
36
|
setMenuColumnId(columnId);
|
|
35
37
|
setOpening(null);
|
|
36
38
|
};
|
|
37
|
-
const
|
|
39
|
+
const hold = (rowKey) => hoverStore?.holdMenuRow(rowKey);
|
|
40
|
+
const latest = useRef({ rowPropsFor, aimAt, aim, views, hold });
|
|
38
41
|
useLayoutEffect(() => {
|
|
39
|
-
latest.current = { rowPropsFor, aimAt, aim, views };
|
|
42
|
+
latest.current = { rowPropsFor, aimAt, aim, views, hold };
|
|
40
43
|
});
|
|
41
44
|
const [aimByRow] = useState(() => (rowKey, event) => {
|
|
42
45
|
const aimed = latest.current.rowPropsFor(rowKey);
|
|
@@ -101,7 +104,9 @@ export function GridRowsMenu({ rowPropsFor, selectable, answerHeldPress, childre
|
|
|
101
104
|
},
|
|
102
105
|
}));
|
|
103
106
|
const rows = cloneElement(children, target);
|
|
104
|
-
|
|
107
|
+
const [onOpenChange] = useState(() => (open) => latest.current.hold(open ? aimRef.current : null));
|
|
108
|
+
useEffect(() => () => hoverStore?.holdMenuRow(null), [hoverStore]);
|
|
109
|
+
return (_jsx(GridRowMenuAimContext.Provider, { value: aimByRow, children: _jsx(RowMenu, { rowId: props?.id ?? "", items: items, openHref: props && !reshape ? props.rowHref?.(props.row) : undefined, onDelete: reshape ? undefined : props?.onRowDelete, deleteLabel: props?.deleteLabel, onOpenChange: onOpenChange, onToggleSelect: selectable
|
|
105
110
|
? () => {
|
|
106
111
|
if (answerHeldPress?.())
|
|
107
112
|
return;
|