viewkitjs 0.29.0 → 0.30.1
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 +127 -6
- package/MIGRATION.md +97 -8
- package/package.json +1 -1
- package/views/dist/cells/cell-format.d.ts +2 -2
- package/views/dist/cells/cell-values.js +0 -2
- package/views/dist/contract.d.ts +15 -18
- package/views/dist/contract.js +13 -27
- package/views/dist/controls/button/map-button.d.ts +5 -3
- package/views/dist/controls/button/map-button.js +14 -7
- package/views/dist/controls/controls.d.ts +2 -4
- package/views/dist/controls/controls.js +2 -2
- package/views/dist/controls/customize/customize.d.ts +51 -0
- package/views/dist/controls/customize/customize.js +128 -23
- package/views/dist/controls/customize/map-customize-body.d.ts +0 -3
- package/views/dist/controls/customize/map-customize-body.js +46 -11
- package/views/dist/controls/customize/map-ranges.d.ts +23 -0
- package/views/dist/controls/customize/map-ranges.js +41 -0
- package/views/dist/controls/customize/rules.d.ts +17 -1
- package/views/dist/controls/customize/rules.js +2 -0
- package/views/dist/controls/customize/words.d.ts +7 -0
- package/views/dist/controls/customize/words.js +5 -0
- package/views/dist/controls/customize.css +3 -0
- package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +1 -0
- package/views/dist/controls/filter-editor/rules.d.ts +1 -2
- package/views/dist/controls/index.d.ts +8 -8
- package/views/dist/controls/index.js +8 -8
- package/views/dist/controls/menu-list/menu-list.d.ts +16 -1
- package/views/dist/controls/menu-list/menu-list.js +26 -8
- package/views/dist/controls/menu-list.css +8 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +1 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +6 -3
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/text-editor/map-text-body.d.ts +1 -1
- package/views/dist/controls/text-editor/map-text-body.js +2 -2
- package/views/dist/controls/text-editor/text-editor.d.ts +3 -0
- package/views/dist/controls/text-editor/text-editor.js +16 -2
- package/views/dist/controls/text-editor.css +11 -0
- package/views/dist/controls/values-editor/values.js +6 -2
- package/views/dist/display/options.d.ts +1 -1
- package/views/dist/display/rich-text.js +0 -1
- package/views/dist/editors/ChipsEditor.d.ts +4 -5
- package/views/dist/editors/ChipsEditor.js +12 -78
- package/views/dist/editors/DateEditor.d.ts +12 -16
- package/views/dist/editors/DateEditor.js +40 -191
- package/views/dist/editors/EditorPanel.d.ts +2 -6
- package/views/dist/editors/EditorPanel.js +2 -2
- package/views/dist/editors/LocationEditor.d.ts +11 -19
- package/views/dist/editors/LocationEditor.js +19 -211
- package/views/dist/editors/NameEditor.d.ts +8 -16
- package/views/dist/editors/NameEditor.js +11 -100
- package/views/dist/editors/NumberEditor.d.ts +14 -21
- package/views/dist/editors/NumberEditor.js +22 -49
- package/views/dist/editors/RangeEditor.d.ts +9 -33
- package/views/dist/editors/RangeEditor.js +12 -97
- package/views/dist/editors/RelationEditor.d.ts +6 -9
- package/views/dist/editors/RelationEditor.js +11 -30
- package/views/dist/editors/RelationSetEditor.d.ts +13 -24
- package/views/dist/editors/RelationSetEditor.js +33 -101
- package/views/dist/editors/SelectEditor.d.ts +15 -17
- package/views/dist/editors/SelectEditor.js +15 -94
- package/views/dist/editors/TextEditor.d.ts +23 -26
- package/views/dist/editors/TextEditor.js +11 -48
- package/views/dist/editors/ValueListEditor.d.ts +14 -23
- package/views/dist/editors/ValueListEditor.js +16 -202
- package/views/dist/editors/body-panel.d.ts +13 -7
- package/views/dist/editors/body-panel.js +3 -7
- package/views/dist/editors/edit-cores.d.ts +15 -15
- package/views/dist/editors/edit-cores.js +14 -14
- package/views/dist/editors/number-body.d.ts +1 -1
- package/views/dist/editors/number-step.d.ts +0 -34
- package/views/dist/editors/number-step.js +0 -37
- package/views/dist/editors/option-add-flow.d.ts +1 -13
- package/views/dist/editors/option-add-flow.js +0 -22
- package/views/dist/editors/relation-links-body.d.ts +2 -3
- package/views/dist/editors/relation-picker.d.ts +13 -3
- package/views/dist/editors/relation-source.d.ts +0 -22
- package/views/dist/editors/relation-source.js +0 -21
- package/views/dist/field-row/FieldRow.js +5 -6
- package/views/dist/field-row/FieldRowLane.js +0 -1
- package/views/dist/field-row/editors/RowChipsEditor.js +2 -2
- package/views/dist/field-row/editors/RowDateEditor.d.ts +2 -2
- package/views/dist/field-row/editors/RowDateEditor.js +2 -2
- package/views/dist/field-row/editors/RowNameEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowNameEditor.js +7 -12
- package/views/dist/field-row/editors/RowNumberEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowNumberEditor.js +4 -4
- package/views/dist/field-row/editors/RowPlaceEditor.js +3 -3
- package/views/dist/field-row/editors/RowRangeEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +7 -14
- package/views/dist/field-row/editors/RowRelationEditor.js +3 -3
- package/views/dist/field-row/editors/RowSelectEditor.js +2 -2
- package/views/dist/field-row/editors/RowTextEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowTextEditor.js +3 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +5 -5
- package/views/dist/field-row/field-row-button.d.ts +6 -9
- package/views/dist/field-row/field-row-button.js +1 -6
- package/views/dist/field-row/field-row-checkbox.d.ts +1 -1
- package/views/dist/field-row/row-target.d.ts +0 -7
- package/views/dist/field-row/row-target.js +0 -2
- package/views/dist/grid/chrome/GridAddColumn.d.ts +2 -1
- package/views/dist/grid/chrome/GridAddColumn.js +8 -66
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +5 -7
- package/views/dist/grid/chrome/GridAggregateMenu.js +20 -39
- package/views/dist/grid/chrome/GridCellEditors.d.ts +2 -2
- package/views/dist/grid/chrome/GridCellEditors.js +12 -12
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -3
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +11 -12
- package/views/dist/grid/chrome/GridColumnMenu.js +32 -93
- package/views/dist/grid/chrome/GridDateEditor.d.ts +6 -6
- package/views/dist/grid/chrome/GridDateEditor.js +3 -3
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -6
- package/views/dist/grid/chrome/GridGroupMenu.js +21 -62
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -2
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +17 -38
- package/views/dist/grid/chrome/GridLongTextEditor.js +6 -7
- package/views/dist/grid/chrome/GridNameEditor.js +4 -4
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +4 -5
- package/views/dist/grid/chrome/GridNumberEditor.js +3 -4
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +2 -5
- package/views/dist/grid/chrome/GridPlaceEditor.js +5 -5
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +6 -12
- package/views/dist/grid/chrome/GridRangeEditor.js +7 -15
- package/views/dist/grid/chrome/GridRelationEditor.js +5 -5
- package/views/dist/grid/chrome/GridRow.js +0 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +1 -1
- package/views/dist/grid/chrome/GridRowActions.js +0 -5
- package/views/dist/grid/chrome/GridRowCells.js +9 -6
- package/views/dist/grid/chrome/GridSelectEditor.js +3 -3
- package/views/dist/grid/chrome/GridStructure.js +0 -1
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTextEditor.d.ts +5 -7
- package/views/dist/grid/chrome/GridTextEditor.js +4 -17
- package/views/dist/grid/chrome/GridValueListEditor.js +4 -4
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -3
- package/views/dist/grid/chrome/grid-body-place.js +4 -8
- package/views/dist/grid/chrome/grid-button.d.ts +7 -10
- package/views/dist/grid/chrome/grid-button.js +1 -6
- package/views/dist/grid/chrome/grid-cell-classes.js +1 -1
- package/views/dist/grid/chrome/grid-column-menu-items.d.ts +4 -4
- package/views/dist/grid/chrome/grid-column-menu-items.js +10 -6
- package/views/dist/grid/chrome/grid-group-menu-parts.d.ts +5 -9
- package/views/dist/grid/chrome/grid-group-menu-parts.js +1 -3
- package/views/dist/grid/chrome/grid-hover.js +0 -1
- package/views/dist/grid/chrome/grid-menu-focus.d.ts +7 -31
- package/views/dist/grid/chrome/grid-menu-focus.js +7 -47
- package/views/dist/grid/chrome/grid-styles.d.ts +0 -3
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/grid-table-props.d.ts +6 -10
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -4
- package/views/dist/grid/core/editing-controller.d.ts +2 -1
- package/views/dist/grid/core/editing-controller.js +10 -2
- package/views/dist/grid/core/refusal-sentence.d.ts +3 -0
- package/views/dist/grid/core/refusal-sentence.js +2 -2
- package/views/dist/grid/core/write-states.d.ts +3 -1
- package/views/dist/grid/core/write-states.js +6 -2
- package/views/dist/grid/grid.css +1 -1
- package/views/dist/model/body-frame.d.ts +0 -32
- package/views/dist/model/body-frame.js +1 -15
- package/views/dist/model/column-inspect.d.ts +5 -5
- package/views/dist/model/column-inspect.js +2 -2
- package/views/dist/panels/customize-body.d.ts +1 -10
- package/views/dist/panels/customize-body.js +0 -3
- package/views/dist/panels/filter/MenuSelect.js +0 -5
- package/views/dist/panels/filter/RangeFilterBody.js +0 -1
- package/views/dist/panels/filter/details.d.ts +1 -5
- package/views/dist/panels/filter/details.js +0 -13
- package/views/dist/panels/filter/filter-list.d.ts +0 -1
- package/views/dist/panels/filter/filter-list.js +1 -1
- package/views/dist/panels/panel-button.d.ts +10 -12
- package/views/dist/panels/panel-button.js +1 -6
- package/views/dist/panels/react/chrome.d.ts +0 -17
- package/views/dist/panels/react/chrome.js +0 -8
- package/views/dist/panels/react/customize-body.d.ts +9 -12
- package/views/dist/panels/react/customize-body.js +57 -11
- package/views/dist/panels/react/customize.d.ts +9 -12
- package/views/dist/panels/react/customize.js +3 -112
- package/views/dist/panels/react/filter/FilterEditor.d.ts +4 -18
- package/views/dist/panels/react/filter/FilterEditor.js +6 -330
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +1 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +27 -59
- package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +1 -11
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +8 -144
- package/views/dist/panels/react/filter/editor-ctx.d.ts +1 -33
- package/views/dist/panels/react/filter/editor-ctx.js +5 -33
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -6
- package/views/dist/panels/react/filter/filter-part-body.js +0 -5
- package/views/dist/panels/react/filter/rule-writes.d.ts +1 -26
- package/views/dist/panels/react/filter/rule-writes.js +4 -95
- package/views/dist/panels/react/order-details.d.ts +1 -26
- package/views/dist/panels/react/order-details.js +3 -69
- package/views/dist/panels/react/panel-header.js +0 -1
- package/views/dist/panels/react/popover.d.ts +4 -7
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +2 -4
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +16 -137
- package/views/dist/panels/react/sort/SortEditor.d.ts +4 -4
- package/views/dist/panels/react/sort/SortEditor.js +8 -245
- package/views/dist/panels/react/sort/SortFieldList.d.ts +1 -1
- package/views/dist/panels/react/sort/SortFieldList.js +11 -25
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -16
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +0 -4
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +0 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -3
- package/views/dist/panels/react/view-actions.js +0 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +5 -9
- package/views/dist/panels/react/views-row/ViewCreatePill.js +0 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +7 -43
- package/views/dist/panels/react/views-row/ViewPickerRow.js +0 -2
- package/views/dist/panels/react/views-row/menu-classes.d.ts +0 -4
- package/views/dist/panels/react/views-row/menu-classes.js +0 -2
- package/views/dist/panels/react.d.ts +5 -12
- package/views/dist/panels/react.js +5 -12
- package/views/dist/provider/ViewsProvider.d.ts +2 -46
- package/views/dist/provider/ViewsProvider.js +2 -22
- package/views/dist/provider/components.d.ts +153 -106
- package/views/dist/provider/context.d.ts +1 -21
- package/views/dist/provider/missing-slot.d.ts +3 -7
- package/views/dist/provider/missing-slot.js +2 -9
- package/views/dist/react.d.ts +1 -2
- package/views/dist/selection/SelectionBar.js +2 -3
- package/views/dist/styles.css +40 -168
- package/views/dist/styles.unlayered.css +40 -168
- package/views/docs/contract.md +99 -123
- package/views/docs/getting-started.md +222 -2
- package/views/docs/guides/cells.md +222 -2
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/editors.md +235 -20
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/selection.md +1 -1
- package/views/docs/guides/the-grid.md +14 -16
- package/views/docs/guides/the-provider.md +9 -15
- package/views/docs/reference/cells.md +1 -1
- package/views/docs/reference/controls.md +28 -15
- package/views/docs/reference/editors-chips.md +2 -2
- package/views/docs/reference/editors-date.md +4 -4
- package/views/docs/reference/editors-location.md +4 -7
- package/views/docs/reference/editors-name.md +3 -5
- package/views/docs/reference/editors-number.md +10 -10
- package/views/docs/reference/editors-panel.md +3 -3
- package/views/docs/reference/editors-range.md +3 -5
- package/views/docs/reference/editors-relation.md +4 -4
- package/views/docs/reference/editors-select.md +3 -3
- package/views/docs/reference/editors-text.md +3 -4
- package/views/docs/reference/editors-value-list.md +3 -3
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +2 -2
- package/views/docs/reference/panels-react.md +20 -34
- package/views/docs/reference/react.md +11 -18
- package/views/docs/reference/views.md +5 -5
- package/views/skills/views/SKILL.md +1 -1
- package/views/dist/editors/relation-panel.d.ts +0 -69
- package/views/dist/editors/relation-panel.js +0 -46
- package/views/dist/grid/chrome/GridColumnColorSection.d.ts +0 -13
- package/views/dist/grid/chrome/GridColumnColorSection.js +0 -40
- package/views/dist/grid/chrome/GridColumnDateSection.d.ts +0 -28
- package/views/dist/grid/chrome/GridColumnDateSection.js +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.d.ts +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.js +0 -24
- package/views/dist/grid/chrome/GridColumnNumberSection.d.ts +0 -29
- package/views/dist/grid/chrome/GridColumnNumberSection.js +0 -27
- package/views/dist/grid/chrome/GridColumnPercentSection.d.ts +0 -16
- package/views/dist/grid/chrome/GridColumnPercentSection.js +0 -16
- package/views/dist/grid/chrome/GridColumnSortSection.d.ts +0 -38
- package/views/dist/grid/chrome/GridColumnSortSection.js +0 -33
- package/views/dist/grid/chrome/GridFlyout.d.ts +0 -44
- package/views/dist/grid/chrome/GridFlyout.js +0 -80
- package/views/dist/grid/chrome/GridMenuRow.d.ts +0 -15
- package/views/dist/grid/chrome/GridMenuRow.js +0 -15
- package/views/dist/grid/chrome/grid-menu-search.d.ts +0 -7
- package/views/dist/grid/chrome/grid-menu-search.js +0 -7
- package/views/dist/panels/react/GroupBucketsList.d.ts +0 -16
- package/views/dist/panels/react/GroupBucketsList.js +0 -44
- package/views/dist/panels/react/LayoutColumnsList.d.ts +0 -24
- package/views/dist/panels/react/LayoutColumnsList.js +0 -101
- package/views/dist/panels/react/PopoverColumnDetail.d.ts +0 -11
- package/views/dist/panels/react/PopoverColumnDetail.js +0 -24
- package/views/dist/panels/react/drag.d.ts +0 -2
- package/views/dist/panels/react/drag.js +0 -5
- package/views/dist/panels/react/layout-detail.d.ts +0 -4
- package/views/dist/panels/react/layout-detail.js +0 -29
- package/views/dist/panels/react/root-list.d.ts +0 -6
- package/views/dist/panels/react/root-list.js +0 -31
- package/views/dist/panels/react/sort/use-sort-drag.d.ts +0 -17
- package/views/dist/panels/react/sort/use-sort-drag.js +0 -39
- package/views/dist/panels/react/view-footer.d.ts +0 -20
- package/views/dist/panels/react/view-footer.js +0 -41
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { memo, useContext } from "react";
|
|
4
|
-
import { cx } from "../../internal/cx.js";
|
|
5
4
|
import { drawGridButton } from "./grid-button.js";
|
|
6
5
|
import { GridRowCheck, GridRailSpacer } from "./checks.js";
|
|
7
|
-
import { GRID_TAIL_BUTTON_BASE } from "./grid-styles.js";
|
|
8
6
|
import { GRID_TAIL_PLACE } from "./grid-columns-template.js";
|
|
9
7
|
import { gridRowClassName, gridSelectionEdgeClass } from "./grid-cell-classes.js";
|
|
10
8
|
import { preventShiftTextSelect, ROW_INTERACTIVE_SELECTOR } from "../../selection/row-click.js";
|
|
@@ -161,7 +159,6 @@ function GridRowInner(props) {
|
|
|
161
159
|
clientY: rect.bottom + 6,
|
|
162
160
|
}));
|
|
163
161
|
},
|
|
164
|
-
own: cx(GRID_TAIL_BUTTON_BASE, "group-data-desktop/gridtable:opacity-0 group-data-desktop/gridtable:group-hover/gridrow:opacity-100 group-data-desktop/gridtable:group-data-hovered/gridrow:opacity-100", selected ? "hover:bg-(color:--vk-brand-subtlest)" : "hover:bg-(color:--vk-hovered)"),
|
|
165
162
|
frame: "h-8 w-9 group-data-desktop/gridtable:opacity-0 group-data-desktop/gridtable:group-hover/gridrow:opacity-100 group-data-desktop/gridtable:group-data-hovered/gridrow:opacity-100",
|
|
166
163
|
variant: "ghost",
|
|
167
164
|
size: "icon",
|
|
@@ -16,7 +16,7 @@ import { type GridButtonViews } from "./grid-button.js";
|
|
|
16
16
|
*/
|
|
17
17
|
type GridActionVariant = "bare" | "outlined";
|
|
18
18
|
export declare function GridActionButton({ views, variant, label, onClick, tabIndex, className, children, }: {
|
|
19
|
-
/** The provider's Button
|
|
19
|
+
/** The provider's Button, handed down: a button in every row reads no context of its own. */
|
|
20
20
|
views: GridButtonViews;
|
|
21
21
|
variant?: GridActionVariant;
|
|
22
22
|
label?: string;
|
|
@@ -3,10 +3,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { cx } from "../../internal/cx.js";
|
|
4
4
|
import { gridFrozenBg } from "./GridCellOutline.js";
|
|
5
5
|
import { drawGridButton } from "./grid-button.js";
|
|
6
|
-
const VARIANT = {
|
|
7
|
-
bare: "h-6 w-6 rounded-md hover:bg-(color:--vk-hovered)",
|
|
8
|
-
outlined: "h-6 w-6 rounded-md [corner-shape:squircle] border border-(color:--vk-border) shadow-xs hover:bg-(color:--vk-hovered)",
|
|
9
|
-
};
|
|
10
6
|
export function GridActionButton({ views, variant = "bare", label, onClick, tabIndex, className, children, }) {
|
|
11
7
|
return drawGridButton(views, {
|
|
12
8
|
tabIndex,
|
|
@@ -16,7 +12,6 @@ export function GridActionButton({ views, variant = "bare", label, onClick, tabI
|
|
|
16
12
|
e.stopPropagation();
|
|
17
13
|
onClick?.(e);
|
|
18
14
|
},
|
|
19
|
-
own: cx("flex shrink-0 items-center justify-center text-(color:--vk-fg-subtle) hover:text-(color:--vk-fg)", VARIANT[variant], className),
|
|
20
15
|
frame: cx("h-6 w-6 shrink-0", className),
|
|
21
16
|
variant: variant === "outlined" ? "outline" : "ghost",
|
|
22
17
|
size: "icon",
|
|
@@ -13,7 +13,7 @@ import { gridCellPlace } from "./grid-columns-template.js";
|
|
|
13
13
|
import { GridValueUnderEditor } from "./grid-edit-session.js";
|
|
14
14
|
import { GRID_RANGE_TINT_CLASS, GRID_TITLE_DATA, gridCellClassName, gridCellStates } from "./grid-cell-classes.js";
|
|
15
15
|
import { isEmptyValue } from "../core/value-equality.js";
|
|
16
|
-
import { gridBooleanMode, columnEffectiveWritable } from "../../model/column-capabilities.js";
|
|
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
19
|
import { GridHoverContext, GridPickerCaret, GridRowHoverActions } from "./grid-hover.js";
|
|
@@ -28,8 +28,7 @@ function FillDot({ enabled }) {
|
|
|
28
28
|
export function GridRowCells({ props }) {
|
|
29
29
|
const views = useViews();
|
|
30
30
|
const { conventions, icons, messages, components, oneValue } = views;
|
|
31
|
-
const
|
|
32
|
-
const booleanCheckbox = views.gridCheckboxes === "checkbox" ? components.Checkbox : undefined;
|
|
31
|
+
const booleanCheckbox = components.Checkbox;
|
|
33
32
|
const hoverStore = useContext(GridHoverContext);
|
|
34
33
|
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, onStartEdit, onEditorTab, onEditorEnter, editSeed, editWhole = false, editByKey = false, onCommitCell, onCancelEdit, onOpenRelation: onOpenRelationValue, entityIcon, commands, ariaColOffset = 0, } = props;
|
|
35
34
|
const canEdit = (column) => editingEnabled && gridColumnHasEditor(column) && columnEffectiveWritable(column, listConfig);
|
|
@@ -92,6 +91,10 @@ export function GridRowCells({ props }) {
|
|
|
92
91
|
const enterAdvance = () => onEditorEnter(rowKey, col.id);
|
|
93
92
|
const frozen = i < frozenCount;
|
|
94
93
|
const settlement = settlementByCol?.[col.id];
|
|
94
|
+
const write = writeStateByCol?.[col.id];
|
|
95
|
+
const refusal = write?.invalid
|
|
96
|
+
? (write.reason ?? messages({ key: "views.grid.commit-refused", values: { field: columnLabel(col) } }))
|
|
97
|
+
: undefined;
|
|
95
98
|
const empty = !!col.accessor &&
|
|
96
99
|
!col.actions &&
|
|
97
100
|
isEmptyValue(pendingByCol && col.id in pendingByCol ? pendingByCol[col.id] : col.accessor(row));
|
|
@@ -119,11 +122,11 @@ export function GridRowCells({ props }) {
|
|
|
119
122
|
focused,
|
|
120
123
|
editing,
|
|
121
124
|
range: span && { top: !!span.top, right: spanRight, bottom: !!span.bottom, left: spanLeft },
|
|
122
|
-
write
|
|
125
|
+
write,
|
|
123
126
|
empty,
|
|
124
127
|
frozen,
|
|
125
128
|
frozenEdge: frozen && i === frozenCount - 1,
|
|
126
|
-
}), title: settlement ? requestedSettlementTitle(col.field?.provenance, conventions) : undefined, style: {
|
|
129
|
+
}), title: refusal ?? (settlement ? requestedSettlementTitle(col.field?.provenance, conventions) : undefined), "aria-description": refusal, style: {
|
|
127
130
|
...gridCellPlace(i),
|
|
128
131
|
...(frozen && frozenLeft
|
|
129
132
|
? { left: `calc(var(--vk-stick,1) * ${frozenLeft(i)} + var(--vk-hold-x,0px))` }
|
|
@@ -141,7 +144,7 @@ export function GridRowCells({ props }) {
|
|
|
141
144
|
verticalBorders,
|
|
142
145
|
settlement,
|
|
143
146
|
}), 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
|
-
(editorKind === "number" || (editorKind === "
|
|
147
|
+
(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: [
|
|
145
148
|
...(rowActions ?? []),
|
|
146
149
|
...(canEdit(col)
|
|
147
150
|
? [
|
|
@@ -10,13 +10,13 @@ import { useViews } from "../../provider/context.js";
|
|
|
10
10
|
import { prettifyOptionValue } from "../../model/column-state.js";
|
|
11
11
|
import { offeredValues, useOpenValues } from "../../editors/open-values.js";
|
|
12
12
|
import { useGridEditSession } from "./grid-edit-session.js";
|
|
13
|
-
import {
|
|
13
|
+
import { bodyPanel } from "../../editors/body-panel.js";
|
|
14
14
|
import { useGridBodyPlace } from "./grid-body-place.js";
|
|
15
15
|
export function GridSelectEditor({ column, title, values, current, clearable = false, seed, openedByKey = false, optionColors, refuse, onCommit, onCancel, }) {
|
|
16
|
-
const panel =
|
|
16
|
+
const panel = bodyPanel("picker", "z-90");
|
|
17
17
|
const editorRef = useRef(null);
|
|
18
18
|
const anchorRef = useRef(null);
|
|
19
|
-
const place = useGridBodyPlace(
|
|
19
|
+
const place = useGridBodyPlace(anchorRef);
|
|
20
20
|
const { session, close, sheet } = useGridEditSession({
|
|
21
21
|
editorRef,
|
|
22
22
|
refuse: refuse && ((value) => refuse(value)),
|
|
@@ -52,7 +52,6 @@ function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks
|
|
|
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
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, {
|
|
55
|
-
own: cx("flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-(color:--vk-fg-subtle) hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)", foldOverChecks && "ml-(--vk-px)"),
|
|
56
55
|
frame: cx("h-6 w-6 shrink-0", foldOverChecks && "ml-(--vk-px)"),
|
|
57
56
|
variant: "ghost",
|
|
58
57
|
size: "icon",
|
|
@@ -369,7 +369,7 @@ function GridTableContent(props) {
|
|
|
369
369
|
};
|
|
370
370
|
const wrapRows = (rows) => (_jsx(GridRowsMenu, { rowPropsFor: rowPropsFor, selectable: selectable, answerHeldPress: pickOnPhone ? longPress.answerHeldPress : undefined, children: rows }));
|
|
371
371
|
const menuHeadKey = oneHead && !empty ? GRID_HEAD_KEY : (groups[0]?.key ?? "__all__");
|
|
372
|
-
const header = (checkbox, groupKey) => (_jsx(GridHeader, { showAddColumn: showAddColumn, addColumnAt: addColumnAt, checkbox: checkbox, checkColumnId: pickOnPhone ? checkColumnId : undefined, groupKey: groupKey, ariaRowIndex: empty ? 1 : groupKey != null ? aria.headIndex(groupKey) : undefined, ariaLevel: grouped ? (oneHead && groupKey === GRID_HEAD_KEY ? 1 : 2) : undefined, ariaColOffset: ariaColOffset, ariaTailIndex: ariaTailIndex, columns: visibleColumns, columnManager: columnManager, minWidth: minWidth, sort: sort, sortMark: sortMark, selectValues: selectValuesByColumn, optionColors: optionColors, onOptionColorChange: onOptionColorChange, dateStyles: dateStyles, onDateStyleChange: onDateStyleChange, durationStyles: durationStyles, onDurationStyleChange: onDurationStyleChange, numberFormats: numberFormats, onNumberFormatChange: onNumberFormatChange, showTimeOverrides: showTimeOverrides, onShowTimeChange: onShowTimeChange, percentDisplays: percentDisplays, onPercentDisplayChange: onPercentDisplayChange, columnStateEnabled: !!onColumnStateChange, listConfig: listConfig, groupBy: groupBy, viewBacked: props.viewBacked, formatsWritable: props.formatsWritable, renderAddColumn: props.renderAddColumn,
|
|
372
|
+
const header = (checkbox, groupKey) => (_jsx(GridHeader, { showAddColumn: showAddColumn, addColumnAt: addColumnAt, checkbox: checkbox, checkColumnId: pickOnPhone ? checkColumnId : undefined, groupKey: groupKey, ariaRowIndex: empty ? 1 : groupKey != null ? aria.headIndex(groupKey) : undefined, ariaLevel: grouped ? (oneHead && groupKey === GRID_HEAD_KEY ? 1 : 2) : undefined, ariaColOffset: ariaColOffset, ariaTailIndex: ariaTailIndex, columns: visibleColumns, columnManager: columnManager, minWidth: minWidth, sort: sort, sortMark: sortMark, selectValues: selectValuesByColumn, optionColors: optionColors, onOptionColorChange: onOptionColorChange, dateStyles: dateStyles, onDateStyleChange: onDateStyleChange, durationStyles: durationStyles, onDurationStyleChange: onDurationStyleChange, numberFormats: numberFormats, onNumberFormatChange: onNumberFormatChange, showTimeOverrides: showTimeOverrides, onShowTimeChange: onShowTimeChange, percentDisplays: percentDisplays, onPercentDisplayChange: onPercentDisplayChange, columnStateEnabled: !!onColumnStateChange, listConfig: listConfig, groupBy: groupBy, viewBacked: props.viewBacked, formatsWritable: props.formatsWritable, renderAddColumn: props.renderAddColumn, columnMenuItems: props.columnMenuItems, openColumnMenu: groupKey === menuHeadKey || props.openColumnMenu === undefined ? props.openColumnMenu : null, onOpenColumnMenuChange: onOpenColumnMenuChange, resizingId: resizingId, startResize: startResize, moveResize: moveResize, endResize: endResize, resetColumnWidth: resetColumnWidth, hideColumn: hideColumn, moveColumn: moveColumn, headerDrag: headerDrag, frozenCount: frozenCount, frozenLeft: frozenLeft, verticalBorders: verticalBorders, headerVerticalBorders: props.headerVerticalBorders }));
|
|
373
373
|
const pinFooter = props.pinFooter && footerKey.includes("1")
|
|
374
374
|
? { pin: grouped ? "group" : "foot", flush: footerKey.endsWith("1") }
|
|
375
375
|
: undefined;
|
|
@@ -5,8 +5,8 @@ import { type TextEditorType } from "../../editors/TextEditor.js";
|
|
|
5
5
|
* anything else as plain text. */
|
|
6
6
|
export declare function gridTextEditorType(colType: string | undefined): TextEditorType;
|
|
7
7
|
/**
|
|
8
|
-
* The GRID's text cell, hosting the shared `
|
|
9
|
-
* desktop it types in the cell (the spreadsheet's typing): Enter, Tab and a click away write at
|
|
8
|
+
* The GRID's text cell, hosting the shared `TextEditorHost` (the app's `TextBody`) through the grid's edit session. On a
|
|
9
|
+
* desktop it types in the cell (the spreadsheet's typing), long text and a line the cell cut off included: Enter, Tab and a click away write at
|
|
10
10
|
* once and move on as the key says; Escape throws the edit away; an unchanged value writes nothing
|
|
11
11
|
* and still moves on. A value the grid would refuse (an email that isn't one) stays in the cell
|
|
12
12
|
* with its reason under it.
|
|
@@ -15,7 +15,7 @@ export declare function gridTextEditorType(colType: string | undefined): TextEdi
|
|
|
15
15
|
* ✕ and a swipe change nothing, ✓ saves and closes without moving the selection, and the write waits
|
|
16
16
|
* for the sheet to slide away.
|
|
17
17
|
*/
|
|
18
|
-
export declare function GridTextEditor({ initial, seed, type, paragraph, region, title,
|
|
18
|
+
export declare function GridTextEditor({ initial, seed, type, paragraph, region, title, open, refuse, onCommit, onCancel, onTab, onEnter, }: {
|
|
19
19
|
/** The stored email, phone, link or domain the sheet's open action follows (mail, call or browse), drawn
|
|
20
20
|
* beside the box on a phone, where a tap on the cell edits it. Gone once the box is typed over: it opens
|
|
21
21
|
* what is stored, never a draft. */
|
|
@@ -29,14 +29,12 @@ export declare function GridTextEditor({ initial, seed, type, paragraph, region,
|
|
|
29
29
|
seed?: string;
|
|
30
30
|
/** The field's text type: the keyboard the box brings. Default `text`. */
|
|
31
31
|
type?: TextEditorType;
|
|
32
|
-
/** A paragraph (long text
|
|
32
|
+
/** A paragraph (long text): handed to the editor as `multiline` when true. */
|
|
33
33
|
paragraph?: boolean;
|
|
34
|
-
/** A phone's country, where a number typed without its code is read: handed to
|
|
34
|
+
/** A phone's country, where a number typed without its code is read: handed to the app's `TextBody`. */
|
|
35
35
|
region?: string;
|
|
36
36
|
/** The sheet's title on a phone: the column's header. */
|
|
37
37
|
title?: ReactNode;
|
|
38
|
-
/** Title columns render medium-weight — match it while editing. */
|
|
39
|
-
strong?: boolean;
|
|
40
38
|
onCommit: (value: string) => void;
|
|
41
39
|
onCancel: () => void;
|
|
42
40
|
/** Commit happened via Tab — move to the next cell in reading order. */
|
|
@@ -3,9 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useRef, useState } from "react";
|
|
4
4
|
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
5
5
|
import { OpenValueAction } from "../../editors/open-value.js";
|
|
6
|
-
import {
|
|
7
|
-
import { cx } from "../../internal/cx.js";
|
|
8
|
-
import { useViews } from "../../provider/context.js";
|
|
6
|
+
import { TextEditorHost, } from "../../editors/TextEditor.js";
|
|
9
7
|
import { GridRefusal, useGridEditSession } from "./grid-edit-session.js";
|
|
10
8
|
import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER } from "./grid-editor-layer.js";
|
|
11
9
|
import { GridFittedBox } from "./grid-fitted-box.js";
|
|
@@ -20,10 +18,9 @@ const TEXT_TYPES = new Set([
|
|
|
20
18
|
export function gridTextEditorType(colType) {
|
|
21
19
|
return colType && TEXT_TYPES.has(colType) ? colType : "text";
|
|
22
20
|
}
|
|
23
|
-
export function GridTextEditor({ initial, seed, type = "text", paragraph = false, region, title,
|
|
21
|
+
export function GridTextEditor({ initial, seed, type = "text", paragraph = false, region, title, open, refuse, onCommit, onCancel, onTab, onEnter, }) {
|
|
24
22
|
const editorRef = useRef(null);
|
|
25
23
|
const boxRef = useRef(null);
|
|
26
|
-
const { TextBody } = useViews().components;
|
|
27
24
|
const { session, close } = useGridEditSession({
|
|
28
25
|
editorRef,
|
|
29
26
|
inPlace: true,
|
|
@@ -35,17 +32,7 @@ export function GridTextEditor({ initial, seed, type = "text", paragraph = false
|
|
|
35
32
|
});
|
|
36
33
|
const [stored, setStored] = useState(seed === undefined);
|
|
37
34
|
return (_jsx(EditorPanel, { session: session, title: title ?? "", anchor: null, inPlace: true, sheetOnPhone: true, children: (surface) => {
|
|
38
|
-
const editor = (_jsx(
|
|
39
|
-
|
|
40
|
-
label: typeof title === "string" ? title : undefined,
|
|
41
|
-
check: refuse,
|
|
42
|
-
region,
|
|
43
|
-
escapeKeeps: session.keeps ?? false,
|
|
44
|
-
form: surface === "sheet" ? "phone" : "computer",
|
|
45
|
-
}
|
|
46
|
-
: {}), boxData: { "data-slot": "vk-grid-editor", "data-grid-editor": "" }, onRequestClose: close, className: surface === "sheet"
|
|
47
|
-
? "w-full min-w-0 select-text"
|
|
48
|
-
: cx("h-full w-full min-w-0 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtlest)", strong && "font-medium") }));
|
|
49
|
-
return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : TextBody ? (_jsxs("span", { "data-grown": "", className: GRID_EDITOR_LAYER, children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] })) : (_jsxs("span", { className: "relative flex h-full w-full min-w-0", children: [_jsx(GridFittedBox, { boxRef: boxRef, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
|
|
35
|
+
const editor = (_jsx(TextEditorHost, { ref: editorRef, type: type, initial: initial, seed: seed, closeOnBlur: surface === "in-place", ...(paragraph ? { multiline: true } : {}), label: typeof title === "string" ? title : undefined, check: refuse, region: region, escapeKeeps: session.keeps ?? false, form: surface === "sheet" ? "phone" : "computer", place: "cell", onRequestClose: close }));
|
|
36
|
+
return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : (_jsxs("span", { "data-grown": "", className: GRID_EDITOR_LAYER, children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
|
|
50
37
|
} }));
|
|
51
38
|
}
|
|
@@ -5,12 +5,12 @@ import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
|
5
5
|
import { ValueListEditor } from "../../editors/ValueListEditor.js";
|
|
6
6
|
import { listOfOne, oneOfList } from "../../editors/values-body.js";
|
|
7
7
|
import { useGridEditSession } from "./grid-edit-session.js";
|
|
8
|
-
import {
|
|
8
|
+
import { bodyPanel } from "../../editors/body-panel.js";
|
|
9
9
|
import { useGridBodyPlace } from "./grid-body-place.js";
|
|
10
10
|
export function GridValueListEditor({ field, title, initial, labels, allowEmpty = false, region, refuse, onCommit, onCancel, onTab, onEnter, holds = "several", seed, }) {
|
|
11
|
-
const panel =
|
|
11
|
+
const panel = bodyPanel("values", "z-90");
|
|
12
12
|
const anchorRef = useRef(null);
|
|
13
|
-
const place = useGridBodyPlace(
|
|
13
|
+
const place = useGridBodyPlace(anchorRef);
|
|
14
14
|
const listRef = useRef(null);
|
|
15
15
|
const one = holds === "one";
|
|
16
16
|
const oneRef = useRef({ resolveClose: (reason) => oneOfList(listRef.current.resolveClose(reason)) });
|
|
@@ -25,5 +25,5 @@ export function GridValueListEditor({ field, title, initial, labels, allowEmpty
|
|
|
25
25
|
onTab,
|
|
26
26
|
onEnter,
|
|
27
27
|
});
|
|
28
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: (
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: () => (_jsx(ValueListEditor, { ref: listRef, field: field, label: typeof title === "string" ? title : undefined, initial: one ? listOfOne(initial) : initial, labels: labels && !one, holds: holds, seed: one ? seed : undefined, allowEmpty: allowEmpty, region: region, escapeKeeps: session.keeps ?? false, onRequestClose: close })) })] }));
|
|
29
29
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare function useGridBodyPlace(body: ViewsBodySlot, anchor: RefObject<HTMLElement | null>): number;
|
|
2
|
+
/** The `sideOffset` a grid editor hands its panel around the app's body: minus the cell's height, over the cell. */
|
|
3
|
+
export declare function useGridBodyPlace(anchor: RefObject<HTMLElement | null>): number;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLayoutEffect, useState } from "react";
|
|
3
|
-
import { bodyHanded } from "../../model/body-frame.js";
|
|
4
|
-
import { useViews } from "../../provider/context.js";
|
|
5
3
|
const UNDER = 4;
|
|
6
|
-
export function useGridBodyPlace(
|
|
7
|
-
const { gridBodyPlace, components } = useViews();
|
|
8
|
-
const over = gridBodyPlace === "over" && bodyHanded(components, body);
|
|
4
|
+
export function useGridBodyPlace(anchor) {
|
|
9
5
|
const [height, setHeight] = useState(null);
|
|
10
6
|
useLayoutEffect(() => {
|
|
11
|
-
if (
|
|
7
|
+
if (anchor.current)
|
|
12
8
|
setHeight(anchor.current.getBoundingClientRect().height);
|
|
13
|
-
}, [
|
|
14
|
-
return
|
|
9
|
+
}, [anchor]);
|
|
10
|
+
return height !== null ? -height : UNDER;
|
|
15
11
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { MouseEvent as ReactMouseEvent, ReactElement, ReactNode, Ref } from "react";
|
|
2
2
|
import type { ViewsContextValue } from "../../provider/context.js";
|
|
3
|
-
/** What a grid button reads from the provider: the app's `Button
|
|
4
|
-
*
|
|
5
|
-
export type GridButtonViews = Pick<ViewsContextValue, "components"
|
|
3
|
+
/** What a grid button reads from the provider: the app's `Button`. Handed down by a part that already reads the
|
|
4
|
+
* provider, so a button in a row reads no context of its own. */
|
|
5
|
+
export type GridButtonViews = Pick<ViewsContextValue, "components">;
|
|
6
6
|
/** One button the grid draws itself, as each of its places describes it. */
|
|
7
7
|
export type GridButtonDraw = {
|
|
8
|
-
/** Today's classes, without `ELEMENT_RESET`: drawn on ViewKit's own `<button>`. */
|
|
9
|
-
own: string;
|
|
10
8
|
/** The box ViewKit keeps on the app's `Button`: its size, its place, its reveal. The look is the app's. */
|
|
11
9
|
frame: string;
|
|
12
10
|
variant: "ghost" | "outline";
|
|
@@ -19,14 +17,13 @@ export type GridButtonDraw = {
|
|
|
19
17
|
"aria-expanded"?: boolean;
|
|
20
18
|
"data-slot"?: string;
|
|
21
19
|
"data-open"?: "";
|
|
22
|
-
/** A press noted before its click (a menu's toggle
|
|
20
|
+
/** A press noted before its click (a menu's toggle). */
|
|
23
21
|
onPointerDownCapture?: () => void;
|
|
24
22
|
onClick?: (event: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
25
23
|
children: ReactNode;
|
|
26
24
|
};
|
|
27
25
|
/**
|
|
28
|
-
* Draws a button the grid draws itself:
|
|
29
|
-
*
|
|
30
|
-
* never a hook, so a row that draws one draws nothing more than its one element while the option is off.
|
|
26
|
+
* Draws a button the grid draws itself: the app's `Button`, handed the grid's box in its class. A plain function,
|
|
27
|
+
* never a component and never a hook, so a row that draws one reads no context of its own.
|
|
31
28
|
*/
|
|
32
|
-
export declare function drawGridButton(views: GridButtonViews, {
|
|
29
|
+
export declare function drawGridButton(views: GridButtonViews, { frame, variant, size, onPointerDownCapture, children, ...props }: GridButtonDraw): ReactElement;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
import { ELEMENT_RESET } from "../../internal/reset.js";
|
|
5
|
-
export function drawGridButton(views, { own, frame, variant, size, onPointerDownCapture, children, ...props }) {
|
|
6
|
-
if (views.gridButtons !== "button") {
|
|
7
|
-
return (_jsx("button", { type: "button", ...props, onPointerDownCapture: onPointerDownCapture, className: cx(ELEMENT_RESET, own), children: children }));
|
|
8
|
-
}
|
|
3
|
+
export function drawGridButton(views, { frame, variant, size, onPointerDownCapture, children, ...props }) {
|
|
9
4
|
const { Button } = views.components;
|
|
10
5
|
const button = (_jsx(Button, { type: "button", variant: variant, size: size, className: frame, ...props, children: children }));
|
|
11
6
|
return onPointerDownCapture ? (_jsx("span", { className: "contents", onPointerDownCapture: onPointerDownCapture, children: button })) : (button);
|
|
@@ -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", "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 || state.lastColumn) && "border-r-transparent", state.align === "right" && "justify-end text-right tabular-nums", state.align === "center" && "justify-center text-center", frozen
|
|
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 || state.lastColumn) && "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"
|
|
@@ -25,7 +25,7 @@ export type GridColumnMenuOffer = {
|
|
|
25
25
|
onMoveLeft?: () => void;
|
|
26
26
|
onMoveRight?: () => void;
|
|
27
27
|
};
|
|
28
|
-
/** What a column's header menu offers, decided once
|
|
28
|
+
/** What a column's header menu offers, decided once. */
|
|
29
29
|
export type ColumnMenuGates = {
|
|
30
30
|
/** The field key every knob and colour writes under. */
|
|
31
31
|
key: string;
|
|
@@ -54,7 +54,7 @@ export type ColumnMenuItemsDeps = {
|
|
|
54
54
|
icons: ViewsIcons;
|
|
55
55
|
/** The cell format in force (`useCellFormat()`): the date and duration samples read it. */
|
|
56
56
|
cellFormat: ReturnType<typeof useCellFormat>;
|
|
57
|
-
/** Closes the menu: every pick that closes
|
|
57
|
+
/** Closes the menu: every pick that closes calls it. */
|
|
58
58
|
close: () => void;
|
|
59
59
|
};
|
|
60
60
|
/** What the rows read beyond the gates: the current choices, and the app's own rows already read. */
|
|
@@ -70,9 +70,9 @@ export type GridColumnMenuItemsProps = GridColumnMenuOffer & {
|
|
|
70
70
|
appItems: ViewsMenuItem[] | null;
|
|
71
71
|
};
|
|
72
72
|
/**
|
|
73
|
-
* THE COLUMN MENU AS DATA,
|
|
73
|
+
* THE COLUMN MENU AS DATA, the rows the app's `Menu` is handed, in this order (sort · group · the knobs · the
|
|
74
74
|
* colours · move · the app's rows · hide), each block after the first behind a divider. Each knob and each option's
|
|
75
75
|
* colour is a group beside the menu, its current choice as its `detail`, its choices ticked rows that close; Show time
|
|
76
|
-
* is a tick that keeps the menu open. Every pick writes under the field key
|
|
76
|
+
* is a tick that keeps the menu open. Every pick writes under the field key.
|
|
77
77
|
*/
|
|
78
78
|
export declare function gridColumnMenuItems<Row>(column: ListColumn<Row>, props: GridColumnMenuItemsProps, gates: ColumnMenuGates, deps: ColumnMenuItemsDeps): ViewsMenuItem[];
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { resolveCategoryColor } from "viewkitjs/fields/design/category-colors";
|
|
3
|
+
import { CATEGORY_DOT_CLASSES, resolveCategoryColor } from "viewkitjs/fields/design/category-colors";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
5
|
import { columnLabel } from "../../model/column-capabilities.js";
|
|
6
6
|
import { LIST_DECIMALS_CHOICES, prettifyOptionValue } from "../../model/column-state.js";
|
|
7
7
|
import { formatDate, formatNumber } from "./cells.js";
|
|
8
|
-
import { ALL_COLORS, COLOR_DOTS } from "./GridColumnColorSection.js";
|
|
9
|
-
import { DATE_STYLES, sampleDate } from "./GridColumnDateSection.js";
|
|
10
|
-
import { DURATION_SAMPLE_MS, DURATION_STYLES } from "./GridColumnDurationSection.js";
|
|
11
|
-
import { AUTOMATIC_SAMPLE, DECIMALS_SAMPLE } from "./GridColumnNumberSection.js";
|
|
12
|
-
import { DISPLAYS } from "./GridColumnPercentSection.js";
|
|
13
8
|
import { columnGroupable } from "../../model/column-order.js";
|
|
14
9
|
import { columnKnobs } from "../../model/column-knobs.js";
|
|
15
10
|
import { columnSortParts, effectiveSortKey, sortPartOf } from "../../model/column-sort.js";
|
|
16
11
|
import { partKey, partWord } from "../../model/part-rows.js";
|
|
17
12
|
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
18
13
|
import { temporalKindOf } from "../../model/field-type-of.js";
|
|
14
|
+
const COLOR_DOTS = CATEGORY_DOT_CLASSES;
|
|
15
|
+
const ALL_COLORS = ["gray", "blue", "green", "amber", "red", "purple", "pink", "teal"];
|
|
16
|
+
const DATE_STYLES = ["short", "long", "numeric", "relative"];
|
|
17
|
+
const sampleDate = (now) => (now ? new Date(now.getTime() - 3 * 86_400_000) : null);
|
|
18
|
+
const DURATION_STYLES = ["adaptive", "clock", "units"];
|
|
19
|
+
const DURATION_SAMPLE_MS = 5_904_000;
|
|
20
|
+
const DECIMALS_SAMPLE = 1234.567;
|
|
21
|
+
const AUTOMATIC_SAMPLE = String(Number(DECIMALS_SAMPLE.toFixed(2)));
|
|
22
|
+
const DISPLAYS = ["text", "bar", "ring"];
|
|
19
23
|
export function columnMenuGates(column, offer) {
|
|
20
24
|
const { values, viewBacked = false, sort, groupBy, formatsWritable = true } = offer;
|
|
21
25
|
const key = fieldKeyOf(column);
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/** A part of a group band's ⋯ menu: Select all in group (it picks the group's rows, or clears them when all are
|
|
2
2
|
* picked), its sort choices, the band's figure toggles (the count and each figure), Hide. */
|
|
3
3
|
export type GridGroupMenuPart = "select" | "sort" | "figures" | "hide";
|
|
4
|
-
/** The parts a band's ⋯ holds, whether
|
|
5
|
-
* a ⋯ at all. */
|
|
4
|
+
/** The parts a band's ⋯ holds, and whether there is a ⋯ at all. */
|
|
6
5
|
export type GridGroupMenuParts = {
|
|
7
6
|
select: boolean;
|
|
8
7
|
sort: boolean;
|
|
9
8
|
figures: boolean;
|
|
10
9
|
hide: boolean;
|
|
11
|
-
command: boolean;
|
|
12
10
|
open: boolean;
|
|
13
11
|
};
|
|
14
12
|
/**
|
|
15
|
-
* Without `groupMenu`, the rule every grid had before it: sort choices or Hide open the ⋯, the figure toggles
|
|
16
|
-
* ride along whenever the menu is drawn,
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `popover` route only: on the `menu` route the sort choices open beside the menu with no search. Select is never
|
|
20
|
-
* offered without `groupMenu`, so a menu the app did not name stays as it was.
|
|
13
|
+
* Without `groupMenu`, the rule every grid had before it: sort choices or Hide open the ⋯, and the figure toggles
|
|
14
|
+
* ride along whenever the menu is drawn. With it, each part it lists that the grid can fill (sort needs a sort and
|
|
15
|
+
* its choices, the figures need figures and a way to turn them on, Hide a way to hide, Select a grid that selects).
|
|
16
|
+
* Select is never offered without `groupMenu`, so a menu the app did not name stays as it was.
|
|
21
17
|
*/
|
|
22
18
|
export declare function groupMenuParts({ groupMenu, hasSort, sortCount, figureCount, canToggleFigures, canHide, canSelect, }: {
|
|
23
19
|
groupMenu?: readonly GridGroupMenuPart[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GRID_MENU_SEARCH_AFTER } from "./grid-menu-search.js";
|
|
2
1
|
export function groupMenuParts({ groupMenu, hasSort, sortCount, figureCount, canToggleFigures, canHide, canSelect, }) {
|
|
3
2
|
const sortable = hasSort && sortCount > 0;
|
|
4
3
|
const toggles = figureCount > 0 && canToggleFigures;
|
|
@@ -9,7 +8,6 @@ export function groupMenuParts({ groupMenu, hasSort, sortCount, figureCount, can
|
|
|
9
8
|
sort: sortable,
|
|
10
9
|
figures: toggles,
|
|
11
10
|
hide: canHide,
|
|
12
|
-
command: sortable && sortCount > GRID_MENU_SEARCH_AFTER,
|
|
13
11
|
open,
|
|
14
12
|
};
|
|
15
13
|
}
|
|
@@ -17,5 +15,5 @@ export function groupMenuParts({ groupMenu, hasSort, sortCount, figureCount, can
|
|
|
17
15
|
const figures = groupMenu.includes("figures") && toggles;
|
|
18
16
|
const hide = groupMenu.includes("hide") && canHide;
|
|
19
17
|
const select = groupMenu.includes("select") && canSelect;
|
|
20
|
-
return { select, sort, figures, hide,
|
|
18
|
+
return { select, sort, figures, hide, open: select || sort || figures || hide };
|
|
21
19
|
}
|
|
@@ -141,7 +141,6 @@ function PickerCaretButton({ editing, onOpen }) {
|
|
|
141
141
|
if (!editing)
|
|
142
142
|
onOpen();
|
|
143
143
|
},
|
|
144
|
-
own: cx("absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center hover:text-(color:--vk-fg)", editing ? "text-(color:--vk-fg)" : "text-(color:--vk-fg-subtlest)"),
|
|
145
144
|
frame: "absolute right-1 top-1/2 h-5 w-5 -translate-y-1/2",
|
|
146
145
|
variant: "ghost",
|
|
147
146
|
size: "icon",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MouseEvent as ReactMouseEvent } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Gives the focus back to `anchor` when a menu that opened from it has closed, and only where the focus had nowhere
|
|
4
4
|
* else to go. Focus on the body goes back at once. Focus still inside a popup (an app's popover that plays its exit
|
|
@@ -12,28 +12,8 @@ import { type KeyboardEvent as ReactKeyboardEvent, type MouseEvent as ReactMouse
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function returnGridFocus(anchor: HTMLElement): () => void;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* last). Only the box's own rows answer: a flyout's popup, drawn elsewhere on the page, keeps its keys.
|
|
18
|
-
*
|
|
19
|
-
* A menu whose first rows sit in a searchable list hands its search field in as `search`: the field is then the
|
|
20
|
-
* walk's first stop, standing for the list, and a key that starts in it is the field's (`gridMenuSearchArrows`).
|
|
21
|
-
* Coming into the field, the walk moves the list's highlight to the end it enters from, ↓ (round from the last row)
|
|
22
|
-
* to the first match and ↑ (from the row below) to the last, by the Home and End a cmdk list answers; left on the
|
|
23
|
-
* other end, the field would hand the next key straight back. A list that doesn't answer them keeps its highlight.
|
|
24
|
-
*/
|
|
25
|
-
export declare function gridMenuArrows(event: ReactKeyboardEvent<HTMLElement>, search?: HTMLElement | null): void;
|
|
26
|
-
/**
|
|
27
|
-
* ↓ and ↑ in a grid menu's search field, its `onKeyDown`: the list walks its own matches, and at its ends the walk
|
|
28
|
-
* goes on through the menu's other rows in `box`, ↓ past the last match (or with none) to the first row and ↑ past
|
|
29
|
-
* the first match round to the last. The default is prevented there, so the list's own arrows stay still. The match
|
|
30
|
-
* the list has highlighted is the option the field names in `aria-activedescendant`, as a combobox does; a list that
|
|
31
|
-
* names none keeps its arrows, and Tab leaves it.
|
|
32
|
-
*/
|
|
33
|
-
export declare function gridMenuSearchArrows(event: ReactKeyboardEvent<HTMLElement>, box: HTMLElement | null): void;
|
|
34
|
-
/**
|
|
35
|
-
* A press on a menu's own cell while the menu is open: noted on the press, read on the click it ends in. On the Menu
|
|
36
|
-
* route the app's menu may close on that press as a press outside it; the click that follows must not open it again.
|
|
15
|
+
* A press on a menu's own cell while the menu is open: noted on the press, read on the click it ends in. The
|
|
16
|
+
* app's menu may close on that press as a press outside it; the click that follows must not open it again.
|
|
37
17
|
*/
|
|
38
18
|
export declare function useGridMenuPress(open: boolean): {
|
|
39
19
|
/** The cell's `onPointerDownCapture`: notes whether the menu was open as the press began. */
|
|
@@ -44,15 +24,11 @@ export declare function useGridMenuPress(open: boolean): {
|
|
|
44
24
|
pressedOpen: (event: ReactMouseEvent) => boolean;
|
|
45
25
|
};
|
|
46
26
|
/**
|
|
47
|
-
* Focus for a menu the grid's chrome opens (a column's menu, a footer's figure picker, a group's ⋯):
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* to its cell where it had nowhere else to go (`returnGridFocus`).
|
|
27
|
+
* Focus for a menu the grid's chrome opens (a column's menu, a footer's figure picker, a group's ⋯): the app's `Menu`
|
|
28
|
+
* places it as it opens; closed, it gives the focus back to its cell where it had nowhere else to go
|
|
29
|
+
* (`returnGridFocus`).
|
|
51
30
|
*/
|
|
52
|
-
export declare function useGridMenuFocus(open: boolean, anchor: HTMLElement | null):
|
|
53
|
-
initialFocus: boolean;
|
|
54
|
-
noteOpen: (event: ReactMouseEvent) => void;
|
|
55
|
-
};
|
|
31
|
+
export declare function useGridMenuFocus(open: boolean, anchor: HTMLElement | null): void;
|
|
56
32
|
/**
|
|
57
33
|
* The column menu an app holds (`openColumnMenu`), told once per change a person makes. One press can ask twice: the
|
|
58
34
|
* app's menu closes on the press, as on any press outside it, and the click that ends the press on a header asks
|