viewkitjs 0.32.0 → 0.34.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 +98 -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 +46 -11
- package/views/dist/contract.js +157 -0
- package/views/dist/controls/alert/alert.js +2 -1
- package/views/dist/controls/alert-dialog/alert-dialog.js +3 -2
- package/views/dist/controls/bulk-bar/bulk-bar.js +25 -22
- 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 +4 -0
- package/views/dist/controls/controls.js +4 -0
- package/views/dist/controls/customize/customize.js +43 -39
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
- package/views/dist/controls/customize/map-customize-body.js +7 -2
- package/views/dist/controls/date-editor/date-days.js +2 -2
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
- package/views/dist/controls/date-editor/date-editor.js +27 -21
- package/views/dist/controls/date-editor/date-parts.js +6 -6
- package/views/dist/controls/date-editor/map-calendar.js +3 -1
- package/views/dist/controls/date-editor/map-date-body.d.ts +1 -1
- package/views/dist/controls/date-editor/map-date-body.js +7 -3
- 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 +3 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +11 -4
- package/views/dist/controls/filter-editor/map-rules.js +1 -1
- package/views/dist/controls/filter-editor/parts.d.ts +3 -1
- package/views/dist/controls/filter-editor/parts.js +8 -6
- package/views/dist/controls/group-editor/group-editor.js +17 -14
- package/views/dist/controls/group-editor/map-group-body.d.ts +1 -0
- package/views/dist/controls/group-editor/map-group-body.js +5 -1
- package/views/dist/controls/index.d.ts +2 -0
- package/views/dist/controls/index.js +1 -0
- package/views/dist/controls/input/input.js +4 -3
- 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/head-button.d.ts +9 -0
- package/views/dist/controls/internal/head-button.js +13 -0
- 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 +58 -0
- package/views/dist/controls/internal/panel-controls.js +240 -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 +3 -0
- package/views/dist/controls/menu/menu.js +5 -5
- 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/modal/modal.js +5 -3
- 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/map-number-body.js +5 -1
- package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
- package/views/dist/controls/number-editor/number-editor.js +16 -16
- package/views/dist/controls/number-field/number-field.js +5 -3
- package/views/dist/controls/pane/map-pane.d.ts +3 -0
- package/views/dist/controls/pane/map-pane.js +5 -0
- package/views/dist/controls/pane/pane.d.ts +4 -2
- package/views/dist/controls/pane/pane.js +4 -4
- package/views/dist/controls/picker/map-fields-body.js +25 -1
- 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/picker.css +10 -1
- 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/map-quick-filters-body.d.ts +2 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +7 -3
- package/views/dist/controls/quick-filters/quick-filters.js +8 -6
- 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/setting-row/looks.js +5 -5
- package/views/dist/controls/setting-row/setting-row.d.ts +3 -1
- package/views/dist/controls/setting-row/setting-row.js +3 -1
- package/views/dist/controls/setting-row.css +3 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +8 -2
- package/views/dist/controls/sheet/bottom-sheet.js +4 -4
- 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 +8 -4
- 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/map-text-body.js +5 -1
- package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
- package/views/dist/controls/text-editor/text-editor.js +11 -10
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- 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.d.ts +3 -2
- package/views/dist/controls/views-list/map-view-menu.js +7 -3
- package/views/dist/controls/views-list/map-views-list-body.d.ts +2 -1
- package/views/dist/controls/views-list/map-views-list-body.js +6 -5
- package/views/dist/controls/views-list/view-menu.js +9 -10
- package/views/dist/controls/views-list/views-list.js +6 -6
- package/views/dist/editors/EditorPanel.js +4 -4
- 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 +74 -0
- package/views/dist/list/list.js +18 -0
- package/views/dist/list/parts.js +11 -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 +23 -5
- 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 +21 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +2 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +20 -6
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +4 -3
- 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 +4 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +5 -4
- 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 +8 -5
- package/views/dist/panels/react/toolbar/context.d.ts +31 -1
- package/views/dist/panels/react/toolbar/context.js +4 -0
- package/views/dist/panels/react/toolbar/pane-host.d.ts +6 -0
- package/views/dist/panels/react/toolbar/pane-host.js +17 -0
- package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
- package/views/dist/panels/react/toolbar/panel-part.js +7 -4
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/settings/filter-groups.js +6 -1
- package/views/dist/provider/ViewsProvider.d.ts +7 -2
- package/views/dist/provider/ViewsProvider.js +18 -1
- package/views/dist/provider/components.d.ts +90 -2
- 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 +107 -80
- package/views/dist/styles.unlayered.css +107 -80
- package/views/docs/contract.md +310 -7
- package/views/docs/controls/alert-dialog.md +4 -0
- package/views/docs/controls/alert.md +4 -0
- package/views/docs/controls/bulk-bar.md +4 -0
- package/views/docs/controls/compound-editor.md +4 -0
- package/views/docs/controls/customize.md +8 -0
- package/views/docs/controls/date-editor.md +6 -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 +8 -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 +6 -0
- package/views/docs/controls/modal.md +4 -0
- package/views/docs/controls/notice.md +4 -0
- package/views/docs/controls/number-editor.md +6 -0
- package/views/docs/controls/pane.md +4 -0
- package/views/docs/controls/picker.md +8 -0
- package/views/docs/controls/quick-filters.md +8 -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 +6 -0
- package/views/docs/controls/toolbar.md +4 -0
- package/views/docs/controls/values-editor.md +4 -0
- package/views/docs/controls/views-list.md +8 -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 +11 -7
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +1 -1
- package/views/docs/reference/list.md +143 -11
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +6 -5
- package/views/docs/reference/react.md +19 -12
- package/views/docs/reference/views.md +11 -5
- package/views/docs/reshaping.md +17 -1
- package/views/skills/views/SKILL.md +1 -1
|
@@ -54,7 +54,9 @@ export type SettingRowProps = SettingRowBase & (({
|
|
|
54
54
|
} & No<"switch" | "select" | "onOpen">) | ({
|
|
55
55
|
onOpen: () => void;
|
|
56
56
|
value?: React.ReactNode;
|
|
57
|
-
} & No<"switch" | "select" | "action">)
|
|
57
|
+
} & No<"switch" | "select" | "action">)
|
|
58
|
+
/** The plain kind (VK-1036): no control and no ›, a row that only says, opening nothing. */
|
|
59
|
+
| No<"switch" | "select" | "action" | "onOpen" | "value">);
|
|
58
60
|
export interface SettingRowsProps {
|
|
59
61
|
/** The danger zone's: a red edge, each row's button the Button's danger kind unless its action says outline, on a phone its
|
|
60
62
|
* names red. */
|
|
@@ -56,7 +56,7 @@ function SettingRowOf(props) {
|
|
|
56
56
|
const phone = !!rows?.phone, worn = rows ? rows.worn : ownWorn, inWords = !phone && worn.end === "words";
|
|
57
57
|
const shut = locked != null && locked !== false;
|
|
58
58
|
const reason = shut && locked !== true ? locked : null;
|
|
59
|
-
const kind = props.switch ? "switch" : props.select ? "select" : props.action ? "action" : "open";
|
|
59
|
+
const kind = props.switch ? "switch" : props.select ? "select" : props.action ? "action" : props.onOpen ? "open" : "plain";
|
|
60
60
|
const begins = mark != null ? "mark" : icon != null || (phone && danger && props.action?.icon != null) ? "icon" : undefined;
|
|
61
61
|
const ownCard = alone && !rows && !device && worn.card === "edged";
|
|
62
62
|
const root = { className: cx("o-setting-row", phone && "o-field-row", props.switch && "o-switch-row", ownCard && "o-smooth o-smooth-ease", className), "data-setting-row-kind": kind,
|
|
@@ -102,6 +102,8 @@ function SettingRowOf(props) {
|
|
|
102
102
|
: _jsx(Button, { kind: kindOf, size: "sm", icon: a.icon, disabled: shut || a.disabled, onClick: a.onClick, children: a.label });
|
|
103
103
|
return (_jsxs("div", { ...root, children: [start, words, _jsxs("span", { className: "o-setting-row-end", children: [value, lead, act] })] }));
|
|
104
104
|
}
|
|
105
|
+
if (!props.onOpen)
|
|
106
|
+
return _jsxs("div", { ...root, children: [start, words, lead != null && _jsx("span", { className: "o-setting-row-end", children: lead })] });
|
|
105
107
|
return (_jsxs("button", { type: "button", ...root, disabled: shut, onClick: shut ? undefined : props.onOpen, children: [start, words, _jsxs("span", { className: "o-setting-row-end", children: [lead, props.value != null && _jsx("span", { className: "o-setting-row-value", children: props.value }), chevron] })] }));
|
|
106
108
|
}
|
|
107
109
|
const firstOf = (v) => (Array.isArray(v) ? v : v == null ? [] : [v]);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* The setting row and its card, as the Outright kit draws them (setting-row/setting-row.tsx): one setting as a row, its words
|
|
2
2
|
(choice.css) on the left, its control at its end (the Switch, the Select, a Button, or its value and ›), its mark or icon at
|
|
3
3
|
its start; the rows in a card, a line between each; the danger zone's card with a red edge; a lone row bare. Two options, each
|
|
4
|
-
a computer's, picked on the frame or the app around it (looks.ts): the card (outlined,
|
|
5
|
-
and the rows (snug,
|
|
4
|
+
a computer's, picked on the frame or the app around it (looks.ts): the card (outlined, or raised on its ground, the default)
|
|
5
|
+
and the rows (snug, or roomy, 64 tall, the default). The defaults are Attio's look, which lookAttrs writes when nothing is
|
|
6
|
+
picked (VK-1035); a frame with no attribute at all still draws outlined and snug, as SwitchRows did (switch-row.css); a switch's row is no
|
|
6
7
|
press of its own, only its Switch is (KIT-969). On a phone the card and its rows are
|
|
7
8
|
Field rows' (field.css), and this sheet adds what a setting puts in them, as iOS's Settings draws it (KIT-972): the name taking
|
|
8
9
|
the room; the value in the quietest grey, cut with …, before iOS's ›; a button's words in the link colour at the end; a lone
|
|
@@ -25,6 +25,8 @@ export interface SheetHeadProps {
|
|
|
25
25
|
close?: boolean;
|
|
26
26
|
/** Back: to the step before, or out of the sheet. In Glass it takes the X's place, and the sheet closes by a drag or the dim. */
|
|
27
27
|
onBack?: () => void;
|
|
28
|
+
/** Back's public name (VK-989): a field editor's step hands `vk-editor-back`, drawn on its ‹ as `data-slot`. */
|
|
29
|
+
backSlot?: string;
|
|
28
30
|
/** The X's and Back's names to a screen reader; English unless handed. */
|
|
29
31
|
words?: {
|
|
30
32
|
close?: string;
|
|
@@ -53,11 +55,13 @@ export declare function SheetButton({ className, kind, children, ...props }: {
|
|
|
53
55
|
className?: string;
|
|
54
56
|
kind?: "primary";
|
|
55
57
|
disabled?: boolean;
|
|
58
|
+
/** Its public name (VK-989), drawn on both its forms: the editors' ✕ and ✓ hand `vk-editor-close` and `vk-editor-save`. */
|
|
59
|
+
"data-slot"?: string;
|
|
56
60
|
}): import("react/jsx-runtime").JSX.Element;
|
|
57
61
|
/** Its head, one of its kinds: the one header (HeaderBar), under its handle. Glass has on its left the X, or Back in its place, and on its right one action, or two, as the phone header's Two buttons says.
|
|
58
62
|
* Flat has Back on its left, if there is one, and its action and the X on its right. Or Decide, a button either side of its
|
|
59
63
|
* title. A sheet with no head is its handle alone. */
|
|
60
|
-
export declare function SheetHead({ title, mark, titleLabel, titleAt, description, close, onBack, left, right, children, words, step }: SheetHeadProps): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
export declare function SheetHead({ title, mark, titleLabel, titleAt, description, close, onBack, backSlot, left, right, children, words, step }: SheetHeadProps): import("react/jsx-runtime").JSX.Element;
|
|
61
65
|
/** Its foot: stays at the foot of the screen at every stop, and leaves with the sheet. */
|
|
62
66
|
export declare const SheetFoot: ({ children }: {
|
|
63
67
|
children: React.ReactNode;
|
|
@@ -109,8 +113,10 @@ export interface SheetProps {
|
|
|
109
113
|
finalFocus?: () => HTMLElement | null;
|
|
110
114
|
/** A class on the sheet itself, after its own. */
|
|
111
115
|
className?: string;
|
|
116
|
+
/** Its public name where a part names it (VK-1023: the bulk bar's `vk-bulk-field-sheet`; a Menu's on a phone), on the sheet. */
|
|
117
|
+
"data-slot"?: string;
|
|
112
118
|
/** Its head and its body. */
|
|
113
119
|
children: React.ReactNode;
|
|
114
120
|
}
|
|
115
121
|
/** What rises from the bottom of the phone, in a form, at stops. What it holds is poured in. */
|
|
116
|
-
export declare function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form, stops, openAt, stop, onStopChange, mark: marked, container, standing: stands, finalFocus, className, children }: SheetProps): import("react/jsx-runtime").JSX.Element;
|
|
122
|
+
export declare function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form, stops, openAt, stop, onStopChange, mark: marked, container, standing: stands, finalFocus, className, "data-slot": slot, children }: SheetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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) {
|
|
@@ -248,7 +248,7 @@ function useKeyboardFoot(popup, on) {
|
|
|
248
248
|
return () => { vv.removeEventListener("resize", read); vv.removeEventListener("scroll", read); popup.style.removeProperty("--sheet-keyboard"); };
|
|
249
249
|
}, [typing, popup]);
|
|
250
250
|
}
|
|
251
|
-
export function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form = "full", stops, openAt, stop, onStopChange, mark: marked = "[data-sheet-mark]", container, standing: stands, finalFocus, className, children }) {
|
|
251
|
+
export function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form = "full", stops, openAt, stop, onStopChange, mark: marked = "[data-sheet-mark]", container, standing: stands, finalFocus, className, "data-slot": slot, children }) {
|
|
252
252
|
const closeBelow = React.useContext(CloseAll), stacked = closeBelow !== null;
|
|
253
253
|
const standsBelow = React.useContext(Standing), standing = stands || standsBelow;
|
|
254
254
|
const [armed, setArmed] = React.useState(false);
|
|
@@ -375,5 +375,5 @@ export function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form =
|
|
|
375
375
|
}, children: _jsxs(Base.Portal, { container: container, children: [_jsx(Base.Backdrop, { ref: backdrop, forceRender: stacked, className: "o-sheet-backdrop", "data-stacked": stacked ? "" : undefined }), _jsxs(Base.Viewport, { ref: setViewport, className: "o-sheet-viewport", "data-sheet-form": form, onClick: standing ? (e) => { if (e.target === e.currentTarget) {
|
|
376
376
|
release("closed");
|
|
377
377
|
close("outside-press");
|
|
378
|
-
} } : undefined, children: [_jsx(Base.Popup, { ref: bindPopup, initialFocus: popupRef, finalFocus: finalFocus ? () => finalFocus() ?? true : undefined, className: cx("o-sheet o-smooth", className), "data-sheet-form": form, "aria-label": label, "data-kit": "sheet", children: _jsxs("div", { className: "o-sheet-cut", children: [_jsx("div", { className: "o-sheet-handle", "aria-hidden": "true" }), _jsx(Standing.Provider, { value: standing, children: _jsx(Body.Provider, { value: body, children: _jsx(CloseAll.Provider, { value: closeAll, children: _jsx(OutOfFieldRows, { children: children }) }) }) })] }) }), coming && _jsx("div", { className: "o-sheet-shield", "aria-hidden": "true", "data-sheet-shield": "", onPointerDown: (e) => { e.preventDefault(); e.stopPropagation(); }, onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); }, onClick: (e) => e.stopPropagation() })] })] }) }));
|
|
378
|
+
} } : undefined, children: [_jsx(Base.Popup, { ref: bindPopup, initialFocus: popupRef, finalFocus: finalFocus ? () => finalFocus() ?? true : undefined, className: cx("o-sheet o-smooth", className), "data-sheet-form": form, "aria-label": label, "data-slot": slot, "data-kit": "sheet", children: _jsxs("div", { className: "o-sheet-cut", children: [_jsx("div", { className: "o-sheet-handle", "aria-hidden": "true" }), _jsx(Standing.Provider, { value: standing, children: _jsx(Body.Provider, { value: body, children: _jsx(CloseAll.Provider, { value: closeAll, children: _jsx(OutOfFieldRows, { children: children }) }) }) })] }) }), coming && _jsx("div", { className: "o-sheet-shield", "aria-hidden": "true", "data-sheet-shield": "", onPointerDown: (e) => { e.preventDefault(); e.stopPropagation(); }, onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); }, onClick: (e) => e.stopPropagation() })] })] }) }));
|
|
379
379
|
}
|
|
@@ -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,10 +4,11 @@ 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 { PanelHeadButton } from "../internal/head-button.js";
|
|
8
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
7
9
|
import { useToldStep } from "../internal/told-step.js";
|
|
8
10
|
import { pickerWordsOf } from "../picker/map-picker.js";
|
|
9
11
|
import { HeaderBar } from "../phone-header/header-bar.js";
|
|
10
|
-
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
11
12
|
import { useSortEditor } from "./sort-editor.js";
|
|
12
13
|
const KIT = { asc: "ascending", desc: "descending" };
|
|
13
14
|
const VIEWKIT = { ascending: "asc", descending: "desc" };
|
|
@@ -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(
|
|
81
|
+
const done = actions.done && _jsx(PanelHeadButton, { "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(
|
|
80
|
-
: _jsx(BodyHead, { title: props.label, left: _jsx(
|
|
83
|
+
? _jsx(BodyHead, { title: parts.title, left: _jsx(PanelHeadButton, { "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(PanelHeadButton, { "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
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { resolveViewsMessage } from "../../contract.js";
|
|
5
5
|
import { ViewsContext } from "../../provider/context.js";
|
|
6
6
|
import { pickerWordsOf } from "../picker/map-picker.js";
|
|
7
7
|
import { useToldStep } from "../internal/told-step.js";
|
|
8
8
|
import { useTextEditor } from "./text-editor.js";
|
|
9
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
9
10
|
export function textEditorPropsOf({ label, kind, paragraph, value, onValueChange, onDone, check, region, autoFocus, form, place }) {
|
|
10
11
|
const as = paragraph || kind === "rich_text" ? "long" : kind === "url" ? "link" : kind;
|
|
11
12
|
return { label, kind: as, value, onValueChange, onDone, check, autoFocus, form, ...(place ? { place } : {}), draft: "shell", ...(region ? { country: region } : {}) };
|
|
@@ -14,6 +15,9 @@ export function textEditorWordsOf(say) {
|
|
|
14
15
|
return { country: say({ key: "views.editors.place-country" }), searchCountry: say({ key: "views.editors.place-country-search" }), picker: pickerWordsOf(say) };
|
|
15
16
|
}
|
|
16
17
|
export function MapTextBody(props) {
|
|
18
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(TextBodyInner, { ...props }) });
|
|
19
|
+
}
|
|
20
|
+
function TextBodyInner(props) {
|
|
17
21
|
const views = React.useContext(ViewsContext), messages = views?.messages ?? resolveViewsMessage;
|
|
18
22
|
const words = React.useMemo(() => textEditorWordsOf(messages), [messages]);
|
|
19
23
|
const parts = useTextEditor({ ...textEditorPropsOf(props), words, ...(views ? { language: views.conventions.language } : {}) });
|
|
@@ -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
|
}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Field } from "../field/field.js";
|
|
5
|
-
import {
|
|
5
|
+
import { InputGroup, InputGroupAddon } from "../input/input.js";
|
|
6
6
|
import { InlineInput, InlineInputGroup } from "../inline-input/inline-input.js";
|
|
7
|
-
import { Popover } from "../popover/popover.js";
|
|
8
7
|
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
9
8
|
import { drawnAt } from "../internal/scroll.js";
|
|
10
9
|
import { spacingPx } from "../internal/read-token.js";
|
|
@@ -15,6 +14,7 @@ import { TEXT_EDITOR_ATTRS, textEditorWornOf } from "./looks.js";
|
|
|
15
14
|
import { Countries } from "./countries.js";
|
|
16
15
|
import { textWords } from "./words.js";
|
|
17
16
|
import { keepTypedRun } from "../internal/typed-run.js";
|
|
17
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
18
18
|
const COUNTRY = { edge: "none", corner: "round", radius: "sm", words: "inherit", colour: "text", pad: "6-4", gap: "3", icon: "14", iconColour: "subtle", hover: "neutral", open: "neutral" };
|
|
19
19
|
const glyph = (paths) => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) }));
|
|
20
20
|
const X = ["M18 6l-12 12", "M6 6l12 12"], TICK = ["M5 12l5 5l10 -10"], DOWN = ["M6 9l6 6l6 -6"];
|
|
@@ -39,6 +39,7 @@ function useWorn(el) {
|
|
|
39
39
|
return worn;
|
|
40
40
|
}
|
|
41
41
|
export function useTextEditor(props) {
|
|
42
|
+
const { Input, GroupButton, Popover } = usePanelControls();
|
|
42
43
|
const { label, kind = "text", value, onValueChange, onDone, check, placeholder, typed, tried = false, autoFocus = true } = props;
|
|
43
44
|
const w = textWords(props.words), language = props.language ?? "en";
|
|
44
45
|
const host = React.useContext(PhoneHost), small = usePhone();
|
|
@@ -232,15 +233,15 @@ export function useTextEditor(props) {
|
|
|
232
233
|
}, [root, form, place, draft, worn.box, worn.long, worn.phone, kind, long, shown]);
|
|
233
234
|
if (form === "phone") {
|
|
234
235
|
const step = withCountry && open;
|
|
235
|
-
const field = withCountry ? (_jsxs(InputGroup, { size: "lg", children: [_jsxs(InputGroupAddon, { side: "start", children: [_jsx(
|
|
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 }) }));
|
|
236
|
+
const field = withCountry ? (_jsxs(InputGroup, { size: "lg", "data-slot": "vk-text-box", children: [_jsxs(InputGroupAddon, { side: "start", children: [_jsx(GroupButton, { 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 }));
|
|
237
|
+
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
238
|
if (step)
|
|
238
|
-
return { body, head: { onBack: () => setOpen(false), close: false }, title: w.country };
|
|
239
|
+
return { body, head: { onBack: () => setOpen(false), backSlot: "vk-editor-back", close: false }, title: w.country };
|
|
239
240
|
if (shell)
|
|
240
241
|
return { body, head: {} };
|
|
241
242
|
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 }),
|
|
243
|
+
left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": "Close", icon: glyph(X), onClick: leave }),
|
|
244
|
+
right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": "Save", icon: glyph(TICK), onClick: keep }),
|
|
244
245
|
};
|
|
245
246
|
return { body, head };
|
|
246
247
|
}
|
|
@@ -252,8 +253,8 @@ export function useTextEditor(props) {
|
|
|
252
253
|
return;
|
|
253
254
|
keep();
|
|
254
255
|
};
|
|
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(
|
|
256
|
+
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 })] });
|
|
257
|
+
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(GroupButton, { 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
258
|
setOpen(o);
|
|
258
259
|
if (shell)
|
|
259
260
|
return;
|
|
@@ -262,7 +263,7 @@ export function useTextEditor(props) {
|
|
|
262
263
|
if (!o && d.reason === "focus-out")
|
|
263
264
|
requestAnimationFrame(() => { if (!root?.contains(document.activeElement))
|
|
264
265
|
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] }));
|
|
266
|
+
}, 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
267
|
return { body, head: {} };
|
|
267
268
|
}
|
|
268
269
|
export function TextEditor(props) {
|
|
@@ -101,9 +101,11 @@ declare function stepsOf(items: React.ReactElement[], fill?: boolean): Step[];
|
|
|
101
101
|
export declare const toolbarSteps: typeof stepsOf;
|
|
102
102
|
/** The row and, under it, the filter bar: Base UI's toolbar, one Tab stop for the whole of it, the arrows inside. */
|
|
103
103
|
export declare function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added, picks: said, size, barSize, spacing, fold, fill, more, holds, form, onMoreViews, moreViewsOpen, className, style, onKeyDown, ...props }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
104
|
-
/** A line between what belongs together and what doesn't, across a line.
|
|
105
|
-
|
|
104
|
+
/** A line between what belongs together and what doesn't, across a line. `data-slot`, its public name where a part names it
|
|
105
|
+
* (VK-1023: the bulk bar's `vk-bulk-separator`). */
|
|
106
|
+
export declare function ToolbarSeparatorControl({ className, "data-slot": slot }: {
|
|
106
107
|
className?: string;
|
|
108
|
+
"data-slot"?: string;
|
|
107
109
|
}): import("react/jsx-runtime").JSX.Element;
|
|
108
110
|
/** Room that pushes what follows it to its line's far end (New, at the end of the row). */
|
|
109
111
|
export declare function ToolbarSpacer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -340,9 +340,9 @@ function dress(el, alone, height) {
|
|
|
340
340
|
return el;
|
|
341
341
|
}
|
|
342
342
|
const isSeparator = (n) => React.isValidElement(n) && n.type === ToolbarSeparatorControl;
|
|
343
|
-
export function ToolbarSeparatorControl({ className }) {
|
|
343
|
+
export function ToolbarSeparatorControl({ className, "data-slot": slot }) {
|
|
344
344
|
const row = React.useContext(InToolbar);
|
|
345
|
-
return row ? _jsx(BaseToolbar.Separator, { className: cn("o-toolbar-sep", className) }) : _jsx("span", { role: "separator", className: cn("o-toolbar-sep", className) });
|
|
345
|
+
return row ? _jsx(BaseToolbar.Separator, { className: cn("o-toolbar-sep", className), "data-slot": slot }) : _jsx("span", { role: "separator", className: cn("o-toolbar-sep", className), "data-slot": slot });
|
|
346
346
|
}
|
|
347
347
|
export function ToolbarSpacer() {
|
|
348
348
|
return _jsx("span", { className: "o-toolbar-spacer", "aria-hidden": "true" });
|
|
@@ -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
|
}
|