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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Input } from "./input.js";
|
|
3
|
+
import { markOwnControl } from "../../provider/own-control.js";
|
|
3
4
|
export function MapInput({ chrome = "bare", size: _width, inputMode, ref, ...rest }) {
|
|
4
5
|
return _jsx(Input, { ref: ref, chrome: chrome, fills: false, inputMode: inputMode, numeric: inputMode === "decimal" || inputMode === "numeric", autofill: false, ...rest });
|
|
5
6
|
}
|
|
7
|
+
markOwnControl(MapInput);
|
|
@@ -44,5 +44,5 @@ export function useDecide(now, change, onDone, words = { close: "Close", save: "
|
|
|
44
44
|
const place = React.useCallback((el) => { opened.current = el ? opened.current ?? now.current : null; }, [now]);
|
|
45
45
|
const leave = () => { const was = opened.current; if (was && JSON.stringify(was) !== JSON.stringify(now.current))
|
|
46
46
|
change(was); onDone?.(); };
|
|
47
|
-
return { place, head: { left: _jsx(SheetButton, { "aria-label": words.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { kind: "primary", "aria-label": words.save, icon: glyph(TICK), onClick: () => onDone?.() }) } };
|
|
47
|
+
return { place, head: { left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": words.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": words.save, icon: glyph(TICK), onClick: () => onDone?.() }) } };
|
|
48
48
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
3
|
+
/** SheetButton's props, and what ViewKit draws in their place when the Button isn't the app's (SheetButton by default). */
|
|
4
|
+
export type PanelHeadButtonProps = React.ComponentProps<typeof SheetButton> & {
|
|
5
|
+
own?: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/** A panel head's ✕, ‹ or ✓: ViewKit's own (`own`, else SheetButton's glass and plain pair), or, where the context holds the app's
|
|
8
|
+
* Button, that Button alone, quiet (primary for a ✓), an icon when it has no words, the part's name on it. */
|
|
9
|
+
export declare function PanelHeadButton({ own, ...props }: PanelHeadButtonProps): React.ReactElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
5
|
+
import { PanelControlsContext, usePanelControls } from "./panel-controls.js";
|
|
6
|
+
export function PanelHeadButton({ own, ...props }) {
|
|
7
|
+
const app = React.useContext(PanelControlsContext).Button;
|
|
8
|
+
const { Button } = usePanelControls();
|
|
9
|
+
if (!app)
|
|
10
|
+
return _jsx(_Fragment, { children: own ?? _jsx(SheetButton, { ...props }) });
|
|
11
|
+
const { kind, children, ...rest } = props;
|
|
12
|
+
return _jsx(Button, { ...rest, kind: kind ?? "quiet", shape: children == null ? "icon" : undefined, children: children });
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type AppPanelControls } from "./panel-controls.js";
|
|
3
|
+
/** The app's controls for the panels, as the provider names them; none outside a provider or with nothing opted in. */
|
|
4
|
+
export declare function useAppPanelControls(): AppPanelControls;
|
|
5
|
+
/** Its children drawn with the app's controls for the panels. */
|
|
6
|
+
export declare function PanelControlsFromViews({ children }: {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
5
|
+
import { NO_APP_CONTROLS, PanelControlsContext } from "./panel-controls.js";
|
|
6
|
+
export function useAppPanelControls() {
|
|
7
|
+
const views = React.useContext(ViewsContext);
|
|
8
|
+
const components = views?.components, names = views?.panelControls;
|
|
9
|
+
return React.useMemo(() => {
|
|
10
|
+
if (!components || !names?.size)
|
|
11
|
+
return NO_APP_CONTROLS;
|
|
12
|
+
const out = {};
|
|
13
|
+
for (const name of names)
|
|
14
|
+
out[name] = components[name];
|
|
15
|
+
return out;
|
|
16
|
+
}, [components, names]);
|
|
17
|
+
}
|
|
18
|
+
export function PanelControlsFromViews({ children }) {
|
|
19
|
+
return _jsx(PanelControlsContext.Provider, { value: useAppPanelControls(), children: children });
|
|
20
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ViewsButtonProps, ViewsCalendarProps, ViewsInputProps, ViewsMenuItem, ViewsMenuProps, ViewsPopoverProps, ViewsSelectProps } from "../../provider/components.js";
|
|
3
|
+
import { type ButtonProps } from "../button/button.js";
|
|
4
|
+
import { type InputProps } from "../input/input.js";
|
|
5
|
+
import { type MenuProps } from "../menu/menu.js";
|
|
6
|
+
import type { MenuEntry } from "../menu-list/menu-list.js";
|
|
7
|
+
import { type PopoverProps } from "../popover/popover.js";
|
|
8
|
+
import { type SelectListProps, type SelectProps } from "../select/select.js";
|
|
9
|
+
/** The app's own controls the panels draw, by name; a name left out is ViewKit's own. */
|
|
10
|
+
export type AppPanelControls = {
|
|
11
|
+
Button?: React.ComponentType<ViewsButtonProps>;
|
|
12
|
+
Select?: React.ComponentType<ViewsSelectProps>;
|
|
13
|
+
Menu?: React.ComponentType<ViewsMenuProps>;
|
|
14
|
+
Popover?: React.ComponentType<ViewsPopoverProps>;
|
|
15
|
+
Input?: React.ComponentType<ViewsInputProps>;
|
|
16
|
+
/** The date editor's month (VK-1021). */
|
|
17
|
+
Calendar?: React.ComponentType<ViewsCalendarProps>;
|
|
18
|
+
};
|
|
19
|
+
/** No app control: what a panel drawn alone reads. */
|
|
20
|
+
export declare const NO_APP_CONTROLS: AppPanelControls;
|
|
21
|
+
/** What a panel draws its controls with; its default holds none of the app's. Filled only by PanelControlsFromViews. */
|
|
22
|
+
export declare const PanelControlsContext: React.Context<AppPanelControls>;
|
|
23
|
+
type ButtonLike = ButtonProps & {
|
|
24
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
25
|
+
};
|
|
26
|
+
type InputLike = InputProps & {
|
|
27
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
28
|
+
};
|
|
29
|
+
/** The controls a panel or a field editor draws, each taking ViewKit's own props; and the app's Calendar, or none. */
|
|
30
|
+
export type PanelControls = {
|
|
31
|
+
Button: React.ComponentType<ButtonLike>;
|
|
32
|
+
Select: React.ComponentType<SelectProps>;
|
|
33
|
+
Menu: React.ComponentType<MenuProps>;
|
|
34
|
+
Popover: React.ComponentType<PopoverProps>;
|
|
35
|
+
Input: React.ComponentType<InputLike>;
|
|
36
|
+
/** A box group's button (InputGroupButton): ViewKit's, or the app's Button handed it as a quiet one (VK-1021). */
|
|
37
|
+
GroupButton: React.ComponentType<ButtonLike>;
|
|
38
|
+
/** The app's Calendar, or null: the date editor then draws its own month (VK-1021). */
|
|
39
|
+
Calendar: React.ComponentType<ViewsCalendarProps> | null;
|
|
40
|
+
};
|
|
41
|
+
/** The controls a panel draws: the app's where the context holds them, else ViewKit's own, the same components. */
|
|
42
|
+
export declare function usePanelControls(): PanelControls;
|
|
43
|
+
/** ViewKit's Button props as the map's: its kind a variant, its size and form one of the map's three sizes, its icons in its
|
|
44
|
+
* children; one that can't be used but keeps its focus says so and takes no press. ViewKit's own look is never handed. */
|
|
45
|
+
export declare function buttonPropsOf(p: ButtonLike): ViewsButtonProps;
|
|
46
|
+
/** ViewKit's Select props as the map's: its rows, value, pick, name and size, and anything else a ViewKit part hands it (an
|
|
47
|
+
* `aria-describedby`, a handler) on the rest; never its list's width or its own look. */
|
|
48
|
+
export declare function selectPropsOf(p: SelectListProps): ViewsSelectProps;
|
|
49
|
+
/** A menu's rows as the map's: an action, a tick, a pick's choices (under its heading when it has one), a line before the next row.
|
|
50
|
+
* Each row keeps its public name and which one it is. A kind the map has no word for is left out, with a warning. */
|
|
51
|
+
export declare function menuItemsOf(entries: MenuEntry[], label: string): ViewsMenuItem[];
|
|
52
|
+
/** ViewKit's Popover props as the map's: open, where, what closes it, its name, its popup's marks and click (an editor's inner
|
|
53
|
+
* Escape rides those marks, VK-1021); a trigger of its own stays ViewKit's. A `finalFocus` ref is honoured by AppPopover itself. */
|
|
54
|
+
export declare function popoverPropsOf(p: PopoverProps): ViewsPopoverProps;
|
|
55
|
+
/** ViewKit's Input props as the map's: a value typed handed as its change, in the app's field frame, or bare where a ViewKit box
|
|
56
|
+
* frames it (a box group) or the part says so (VK-1021); never ViewKit's own look. */
|
|
57
|
+
export declare function inputPropsOf(p: InputLike, bare?: boolean): ViewsInputProps;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { useAutofill } from "../input/autofill.js";
|
|
6
|
+
import { Input, InputGroupButton, InputGroupContext } from "../input/input.js";
|
|
7
|
+
import { Menu } from "../menu/menu.js";
|
|
8
|
+
import { Popover } from "../popover/popover.js";
|
|
9
|
+
import { Select } from "../select/select.js";
|
|
10
|
+
export const NO_APP_CONTROLS = Object.freeze({});
|
|
11
|
+
export const PanelControlsContext = React.createContext(NO_APP_CONTROLS);
|
|
12
|
+
const OWN = {
|
|
13
|
+
Button: Button, Select, Menu, Popover, Input: Input,
|
|
14
|
+
GroupButton: InputGroupButton, Calendar: null,
|
|
15
|
+
};
|
|
16
|
+
export function usePanelControls() {
|
|
17
|
+
const app = React.useContext(PanelControlsContext);
|
|
18
|
+
return React.useMemo(() => (app === NO_APP_CONTROLS ? OWN : {
|
|
19
|
+
Button: app.Button ? AppButton : OWN.Button,
|
|
20
|
+
Select: app.Select ? AppSelect : Select,
|
|
21
|
+
Menu: app.Menu || app.Button ? OpenedMenu : Menu,
|
|
22
|
+
Popover: app.Popover ? AppPopover : Popover,
|
|
23
|
+
Input: app.Input ? AppInput : OWN.Input,
|
|
24
|
+
GroupButton: app.Button ? AppGroupButton : OWN.GroupButton,
|
|
25
|
+
Calendar: app.Calendar ?? null,
|
|
26
|
+
}), [app]);
|
|
27
|
+
}
|
|
28
|
+
const VARIANT = {
|
|
29
|
+
primary: "default", outline: "outline", soft: "secondary", quiet: "ghost", link: "ghost", text: "ghost", danger: "destructive",
|
|
30
|
+
information: "default", success: "default", warning: "default",
|
|
31
|
+
};
|
|
32
|
+
const SMALL = new Set(["2xs", "xs", "sm", "20", "22", "26", "20x24", "line"]);
|
|
33
|
+
export function buttonPropsOf(p) {
|
|
34
|
+
const { kind, size, shape, look: _look, loading: _loading, render: _render, nativeButton: _native, icon, iconEnd, children, focusableWhenDisabled, disabled, onClick, ...rest } = p;
|
|
35
|
+
const words = children != null && children !== false;
|
|
36
|
+
const inside = icon != null && !words && iconEnd == null ? icon : _jsxs(_Fragment, { children: [icon, children, iconEnd] });
|
|
37
|
+
const held = !!disabled && !!focusableWhenDisabled;
|
|
38
|
+
return {
|
|
39
|
+
...rest,
|
|
40
|
+
type: rest.type ?? "button",
|
|
41
|
+
variant: VARIANT[kind ?? "outline"],
|
|
42
|
+
size: shape === "icon" || shape === "round" ? "icon" : SMALL.has(size ?? "md") ? "sm" : "default",
|
|
43
|
+
children: inside,
|
|
44
|
+
...(held ? { "aria-disabled": true } : { disabled, onClick: onClick }),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function AppButton(p) {
|
|
48
|
+
const Own = React.useContext(PanelControlsContext).Button;
|
|
49
|
+
if (!Own)
|
|
50
|
+
return _jsx(Button, { ...p });
|
|
51
|
+
return _jsx(Own, { ...buttonPropsOf(p) });
|
|
52
|
+
}
|
|
53
|
+
function AppGroupButton(p) {
|
|
54
|
+
return _jsx(AppButton, { kind: "quiet", size: "sm", ...p });
|
|
55
|
+
}
|
|
56
|
+
const selectItemsOf = (items) => items.map(({ value, label, line, group, disabled, mark, level }) => ({
|
|
57
|
+
value, label, ...(mark != null ? { icon: mark } : {}), ...(line != null ? { line } : {}), ...(group != null ? { group } : {}),
|
|
58
|
+
...(disabled ? { disabled } : {}), ...(level ? { level: selectItemsOf(level) } : {}),
|
|
59
|
+
}));
|
|
60
|
+
export function selectPropsOf(p) {
|
|
61
|
+
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;
|
|
62
|
+
const { "data-force": _force, saving: _saving, ...passed } = rest;
|
|
63
|
+
const unsaid = Object.entries({ onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, clear: _clear })
|
|
64
|
+
.filter(([, v]) => v != null && v !== false).map(([k]) => k);
|
|
65
|
+
if (unsaid.length)
|
|
66
|
+
warnUnsaid("Select", unsaid, named(p) ?? "");
|
|
67
|
+
return {
|
|
68
|
+
...passed,
|
|
69
|
+
items: selectItemsOf(items), value: value ?? null, onValueChange: (v) => onValueChange?.(v), size: size === "md" || size === "lg" ? "default" : "sm",
|
|
70
|
+
...(multiple ? { multiple } : {}), ...(placeholder != null ? { placeholder } : {}), ...(disabled ? { disabled } : {}),
|
|
71
|
+
...(open !== undefined ? { open } : {}), ...(onOpenChange ? { onOpenChange } : {}), ...(search != null ? { search } : {}),
|
|
72
|
+
...(className ? { className } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function AppSelect(p) {
|
|
76
|
+
const Own = React.useContext(PanelControlsContext).Select;
|
|
77
|
+
if (!Own || p.opens)
|
|
78
|
+
return _jsx(Select, { ...p });
|
|
79
|
+
return _jsx(Own, { ...selectPropsOf(p) });
|
|
80
|
+
}
|
|
81
|
+
const named = (p) => p["aria-label"] ?? p["data-slot"];
|
|
82
|
+
const warned = new Set();
|
|
83
|
+
function warnUnsaid(control, props, name) {
|
|
84
|
+
const key = `${control}:${props.join(",")}:${name}`;
|
|
85
|
+
if (process.env.NODE_ENV === "production" || warned.has(key))
|
|
86
|
+
return;
|
|
87
|
+
warned.add(key);
|
|
88
|
+
console.warn(`ViewKit: the ${control}${name ? ` "${name}"` : ""} is handed ${props.join(", ")}, which the components map's ${control} has no word for, so your ${control} isn't told.`);
|
|
89
|
+
}
|
|
90
|
+
function warnLeftOut(kind, label) {
|
|
91
|
+
if (process.env.NODE_ENV === "production" || warned.has(`${kind}:${label}`))
|
|
92
|
+
return;
|
|
93
|
+
warned.add(`${kind}:${label}`);
|
|
94
|
+
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.`);
|
|
95
|
+
}
|
|
96
|
+
export function menuItemsOf(entries, label) {
|
|
97
|
+
const out = [];
|
|
98
|
+
let line = false;
|
|
99
|
+
const push = (item) => { out.push(line ? { ...item, separatorBefore: true } : item); line = false; };
|
|
100
|
+
entries.forEach((e, at) => {
|
|
101
|
+
if (e.kind === "separator") {
|
|
102
|
+
line = out.length > 0;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const slot = e.slot?.slot, key = e.slot?.key ?? String(at);
|
|
106
|
+
if (e.kind === undefined || e.kind === "action") {
|
|
107
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), ...(e.onSelect ? { onSelect: e.onSelect } : {}), ...(e.danger ? { destructive: true } : {}),
|
|
108
|
+
...(e.disabled ? { disabled: true, disabledReason: e.disabled } : {}), ...(slot ? { slot } : {}) });
|
|
109
|
+
}
|
|
110
|
+
else if (e.kind === "check") {
|
|
111
|
+
const checked = !!(e.checked ?? e.defaultChecked);
|
|
112
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), checked, keepOpen: true, onSelect: () => e.onCheckedChange?.(!checked),
|
|
113
|
+
...(e.disabled ? { disabled: true, disabledReason: e.disabled } : {}), ...(slot ? { slot } : {}) });
|
|
114
|
+
}
|
|
115
|
+
else if (e.kind === "pick") {
|
|
116
|
+
const rows = e.choices.map((c) => {
|
|
117
|
+
const named = c.slot?.slot ?? slot;
|
|
118
|
+
return { key: c.slot?.key ?? c.value, label: c.label, ...(c.mark != null ? { icon: c.mark } : {}), checked: c.value === e.value,
|
|
119
|
+
onSelect: () => e.onChoose?.(c.value), ...(named ? { slot: named } : {}) };
|
|
120
|
+
});
|
|
121
|
+
if (e.heading)
|
|
122
|
+
push({ key: e.slot?.key ?? e.heading, label: e.heading, children: rows, ...(slot ? { slot } : {}) });
|
|
123
|
+
else
|
|
124
|
+
rows.forEach(push);
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
warnLeftOut(e.kind, label);
|
|
128
|
+
});
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
function fillRef(ref, el) {
|
|
132
|
+
if (typeof ref === "function")
|
|
133
|
+
ref(el);
|
|
134
|
+
else if (ref)
|
|
135
|
+
ref.current = el;
|
|
136
|
+
}
|
|
137
|
+
function OpenedMenu(p) {
|
|
138
|
+
const app = React.useContext(PanelControlsContext);
|
|
139
|
+
const [ownOpen, setOwnOpen] = React.useState(!!p.defaultOpen), open = p.open ?? ownOpen;
|
|
140
|
+
const [at, setAt] = React.useState(null);
|
|
141
|
+
const openNow = React.useRef(open), pressedOpen = React.useRef(null);
|
|
142
|
+
React.useLayoutEffect(() => { openNow.current = open; });
|
|
143
|
+
const set = (next, reason = "trigger-press") => {
|
|
144
|
+
openNow.current = next;
|
|
145
|
+
setOwnOpen(next);
|
|
146
|
+
p.onOpenChange?.(next, { reason });
|
|
147
|
+
if (!next && reason !== "outside-press")
|
|
148
|
+
at?.focus({ preventScroll: true });
|
|
149
|
+
};
|
|
150
|
+
if (!p.trigger || p.anchor !== undefined)
|
|
151
|
+
return app.Menu ? _jsx(AnchoredAppMenu, { ...p }) : _jsx(Menu, { ...p });
|
|
152
|
+
const trigger = p.trigger;
|
|
153
|
+
const own = trigger.props.ref;
|
|
154
|
+
const placed = (el) => { setAt(el); fillRef(own, el); };
|
|
155
|
+
function onPointerDown(e) { pressedOpen.current = openNow.current; trigger.props.onPointerDown?.(e); }
|
|
156
|
+
function onClick(e) { trigger.props.onClick?.(e); const was = pressedOpen.current ?? openNow.current; pressedOpen.current = null; set(!was); }
|
|
157
|
+
const opener = React.cloneElement(trigger, { ref: placed, "aria-haspopup": "menu", "aria-expanded": open, "data-state": open ? "open" : "closed", onPointerDown, onClick });
|
|
158
|
+
const Own = app.Menu;
|
|
159
|
+
return (_jsxs(_Fragment, { children: [opener, Own
|
|
160
|
+
? _jsx(Own, { open: open, onOpenChange: (o, d) => set(o, (d?.reason ?? "none")), anchor: at, items: menuItemsOf(p.entries, p.label), label: p.label, align: p.align, side: p.side, "data-slot": p["data-slot"] })
|
|
161
|
+
: _jsx(Menu, { ...p, trigger: undefined, anchor: at, open: open, finalFocus: false, onOpenChange: (o, d) => set(o, d.reason) })] }));
|
|
162
|
+
}
|
|
163
|
+
function AnchoredAppMenu(p) {
|
|
164
|
+
const Own = React.useContext(PanelControlsContext).Menu;
|
|
165
|
+
const [ownOpen, setOwnOpen] = React.useState(!!p.defaultOpen), open = p.open ?? ownOpen;
|
|
166
|
+
return _jsx(Own, { open: open, onOpenChange: (o, d) => { setOwnOpen(o); p.onOpenChange?.(o, { reason: d?.reason ?? "none" }); }, anchor: (p.anchor ?? null), items: menuItemsOf(p.entries, p.label), label: p.label, align: p.align, side: p.side, "data-slot": p["data-slot"] });
|
|
167
|
+
}
|
|
168
|
+
export function popoverPropsOf(p) {
|
|
169
|
+
const extra = p;
|
|
170
|
+
const unsaid = ["defaultOpen"].filter((k) => extra[k] != null);
|
|
171
|
+
if (typeof p.finalFocus === "boolean")
|
|
172
|
+
unsaid.push("finalFocus");
|
|
173
|
+
if (unsaid.length)
|
|
174
|
+
warnUnsaid("Popover", unsaid, named(p) ?? "");
|
|
175
|
+
const { open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, className, style, children, popupData, onPopupClick } = p;
|
|
176
|
+
const label = p["aria-label"];
|
|
177
|
+
return {
|
|
178
|
+
open: !!open, onOpenChange: (o, d) => onOpenChange?.(o, { reason: (d?.reason ?? "none") }),
|
|
179
|
+
anchor: (anchor ?? null), children,
|
|
180
|
+
...(side ? { side } : {}), ...(align ? { align } : {}), ...(sideOffset != null ? { sideOffset } : {}), ...(alignOffset != null ? { alignOffset } : {}),
|
|
181
|
+
...(initialFocus !== undefined ? { initialFocus: typeof initialFocus === "boolean" ? initialFocus : true } : {}),
|
|
182
|
+
...(onOutsidePress ? { onOutsidePress } : {}), ...(onEscape ? { onEscape } : {}), ...(className ? { className } : {}), ...(style ? { style } : {}),
|
|
183
|
+
...(label != null ? { label } : {}), ...(popupData ? { panelData: popupData } : {}), ...(onPopupClick ? { onPanelClick: onPopupClick } : {}),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function AppPopover(p) {
|
|
187
|
+
const Own = React.useContext(PanelControlsContext).Popover;
|
|
188
|
+
const open = !!p.open, was = React.useRef(open), why = React.useRef(null);
|
|
189
|
+
const back = Own && !p.trigger && p.finalFocus && typeof p.finalFocus !== "boolean" ? p.finalFocus : null;
|
|
190
|
+
React.useLayoutEffect(() => {
|
|
191
|
+
const shut = was.current && !open, reason = why.current;
|
|
192
|
+
was.current = open;
|
|
193
|
+
why.current = null;
|
|
194
|
+
if (!shut || !back || reason === "outside-press" || reason === "focus-out")
|
|
195
|
+
return;
|
|
196
|
+
const give = () => back.current?.focus({ preventScroll: true });
|
|
197
|
+
if (reason) {
|
|
198
|
+
give();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const from = document.activeElement;
|
|
202
|
+
let frame = 0, tries = 0;
|
|
203
|
+
const look = () => {
|
|
204
|
+
const now = document.activeElement;
|
|
205
|
+
if (!now || now === document.body || !now.isConnected) {
|
|
206
|
+
give();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (now !== from || tries++ >= 120)
|
|
210
|
+
return;
|
|
211
|
+
frame = requestAnimationFrame(look);
|
|
212
|
+
};
|
|
213
|
+
look();
|
|
214
|
+
return () => cancelAnimationFrame(frame);
|
|
215
|
+
}, [open, back]);
|
|
216
|
+
if (!Own || p.trigger)
|
|
217
|
+
return _jsx(Popover, { ...p });
|
|
218
|
+
const handed = popoverPropsOf(p);
|
|
219
|
+
const onOutsidePress = (e) => { const kept = p.onOutsidePress?.(e); if (kept !== false)
|
|
220
|
+
why.current = "outside-press"; return kept; };
|
|
221
|
+
return _jsx(Own, { ...handed, onOutsidePress: onOutsidePress, onOpenChange: (o, d) => { why.current = o ? null : d?.reason ?? why.current; handed.onOpenChange(o, d); } });
|
|
222
|
+
}
|
|
223
|
+
export function inputPropsOf(p, bare = false) {
|
|
224
|
+
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;
|
|
225
|
+
return {
|
|
226
|
+
...rest,
|
|
227
|
+
chrome: bare ? "bare" : "field",
|
|
228
|
+
onChange: (e) => {
|
|
229
|
+
onChange?.(e);
|
|
230
|
+
onValueChange?.(e.target.value, { event: e.nativeEvent });
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function AppInput(p) {
|
|
235
|
+
const Own = React.useContext(PanelControlsContext).Input;
|
|
236
|
+
const grouped = React.useContext(InputGroupContext) != null, fill = useAutofill();
|
|
237
|
+
if (!Own || p.multiline || p.combobox)
|
|
238
|
+
return _jsx(Input, { ...p });
|
|
239
|
+
return _jsx(Own, { ...fill(p.autofill !== false), ...inputPropsOf(p, p.chrome === "bare" || grouped) });
|
|
240
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A part's public name, and which one of its kind it is. */
|
|
2
|
+
export type PartSlot = {
|
|
3
|
+
slot: string;
|
|
4
|
+
key?: string;
|
|
5
|
+
index?: number;
|
|
6
|
+
};
|
|
7
|
+
/** The attributes a part's name draws: nothing for what isn't handed. */
|
|
8
|
+
export declare const partAttrs: (p?: PartSlot) => {
|
|
9
|
+
"data-slot"?: string;
|
|
10
|
+
"data-key"?: string;
|
|
11
|
+
"data-index"?: string;
|
|
12
|
+
};
|
|
@@ -70,7 +70,7 @@ export interface LinksEditorAction {
|
|
|
70
70
|
export interface LinksEditorParts {
|
|
71
71
|
body: React.ReactNode;
|
|
72
72
|
/** On a phone, the Sheet head's ✕ and ✓, or on a step its Back (`onBack`, `close: false`); {} on a computer. */
|
|
73
|
-
head: Pick<SheetHeadProps, "close" | "left" | "right" | "onBack">;
|
|
73
|
+
head: Pick<SheetHeadProps, "close" | "left" | "right" | "onBack" | "backSlot">;
|
|
74
74
|
/** On a phone, the Sheet's title while it stands on a step: a link's field, or a link's fields by the record's name. */
|
|
75
75
|
title?: string;
|
|
76
76
|
}
|
|
@@ -79,8 +79,8 @@ export function useLinksEditor(props) {
|
|
|
79
79
|
asked.current?.(); was = now; });
|
|
80
80
|
seenRef.current.observe(el);
|
|
81
81
|
}, []);
|
|
82
|
-
const more = onMore && !doing ? _jsxs("div", { ref: moreRef, className: "o-links-editor-loading", children: [_jsx(Spinner, { size: 16, label: "" }), _jsx("span", { children: w.loadingMore })] }) : null;
|
|
83
|
-
const doingNote = doing === "searching" ? w.searching : doing === "failed" ? _jsxs(_Fragment, { children: [w.failed, onRetry && _jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-retry", onClick: onRetry, children: w.retry })] }) : null;
|
|
82
|
+
const more = onMore && !doing ? _jsxs("div", { ref: moreRef, className: "o-links-editor-loading", "data-slot": "vk-links-note", children: [_jsx(Spinner, { size: 16, label: "" }), _jsx("span", { children: w.loadingMore })] }) : null;
|
|
83
|
+
const doingNote = doing === "searching" ? w.searching : doing === "failed" ? _jsxs(_Fragment, { children: [w.failed, onRetry && _jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-retry", "data-slot": "vk-links-retry", onClick: onRetry, children: w.retry })] }) : null;
|
|
84
84
|
const byValue = (value) => records.find((r) => r.value === value) ?? { value, label: links.find((l) => l.value === value)?.label ?? value };
|
|
85
85
|
const [root, setRoot] = React.useState(null);
|
|
86
86
|
const searchBox = React.useRef(null), list = React.useRef(null);
|
|
@@ -223,27 +223,27 @@ export function useLinksEditor(props) {
|
|
|
223
223
|
.filter(Boolean).join(" · ");
|
|
224
224
|
const rowWords = (f, v) => { const s = said(f, v, w.yes); return f.kind === "yes-no" ? (v === true ? w.yes : w.no) : s === "–" ? w.none : s; };
|
|
225
225
|
const openList = (value, field) => setTop({ link: value, field });
|
|
226
|
-
const fieldRow = (l, name, f) => (f.kind === "yes-no" ? (_jsxs(FieldRow, { className: "o-links-editor-open", "data-field": f.id, children: [_jsx("span", { className: "o-links-editor-open-name", children: f.label }), _jsx(Switch, { size: "lg", className: "o-links-editor-switch", checked: l.values[f.id] === true, "aria-label": w.fieldAt(f.label, name), onCheckedChange: (c) => setField(l.value, f.id, c) })] }, f.id)) : (_jsxs(FieldRow, { as: "button", className: "o-links-editor-open", "data-field": f.id, "aria-label": w.fieldAt(f.label, name), onClick: () => openList(l.value, f.id), children: [_jsx("span", { className: "o-links-editor-open-name", children: f.label }), _jsx("span", { className: "o-links-editor-open-value", children: rowWords(f, l.values[f.id]) }), glyph(MORE, "o-links-editor-open-mark")] }, f.id)));
|
|
226
|
+
const fieldRow = (l, name, f) => (f.kind === "yes-no" ? (_jsxs(FieldRow, { className: "o-links-editor-open", "data-slot": "vk-links-field", "data-key": f.id, "data-field": f.id, children: [_jsx("span", { className: "o-links-editor-open-name", children: f.label }), _jsx(Switch, { size: "lg", className: "o-links-editor-switch", "data-slot": "vk-links-control", "data-key": f.id, checked: l.values[f.id] === true, "aria-label": w.fieldAt(f.label, name), onCheckedChange: (c) => setField(l.value, f.id, c) })] }, f.id)) : (_jsxs(FieldRow, { as: "button", className: "o-links-editor-open", "data-slot": "vk-links-field", "data-key": f.id, "data-field": f.id, "aria-label": w.fieldAt(f.label, name), onClick: () => openList(l.value, f.id), children: [_jsx("span", { className: "o-links-editor-open-name", children: f.label }), _jsx("span", { className: "o-links-editor-open-value", children: rowWords(f, l.values[f.id]) }), glyph(MORE, "o-links-editor-open-mark")] }, f.id)));
|
|
227
227
|
const card = (r) => {
|
|
228
228
|
const l = links.find((x) => x.value === r.value), name = r.label, leads = lead != null && lead.value === r.value;
|
|
229
229
|
const said_ = holds(l);
|
|
230
|
-
return (_jsxs(FieldRows, { look: CARD, className: "o-links-editor-card", "data-link": r.value, role: "listitem", "aria-label": name, children: [_jsxs(FieldRow, { as: "div", className: "o-links-editor-card-head", children: [_jsx(Face, { record: r, size: 24 }), _jsxs("span", { className: "o-links-editor-card-name", children: [_jsx("span", { children: name }), leads && _jsx("span", { className: "o-links-editor-lead-word", children: lead.label })] }), !several
|
|
231
|
-
? _jsx(Menu, { label: w.linkMenu(name), align: "end", entries: [...(lead && !leads ? [{ icon: _jsx(Icon, { name: "star" }), label: w.setLead(lead.label), onSelect: () => setLead(r.value) }] : []), { icon: glyph(UNLINK), label: w.unlink, danger: true, onSelect: () => unlink(r.value) }], trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-links-editor-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS) }) })
|
|
232
|
-
: _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-links-editor-config", "aria-label": w.editLink(name), "aria-haspopup": "dialog", icon: _jsx(Icon, { name: "settings", size: 20 }), onClick: () => setFieldsOf(r.value) })] }), !several ? one && fieldRow(l, name, one) : _jsx("div", { className: "o-links-editor-card-line", "data-none": said_ ? undefined : "", children: said_ || w.noDetails })] }, r.value));
|
|
230
|
+
return (_jsxs(FieldRows, { look: CARD, className: "o-links-editor-card", "data-slot": "vk-links-row", "data-key": r.value, "data-link": r.value, role: "listitem", "aria-label": name, children: [_jsxs(FieldRow, { as: "div", className: "o-links-editor-card-head", children: [_jsx(Face, { record: r, size: 24 }), _jsxs("span", { className: "o-links-editor-card-name", "data-slot": "vk-links-name", children: [_jsx("span", { children: name }), leads && _jsx("span", { className: "o-links-editor-lead-word", children: lead.label })] }), !several
|
|
231
|
+
? _jsx(Menu, { label: w.linkMenu(name), align: "end", entries: [...(lead && !leads ? [{ icon: _jsx(Icon, { name: "star" }), label: w.setLead(lead.label), onSelect: () => setLead(r.value), slot: { slot: "vk-links-action", key: "lead" } }] : []), { icon: glyph(UNLINK), label: w.unlink, danger: true, onSelect: () => unlink(r.value), slot: { slot: "vk-links-action", key: "unlink" } }], trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-links-editor-more", "data-slot": "vk-links-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS) }) })
|
|
232
|
+
: _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-links-editor-config", "data-slot": "vk-links-config", "aria-label": w.editLink(name), "aria-haspopup": "dialog", icon: _jsx(Icon, { name: "settings", size: 20 }), onClick: () => setFieldsOf(r.value) })] }), !several ? one && fieldRow(l, name, one) : _jsx("div", { className: "o-links-editor-card-line", "data-none": said_ ? undefined : "", children: said_ || w.noDetails })] }, r.value));
|
|
233
233
|
};
|
|
234
234
|
const topLink = top ? links.find((l) => l.value === top.link) : undefined, topField = top ? fields.find((f) => f.id === top.field) : undefined;
|
|
235
235
|
const fieldsLink = fieldsOf ? links.find((l) => l.value === fieldsOf) : undefined;
|
|
236
236
|
const fieldsName = fieldsOf ? byValue(fieldsOf).label : "";
|
|
237
237
|
const listStep = top && topLink && topField ? top : null;
|
|
238
238
|
const fieldsStep = several ? fieldsLink ?? null : null;
|
|
239
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-links-editor", "data-kit": "links-editor", ...mark, "data-links-form": "phone", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", tabIndex: -1, "data-links-step": listStep ? "list" : fieldsStep ? "fields" : undefined, style: sheetRoom ? { "--links-room": `${sheetRoom.height}px`, "--links-under": `${sheetRoom.under}px` } : undefined, children: listStep && topLink && topField ? (_jsx(StepList, { ...listOf(topLink, topField), draft: "shell", form: "phone", onDone: () => setTop(null) }, `${listStep.link}-${listStep.field}`)) : fieldsStep ? _jsxs(_Fragment, { children: [_jsxs(FieldRows, { look: FIELDS, className: "o-links-editor-fields", "data-link": fieldsStep.value, children: [fields.map((f) => f.kind === "yes-no"
|
|
240
|
-
? _jsx(FieldRow, { label: f.label, "data-field": f.id, children: _jsx(Switch, { size: "lg", className: "o-links-editor-switch", checked: fieldsStep.values[f.id] === true, "aria-label": w.fieldAt(f.label, fieldsName), onCheckedChange: (c) => setField(fieldsStep.value, f.id, c) }) }, f.id)
|
|
241
|
-
: _jsxs(FieldRow, { as: "button", label: f.label, className: "o-links-editor-open", "data-field": f.id, "aria-label": w.fieldAt(f.label, fieldsName), onClick: () => openList(fieldsStep.value, f.id), children: [_jsx("span", { className: "o-links-editor-open-value", children: rowWords(f, fieldsStep.values[f.id]) }), glyph(MORE, "o-links-editor-open-mark")] }, f.id)), lead && _jsx(FieldRow, { label: lead.label, "data-field": "lead", children: _jsx(Switch, { size: "lg", className: "o-links-editor-switch", checked: lead.value === fieldsStep.value, "aria-label": w.isLead(fieldsName, lead.label), onCheckedChange: (c) => { if (c)
|
|
242
|
-
setLead(fieldsStep.value); } }) })] }), _jsx(FieldRows, { look: FIELDS, className: "o-links-editor-fields-foot", children: _jsx(FieldRow, { as: "button", className: "o-links-editor-unlink", onClick: () => { const v = fieldsStep.value; setFieldsOf(null); unlink(v); }, children: w.unlink }) })] }) : _jsxs(_Fragment, { children: [linked.length > 0 && _jsx("div", { className: "o-links-editor-cards", role: "list", "aria-label": label, children: linked.map(card) }), (rest.length > 0 || actions.length > 0) && _jsxs(_Fragment, { children: [_jsx("div", { className: "o-links-editor-label", children: addWords }), _jsxs(FieldRows, { look: ADDS, className: "o-links-editor-adds", role: "list", "aria-label": addWords, children: [rest.map((r) => (_jsxs(FieldRow, { as: "button", className: "o-links-editor-add", "data-record": r.value, role: "listitem", "aria-label": w.linkName(r.label), onClick: () => link(r.value), children: [_jsx(Face, { record: r, size: 40 }), _jsx("span", { className: "o-links-editor-add-name", children: r.label }), glyph(PLUS, "o-links-editor-add-mark")] }, r.value))), actions.map((a) => (_jsxs(FieldRow, { as: "button", className: "o-links-editor-add o-links-editor-action", role: "listitem", onClick: a.onSelect, children: [a.icon != null && _jsx("span", { className: "o-links-editor-action-mark", children: a.icon }), _jsx("span", { className: "o-links-editor-add-name", children: a.label })] }, a.key)))] }), more] }), doingNote ? _jsx("div", { className: "o-links-editor-note", children: doingNote }) : _jsxs(_Fragment, { children: [!rest.length && query.trim() && !linked.length && _jsx("div", { className: "o-links-editor-note", children: w.nothingMatchesTyped(query.trim()) }), !rest.length && !query.trim() && linked.length > 0 && _jsx("div", { className: "o-links-editor-note", children: w.everythingLinked })] }), _jsx("div", { className: "o-links-editor-bar", children: _jsxs(InputGroup, { size: "lg", className: "o-links-editor-pill", children: [_jsx(InputGroupAddon, { side: "start", children: glyph(SEARCH) }), _jsx(Input, { autofill: false, ref: searchBox, className: "o-links-editor-input", placeholder: search, "aria-label": search, value: query, onValueChange: (v) => typeQuery(v) })] }) })] }) }));
|
|
239
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-links-editor", "data-slot": "vk-links", "data-kit": "links-editor", ...mark, "data-links-form": "phone", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", tabIndex: -1, "data-links-step": listStep ? "list" : fieldsStep ? "fields" : undefined, style: sheetRoom ? { "--links-room": `${sheetRoom.height}px`, "--links-under": `${sheetRoom.under}px` } : undefined, children: listStep && topLink && topField ? (_jsx(StepList, { ...listOf(topLink, topField), draft: "shell", form: "phone", onDone: () => setTop(null) }, `${listStep.link}-${listStep.field}`)) : fieldsStep ? _jsxs(_Fragment, { children: [_jsxs(FieldRows, { look: FIELDS, className: "o-links-editor-fields", "data-link": fieldsStep.value, children: [fields.map((f) => f.kind === "yes-no"
|
|
240
|
+
? _jsx(FieldRow, { label: f.label, "data-slot": "vk-links-field", "data-key": f.id, "data-field": f.id, children: _jsx(Switch, { size: "lg", className: "o-links-editor-switch", "data-slot": "vk-links-control", "data-key": f.id, checked: fieldsStep.values[f.id] === true, "aria-label": w.fieldAt(f.label, fieldsName), onCheckedChange: (c) => setField(fieldsStep.value, f.id, c) }) }, f.id)
|
|
241
|
+
: _jsxs(FieldRow, { as: "button", label: f.label, className: "o-links-editor-open", "data-slot": "vk-links-field", "data-key": f.id, "data-field": f.id, "aria-label": w.fieldAt(f.label, fieldsName), onClick: () => openList(fieldsStep.value, f.id), children: [_jsx("span", { className: "o-links-editor-open-value", children: rowWords(f, fieldsStep.values[f.id]) }), glyph(MORE, "o-links-editor-open-mark")] }, f.id)), lead && _jsx(FieldRow, { label: lead.label, "data-slot": "vk-links-lead", "data-field": "lead", children: _jsx(Switch, { size: "lg", className: "o-links-editor-switch", "data-slot": "vk-links-control", "data-key": "lead", checked: lead.value === fieldsStep.value, "aria-label": w.isLead(fieldsName, lead.label), onCheckedChange: (c) => { if (c)
|
|
242
|
+
setLead(fieldsStep.value); } }) })] }), _jsx(FieldRows, { look: FIELDS, className: "o-links-editor-fields-foot", children: _jsx(FieldRow, { as: "button", className: "o-links-editor-unlink", "data-slot": "vk-links-unlink", onClick: () => { const v = fieldsStep.value; setFieldsOf(null); unlink(v); }, children: w.unlink }) })] }) : _jsxs(_Fragment, { children: [linked.length > 0 && _jsx("div", { className: "o-links-editor-cards", "data-slot": "vk-links-rows", role: "list", "aria-label": label, children: linked.map(card) }), (rest.length > 0 || actions.length > 0) && _jsxs(_Fragment, { children: [_jsx("div", { className: "o-links-editor-label", children: addWords }), _jsxs(FieldRows, { look: ADDS, className: "o-links-editor-adds", "data-slot": "vk-links-offers", role: "list", "aria-label": addWords, children: [rest.map((r) => (_jsxs(FieldRow, { as: "button", className: "o-links-editor-add", "data-slot": "vk-links-offer", "data-key": r.value, "data-record": r.value, role: "listitem", "aria-label": w.linkName(r.label), onClick: () => link(r.value), children: [_jsx(Face, { record: r, size: 40 }), _jsx("span", { className: "o-links-editor-add-name", children: r.label }), glyph(PLUS, "o-links-editor-add-mark")] }, r.value))), actions.map((a) => (_jsxs(FieldRow, { as: "button", className: "o-links-editor-add o-links-editor-action", "data-slot": "vk-links-offer-action", "data-key": a.key, role: "listitem", onClick: a.onSelect, children: [a.icon != null && _jsx("span", { className: "o-links-editor-action-mark", children: a.icon }), _jsx("span", { className: "o-links-editor-add-name", children: a.label })] }, a.key)))] }), more] }), doingNote ? _jsx("div", { className: "o-links-editor-note", "data-slot": "vk-links-note", children: doingNote }) : _jsxs(_Fragment, { children: [!rest.length && query.trim() && !linked.length && _jsx("div", { className: "o-links-editor-note", "data-slot": "vk-links-note", children: w.nothingMatchesTyped(query.trim()) }), !rest.length && !query.trim() && linked.length > 0 && _jsx("div", { className: "o-links-editor-note", "data-slot": "vk-links-note", children: w.everythingLinked })] }), _jsx("div", { className: "o-links-editor-bar", children: _jsxs(InputGroup, { size: "lg", className: "o-links-editor-pill", "data-slot": "vk-links-search", children: [_jsx(InputGroupAddon, { side: "start", children: glyph(SEARCH) }), _jsx(Input, { autofill: false, ref: searchBox, className: "o-links-editor-input", placeholder: search, "aria-label": search, value: query, onValueChange: (v) => typeQuery(v) })] }) })] }) }));
|
|
243
243
|
if (listStep && topField)
|
|
244
|
-
return { body, head: { onBack: () => setTop(null), close: false }, title: topField.label };
|
|
244
|
+
return { body, head: { onBack: () => setTop(null), backSlot: "vk-editor-back", close: false }, title: topField.label };
|
|
245
245
|
if (fieldsStep)
|
|
246
|
-
return { body, head: { onBack: () => setFieldsOf(null), close: false }, title: fieldsName };
|
|
246
|
+
return { body, head: { onBack: () => setFieldsOf(null), backSlot: "vk-editor-back", close: false }, title: fieldsName };
|
|
247
247
|
return { body, head: decide.head };
|
|
248
248
|
}
|
|
249
249
|
const stepLink = step ? links.find((l) => l.value === step) : undefined;
|
|
@@ -253,18 +253,18 @@ export function useLinksEditor(props) {
|
|
|
253
253
|
const control = (f) => {
|
|
254
254
|
const v = stepLink.values[f.id], words = w.fieldAt(f.label, name);
|
|
255
255
|
if (f.kind === "yes-no")
|
|
256
|
-
return _jsx(Switch, { size: "md", checked: v === true, "aria-label": words, onCheckedChange: (c) => setField(step, f.id, c) });
|
|
256
|
+
return _jsx(Switch, { size: "md", "data-slot": "vk-links-control", "data-key": f.id, checked: v === true, "aria-label": words, onCheckedChange: (c) => setField(step, f.id, c) });
|
|
257
257
|
if (f.kind === "several")
|
|
258
|
-
return _jsx(Select, { size: "sm", multiple: true, listWidth: "rows", items: offered(f, v), value: heldOf(v), placeholder: w.none, "aria-label": words, onValueChange: (next) => tickFrom(step, f, Array.isArray(next) ? next : []) });
|
|
259
|
-
return _jsx(Select, { size: "sm", listWidth: "rows", items: offered(f, v), value: typeof v === "string" ? v : null, placeholder: w.none, "aria-label": words, onValueChange: (next) => setField(step, f.id, typeof next === "string" ? next : null) });
|
|
258
|
+
return _jsx(Select, { size: "sm", "data-slot": "vk-links-control", "data-key": f.id, multiple: true, listWidth: "rows", items: offered(f, v), value: heldOf(v), placeholder: w.none, "aria-label": words, onValueChange: (next) => tickFrom(step, f, Array.isArray(next) ? next : []) });
|
|
259
|
+
return _jsx(Select, { size: "sm", "data-slot": "vk-links-control", "data-key": f.id, listWidth: "rows", items: offered(f, v), value: typeof v === "string" ? v : null, placeholder: w.none, "aria-label": words, onValueChange: (next) => setField(step, f.id, typeof next === "string" ? next : null) });
|
|
260
260
|
};
|
|
261
|
-
const body = (_jsxs("div", { ref: setRoot, className: "o-links-editor", "data-kit": "links-editor", ...mark, "data-links-form": "computer", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", "data-links-step": "", role: "group", "aria-label": name, tabIndex: -1, onKeyDown: (e) => {
|
|
261
|
+
const body = (_jsxs("div", { ref: setRoot, className: "o-links-editor", "data-slot": "vk-links", "data-kit": "links-editor", ...mark, "data-links-form": "computer", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", "data-links-step": "", role: "group", "aria-label": name, tabIndex: -1, onKeyDown: (e) => {
|
|
262
262
|
if (e.key !== "Escape" || e.target.closest?.("[aria-expanded='true']"))
|
|
263
263
|
return;
|
|
264
264
|
e.preventDefault();
|
|
265
265
|
e.stopPropagation();
|
|
266
266
|
leave();
|
|
267
|
-
}, children: [_jsxs("div", { className: "o-links-editor-step-head o-popup-line", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", className: "o-links-editor-back", "aria-label": w.backTo(label), icon: glyph(BACK), onClick: leave }), _jsx(Face, { record: record, size: 20 }), _jsx("span", { className: "o-links-editor-step-name", children: name })] }), _jsx("div", { className: "o-links-editor-fields", "data-link": step, children: fields.map((f) => (_jsxs("div", { className: "o-links-editor-field", "data-field": f.id, children: [_jsx("span", { className: "o-links-editor-field-label", children: f.label }), _jsx("span", { className: "o-links-editor-field-control", "data-kind": f.kind, children: control(f) })] }, f.id))) }), _jsx("div", { className: "o-links-editor-step-foot", children: _jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-unlink", onClick: () => unlink(step), children: w.unlink }) })] }));
|
|
267
|
+
}, children: [_jsxs("div", { className: "o-links-editor-step-head o-popup-line", "data-slot": "vk-links-step", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", className: "o-links-editor-back", "data-slot": "vk-links-back", "aria-label": w.backTo(label), icon: glyph(BACK), onClick: leave }), _jsx(Face, { record: record, size: 20 }), _jsx("span", { className: "o-links-editor-step-name", children: name })] }), _jsx("div", { className: "o-links-editor-fields", "data-link": step, children: fields.map((f) => (_jsxs("div", { className: "o-links-editor-field", "data-slot": "vk-links-field", "data-key": f.id, "data-field": f.id, children: [_jsx("span", { className: "o-links-editor-field-label", children: f.label }), _jsx("span", { className: "o-links-editor-field-control", "data-kind": f.kind, children: control(f) })] }, f.id))) }), _jsx("div", { className: "o-links-editor-step-foot", children: _jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-unlink", "data-slot": "vk-links-unlink", onClick: () => unlink(step), children: w.unlink }) })] }));
|
|
268
268
|
return { body, head: {} };
|
|
269
269
|
}
|
|
270
270
|
const keepArrows = (e) => { if (e.key.startsWith("Arrow"))
|
|
@@ -294,17 +294,17 @@ export function useLinksEditor(props) {
|
|
|
294
294
|
};
|
|
295
295
|
const short = (l, name, f) => {
|
|
296
296
|
const words = saidShort(f, l.values[f.id], w.yes), standing = shownList?.link === l.value && shownList.field === f.id;
|
|
297
|
-
const button = (_jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-short", "data-field": f.id, "data-none": words ? undefined : "", "aria-label": w.fieldAt(f.label, name), iconEnd: _jsx(Icon, { name: "down" }), "data-popup-open": standing ? "" : undefined, children: words || f.label }));
|
|
297
|
+
const button = (_jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-short", "data-slot": "vk-links-value", "data-key": f.id, "data-field": f.id, "data-none": words ? undefined : "", "aria-label": w.fieldAt(f.label, name), iconEnd: _jsx(Icon, { name: "down" }), "data-popup-open": standing ? "" : undefined, children: words || f.label }));
|
|
298
298
|
if (standing)
|
|
299
299
|
return button;
|
|
300
|
-
return (_jsx(Popover, { trigger: button, open: open?.link === l.value && open.field === f.id, onOpenChange: (o) => setOpen(o ? { link: l.value, field: f.id } : null), side: "bottom", align: "start", className: "o-links-editor-pop", "aria-label": w.fieldAt(f.label, name), ...
|
|
300
|
+
return (_jsx(Popover, { trigger: button, open: open?.link === l.value && open.field === f.id, onOpenChange: (o) => setOpen(o ? { link: l.value, field: f.id } : null), side: "bottom", align: "start", className: "o-links-editor-pop", "aria-label": w.fieldAt(f.label, name), popupData: { ...props.popupData, "data-slot": "vk-links-pop", "data-key": f.id }, children: _jsx(Picker, { ...listOf(l, f), form: "computer", onDone: () => setOpen(null) }) }));
|
|
301
301
|
};
|
|
302
|
-
const cell = (l, name, f) => (_jsx("span", { className: "o-links-editor-cell", "data-field": f.id, "data-kind": f.kind, onKeyDown: keepArrows, children: one && f.kind === "yes-no" ? _jsx(Switch, { size: "sm", checked: l.values[f.id] === true, "aria-label": w.fieldAt(f.label, name), onCheckedChange: (c) => setField(l.value, f.id, c) })
|
|
302
|
+
const cell = (l, name, f) => (_jsx("span", { className: "o-links-editor-cell", "data-slot": "vk-links-field", "data-key": f.id, "data-field": f.id, "data-kind": f.kind, onKeyDown: keepArrows, children: one && f.kind === "yes-no" ? _jsx(Switch, { size: "sm", "data-slot": "vk-links-control", "data-key": f.id, checked: l.values[f.id] === true, "aria-label": w.fieldAt(f.label, name), onCheckedChange: (c) => setField(l.value, f.id, c) })
|
|
303
303
|
: one ? short(l, name, f) : said(f, l.values[f.id], w.yes) }, f.id));
|
|
304
304
|
const row = (r) => {
|
|
305
305
|
const l = links.find((x) => x.value === r.value), name = r.label;
|
|
306
|
-
return (_jsxs("div", { className: "o-links-editor-row", "data-link": r.value, role: "group", "aria-label": name, children: [_jsxs("span", { className: "o-links-editor-who", children: [_jsx(Face, { record: r, size: 20 }), _jsx("span", { className: "o-links-editor-name", children: name })] }), fields.map((f) => cell(l, name, f)), lead && _jsx("span", { className: "o-links-editor-lead", children: _jsx(Radio, { value: r.value, "aria-label": w.isLead(name, lead.label) }) }), _jsx("span", { className: "o-links-editor-end", onKeyDown: keepArrows, children: !several ? _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: END_LOOK, "aria-label": w.unlinkName(name), icon: glyph(X), onClick: () => unlink(r.value) })
|
|
307
|
-
: _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: END_LOOK, className: "o-links-editor-config", "aria-label": w.editLink(name), icon: _jsx(Icon, { name: "settings" }), onClick: () => { setOpen(null); stepPressed.current = true; setStep(r.value); } }) })] }, r.value));
|
|
306
|
+
return (_jsxs("div", { className: "o-links-editor-row", "data-slot": "vk-links-row", "data-key": r.value, "data-link": r.value, role: "group", "aria-label": name, children: [_jsxs("span", { className: "o-links-editor-who", "data-slot": "vk-links-name", children: [_jsx(Face, { record: r, size: 20 }), _jsx("span", { className: "o-links-editor-name", children: name })] }), fields.map((f) => cell(l, name, f)), lead && _jsx("span", { className: "o-links-editor-lead", "data-slot": "vk-links-lead", children: _jsx(Radio, { value: r.value, "data-slot": "vk-links-control", "data-key": "lead", "aria-label": w.isLead(name, lead.label) }) }), _jsx("span", { className: "o-links-editor-end", onKeyDown: keepArrows, children: !several ? _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: END_LOOK, "aria-label": w.unlinkName(name), icon: glyph(X), "data-slot": "vk-links-remove", onClick: () => unlink(r.value) })
|
|
307
|
+
: _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: END_LOOK, className: "o-links-editor-config", "data-slot": "vk-links-config", "aria-label": w.editLink(name), icon: _jsx(Icon, { name: "settings" }), onClick: () => { setOpen(null); stepPressed.current = true; setStep(r.value); } }) })] }, r.value));
|
|
308
308
|
};
|
|
309
309
|
const rows = linked.map(row);
|
|
310
310
|
const message = doingNote ?? (!lights && (query.trim() ? (!linked.length ? w.nothingMatches : null) : linked.length ? w.everythingLinked : null));
|
|
@@ -314,14 +314,14 @@ export function useLinksEditor(props) {
|
|
|
314
314
|
return null;
|
|
315
315
|
return (_jsx("div", { className: "o-links-editor-shown o-list o-smooth o-smooth-ease", "data-links-shown": "list", ...phoneMark(small), style: shownAt ? { top: shownAt.top, left: shownAt.left } : { visibility: "hidden" }, children: _jsx(Picker, { ...listOf(l, f), form: "computer", standing: true }) }));
|
|
316
316
|
})() : null;
|
|
317
|
-
const body = (_jsxs("div", { ref: setRoot, className: "o-links-editor", "data-kit": "links-editor", ...mark, "data-links-form": "computer", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", role: "group", "aria-label": label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, children: [_jsxs("div", { className: "o-links-editor-search o-popup-line", children: [glyph(SEARCH), _jsx(Input, { chrome: "bare", autofill: false, ref: searchBox, className: "o-links-editor-input", placeholder: search, "aria-label": search, role: "combobox", "aria-expanded": lights > 0, "aria-autocomplete": "list", "aria-controls": lights ? `${ids}-add` : undefined, "aria-activedescendant": litAt != null ? `${ids}-add-${litAt}` : undefined, value: query, onValueChange: (v) => { typeQuery(v); setLit(v.trim() ? 0 : null); }, onKeyDown: keys })] }), _jsxs("div", { ref: placeList, className: "o-links-editor-list", "data-head": linked.length ? "" : undefined, "data-held": open ? "" : undefined, children: [linked.length > 0 && _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-links-editor-head", "aria-hidden": "true", children: [_jsx("span", { className: "o-links-editor-who", children: kind }), fields.map((f) => _jsx("span", { className: "o-links-editor-cell", "data-field": f.id, "data-kind": f.kind, children: f.label }, f.id)), lead && _jsx("span", { className: "o-links-editor-lead", children: lead.label }), _jsx("span", { className: "o-links-editor-end" })] }), lead
|
|
318
|
-
? _jsx(RadioGroup, { className: "o-links-editor-rows", "aria-label": lead.label, value: lead.value, onValueChange: (v) => setLead(v), children: rows })
|
|
319
|
-
: _jsx("div", { className: "o-links-editor-rows", children: rows })] }), linked.length > 0 && lights > 0 && _jsx("div", { className: "o-list-sep", role: "presentation" }), lights > 0 && _jsxs("div", { id: `${ids}-add`, role: "listbox", "aria-label": w.addTo(label), className: "o-links-editor-adds", onPointerLeave: () => setLit(query.trim() ? 0 : null), children: [linked.length > 0 && _jsx("div", { className: "o-list-heading", "aria-hidden": "true", children: w.add }), rest.map((r, i) => (_jsxs("div", { id: `${ids}-add-${i}`, role: "option", "aria-selected": i === litAt, className: "o-list-row o-smooth o-smooth-ease o-links-editor-add", "data-record": r.value, ...phoneMark(small), "data-highlighted": i === litAt ? "" : undefined, onPointerMove: () => { if (!open && doing !== "searching" && i !== litAt)
|
|
317
|
+
const body = (_jsxs("div", { ref: setRoot, className: "o-links-editor", "data-slot": "vk-links", "data-kit": "links-editor", ...mark, "data-links-form": "computer", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", role: "group", "aria-label": label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, children: [_jsxs("div", { className: "o-links-editor-search o-popup-line", "data-slot": "vk-links-search", children: [glyph(SEARCH), _jsx(Input, { chrome: "bare", autofill: false, ref: searchBox, className: "o-links-editor-input", placeholder: search, "aria-label": search, role: "combobox", "aria-expanded": lights > 0, "aria-autocomplete": "list", "aria-controls": lights ? `${ids}-add` : undefined, "aria-activedescendant": litAt != null ? `${ids}-add-${litAt}` : undefined, value: query, onValueChange: (v) => { typeQuery(v); setLit(v.trim() ? 0 : null); }, onKeyDown: keys })] }), _jsxs("div", { ref: placeList, className: "o-links-editor-list", "data-slot": "vk-links-list", "data-head": linked.length ? "" : undefined, "data-held": open ? "" : undefined, children: [linked.length > 0 && _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-links-editor-head", "data-slot": "vk-links-head", "aria-hidden": "true", children: [_jsx("span", { className: "o-links-editor-who", "data-slot": "vk-links-name", children: kind }), fields.map((f) => _jsx("span", { className: "o-links-editor-cell", "data-slot": "vk-links-field", "data-key": f.id, "data-field": f.id, "data-kind": f.kind, children: f.label }, f.id)), lead && _jsx("span", { className: "o-links-editor-lead", "data-slot": "vk-links-lead", children: lead.label }), _jsx("span", { className: "o-links-editor-end" })] }), lead
|
|
318
|
+
? _jsx(RadioGroup, { className: "o-links-editor-rows", "data-slot": "vk-links-rows", "aria-label": lead.label, value: lead.value, onValueChange: (v) => setLead(v), children: rows })
|
|
319
|
+
: _jsx("div", { className: "o-links-editor-rows", "data-slot": "vk-links-rows", children: rows })] }), linked.length > 0 && lights > 0 && _jsx("div", { className: "o-list-sep", role: "presentation" }), lights > 0 && _jsxs("div", { id: `${ids}-add`, role: "listbox", "aria-label": w.addTo(label), className: "o-links-editor-adds", "data-slot": "vk-links-offers", onPointerLeave: () => setLit(query.trim() ? 0 : null), children: [linked.length > 0 && _jsx("div", { className: "o-list-heading", "aria-hidden": "true", children: w.add }), rest.map((r, i) => (_jsxs("div", { id: `${ids}-add-${i}`, role: "option", "aria-selected": i === litAt, className: "o-list-row o-smooth o-smooth-ease o-links-editor-add", "data-slot": "vk-links-offer", "data-key": r.value, "data-record": r.value, ...phoneMark(small), "data-highlighted": i === litAt ? "" : undefined, onPointerMove: () => { if (!open && doing !== "searching" && i !== litAt)
|
|
320
320
|
setLit(i); }, onMouseDown: (e) => e.preventDefault(), onClick: () => link(r.value), children: [_jsx(Face, { record: r, size: 20 }), _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: r.label }) })] }, r.value))), actions.map((a, j) => {
|
|
321
321
|
const i = rest.length + j;
|
|
322
|
-
return (_jsxs("div", { id: `${ids}-add-${i}`, role: "option", "aria-selected": i === litAt, className: "o-list-row o-smooth o-smooth-ease o-links-editor-add o-links-editor-action", ...phoneMark(small), "data-highlighted": i === litAt ? "" : undefined, onPointerMove: () => { if (!open && doing !== "searching" && i !== litAt)
|
|
322
|
+
return (_jsxs("div", { id: `${ids}-add-${i}`, role: "option", "aria-selected": i === litAt, className: "o-list-row o-smooth o-smooth-ease o-links-editor-add o-links-editor-action", "data-slot": "vk-links-offer-action", "data-key": a.key, ...phoneMark(small), "data-highlighted": i === litAt ? "" : undefined, onPointerMove: () => { if (!open && doing !== "searching" && i !== litAt)
|
|
323
323
|
setLit(i); }, onMouseDown: (e) => e.preventDefault(), onClick: a.onSelect, children: [a.icon != null && _jsx("span", { className: "o-links-editor-action-mark", children: a.icon }), _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: a.label }) })] }, a.key));
|
|
324
|
-
})] }), more, message && _jsx("div", { className: "o-links-editor-message", children: message })] }), shown] }));
|
|
324
|
+
})] }), more, message && _jsx("div", { className: "o-links-editor-message", "data-slot": "vk-links-note", children: message })] }), shown] }));
|
|
325
325
|
return { body, head: {} };
|
|
326
326
|
}
|
|
327
327
|
export function LinksEditor(props) {
|
|
@@ -5,7 +5,7 @@ import type { MenuEntry } from "../menu-list/menu-list.js";
|
|
|
5
5
|
* its row is a level in, its choices when its rows are ticks that close, its actions otherwise; a group in place is its rows
|
|
6
6
|
* under its heading, a pick when they are ticks that close; a link and an action as they are. A row's detail, its value in
|
|
7
7
|
* words, rides to a level's end and a choice's. Nothing here closes the menu: the Menu's rows close it as ViewKit's do. */
|
|
8
|
-
export declare function menuEntries(items: ViewsMenuItem[], notNow?: string): MenuEntry[];
|
|
8
|
+
export declare function menuEntries(items: ViewsMenuItem[], notNow?: string, rowSlot?: string): MenuEntry[];
|
|
9
9
|
/** ViewKit's menu, drawn as the Menu at its anchor with no trigger. Every menu ViewKit opens names itself; centred or unsaid,
|
|
10
10
|
* it opens at its anchor's start. */
|
|
11
|
-
export declare function MapMenu({ open, onOpenChange, anchor, items, side, align, label }: ViewsMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function MapMenu({ open, onOpenChange, anchor, items, side, align, label, "data-slot": slot }: ViewsMenuProps): import("react/jsx-runtime").JSX.Element;
|