viewkitjs 0.33.0 → 0.35.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 +139 -0
- package/package.json +1 -1
- package/views/README.md +1 -1
- package/views/dist/atoms/Avatar.js +2 -1
- package/views/dist/atoms/RelationChip.d.ts +2 -0
- package/views/dist/atoms/RelationChip.js +5 -0
- package/views/dist/atoms/RowMenu.d.ts +1 -1
- package/views/dist/atoms/RowMenu.js +15 -3
- package/views/dist/atoms/defaults.js +2 -0
- package/views/dist/atoms/types.d.ts +40 -4
- package/views/dist/cells/relation-wrap.js +9 -2
- package/views/dist/contract.d.ts +27 -14
- package/views/dist/contract.js +40 -4
- package/views/dist/controls/alert/alert.js +2 -1
- package/views/dist/controls/alert-dialog/alert-dialog.js +3 -2
- package/views/dist/controls/avatar/avatar-mark.d.ts +4 -0
- package/views/dist/controls/avatar/avatar-mark.js +5 -0
- package/views/dist/controls/avatar/avatar.d.ts +7 -4
- package/views/dist/controls/avatar/avatar.js +10 -4
- package/views/dist/controls/avatar/looks.d.ts +1 -1
- package/views/dist/controls/avatar/looks.js +3 -0
- package/views/dist/controls/avatar/record-mark.d.ts +16 -0
- package/views/dist/controls/avatar/record-mark.js +13 -0
- package/views/dist/controls/avatar/tokens.d.ts +12 -0
- package/views/dist/controls/avatar/tokens.js +3 -0
- package/views/dist/controls/avatar.css +54 -17
- package/views/dist/controls/bulk-bar/bulk-bar.js +29 -27
- package/views/dist/controls/bulk-bar/map-selection-bar.js +2 -1
- package/views/dist/controls/compound-editor/compound-editor.d.ts +3 -0
- package/views/dist/controls/compound-editor/map-parts-body.d.ts +1 -1
- package/views/dist/controls/compound-editor/map-parts-body.js +6 -1
- package/views/dist/controls/compound-editor/name-parts.js +2 -1
- package/views/dist/controls/compound-editor/place-parts.js +2 -2
- package/views/dist/controls/compound-editor/range-parts.js +10 -9
- package/views/dist/controls/controls.d.ts +2 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +14 -5
- package/views/dist/controls/customize/customize.js +19 -20
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -2
- package/views/dist/controls/customize/map-customize-body.js +15 -13
- package/views/dist/controls/customize/words.d.ts +3 -3
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
- package/views/dist/controls/date-editor/date-editor.js +13 -7
- package/views/dist/controls/date-editor/map-calendar.js +2 -0
- 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/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +4 -6
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +2 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +7 -4
- package/views/dist/controls/filter-editor/parts.d.ts +4 -2
- package/views/dist/controls/filter-editor/parts.js +8 -7
- package/views/dist/controls/group-editor/group-editor.js +2 -1
- 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 +1 -1
- package/views/dist/controls/input/input.js +2 -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.js +9 -5
- package/views/dist/controls/internal/panel-controls.d.ts +38 -6
- package/views/dist/controls/internal/panel-controls.js +191 -19
- package/views/dist/controls/links-editor/links-editor.js +5 -7
- package/views/dist/controls/links-editor/map-links-body.d.ts +1 -1
- package/views/dist/controls/links-editor/map-links-body.js +5 -1
- package/views/dist/controls/menu/menu.d.ts +5 -1
- package/views/dist/controls/menu/menu.js +4 -3
- package/views/dist/controls/modal/modal.js +5 -3
- package/views/dist/controls/number-editor/map-number-body.js +5 -1
- package/views/dist/controls/number-editor/number-editor.js +6 -6
- 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/picker/map-fields-body.d.ts +2 -2
- package/views/dist/controls/picker/map-fields-body.js +30 -2
- package/views/dist/controls/picker/map-picker.d.ts +8 -3
- package/views/dist/controls/picker/map-picker.js +14 -3
- package/views/dist/controls/picker/picker.js +11 -8
- package/views/dist/controls/picker/rows.d.ts +7 -2
- package/views/dist/controls/picker.css +10 -1
- 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 +9 -4
- package/views/dist/controls/quick-filters/quick-filters.js +8 -6
- package/views/dist/controls/quick-filters/reminder.js +2 -2
- package/views/dist/controls/quick-filters/rules.d.ts +4 -1
- package/views/dist/controls/quick-filters/words.d.ts +2 -0
- package/views/dist/controls/quick-filters/words.js +1 -0
- package/views/dist/controls/select/select.d.ts +3 -0
- package/views/dist/controls/select/select.js +9 -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 +3 -1
- package/views/dist/controls/sheet/bottom-sheet.js +2 -2
- package/views/dist/controls/sort-editor/map-sort-body.js +4 -4
- package/views/dist/controls/sort-editor/sort-editor.d.ts +2 -0
- package/views/dist/controls/sort-editor/sort-editor.js +4 -5
- package/views/dist/controls/text-editor/map-text-body.js +5 -1
- package/views/dist/controls/text-editor/text-editor.js +5 -4
- package/views/dist/controls/toolbar/toolbar.d.ts +29 -14
- package/views/dist/controls/toolbar/toolbar.js +17 -22
- package/views/dist/controls/toolbar.css +0 -5
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +4 -2
- package/views/dist/controls/values-editor/map-values-body.d.ts +1 -2
- package/views/dist/controls/values-editor/map-values-body.js +5 -1
- package/views/dist/controls/values-editor/values-editor.js +8 -7
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -2
- package/views/dist/controls/views-list/map-view-menu.js +6 -2
- 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 +3 -4
- package/views/dist/controls/views-list/views-list.js +2 -2
- package/views/dist/display/option-badges.d.ts +16 -0
- package/views/dist/display/option-badges.js +11 -0
- package/views/dist/display/relation-link.d.ts +12 -0
- package/views/dist/display/relation-link.js +17 -0
- package/views/dist/display/relation.d.ts +1 -1
- package/views/dist/display/relation.js +10 -3
- package/views/dist/display/select.js +1 -8
- package/views/dist/editors/EditorPanel.js +4 -4
- package/views/dist/editors/RangeEditor.d.ts +3 -0
- package/views/dist/editors/RangeEditor.js +2 -2
- package/views/dist/editors/SelectEditor.d.ts +2 -2
- package/views/dist/editors/SelectEditor.js +1 -1
- package/views/dist/editors/TextEditor.js +4 -2
- package/views/dist/editors/ValueListEditor.js +2 -1
- package/views/dist/field-row/FieldRow.js +32 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/views/dist/grid/chrome/GridAddColumn.js +9 -6
- package/views/dist/grid/chrome/GridCellEditors.js +1 -1
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -1
- package/views/dist/grid/chrome/GridCellOutline.js +16 -6
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +7 -4
- package/views/dist/grid/chrome/GridFooter.d.ts +4 -1
- package/views/dist/grid/chrome/GridFooter.js +4 -4
- package/views/dist/grid/chrome/GridGroupMenu.js +39 -14
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -1
- package/views/dist/grid/chrome/GridHeader.js +1 -2
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +4 -1
- package/views/dist/grid/chrome/GridRangeEditor.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +5 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +4 -1
- package/views/dist/grid/chrome/GridRowActions.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +3 -2
- package/views/dist/grid/chrome/GridStructure.js +1 -1
- package/views/dist/grid/chrome/GridTable.js +32 -20
- package/views/dist/grid/chrome/checks.d.ts +1 -1
- package/views/dist/grid/chrome/checks.js +4 -1
- package/views/dist/grid/chrome/grid-cell-classes.d.ts +6 -2
- package/views/dist/grid/chrome/grid-cell-classes.js +10 -5
- package/views/dist/grid/chrome/grid-hover.d.ts +10 -2
- package/views/dist/grid/chrome/grid-hover.js +14 -4
- package/views/dist/grid/chrome/grid-row-props.d.ts +4 -0
- package/views/dist/grid/chrome/grid-rows-menu.js +9 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +10 -2
- package/views/dist/grid/grid.css +6 -0
- package/views/dist/grid/looks.d.ts +3 -1
- package/views/dist/grid/looks.js +10 -4
- package/views/dist/list/layer.d.ts +8 -0
- package/views/dist/list/layer.js +7 -0
- package/views/dist/list/list.d.ts +6 -2
- package/views/dist/list/list.js +6 -2
- package/views/dist/list/parts.js +3 -2
- package/views/dist/list/store.d.ts +1 -1
- package/views/dist/list/toolbar.js +51 -20
- package/views/dist/list/views.js +1 -0
- package/views/dist/panels/availability.d.ts +5 -0
- package/views/dist/panels/availability.js +4 -5
- package/views/dist/panels/customize-body.d.ts +4 -0
- package/views/dist/panels/customize-body.js +13 -11
- package/views/dist/panels/model.d.ts +9 -4
- package/views/dist/panels/react/customize-body.js +5 -2
- package/views/dist/panels/react/customize.d.ts +5 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +6 -0
- package/views/dist/panels/react/filter/FilterEditor.js +7 -0
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +3 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +7 -3
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +17 -1
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +15 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +24 -9
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +14 -6
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +7 -3
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +21 -10
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +5 -4
- package/views/dist/panels/react/toolbar/ToolbarSort.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +6 -3
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +3 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +7 -6
- package/views/dist/panels/react/toolbar/context.d.ts +21 -0
- 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.js +3 -2
- package/views/dist/panels/react/views-row/ViewPicker.js +13 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/settings/layout.js +6 -38
- package/views/dist/panels/toolbar/page-resets.d.ts +17 -0
- package/views/dist/panels/toolbar/page-resets.js +62 -0
- package/views/dist/panels/toolbar/same-item.d.ts +7 -0
- package/views/dist/panels/toolbar/same-item.js +9 -0
- package/views/dist/panels/view-state.d.ts +4 -0
- package/views/dist/provider/ViewsProvider.d.ts +9 -3
- package/views/dist/provider/ViewsProvider.js +13 -2
- package/views/dist/provider/components.d.ts +59 -8
- package/views/dist/provider/components.js +1 -1
- package/views/dist/react.d.ts +2 -2
- package/views/dist/styles.css +194 -100
- package/views/dist/styles.unlayered.css +194 -100
- package/views/docs/contract.md +96 -27
- package/views/docs/controls/alert-dialog.md +4 -0
- package/views/docs/controls/alert.md +4 -0
- package/views/docs/controls/avatar.md +3 -0
- package/views/docs/controls/bulk-bar.md +7 -1
- package/views/docs/controls/compound-editor.md +2 -0
- package/views/docs/controls/customize.md +3 -1
- package/views/docs/controls/date-editor.md +2 -0
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/group-editor.md +2 -0
- package/views/docs/controls/links-editor.md +2 -0
- package/views/docs/controls/menu.md +3 -1
- package/views/docs/controls/modal.md +4 -0
- package/views/docs/controls/number-editor.md +2 -0
- package/views/docs/controls/pane.md +1 -1
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/quick-filters.md +4 -2
- package/views/docs/controls/sheet.md +1 -1
- package/views/docs/controls/text-editor.md +3 -1
- package/views/docs/controls/toolbar.md +4 -0
- package/views/docs/controls/values-editor.md +2 -0
- package/views/docs/controls/views-list.md +2 -0
- package/views/docs/guides/atoms.md +54 -3
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +4 -2
- package/views/docs/guides/the-provider.md +4 -4
- package/views/docs/index.md +2 -2
- package/views/docs/install.md +198 -104
- package/views/docs/reference/controls.md +21 -17
- package/views/docs/reference/editors-range.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +2 -1
- package/views/docs/reference/list.md +7 -5
- package/views/docs/reference/looks.md +6 -6
- package/views/docs/reference/panels-react.md +17 -15
- package/views/docs/reference/panels.md +4 -4
- package/views/docs/reference/react.md +15 -12
- package/views/docs/reference/views.md +6 -4
- package/views/docs/reshaping.md +32 -5
- package/views/skills/views/SKILL.md +3 -3
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { useLabelableContext, useLabelableId } from "@base-ui/react/internals/labelable-provider";
|
|
5
|
+
import { NOOP } from "@base-ui/react/internals/noop";
|
|
4
6
|
import { Button } from "../button/button.js";
|
|
5
|
-
import {
|
|
7
|
+
import { GlassButton } from "../glass-button/glass-button.js";
|
|
8
|
+
import { useAutofill } from "../input/autofill.js";
|
|
9
|
+
import { Input, InputGroupButton, InputGroupContext } from "../input/input.js";
|
|
6
10
|
import { Menu } from "../menu/menu.js";
|
|
11
|
+
import { NumberField } from "../number-field/number-field.js";
|
|
7
12
|
import { Popover } from "../popover/popover.js";
|
|
8
13
|
import { Select } from "../select/select.js";
|
|
14
|
+
import { Tooltip } from "../tooltip/tooltip.js";
|
|
9
15
|
export const NO_APP_CONTROLS = Object.freeze({});
|
|
10
16
|
export const PanelControlsContext = React.createContext(NO_APP_CONTROLS);
|
|
11
|
-
const OWN = {
|
|
17
|
+
const OWN = {
|
|
18
|
+
Button: Button, Select, Menu, Popover, Input: Input,
|
|
19
|
+
GroupButton: InputGroupButton, Calendar: null, RoundButton: GlassButton,
|
|
20
|
+
Tooltip, NumberBox: NumberField,
|
|
21
|
+
};
|
|
12
22
|
export function usePanelControls() {
|
|
13
23
|
const app = React.useContext(PanelControlsContext);
|
|
14
24
|
return React.useMemo(() => (app === NO_APP_CONTROLS ? OWN : {
|
|
15
25
|
Button: app.Button ? AppButton : OWN.Button,
|
|
16
26
|
Select: app.Select ? AppSelect : Select,
|
|
17
27
|
Menu: app.Menu || app.Button ? OpenedMenu : Menu,
|
|
18
|
-
Popover: app.Popover ?
|
|
28
|
+
Popover: app.Popover || app.Button ? OpenedPopover : Popover,
|
|
19
29
|
Input: app.Input ? AppInput : OWN.Input,
|
|
30
|
+
GroupButton: app.Button ? AppGroupButton : OWN.GroupButton,
|
|
31
|
+
Calendar: app.Calendar ?? null,
|
|
32
|
+
RoundButton: app.Button ? AppRoundButton : OWN.RoundButton,
|
|
33
|
+
Tooltip: app.Tooltip ? AppTooltip : Tooltip,
|
|
34
|
+
NumberBox: app.Input ? AppNumberBox : NumberField,
|
|
20
35
|
}), [app]);
|
|
21
36
|
}
|
|
22
37
|
const VARIANT = {
|
|
@@ -25,12 +40,13 @@ const VARIANT = {
|
|
|
25
40
|
};
|
|
26
41
|
const SMALL = new Set(["2xs", "xs", "sm", "20", "22", "26", "20x24", "line"]);
|
|
27
42
|
export function buttonPropsOf(p) {
|
|
28
|
-
const { kind, size, shape, look: _look, loading
|
|
43
|
+
const { kind, size, shape, look: _look, loading, render: _render, nativeButton: _native, icon, iconEnd, children, focusableWhenDisabled, disabled, onClick, ...rest } = p;
|
|
29
44
|
const words = children != null && children !== false;
|
|
30
45
|
const inside = icon != null && !words && iconEnd == null ? icon : _jsxs(_Fragment, { children: [icon, children, iconEnd] });
|
|
31
|
-
const held = !!disabled && !!focusableWhenDisabled;
|
|
46
|
+
const held = (!!disabled && !!focusableWhenDisabled) || (!!loading && !disabled);
|
|
32
47
|
return {
|
|
33
48
|
...rest,
|
|
49
|
+
...(loading ? { "aria-busy": true } : {}),
|
|
34
50
|
type: rest.type ?? "button",
|
|
35
51
|
variant: VARIANT[kind ?? "outline"],
|
|
36
52
|
size: shape === "icon" || shape === "round" ? "icon" : SMALL.has(size ?? "md") ? "sm" : "default",
|
|
@@ -40,10 +56,71 @@ export function buttonPropsOf(p) {
|
|
|
40
56
|
}
|
|
41
57
|
function AppButton(p) {
|
|
42
58
|
const Own = React.useContext(PanelControlsContext).Button;
|
|
43
|
-
if (!Own)
|
|
59
|
+
if (!Own || p.render)
|
|
44
60
|
return _jsx(Button, { ...p });
|
|
45
61
|
return _jsx(Own, { ...buttonPropsOf(p) });
|
|
46
62
|
}
|
|
63
|
+
export const isAppButton = (type) => type === AppButton;
|
|
64
|
+
function AppGroupButton(p) {
|
|
65
|
+
return _jsx(AppButton, { kind: "quiet", size: "sm", ...p });
|
|
66
|
+
}
|
|
67
|
+
function AppRoundButton({ icon, children, kind, pressed, count, dot, size, render, ...p }) {
|
|
68
|
+
if (render)
|
|
69
|
+
return _jsx(GlassButton, { icon, children, kind, pressed, count, dot, size, render, ...p });
|
|
70
|
+
if (count != null || dot)
|
|
71
|
+
warnUnsaid("Button", [...(count != null ? ["count"] : []), ...(dot ? ["dot"] : [])], named(p) ?? "");
|
|
72
|
+
return _jsx(AppButton, { kind: kind === "primary" ? "primary" : kind === "danger" ? "danger" : "quiet", ...(children == null ? { shape: "icon" } : {}), icon: icon, ...(pressed !== undefined ? { "aria-pressed": pressed } : {}), ...p, children: children });
|
|
73
|
+
}
|
|
74
|
+
function useFieldControlId(id) {
|
|
75
|
+
const inField = useLabelableContext().registerControlId !== NOOP;
|
|
76
|
+
const named = useLabelableId({ id });
|
|
77
|
+
return inField && named ? { id: named } : {};
|
|
78
|
+
}
|
|
79
|
+
function AppTooltip({ label, keys, reason, side, align, disabled, delay, children }) {
|
|
80
|
+
const Own = React.useContext(PanelControlsContext).Tooltip;
|
|
81
|
+
if (!Own)
|
|
82
|
+
return _jsx(Tooltip, { label, keys, reason, side, align, disabled, delay, children: children });
|
|
83
|
+
if (disabled)
|
|
84
|
+
return children;
|
|
85
|
+
if (keys?.length)
|
|
86
|
+
warnUnsaid("Tooltip", ["keys"], typeof label === "string" ? label : "");
|
|
87
|
+
return _jsx(Own, { content: label, ...(reason ? { reason } : {}), ...(side ? { side } : {}), ...(align ? { align } : {}), ...(delay != null ? { delayMs: delay } : {}), children: children });
|
|
88
|
+
}
|
|
89
|
+
const plainNumber = (typed) => {
|
|
90
|
+
const t = typed.trim();
|
|
91
|
+
if (!t)
|
|
92
|
+
return null;
|
|
93
|
+
const n = Number(t.replace(",", "."));
|
|
94
|
+
return Number.isFinite(n) ? n : null;
|
|
95
|
+
};
|
|
96
|
+
function AppNumberBox(p) {
|
|
97
|
+
const read = React.useContext(PanelControlsContext).parseNumber ?? plainNumber;
|
|
98
|
+
const { value, onValueChange, format, onKeyDown, onBlur, onFocus, placeholder, size, disabled, readOnly, autoFocus, id, name } = p;
|
|
99
|
+
const whole = format?.maximumFractionDigits === 0;
|
|
100
|
+
const numberOf = (typed) => { const n = read(typed); return n == null ? null : whole ? Math.round(n) : n; };
|
|
101
|
+
const textOf = (n) => (n == null ? "" : String(n));
|
|
102
|
+
const [typed, setTyped] = React.useState(() => textOf(value));
|
|
103
|
+
const [held, setHeld] = React.useState(value ?? null);
|
|
104
|
+
if ((value ?? null) !== held) {
|
|
105
|
+
setHeld(value ?? null);
|
|
106
|
+
if (numberOf(typed) !== (value ?? null))
|
|
107
|
+
setTyped(textOf(value));
|
|
108
|
+
}
|
|
109
|
+
const hand = (n) => {
|
|
110
|
+
setHeld(n);
|
|
111
|
+
onValueChange?.(n);
|
|
112
|
+
};
|
|
113
|
+
const named = Object.fromEntries(Object.entries(p).filter(([k]) => k.startsWith("aria-") || k.startsWith("data-")));
|
|
114
|
+
return (_jsx(AppInput, { ...named, id, name, placeholder, disabled, readOnly, autoFocus, onFocus, size: size, type: "text", inputMode: "decimal", value: typed, onChange: (e) => { setTyped(e.target.value); hand(numberOf(e.target.value)); }, onKeyDown: (e) => {
|
|
115
|
+
onKeyDown?.(e);
|
|
116
|
+
if (e.defaultPrevented || (e.key !== "ArrowUp" && e.key !== "ArrowDown") || disabled || readOnly)
|
|
117
|
+
return;
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
const n = (numberOf(typed) ?? 0) + (e.key === "ArrowUp" ? 1 : -1) * (e.shiftKey ? 10 : 1);
|
|
120
|
+
setTyped(textOf(n));
|
|
121
|
+
hand(n);
|
|
122
|
+
}, onBlur: (e) => { onBlur?.(e); setTyped(textOf(numberOf(typed))); } }));
|
|
123
|
+
}
|
|
47
124
|
const selectItemsOf = (items) => items.map(({ value, label, line, group, disabled, mark, level }) => ({
|
|
48
125
|
value, label, ...(mark != null ? { icon: mark } : {}), ...(line != null ? { line } : {}), ...(group != null ? { group } : {}),
|
|
49
126
|
...(disabled ? { disabled } : {}), ...(level ? { level: selectItemsOf(level) } : {}),
|
|
@@ -51,23 +128,27 @@ const selectItemsOf = (items) => items.map(({ value, label, line, group, disable
|
|
|
51
128
|
export function selectPropsOf(p) {
|
|
52
129
|
const { items, value, onValueChange, multiple, placeholder, disabled, open, onOpenChange, search, size, className, opens: _opens, defaultValue: _defaultValue, label: _label, labelAt: _labelAt, note: _note, error: _error, name: _name, required: _required, readOnly: _readOnly, autoComplete: _autoComplete, side: _side, align: _align, listWidth: _listWidth, chips: _chips, clear: _clear, pickerWords: _pickerWords, searchIn: _searchIn, onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, ...rest } = p;
|
|
53
130
|
const { "data-force": _force, saving: _saving, ...passed } = rest;
|
|
54
|
-
const unsaid = Object.entries({ onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, clear: _clear })
|
|
131
|
+
const unsaid = Object.entries({ onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, ...(multiple ? { clear: _clear } : {}) })
|
|
55
132
|
.filter(([, v]) => v != null && v !== false).map(([k]) => k);
|
|
56
133
|
if (unsaid.length)
|
|
57
134
|
warnUnsaid("Select", unsaid, named(p) ?? "");
|
|
135
|
+
const clears = !multiple && typeof _clear === "string" && _clear !== "";
|
|
58
136
|
return {
|
|
59
137
|
...passed,
|
|
60
|
-
items:
|
|
138
|
+
items: clears ? [{ value: NO_VALUE, label: _clear }, ...selectItemsOf(items)] : selectItemsOf(items), value: value ?? null,
|
|
139
|
+
onValueChange: (v) => onValueChange?.(clears && v === NO_VALUE ? null : v), size: size === "md" || size === "lg" ? "default" : "sm",
|
|
61
140
|
...(multiple ? { multiple } : {}), ...(placeholder != null ? { placeholder } : {}), ...(disabled ? { disabled } : {}),
|
|
62
141
|
...(open !== undefined ? { open } : {}), ...(onOpenChange ? { onOpenChange } : {}), ...(search != null ? { search } : {}),
|
|
63
142
|
...(className ? { className } : {}),
|
|
64
143
|
};
|
|
65
144
|
}
|
|
145
|
+
const NO_VALUE = "\u0000vk-none";
|
|
66
146
|
function AppSelect(p) {
|
|
67
147
|
const Own = React.useContext(PanelControlsContext).Select;
|
|
148
|
+
const field = useFieldControlId(p.id);
|
|
68
149
|
if (!Own || p.opens)
|
|
69
150
|
return _jsx(Select, { ...p });
|
|
70
|
-
return _jsx(Own, { ...selectPropsOf(p) });
|
|
151
|
+
return _jsx(Own, { ...selectPropsOf(p), ...field });
|
|
71
152
|
}
|
|
72
153
|
const named = (p) => p["aria-label"] ?? p["data-slot"];
|
|
73
154
|
const warned = new Set();
|
|
@@ -84,7 +165,7 @@ function warnLeftOut(kind, label) {
|
|
|
84
165
|
warned.add(`${kind}:${label}`);
|
|
85
166
|
console.warn(`ViewKit: the menu "${label}" holds a "${kind}" row the components map's Menu can't be handed, so your Menu doesn't draw it.`);
|
|
86
167
|
}
|
|
87
|
-
export function menuItemsOf(entries, label) {
|
|
168
|
+
export function menuItemsOf(entries, label, within = "") {
|
|
88
169
|
const out = [];
|
|
89
170
|
let line = false;
|
|
90
171
|
const push = (item) => { out.push(line ? { ...item, separatorBefore: true } : item); line = false; };
|
|
@@ -93,7 +174,7 @@ export function menuItemsOf(entries, label) {
|
|
|
93
174
|
line = out.length > 0;
|
|
94
175
|
return;
|
|
95
176
|
}
|
|
96
|
-
const slot = e.slot?.slot, key = e.slot?.key ??
|
|
177
|
+
const slot = e.slot?.slot, key = e.slot?.key ?? `${within}${at}`;
|
|
97
178
|
if (e.kind === undefined || e.kind === "action") {
|
|
98
179
|
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), ...(e.onSelect ? { onSelect: e.onSelect } : {}), ...(e.danger ? { destructive: true } : {}),
|
|
99
180
|
...(e.disabled ? { disabled: true, disabledReason: e.disabled } : {}), ...(slot ? { slot } : {}) });
|
|
@@ -114,6 +195,30 @@ export function menuItemsOf(entries, label) {
|
|
|
114
195
|
else
|
|
115
196
|
rows.forEach(push);
|
|
116
197
|
}
|
|
198
|
+
else if (e.kind === "group") {
|
|
199
|
+
push({ key, label: e.heading, children: menuItemsOf(e.entries, label, `${key}.`), ...(slot ? { slot } : {}) });
|
|
200
|
+
}
|
|
201
|
+
else if (e.kind === "actions") {
|
|
202
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), children: menuItemsOf(e.entries, label, `${key}.`), beside: true,
|
|
203
|
+
...(e.detail ? { detail: e.detail } : {}), ...(slot ? { slot } : {}) });
|
|
204
|
+
}
|
|
205
|
+
else if (e.kind === "choices") {
|
|
206
|
+
const rows = e.choices.map((c) => {
|
|
207
|
+
const named = c.slot?.slot ?? slot;
|
|
208
|
+
return { key: c.slot?.key ?? c.value, label: c.label, ...(c.mark != null ? { icon: c.mark } : {}), checked: c.value === e.value,
|
|
209
|
+
onSelect: () => e.onChoose?.(c.value), ...(named ? { slot: named } : {}) };
|
|
210
|
+
});
|
|
211
|
+
const said = e.detail ?? e.choices.find((c) => c.value === e.value)?.label;
|
|
212
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), beside: true, children: rows, ...(said ? { detail: said } : {}), ...(slot ? { slot } : {}) });
|
|
213
|
+
}
|
|
214
|
+
else if (e.kind === "link") {
|
|
215
|
+
const unsaid = [...(e.render ? ["render"] : []), ...(e.external ? ["external"] : [])];
|
|
216
|
+
if (unsaid.length)
|
|
217
|
+
warnUnsaid("Menu", unsaid, label);
|
|
218
|
+
const go = e.onSelect;
|
|
219
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), ...(e.href ? { href: e.href } : {}),
|
|
220
|
+
...(go ? { onSelect: () => go(undefined) } : {}), ...(slot ? { slot } : {}) });
|
|
221
|
+
}
|
|
117
222
|
else
|
|
118
223
|
warnLeftOut(e.kind, label);
|
|
119
224
|
});
|
|
@@ -158,10 +263,12 @@ function AnchoredAppMenu(p) {
|
|
|
158
263
|
}
|
|
159
264
|
export function popoverPropsOf(p) {
|
|
160
265
|
const extra = p;
|
|
161
|
-
const unsaid = ["
|
|
266
|
+
const unsaid = ["defaultOpen"].filter((k) => extra[k] != null);
|
|
267
|
+
if (typeof p.finalFocus === "boolean")
|
|
268
|
+
unsaid.push("finalFocus");
|
|
162
269
|
if (unsaid.length)
|
|
163
270
|
warnUnsaid("Popover", unsaid, named(p) ?? "");
|
|
164
|
-
const { open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, className, style, children } = p;
|
|
271
|
+
const { open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, className, style, children, popupData, onPopupClick } = p;
|
|
165
272
|
const label = p["aria-label"];
|
|
166
273
|
return {
|
|
167
274
|
open: !!open, onOpenChange: (o, d) => onOpenChange?.(o, { reason: (d?.reason ?? "none") }),
|
|
@@ -169,20 +276,84 @@ export function popoverPropsOf(p) {
|
|
|
169
276
|
...(side ? { side } : {}), ...(align ? { align } : {}), ...(sideOffset != null ? { sideOffset } : {}), ...(alignOffset != null ? { alignOffset } : {}),
|
|
170
277
|
...(initialFocus !== undefined ? { initialFocus: typeof initialFocus === "boolean" ? initialFocus : true } : {}),
|
|
171
278
|
...(onOutsidePress ? { onOutsidePress } : {}), ...(onEscape ? { onEscape } : {}), ...(className ? { className } : {}), ...(style ? { style } : {}),
|
|
172
|
-
...(label != null ? { label } : {}),
|
|
279
|
+
...(label != null ? { label } : {}), ...(popupData ? { panelData: popupData } : {}), ...(onPopupClick ? { onPanelClick: onPopupClick } : {}),
|
|
173
280
|
};
|
|
174
281
|
}
|
|
175
282
|
function AppPopover(p) {
|
|
176
283
|
const Own = React.useContext(PanelControlsContext).Popover;
|
|
284
|
+
const open = !!p.open, was = React.useRef(open), why = React.useRef(null);
|
|
285
|
+
const back = Own && !p.trigger && p.finalFocus && typeof p.finalFocus !== "boolean" ? p.finalFocus : null;
|
|
286
|
+
React.useLayoutEffect(() => {
|
|
287
|
+
const shut = was.current && !open, reason = why.current;
|
|
288
|
+
was.current = open;
|
|
289
|
+
why.current = null;
|
|
290
|
+
if (!shut || !back || reason === "outside-press" || reason === "focus-out")
|
|
291
|
+
return;
|
|
292
|
+
const give = () => back.current?.focus({ preventScroll: true });
|
|
293
|
+
if (reason) {
|
|
294
|
+
give();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const from = document.activeElement;
|
|
298
|
+
let frame = 0, tries = 0;
|
|
299
|
+
const look = () => {
|
|
300
|
+
const now = document.activeElement;
|
|
301
|
+
if (!now || now === document.body || !now.isConnected) {
|
|
302
|
+
give();
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (now !== from || tries++ >= 120)
|
|
306
|
+
return;
|
|
307
|
+
frame = requestAnimationFrame(look);
|
|
308
|
+
};
|
|
309
|
+
look();
|
|
310
|
+
return () => cancelAnimationFrame(frame);
|
|
311
|
+
}, [open, back]);
|
|
177
312
|
if (!Own || p.trigger)
|
|
178
313
|
return _jsx(Popover, { ...p });
|
|
179
|
-
|
|
314
|
+
const handed = popoverPropsOf(p);
|
|
315
|
+
const onOutsidePress = (e) => { const kept = p.onOutsidePress?.(e); if (kept !== false)
|
|
316
|
+
why.current = "outside-press"; return kept; };
|
|
317
|
+
return _jsx(Own, { ...handed, onOutsidePress: onOutsidePress, onOpenChange: (o, d) => { why.current = o ? null : d?.reason ?? why.current; handed.onOpenChange(o, d); } });
|
|
318
|
+
}
|
|
319
|
+
function OpenedPopover(p) {
|
|
320
|
+
return p.trigger ? _jsx(TriggeredPopover, { ...p }) : _jsx(AppPopover, { ...p });
|
|
321
|
+
}
|
|
322
|
+
function TriggeredPopover(p) {
|
|
323
|
+
const [ownOpen, setOwnOpen] = React.useState(!!p.defaultOpen), open = p.open ?? ownOpen;
|
|
324
|
+
const [at, setAt] = React.useState(null);
|
|
325
|
+
const back = React.useRef(null);
|
|
326
|
+
const openNow = React.useRef(open), pressedOpen = React.useRef(null);
|
|
327
|
+
React.useLayoutEffect(() => { openNow.current = open; });
|
|
328
|
+
const set = (next, reason = "trigger-press") => {
|
|
329
|
+
openNow.current = next;
|
|
330
|
+
setOwnOpen(next);
|
|
331
|
+
p.onOpenChange?.(next, { reason });
|
|
332
|
+
};
|
|
333
|
+
const trigger = p.trigger;
|
|
334
|
+
const own = trigger.props.ref;
|
|
335
|
+
const placed = (el) => { if (el) {
|
|
336
|
+
back.current = el;
|
|
337
|
+
setAt(el);
|
|
338
|
+
} fillRef(own, el); };
|
|
339
|
+
function onPointerDown(e) { pressedOpen.current = openNow.current; trigger.props.onPointerDown?.(e); }
|
|
340
|
+
function onClick(e) {
|
|
341
|
+
trigger.props.onClick?.(e);
|
|
342
|
+
back.current = e.currentTarget;
|
|
343
|
+
setAt(e.currentTarget);
|
|
344
|
+
const was = pressedOpen.current ?? openNow.current;
|
|
345
|
+
pressedOpen.current = null;
|
|
346
|
+
set(!was);
|
|
347
|
+
}
|
|
348
|
+
const opener = React.cloneElement(trigger, { ref: placed, "aria-haspopup": "dialog", "aria-expanded": open, "data-state": open ? "open" : "closed", onPointerDown, onClick });
|
|
349
|
+
const finalFocus = p.finalFocus === false ? false : p.finalFocus && typeof p.finalFocus !== "boolean" ? p.finalFocus : back;
|
|
350
|
+
return (_jsxs(_Fragment, { children: [opener, _jsx(AppPopover, { ...p, trigger: undefined, defaultOpen: undefined, anchor: p.anchor ?? at, open: open, finalFocus: finalFocus, onOpenChange: (o, d) => set(o, d.reason) })] }));
|
|
180
351
|
}
|
|
181
|
-
export function inputPropsOf(p) {
|
|
352
|
+
export function inputPropsOf(p, bare = false) {
|
|
182
353
|
const { size: _size, chrome: _chrome, look: _look, numeric: _numeric, multiline: _multiline, grow: _grow, maxLines: _maxLines, minLines: _minLines, lines: _lines, autofill: _autofill, fills: _fills, saving: _saving, saved: _saved, combobox: _combobox, onValueChange, onChange, ...rest } = p;
|
|
183
354
|
return {
|
|
184
355
|
...rest,
|
|
185
|
-
chrome: "field",
|
|
356
|
+
chrome: bare ? "bare" : "field",
|
|
186
357
|
onChange: (e) => {
|
|
187
358
|
onChange?.(e);
|
|
188
359
|
onValueChange?.(e.target.value, { event: e.nativeEvent });
|
|
@@ -191,7 +362,8 @@ export function inputPropsOf(p) {
|
|
|
191
362
|
}
|
|
192
363
|
function AppInput(p) {
|
|
193
364
|
const Own = React.useContext(PanelControlsContext).Input;
|
|
194
|
-
|
|
365
|
+
const grouped = React.useContext(InputGroupContext) != null, fill = useAutofill(), field = useFieldControlId(p.id);
|
|
366
|
+
if (!Own || p.multiline || p.combobox)
|
|
195
367
|
return _jsx(Input, { ...p });
|
|
196
|
-
return _jsx(Own, { ...inputPropsOf(p) });
|
|
368
|
+
return _jsx(Own, { ...fill(p.autofill !== false), ...inputPropsOf(p, p.chrome === "bare" || grouped), ...field });
|
|
197
369
|
}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { Button } from "../button/button.js";
|
|
4
|
+
import { RecordMark } from "../avatar/record-mark.js";
|
|
6
5
|
import { FieldRows, FieldRowsRow as FieldRow } from "../field/field.js";
|
|
7
|
-
import {
|
|
6
|
+
import { InputGroup, InputGroupAddon } from "../input/input.js";
|
|
7
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
8
8
|
import { DOTS, DOTS_LOOK, glyph, PLUS, useDecide, useStandingRoom, X } from "../internal/editor-parts.js";
|
|
9
9
|
import { Icon } from "../internal/icons.js";
|
|
10
10
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
11
11
|
import { spacingPx } from "../internal/read-token.js";
|
|
12
12
|
import { drawnAt, scrollInList } from "../internal/scroll.js";
|
|
13
13
|
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
14
|
-
import { Menu } from "../menu/menu.js";
|
|
15
14
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
16
|
-
import { Popover } from "../popover/popover.js";
|
|
17
15
|
import { Radio, RadioGroup } from "../radio/radio.js";
|
|
18
|
-
import { Select } from "../select/select.js";
|
|
19
16
|
import { Spinner } from "../spinner/spinner.js";
|
|
20
17
|
import { Switch } from "../switch/switch.js";
|
|
21
18
|
import { midWord } from "../text-editor/check.js";
|
|
@@ -34,9 +31,10 @@ const FIELDS = { cards: "one", edge: "on", height: "52", label: "104", lines: "w
|
|
|
34
31
|
function Face({ record, size }) {
|
|
35
32
|
const as = record.as;
|
|
36
33
|
const avatar = as && "avatar" in as ? as : null;
|
|
37
|
-
return _jsx(
|
|
34
|
+
return _jsx(RecordMark, { label: record.label, shape: avatar?.avatar === "person" ? "person" : "thing", id: avatar?.id, src: avatar?.src, kind: avatar?.kind, size: size });
|
|
38
35
|
}
|
|
39
36
|
export function useLinksEditor(props) {
|
|
37
|
+
const { Button, Input, Menu, Popover, Select } = usePanelControls();
|
|
40
38
|
const { label, kind, records, fields, links, onLinksChange, lead, autoFocus = true, opens, onSearch, doing, onRetry, onMore, actions = [] } = props;
|
|
41
39
|
const w = linksWords(props.words), search = props.search ?? w.search;
|
|
42
40
|
const screen = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (screen || small ? "phone" : "computer")) === "phone";
|
|
@@ -6,5 +6,5 @@ import type { LinksEditorWords } from "./words.js";
|
|
|
6
6
|
export declare function linksEditorWordsOf(say: ViewsMessageResolver, makeLead?: string): LinksEditorWords;
|
|
7
7
|
/** ViewKit's links body's props as the Links editor's, its roles' column named `rolesWord`. */
|
|
8
8
|
export declare function linksEditorPropsOf(p: ViewsLinksBodyProps, words: LinksEditorWords, rolesWord: string, AppIcon?: ViewsResolvedComponents["AppIcon"]): LinksEditorProps;
|
|
9
|
-
/** ViewKit's links body,
|
|
9
|
+
/** ViewKit's links body, its controls the app's where the provider's `panelControls` names them (VK-1022). */
|
|
10
10
|
export declare function MapLinksBody(props: ViewsLinksBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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 { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
|
|
6
6
|
import { ViewsContext } from "../../provider/context.js";
|
|
7
7
|
import { pickerItemsOf, pickerWordsOf } from "../picker/map-picker.js";
|
|
8
8
|
import { useToldStep } from "../internal/told-step.js";
|
|
9
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
9
10
|
import { useLinksEditor } from "./links-editor.js";
|
|
10
11
|
import { heldOf } from "./links.js";
|
|
11
12
|
const ROLES = "roles";
|
|
@@ -63,6 +64,9 @@ export function linksEditorPropsOf(p, words, rolesWord, AppIcon) {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
export function MapLinksBody(props) {
|
|
67
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(LinksBodyInner, { ...props }) });
|
|
68
|
+
}
|
|
69
|
+
function LinksBodyInner(props) {
|
|
66
70
|
const views = React.useContext(ViewsContext);
|
|
67
71
|
const messages = views?.messages ?? resolveViewsMessage;
|
|
68
72
|
const makeLead = props.lead?.makeLabel;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type MenuChoice, type MenuEntry } from "../menu-list/menu-list.js";
|
|
3
|
+
import { type ButtonProps } from "../button/button.js";
|
|
3
4
|
import { type Anchor } from "../internal/anchor.js";
|
|
4
5
|
import { type CloseReason } from "../internal/close-reason.js";
|
|
5
6
|
import { type PickerWords } from "../picker/picker.js";
|
|
@@ -17,7 +18,8 @@ export interface MenuProps {
|
|
|
17
18
|
words?: MenuWords;
|
|
18
19
|
/** What the menu is for, to screen readers ("Acme Robotics — service portal redesign"). */
|
|
19
20
|
label: string;
|
|
20
|
-
/** Its public name where a
|
|
21
|
+
/** Its public name where a part names it (VK-988: `vk-view-menu`; VK-1023: the bulk bar's `vk-bulk-menu`), on its popup on a
|
|
22
|
+
* computer and on its Sheet on a phone. */
|
|
21
23
|
"data-slot"?: string;
|
|
22
24
|
/** What opens it: the ⋯ button by default (MenuDots), named "Actions for <label>". */
|
|
23
25
|
trigger?: React.ReactElement;
|
|
@@ -86,3 +88,5 @@ export declare const MenuDots: React.ForwardRefExoticComponent<{
|
|
|
86
88
|
className?: string;
|
|
87
89
|
"data-force"?: string;
|
|
88
90
|
} & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
|
91
|
+
/** The ⋯ button's own props, for a part that draws it through another Button (the Picker's phone row, under `panelControls`). */
|
|
92
|
+
export declare const menuDotsProps: (label: string, className?: string) => ButtonProps;
|
|
@@ -63,7 +63,7 @@ function LevelSheet({ index, at }) {
|
|
|
63
63
|
at.shut(index); }, onOpenChangeComplete: (o) => { if (!o)
|
|
64
64
|
at.gone(index); }, label: entry.label, form: entry.kind === "choices" ? "full" : at.form, container: at.container, standing: at.standing, children: [entry.kind === "choices" ? _jsx(LevelPicker, { entry: entry }) : _jsx(LevelActions, { entry: entry, index: index, at: at }), index + 1 < at.levels.length && _jsx(LevelSheet, { index: index + 1, at: at })] }));
|
|
65
65
|
}
|
|
66
|
-
function MenuSheet({ entries, label, trigger, anchor, open, defaultOpen, onOpenChange, defaultLevel, allRows, frame, words: said = NO_WORDS }) {
|
|
66
|
+
function MenuSheet({ entries, label, trigger, anchor, open, defaultOpen, onOpenChange, defaultLevel, allRows, frame, words: said = NO_WORDS, "data-slot": slot }) {
|
|
67
67
|
const { ref, host } = usePickHost(), screen = React.useContext(PhoneHost), [mark, setMark] = React.useState(null);
|
|
68
68
|
const first = () => { const l = levelOf(entries, defaultLevel); return l ? [{ entry: l, open: true }] : []; };
|
|
69
69
|
const rows = useMenuListRows(mark), words = rows === "words", closeRow = useMenuListOption(mark, "close") === "shown" && !words;
|
|
@@ -78,7 +78,7 @@ function MenuSheet({ entries, label, trigger, anchor, open, defaultOpen, onOpenC
|
|
|
78
78
|
const rowsList = _jsx(MenuList, { label: label, ...(words ? { entries: shutting } : tilesOf(shutting, allRows)), onOpen: at.openFrom(-1), onClose: closeRow ? () => set(false, "close-press") : undefined, closeWord: said.close });
|
|
79
79
|
const list = frame ? _jsx("div", { ...frame, style: { display: "contents" }, children: rowsList }) : rowsList;
|
|
80
80
|
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: (el) => { ref.current = el; setMark(el); }, hidden: true, ...frame }), opener && React.cloneElement(opener, mergeProps({ "aria-haspopup": "dialog", "aria-expanded": shown, onClick: () => set(!shown, "trigger-press") }, opener.props)), _jsx(MenuWordsContext.Provider, { value: said, children: _jsxs(Sheet, { open: shown, onOpenChange: (o, d) => set(o, d.reason), onOpenChangeComplete: (o) => { if (!o)
|
|
81
|
-
setLevels(first()); }, label: label, form: at.form, container: at.container, standing: at.standing, children: [_jsx(SheetBody, { children: list }), levels.length > 0 && _jsx(LevelSheet, { index: 0, at: at })] }, at.form) })] }));
|
|
81
|
+
setLevels(first()); }, label: label, form: at.form, container: at.container, standing: at.standing, "data-slot": slot, children: [_jsx(SheetBody, { children: list }), levels.length > 0 && _jsx(LevelSheet, { index: 0, at: at })] }, at.form) })] }));
|
|
82
82
|
}
|
|
83
83
|
export function Menu(props) {
|
|
84
84
|
return useSheetMenus() && !props.popup ? _jsx(MenuSheet, { ...props }) : _jsx(MenuPopup, { ...props });
|
|
@@ -103,5 +103,6 @@ function ContextMenuPopup({ entries, label, children, className, open, onOpenCha
|
|
|
103
103
|
return (_jsxs(BaseContextMenu.Root, { open: open, onOpenChange: onOpenChange ? (o) => onOpenChange(o) : undefined, children: [_jsxs(BaseContextMenu.Trigger, { className: className, children: [_jsx("span", { ref: ref, hidden: true }), children] }), _jsx(BaseContextMenu.Portal, { container: host, className: "o-menu-portal", children: _jsx(BaseContextMenu.Positioner, { ref: setAt, className: "o-list-positioner", collisionPadding: spacingPx(2, at ?? host), children: _jsx(BaseContextMenu.Popup, { className: "o-list o-menu o-smooth o-smooth-ease", "aria-label": label, "data-kit": "menu", ...mark, children: _jsx(MenuScroll, { children: _jsx(MenuListRows, { entries: entries, host: host }) }) }) }) })] }));
|
|
104
104
|
}
|
|
105
105
|
export const MenuDots = React.forwardRef(function MenuDots({ label, className, ...props }, ref) {
|
|
106
|
-
return _jsx(Button, { ref: ref,
|
|
106
|
+
return _jsx(Button, { ref: ref, ...menuDotsProps(label, className), ...props });
|
|
107
107
|
});
|
|
108
|
+
export const menuDotsProps = (label, className) => ({ kind: "quiet", shape: "icon", size: "sm", "aria-label": label, className: cx("o-menu-dots", className), icon: glyph(DOTS, "") });
|
|
@@ -2,14 +2,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
|
|
4
4
|
import { AlertDialog } from "../alert-dialog/alert-dialog.js";
|
|
5
|
-
import {
|
|
5
|
+
import { PanelHeadButton } from "../internal/head-button.js";
|
|
6
6
|
import { useKeptFocus } from "../internal/keep-focus.js";
|
|
7
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
7
8
|
import { PhoneHost, usePhone } from "../internal/phone.js";
|
|
8
9
|
import { OutOfFieldRows } from "../../internal/field-rows.js";
|
|
9
10
|
import { usePopupHost } from "../internal/popup-host.js";
|
|
10
11
|
import { Notice } from "../notice/notice.js";
|
|
11
12
|
import { Scrollbar } from "../scrollbar/scrollbar.js";
|
|
12
|
-
import { Sheet, SheetBody,
|
|
13
|
+
import { Sheet, SheetBody, SheetHead } from "../sheet/bottom-sheet.js";
|
|
13
14
|
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)) });
|
|
14
15
|
const X = ["M18 6l-12 12", "M6 6l12 12"], CHECK = ["M5 12l5 5l10 -10"], NEXT = ["M9 6l6 6l-6 6"];
|
|
15
16
|
const EXPAND = ["M16 4l4 0l0 4", "M14 10l6 -6", "M8 20l-4 0l0 -4", "M4 20l6 -6"];
|
|
@@ -24,6 +25,7 @@ export const MODAL_WORDS = {
|
|
|
24
25
|
};
|
|
25
26
|
export function Modal({ open, onOpenChange, title, mark, path, onOpenAsPage, size = "md", foot = "both", action, cancel = "Cancel", footStart, dirty, state, failed, container, standing, children, words }) {
|
|
26
27
|
const said = { ...MODAL_WORDS, ...words };
|
|
28
|
+
const { Button } = usePanelControls();
|
|
27
29
|
const ref = React.useRef(null), host = usePopupHost(ref), body = React.useRef(null);
|
|
28
30
|
const small = usePhone(), screen = React.useContext(PhoneHost), phone = small || !!screen;
|
|
29
31
|
const [own, setOwn] = React.useState("rest"), [why, setWhy] = React.useState(null), [asking, setAsking] = React.useState(false);
|
|
@@ -60,7 +62,7 @@ export function Modal({ open, onOpenChange, title, mark, path, onOpenAsPage, siz
|
|
|
60
62
|
onOpenChange(false); }, title: said.discardTitle, line: said.discardLine, action: said.discard, kind: "danger", cancel: said.keepEditing, container: where, standing: standing }));
|
|
61
63
|
if (phone)
|
|
62
64
|
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: ref, hidden: true }), _jsxs(Sheet, { open: open, onOpenChange: (o) => { if (!o)
|
|
63
|
-
leave(); }, label: title, form: "full", container: where, standing: standing, children: [_jsx(SheetHead, { title: title, left: _jsx(
|
|
65
|
+
leave(); }, label: title, form: "full", container: where, standing: standing, children: [_jsx(SheetHead, { title: title, left: _jsx(PanelHeadButton, { "aria-label": cancel, icon: glyph(X), onClick: leave, disabled: saving }), right: foot !== "none" && action ? _jsx(PanelHeadButton, { kind: "primary", "aria-label": action.label, icon: glyph(CHECK), onClick: act, disabled: saving || action.disabled }) : _jsx("span", {}) }), _jsxs(SheetBody, { children: [notice, children] }), guard] })] }));
|
|
64
66
|
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: ref, hidden: true }), _jsx(BaseDialog.Root, { open: open, onOpenChange: (o) => { if (!o)
|
|
65
67
|
leave(); }, ...(standing ? { modal: false, disablePointerDismissal: true } : {}), children: _jsxs(BaseDialog.Portal, { container: where, children: [_jsx(BaseDialog.Backdrop, { className: "o-modal-backdrop", "data-over-popup": over }), _jsx(BaseDialog.Viewport, { className: "o-modal-viewport", "data-over-popup": over, children: _jsxs(BaseDialog.Popup, { ref: setPopup, className: "o-modal", "data-kit": "modal", "data-width": size, "aria-busy": saving || undefined, initialFocus: standing ? false : () => body.current?.querySelector("input:not([type=hidden]), textarea, [role='combobox'], .o-select-field") ?? true, children: [_jsxs("div", { className: "o-modal-cut o-smooth", children: [_jsxs("header", { className: "o-modal-head", children: [mark != null && _jsx("span", { className: "o-modal-mark", "aria-hidden": "true", children: mark }), path && _jsxs("span", { className: "o-modal-path", children: [_jsxs("span", { className: "o-modal-chip", children: [path.icon, _jsx("span", { className: "o-modal-chip-word", children: path.label })] }), glyph(NEXT)] }), _jsx(BaseDialog.Title, { className: "o-modal-title", children: title }), _jsxs("span", { className: "o-modal-tools", children: [onOpenAsPage && _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", "aria-label": said.openAsPage, icon: glyph(EXPAND), onClick: onOpenAsPage }), _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", "aria-label": said.close, icon: glyph(X), disabled: saving, onClick: leave })] })] }), _jsx("div", { ref: body, className: "o-modal-body", children: _jsxs(OutOfFieldRows, { children: [notice, children] }) }), _jsx(Scrollbar, { drawn: true }), foot !== "none" && (_jsxs("footer", { className: "o-modal-foot", children: [footStart != null && _jsx("span", { className: "o-modal-start", children: footStart }), _jsxs("span", { className: "o-modal-end", children: [foot === "both" && _jsx(Button, { className: "o-modal-cancel", disabled: saving, onClick: leave, children: cancel }), action && _jsx(Button, { kind: action.kind ?? "primary", loading: saving, disabled: action.disabled, onClick: act, children: action.label })] })] }))] }), guard] }) })] }) })] }));
|
|
66
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
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 { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
|
|
@@ -7,6 +7,7 @@ import { ViewsContext } from "../../provider/context.js";
|
|
|
7
7
|
import { pickerWordsOf } from "../picker/map-picker.js";
|
|
8
8
|
import { useToldStep } from "../internal/told-step.js";
|
|
9
9
|
import { useNumberEditor } from "./number-editor.js";
|
|
10
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
10
11
|
const signs = new Map();
|
|
11
12
|
export function currencyOf(code, locale, language = locale) {
|
|
12
13
|
const key = `${locale}␟${language}␟${code}`;
|
|
@@ -49,6 +50,9 @@ export function numberEditorPropsOf({ label, kind, value, unit, units, onValueCh
|
|
|
49
50
|
return { ...props, ...(min !== undefined && { min }), ...(max !== undefined && { max }), ...(decimal && { decimal }), ...(typed !== undefined && { typed }) };
|
|
50
51
|
}
|
|
51
52
|
export function MapNumberBody(props) {
|
|
53
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(NumberBodyInner, { ...props }) });
|
|
54
|
+
}
|
|
55
|
+
function NumberBodyInner(props) {
|
|
52
56
|
const views = React.useContext(ViewsContext), messages = views?.messages ?? resolveViewsMessage;
|
|
53
57
|
const words = React.useMemo(() => numberEditorWordsOf(messages), [messages]);
|
|
54
58
|
const parts = useNumberEditor(numberEditorPropsOf(props, words, views?.conventions.language));
|
|
@@ -1,12 +1,10 @@
|
|
|
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
|
-
import { InputGroupButton } from "../input/input.js";
|
|
6
4
|
import { PhoneHost, phoneMark, usePhone, usePhoneForm } from "../internal/phone.js";
|
|
5
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
7
6
|
import { NumberField } from "../number-field/number-field.js";
|
|
8
7
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
9
|
-
import { Popover } from "../popover/popover.js";
|
|
10
8
|
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
11
9
|
import { boxLocale, readTyped } from "./format.js";
|
|
12
10
|
import { NUMBER_EDITOR_ATTRS, numberEditorWornOf } from "./looks.js";
|
|
@@ -56,6 +54,7 @@ function homeOrEnd(e) {
|
|
|
56
54
|
}
|
|
57
55
|
export function useNumberEditor(props) {
|
|
58
56
|
const { label, kind = "number", value, currency, currencies = [], unit, units = [], onValueChange, onDone, min, max, step = 1, decimals = 2, locale, decimal, align = "end", typed, popupData } = props;
|
|
57
|
+
const { Button, GroupButton, Popover } = usePanelControls();
|
|
59
58
|
const shell = props.draft === "shell";
|
|
60
59
|
const { phone, box } = useKeeping(props);
|
|
61
60
|
const settled = React.useRef(false);
|
|
@@ -162,7 +161,7 @@ export function useNumberEditor(props) {
|
|
|
162
161
|
} };
|
|
163
162
|
const sign = now?.sign ?? now?.code;
|
|
164
163
|
const fieldStart = now ? (pickable
|
|
165
|
-
? _jsx(
|
|
164
|
+
? _jsx(GroupButton, { "data-slot": "vk-number-currency", "aria-label": named, iconEnd: glyph(DOWN), onClick: choose, children: codes || !now.sign ? now.code : `${now.sign} ${now.code}` })
|
|
166
165
|
: codes ? _jsx("span", { className: "o-number-editor-code", "data-slot": "vk-number-unit", "data-key": "code", children: now.code }) : _jsx("span", { className: "o-number-editor-sign", "data-slot": "vk-number-unit", "data-key": "sign", children: sign })) : undefined;
|
|
167
166
|
const boxStart = now ? (pickable
|
|
168
167
|
? _jsx(Button, { kind: "quiet", size: "sm", className: "o-number-editor-code", "data-slot": "vk-number-currency", look: SHEET_CODE, "aria-label": named, iconEnd: glyph(DOWN), onClick: choose, children: codes || !now.sign ? now.code : `${now.sign} ${now.code}` })
|
|
@@ -182,9 +181,10 @@ export function useNumberEditor(props) {
|
|
|
182
181
|
return;
|
|
183
182
|
keep();
|
|
184
183
|
};
|
|
184
|
+
const openAt = (e) => { setChip(e.currentTarget); setChoosing(true); };
|
|
185
185
|
const start = !now ? null : worn.units === "code"
|
|
186
|
-
? (pickable ? _jsx(Button, { ref: setChip, kind: "quiet", size: "xs", className: "o-number-editor-code", "data-slot": "vk-number-currency", "aria-label": named, "aria-expanded": choosing, iconEnd: glyph(DOWN), onClick:
|
|
187
|
-
: (pickable ? _jsx(Button, { ref: setChip, kind: "soft", size: "2xs", className: "o-number-editor-currency", "data-slot": "vk-number-currency", "aria-label": named, iconEnd: glyph(DOWN), onClick:
|
|
186
|
+
? (pickable ? _jsx(Button, { ref: setChip, kind: "quiet", size: "xs", className: "o-number-editor-code", "data-slot": "vk-number-currency", "aria-label": named, "aria-expanded": choosing, iconEnd: glyph(DOWN), onClick: openAt, children: now.code }) : null)
|
|
187
|
+
: (pickable ? _jsx(Button, { ref: setChip, kind: "soft", size: "2xs", className: "o-number-editor-currency", "data-slot": "vk-number-currency", "aria-label": named, iconEnd: glyph(DOWN), onClick: openAt, children: now.sign ?? now.code })
|
|
188
188
|
: _jsx("span", { className: "o-number-editor-sign", "data-slot": "vk-number-unit", "data-key": "sign", children: now.sign ?? now.code }));
|
|
189
189
|
const body = (_jsxs("div", { ref: wornAt, className: "o-number-editor", "data-slot": "vk-number", "data-kit": "number-editor", ...device, "data-number-form": "computer", "data-number-kind": kind, onChange: readChange, onBlur: onBlur, onFocus: () => { settled.current = false; }, children: [_jsx(NumberField, { ref: field, chrome: "inline", align: align, words: steps, steppers: worn.arrows === "editing" ? "arrows" : false, before: start ?? undefined, after: kind === "percent" ? _jsx("span", { className: "o-number-editor-unit", "data-slot": "vk-number-unit", "data-key": "percent", children: "%" }) : undefined, ...shared, "aria-label": label, autofill: false, onKeyDown: onKeyDown, className: "o-number-editor-field", "data-slot": "vk-number-box" }), pickable && chip && (_jsx(Popover, { open: choosing, onOpenChange: (o) => { if (!o)
|
|
190
190
|
back(); }, anchor: chip, "aria-label": words.name, popupData: popupData, children: _jsx(Picker, { label: words.name, items: items, value: code ?? null, onValueChange: (c) => { if (typeof c === "string")
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ViewsPaneProps } from "../../provider/components.js";
|
|
2
|
+
/** ViewKit's panel host at the list's edge, drawn as the controls' Pane. */
|
|
3
|
+
export declare function MapPane({ open, onOpenChange, container, opener, label, children }: ViewsPaneProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Pane } from "./pane.js";
|
|
3
|
+
export function MapPane({ open, onOpenChange, container, opener, label, children }) {
|
|
4
|
+
return (_jsx(Pane, { open: open, onOpenChange: (next) => onOpenChange(next), container: container, opener: opener, "aria-label": label, children: children }));
|
|
5
|
+
}
|
|
@@ -14,5 +14,5 @@ export declare function fieldsBodyHandlers({ onPick, onDone }: Pick<ViewsFieldsB
|
|
|
14
14
|
onValueChange(v: string | string[] | null): void;
|
|
15
15
|
onDone(): void;
|
|
16
16
|
};
|
|
17
|
-
/** ViewKit's field list,
|
|
18
|
-
export declare function MapFieldsBody(
|
|
17
|
+
/** ViewKit's field list, its controls the app's where the provider's `panelControls` names them (VK-1022). */
|
|
18
|
+
export declare function MapFieldsBody(props: ViewsFieldsBodyProps): import("react/jsx-runtime").JSX.Element;
|