viewkitjs 0.32.0 → 0.33.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 +69 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/query/evaluate.d.ts +7 -0
- package/fields/dist/query/exact-number.d.ts +8 -2
- package/fields/dist/query/exact-number.js +14 -1
- package/fields/dist/query/sort.js +13 -10
- package/fields/dist/registry.js +5 -1
- package/fields/dist/types.d.ts +4 -1
- package/fields/dist/zod.d.ts +5 -0
- package/fields/dist/zod.js +10 -1
- package/fields/docs/guides/contact-values.md +12 -0
- package/fields/docs/guides/field-types.md +1 -1
- package/fields/docs/guides/queries.md +3 -1
- package/fields/docs/reference/fields.md +1 -0
- package/package.json +1 -1
- package/postgres/dist/check.js +4 -1
- package/postgres/dist/definitions/formula-forms.js +3 -1
- package/postgres/dist/definitions/money.js +2 -1
- package/postgres/dist/page.js +6 -3
- package/postgres/dist/rules.d.ts +15 -1
- package/postgres/dist/rules.js +16 -0
- package/postgres/dist/sort.js +7 -2
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +1 -1
- package/postgres/docs/reference/definitions.md +1 -1
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +4 -3
- package/views/dist/atoms/frame-parts.d.ts +6 -0
- package/views/dist/atoms/frame-parts.js +15 -0
- package/views/dist/atoms/types.d.ts +16 -7
- package/views/dist/cells/cell-title.d.ts +3 -1
- package/views/dist/cells/cell-title.js +2 -2
- package/views/dist/cells/cell-values.js +2 -2
- package/views/dist/contract.d.ts +31 -6
- package/views/dist/contract.js +123 -0
- package/views/dist/controls/button/map-button.js +2 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +3 -2
- package/views/dist/controls/checkbox/checkbox.js +2 -2
- package/views/dist/controls/compound-editor/compound-editor.d.ts +1 -1
- package/views/dist/controls/compound-editor/name-parts.js +4 -4
- package/views/dist/controls/compound-editor/place-parts.js +19 -19
- package/views/dist/controls/compound-editor/range-parts.js +14 -14
- package/views/dist/controls/compound-editor/row.d.ts +3 -1
- package/views/dist/controls/compound-editor/row.js +2 -2
- package/views/dist/controls/controls.d.ts +2 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/customize/customize.js +37 -35
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
- package/views/dist/controls/customize/map-customize-body.js +4 -0
- package/views/dist/controls/date-editor/date-days.js +2 -2
- package/views/dist/controls/date-editor/date-editor.js +18 -18
- package/views/dist/controls/date-editor/date-parts.js +6 -6
- package/views/dist/controls/date-editor/map-calendar.js +1 -1
- package/views/dist/controls/date-editor.css +2 -2
- package/views/dist/controls/field/field.d.ts +3 -0
- package/views/dist/controls/field/field.js +6 -6
- package/views/dist/controls/filter-editor/block.d.ts +2 -2
- package/views/dist/controls/filter-editor/block.js +5 -5
- package/views/dist/controls/filter-editor/filter-editor.js +31 -33
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +1 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +7 -3
- package/views/dist/controls/filter-editor/map-rules.js +1 -1
- package/views/dist/controls/filter-editor/parts.js +2 -1
- package/views/dist/controls/group-editor/group-editor.js +15 -13
- package/views/dist/controls/index.d.ts +2 -0
- package/views/dist/controls/index.js +1 -0
- package/views/dist/controls/input/input.js +2 -2
- package/views/dist/controls/input/map-input.js +2 -0
- package/views/dist/controls/internal/editor-parts.js +1 -1
- package/views/dist/controls/internal/map-panel-controls.d.ts +8 -0
- package/views/dist/controls/internal/map-panel-controls.js +20 -0
- package/views/dist/controls/internal/panel-controls.d.ts +50 -0
- package/views/dist/controls/internal/panel-controls.js +197 -0
- package/views/dist/controls/internal/part-slot.d.ts +12 -0
- package/views/dist/controls/internal/part-slot.js +5 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +1 -1
- package/views/dist/controls/links-editor/links-editor.js +27 -27
- package/views/dist/controls/menu/map-menu.d.ts +2 -2
- package/views/dist/controls/menu/map-menu.js +15 -12
- package/views/dist/controls/menu/menu.d.ts +2 -0
- package/views/dist/controls/menu/menu.js +3 -3
- package/views/dist/controls/menu-list/menu-list.d.ts +14 -4
- package/views/dist/controls/menu-list/menu-list.js +23 -22
- package/views/dist/controls/notice/notice.d.ts +3 -1
- package/views/dist/controls/notice/notice.js +2 -2
- package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
- package/views/dist/controls/number-editor/number-editor.js +13 -13
- package/views/dist/controls/number-field/number-field.js +5 -3
- package/views/dist/controls/pane/pane.d.ts +4 -2
- package/views/dist/controls/pane/pane.js +4 -4
- package/views/dist/controls/picker/picker.d.ts +2 -0
- package/views/dist/controls/picker/picker.js +37 -36
- package/views/dist/controls/picker/rows.d.ts +4 -0
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +4 -2
- package/views/dist/controls/quick-filters/quick-filters.js +4 -4
- package/views/dist/controls/radio/radio.d.ts +3 -0
- package/views/dist/controls/radio/radio.js +4 -3
- package/views/dist/controls/select/map-select.d.ts +3 -0
- package/views/dist/controls/select/map-select.js +8 -0
- package/views/dist/controls/select/select.d.ts +3 -0
- package/views/dist/controls/select/select.js +3 -3
- package/views/dist/controls/sheet/bottom-sheet.d.ts +5 -1
- package/views/dist/controls/sheet/bottom-sheet.js +2 -2
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/sort-editor/map-sort-body.d.ts +1 -0
- package/views/dist/controls/sort-editor/map-sort-body.js +7 -3
- package/views/dist/controls/sort-editor/sort-editor.js +24 -26
- package/views/dist/controls/sort-editor.css +5 -0
- package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
- package/views/dist/controls/text-editor/text-editor.js +8 -8
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +3 -3
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +7 -6
- package/views/dist/controls/values-editor/values-editor.d.ts +1 -1
- package/views/dist/controls/values-editor/values-editor.js +22 -22
- package/views/dist/controls/views-list/map-view-menu.js +1 -1
- package/views/dist/controls/views-list/view-menu.js +6 -6
- package/views/dist/controls/views-list/views-list.js +4 -4
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +13 -0
- package/views/dist/fields/money.d.ts +5 -2
- package/views/dist/fields/money.js +14 -2
- package/views/dist/grid/chrome/GridTable.js +4 -1
- package/views/dist/grid/chrome/cell-clipboard.d.ts +4 -2
- package/views/dist/grid/chrome/cell-clipboard.js +2 -2
- package/views/dist/grid/chrome/cells.js +3 -1
- package/views/dist/grid/chrome/grid-row-menu-items.js +1 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +29 -6
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +9 -2
- package/views/dist/grid/core/clipboard-model.d.ts +3 -1
- package/views/dist/grid/core/clipboard-model.js +9 -8
- package/views/dist/grid/core/editing-controller.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.js +6 -0
- package/views/dist/grid/core/edits-sink.d.ts +19 -0
- package/views/dist/grid/core/edits-sink.js +2 -0
- package/views/dist/grid/core/spreadsheet-operations.js +1 -1
- package/views/dist/grid/core/useGridEditing.d.ts +5 -0
- package/views/dist/grid/core/useGridEditing.js +6 -0
- package/views/dist/list/answer.d.ts +40 -0
- package/views/dist/list/answer.js +43 -0
- package/views/dist/list/bulk-bar.d.ts +7 -0
- package/views/dist/list/bulk-bar.js +10 -0
- package/views/dist/list/columns.d.ts +24 -0
- package/views/dist/list/columns.js +27 -0
- package/views/dist/list/edits.d.ts +19 -0
- package/views/dist/list/edits.js +56 -0
- package/views/dist/list/grid.d.ts +11 -0
- package/views/dist/list/grid.js +76 -0
- package/views/dist/list/index.d.ts +14 -1
- package/views/dist/list/index.js +4 -1
- package/views/dist/list/link.d.ts +8 -0
- package/views/dist/list/link.js +78 -0
- package/views/dist/list/list.d.ts +70 -0
- package/views/dist/list/list.js +14 -0
- package/views/dist/list/parts.js +10 -3
- package/views/dist/list/root-base.d.ts +46 -0
- package/views/dist/list/root-base.js +137 -0
- package/views/dist/list/root.d.ts +35 -34
- package/views/dist/list/root.js +153 -113
- package/views/dist/list/source-answers.d.ts +39 -0
- package/views/dist/list/source-answers.js +225 -0
- package/views/dist/list/store.d.ts +37 -5
- package/views/dist/list/store.js +31 -0
- package/views/dist/list/toolbar.d.ts +3 -2
- package/views/dist/list/toolbar.js +14 -2
- package/views/dist/list/views-axis.js +4 -2
- package/views/dist/list/views.d.ts +7 -2
- package/views/dist/list/views.js +16 -5
- package/views/dist/model/column-capabilities.d.ts +13 -0
- package/views/dist/model/column-capabilities.js +23 -2
- package/views/dist/model/column-schema.d.ts +11 -1
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/model.d.ts +2 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +8 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +2 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +8 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +12 -3
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -4
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilter.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/context.d.ts +10 -1
- package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
- package/views/dist/panels/react/toolbar/panel-part.js +5 -3
- package/views/dist/panels/settings/filter-groups.js +6 -1
- package/views/dist/provider/ViewsProvider.d.ts +6 -2
- package/views/dist/provider/ViewsProvider.js +18 -1
- package/views/dist/provider/components.d.ts +59 -0
- package/views/dist/provider/components.js +1 -1
- package/views/dist/provider/context.d.ts +4 -1
- package/views/dist/provider/own-control.d.ts +4 -0
- package/views/dist/provider/own-control.js +7 -0
- package/views/dist/provider/select-items.d.ts +3 -0
- package/views/dist/provider/select-items.js +6 -0
- package/views/dist/react.d.ts +4 -2
- package/views/dist/react.js +2 -0
- package/views/dist/styles.css +86 -78
- package/views/dist/styles.unlayered.css +86 -78
- package/views/docs/contract.md +252 -5
- package/views/docs/controls/compound-editor.md +4 -0
- package/views/docs/controls/customize.md +6 -0
- package/views/docs/controls/date-editor.md +4 -0
- package/views/docs/controls/field.md +4 -0
- package/views/docs/controls/filter-editor.md +8 -0
- package/views/docs/controls/group-editor.md +6 -0
- package/views/docs/controls/input.md +4 -0
- package/views/docs/controls/links-editor.md +4 -0
- package/views/docs/controls/menu-list.md +8 -0
- package/views/docs/controls/menu.md +4 -0
- package/views/docs/controls/notice.md +4 -0
- package/views/docs/controls/number-editor.md +4 -0
- package/views/docs/controls/pane.md +4 -0
- package/views/docs/controls/picker.md +8 -0
- package/views/docs/controls/quick-filters.md +6 -0
- package/views/docs/controls/radio.md +4 -0
- package/views/docs/controls/select.md +8 -0
- package/views/docs/controls/sheet.md +4 -0
- package/views/docs/controls/sort-editor.md +8 -0
- package/views/docs/controls/text-editor.md +4 -0
- package/views/docs/controls/values-editor.md +4 -0
- package/views/docs/controls/views-list.md +6 -0
- package/views/docs/guides/the-grid.md +2 -2
- package/views/docs/guides/the-provider.md +19 -2
- package/views/docs/reference/controls.md +7 -5
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +1 -1
- package/views/docs/reference/list.md +141 -11
- package/views/docs/reference/panels-react.md +2 -2
- package/views/docs/reference/react.md +15 -9
- package/views/docs/reference/views.md +8 -4
- package/views/docs/reshaping.md +6 -1
|
@@ -22,10 +22,10 @@ export const SheetClose = ({ children }) => _jsx(Base.Close, { render: children
|
|
|
22
22
|
export function SheetButton({ className, kind, children, ...props }) {
|
|
23
23
|
return _jsxs(_Fragment, { children: [_jsx(GlassButton, { ...props, kind: kind, className: cx("o-sheet-glass", className), children: children }), _jsx(Button, { ...props, kind: kind ?? "quiet", shape: children == null ? "icon" : undefined, className: cx("o-sheet-plain", className), children: children })] });
|
|
24
24
|
}
|
|
25
|
-
export function SheetHead({ title, mark, titleLabel, titleAt, description, close = true, onBack, left, right, children, words, step }) {
|
|
25
|
+
export function SheetHead({ title, mark, titleLabel, titleAt, description, close = true, onBack, backSlot, left, right, children, words, step }) {
|
|
26
26
|
const closeWord = words?.close ?? "Close", backWord = words?.back ?? "Back";
|
|
27
27
|
const sides = left != null || right != null;
|
|
28
|
-
return (_jsx("div", { className: "o-sheet-head", children: _jsx(HeaderBar, { className: "o-sheet-row", titleAt: titleAt, mark: mark, "data-sides": sides ? "" : undefined, "data-step": step ? (step.back ? "back" : "in") : undefined, left: sides ? left : onBack ? _jsx(SheetButton, { "aria-label": backWord, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack }) : close && _jsx(Base.Close, { render: _jsx(GlassButton, { "aria-label": closeWord, className: "o-sheet-glass", icon: glyph(X) }) }), title: _jsx(Base.Title, { className: "o-sheet-title", "aria-label": titleLabel, children: title }), description: description, descriptionRender: _jsx(Base.Description, {}), right: sides ? right : _jsxs(_Fragment, { children: [children, close && _jsx(Base.Close, { render: _jsx(Button, { kind: "quiet", shape: "icon", "aria-label": closeWord, className: "o-sheet-plain", icon: glyph(X) }) })] }) }, step?.id) }));
|
|
28
|
+
return (_jsx("div", { className: "o-sheet-head", children: _jsx(HeaderBar, { className: "o-sheet-row", titleAt: titleAt, mark: mark, "data-sides": sides ? "" : undefined, "data-step": step ? (step.back ? "back" : "in") : undefined, left: sides ? left : onBack ? _jsx(SheetButton, { "aria-label": backWord, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack, ...(backSlot ? { "data-slot": backSlot } : {}) }) : close && _jsx(Base.Close, { render: _jsx(GlassButton, { "aria-label": closeWord, className: "o-sheet-glass", icon: glyph(X) }) }), title: _jsx(Base.Title, { className: "o-sheet-title", "aria-label": titleLabel, children: title }), description: description, descriptionRender: _jsx(Base.Description, {}), right: sides ? right : _jsxs(_Fragment, { children: [children, close && _jsx(Base.Close, { render: _jsx(Button, { kind: "quiet", shape: "icon", "aria-label": closeWord, className: "o-sheet-plain", icon: glyph(X) }) })] }) }, step?.id) }));
|
|
29
29
|
}
|
|
30
30
|
export const SheetFoot = ({ children }) => _jsx("div", { className: "o-sheet-foot", children: children });
|
|
31
31
|
export const SheetBody = React.forwardRef(function SheetBody({ onScroll, children }, ref) {
|
|
@@ -21,6 +21,6 @@ export function MapSheet({ open, onOpenChange, title, label, description, action
|
|
|
21
21
|
return (_jsxs(Sheet, { open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), label: name, ...SNAP_FORM[snap ?? "full"], className: className, children: [parts
|
|
22
22
|
? _jsx(SheetHead, { title: parts.title, ...parts.head, words: words })
|
|
23
23
|
: actions && left
|
|
24
|
-
? _jsx(SheetHead, { title: shown, titleLabel: titleLabel, description: description, left: _jsx(SheetButton, { "aria-label": left.label, className: actions.back ? "o-sheet-back" : undefined, icon: actions.back ? _jsx(Back, {}) : _jsx(Close, {}), onClick: left.onPress }), right: actions.done ? _jsx(SheetButton, { kind: "primary", "aria-label": actions.done.label, icon: _jsx(Check, {}), onClick: actions.done.onPress }) : _jsx("span", {}) })
|
|
24
|
+
? _jsx(SheetHead, { title: shown, titleLabel: titleLabel, description: description, left: _jsx(SheetButton, { "data-slot": actions.back ? "vk-editor-back" : "vk-editor-close", "aria-label": left.label, className: actions.back ? "o-sheet-back" : undefined, icon: actions.back ? _jsx(Back, {}) : _jsx(Close, {}), onClick: left.onPress }), right: actions.done ? _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": actions.done.label, icon: _jsx(Check, {}), onClick: actions.done.onPress }) : _jsx("span", {}) })
|
|
25
25
|
: (title != null || description != null) && _jsx(SheetHead, { title: shown, titleLabel: titleLabel, description: description, words: words }), _jsx(SheetBody, { children: _jsx(SheetPartsFrom.Provider, { value: setParts, children: children }) }), parts?.foot && _jsx(SheetFoot, { children: parts.foot })] }));
|
|
26
26
|
}
|
|
@@ -6,4 +6,5 @@ import type { SortEditorWords } from "./words.js";
|
|
|
6
6
|
export declare function sortEditorWordsOf(say: ViewsMessageResolver): SortEditorWords;
|
|
7
7
|
/** ViewKit's sort body's props as the sort editor's. */
|
|
8
8
|
export declare function sortEditorPropsOf(p: ViewsSortBodyProps, words: SortEditorWords, say?: ViewsMessageResolver): SortEditorProps;
|
|
9
|
+
/** ViewKit's sort body, its controls the app's where the provider's `panelControls` names them (VK-1013). */
|
|
9
10
|
export declare function MapSortBody(props: ViewsSortBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { resolveViewsMessage } from "../../contract.js";
|
|
5
5
|
import { ViewsContext } from "../../provider/context.js";
|
|
6
6
|
import { glyph, TICK, X } from "../internal/editor-parts.js";
|
|
7
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
7
8
|
import { useToldStep } from "../internal/told-step.js";
|
|
8
9
|
import { pickerWordsOf } from "../picker/map-picker.js";
|
|
9
10
|
import { HeaderBar } from "../phone-header/header-bar.js";
|
|
@@ -66,6 +67,9 @@ export function sortEditorPropsOf(p, words, say = resolveViewsMessage) {
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
export function MapSortBody(props) {
|
|
70
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(SortBodyInner, { ...props }) });
|
|
71
|
+
}
|
|
72
|
+
function SortBodyInner(props) {
|
|
69
73
|
const views = React.useContext(ViewsContext);
|
|
70
74
|
const messages = views?.messages ?? resolveViewsMessage;
|
|
71
75
|
const words = React.useMemo(() => sortEditorWordsOf(messages), [messages]);
|
|
@@ -74,8 +78,8 @@ export function MapSortBody(props) {
|
|
|
74
78
|
const { actions } = props;
|
|
75
79
|
if (!actions)
|
|
76
80
|
return _jsx(_Fragment, { children: parts.body });
|
|
77
|
-
const done = actions.done && _jsx(SheetButton, { kind: "primary", "aria-label": actions.done.label, icon: glyph(TICK), onClick: actions.done.onPress });
|
|
81
|
+
const done = actions.done && _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": actions.done.label, icon: glyph(TICK), onClick: actions.done.onPress });
|
|
78
82
|
return (_jsxs(_Fragment, { children: [parts.title !== undefined
|
|
79
|
-
? _jsx(BodyHead, { title: parts.title, left: _jsx(SheetButton, { "aria-label": words.back, className: "o-sheet-back", icon: glyph(BACK), onClick: parts.head.onBack }), right: done || _jsx("span", {}) })
|
|
80
|
-
: _jsx(BodyHead, { title: props.label, left: _jsx(SheetButton, { "aria-label": actions.close.label, icon: glyph(X), onClick: actions.close.onPress }), right: done || _jsx("span", {}) }), parts.body] }));
|
|
83
|
+
? _jsx(BodyHead, { title: parts.title, left: _jsx(SheetButton, { "data-slot": "vk-editor-back", "aria-label": words.back, className: "o-sheet-back", icon: glyph(BACK), onClick: parts.head.onBack }), right: done || _jsx("span", {}) })
|
|
84
|
+
: _jsx(BodyHead, { title: props.label, left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": actions.close.label, icon: glyph(X), onClick: actions.close.onPress }), right: done || _jsx("span", {}) }), parts.body] }));
|
|
81
85
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { Button } from "../button/button.js";
|
|
5
4
|
import { FieldRows, FieldRowsRow as FieldRow } from "../field/field.js";
|
|
6
5
|
import { Grip } from "../grip/grip.js";
|
|
7
6
|
import { asSelect, DOTS, DOTS_LOOK, DOTS_UP, glyph, MORE_LOOK, PLUS, TRASH, useDecide, useStandingRoom, X } from "../internal/editor-parts.js";
|
|
8
7
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
8
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
9
9
|
import { moved, useReorder } from "../internal/reorder.js";
|
|
10
10
|
import { useStepReturn } from "../internal/step-return.js";
|
|
11
|
-
import { Menu } from "../menu/menu.js";
|
|
12
11
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
13
12
|
import { findItem, itemLabel } from "../picker/rows.js";
|
|
14
|
-
import { Popover } from "../popover/popover.js";
|
|
15
|
-
import { Select } from "../select/select.js";
|
|
16
13
|
import { Tooltip } from "../tooltip/tooltip.js";
|
|
17
14
|
import { addSort, canAddSort, dropAside, openPlaces, putBack, repoint, SORT_MAX, takenBy } from "./rules.js";
|
|
18
15
|
import { sortWords } from "./words.js";
|
|
@@ -20,8 +17,8 @@ const ASCENDING = ["M4 6l7 0", "M4 12l7 0", "M4 18l9 0", "M15 9l3 -3l3 3", "M18
|
|
|
20
17
|
const DESCENDING = ["M4 6l9 0", "M4 12l7 0", "M4 18l7 0", "M15 15l3 3l3 -3", "M18 6l0 12"];
|
|
21
18
|
const markOf = (paths) => _jsx("span", { className: "o-sort-editor-mark", children: glyph(paths) });
|
|
22
19
|
const directionsOf = (w) => [
|
|
23
|
-
{ value: "ascending", label: w.ascending, as: { mark: markOf(ASCENDING) } },
|
|
24
|
-
{ value: "descending", label: w.descending, as: { mark: markOf(DESCENDING) } },
|
|
20
|
+
{ value: "ascending", label: w.ascending, as: { mark: markOf(ASCENDING) }, slot: { slot: "vk-sort-direction-option", key: "ascending" } },
|
|
21
|
+
{ value: "descending", label: w.descending, as: { mark: markOf(DESCENDING) }, slot: { slot: "vk-sort-direction-option", key: "descending" } },
|
|
25
22
|
];
|
|
26
23
|
const isDirection = (v) => v === "ascending" || v === "descending";
|
|
27
24
|
const DirectionFit = ({ items }) => (_jsx("span", { className: "o-sort-editor-fit", "aria-hidden": "true", children: items.map((i) => (_jsxs("span", { className: "o-input o-input-xs o-select-field", children: [_jsxs("span", { className: "o-select-value", children: [i.mark, _jsx("span", { className: "o-list-main", children: i.label })] }), _jsx("span", { className: "o-select-chevron", children: _jsx("svg", {}) })] }, i.value))) }));
|
|
@@ -34,6 +31,7 @@ function fieldsFor(fields, rules, sorted, own, fieldOf) {
|
|
|
34
31
|
export const sortableFields = (fields, rules, fieldOf, sorted = sortWords().sorted) => fieldsFor(fields, rules, sorted, undefined, fieldOf);
|
|
35
32
|
export function useSortEditor(props) {
|
|
36
33
|
const { label, fields, rules, onRulesChange, max = SORT_MAX, onDone, opens, fieldOf, addSort: adds = true } = props;
|
|
34
|
+
const { Button, Select, Menu, Popover } = usePanelControls();
|
|
37
35
|
const aside = React.useMemo(() => props.aside ?? [], [props.aside]);
|
|
38
36
|
const w = sortWords(props.words), search = props.search ?? w.search, DIRECTIONS = directionsOf(w);
|
|
39
37
|
const words = w.picker ? { words: w.picker } : {};
|
|
@@ -111,25 +109,25 @@ export function useSortEditor(props) {
|
|
|
111
109
|
React.useEffect(() => { if (step && step.list !== "add" && !stepRule && !(step.list === "repoint" && aside.some((a) => a.key === step.key)))
|
|
112
110
|
setStep(null); }, [step, stepRule, aside]);
|
|
113
111
|
const stepTitle = phone && step ? (stepRule ? nameOf(stepRule.field) : stepAside ? w.fieldNamed(stepAside.label) : step.list === "add" ? w.add : undefined) : undefined;
|
|
114
|
-
const addButton = (size) => (_jsx(Tooltip, { label: w.max(max), reason: true, side: "top", disabled: can, children: _jsx(Button, { kind: "outline", size: size, icon: glyph(PLUS), className: "o-sort-editor-add", disabled: !can, focusableWhenDisabled: true, "aria-haspopup": phone ? undefined : "dialog", "aria-expanded": phone ? undefined : pop?.list === "add", onClick: (e) => { const at = e.currentTarget; if (phone)
|
|
112
|
+
const addButton = (size) => (_jsx(Tooltip, { label: w.max(max), reason: true, side: "top", disabled: can, children: _jsx(Button, { kind: "outline", size: size, icon: glyph(PLUS), className: "o-sort-editor-add", "data-slot": "vk-sort-add", disabled: !can, focusableWhenDisabled: true, "aria-haspopup": phone ? undefined : "dialog", "aria-expanded": phone ? undefined : pop?.list === "add", onClick: (e) => { const at = e.currentTarget; if (phone)
|
|
115
113
|
setStep({ list: "add" });
|
|
116
114
|
else
|
|
117
115
|
setPop((p) => (p?.list === "add" ? null : { list: "add", rule: -1, at })); }, children: w.add }) }));
|
|
118
116
|
const closePop = () => setPop(null);
|
|
119
117
|
const addPicker = _jsx(Picker, { label: w.add, items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { addField(v); }, ...words });
|
|
120
118
|
const asideEntries = (a) => [
|
|
121
|
-
{ icon: null, label: a.why, disabled: a.why },
|
|
122
|
-
...(a.back != null ? [{ icon: null, label: w.putBack, onSelect: () => backOn(a.key) }] : []),
|
|
123
|
-
{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => drop(a.key) },
|
|
119
|
+
{ icon: null, label: a.why, disabled: a.why, slot: { slot: "vk-sort-rule-action", key: "why" } },
|
|
120
|
+
...(a.back != null ? [{ icon: null, label: w.putBack, onSelect: () => backOn(a.key), slot: { slot: "vk-sort-rule-action", key: "put-back" } }] : []),
|
|
121
|
+
{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => drop(a.key), slot: { slot: "vk-sort-rule-action", key: "delete" } },
|
|
124
122
|
];
|
|
125
123
|
if (phone || narrow) {
|
|
126
124
|
const size = phone ? "44" : "sm";
|
|
127
125
|
const more = (name) => (phone
|
|
128
|
-
? _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-sort-editor-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS) })
|
|
129
|
-
: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-sort-editor-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS_UP) }));
|
|
126
|
+
? _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS) })
|
|
127
|
+
: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS_UP) }));
|
|
130
128
|
const ruleRow = (r, i) => {
|
|
131
129
|
const name = nameOf(r.field), mark = markFor(r.field), g = gripProps(i), standing = narrow && opens?.list === "direction" && opens.rule === i;
|
|
132
|
-
const inner = _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "o-sort-editor-press", ...g, onPointerDown: (e) => { dragged.current = false; setMoving(false); g.onPointerDown(e); }, "aria-haspopup": narrow ? "dialog" : undefined, "aria-expanded": narrow ? pop?.list === "direction" && pop.rule === i : undefined, onClick: (e) => {
|
|
130
|
+
const inner = _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "o-sort-editor-press", "data-slot": "vk-sort-rule-open", ...g, onPointerDown: (e) => { dragged.current = false; setMoving(false); g.onPointerDown(e); }, "aria-haspopup": narrow ? "dialog" : undefined, "aria-expanded": narrow ? pop?.list === "direction" && pop.rule === i : undefined, onClick: (e) => {
|
|
133
131
|
if (dragged.current) {
|
|
134
132
|
dragged.current = false;
|
|
135
133
|
return;
|
|
@@ -139,39 +137,39 @@ export function useSortEditor(props) {
|
|
|
139
137
|
setPop((p) => (p?.list === "direction" && p.rule === i ? null : { list: "direction", rule: i, at }));
|
|
140
138
|
else
|
|
141
139
|
setStep({ list: "direction", rule: i });
|
|
142
|
-
}, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }), _jsx(Menu, { label: w.sortBy(name), align: "end", entries: [{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => change(now.current.filter((_, k) => k !== i)) }], trigger: more(name) }), standing && shownList(DIRECTIONS, r.direction, w.direction, false)] });
|
|
140
|
+
}, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }), _jsx(Menu, { label: w.sortBy(name), align: "end", entries: [{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => change(now.current.filter((_, k) => k !== i)), slot: { slot: "vk-sort-rule-action", key: "delete" } }], trigger: more(name) }), standing && shownList(DIRECTIONS, r.direction, w.direction, false)] });
|
|
143
141
|
return phone
|
|
144
|
-
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule", "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field)
|
|
145
|
-
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule", "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field);
|
|
142
|
+
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field)
|
|
143
|
+
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field);
|
|
146
144
|
};
|
|
147
145
|
const asideRow = (a) => {
|
|
148
|
-
const inner = _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "o-sort-editor-press", "aria-haspopup": narrow ? "dialog" : undefined, "aria-expanded": narrow ? pop?.list === "repoint" && pop.key === a.key : undefined, onClick: (e) => { const at = e.currentTarget; if (narrow)
|
|
146
|
+
const inner = _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "o-sort-editor-press", "data-slot": "vk-sort-rule-open", "aria-haspopup": narrow ? "dialog" : undefined, "aria-expanded": narrow ? pop?.list === "repoint" && pop.key === a.key : undefined, onClick: (e) => { const at = e.currentTarget; if (narrow)
|
|
149
147
|
setPop((p) => (p?.list === "repoint" && p.key === a.key ? null : { list: "repoint", rule: -1, key: a.key, at }));
|
|
150
148
|
else {
|
|
151
149
|
repointed.current = null;
|
|
152
150
|
setStep({ list: "repoint", key: a.key });
|
|
153
151
|
} }, children: _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: a.label }), _jsx("span", { className: "o-sort-editor-way", children: a.why })] }) }), _jsx(Menu, { label: w.sortBy(a.label), align: "end", entries: asideEntries(a), trigger: more(a.label) })] });
|
|
154
152
|
return phone
|
|
155
|
-
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`)
|
|
156
|
-
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`);
|
|
153
|
+
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`)
|
|
154
|
+
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`);
|
|
157
155
|
};
|
|
158
156
|
const popRule = pop?.list === "direction" ? rules[pop.rule] : undefined;
|
|
159
157
|
const popAside = pop?.list === "repoint" ? aside.find((a) => a.key === pop.key) : undefined;
|
|
160
|
-
const body = (_jsxs("div", { ref: placeRoot, className: "o-sort-editor", "data-kit": "sort-editor", "data-sort-form": way, role: narrow ? "group" : undefined, "aria-label": narrow ? label : undefined, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-sort-step": stepTitle !== undefined ? step?.list : undefined, children: [stepTitle !== undefined ? stepList.body : _jsxs(_Fragment, { children: [rules.length || aside.length ? (phone
|
|
161
|
-
? _jsxs(FieldRows, { look: ROWS, className: "o-sort-editor-card", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })
|
|
162
|
-
: _jsxs("div", { className: "o-sort-editor-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })), _jsxs("div", { className: "o-sort-editor-acts", children: [addButton(size), rules.length > 0 && _jsx(Button, { kind: "quiet", size: size, className: "o-sort-editor-clear", onClick: () => change([]), children: w.clearAll })] })] }), narrow && (_jsx(Popover, { open: !!pop && (pop.list === "add" || !!popRule || !!popAside), onOpenChange: (o) => { if (!o)
|
|
158
|
+
const body = (_jsxs("div", { ref: placeRoot, className: "o-sort-editor", "data-slot": "vk-sort", "data-kit": "sort-editor", "data-sort-form": way, role: narrow ? "group" : undefined, "aria-label": narrow ? label : undefined, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-sort-step": stepTitle !== undefined ? step?.list : undefined, children: [stepTitle !== undefined ? stepList.body : _jsxs(_Fragment, { children: [rules.length || aside.length ? (phone
|
|
159
|
+
? _jsxs(FieldRows, { look: ROWS, className: "o-sort-editor-card", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })
|
|
160
|
+
: _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })), _jsxs("div", { className: "o-sort-editor-acts", "data-slot": "vk-sort-foot", children: [addButton(size), rules.length > 0 && _jsx(Button, { kind: "quiet", size: size, className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", onClick: () => change([]), children: w.clearAll })] })] }), narrow && (_jsx(Popover, { open: !!pop && (pop.list === "add" || !!popRule || !!popAside), onOpenChange: (o) => { if (!o)
|
|
163
161
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": pop?.list === "add" ? w.add : popAside ? w.fieldNamed(popAside.label) : popRule ? nameOf(popRule.field) : label, children: pop?.list === "add"
|
|
164
162
|
? addPicker
|
|
165
163
|
: popAside ? _jsx(Picker, { label: w.fieldNamed(popAside.label), items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { pointAt(popAside.key)(v); closePop(); }, ...words })
|
|
166
164
|
: popRule && _jsx(Picker, { label: nameOf(popRule.field), items: DIRECTIONS, value: popRule.direction, searchShown: false, form: "computer", fromHeld: true, onDone: closePop, onValueChange: turn(pop?.rule ?? -1), ...words }) }))] }));
|
|
167
165
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
168
166
|
}
|
|
169
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-sort-editor", "data-kit": "sort-editor", "data-sort-form": "computer", role: "group", "aria-label": label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: (rules.length > 0 || aside.length > 0) && _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-sort-editor-rules", role: "list", "aria-label": label, children: [rules.map((r, i) => {
|
|
167
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-sort-editor", "data-slot": "vk-sort", "data-kit": "sort-editor", "data-sort-form": "computer", role: "group", "aria-label": label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: (rules.length > 0 || aside.length > 0) && _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map((r, i) => {
|
|
170
168
|
const name = nameOf(r.field), g = gripProps(i), open = opens?.rule === i ? opens.list : null;
|
|
171
169
|
const items = pickable(r.field);
|
|
172
|
-
return (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule", "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: [_jsx(Grip, { label: w.move(name), className: "o-sort-editor-grip", ...g }), _jsxs("div", { className: "o-sort-editor-field", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.field, items: asSelect(items), value: r.field, search: search, "data-force": open === "field" ? "focus" : undefined, onValueChange: (v) => { if (typeof v === "string" && v !== r.field && !takenBy(now.current, v, r.field, fieldOf))
|
|
173
|
-
change(now.current.map((x, k) => (k === i ? { ...x, field: v } : x))); } }), open === "field" && shownList(items, r.field, w.field, true)] }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, items: asSelect(DIRECTIONS), value: r.direction, "data-force": open === "direction" ? "focus" : undefined, onValueChange: turn(i) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) }), open === "direction" && shownList(DIRECTIONS, r.direction, w.direction, false)] }), _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-remove", "aria-label": w.remove(name), icon: glyph(X), onClick: () => remove(i) })] }, r.field));
|
|
174
|
-
}), aside.map((a) => (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-aside": "", "data-aside-key": a.key, children: [_jsx("span", { className: "o-sort-editor-grip-place", "aria-hidden": "true" }), _jsx("div", { className: "o-sort-editor-field", children: _jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.fieldNamed(a.label), items: asSelect(pickable()), value: null, placeholder: a.label, search: search, onValueChange: pointAt(a.key) }) }) }) }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, items: asSelect(DIRECTIONS), value: a.direction, disabled: true, onValueChange: () => { } }) }) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) })] }), _jsx(Menu, { label: w.sortBy(a.label), align: "end", entries: asideEntries(a), trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-more", "aria-label": w.actionsFor(a.label), icon: glyph(DOTS) }) })] }, `aside-${a.key}`)))] }), (adds || rules.length > 0) && _jsxs("div", { className: "o-sort-editor-foot", children: [adds && addButton("sm"), rules.length > 0 && _jsx(Button, { kind: "quiet", size: "sm", className: "o-sort-editor-clear", onClick: () => { closePop(); change([]); if (!asideNow.current.length)
|
|
170
|
+
return (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: [_jsx(Grip, { label: w.move(name), className: "o-sort-editor-grip", "data-slot": "vk-sort-grip", ...g }), _jsxs("div", { className: "o-sort-editor-field", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.field, "data-slot": "vk-sort-field", items: asSelect(items), value: r.field, search: search, "data-force": open === "field" ? "focus" : undefined, onValueChange: (v) => { if (typeof v === "string" && v !== r.field && !takenBy(now.current, v, r.field, fieldOf))
|
|
171
|
+
change(now.current.map((x, k) => (k === i ? { ...x, field: v } : x))); } }), open === "field" && shownList(items, r.field, w.field, true)] }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: r.direction, "data-force": open === "direction" ? "focus" : undefined, onValueChange: turn(i) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) }), open === "direction" && shownList(DIRECTIONS, r.direction, w.direction, false)] }), _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-remove", "data-slot": "vk-sort-remove", "aria-label": w.remove(name), icon: glyph(X), onClick: () => remove(i) })] }, r.field));
|
|
172
|
+
}), aside.map((a) => (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: [_jsx("span", { className: "o-sort-editor-grip-place", "aria-hidden": "true" }), _jsx("div", { className: "o-sort-editor-field", children: _jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.fieldNamed(a.label), "data-slot": "vk-sort-field", items: asSelect(pickable()), value: null, placeholder: a.label, search: search, onValueChange: pointAt(a.key) }) }) }) }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: a.direction, disabled: true, onValueChange: () => { } }) }) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) })] }), _jsx(Menu, { label: w.sortBy(a.label), align: "end", entries: asideEntries(a), trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(a.label), icon: glyph(DOTS) }) })] }, `aside-${a.key}`)))] }), (adds || rules.length > 0) && _jsxs("div", { className: "o-sort-editor-foot", "data-slot": "vk-sort-foot", children: [adds && addButton("sm"), rules.length > 0 && _jsx(Button, { kind: "quiet", size: "sm", className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", onClick: () => { closePop(); change([]); if (!asideNow.current.length)
|
|
175
173
|
onDone?.(); }, children: w.clearAllSorts })] }), _jsx(Popover, { open: pop?.list === "add", onOpenChange: (o) => { if (!o)
|
|
176
174
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": w.add, children: pop?.list === "add" && addPicker })] }) }));
|
|
177
175
|
return { body, head: {} };
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
/* Add sort's fields, and in the narrow form a rule's direction, in the Popover under what was pressed: as wide as its rows, never
|
|
41
41
|
under 192 (the kit's w-fit and min-w-48, written here since an app compiles no utilities of ViewKit's). */
|
|
42
42
|
.o-popover.o-sort-editor-pop { width: fit-content; min-width: calc(var(--vk-spacing) * 48); }
|
|
43
|
+
/* ViewKit's own Popover holding the rules on a computer (the ready toolbar's Sort): as wide as its rows, so each rule's grip, field,
|
|
44
|
+
direction and × stand inside it, never under the 288 it opens Add sort's fields at, and never past the room on screen (its own
|
|
45
|
+
--available-width, popover.css). Keyed on what it holds, so the fields with no rule keep their 288; an app's own Popover, or its own
|
|
46
|
+
width on this one, is the app's (VK-977). */
|
|
47
|
+
.o-popover:has(.o-sort-editor[data-sort-form="computer"]) { width: max-content; min-width: max(var(--anchor-width, 0px), calc(var(--vk-spacing) * 72)); }
|
|
43
48
|
|
|
44
49
|
/* A list a page shows standing open: under what opens it, over the rules, as the Select's list stands, as wide as its rows, never
|
|
45
50
|
under 192 nor its box, never past 288 (listWidth, select.css). Scoped to the editor, so it wins over the smooth list's own
|
|
@@ -48,7 +48,7 @@ export interface TextEditorParts {
|
|
|
48
48
|
/** What the shell holds: on a computer what stands in the cell, on a phone what the Sheet's body holds. */
|
|
49
49
|
body: React.ReactNode;
|
|
50
50
|
/** On a phone, the Sheet head's ✕ (left) and ✓ (right), or on a step its back; on a computer, nothing. */
|
|
51
|
-
head: Pick<SheetHeadProps, "left" | "right" | "onBack" | "close">;
|
|
51
|
+
head: Pick<SheetHeadProps, "left" | "right" | "onBack" | "backSlot" | "close">;
|
|
52
52
|
/** On a phone's step, its title (Country); left out, the field's name. */
|
|
53
53
|
title?: string;
|
|
54
54
|
}
|
|
@@ -232,15 +232,15 @@ export function useTextEditor(props) {
|
|
|
232
232
|
}, [root, form, place, draft, worn.box, worn.long, worn.phone, kind, long, shown]);
|
|
233
233
|
if (form === "phone") {
|
|
234
234
|
const step = withCountry && open;
|
|
235
|
-
const field = withCountry ? (_jsxs(InputGroup, { size: "lg", children: [_jsxs(InputGroupAddon, { side: "start", children: [_jsx(InputGroupButton, { className: "o-text-editor-country", "aria-label": `${w.country}: ${countryName(phone.country, language)}`, iconEnd: glyph(DOWN), onClick: () => setOpen(true), children: _jsx("span", { className: "o-text-editor-country-code", children: phone.country }) }), _jsx("span", { className: "o-text-editor-dial", children: dialOf(phone.country) })] }), _jsx(Input, { ref: number, autofill: false, type: "tel", inputMode: "tel", enterKeyHint: "done", value: phone.digits, ...common, placeholder: patternOf(phone.country), spellCheck: false, onChange: (e) => movePhone({ digits: e.target.value }), onKeyDown: onKeyDown })] })) : (_jsx(Input, { ref: box, size: "lg", autofill: false, multiline: long || kind === "text", grow: long || kind === "text", className: long ? "o-text-editor-tall" : undefined, type: long || kind === "text" ? undefined : keys.type, inputMode: keys.inputMode, enterKeyHint: long ? undefined : "done", value: draft, ...common, onChange: change, onKeyDown: long ? undefined : onKeyDown }));
|
|
236
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-text-editor", "data-kit": "text-editor", "data-text-form": "phone", ...phoneMark(!!host || small), "data-text-kind": kind, "data-text-view": step ? "country" : undefined, children: step ? countriesList : _jsx(Field, { error: refused ?? undefined, children: field }) }));
|
|
235
|
+
const field = withCountry ? (_jsxs(InputGroup, { size: "lg", "data-slot": "vk-text-box", children: [_jsxs(InputGroupAddon, { side: "start", children: [_jsx(InputGroupButton, { className: "o-text-editor-country", "data-slot": "vk-text-country", "aria-label": `${w.country}: ${countryName(phone.country, language)}`, iconEnd: glyph(DOWN), onClick: () => setOpen(true), children: _jsx("span", { className: "o-text-editor-country-code", children: phone.country }) }), _jsx("span", { className: "o-text-editor-dial", "data-slot": "vk-text-dial", children: dialOf(phone.country) })] }), _jsx(Input, { ref: number, autofill: false, type: "tel", inputMode: "tel", enterKeyHint: "done", value: phone.digits, ...common, placeholder: patternOf(phone.country), spellCheck: false, onChange: (e) => movePhone({ digits: e.target.value }), onKeyDown: onKeyDown })] })) : (_jsx(Input, { ref: box, size: "lg", "data-slot": "vk-text-box", autofill: false, multiline: long || kind === "text", grow: long || kind === "text", className: long ? "o-text-editor-tall" : undefined, type: long || kind === "text" ? undefined : keys.type, inputMode: keys.inputMode, enterKeyHint: long ? undefined : "done", value: draft, ...common, onChange: change, onKeyDown: long ? undefined : onKeyDown }));
|
|
236
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-text-editor", "data-slot": "vk-text", "data-kit": "text-editor", "data-text-form": "phone", ...phoneMark(!!host || small), "data-text-kind": kind, "data-text-view": step ? "country" : undefined, children: step ? countriesList : _jsx(Field, { error: refused ?? undefined, children: field }) }));
|
|
237
237
|
if (step)
|
|
238
|
-
return { body, head: { onBack: () => setOpen(false), close: false }, title: w.country };
|
|
238
|
+
return { body, head: { onBack: () => setOpen(false), backSlot: "vk-editor-back", close: false }, title: w.country };
|
|
239
239
|
if (shell)
|
|
240
240
|
return { body, head: {} };
|
|
241
241
|
const head = {
|
|
242
|
-
left: _jsx(SheetButton, { "aria-label": "Close", icon: glyph(X), onClick: leave }),
|
|
243
|
-
right: _jsx(SheetButton, { kind: "primary", "aria-label": "Save", icon: glyph(TICK), onClick: keep }),
|
|
242
|
+
left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": "Close", icon: glyph(X), onClick: leave }),
|
|
243
|
+
right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": "Save", icon: glyph(TICK), onClick: keep }),
|
|
244
244
|
};
|
|
245
245
|
return { body, head };
|
|
246
246
|
}
|
|
@@ -252,8 +252,8 @@ export function useTextEditor(props) {
|
|
|
252
252
|
return;
|
|
253
253
|
keep();
|
|
254
254
|
};
|
|
255
|
-
const note = refused && _jsxs("div", { className: "o-text-editor-note", id: noteId, role: "alert", children: [glyph(["M12 8v5", "M12 16.5v.01", "M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"]), _jsx("span", { children: refused })] });
|
|
256
|
-
const body = (_jsxs("div", { ref: placeRoot, className: "o-text-editor", "data-kit": "text-editor", "data-text-form": "computer", ...phoneMark(!!host || small), "data-text-kind": kind, "data-text-box": worn.box, "data-text-place": place, "data-refused": refused ? "" : undefined, onBlur: blur, children: [withCountry ? _jsxs(_Fragment, { children: [_jsxs(InlineInputGroup, { className: "o-text-editor-phone", "data-refused": refused ? "" : undefined, children: [_jsx(InputGroupAddon, { side: "start", children: _jsx(InputGroupButton, { className: "o-text-editor-country", look: COUNTRY, "aria-label": `${w.country}: ${countryName(phone.country, language)}`, "aria-haspopup": "listbox", "aria-expanded": open, iconEnd: glyph(DOWN), onClick: () => setOpen((o) => !o), children: _jsx("span", { className: "o-text-editor-country-code", children: phone.country }) }) }), _jsx(InputGroupAddon, { side: "start", children: _jsx("span", { className: "o-text-editor-dial", children: dialOf(phone.country) }) }), _jsx(Input, { ref: number, className: "o-text-editor-number", type: "tel", inputMode: "tel", enterKeyHint: "done", value: phone.digits, ...common, autofill: false, placeholder: patternOf(phone.country), spellCheck: false, onChange: (e) => movePhone({ digits: e.target.value }), onKeyDown: onKeyDown, "aria-invalid": refused ? true : undefined, "aria-describedby": refused ? noteId : undefined })] }), _jsx(Popover, { open: open, onOpenChange: (o, d) => {
|
|
255
|
+
const note = refused && _jsxs("div", { className: "o-text-editor-note", "data-slot": "vk-text-note", id: noteId, role: "alert", children: [glyph(["M12 8v5", "M12 16.5v.01", "M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"]), _jsx("span", { children: refused })] });
|
|
256
|
+
const body = (_jsxs("div", { ref: placeRoot, className: "o-text-editor", "data-slot": "vk-text", "data-kit": "text-editor", "data-text-form": "computer", ...phoneMark(!!host || small), "data-text-kind": kind, "data-text-box": worn.box, "data-text-place": place, "data-refused": refused ? "" : undefined, onBlur: blur, children: [withCountry ? _jsxs(_Fragment, { children: [_jsxs(InlineInputGroup, { className: "o-text-editor-phone", "data-slot": "vk-text-box", "data-refused": refused ? "" : undefined, children: [_jsx(InputGroupAddon, { side: "start", children: _jsx(InputGroupButton, { className: "o-text-editor-country", "data-slot": "vk-text-country", look: COUNTRY, "aria-label": `${w.country}: ${countryName(phone.country, language)}`, "aria-haspopup": "listbox", "aria-expanded": open, iconEnd: glyph(DOWN), onClick: () => setOpen((o) => !o), children: _jsx("span", { className: "o-text-editor-country-code", children: phone.country }) }) }), _jsx(InputGroupAddon, { side: "start", children: _jsx("span", { className: "o-text-editor-dial", "data-slot": "vk-text-dial", children: dialOf(phone.country) }) }), _jsx(Input, { ref: number, className: "o-text-editor-number", type: "tel", inputMode: "tel", enterKeyHint: "done", value: phone.digits, ...common, autofill: false, placeholder: patternOf(phone.country), spellCheck: false, onChange: (e) => movePhone({ digits: e.target.value }), onKeyDown: onKeyDown, "aria-invalid": refused ? true : undefined, "aria-describedby": refused ? noteId : undefined })] }), _jsx(Popover, { open: open, onOpenChange: (o, d) => {
|
|
257
257
|
setOpen(o);
|
|
258
258
|
if (shell)
|
|
259
259
|
return;
|
|
@@ -262,7 +262,7 @@ export function useTextEditor(props) {
|
|
|
262
262
|
if (!o && d.reason === "focus-out")
|
|
263
263
|
requestAnimationFrame(() => { if (!root?.contains(document.activeElement))
|
|
264
264
|
keep(); });
|
|
265
|
-
}, anchor: root, side: "bottom", align: "start", sideOffset: spacingPx(1, root), onOutsidePress: (e) => (e.target instanceof Node && root?.contains(e.target) ? false : undefined), finalFocus: numberRef, style: { width: "calc(var(--vk-spacing) * 88)" }, "aria-label": w.country, children: _jsx("div", { ref: popup, children: open && countriesList }) })] }) : _jsxs(_Fragment, { children: [_jsx(InlineInput, { ref: box, multiline: true, className: "o-text-editor-box", value: draft, ...common, autofill: false, onChange: change, onKeyDown: onKeyDown, inputMode: keys.inputMode, enterKeyHint: long ? undefined : "done", "data-refused": refused ? "" : undefined, "aria-invalid": refused ? true : undefined, "aria-describedby": refused ? noteId : undefined }), _jsx("span", { ref: mirror, className: "o-text-editor-mirror", "aria-hidden": "true" })] }), note] }));
|
|
265
|
+
}, anchor: root, side: "bottom", align: "start", sideOffset: spacingPx(1, root), onOutsidePress: (e) => (e.target instanceof Node && root?.contains(e.target) ? false : undefined), finalFocus: numberRef, style: { width: "calc(var(--vk-spacing) * 88)" }, "aria-label": w.country, children: _jsx("div", { ref: popup, children: open && countriesList }) })] }) : _jsxs(_Fragment, { children: [_jsx(InlineInput, { ref: box, multiline: true, className: "o-text-editor-box", "data-slot": "vk-text-box", value: draft, ...common, autofill: false, onChange: change, onKeyDown: onKeyDown, inputMode: keys.inputMode, enterKeyHint: long ? undefined : "done", "data-refused": refused ? "" : undefined, "aria-invalid": refused ? true : undefined, "aria-describedby": refused ? noteId : undefined }), _jsx("span", { ref: mirror, className: "o-text-editor-mirror", "aria-hidden": "true" })] }), note] }));
|
|
266
266
|
return { body, head: {} };
|
|
267
267
|
}
|
|
268
268
|
export function TextEditor(props) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewsFramePart, ViewsToolbarButtonProps } from "../../atoms/types.js";
|
|
2
2
|
import { type ToolbarButtonGround, type ToolbarButtonProps } from "./toolbar-button.js";
|
|
3
3
|
/** How the Toolbar's own page dresses each of the toolbar's parts, on a phone or a computer, its tabs on the ground "The tabs"
|
|
4
4
|
* picks: the view switcher with its words and ▾ (on a phone, current and in the brand where the views are tabs, its words alone
|
|
5
5
|
* where they are one button); a tab its corners full, its words beside its icon, the open one current; "+N" an unopened tab's
|
|
6
6
|
* dress with its word; + its icon alone, ghost; Clear the ghost and Save the bordered, each its word. */
|
|
7
|
-
export declare function toolbarPartDress(part:
|
|
7
|
+
export declare function toolbarPartDress(part: ViewsFramePart, { current, phone, tabs, ground }: {
|
|
8
8
|
current?: boolean;
|
|
9
9
|
phone: boolean;
|
|
10
10
|
tabs: boolean;
|
|
11
11
|
ground: ToolbarButtonGround;
|
|
12
12
|
}): Partial<ToolbarButtonProps>;
|
|
13
13
|
/** The ToolbarButton atom as the toolbar button. ViewKit's own `size` is not read: in a Toolbar a button takes its line's. */
|
|
14
|
-
export declare function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, onContextMenu, onClick, onPointerDown, ref }: ViewsToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }: ViewsToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
5
|
+
import { isFramePart } from "../../atoms/frame-parts.js";
|
|
5
6
|
import { Button } from "../button/button.js";
|
|
6
7
|
import { Icon } from "../internal/icons.js";
|
|
7
8
|
import { useToolbarWorn } from "../toolbar/toolbar.js";
|
|
@@ -21,7 +22,7 @@ export function toolbarPartDress(part, { current, phone, tabs, ground }) {
|
|
|
21
22
|
case "save": return { ground: "bordered", words: "word" };
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, onContextMenu, onClick, onPointerDown, ref }) {
|
|
25
|
+
export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }) {
|
|
25
26
|
const row = React.useContext(InToolbar);
|
|
26
27
|
const [el, setEl] = React.useState(null);
|
|
27
28
|
const picks = useToolbarWorn(el);
|
|
@@ -36,16 +37,16 @@ export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, c
|
|
|
36
37
|
const text = children ?? (typeof word === "string" ? word : undefined);
|
|
37
38
|
const said = waits && text != null ? _jsx("span", { className: "o-toolbar-button-waits", children: text }) : text;
|
|
38
39
|
if (foot)
|
|
39
|
-
return _jsx(Button, { ref: own, kind: "primary", shape: "round", size: "44", icon: icon, "aria-label": label, disabled: disabled, onClick: onClick, onPointerDown: onPointerDown, ...opens });
|
|
40
|
+
return _jsx(Button, { ref: own, kind: "primary", shape: "round", size: "44", icon: icon, "aria-label": label, className: className, disabled: disabled, onClick: onClick, onPointerDown: onPointerDown, ...opens });
|
|
40
41
|
if (edge && !picks.add.startsWith("like")) {
|
|
41
42
|
const alone = word === null || picks.add.endsWith("-icon");
|
|
42
|
-
const button = (_jsx(Button, { ref: own, kind: picks.add.startsWith("primary") ? "primary" : "outline", size: BUTTON_SIZE[row?.size ?? "32"], icon: icon, shape: alone ? "icon" : undefined, "aria-label": alone ? label : undefined, disabled: disabled, onClick: onClick, onPointerDown: onPointerDown, ...opens, children: alone ? undefined : (said ?? label) }));
|
|
43
|
+
const button = (_jsx(Button, { ref: own, kind: picks.add.startsWith("primary") ? "primary" : "outline", size: BUTTON_SIZE[row?.size ?? "32"], icon: icon, shape: alone ? "icon" : undefined, "aria-label": alone ? label : undefined, className: className, disabled: disabled, onClick: onClick, onPointerDown: onPointerDown, ...opens, children: alone ? undefined : (said ?? label) }));
|
|
43
44
|
return row ? _jsx(BaseToolbar.Button, { render: button, disabled: disabled }) : button;
|
|
44
45
|
}
|
|
45
46
|
const words = iconAlone || (edge && picks.add === "like-icon") || word === null ? "icon" : undefined;
|
|
46
|
-
if (part) {
|
|
47
|
-
return (_jsx(ToolbarButtonControl, { ref: own, label: label, icon: icon, "data-slot": PART_SLOT[part], ...toolbarPartDress(part, { current, phone: row?.form === "phone", tabs: picks.views === "tabs", ground: picks.tabs ?? "ghost" }), disabled: disabled, focusableWhenDisabled: !!disabledReason, onClick: onClick, onPointerDown: onPointerDown, onContextMenu: onContextMenu, ...opens, children: said }));
|
|
47
|
+
if (isFramePart(part)) {
|
|
48
|
+
return (_jsx(ToolbarButtonControl, { ref: own, label: label, icon: icon, className: className, "data-slot": PART_SLOT[part], ...toolbarPartDress(part, { current, phone: row?.form === "phone", tabs: picks.views === "tabs", ground: picks.tabs ?? "ghost" }), disabled: disabled, focusableWhenDisabled: !!disabledReason, onClick: onClick, onPointerDown: onPointerDown, onContextMenu: onContextMenu, ...opens, children: said }));
|
|
48
49
|
}
|
|
49
50
|
const counted = !dot && typeof count === "number" && count > 0 ? count : more;
|
|
50
|
-
return (_jsx(ToolbarButtonControl, { ref: own, label: label, icon: icon, words: words, count: counted, dot: dot, empty: empty, lit: changed, aside: aside, stays: edge, joined: joined, ...(waits ? { "data-waits": "" } : {}), disabled: disabled, focusableWhenDisabled: !!disabledReason, onClick: onClick, onPointerDown: onPointerDown, ...opens, children: said }));
|
|
51
|
+
return (_jsx(ToolbarButtonControl, { ref: own, label: label, icon: icon, className: className, words: words, count: counted, dot: dot, empty: empty, lit: changed, aside: aside, stays: edge, joined: joined, ...(waits ? { "data-waits": "" } : {}), disabled: disabled, focusableWhenDisabled: !!disabledReason, onClick: onClick, onPointerDown: onPointerDown, ...opens, children: said }));
|
|
51
52
|
}
|
|
@@ -50,7 +50,7 @@ export interface ValuesEditorProps {
|
|
|
50
50
|
export interface ValuesEditorParts {
|
|
51
51
|
body: React.ReactNode;
|
|
52
52
|
/** On a phone, the Sheet head's buttons: ✕ and ✓; Back on a list's step. */
|
|
53
|
-
head: Pick<SheetHeadProps, "left" | "right" | "onBack" | "close" | "children">;
|
|
53
|
+
head: Pick<SheetHeadProps, "left" | "right" | "onBack" | "backSlot" | "close" | "children">;
|
|
54
54
|
/** On a phone, the Sheet's title while it is on a list's step (Label, Country code). */
|
|
55
55
|
title?: string;
|
|
56
56
|
}
|
|
@@ -222,7 +222,7 @@ export function useValuesEditor(props) {
|
|
|
222
222
|
const lifted = (r, i) => (dragging === i || posed?.id === r.id ? "" : undefined);
|
|
223
223
|
const grip = (r, i, icon, size, look) => {
|
|
224
224
|
const g = gripProps(i);
|
|
225
|
-
return _jsx(Button, { kind: "quiet", shape: "icon", size: size, look: look, className: "o-values-editor-grip", "aria-label": w.move(r.value), icon: glyph(icon), ...g, onPointerDown: (e) => { setPosed(null); setMainHeld(rows[0]?.id); g.onPointerDown(e); } });
|
|
225
|
+
return _jsx(Button, { kind: "quiet", shape: "icon", size: size, look: look, className: "o-values-editor-grip", "data-slot": "vk-values-grip", "aria-label": w.move(r.value), icon: glyph(icon), ...g, onPointerDown: (e) => { setPosed(null); setMainHeld(rows[0]?.id); g.onPointerDown(e); } });
|
|
226
226
|
};
|
|
227
227
|
const [focusTo, setFocusTo] = React.useState(autoFocus && !phone ? (first.editing != null ? ".o-values-editor-edit input" : props.holds === "one" && first.rows.length ? ROOT : ".o-values-editor-line-input") : null);
|
|
228
228
|
React.useLayoutEffect(() => {
|
|
@@ -314,17 +314,17 @@ export function useValuesEditor(props) {
|
|
|
314
314
|
if (!finishEdit() && shell)
|
|
315
315
|
onDone?.();
|
|
316
316
|
} };
|
|
317
|
-
const card = (_jsxs(_Fragment, { children: [_jsxs(FieldRows, { look: ATTIO_ROWS, className: "o-values-editor-card", role: "list", "aria-label": label, children: [rows.map((r, i) => {
|
|
317
|
+
const card = (_jsxs(_Fragment, { children: [_jsxs(FieldRows, { look: ATTIO_ROWS, className: "o-values-editor-card", "data-slot": "vk-values-rows", role: "list", "aria-label": label, children: [rows.map((r, i) => {
|
|
318
318
|
const act = openOf(kind, r.value);
|
|
319
|
-
return (_jsxs(React.Fragment, { children: [_jsxs(FieldRow, { as: "div", role: "listitem", className: "o-values-editor-row", "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), children: [!one && grip(r, i, GRIP, "32x44", { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none", icon: "16" }), editing === i ? (_jsxs(InlineInputGroup, { className: "o-values-editor-edit", style: ROW_40, children: [_jsx(Input, { "aria-label": w.change(r.value), value: editText, type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "done", onChange: (e) => setEditText(e.target.value), onKeyDown: editKeys }), labels.length > 0 && _jsx(InputGroupAddon, { side: "end", children: _jsx(InputGroupButton, { className: "o-values-editor-edit-label", size: "line", look: { radius: "none", corner: "round", edge: "none", words: "sm", icon: "14", hover: "words" }, "aria-label": w.labelIs(r.label ?? w.noLabel), onClick: () => go("label", i), iconEnd: glyph(DOWN), children: r.label ?? w.label }) })] })) : _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "o-values-editor-value", onClick: () => { if (!finishEdit())
|
|
320
|
-
return; setEditing(i); setEditText(r.value); setFocusTo(".o-values-editor-edit input"); }, children: r.value }), r.label && labels.length > 0 && _jsx("span", { className: "o-values-editor-label", children: r.label }), _jsxs("span", { className: "o-values-editor-acts", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: { radius: "md", corner: "round", edge: "none", words: "inherit", icon: "20", hover: "none", press: "card" }, className: "o-values-editor-open", nativeButton: false, render: _jsx("a", { href: act.href }), "aria-label": w.open[kind](r.value), icon: glyph(kind === "phone" ? CALL : kind === "email" ? MAIL : OPEN) }), _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: { radius: "md", corner: "round", edge: "none", words: "inherit", icon: "20", hover: "none", press: "card" }, className: "o-values-editor-remove", "aria-label": w.remove(r.value), onClick: () => remove(i), icon: glyph(TRASH) })] })] })] }), bad[i] && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: bad[i] })] }, r.id));
|
|
321
|
-
}), showLine && (_jsxs("div", { className: "o-values-editor-line", "data-bad": refusal ? "" : undefined, children: [kind === "phone"
|
|
322
|
-
? _jsxs(_Fragment, { children: [_jsx(Button, { kind: "quiet", size: "sm", look: { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "text", icon: "12", iconColour: "faint", pad: "8", gap: "4" }, className: "o-values-editor-code", "aria-label": w.countryIs(countryName(reading, language)), onClick: () => go("dial"), iconEnd: glyph(DOWN), children: reading }), _jsx("span", { className: "o-values-editor-prefix", children: dialOf(reading) })] })
|
|
323
|
-
: _jsx("span", { className: "o-values-editor-plus", children: glyph(PLUS) }), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-line-input", "aria-label": w.add[kind], value: typed, placeholder: kind === "phone" ? patternOf(reading) : w.cardLine[kind], type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "enter", onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }))] }), refusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: refusal })] }));
|
|
324
|
-
const cards = (_jsxs(FieldRows, { look: MIHAI_CARDS, className: "o-values-editor-cards", role: "list", "aria-label": label, children: [rows.map((r, i) => (_jsxs("div", { role: "listitem", "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), children: [_jsxs(FieldRow, { as: "div", className: "o-values-editor-card", children: [!one && grip(r, i, LINES, "20x24", { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none", icon: "20" }), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-card-input", "aria-label": w.nth[kind](i + 1), value: r.value, type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, onChange: (e) => setRows((rs) => rs.map((x) => (x.id === r.id ? { ...x, value: e.target.value } : x))) }), labels.length > 0 && _jsx(Button, { kind: "quiet", size: "line", look: { radius: "none", corner: "round", edge: "none", words: "sm", hover: "none" }, className: "o-values-editor-label", "aria-label": w.labelIs(r.label ?? w.noLabel), onClick: () => go("label", i), children: r.label ?? w.label }), _jsx(Button, { kind: "danger", shape: "round", size: "2xs", look: { edge: "none", words: "inherit", colour: "inherit", hover: "none" }, className: "o-values-editor-minus", "aria-label": w.remove(r.value), onClick: () => remove(i), children: _jsx("span", {}) })] }), bad[i] && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: bad[i] })] }, r.id))), showLine && _jsxs("div", { className: "o-values-editor-adding", children: [_jsxs(FieldRow, { className: "o-values-editor-card o-values-editor-new", children: [kind === "phone" ? _jsxs(_Fragment, { children: [dial && _jsx(Button, { kind: "quiet", shape: "icon", size: "line", look: { radius: "md", corner: "round", edge: "none", words: "xs-medium", colour: "text", disabled: "plain" }, className: "o-values-editor-code", "aria-label": w.countryCodeIs(dial.country), disabled: dialCodes.length < 2, onClick: () => go("dial"), icon: _jsx(Flag, { code: dial.country, size: "lg" }) }), dial && _jsx("span", { className: "o-values-editor-prefix", children: dial.code })] }) : glyph(ICON[kind]), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-card-input", value: typed, placeholder: w.add[kind], type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "done", onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }), _jsx(Button, { kind: "soft", size: "lg", onClick: add, children: w.addButton })] }), refusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: refusal })] }));
|
|
325
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-values-editor", "data-kit": "values-editor", ...device, "data-values-form": "phone", "data-values-view": view, "data-values-holds": one ? "one" : "several", "data-values-phone": worn.phone, children: view === "label" ? labelList.body : view === "dial" ? dialList.body : cardsLook ? cards : card }));
|
|
319
|
+
return (_jsxs(React.Fragment, { children: [_jsxs(FieldRow, { as: "div", role: "listitem", className: "o-values-editor-row", "data-slot": "vk-values-row", "data-index": i, "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), children: [!one && grip(r, i, GRIP, "32x44", { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none", icon: "16" }), editing === i ? (_jsxs(InlineInputGroup, { className: "o-values-editor-edit", "data-slot": "vk-values-edit", style: ROW_40, children: [_jsx(Input, { "aria-label": w.change(r.value), value: editText, type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "done", onChange: (e) => setEditText(e.target.value), onKeyDown: editKeys }), labels.length > 0 && _jsx(InputGroupAddon, { side: "end", children: _jsx(InputGroupButton, { className: "o-values-editor-edit-label", "data-slot": "vk-values-label", size: "line", look: { radius: "none", corner: "round", edge: "none", words: "sm", icon: "14", hover: "words" }, "aria-label": w.labelIs(r.label ?? w.noLabel), onClick: () => go("label", i), iconEnd: glyph(DOWN), children: r.label ?? w.label }) })] })) : _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "o-values-editor-value", "data-slot": "vk-values-value", onClick: () => { if (!finishEdit())
|
|
320
|
+
return; setEditing(i); setEditText(r.value); setFocusTo(".o-values-editor-edit input"); }, children: r.value }), r.label && labels.length > 0 && _jsx("span", { className: "o-values-editor-label", "data-slot": "vk-values-label", children: r.label }), _jsxs("span", { className: "o-values-editor-acts", "data-slot": "vk-values-acts", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: { radius: "md", corner: "round", edge: "none", words: "inherit", icon: "20", hover: "none", press: "card" }, className: "o-values-editor-open", "data-slot": "vk-values-open", nativeButton: false, render: _jsx("a", { href: act.href }), "aria-label": w.open[kind](r.value), icon: glyph(kind === "phone" ? CALL : kind === "email" ? MAIL : OPEN) }), _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: { radius: "md", corner: "round", edge: "none", words: "inherit", icon: "20", hover: "none", press: "card" }, className: "o-values-editor-remove", "data-slot": "vk-values-remove", "aria-label": w.remove(r.value), onClick: () => remove(i), icon: glyph(TRASH) })] })] })] }), bad[i] && !shell && _jsx("p", { className: "o-values-editor-error", "data-slot": "vk-values-error", role: "alert", children: bad[i] })] }, r.id));
|
|
321
|
+
}), showLine && (_jsxs("div", { className: "o-values-editor-line", "data-slot": "vk-values-line", "data-bad": refusal ? "" : undefined, children: [kind === "phone"
|
|
322
|
+
? _jsxs(_Fragment, { children: [_jsx(Button, { kind: "quiet", size: "sm", look: { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "text", icon: "12", iconColour: "faint", pad: "8", gap: "4" }, className: "o-values-editor-code", "data-slot": "vk-values-code", "aria-label": w.countryIs(countryName(reading, language)), onClick: () => go("dial"), iconEnd: glyph(DOWN), children: reading }), _jsx("span", { className: "o-values-editor-prefix", "data-slot": "vk-values-prefix", children: dialOf(reading) })] })
|
|
323
|
+
: _jsx("span", { className: "o-values-editor-plus", "data-slot": "vk-values-prefix", children: glyph(PLUS) }), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-line-input", "aria-label": w.add[kind], value: typed, placeholder: kind === "phone" ? patternOf(reading) : w.cardLine[kind], type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "enter", onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }))] }), refusal && !shell && _jsx("p", { className: "o-values-editor-error", "data-slot": "vk-values-error", role: "alert", children: refusal })] }));
|
|
324
|
+
const cards = (_jsxs(FieldRows, { look: MIHAI_CARDS, className: "o-values-editor-cards", "data-slot": "vk-values-rows", role: "list", "aria-label": label, children: [rows.map((r, i) => (_jsxs("div", { role: "listitem", "data-slot": "vk-values-row", "data-index": i, "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), children: [_jsxs(FieldRow, { as: "div", className: "o-values-editor-card", children: [!one && grip(r, i, LINES, "20x24", { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none", icon: "20" }), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-card-input", "data-slot": "vk-values-value", "aria-label": w.nth[kind](i + 1), value: r.value, type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, onChange: (e) => setRows((rs) => rs.map((x) => (x.id === r.id ? { ...x, value: e.target.value } : x))) }), labels.length > 0 && _jsx(Button, { kind: "quiet", size: "line", look: { radius: "none", corner: "round", edge: "none", words: "sm", hover: "none" }, className: "o-values-editor-label", "data-slot": "vk-values-label", "aria-label": w.labelIs(r.label ?? w.noLabel), onClick: () => go("label", i), children: r.label ?? w.label }), _jsx(Button, { kind: "danger", shape: "round", size: "2xs", look: { edge: "none", words: "inherit", colour: "inherit", hover: "none" }, className: "o-values-editor-minus", "data-slot": "vk-values-remove", "aria-label": w.remove(r.value), onClick: () => remove(i), children: _jsx("span", {}) })] }), bad[i] && !shell && _jsx("p", { className: "o-values-editor-error", "data-slot": "vk-values-error", role: "alert", children: bad[i] })] }, r.id))), showLine && _jsxs("div", { className: "o-values-editor-adding", children: [_jsxs(FieldRow, { className: "o-values-editor-card o-values-editor-new", "data-slot": "vk-values-line", children: [kind === "phone" ? _jsxs(_Fragment, { children: [dial && _jsx(Button, { kind: "quiet", shape: "icon", size: "line", look: { radius: "md", corner: "round", edge: "none", words: "xs-medium", colour: "text", disabled: "plain" }, className: "o-values-editor-code", "data-slot": "vk-values-code", "aria-label": w.countryCodeIs(dial.country), disabled: dialCodes.length < 2, onClick: () => go("dial"), icon: _jsx(Flag, { code: dial.country, size: "lg" }) }), dial && _jsx("span", { className: "o-values-editor-prefix", "data-slot": "vk-values-prefix", children: dial.code })] }) : glyph(ICON[kind]), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-card-input", value: typed, placeholder: w.add[kind], type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "done", onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }), _jsx(Button, { kind: "soft", size: "lg", "data-slot": "vk-values-add", onClick: add, children: w.addButton })] }), refusal && !shell && _jsx("p", { className: "o-values-editor-error", "data-slot": "vk-values-error", role: "alert", children: refusal })] }));
|
|
325
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-values-editor", "data-slot": "vk-values", "data-kit": "values-editor", ...device, "data-values-form": "phone", "data-values-view": view, "data-values-holds": one ? "one" : "several", "data-values-phone": worn.phone, children: view === "label" ? labelList.body : view === "dial" ? dialList.body : cardsLook ? cards : card }));
|
|
326
326
|
if (view !== "rows")
|
|
327
|
-
return { body, head: { onBack: back, close: false }, title: view === "label" ? w.label : w.countryCode };
|
|
327
|
+
return { body, head: { onBack: back, backSlot: "vk-editor-back", close: false }, title: view === "label" ? w.label : w.countryCode };
|
|
328
328
|
const save = () => {
|
|
329
329
|
if (edit != null && !finishEdit())
|
|
330
330
|
return;
|
|
@@ -341,7 +341,7 @@ export function useValuesEditor(props) {
|
|
|
341
341
|
};
|
|
342
342
|
if (shell)
|
|
343
343
|
return { body, head: {} };
|
|
344
|
-
return { body, head: { left: _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: save }) } };
|
|
344
|
+
return { body, head: { left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: save }) } };
|
|
345
345
|
}
|
|
346
346
|
const onBlur = (e) => {
|
|
347
347
|
if (shell || settled.current || swapping.current || drop || !(e.target instanceof Node) || !e.currentTarget.contains(e.target))
|
|
@@ -407,21 +407,21 @@ export function useValuesEditor(props) {
|
|
|
407
407
|
};
|
|
408
408
|
const editRefusal = editing != null && editText.trim() ? rule(keepAs(editText)) : null;
|
|
409
409
|
const showLine = !(one && rows.length > 0);
|
|
410
|
-
const labelButton = (r, i) => labels.length > 0 && (_jsx(InputGroupAddon, { side: "end", children: _jsx(InputGroupButton, { className: "o-values-editor-edit-label", size: "line", look: under ? { radius: "xs", corner: "round", edge: "none", words: "sm", iconColour: "faint", pad: "4", hover: "words", open: "hovered" } : { radius: "none", corner: "round", edge: "none", words: "xs", hover: "words" }, "aria-label": w.labelIs(r.label ?? w.noLabel), "aria-haspopup": under ? "listbox" : undefined, "aria-expanded": under ? drop?.what === "label" : undefined, onClick: open("label", i), iconEnd: under ? glyph(DOWN) : undefined, children: r.label ?? w.label }) }));
|
|
411
|
-
const code = attio ? (_jsx(Button, { kind: "quiet", size: "2xs", look: { radius: "sm", corner: "round", edge: "none", words: "inherit", colour: "text", icon: "12", iconColour: "faint", pad: "6", open: "hovered" }, className: "o-values-editor-code", "aria-label": w.countryIs(countryName(reading, language)), "aria-haspopup": "listbox", "aria-expanded": drop?.what === "dial", onClick: open("dial"), iconEnd: glyph(DOWN), children: reading })) : dial && (_jsx(Button, { kind: "quiet", size: "26", look: { radius: "md", corner: "round", edge: "none", words: "xs-medium", colour: "text", disabled: "plain", icon: "12", iconColour: "faint" }, className: "o-values-editor-code", "aria-label": w.countryCodeIs(dial.country), disabled: dialCodes.length < 2, onClick: open("dial"), icon: _jsx(Flag, { code: dial.country }), iconEnd: dialCodes.length > 1 ? glyph(DOWN) : undefined, children: dial.country }));
|
|
412
|
-
const line = (_jsxs("div", { className: cx("o-values-editor-line", !attio && "o-popup-line"), "data-at": attio ? undefined : "foot", "data-bad": refusal ? "" : undefined, children: [kind === "phone"
|
|
413
|
-
? _jsxs(_Fragment, { children: [code, attio ? _jsx("span", { className: "o-values-editor-prefix", children: dialOf(reading) }) : dial?.code && _jsx("span", { className: "o-values-editor-prefix", children: dial.code })] })
|
|
414
|
-
: attio ? _jsx("span", { className: "o-values-editor-plus", children: glyph(PLUS) }) : glyph(ICON[kind]), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-line-input", "aria-label": w.add[kind], placeholder: kind === "phone" ? (attio ? patternOf(reading) : hint) : attio ? w.line[kind] : hint, value: typed, type: keys.type, inputMode: keys.inputMode, autofill: false, spellCheck: false, "aria-invalid": refusal ? true : undefined, onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }));
|
|
415
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-values-editor", "data-kit": "values-editor", ...device, "data-values-form": "computer", "data-values-view": view, "data-values-holds": one ? "one" : "several", "data-values-rows": worn.rows, "data-values-main": worn.main, "data-values-line": worn.line, "data-values-lists": worn.lists, ...(view !== "rows" ? { [EDITOR_INNER_ESCAPE]: "" } : {}), role: "group", "aria-label": label, tabIndex: -1, onBlur: onBlur, onFocus: () => { settled.current = false; }, onKeyDown: onKeyDown, children: view === "rows" ? _jsxs(_Fragment, { children: [rows.length > 0 && (_jsx("div", { className: "o-values-editor-rows", role: "list", "aria-label": label, children: rows.map((r, i) => (_jsxs("div", { role: "listitem", className: "o-values-editor-row", "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), onPointerLeave: () => { if (copied === r.id)
|
|
416
|
-
setCopied(null); }, children: [!one && grip(r, i, GRIP, worn.rows === "copy" ? "2xs" : "20x24", { radius: worn.rows === "copy" ? "sm" : "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none" }), editing === i ? (_jsxs(InlineInputGroup, { className: "o-values-editor-edit", style: ROW_28, "data-bad": editRefusal ? "" : undefined, children: [_jsx(Input, { numeric: true, "aria-label": w.change(r.value), value: editText, type: keys.type, inputMode: keys.inputMode, autofill: false, spellCheck: false, "aria-invalid": editRefusal ? true : undefined, onChange: (e) => setEditText(e.target.value), onKeyDown: editKeys, onBlur: (e) => { const to = e.relatedTarget; if (to && to !== root.current && root.current?.contains(to) && !e.currentTarget.parentElement?.contains(to) && !swapping.current)
|
|
410
|
+
const labelButton = (r, i) => labels.length > 0 && (_jsx(InputGroupAddon, { side: "end", children: _jsx(InputGroupButton, { className: "o-values-editor-edit-label", "data-slot": "vk-values-label", size: "line", look: under ? { radius: "xs", corner: "round", edge: "none", words: "sm", iconColour: "faint", pad: "4", hover: "words", open: "hovered" } : { radius: "none", corner: "round", edge: "none", words: "xs", hover: "words" }, "aria-label": w.labelIs(r.label ?? w.noLabel), "aria-haspopup": under ? "listbox" : undefined, "aria-expanded": under ? drop?.what === "label" : undefined, onClick: open("label", i), iconEnd: under ? glyph(DOWN) : undefined, children: r.label ?? w.label }) }));
|
|
411
|
+
const code = attio ? (_jsx(Button, { kind: "quiet", size: "2xs", look: { radius: "sm", corner: "round", edge: "none", words: "inherit", colour: "text", icon: "12", iconColour: "faint", pad: "6", open: "hovered" }, className: "o-values-editor-code", "data-slot": "vk-values-code", "aria-label": w.countryIs(countryName(reading, language)), "aria-haspopup": "listbox", "aria-expanded": drop?.what === "dial", onClick: open("dial"), iconEnd: glyph(DOWN), children: reading })) : dial && (_jsx(Button, { kind: "quiet", size: "26", look: { radius: "md", corner: "round", edge: "none", words: "xs-medium", colour: "text", disabled: "plain", icon: "12", iconColour: "faint" }, className: "o-values-editor-code", "data-slot": "vk-values-code", "aria-label": w.countryCodeIs(dial.country), disabled: dialCodes.length < 2, onClick: open("dial"), icon: _jsx(Flag, { code: dial.country }), iconEnd: dialCodes.length > 1 ? glyph(DOWN) : undefined, children: dial.country }));
|
|
412
|
+
const line = (_jsxs("div", { className: cx("o-values-editor-line", !attio && "o-popup-line"), "data-slot": "vk-values-line", "data-at": attio ? undefined : "foot", "data-bad": refusal ? "" : undefined, children: [kind === "phone"
|
|
413
|
+
? _jsxs(_Fragment, { children: [code, attio ? _jsx("span", { className: "o-values-editor-prefix", "data-slot": "vk-values-prefix", children: dialOf(reading) }) : dial?.code && _jsx("span", { className: "o-values-editor-prefix", "data-slot": "vk-values-prefix", children: dial.code })] })
|
|
414
|
+
: attio ? _jsx("span", { className: "o-values-editor-plus", "data-slot": "vk-values-prefix", children: glyph(PLUS) }) : glyph(ICON[kind]), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-line-input", "aria-label": w.add[kind], placeholder: kind === "phone" ? (attio ? patternOf(reading) : hint) : attio ? w.line[kind] : hint, value: typed, type: keys.type, inputMode: keys.inputMode, autofill: false, spellCheck: false, "aria-invalid": refusal ? true : undefined, onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }));
|
|
415
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-values-editor", "data-slot": "vk-values", "data-kit": "values-editor", ...device, "data-values-form": "computer", "data-values-view": view, "data-values-holds": one ? "one" : "several", "data-values-rows": worn.rows, "data-values-main": worn.main, "data-values-line": worn.line, "data-values-lists": worn.lists, ...(view !== "rows" ? { [EDITOR_INNER_ESCAPE]: "" } : {}), role: "group", "aria-label": label, tabIndex: -1, onBlur: onBlur, onFocus: () => { settled.current = false; }, onKeyDown: onKeyDown, children: view === "rows" ? _jsxs(_Fragment, { children: [rows.length > 0 && (_jsx("div", { className: "o-values-editor-rows", "data-slot": "vk-values-rows", role: "list", "aria-label": label, children: rows.map((r, i) => (_jsxs("div", { role: "listitem", className: "o-values-editor-row", "data-slot": "vk-values-row", "data-index": i, "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), onPointerLeave: () => { if (copied === r.id)
|
|
416
|
+
setCopied(null); }, children: [!one && grip(r, i, GRIP, worn.rows === "copy" ? "2xs" : "20x24", { radius: worn.rows === "copy" ? "sm" : "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none" }), editing === i ? (_jsxs(InlineInputGroup, { className: "o-values-editor-edit", "data-slot": "vk-values-edit", style: ROW_28, "data-bad": editRefusal ? "" : undefined, children: [_jsx(Input, { numeric: true, "aria-label": w.change(r.value), value: editText, type: keys.type, inputMode: keys.inputMode, autofill: false, spellCheck: false, "aria-invalid": editRefusal ? true : undefined, onChange: (e) => setEditText(e.target.value), onKeyDown: editKeys, onBlur: (e) => { const to = e.relatedTarget; if (to && to !== root.current && root.current?.contains(to) && !e.currentTarget.parentElement?.contains(to) && !swapping.current)
|
|
417
417
|
finishEdit(); } }), labelButton(r, i)] })) : _jsxs(_Fragment, { children: [(() => {
|
|
418
418
|
const parts = kind === "email" ? splitEmail(r.value) : null;
|
|
419
|
-
const value = _jsx("button", { type: "button", className: "o-values-editor-value", "aria-label": r.value, onClick: () => { hold(); if (!finishEdit()) {
|
|
419
|
+
const value = _jsx("button", { type: "button", className: "o-values-editor-value", "data-slot": "vk-values-value", "aria-label": r.value, onClick: () => { hold(); if (!finishEdit()) {
|
|
420
420
|
setFocusTo(".o-values-editor-edit input");
|
|
421
421
|
return;
|
|
422
422
|
} setEditing(i); setEditText(r.value); setFocusTo(".o-values-editor-edit input"); }, children: parts ? _jsxs(_Fragment, { children: [_jsx("span", { className: "o-values-editor-name", "data-name": parts[0], children: parts[0] }), _jsx("span", { className: "o-values-editor-domain", children: parts[1] })] }) : r.value });
|
|
423
|
-
return worn.rows === "copy" ? (_jsxs("span", { className: "o-values-editor-pill", children: [value, _jsx(Button, { kind: "quiet", shape: "icon", size: "20", look: { radius: "xs", corner: "round", edge: "none", words: "inherit", colour: "link", icon: "15", hover: "none" }, className: "o-values-editor-copy", "aria-label": w.copy(r.value), "data-copied": copied === r.id ? "" : undefined, onClick: copy(r), icon: glyph(copied === r.id ? TICK : COPY) })] })) : value;
|
|
424
|
-
})(), !one && worn.main === "pill" && r.id === mainId && _jsx("span", { className: "o-values-editor-main", children: w.main }), r.label && !one && _jsx("span", { className: "o-values-editor-label", children: r.label }), _jsx(Button, { kind: "quiet", shape: "icon", size: worn.rows === "copy" ? "2xs" : "22", look: worn.rows === "copy" ? { radius: "sm", corner: "round", edge: "none", words: "inherit", icon: "16" } : { radius: "md", corner: "round", edge: "none", words: "inherit" }, className: "o-values-editor-remove", "aria-label": w.remove(r.value), icon: glyph(worn.rows === "copy" ? TRASH : X), onClick: () => { hold(); remove(i); setFocusTo(editing != null ? ".o-values-editor-edit input" : ".o-values-editor-line-input"); } })] })] }, r.id))) })), editRefusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: editRefusal }), showLine && line, refusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: refusal }), under && (_jsx(Popover, { open: !!drop, popupData: props.popupData, anchor: drop?.at, side: "bottom", align: "start", sideOffset: spacingPx(1, drop?.at), finalFocus: dropBack, "aria-label": drop?.what === "label" ? w.label : w.country, style: { width: drop?.what === "label" ? "calc(var(--vk-spacing) * 48)" : "calc(var(--vk-spacing) * 60)" }, onOpenChange: (o, d) => {
|
|
423
|
+
return worn.rows === "copy" ? (_jsxs("span", { className: "o-values-editor-pill", "data-slot": "vk-values-pill", children: [value, _jsx(Button, { kind: "quiet", shape: "icon", size: "20", look: { radius: "xs", corner: "round", edge: "none", words: "inherit", colour: "link", icon: "15", hover: "none" }, className: "o-values-editor-copy", "data-slot": "vk-values-copy", "aria-label": w.copy(r.value), "data-copied": copied === r.id ? "" : undefined, onClick: copy(r), icon: glyph(copied === r.id ? TICK : COPY) })] })) : value;
|
|
424
|
+
})(), !one && worn.main === "pill" && r.id === mainId && _jsx("span", { className: "o-values-editor-main", "data-slot": "vk-values-main", children: w.main }), r.label && !one && _jsx("span", { className: "o-values-editor-label", "data-slot": "vk-values-label", children: r.label }), _jsx(Button, { kind: "quiet", shape: "icon", size: worn.rows === "copy" ? "2xs" : "22", look: worn.rows === "copy" ? { radius: "sm", corner: "round", edge: "none", words: "inherit", icon: "16" } : { radius: "md", corner: "round", edge: "none", words: "inherit" }, className: "o-values-editor-remove", "data-slot": "vk-values-remove", "aria-label": w.remove(r.value), icon: glyph(worn.rows === "copy" ? TRASH : X), onClick: () => { hold(); remove(i); setFocusTo(editing != null ? ".o-values-editor-edit input" : ".o-values-editor-line-input"); } })] })] }, r.id))) })), editRefusal && !shell && _jsx("p", { className: "o-values-editor-error", "data-slot": "vk-values-error", role: "alert", children: editRefusal }), showLine && line, refusal && !shell && _jsx("p", { className: "o-values-editor-error", "data-slot": "vk-values-error", role: "alert", children: refusal }), under && (_jsx(Popover, { open: !!drop, popupData: props.popupData, anchor: drop?.at, side: "bottom", align: "start", sideOffset: spacingPx(1, drop?.at), finalFocus: dropBack, "aria-label": drop?.what === "label" ? w.label : w.country, style: { width: drop?.what === "label" ? "calc(var(--vk-spacing) * 48)" : "calc(var(--vk-spacing) * 60)" }, onOpenChange: (o, d) => {
|
|
425
425
|
if (o)
|
|
426
426
|
return;
|
|
427
427
|
closeDrop();
|
|
@@ -430,7 +430,7 @@ export function useValuesEditor(props) {
|
|
|
430
430
|
}, onOutsidePress: (e) => (e.target instanceof Node && drop?.at.contains(e.target) ? false : undefined), children: _jsx("div", { ref: popup, children: drop?.what === "label"
|
|
431
431
|
? _jsx(Picker, { label: w.label, items: labelItems, value: labelOf != null ? rows[labelOf]?.label ?? null : null, onValueChange: setLabel, onCreate: (t) => t.trim(), onDone: closeDrop, search: w.labelFind, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) })
|
|
432
432
|
: drop && _jsx(Picker, { label: w.country, items: attio ? countryItems(language) : dialItems, value: attio ? reading : country ?? null, onValueChange: (c) => { if (typeof c === "string")
|
|
433
|
-
setCountry(c); }, onDone: closeDrop, search: w.searchCountry, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) }) }) }))] }) : _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-values-editor-back o-popup-line", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "xs", "aria-label": w.backTo(label.toLowerCase()), icon: glyph(LEFT), onClick: back }), _jsx("span", { children: view === "label" ? w.label : w.countryCode })] }), view === "label"
|
|
433
|
+
setCountry(c); }, onDone: closeDrop, search: w.searchCountry, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) }) }) }))] }) : _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-values-editor-back o-popup-line", "data-slot": "vk-values-back", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "xs", "aria-label": w.backTo(label.toLowerCase()), icon: glyph(LEFT), onClick: back }), _jsx("span", { children: view === "label" ? w.label : w.countryCode })] }), view === "label"
|
|
434
434
|
? _jsx(Picker, { label: w.label, items: labelItems, value: labelOf != null ? rows[labelOf]?.label ?? null : null, onValueChange: setLabel, onCreate: (t) => t.trim(), onDone: back, search: w.labelFind, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) })
|
|
435
435
|
: _jsx(Picker, { label: w.countryCode, items: attio ? countryItems(language) : dialItems, value: attio ? reading : country ?? null, onValueChange: (c) => { if (typeof c === "string")
|
|
436
436
|
setCountry(c); }, onDone: back, search: w.findCountry, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) })] }) }));
|
|
@@ -21,5 +21,5 @@ export function MapViewMenu({ open, onOpenChange, anchor, align, view, views, va
|
|
|
21
21
|
if (creating)
|
|
22
22
|
return _jsx(_Fragment, { children: menu.dialogs });
|
|
23
23
|
const label = views.find((v) => v.value === view)?.label ?? "";
|
|
24
|
-
return (_jsxs(_Fragment, { children: [_jsx(Menu, { open: open, onOpenChange: onOpenChange, anchor: anchor, align: align ?? "start", label: label, items: open ? menu.items(view) : [] }), menu.dialogs] }));
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx(Menu, { open: open, onOpenChange: onOpenChange, anchor: anchor, align: align ?? "start", label: label, items: open ? menu.items(view) : [], "data-slot": "vk-view-menu" }), menu.dialogs] }));
|
|
25
25
|
}
|