@viewkitjs/views 0.2.0 → 0.3.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 +571 -0
- package/README.md +5 -3
- package/dist/atoms/LoadMore.js +11 -1
- package/dist/atoms/RowMenu.js +5 -2
- package/dist/cells/cell-format.d.ts +3 -3
- package/dist/cells/cell-title.d.ts +1 -2
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +6 -3
- package/dist/contract.d.ts +50 -9
- package/dist/contract.js +33 -5
- package/dist/display/converted.d.ts +19 -0
- package/dist/display/converted.js +12 -0
- package/dist/display/index.d.ts +1 -0
- package/dist/display/index.js +1 -0
- package/dist/display/link-click.d.ts +11 -0
- package/dist/display/link-click.js +3 -0
- package/dist/display/link.js +7 -3
- package/dist/display/multi-value.d.ts +1 -1
- package/dist/display/multi-value.js +1 -1
- package/dist/display/options.d.ts +7 -1
- package/dist/display/phone.js +3 -1
- package/dist/editors/ChipsEditor.d.ts +9 -4
- package/dist/editors/ChipsEditor.js +6 -2
- package/dist/editors/DateEditor.d.ts +21 -6
- package/dist/editors/DateEditor.js +118 -30
- package/dist/editors/EditorPanel.d.ts +61 -0
- package/dist/editors/EditorPanel.js +54 -0
- package/dist/editors/LocationEditor.d.ts +3 -0
- package/dist/editors/LocationEditor.js +14 -6
- package/dist/editors/NameEditor.d.ts +3 -0
- package/dist/editors/NameEditor.js +11 -7
- package/dist/editors/NumberEditor.d.ts +3 -0
- package/dist/editors/NumberEditor.js +6 -6
- package/dist/editors/RangeEditor.d.ts +16 -1
- package/dist/editors/RangeEditor.js +21 -5
- package/dist/editors/RelationEditor.d.ts +13 -28
- package/dist/editors/RelationEditor.js +17 -40
- package/dist/editors/RelationSetEditor.d.ts +53 -0
- package/dist/editors/RelationSetEditor.js +112 -0
- package/dist/editors/SelectEditor.d.ts +21 -3
- package/dist/editors/SelectEditor.js +55 -9
- package/dist/editors/TextEditor.d.ts +51 -0
- package/dist/editors/TextEditor.js +81 -0
- package/dist/editors/ValueListEditor.d.ts +3 -0
- package/dist/editors/ValueListEditor.js +4 -2
- package/dist/editors/edit-cores.d.ts +12 -9
- package/dist/editors/edit-cores.js +7 -6
- package/dist/editors/edit-session.d.ts +21 -11
- package/dist/editors/edit-session.js +19 -5
- package/dist/editors/keep-inside.d.ts +12 -0
- package/dist/editors/keep-inside.js +20 -0
- package/dist/editors/open-value.d.ts +21 -0
- package/dist/editors/open-value.js +36 -0
- package/dist/editors/open-values.d.ts +4 -0
- package/dist/editors/open-values.js +7 -0
- package/dist/editors/relation-kinds.d.ts +7 -0
- package/dist/editors/relation-kinds.js +21 -0
- package/dist/editors/relation-panel.d.ts +69 -0
- package/dist/editors/relation-panel.js +40 -0
- package/dist/field-row/FieldNoteLine.d.ts +14 -0
- package/dist/field-row/FieldNoteLine.js +14 -0
- package/dist/field-row/FieldRow.d.ts +73 -0
- package/dist/field-row/FieldRow.js +157 -0
- package/dist/field-row/FieldRowLane.d.ts +19 -0
- package/dist/field-row/FieldRowLane.js +11 -0
- package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
- package/dist/field-row/editors/RowChipsEditor.js +25 -0
- package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
- package/dist/field-row/editors/RowDateEditor.js +18 -0
- package/dist/field-row/editors/RowEditor.d.ts +39 -0
- package/dist/field-row/editors/RowEditor.js +64 -0
- package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
- package/dist/field-row/editors/RowNameEditor.js +15 -0
- package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
- package/dist/field-row/editors/RowNumberEditor.js +18 -0
- package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
- package/dist/field-row/editors/RowPlaceEditor.js +18 -0
- package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
- package/dist/field-row/editors/RowRangeEditor.js +15 -0
- package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
- package/dist/field-row/editors/RowRelationEditor.js +77 -0
- package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
- package/dist/field-row/editors/RowSelectEditor.js +23 -0
- package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
- package/dist/field-row/editors/RowTextEditor.js +16 -0
- package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
- package/dist/field-row/editors/RowValueListEditor.js +21 -0
- package/dist/field-row/editors/host.d.ts +59 -0
- package/dist/field-row/editors/host.js +1 -0
- package/dist/field-row/editors/row-session.d.ts +49 -0
- package/dist/field-row/editors/row-session.js +49 -0
- package/dist/field-row/index.d.ts +5 -0
- package/dist/field-row/index.js +5 -0
- package/dist/field-row/row-target.d.ts +20 -0
- package/dist/field-row/row-target.js +3 -0
- package/dist/field-row/useFieldWrite.d.ts +45 -0
- package/dist/field-row/useFieldWrite.js +190 -0
- package/dist/field-row/useRowSettlement.d.ts +33 -0
- package/dist/field-row/useRowSettlement.js +23 -0
- package/dist/fields/binding.d.ts +6 -1
- package/dist/fields/binding.js +13 -6
- package/dist/fields/edit-core-types.d.ts +9 -9
- package/dist/fields/edit-core-types.js +6 -6
- package/dist/fields/money.d.ts +5 -0
- package/dist/fields/money.js +10 -0
- package/dist/fields/number-edit.d.ts +6 -0
- package/dist/fields/number-edit.js +4 -0
- package/dist/fields/prepare-write.js +6 -1
- package/dist/fields/relation-source-types.d.ts +12 -0
- package/dist/fields/write-target.d.ts +50 -0
- package/dist/fields/write-target.js +10 -0
- package/dist/grid/chrome/GridAddColumn.js +1 -1
- package/dist/grid/chrome/GridAggregateMenu.d.ts +1 -1
- package/dist/grid/chrome/GridAggregateMenu.js +8 -6
- package/dist/grid/chrome/GridCellEditors.d.ts +7 -0
- package/dist/grid/chrome/GridCellEditors.js +87 -16
- package/dist/grid/chrome/GridCellOutline.d.ts +22 -43
- package/dist/grid/chrome/GridCellOutline.js +2 -7
- package/dist/grid/chrome/GridChipsEditor.d.ts +16 -6
- package/dist/grid/chrome/GridChipsEditor.js +21 -26
- package/dist/grid/chrome/GridColumnMenu.d.ts +1 -1
- package/dist/grid/chrome/GridColumnMenu.js +7 -3
- package/dist/grid/chrome/GridDateEditor.d.ts +23 -11
- package/dist/grid/chrome/GridDateEditor.js +13 -25
- package/dist/grid/chrome/GridFooter.d.ts +12 -2
- package/dist/grid/chrome/GridFooter.js +10 -6
- package/dist/grid/chrome/GridGroupMenu.js +20 -13
- package/dist/grid/chrome/GridHeader.d.ts +9 -4
- package/dist/grid/chrome/GridHeader.js +15 -10
- package/dist/grid/chrome/GridLongTextEditor.d.ts +28 -9
- package/dist/grid/chrome/GridLongTextEditor.js +16 -74
- package/dist/grid/chrome/GridNameEditor.d.ts +11 -6
- package/dist/grid/chrome/GridNameEditor.js +12 -27
- package/dist/grid/chrome/GridNumberEditor.d.ts +20 -6
- package/dist/grid/chrome/GridNumberEditor.js +46 -20
- package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
- package/dist/grid/chrome/GridPlaceEditor.js +22 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +15 -5
- package/dist/grid/chrome/GridRangeEditor.js +16 -20
- package/dist/grid/chrome/GridRelationEditor.d.ts +38 -14
- package/dist/grid/chrome/GridRelationEditor.js +86 -24
- package/dist/grid/chrome/GridRow.d.ts +7 -1
- package/dist/grid/chrome/GridRow.js +57 -14
- package/dist/grid/chrome/GridRowActions.js +1 -1
- package/dist/grid/chrome/GridRowCells.js +18 -23
- package/dist/grid/chrome/GridSelectEditor.d.ts +19 -4
- package/dist/grid/chrome/GridSelectEditor.js +21 -27
- package/dist/grid/chrome/GridStructure.d.ts +9 -10
- package/dist/grid/chrome/GridStructure.js +10 -14
- package/dist/grid/chrome/GridTable.js +97 -30
- package/dist/grid/chrome/GridTableSurface.d.ts +39 -2
- package/dist/grid/chrome/GridTableSurface.js +12 -3
- package/dist/grid/chrome/GridTextEditor.d.ts +35 -1
- package/dist/grid/chrome/GridTextEditor.js +35 -37
- package/dist/grid/chrome/GridValueListEditor.d.ts +15 -3
- package/dist/grid/chrome/GridValueListEditor.js +10 -27
- package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
- package/dist/grid/chrome/cell-cut-off.js +20 -0
- package/dist/grid/chrome/cells.js +1 -2
- package/dist/grid/chrome/checks.d.ts +2 -5
- package/dist/grid/chrome/checks.js +15 -5
- package/dist/grid/chrome/editors.d.ts +1 -1
- package/dist/grid/chrome/editors.js +1 -1
- package/dist/grid/chrome/grid-cell-classes.d.ts +2 -8
- package/dist/grid/chrome/grid-cell-classes.js +10 -8
- package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
- package/dist/grid/chrome/grid-cell-link.js +9 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
- package/dist/grid/chrome/grid-edit-session.js +118 -0
- package/dist/grid/chrome/grid-hover.d.ts +60 -0
- package/dist/grid/chrome/grid-hover.js +81 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
- package/dist/grid/chrome/grid-menu-focus.js +93 -0
- package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
- package/dist/grid/chrome/grid-row-menu-key.js +36 -0
- package/dist/grid/chrome/grid-row-props.d.ts +16 -4
- package/dist/grid/chrome/grid-row-window.d.ts +61 -0
- package/dist/grid/chrome/grid-row-window.js +212 -0
- package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
- package/dist/grid/chrome/grid-scroll-owner.js +75 -0
- package/dist/grid/chrome/grid-styles.d.ts +4 -1
- package/dist/grid/chrome/grid-styles.js +1 -0
- package/dist/grid/chrome/grid-table-props.d.ts +2 -3
- package/dist/grid/chrome/useGridFocus.d.ts +45 -0
- package/dist/grid/chrome/useGridFocus.js +122 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +21 -4
- package/dist/grid/chrome/useGridKeyboard.js +214 -38
- package/dist/grid/chrome/useGridRangeActions.d.ts +3 -1
- package/dist/grid/chrome/useGridRangeActions.js +17 -10
- package/dist/grid/chrome/useGridRangeGestures.js +68 -21
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +4 -2
- package/dist/grid/chrome/useGridRowContextMenu.js +28 -2
- package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -1
- package/dist/grid/chrome/useGridScaleStyles.js +6 -7
- package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
- package/dist/grid/chrome/useGridScrollArea.js +65 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +28 -5
- package/dist/grid/chrome/useGridTableInteractionModel.js +66 -14
- package/dist/grid/chrome/useHeaderDragReorder.d.ts +2 -2
- package/dist/grid/core/clipboard-model.d.ts +2 -0
- package/dist/grid/core/clipboard-model.js +1 -1
- package/dist/grid/core/commit-model.d.ts +7 -0
- package/dist/grid/core/edge-scroll.d.ts +21 -0
- package/dist/grid/core/edge-scroll.js +23 -0
- package/dist/grid/core/editing-controller.d.ts +2 -1
- package/dist/grid/core/editing-controller.js +35 -9
- package/dist/grid/core/editing-model.d.ts +9 -0
- package/dist/grid/core/editing-model.js +12 -0
- package/dist/grid/core/flat-rows.d.ts +35 -0
- package/dist/grid/core/flat-rows.js +20 -0
- package/dist/grid/core/grid-aria.d.ts +27 -0
- package/dist/grid/core/grid-aria.js +39 -0
- package/dist/grid/core/grid-focus.d.ts +54 -0
- package/dist/grid/core/grid-focus.js +148 -0
- package/dist/grid/core/nav.d.ts +2 -2
- package/dist/grid/core/pending-reconciliation.d.ts +3 -0
- package/dist/grid/core/pending-reconciliation.js +5 -3
- package/dist/grid/core/row-window.d.ts +40 -0
- package/dist/grid/core/row-window.js +43 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +17 -1
- package/dist/grid/core/spreadsheet-operations.js +33 -6
- package/dist/grid/core/useGridEditing.d.ts +3 -0
- package/dist/grid/core/useGridEditing.js +6 -3
- package/dist/grid/core/value-equality.d.ts +23 -1
- package/dist/grid/core/value-equality.js +46 -0
- package/dist/grid/useGridTablePrefs.d.ts +0 -1
- package/dist/grid/useGridTablePrefs.js +1 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/viewport.d.ts +0 -2
- package/dist/internal/viewport.js +0 -14
- package/dist/model/column-capabilities.d.ts +2 -1
- package/dist/model/column-capabilities.js +28 -8
- package/dist/model/column-from.js +3 -0
- package/dist/model/column-inspect.d.ts +10 -2
- package/dist/model/column-inspect.js +9 -0
- package/dist/model/column-schema.d.ts +6 -1
- package/dist/model/column-types.d.ts +3 -1
- package/dist/model/column-types.js +1 -1
- package/dist/model/preferences.d.ts +0 -4
- package/dist/model/preferences.js +0 -1
- package/dist/model/prefs-buckets.d.ts +0 -1
- package/dist/model/prefs-buckets.js +0 -3
- package/dist/model/render-count.d.ts +6 -0
- package/dist/model/render-count.js +11 -0
- package/dist/provider/ViewsProvider.d.ts +5 -1
- package/dist/provider/ViewsProvider.js +9 -3
- package/dist/provider/components.d.ts +19 -1
- package/dist/provider/components.js +4 -2
- package/dist/provider/context.d.ts +5 -2
- package/dist/provider/desktop.d.ts +9 -0
- package/dist/provider/desktop.js +22 -0
- package/dist/provider/plain-input.d.ts +8 -0
- package/dist/provider/plain-input.js +5 -0
- package/dist/react.d.ts +2 -1
- package/dist/react.js +1 -0
- package/dist/selection/SelectCheckbox.d.ts +3 -1
- package/dist/selection/SelectCheckbox.js +2 -2
- package/dist/selection/useCheckDragSelect.js +6 -5
- package/docs/contract.md +93 -35
- package/docs/guides/atoms.md +1 -1
- package/docs/guides/cells.md +2 -2
- package/docs/guides/columns.md +3 -2
- package/docs/guides/display.md +1 -0
- package/docs/guides/editors.md +71 -13
- package/docs/guides/the-grid.md +32 -13
- package/docs/guides/the-provider.md +3 -1
- package/docs/index.md +3 -1
- package/docs/install.md +1 -1
- package/docs/reference/cells.md +1 -1
- package/docs/reference/display.md +3 -1
- package/docs/reference/editors-chips.md +2 -2
- package/docs/reference/editors-date.md +3 -3
- package/docs/reference/editors-location.md +1 -1
- package/docs/reference/editors-number.md +1 -1
- package/docs/reference/editors-open-values.md +1 -0
- package/docs/reference/editors-panel.md +12 -0
- package/docs/reference/editors-range.md +1 -1
- package/docs/reference/editors-relation.md +6 -3
- package/docs/reference/editors-select.md +3 -2
- package/docs/reference/editors-session.md +4 -2
- package/docs/reference/editors-text.md +9 -0
- package/docs/reference/editors-value-list.md +1 -1
- package/docs/reference/editors.md +2 -2
- package/docs/reference/field-row.md +16 -0
- package/docs/reference/grid.md +3 -3
- package/docs/reference/react.md +8 -5
- package/docs/reference/views.md +36 -15
- package/package.json +23 -4
- package/skills/views/SKILL.md +4 -4
- package/dist/grid/chrome/useGridScrollSync.d.ts +0 -38
- package/dist/grid/chrome/useGridScrollSync.js +0 -176
|
@@ -18,53 +18,32 @@ export declare function gridFrozenBg(selected: boolean): string;
|
|
|
18
18
|
* and a pale patch in the highlight at the Name column's edge — multiplied by
|
|
19
19
|
* the row count.
|
|
20
20
|
*/
|
|
21
|
+
export declare const GRID_CELL_HOVER_SHADOW = "hover:shadow-[0_1px_2px_rgb(0_0_0/0.05)] dark:hover:shadow-[0_1px_2px_rgb(0_0_0/0.22)]";
|
|
21
22
|
/**
|
|
22
|
-
* The
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* which is the one thing every other column edge already says.
|
|
23
|
+
* The quiet pointer affordance: a 1px neutral ring on the cell under the
|
|
24
|
+
* pointer, drawn as the hovered cell's OWN `::after`. The pseudo-element exists
|
|
25
|
+
* only while the cell is hovered, so no cell carries an element for it: one
|
|
26
|
+
* ring for the whole table, wherever the pointer is, with no script and no
|
|
27
|
+
* redraw. Applied to the cell by `gridCellClassName`, gated with
|
|
28
|
+
* GRID_CELL_HOVER_SHADOW: the line and the lift always appear together.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* short shadows rather than one edge. A table has ONE lit edge. So it lives
|
|
34
|
-
* outside the scrolled content — an overlay spanning the full height of its
|
|
35
|
-
* surface — and the rows know nothing about it.
|
|
30
|
+
* Literal 4px radius (`rounded-sm`): this repo's named radius tokens start at
|
|
31
|
+
* 10px, which on a 37px-tall cell reads as a lozenge, not a softened rectangle.
|
|
32
|
+
* Do not swap it for a token.
|
|
36
33
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
34
|
+
* The outward shadow is on the cell itself (GRID_CELL_HOVER_SHADOW), not here:
|
|
35
|
+
* this ring sits at inset-0, exactly the cell's padding box, and a resting cell
|
|
36
|
+
* is `overflow-hidden`, so an outward shadow declared on it would paint outside
|
|
37
|
+
* the clip and render as nothing. An element's own box-shadow is not clipped by
|
|
38
|
+
* its own overflow — hence the split.
|
|
42
39
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* Alpha is roughly doubled in dark mode — the same asymmetry
|
|
47
|
-
* GRID_CELL_HOVER_SHADOW uses, because a shadow that reads on white disappears
|
|
48
|
-
* on a dark surface, where it is nearly the only depth cue available.
|
|
49
|
-
*
|
|
50
|
-
* Visible only when there is something to explain, via two flags multiplied
|
|
51
|
-
* together in the opacity:
|
|
52
|
-
* - `--vk-parked` (0/1, from the scroll sync) — the block has REACHED its
|
|
53
|
-
* stop. Not `--vk-scrolled`, which is the weaker "has moved at all": this
|
|
54
|
-
* band is drawn at the parked x, but the block travels for the first ~24px of
|
|
55
|
-
* scroll before it gets there. Gated on the weaker flag, the shadow appeared
|
|
56
|
-
* immediately and hung in open space while the title column was still sliding
|
|
57
|
-
* toward it. The two flags share a threshold with the block's own sticky
|
|
58
|
-
* stop, so on this one the band and the column's edge arrive together.
|
|
59
|
-
* - `--vk-frozen-on` (0/1, from the column layout) — with the freeze pref off
|
|
60
|
-
* or no title column there is no block, and the band would be a seam between
|
|
61
|
-
* two perfectly ordinary columns.
|
|
62
|
-
* Both are CSS vars rather than props on purpose: neither one re-renders a row.
|
|
40
|
+
* The strong line rung: a step louder than the cell rules around it, so the
|
|
41
|
+
* hovered cell reads as an edge among hairlines. This ring is the token's only
|
|
42
|
+
* consumer (hairlines ratchet).
|
|
63
43
|
*/
|
|
64
|
-
export declare
|
|
65
|
-
|
|
66
|
-
export declare function GridCellOutline({
|
|
67
|
-
|
|
68
|
-
/** `focus` only: lifts the cell with a drop shadow to read as a live input. */
|
|
44
|
+
export declare const GRID_CELL_HOVER_RING = "hover:after:pointer-events-none hover:after:absolute hover:after:inset-0 hover:after:z-1 hover:after:rounded-sm hover:after:border hover:after:border-(color:--vk-border-bold)";
|
|
45
|
+
/** The selection ring, in the same geometry the hover ring draws. */
|
|
46
|
+
export declare function GridCellOutline({ editing, }: {
|
|
47
|
+
/** Lifts the cell with a drop shadow to read as a live input. */
|
|
69
48
|
editing?: boolean;
|
|
70
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,13 +9,8 @@ export function gridFrozenBg(selected) {
|
|
|
9
9
|
? cx(GRID_GROUND, GRID_FROZEN_BG_SELECTED, GRID_FROZEN_BG_SELECTED_HOVER)
|
|
10
10
|
: cx(GRID_GROUND, GRID_FROZEN_HOVER);
|
|
11
11
|
}
|
|
12
|
-
export function GridFrozenShadow() {
|
|
13
|
-
return (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-y-0 z-8 w-1.5 bg-linear-to-r from-black/15 to-transparent opacity-[calc(var(--vk-parked,0)*var(--vk-frozen-on,0))] transition-opacity duration-150 dark:from-black/60", style: { left: "calc(var(--vk-rail-w) + var(--vk-frozen-w,0px))" } }));
|
|
14
|
-
}
|
|
15
12
|
export const GRID_CELL_HOVER_SHADOW = "hover:shadow-[0_1px_2px_rgb(0_0_0/0.05)] dark:hover:shadow-[0_1px_2px_rgb(0_0_0/0.22)]";
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
return (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 z-1 rounded-sm border border-(color:--vk-border-bold) opacity-0 group-hover/gridcell:opacity-100" }));
|
|
19
|
-
}
|
|
13
|
+
export const GRID_CELL_HOVER_RING = "hover:after:pointer-events-none hover:after:absolute hover:after:inset-0 hover:after:z-1 hover:after:rounded-sm hover:after:border hover:after:border-(color:--vk-border-bold)";
|
|
14
|
+
export function GridCellOutline({ editing = false, }) {
|
|
20
15
|
return (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: cx("pointer-events-none absolute inset-0 z-1 rounded-sm border", editing ? "border-(color:--vk-border-brand)" : "border-(color:--vk-fg-subtle) group-hover/gridcell:border-(color:--vk-border-brand)", editing && "shadow-lg shadow-black/20 dark:shadow-black/50") }));
|
|
21
16
|
}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
2
3
|
/**
|
|
3
4
|
* The GRID's host around the shared `ChipsEditor` (`@viewkitjs/views/editors/chips`) —
|
|
4
|
-
* the set-editing panel is one component across every surface
|
|
5
|
-
* the
|
|
6
|
-
*
|
|
5
|
+
* the set-editing panel is one component across every surface. The edit session
|
|
6
|
+
* owns the one-answer guard and the exit gap; the editor panel opens the popover on
|
|
7
|
+
* a desktop and the sheet on a phone. This host owns the anchor on the cell rect,
|
|
8
|
+
* the labels and colours, and the write.
|
|
7
9
|
*
|
|
8
10
|
* Telling Escape from an outside click matters more here than anywhere else,
|
|
9
11
|
* because the two mean OPPOSITE things for a set: Escape discards the session,
|
|
10
|
-
* an outside click keeps what you built.
|
|
11
|
-
* `onOpenChange
|
|
12
|
+
* an outside click keeps what you built. The panel tells them apart before
|
|
13
|
+
* either reaches the popover's `onOpenChange`; on a phone ✓ keeps the set and
|
|
14
|
+
* ✕ or a swipe discards it.
|
|
12
15
|
*/
|
|
13
|
-
export declare function GridChipsEditor<Row>({ column, values, suggestions, optionColors, onCommit, onCancel, }: {
|
|
16
|
+
export declare function GridChipsEditor<Row>({ column, title, values, suggestions, optionColors, refuse, onCommit, onCancel, onTab, }: {
|
|
14
17
|
/** Read for its declared `options` — the labels and colours the cell uses. */
|
|
15
18
|
column: ListColumn<Row>;
|
|
19
|
+
/** The field's name: the sheet's title on a phone. */
|
|
20
|
+
title: ReactNode;
|
|
16
21
|
/** The cell's current values. */
|
|
17
22
|
values: string[];
|
|
18
23
|
/** What this column holds on screen, from `deriveGridSelectValues`. An open
|
|
@@ -25,4 +30,9 @@ export declare function GridChipsEditor<Row>({ column, values, suggestions, opti
|
|
|
25
30
|
optionColors?: Record<string, ListSelectColor>;
|
|
26
31
|
onCommit: (next: string[]) => void;
|
|
27
32
|
onCancel: () => void;
|
|
33
|
+
/** Tab and Shift-Tab saved the set: the grid moves to the next cell, or the one before. */
|
|
34
|
+
onTab?: (backwards: boolean) => void;
|
|
35
|
+
/** The grid's judgement of a value before it is written: its reason when it would refuse it.
|
|
36
|
+
* A refused value keeps the editor open with that reason. */
|
|
37
|
+
refuse?: (value: string[]) => string | null;
|
|
28
38
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef
|
|
4
|
-
import { useViews } from "../../provider/context.js";
|
|
3
|
+
import { useRef } from "react";
|
|
5
4
|
import { ChipsEditor } from "../../editors/ChipsEditor.js";
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
6
|
import { resolveCategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
7
7
|
import { prettifyOptionValue } from "../../model/column-state.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { optionValues } from "@viewkitjs/fields";
|
|
9
|
+
import { offeredValues, takesNewValues, useOpenValues } from "../../editors/open-values.js";
|
|
10
|
+
import { useGridEditSession } from "./grid-edit-session.js";
|
|
11
|
+
export function GridChipsEditor({ column, title, values, suggestions, optionColors, refuse, onCommit, onCancel, onTab, }) {
|
|
12
12
|
const editorRef = useRef(null);
|
|
13
13
|
const anchorRef = useRef(null);
|
|
14
|
-
const
|
|
14
|
+
const { session, close } = useGridEditSession({
|
|
15
|
+
editorRef,
|
|
16
|
+
refuse: refuse && ((value) => refuse(value)),
|
|
17
|
+
onCommit: (next) => onCommit(next),
|
|
18
|
+
onCancel,
|
|
19
|
+
onTab,
|
|
20
|
+
});
|
|
15
21
|
const known = useOpenValues(column.field);
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
setOpen(false);
|
|
24
|
-
window.setTimeout(() => {
|
|
25
|
-
if (resolution.kind === "commit")
|
|
26
|
-
onCommit(resolution.payload);
|
|
27
|
-
else
|
|
28
|
-
onCancel();
|
|
29
|
-
}, EXIT_MS);
|
|
30
|
-
};
|
|
22
|
+
const field = column.field?.type === "multiselect" ? column.field : undefined;
|
|
23
|
+
const open = field ? takesNewValues(field) : true;
|
|
24
|
+
const offered = !column.field
|
|
25
|
+
? suggestions
|
|
26
|
+
: field && !open
|
|
27
|
+
? optionValues(field)
|
|
28
|
+
: offeredValues(column.field, known, suggestions);
|
|
31
29
|
const resolve = (value) => ({
|
|
32
30
|
value,
|
|
33
31
|
label: column.options?.find((option) => option.value === value)?.label ?? prettifyOptionValue(value),
|
|
34
32
|
color: resolveCategoryColor(value, column.options, optionColors),
|
|
35
33
|
});
|
|
36
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(
|
|
37
|
-
if (!next)
|
|
38
|
-
close("outside");
|
|
39
|
-
}, anchor: anchorRef, align: "start", sideOffset: 4, onEscape: () => close("escape"), onOutsidePress: () => close("outside"), initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (event) => event.stopPropagation(), chrome: "menu", className: "w-64 z-90", children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offered, resolve: resolve, normalize: column.chips?.normalize, onRequestClose: close }) })] }));
|
|
34
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (event) => event.stopPropagation(), chrome: "menu", className: "w-64 z-90", children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offered, resolve: resolve, normalize: column.chips?.normalize, creatable: open, onRequestClose: close }) })] }));
|
|
40
35
|
}
|
|
@@ -7,7 +7,7 @@ import type { ListDateStyle, ListDurationStyle, ListNumberFormatState } from "..
|
|
|
7
7
|
type TriggerProps = {
|
|
8
8
|
ref?: Ref<HTMLElement>;
|
|
9
9
|
onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
|
|
10
|
-
role?: "button";
|
|
10
|
+
role?: "button" | "columnheader";
|
|
11
11
|
"aria-haspopup"?: "dialog";
|
|
12
12
|
"aria-expanded"?: boolean;
|
|
13
13
|
};
|
|
@@ -15,6 +15,7 @@ import { GridColumnPercentSection } from "./GridColumnPercentSection.js";
|
|
|
15
15
|
import { GridColumnSortSection } from "./GridColumnSortSection.js";
|
|
16
16
|
import { insideGridFlyout, useGridFlyouts } from "./GridFlyout.js";
|
|
17
17
|
import { GridMenuRow, GridMenuSeparator } from "./GridMenuRow.js";
|
|
18
|
+
import { gridMenuArrows, useGridMenuFocus } from "./grid-menu-focus.js";
|
|
18
19
|
export function gridColumnMenuEnabled(col) {
|
|
19
20
|
return !col.actions;
|
|
20
21
|
}
|
|
@@ -22,6 +23,7 @@ export function GridColumnMenu({ column, values, viewBacked = false, sort, group
|
|
|
22
23
|
const [open, setOpen] = useState(false);
|
|
23
24
|
const flyouts = useGridFlyouts();
|
|
24
25
|
const [anchor, setAnchor] = useState(null);
|
|
26
|
+
const menuFocus = useGridMenuFocus(open, anchor);
|
|
25
27
|
const { atoms, components, messages } = useViews();
|
|
26
28
|
const { Popover } = components;
|
|
27
29
|
const { List } = atoms;
|
|
@@ -70,14 +72,16 @@ export function GridColumnMenu({ column, values, viewBacked = false, sort, group
|
|
|
70
72
|
children.props.onClick?.(event);
|
|
71
73
|
if (open)
|
|
72
74
|
close();
|
|
73
|
-
else
|
|
75
|
+
else {
|
|
76
|
+
menuFocus.noteOpen(event);
|
|
74
77
|
setOpen(true);
|
|
78
|
+
}
|
|
75
79
|
},
|
|
76
|
-
role: "button",
|
|
80
|
+
role: children.props.role ?? "button",
|
|
77
81
|
"aria-haspopup": "dialog",
|
|
78
82
|
"aria-expanded": open,
|
|
79
83
|
});
|
|
80
|
-
return (_jsxs(_Fragment, { children: [trigger, _jsx(Popover, { open: open, onOpenChange: handleOpenChange, anchor: anchor, side: "bottom", align: "start", sideOffset: 2, initialFocus:
|
|
84
|
+
return (_jsxs(_Fragment, { children: [trigger, _jsx(Popover, { open: open, onOpenChange: handleOpenChange, anchor: anchor, side: "bottom", align: "start", sideOffset: 2, initialFocus: menuFocus.initialFocus, chrome: "menu", panelData: { "data-slot": "vk-grid-column-menu" }, className: "w-52", onOutsidePress: (event) => anchor?.contains(event.target) || insideGridFlyout(event) ? false : undefined, children: _jsx("div", { onPointerOver: flyouts.onListPointerOver, onKeyDown: gridMenuArrows, children: _jsxs(List, { children: [sortable && (_jsxs(_Fragment, { children: [divider(0), _jsx(GridColumnSortSection, { sortKey: sortKey, value: sort.value, dir: sort.dir, onChange: sort.onChange, onClose: close })] })), groupable && (_jsxs(_Fragment, { children: [divider(1), grouped ? (_jsx(GridMenuRow, { label: messages({ key: "views.menus.ungroup" }), icon: "group", active: true, onClick: () => {
|
|
81
85
|
groupBy.onChange(null);
|
|
82
86
|
close();
|
|
83
87
|
} })) : (_jsx(GridMenuRow, { label: messages({
|
|
@@ -1,22 +1,34 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* The GRID's host around the shared `DateEditor` (`@viewkitjs/views/editors/date`) —
|
|
3
|
-
* the editing core is one component across every surface
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* the editing core is one component across every surface. The edit session owns the
|
|
5
|
+
* one-answer guard and the exit gap, and the core answers what the close means
|
|
6
|
+
* (`resolveClose`); the editor panel opens the popover on a desktop and the sheet on a
|
|
7
|
+
* phone. This host owns the anchor on the cell rect and the payload's shape. Time is
|
|
8
|
+
* present in the payload ("YYYY-MM-DDTHH:MM") unless the column is a calendar-day
|
|
9
|
+
* field (`dayOnly`): then the panel has no time box, a day click saves, and the
|
|
10
|
+
* payload is the day. The column's Show-time setting is display only. A cleared
|
|
11
|
+
* date commits "", which the app's write maps to its empty value.
|
|
10
12
|
*/
|
|
11
|
-
export declare function GridDateEditor({ initial, dayOnly, onCommit, onCancel, }: {
|
|
13
|
+
export declare function GridDateEditor({ title, initial, dayOnly, clearable, seed, refuse, onCommit, onCancel, onTab, }: {
|
|
14
|
+
/** The field's name: the sheet's title on a phone. */
|
|
15
|
+
title: ReactNode;
|
|
12
16
|
/** The stored value (ISO string) — selects the day + opening month. */
|
|
13
17
|
initial?: string;
|
|
14
18
|
/** The column presents a calendar-day field (`date`): the commit is the day
|
|
15
19
|
* alone — the shape the row stores and the write gate judges through
|
|
16
|
-
* `zodFor
|
|
17
|
-
* clock for it to land in. */
|
|
20
|
+
* `zodFor` — the panel draws no time box, and a day click saves. */
|
|
18
21
|
dayOnly?: boolean;
|
|
19
|
-
/**
|
|
22
|
+
/** The column may be emptied: the panel ends with a Clear row, which commits "". */
|
|
23
|
+
clearable?: boolean;
|
|
24
|
+
/** The character typed on the cell that opened the editor: the date box starts with it. */
|
|
25
|
+
seed?: string;
|
|
26
|
+
/** "YYYY-MM-DDTHH:MM" (local); "YYYY-MM-DD" when `dayOnly`; "" for a clear. */
|
|
20
27
|
onCommit: (value: string) => void;
|
|
21
28
|
onCancel: () => void;
|
|
29
|
+
/** The grid's judgement of a value before it is written: its reason when it would refuse it.
|
|
30
|
+
* A refused value keeps the editor open with that reason. */
|
|
31
|
+
refuse?: (value: string) => string | null;
|
|
32
|
+
/** After a Tab out of the panel saves: move to the next cell, or the one before on Shift-Tab. */
|
|
33
|
+
onTab?: (backwards: boolean) => void;
|
|
22
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef
|
|
4
|
-
import { useViews } from "../../provider/context.js";
|
|
3
|
+
import { useRef } from "react";
|
|
5
4
|
import { DateEditor } from "../../editors/DateEditor.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
|
+
import { useGridEditSession } from "./grid-edit-session.js";
|
|
7
|
+
export function GridDateEditor({ title, initial, dayOnly = false, clearable = false, seed, refuse, onCommit, onCancel, onTab, }) {
|
|
9
8
|
const editorRef = useRef(null);
|
|
10
9
|
const anchorRef = useRef(null);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (resolution.kind === "commit") {
|
|
21
|
-
onCommit(dayOnly ? resolution.payload.slice(0, 10) : resolution.payload);
|
|
22
|
-
}
|
|
23
|
-
else
|
|
24
|
-
onCancel();
|
|
25
|
-
}, EXIT_MS);
|
|
26
|
-
};
|
|
27
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(Popover, { open: open, onOpenChange: (next) => {
|
|
28
|
-
if (!next)
|
|
29
|
-
close("outside");
|
|
30
|
-
}, anchor: anchorRef, align: "start", sideOffset: 4, onEscape: () => close("escape"), onOutsidePress: () => close("outside"), initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-auto", children: _jsx(DateEditor, { ref: editorRef, initial: initial, onRequestClose: close }) })] }));
|
|
10
|
+
const { session, close, sheet } = useGridEditSession({
|
|
11
|
+
editorRef,
|
|
12
|
+
mapPayload: dayOnly ? (payload) => payload.slice(0, 10) : undefined,
|
|
13
|
+
refuse: refuse && ((value) => refuse(value)),
|
|
14
|
+
onCommit: (value) => onCommit(value),
|
|
15
|
+
onCancel,
|
|
16
|
+
onTab,
|
|
17
|
+
});
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-auto", children: _jsx(DateEditor, { ref: editorRef, initial: initial, dayOnly: dayOnly, clearable: clearable, seed: seed, focusDate: !sheet, onRequestClose: close }) })] }));
|
|
31
19
|
}
|
|
@@ -3,10 +3,20 @@ import type { ListGroup } from "../../grouping/types.js";
|
|
|
3
3
|
import { type DisplayCurrency } from "../../fields/currency.js";
|
|
4
4
|
import type { ListAggregateKind, ListColumn } from "../../model/column-schema.js";
|
|
5
5
|
import type { ListNumberFormatOverrides } from "../../model/column-format.js";
|
|
6
|
-
|
|
6
|
+
/** Whether a group's footer row is drawn: when its figures can be picked, or the host hands in one of its own. The
|
|
7
|
+
* keyboard and the screen reader's row numbers ask the same question the footer does. */
|
|
8
|
+
export declare function gridFooterShown({ interactive, hostCells, }: {
|
|
9
|
+
interactive: boolean;
|
|
10
|
+
hostCells: readonly ReactNode[];
|
|
11
|
+
}): boolean;
|
|
12
|
+
export declare function GridFooter<Row>({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked, frozenCount, frozenLeft, continuation, defaultCurrency, ariaRowIndex, ariaLevel, ariaColOffset, }: {
|
|
13
|
+
/** What a screen reader reads (`core/grid-aria.ts`): the row's number, its level in a tree grid, and the columns
|
|
14
|
+
* before the first data column (the checkbox lane). */
|
|
15
|
+
ariaRowIndex?: number;
|
|
16
|
+
ariaLevel?: number;
|
|
17
|
+
ariaColOffset?: number;
|
|
7
18
|
group: ListGroup<Row>;
|
|
8
19
|
columns: ListColumn<Row>[];
|
|
9
|
-
gridTemplate: string;
|
|
10
20
|
selecting: boolean;
|
|
11
21
|
aggregates?: Record<string, ListAggregateKind>;
|
|
12
22
|
numberFormats?: ListNumberFormatOverrides;
|
|
@@ -12,8 +12,12 @@ import { useCellFormat } from "../../cells/use-cell-format.js";
|
|
|
12
12
|
import { useViews } from "../../provider/context.js";
|
|
13
13
|
import { GridAggregateMenu } from "./GridAggregateMenu.js";
|
|
14
14
|
import { GridRailSpacer } from "./checks.js";
|
|
15
|
-
import { GRID_CONTENT_PAD, GRID_GROUND } from "./grid-styles.js";
|
|
16
|
-
|
|
15
|
+
import { GRID_CHROME_FOCUS, GRID_CONTENT_PAD, GRID_GROUND } from "./grid-styles.js";
|
|
16
|
+
import { gridFocusOnPress } from "./useGridFocus.js";
|
|
17
|
+
export function gridFooterShown({ interactive, hostCells, }) {
|
|
18
|
+
return interactive || hostCells.some((cell) => cell != null);
|
|
19
|
+
}
|
|
20
|
+
export function GridFooter({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked = false, frozenCount = 0, frozenLeft, continuation, defaultCurrency = DEFAULT_DISPLAY_CURRENCY, ariaRowIndex, ariaLevel, ariaColOffset = 0, }) {
|
|
17
21
|
const interactive = !!onAggregateChange;
|
|
18
22
|
const cellFormat = useCellFormat();
|
|
19
23
|
const { messages } = useViews();
|
|
@@ -21,9 +25,9 @@ export function GridFooter({ group, columns, gridTemplate, selecting, aggregates
|
|
|
21
25
|
const sourced = group.figures
|
|
22
26
|
? { totalled: new Set(Object.keys(group.figures.fields)), defaultCurrency }
|
|
23
27
|
: undefined;
|
|
24
|
-
if (!interactive
|
|
28
|
+
if (!gridFooterShown({ interactive, hostCells }))
|
|
25
29
|
return continuation;
|
|
26
|
-
const footer = (_jsxs("div", { "data-slot": "vk-grid-footer",
|
|
30
|
+
const footer = (_jsxs("div", { "data-slot": "vk-grid-footer", "data-group-key": group.key, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, className: cx("grid grid-cols-(--vk-cols)", GRID_CONTENT_PAD), children: [_jsx(GridRailSpacer, { selecting: selecting }), columns.map((column, index) => {
|
|
27
31
|
const kind = resolveAggregateKind(column, aggregates, sourced);
|
|
28
32
|
const columnInteractive = interactive && (!viewBacked || column.field != null);
|
|
29
33
|
const host = hostCells[index];
|
|
@@ -72,10 +76,10 @@ export function GridFooter({ group, columns, gridTemplate, selecting, aggregates
|
|
|
72
76
|
? column.aggregateSuffix
|
|
73
77
|
: null;
|
|
74
78
|
const frozen = index < frozenCount && !!frozenLeft;
|
|
75
|
-
const cell = (_jsx("div", { "data-slot": "vk-grid-footer-cell", style: frozen ? { left: frozenLeft(index) } : undefined, className: cx("group/gridagg flex h-(--vk-footer-h) min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap px-(--vk-px)", column.align === "right" && "justify-end", column.align === "center" && "justify-center", columnInteractive && "cursor-pointer select-none hover:bg-(color:--vk-hovered)", frozen ? cx("sticky z-7", GRID_GROUND) : "relative"), children: value != null ? (_jsxs(_Fragment, { children: [label && (_jsx("span", { className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest)", children: label })), _jsxs("span", { className: "text-(length:--vk-text) font-medium tabular-nums", children: [value, suffix && _jsx(CellSuffix, { children: suffix })] })] })) : columnInteractive ? (_jsx("span", { className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest) opacity-0 group-hover/gridagg:opacity-100", children: messages({ key: "views.grid.figure-pick" }) })) : null }, column.id));
|
|
79
|
+
const cell = (_jsx("div", { "data-slot": "vk-grid-footer-cell", "data-footcell": column.id, role: "gridcell", "aria-colindex": ariaColOffset + index + 1, tabIndex: -1, onPointerDown: (event) => gridFocusOnPress(event, "[data-footcell]"), style: frozen ? { left: frozenLeft(index) } : undefined, className: cx("group/gridagg flex h-(--vk-footer-h) min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap px-(--vk-px)", GRID_CHROME_FOCUS, column.align === "right" && "justify-end", column.align === "center" && "justify-center", columnInteractive && "cursor-pointer select-none hover:bg-(color:--vk-hovered)", frozen ? cx("sticky z-7", GRID_GROUND) : "relative"), children: value != null ? (_jsxs(_Fragment, { children: [label && (_jsx("span", { className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest)", children: label })), _jsxs("span", { className: "text-(length:--vk-text) font-medium tabular-nums", children: [value, suffix && _jsx(CellSuffix, { children: suffix })] })] })) : columnInteractive ? (_jsx("span", { className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest) opacity-0 group-hover/gridagg:opacity-100", children: messages({ key: "views.grid.figure-pick" }) })) : null }, column.id));
|
|
76
80
|
if (!columnInteractive)
|
|
77
81
|
return cell;
|
|
78
82
|
return (_jsx(GridAggregateMenu, { column: column, options: aggregateOptions(column, sourced), current: kind, onChange: (next) => onAggregateChange(column.id, next), align: column.align === "right" ? "end" : column.align === "center" ? "center" : "start", children: cell }, column.id));
|
|
79
|
-
}), _jsx("div", { "data-slot": "vk-grid-tail", className: "h-(--vk-footer-h)" })] }));
|
|
83
|
+
}), _jsx("div", { "data-slot": "vk-grid-tail", "aria-hidden": true, className: "h-(--vk-footer-h)" })] }));
|
|
80
84
|
return (_jsxs(_Fragment, { children: [footer, continuation] }));
|
|
81
85
|
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
4
|
import { useViews } from "../../provider/context.js";
|
|
5
5
|
import { cx } from "../../internal/cx.js";
|
|
6
6
|
import { GridMenuRow, GridMenuSeparator } from "./GridMenuRow.js";
|
|
7
7
|
import { GRID_MENU_SEARCH_AFTER, matchMenuOptions } from "./grid-menu-search.js";
|
|
8
|
+
import { GRID_CHROME_FOCUS } from "./grid-styles.js";
|
|
9
|
+
import { gridMenuArrows, gridMenuSearchArrows, useGridMenuFocus } from "./grid-menu-focus.js";
|
|
8
10
|
const EYEBROW = "px-2 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-(color:--vk-fg-subtle)";
|
|
9
11
|
export function GridGroupMenu({ sort, sortOptions, summary, onSummaryChange, figures = [], onHide, }) {
|
|
10
12
|
const [open, setOpen] = useState(false);
|
|
11
13
|
const [anchor, setAnchor] = useState(null);
|
|
14
|
+
const menuFocus = useGridMenuFocus(open, anchor);
|
|
15
|
+
const rowsBox = useRef(null);
|
|
16
|
+
const searchField = useRef(null);
|
|
12
17
|
const { atoms, components, icons, messages } = useViews();
|
|
13
18
|
const { Popover, Command } = components;
|
|
14
19
|
const { List, Row, RowContent } = atoms;
|
|
@@ -38,20 +43,22 @@ export function GridGroupMenu({ sort, sortOptions, summary, onSummaryChange, fig
|
|
|
38
43
|
const Glyph = active && sort.dir === "desc" ? icons.sortRowsDown : icons.sortRowsUp;
|
|
39
44
|
return (_jsx(Glyph, { className: cx("size-3.5", active ? "text-(color:--vk-fg-brand)" : "text-(color:--vk-fg-subtlest)") }));
|
|
40
45
|
};
|
|
41
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { ref: setAnchor, type: "button", "aria-label": messages({ key: "views.menus.group-options" }), "aria-haspopup": "dialog", "aria-expanded": open, onClick: (e) => {
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { ref: setAnchor, type: "button", tabIndex: -1, "aria-label": messages({ key: "views.menus.group-options" }), "aria-haspopup": "dialog", "aria-expanded": open, onClick: (e) => {
|
|
42
47
|
e.stopPropagation();
|
|
43
48
|
if (open)
|
|
44
49
|
close();
|
|
45
|
-
else
|
|
50
|
+
else {
|
|
51
|
+
menuFocus.noteOpen(e);
|
|
46
52
|
setOpen(true);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
}
|
|
54
|
+
}, className: cx("inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-(color:--vk-fg-subtle)", "transition-opacity hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)", "md:opacity-0 md:group-hover/gridlabel:opacity-100 aria-expanded:opacity-100 md:focus-visible:opacity-100", GRID_CHROME_FOCUS), children: _jsx(More, { className: "h-3.5 w-3.5" }) }), _jsx(Popover, { open: open, onOpenChange: (next) => (next ? setOpen(true) : close()), anchor: anchor, side: "bottom", align: "start", sideOffset: 4, initialFocus: menuFocus.initialFocus, chrome: "menu", panelData: { "data-slot": "vk-grid-group-menu" }, onPanelClick: (e) => e.stopPropagation(), className: "w-52", onOutsidePress: (event) => (anchor?.contains(event.target) ? false : undefined), children: _jsx("div", { ref: rowsBox, onKeyDown: (e) => gridMenuArrows(e, searchField.current), children: _jsxs(List, { children: [offered.length > 0 && _jsx("div", { className: EYEBROW, children: messages({ key: "views.menus.group-sort" }) }), searchable ? (_jsxs(Command.Root, { shouldFilter: false, loop: true, label: messages({ key: "views.menus.search" }), children: [_jsx(Command.Input, { ref: searchField, onKeyDown: (e) => gridMenuSearchArrows(e, rowsBox.current), value: query, onValueChange: setQuery, placeholder: messages({ key: "views.menus.search" }) }), _jsx(Command.List, { className: "max-h-64 overscroll-contain", children: _jsx(Command.Group, { className: "p-0", children: sorts.map((opt) => {
|
|
55
|
+
const active = sort.value === opt.value;
|
|
56
|
+
return (_jsx(Command.Item, { value: opt.value, onSelect: () => pick(opt), chosen: active, children: _jsx(RowContent, { label: opt.label, leading: sortGlyph(opt), chosen: active }) }, opt.value));
|
|
57
|
+
}) }) })] })) : (sorts.map((opt) => (_jsx(Row, { chosen: sort.value === opt.value, label: opt.label, leading: sortGlyph(opt), onClick: () => pick(opt) }, opt.value)))), figures.length > 0 && onSummaryChange && (_jsxs(_Fragment, { children: [offered.length > 0 && _jsx(GridMenuSeparator, {}), _jsx("div", { className: EYEBROW, children: messages({ key: "views.menus.group-show" }) }), [
|
|
58
|
+
{ part: "count", label: messages({ key: "views.menus.group-count" }) },
|
|
59
|
+
...figures,
|
|
60
|
+
].map((s) => (_jsx(Row, { chosen: (summary ?? []).includes(s.part), label: s.label, onClick: () => onSummaryChange(s.part, !(summary ?? []).includes(s.part)) }, s.part)))] })), onHide && (_jsxs(_Fragment, { children: [(offered.length > 0 || (figures.length > 0 && onSummaryChange)) && _jsx(GridMenuSeparator, {}), _jsx(GridMenuRow, { label: messages({ key: "views.menus.group-hide" }), icon: "hide", onClick: () => {
|
|
61
|
+
onHide();
|
|
62
|
+
close();
|
|
63
|
+
} })] }))] }) }) })] }));
|
|
57
64
|
}
|
|
@@ -7,14 +7,20 @@ import type { PercentDisplay } from "@viewkitjs/fields";
|
|
|
7
7
|
import { type GridGroupByState, type GridSortState } from "./GridColumnMenu.js";
|
|
8
8
|
import type { useHeaderDragReorder } from "./useHeaderDragReorder.js";
|
|
9
9
|
type HeaderDrag = ReturnType<typeof useHeaderDragReorder>;
|
|
10
|
-
export declare function GridHeader<Row>({
|
|
11
|
-
inline: boolean;
|
|
10
|
+
export declare function GridHeader<Row>({ showAddColumn, checkbox, groupKey, ariaRowIndex, ariaLevel, ariaColOffset, ariaTailIndex, columns, columnManager, minWidth, sort, selectValues, optionColors, onOptionColorChange, dateStyles, onDateStyleChange, durationStyles, onDurationStyleChange, numberFormats, onNumberFormatChange, showTimeOverrides, onShowTimeChange, percentDisplays, onPercentDisplayChange, columnStateEnabled, listConfig, groupBy, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, headerDrag, frozenCount, frozenLeft, viewBacked, formatsWritable, renderAddColumn, renderColumnMenuRows, }: {
|
|
12
11
|
/** The table sized the tail for "+ Add column": the desktop strip of a grid with column state. */
|
|
13
12
|
showAddColumn?: boolean;
|
|
14
13
|
checkbox?: ReactNode;
|
|
14
|
+
/** The section this column-name row heads: the keyboard finds its cells by it. */
|
|
15
|
+
groupKey?: string;
|
|
16
|
+
/** What a screen reader reads (`core/grid-aria.ts`): the row's number, its level in a tree grid, the columns
|
|
17
|
+
* before the first data column (the checkbox lane), and the tail's column. */
|
|
18
|
+
ariaRowIndex?: number;
|
|
19
|
+
ariaLevel?: number;
|
|
20
|
+
ariaColOffset?: number;
|
|
21
|
+
ariaTailIndex?: number;
|
|
15
22
|
columns: ListColumn<Row>[];
|
|
16
23
|
columnManager: ListColumnsConfig | null;
|
|
17
|
-
gridTemplate: string;
|
|
18
24
|
minWidth: string;
|
|
19
25
|
sort?: GridSortState;
|
|
20
26
|
selectValues: Record<string, string[]>;
|
|
@@ -46,7 +52,6 @@ export declare function GridHeader<Row>({ inline, showAddColumn, checkbox, colum
|
|
|
46
52
|
hideColumn: (column: ListColumn<Row>) => void;
|
|
47
53
|
moveColumn: (column: ListColumn<Row>, direction: -1 | 1) => void;
|
|
48
54
|
headerDrag: HeaderDrag;
|
|
49
|
-
registerHeader: (element: HTMLElement | null) => (() => void) | undefined;
|
|
50
55
|
/** How many LEADING columns are pinned to the left edge (0 = nothing). */
|
|
51
56
|
frozenCount?: number;
|
|
52
57
|
/** Sticky `left` for the frozen column at visible index i — a calc() over the
|
|
@@ -3,16 +3,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { cx } from "../../internal/cx.js";
|
|
4
4
|
import { columnHideable } from "../../model/column-state.js";
|
|
5
5
|
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
6
|
-
import { GridFrozenShadow } from "./GridCellOutline.js";
|
|
7
6
|
import { GridRailSpacer } from "./checks.js";
|
|
8
7
|
import { GridAddColumn } from "./GridAddColumn.js";
|
|
9
8
|
import { GridColumnMenu, gridColumnMenuEnabled, } from "./GridColumnMenu.js";
|
|
10
9
|
import { GridResizeHandle } from "./GridResizeHandle.js";
|
|
11
|
-
import {
|
|
10
|
+
import { GRID_CHROME_FOCUS, GRID_CONTENT_PAD, GRID_HEADER_BG_FROZEN, GRID_HEADER_BG_FROZEN_HOVER, } from "./grid-styles.js";
|
|
12
11
|
import { useViews } from "../../provider/context.js";
|
|
13
12
|
import { gridColumnGlyph } from "./column-glyph.js";
|
|
13
|
+
import { gridFocusOnPress } from "./useGridFocus.js";
|
|
14
|
+
import { effectiveSortKey } from "../../model/column-sort.js";
|
|
14
15
|
import { columnPlacedByView } from "../../model/column-capabilities.js";
|
|
15
|
-
export function GridHeader({
|
|
16
|
+
export function GridHeader({ showAddColumn = false, checkbox, groupKey, ariaRowIndex, ariaLevel, ariaColOffset = 0, ariaTailIndex, columns, columnManager, minWidth, sort, selectValues, optionColors, onOptionColorChange, dateStyles, onDateStyleChange, durationStyles, onDurationStyleChange, numberFormats, onNumberFormatChange, showTimeOverrides, onShowTimeChange, percentDisplays, onPercentDisplayChange, columnStateEnabled, listConfig, groupBy, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, headerDrag, frozenCount = 0, frozenLeft, viewBacked = false, formatsWritable, renderAddColumn, renderColumnMenuRows, }) {
|
|
16
17
|
const { icons, components, messages } = useViews();
|
|
17
18
|
const addColumn = columnManager && showAddColumn
|
|
18
19
|
? renderAddColumn?.(columnManager) || _jsx(GridAddColumn, { columns: columnManager })
|
|
@@ -22,16 +23,20 @@ export function GridHeader({ inline, showAddColumn = false, checkbox, columns, c
|
|
|
22
23
|
const canHide = canMove && columnHideable(column) && columns.length > 1;
|
|
23
24
|
const menuEnabled = gridColumnMenuEnabled(column);
|
|
24
25
|
const frozen = index < frozenCount && !!frozenLeft;
|
|
25
|
-
const cell = (_jsxs("div", { "data-slot": "vk-grid-header-cell", "data-headcell": column.id,
|
|
26
|
+
const cell = (_jsxs("div", { "data-slot": "vk-grid-header-cell", "data-headcell": column.id, tabIndex: -1, role: "columnheader", "aria-colindex": ariaColOffset + index + 1, "aria-sort": sort && sort.value === effectiveSortKey(column, viewBacked)
|
|
27
|
+
? sort.dir === "asc"
|
|
28
|
+
? "ascending"
|
|
29
|
+
: "descending"
|
|
30
|
+
: undefined, "aria-label": column.header ? undefined : (column.field?.label ?? column.id), style: {
|
|
26
31
|
...headerDrag.cellStyle(column.id, index),
|
|
27
32
|
...(frozen ? { left: frozenLeft(index) } : null),
|
|
28
|
-
}, onPointerDown:
|
|
33
|
+
}, onPointerDown: (event) => {
|
|
34
|
+
gridFocusOnPress(event, "[data-headcell]");
|
|
35
|
+
headerDrag.onCellPointerDown(column.id, index)(event);
|
|
36
|
+
}, onPointerMove: headerDrag.onCellPointerMove, onPointerUp: headerDrag.onCellPointerUp, onPointerCancel: headerDrag.onCellPointerCancel, onClickCapture: headerDrag.onCellClickCapture, className: cx("flex h-(--vk-head-h) min-w-0 select-none items-center gap-1.5 overflow-hidden whitespace-nowrap border-b border-(color:--vk-border-subtle) px-(--vk-px) text-(length:--vk-head-text) text-(color:--vk-fg-subtle)", GRID_CHROME_FOCUS, !frozen && "hover:bg-(color:--vk-hovered)", column.align === "center" && "justify-center", menuEnabled ? "cursor-pointer" : "cursor-default", "translate-x-(--vk-drag-shift,0px)", frozen ? cx("sticky z-7", GRID_HEADER_BG_FROZEN, GRID_HEADER_BG_FROZEN_HOVER) : "relative"), children: [gridColumnGlyph({ icons, AppIcon: components.AppIcon }, column, "h-(--vk-head-glyph) w-(--vk-head-glyph) shrink-0 opacity-70"), column.header ? _jsx("span", { className: "truncate", children: column.header }) : null, columnStateEnabled && (_jsx(GridResizeHandle, { active: resizingId === column.id, onResizeStart: (event) => startResize(column, event), onResizeMove: moveResize, onResizeEnd: endResize, onReset: () => resetColumnWidth(column) }))] }, column.id));
|
|
29
37
|
if (!menuEnabled)
|
|
30
38
|
return cell;
|
|
31
39
|
return (_jsx(GridColumnMenu, { column: column, values: selectValues[column.id] ?? [], viewBacked: viewBacked, sort: sort, groupBy: groupBy, optionColors: optionColors?.[fieldKeyOf(column)], onOptionColorChange: onOptionColorChange, dateStyle: dateStyles?.[fieldKeyOf(column)], onDateStyleChange: onDateStyleChange, durationStyle: durationStyles?.[fieldKeyOf(column)], onDurationStyleChange: onDurationStyleChange, numberFormat: numberFormats?.[fieldKeyOf(column)], onNumberFormatChange: onNumberFormatChange, showTime: showTimeOverrides?.[fieldKeyOf(column)] ?? column.format?.withTime ?? false, onShowTimeChange: column.type === "datetime" ? onShowTimeChange : undefined, percentDisplay: percentDisplays?.[fieldKeyOf(column)], onPercentDisplayChange: onPercentDisplayChange, onMoveLeft: canMove && index > 0 ? () => moveColumn(column, -1) : undefined, onMoveRight: canMove && index < columns.length - 1 ? () => moveColumn(column, 1) : undefined, onHide: canHide ? () => hideColumn(column) : undefined, formatsWritable: formatsWritable, renderColumnMenuRows: renderColumnMenuRows, children: cell }, column.id));
|
|
32
|
-
}), _jsxs("div", { "data-slot": "vk-grid-tail", className: cx("flex h-(--vk-head-h) min-w-0 items-center gap-2 border-b border-(color:--vk-border-subtle)", addColumn ? "pl-0" : "pl-(--vk-px)"), children: [listConfig?.readOnly && (_jsxs("span", { title: messages({ key: "views.grid.read-only-why" }), className: cx("inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-(length:--vk-head-text) text-(color:--vk-fg-subtle)", !!addColumn && "pl-(--vk-px)"), children: [_jsx(icons.lock, { className: "h-3 w-3" }), messages({ key: "views.grid.read-only" })] })), addColumn && _jsx("div", { className: "flex h-full min-w-0 flex-1 items-stretch", children: addColumn })] })] }));
|
|
33
|
-
|
|
34
|
-
return (_jsx("div", { "data-slot": "vk-grid-header", className: cx("group/gridhead grid", GRID_CONTENT_PAD), style: { gridTemplateColumns: gridTemplate, minWidth }, children: cells }));
|
|
35
|
-
}
|
|
36
|
-
return (_jsxs("div", { className: cx("group/gridhead relative", GRID_HEADER_BG, GRID_BLEED), children: [_jsx("div", { ref: registerHeader, className: "overflow-x-hidden", children: _jsx("div", { "data-slot": "vk-grid-header", className: cx("grid", GRID_CONTENT_PAD), style: { gridTemplateColumns: gridTemplate, minWidth }, children: cells }) }), _jsx(GridFrozenShadow, {})] }));
|
|
40
|
+
}), _jsxs("div", { "data-slot": "vk-grid-tail", role: "columnheader", "aria-colindex": ariaTailIndex, className: cx("flex h-(--vk-head-h) min-w-0 items-center gap-2 border-b border-(color:--vk-border-subtle)", addColumn ? "pl-0" : "pl-(--vk-px)"), children: [listConfig?.readOnly && (_jsxs("span", { title: messages({ key: "views.grid.read-only-why" }), className: cx("inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-(length:--vk-head-text) text-(color:--vk-fg-subtle)", !!addColumn && "pl-(--vk-px)"), children: [_jsx(icons.lock, { className: "h-3 w-3" }), messages({ key: "views.grid.read-only" })] })), addColumn && _jsx("div", { className: "flex h-full min-w-0 flex-1 items-stretch", children: addColumn })] })] }));
|
|
41
|
+
return (_jsx("div", { "data-slot": "vk-grid-header", "data-group-key": groupKey, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, className: cx("group/gridhead grid grid-cols-(--vk-cols)", GRID_CONTENT_PAD), style: { minWidth }, children: cells }));
|
|
37
42
|
}
|