viewkitjs 0.29.0 → 0.30.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 +111 -0
- 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/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 +2 -5
- 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 +26 -13
- 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,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
4
4
|
import { parseNumber, roundTo, } from "viewkitjs/fields";
|
|
5
5
|
import { durationUnitToMs, formatDurationInput, msToDurationUnit, parseDurationInput, } from "viewkitjs/fields/query";
|
|
@@ -7,20 +7,15 @@ import { cx } from "../internal/cx.js";
|
|
|
7
7
|
import { BodyFrame } from "./BodyFrame.js";
|
|
8
8
|
import { useBodyStep } from "./body-step.js";
|
|
9
9
|
import { numberBodyKind, numberChange, resolveNumberBody } from "./number-body.js";
|
|
10
|
-
import { openingNumberText
|
|
11
|
-
import { ELEMENT_RESET } from "../internal/reset.js";
|
|
10
|
+
import { openingNumberText } from "./number-step.js";
|
|
12
11
|
import { useViews } from "../provider/context.js";
|
|
13
12
|
const EVERY_VALUE_READS = () => null;
|
|
14
|
-
export const
|
|
13
|
+
export const NumberEditorHost = forwardRef(function NumberEditorHost({ boxClassName, initial, seed, unit, unitOptions, code, decimals = 2, durationUnit, allowEmpty = false, align = "end", conventions, type = "number", label, min, max, check, escapeKeeps = false, closeOnBlur = true, form = "computer", onRequestClose, }, ref) {
|
|
15
14
|
const inputRef = useRef(null);
|
|
16
|
-
const chipRef = useRef(null);
|
|
17
|
-
const [currentUnit, setCurrentUnit] = useState(unit);
|
|
18
|
-
const [unitOpen, setUnitOpen] = useState(false);
|
|
19
15
|
const views = useViews();
|
|
20
16
|
const cv = conventions ?? views.conventions;
|
|
21
|
-
const {
|
|
17
|
+
const { Input } = views.components;
|
|
22
18
|
const NumberBody = durationUnit ? undefined : views.components.NumberBody;
|
|
23
|
-
const { List, Row } = views.atoms;
|
|
24
19
|
const onStepChange = useBodyStep();
|
|
25
20
|
useEffect(() => {
|
|
26
21
|
const el = inputRef.current;
|
|
@@ -54,16 +49,16 @@ export const NumberEditor = forwardRef(function NumberEditor({ boxClassName, ini
|
|
|
54
49
|
if (raw.trim() === "") {
|
|
55
50
|
if (!allowEmpty)
|
|
56
51
|
return { kind: "cancel" };
|
|
57
|
-
if (!Number.isFinite(initial)
|
|
52
|
+
if (!Number.isFinite(initial))
|
|
58
53
|
return { kind: "noop" };
|
|
59
|
-
return { kind: "commit", payload: { value: null, unit
|
|
54
|
+
return { kind: "commit", payload: { value: null, unit } };
|
|
60
55
|
}
|
|
61
56
|
const parsed = parse(raw);
|
|
62
57
|
if (parsed == null)
|
|
63
58
|
return { kind: "cancel" };
|
|
64
|
-
if (parsed === round(initial)
|
|
59
|
+
if (parsed === round(initial))
|
|
65
60
|
return { kind: "noop" };
|
|
66
|
-
return { kind: "commit", payload: { value: parsed, unit
|
|
61
|
+
return { kind: "commit", payload: { value: parsed, unit } };
|
|
67
62
|
};
|
|
68
63
|
const opening = () => ({
|
|
69
64
|
value: seed === undefined ? (Number.isFinite(initial) ? round(initial) : null) : (parse(seed) ?? Number.NaN),
|
|
@@ -89,40 +84,18 @@ export const NumberEditor = forwardRef(function NumberEditor({ boxClassName, ini
|
|
|
89
84
|
? (value, next) => check(value == null || !Number.isFinite(value) ? value : round(value), next !== undefined && units?.includes(next) ? next : draftRef.current.unit)
|
|
90
85
|
: EVERY_VALUE_READS, decimals: decimals, ...(min !== undefined ? { min } : {}), ...(max !== undefined ? { max } : {}), locale: cv.locale, ...(cv.decimal ? { decimal: cv.decimal } : {}), empty: allowEmpty, align: align, ...(seed !== undefined ? { typed: seed } : {}), autoFocus: true, form: form, ...(onStepChange && { onStepChange }) }) }));
|
|
91
86
|
}
|
|
92
|
-
return (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
onRequestClose("enter");
|
|
108
|
-
}
|
|
109
|
-
else if (e.key === "Escape") {
|
|
110
|
-
onRequestClose("escape");
|
|
111
|
-
}
|
|
112
|
-
else if (e.key === "Tab") {
|
|
113
|
-
e.preventDefault();
|
|
114
|
-
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
115
|
-
}
|
|
116
|
-
}, onBlur: () => {
|
|
117
|
-
if (!unitOpen)
|
|
118
|
-
onRequestClose("blur");
|
|
119
|
-
}, onClick: (e) => e.stopPropagation(), className: cx("h-full min-w-0 select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "start" ? "w-40 flex-initial text-left" : "w-full flex-1 text-right", boxClassName) }), (unit ?? code) &&
|
|
120
|
-
(unit && unitOptions && unitOptions.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("button", { ref: chipRef, type: "button", tabIndex: -1, onMouseDown: (e) => e.preventDefault(), onClick: (e) => {
|
|
121
|
-
e.stopPropagation();
|
|
122
|
-
setUnitOpen((o) => !o);
|
|
123
|
-
}, className: cx(ELEMENT_RESET, "shrink-0 text-xs font-normal text-(color:--vk-fg-subtle) transition-colors hover:text-(color:--vk-fg)", unitLeft && "order-first"), children: currentUnit }), _jsx(Popover, { open: unitOpen, onOpenChange: (next) => setUnitOpen(next), anchor: chipRef, side: "bottom", align: unitLeft ? "start" : "end", sideOffset: 6, initialFocus: false, onOutsidePress: (event) => (chipRef.current?.contains(event.target) ? false : undefined), onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-24", children: _jsx(List, { children: unitOptions.map((u) => (_jsx(Row, { label: u, chosen: u === currentUnit, onMouseDown: (e) => e.preventDefault(), onClick: () => {
|
|
124
|
-
setCurrentUnit(u);
|
|
125
|
-
setUnitOpen(false);
|
|
126
|
-
inputRef.current?.focus();
|
|
127
|
-
} }, u))) }) })] })) : (_jsx("span", { className: cx("shrink-0 text-xs font-normal text-(color:--vk-fg-subtlest)", unitLeft && "order-first"), children: unit ?? code })))] }));
|
|
87
|
+
return (_jsx("span", { className: "flex h-full w-full min-w-0 items-center gap-1.5", children: _jsx(Input, { ref: inputRef, defaultValue: seed ?? initialText, inputMode: "text", onKeyDown: (e) => {
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
if (e.key === "Enter") {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
onRequestClose("enter");
|
|
92
|
+
}
|
|
93
|
+
else if (e.key === "Escape") {
|
|
94
|
+
onRequestClose("escape");
|
|
95
|
+
}
|
|
96
|
+
else if (e.key === "Tab") {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
99
|
+
}
|
|
100
|
+
}, onBlur: () => onRequestClose("blur"), onClick: (e) => e.stopPropagation(), className: cx("h-full min-w-0 select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "start" ? "w-40 flex-initial text-left" : "w-full flex-1 text-right", boxClassName) }) }));
|
|
128
101
|
});
|
|
@@ -1,51 +1,27 @@
|
|
|
1
1
|
import { type CloseReason, type CloseResolution, type FieldConventions, type RangePreset, type RangeValue } from "viewkitjs/fields";
|
|
2
2
|
/**
|
|
3
|
-
* A RANGE — two
|
|
4
|
-
*
|
|
5
|
-
* is not a close. An empty box is an open end; two empty boxes are a clear,
|
|
6
|
-
* committed only when the host allows one.
|
|
3
|
+
* A RANGE — two ends, low and high, drawn by the app's `PartsBody` (`CONTROLS.PartsBody` is ViewKit's own). An empty
|
|
4
|
+
* end is an open end; two empty ends are a clear, committed only when the host allows one.
|
|
7
5
|
*
|
|
8
|
-
* A field that names its bands (`presets`, such as a company's 1–10 or 11–50
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* band writes its two ends into the boxes and closes as a pick, so the band is
|
|
12
|
-
* read, compared and judged exactly as typed ends are. The boxes stay, so a value
|
|
13
|
-
* between bands is still typed.
|
|
14
|
-
*
|
|
15
|
-
* With bands listed, the editor draws its host's refusal itself, between the
|
|
16
|
-
* boxes and the bands (atop the menu, or above the list below), so the bands
|
|
17
|
-
* never cover the reason or push it away from the boxes it is about.
|
|
6
|
+
* A field that names its bands (`presets`, such as a company's 1–10 or 11–50 people) hands them to the body, which
|
|
7
|
+
* lists them; a band chosen writes its two ends and closes as a pick, so the band is read, compared and judged exactly
|
|
8
|
+
* as typed ends are. The body draws no refusal: the host's panel draws it.
|
|
18
9
|
*/
|
|
19
10
|
export type RangeEditorHandle = {
|
|
20
11
|
resolveClose: (reason: CloseReason) => CloseResolution<RangeValue>;
|
|
21
12
|
};
|
|
22
13
|
export declare const RangeEditor: import("react").ForwardRefExoticComponent<{
|
|
23
14
|
initial: RangeValue | null;
|
|
24
|
-
/** Type-to-replace: the character that opened the editor replaces the low
|
|
15
|
+
/** Type-to-replace: the character that opened the editor replaces the low end. */
|
|
25
16
|
seed?: string;
|
|
26
17
|
decimals?: number;
|
|
27
18
|
allowEmpty?: boolean;
|
|
28
|
-
/** A unit drawn after the high
|
|
19
|
+
/** A unit drawn after the high end: "%", a currency code. */
|
|
29
20
|
suffix?: string;
|
|
30
|
-
align?: "start" | "end";
|
|
31
21
|
conventions?: FieldConventions;
|
|
32
|
-
/** The field's bands (`presets`):
|
|
22
|
+
/** The field's bands (`presets`): the body lists them, and choosing one saves that band. */
|
|
33
23
|
bands?: readonly RangePreset[];
|
|
34
|
-
/**
|
|
35
|
-
* editor typed where its value stands. `below`: in the editor's own column, for an editor
|
|
36
|
-
* that already sits in a sheet or a panel. */
|
|
37
|
-
bandsAt?: "popover" | "below";
|
|
38
|
-
/** The host's reason for refusing the range typed or picked. With bands listed it is drawn here,
|
|
39
|
-
* between the boxes and the bands, and the host draws none of its own; without bands the editor
|
|
40
|
-
* draws nothing, and the host draws it as for any type-in. */
|
|
41
|
-
refusal?: string | null;
|
|
42
|
-
/** Classes for the box that holds the two inputs: the host's frame, such as a sheet's field. */
|
|
43
|
-
boxClassName?: string;
|
|
44
|
-
/** The field's name, for an app's `PartsBody`. Default: the two ends' words. */
|
|
24
|
+
/** The field's name, for the app's `PartsBody`. Default: the two ends' words. */
|
|
45
25
|
label?: string;
|
|
46
|
-
/** The lowest either end may hold, where the field says: a box steps no lower. */
|
|
47
|
-
min?: number;
|
|
48
|
-
/** The highest either end may hold, where the field says: a box steps no higher. */
|
|
49
|
-
max?: number;
|
|
50
26
|
onRequestClose: (reason: CloseReason) => void;
|
|
51
27
|
} & import("react").RefAttributes<RangeEditorHandle>>;
|
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import { forwardRef,
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { parseNumber, roundTo, } from "viewkitjs/fields";
|
|
5
|
-
import { cx } from "../internal/cx.js";
|
|
6
5
|
import { useViews } from "../provider/context.js";
|
|
7
6
|
import { BodyFrame } from "./BodyFrame.js";
|
|
8
7
|
import { useBodyStep } from "./body-step.js";
|
|
9
8
|
import { mergeParts, rangeBodyStart, resolveRangeBody } from "./parts-body.js";
|
|
10
|
-
import { openingNumberText, stepDelta, stepKey, steppedNumber, writeStep } from "./number-step.js";
|
|
11
9
|
import { usePickerForm } from "./picker-slot.js";
|
|
12
|
-
export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, decimals = 0, allowEmpty = false, suffix,
|
|
10
|
+
export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, decimals = 0, allowEmpty = false, suffix, conventions, bands, label, onRequestClose }, ref) {
|
|
13
11
|
const views = useViews();
|
|
14
|
-
const {
|
|
12
|
+
const { PartsBody } = views.components;
|
|
15
13
|
const onStepChange = useBodyStep();
|
|
16
|
-
const { List, Row } = views.atoms;
|
|
17
14
|
const cv = conventions ?? views.conventions;
|
|
18
|
-
const rootRef = useRef(null);
|
|
19
|
-
const boxRef = useRef(null);
|
|
20
|
-
const lowRef = useRef(null);
|
|
21
|
-
const highRef = useRef(null);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
const el = lowRef.current;
|
|
24
|
-
if (!el)
|
|
25
|
-
return;
|
|
26
|
-
el.focus({ preventScroll: true });
|
|
27
|
-
el.setSelectionRange(el.value.length, el.value.length);
|
|
28
|
-
}, []);
|
|
29
15
|
const parse = (raw) => {
|
|
30
16
|
if (raw.trim() === "")
|
|
31
17
|
return null;
|
|
32
18
|
const n = parseNumber(raw, cv);
|
|
33
19
|
return n == null ? undefined : roundTo(n, decimals);
|
|
34
20
|
};
|
|
35
|
-
const text = (n) => n == null ? "" : openingNumberText(n, decimals, cv);
|
|
36
21
|
const form = usePickerForm();
|
|
37
22
|
const [bodyDraft, setBodyDraft] = useState(() => rangeBodyStart(initial, seed, parse));
|
|
38
23
|
const bodyRef = useRef(bodyDraft);
|
|
@@ -41,85 +26,15 @@ export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, deci
|
|
|
41
26
|
useLayoutEffect(() => {
|
|
42
27
|
shownRef.current = bodyValue;
|
|
43
28
|
});
|
|
44
|
-
const resolveClose = (reason) => {
|
|
45
|
-
if (reason === "escape")
|
|
46
|
-
return { kind: "cancel" };
|
|
47
|
-
const low = parse(lowRef.current?.value ?? "");
|
|
48
|
-
const high = parse(highRef.current?.value ?? "");
|
|
49
|
-
if (low === undefined || high === undefined)
|
|
50
|
-
return { kind: "cancel" };
|
|
51
|
-
const shown = (n) => (n == null ? null : roundTo(n, decimals));
|
|
52
|
-
if (low === shown(initial?.low) && high === shown(initial?.high))
|
|
53
|
-
return { kind: "noop" };
|
|
54
|
-
if (low === null && high === null && !allowEmpty)
|
|
55
|
-
return { kind: "cancel" };
|
|
56
|
-
return { kind: "commit", payload: { low, high } };
|
|
57
|
-
};
|
|
58
29
|
useImperativeHandle(ref, () => ({
|
|
59
|
-
resolveClose:
|
|
60
|
-
? (reason) => resolveRangeBody(reason, bodyRef.current, initial, decimals, allowEmpty)
|
|
61
|
-
: resolveClose,
|
|
30
|
+
resolveClose: (reason) => resolveRangeBody(reason, bodyRef.current, initial, decimals, allowEmpty),
|
|
62
31
|
}));
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const box = e.currentTarget;
|
|
69
|
-
const current = parse(box.value);
|
|
70
|
-
if (current === undefined)
|
|
71
|
-
return;
|
|
72
|
-
writeStep(box, text(steppedNumber(current, delta, { decimals, min, max })));
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (e.key === "Enter") {
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
onRequestClose("enter");
|
|
78
|
-
}
|
|
79
|
-
else if (e.key === "Escape") {
|
|
80
|
-
onRequestClose("escape");
|
|
81
|
-
}
|
|
82
|
-
else if (e.key === "Tab") {
|
|
83
|
-
e.preventDefault();
|
|
84
|
-
if (which === "low" && !e.shiftKey)
|
|
85
|
-
highRef.current?.focus();
|
|
86
|
-
else if (which === "high" && e.shiftKey)
|
|
87
|
-
lowRef.current?.focus();
|
|
88
|
-
else
|
|
89
|
-
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const blur = (e) => {
|
|
93
|
-
if (!rootRef.current?.contains(e.relatedTarget))
|
|
94
|
-
onRequestClose("blur");
|
|
95
|
-
};
|
|
96
|
-
const pickBand = (band) => {
|
|
97
|
-
if (lowRef.current)
|
|
98
|
-
lowRef.current.value = text(band.low);
|
|
99
|
-
if (highRef.current)
|
|
100
|
-
highRef.current.value = text(band.high);
|
|
101
|
-
onRequestClose("pick");
|
|
102
|
-
};
|
|
103
|
-
const held = (band) => {
|
|
104
|
-
const at = (n) => (n == null ? null : roundTo(n, decimals));
|
|
105
|
-
return initial != null && at(initial.low) === band.low && at(initial.high) === band.high;
|
|
32
|
+
const take = (next) => {
|
|
33
|
+
const current = bodyRef.current;
|
|
34
|
+
const merged = mergeParts({ low: current.low, high: current.high }, shownRef.current, next);
|
|
35
|
+
bodyRef.current = { low: merged.low, high: merged.high, unread: false };
|
|
36
|
+
setBodyDraft(bodyRef.current);
|
|
106
37
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const below = bandList !== null && bandsAt === "below";
|
|
110
|
-
const reason = bandList !== null && refusal ? (_jsx("p", { role: "alert", "data-slot": "vk-editor-refusal", className: cx("text-xs text-(color:--vk-danger)", !below && "px-2 pb-1 pt-1.5"), children: refusal })) : null;
|
|
111
|
-
if (PartsBody) {
|
|
112
|
-
const take = (next) => {
|
|
113
|
-
const current = bodyRef.current;
|
|
114
|
-
const merged = mergeParts({ low: current.low, high: current.high }, shownRef.current, next);
|
|
115
|
-
bodyRef.current = { low: merged.low, high: merged.high, unread: false };
|
|
116
|
-
setBodyDraft(bodyRef.current);
|
|
117
|
-
};
|
|
118
|
-
return (_jsx(BodyFrame, { slot: "vk-parts-body", onRequestClose: onRequestClose, children: _jsx(PartsBody, { kind: "range", value: bodyValue, onValueChange: take, decimals: decimals, ...(suffix !== undefined ? { unit: suffix } : {}), ...(bands !== undefined ? { bands } : {}), label: label ??
|
|
119
|
-
`${views.messages({ key: "views.editors.range-low" })} – ${views.messages({ key: "views.editors.range-high" })}`, onDone: (how) => onRequestClose(how === "pick" ? "pick" : "enter"), empty: allowEmpty, typed: seed, autoFocus: true, form: form, ...(onStepChange && { onStepChange }) }) }));
|
|
120
|
-
}
|
|
121
|
-
return (_jsxs("span", { ref: rootRef, onMouseDown: (e) => {
|
|
122
|
-
if (!(e.target instanceof HTMLInputElement))
|
|
123
|
-
e.preventDefault();
|
|
124
|
-
}, className: below ? "flex w-full min-w-0 flex-col gap-1" : "contents", children: [_jsxs("span", { ref: boxRef, className: cx("flex h-full w-full min-w-0 items-center gap-1.5", align === "end" && "justify-end", boxClassName), children: [_jsx(Input, { ref: lowRef, defaultValue: seed ?? text(initial?.low), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-low" }), placeholder: views.messages({ key: "views.editors.range-low" }), onKeyDown: keys("low"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: "\u2013" }), _jsx(Input, { ref: highRef, defaultValue: text(initial?.high), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-high" }), placeholder: views.messages({ key: "views.editors.range-high" }), onKeyDown: keys("high"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), suffix && _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtlest)", children: suffix })] }), below && reason, below && bandList, bandList !== null && !below && (_jsxs(Popover, { open: true, onOpenChange: () => { }, anchor: boxRef, side: "bottom", align: align === "end" ? "end" : "start", sideOffset: 6, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-40", children: [reason, bandList] }))] }));
|
|
38
|
+
return (_jsx(BodyFrame, { slot: "vk-parts-body", onRequestClose: onRequestClose, children: _jsx(PartsBody, { kind: "range", value: bodyValue, onValueChange: take, decimals: decimals, ...(suffix !== undefined ? { unit: suffix } : {}), ...(bands !== undefined ? { bands } : {}), label: label ??
|
|
39
|
+
`${views.messages({ key: "views.editors.range-low" })} – ${views.messages({ key: "views.editors.range-high" })}`, onDone: (how) => onRequestClose(how === "pick" ? "pick" : "enter"), empty: allowEmpty, typed: seed, autoFocus: true, form: form, ...(onStepChange && { onStepChange }) }) }));
|
|
125
40
|
});
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { CloseReason, CloseResolution, FieldMessageResolver } from "viewkitjs/fields";
|
|
3
|
-
import { type RelationCreate } from "./relation-
|
|
3
|
+
import { type RelationCreate } from "./relation-picker.js";
|
|
4
4
|
import type { RelationSource } from "./relation-source.js";
|
|
5
5
|
export { RELATION_PAGE_SIZE, RELATION_SEARCH_DEBOUNCE_MS } from "./relation-source.js";
|
|
6
6
|
export type { RelationCandidate, RelationSearch, RelationSource } from "./relation-source.js";
|
|
7
|
-
export type { RelationCreate } from "./relation-
|
|
7
|
+
export type { RelationCreate } from "./relation-picker.js";
|
|
8
8
|
export { RelationSetEditor, type RelationSetEditorHandle, type RelationSetItem, } from "./RelationSetEditor.js";
|
|
9
9
|
/**
|
|
10
10
|
* THE relation-picking core — search the candidates, pick one, it REPLACES the
|
|
11
11
|
* link. Many-to-one, so there is nothing to accumulate.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* relation: a pick is the commit, everything else discards. The list itself —
|
|
18
|
-
* the search, the candidates, the host's pinned create rows — is the shared
|
|
19
|
-
* `RelationPanel`.
|
|
13
|
+
* The list is the app's `Picker` (the components map's), handed the candidates
|
|
14
|
+
* as data, the host's create rows as its actions. The host owns the mounting;
|
|
15
|
+
* what lives here is what a close MEANS for a relation: a pick is the commit,
|
|
16
|
+
* everything else discards.
|
|
20
17
|
*/
|
|
21
18
|
export type RelationEditorHandle = {
|
|
22
19
|
/** What this close means. Synchronous, idempotent, no timer — the host
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef,
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
4
4
|
import { useViews } from "../provider/context.js";
|
|
5
|
-
import { RelationPanel } from "./relation-panel.js";
|
|
6
5
|
import { RelationPickerBody } from "./relation-picker.js";
|
|
7
6
|
export { RELATION_PAGE_SIZE, RELATION_SEARCH_DEBOUNCE_MS } from "./relation-source.js";
|
|
8
7
|
export { RelationSetEditor, } from "./RelationSetEditor.js";
|
|
@@ -10,15 +9,9 @@ export const RelationEditor = forwardRef(function RelationEditor({ candidates, i
|
|
|
10
9
|
const [picked, setPicked] = useState(undefined);
|
|
11
10
|
const pickedRef = useRef(undefined);
|
|
12
11
|
const [query, setQuery] = useState(seed ?? "");
|
|
13
|
-
const searchRef = useRef(null);
|
|
14
12
|
const views = useViews();
|
|
15
13
|
const words = message ?? views.conventions.messages;
|
|
16
|
-
const {
|
|
17
|
-
const { RowContent } = views.atoms;
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (focusSearch)
|
|
20
|
-
searchRef.current?.focus({ preventScroll: true });
|
|
21
|
-
}, []);
|
|
14
|
+
const { Picker } = views.components;
|
|
22
15
|
const resolveClose = (reason) => {
|
|
23
16
|
if (reason !== "pick")
|
|
24
17
|
return { kind: "cancel" };
|
|
@@ -28,28 +21,16 @@ export const RelationEditor = forwardRef(function RelationEditor({ candidates, i
|
|
|
28
21
|
return value === initial ? { kind: "noop" } : { kind: "commit", payload: value };
|
|
29
22
|
};
|
|
30
23
|
useImperativeHandle(ref, () => ({ resolveClose }));
|
|
31
|
-
const pick = (id) => {
|
|
32
|
-
pickedRef.current = id;
|
|
33
|
-
setPicked(id);
|
|
34
|
-
onRequestClose("pick");
|
|
35
|
-
};
|
|
36
24
|
const current = picked === undefined ? initial : picked;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
pickedRef.current = undefined;
|
|
46
|
-
setPicked(undefined);
|
|
47
|
-
onRequestClose("pick");
|
|
48
|
-
create.onCreate(typed);
|
|
49
|
-
}, kindGlyph: kindGlyph, search: words({ key: "editor.search" }), onTab: (reason) => onRequestClose(reason), typed: seed, autoFocus: focusSearch }));
|
|
50
|
-
}
|
|
51
|
-
return (_jsx(RelationPanel, { candidates: candidates, query: query, onQueryChange: setQuery, searchRef: searchRef, kindGlyph: kindGlyph, message: message, creates: creates, onCreate: (create, typed) => {
|
|
25
|
+
return (_jsx(RelationPickerBody, { Picker: Picker, label: label ?? words({ key: "editor.search" }), candidates: candidates, query: query, onQueryChange: setQuery, held: [], multiple: false, value: current ?? null, onValueChange: (id) => {
|
|
26
|
+
if (typeof id === "string" || id === null) {
|
|
27
|
+
pickedRef.current = id;
|
|
28
|
+
setPicked(id);
|
|
29
|
+
}
|
|
30
|
+
}, onDone: () => onRequestClose("pick"), empty: clearable ? (noneLabel ?? words({ key: "relation.none" })) : undefined, creates: creates, onCreate: (create, typed) => {
|
|
31
|
+
pickedRef.current = undefined;
|
|
32
|
+
setPicked(undefined);
|
|
52
33
|
onRequestClose("pick");
|
|
53
34
|
create.onCreate(typed);
|
|
54
|
-
},
|
|
35
|
+
}, kindGlyph: kindGlyph, search: words({ key: "editor.search" }), onTab: (reason) => onRequestClose(reason), typed: seed, autoFocus: focusSearch }));
|
|
55
36
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type CloseReason, type CloseResolution, type FieldMessageResolver, type RelationDraftLink, type RelationLinks } from "viewkitjs/fields";
|
|
3
|
-
import { type RelationCreate } from "./relation-
|
|
3
|
+
import { type RelationCreate } from "./relation-picker.js";
|
|
4
4
|
import type { RelationSource } from "./relation-source.js";
|
|
5
5
|
/** One linked record as the several-records core holds it: the link, and what its row shows. */
|
|
6
6
|
export type RelationSetItem = RelationDraftLink & {
|
|
@@ -13,29 +13,18 @@ export type RelationSetEditorHandle = {
|
|
|
13
13
|
resolveClose: (reason: CloseReason) => CloseResolution<RelationDraftLink[]>;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* THE core for a relation holding several records
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* ONE change: a click outside, the sheet's ✓, Tab or Shift-Tab commit what it
|
|
20
|
-
* holds, as pick many does; Escape and the sheet's ✕ throw it away.
|
|
16
|
+
* THE core for a relation holding several records, in the app's `Picker`: search the candidates, and every pick adds
|
|
17
|
+
* a record to the set or takes it out, with the list kept open. The set leaves as ONE change: a click outside, the
|
|
18
|
+
* sheet's ✓, Tab or Shift-Tab commit what it holds, as pick many does; Escape and the sheet's ✕ throw it away.
|
|
21
19
|
*
|
|
22
|
-
* The linked records are
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* another is marked, and removing the lead passes it to the next; Space on a
|
|
27
|
-
* highlighted linked record, with the search empty, makes it the lead, as its
|
|
28
|
-
* Make lead button does. A link keeps the role and roles it was stored with; a
|
|
29
|
-
* new one has neither.
|
|
20
|
+
* The linked records are handed first, chosen, whatever page the search holds — a remote list may not hold them at all.
|
|
21
|
+
* Where the field leads by a flag the first is the lead (the Picker's `lead`); a record added joins at the end, so the
|
|
22
|
+
* lead stays until another is marked, and removing the lead passes it to the next. A link keeps the role and roles it
|
|
23
|
+
* was stored with; a new one has neither.
|
|
30
24
|
*
|
|
31
|
-
* Handed the field's `links
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* saves it first.
|
|
35
|
-
*
|
|
36
|
-
* The highlight opens on the first linked record. Until it leaves that record,
|
|
37
|
-
* by a key, by typing or by the pointer, an Enter does nothing, so the first
|
|
38
|
-
* linked record is never taken out unasked.
|
|
25
|
+
* Handed the field's `links`, the set opens the app's `LinksBody` instead: each link's roles, the field's roles and the
|
|
26
|
+
* lead go to it, and what it sets is saved, each link's roles in the key it was stored with (`writtenRoles`). There the
|
|
27
|
+
* lead is held beside the links, so a line never moves when it changes; the set still saves it first.
|
|
39
28
|
*/
|
|
40
29
|
export declare const RelationSetEditor: import("react").ForwardRefExoticComponent<{
|
|
41
30
|
candidates: RelationSource;
|
|
@@ -57,7 +46,7 @@ export declare const RelationSetEditor: import("react").ForwardRefExoticComponen
|
|
|
57
46
|
focusSearch?: boolean;
|
|
58
47
|
/** The field's name, for an app's own `Picker` (its list's accessible name). Default: the search's words. */
|
|
59
48
|
label?: string;
|
|
60
|
-
/** The field's `links`: handed,
|
|
61
|
-
*
|
|
49
|
+
/** The field's `links`: handed, the set opens the app's `LinksBody` with each link's roles and the field's roles;
|
|
50
|
+
* left out, its `Picker`. */
|
|
62
51
|
links?: RelationLinks;
|
|
63
52
|
} & import("react").RefAttributes<RelationSetEditorHandle>>;
|