viewkitjs 0.30.1 → 0.32.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 +143 -0
- package/MIGRATION.md +40 -6
- package/README.md +1 -1
- package/fields/dist/query/index.d.ts +2 -0
- package/fields/dist/query/index.js +2 -0
- package/fields/dist/query/list-request.d.ts +148 -0
- package/fields/dist/query/list-request.js +125 -0
- package/fields/dist/query/saved-view.d.ts +15 -0
- package/fields/dist/query/saved-view.js +11 -0
- package/fields/dist/query/settings.d.ts +9 -0
- package/fields/dist/query/settings.js +9 -0
- package/fields/docs/reference/query.md +66 -0
- package/package.json +8 -2
- package/postgres/README.md +1 -0
- package/postgres/dist/handler.d.ts +53 -0
- package/postgres/dist/handler.js +211 -0
- package/postgres/dist/ids.d.ts +1 -1
- package/postgres/dist/ids.js +19 -1
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/limits.d.ts +3 -1
- package/postgres/dist/limits.js +1 -1
- package/postgres/dist/list-fields.d.ts +10 -0
- package/postgres/dist/list-fields.js +36 -0
- package/postgres/dist/readable.d.ts +4 -0
- package/postgres/dist/readable.js +4 -0
- package/postgres/dist/refusals.d.ts +9 -2
- package/postgres/dist/refusals.js +6 -0
- package/postgres/docs/guides/field-map.md +2 -2
- package/postgres/docs/guides/list-handler.md +99 -0
- package/postgres/docs/index.md +1 -0
- package/postgres/docs/reference/postgres.md +11 -3
- package/views/README.md +2 -2
- package/views/dist/atoms/RowMenu.d.ts +7 -0
- package/views/dist/atoms/RowMenu.js +18 -16
- package/views/dist/atoms/carried.d.ts +5 -0
- package/views/dist/atoms/carried.js +7 -0
- package/views/dist/atoms/types.d.ts +3 -0
- package/views/dist/contract.d.ts +26 -6
- package/views/dist/contract.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
- package/views/dist/controls/atoms.d.ts +2 -0
- package/views/dist/controls/atoms.js +2 -0
- package/views/dist/controls/avatar/avatar.d.ts +10 -4
- package/views/dist/controls/avatar/avatar.js +5 -3
- package/views/dist/controls/avatar/tokens.d.ts +104 -0
- package/views/dist/controls/avatar/tokens.js +26 -0
- package/views/dist/controls/avatar.css +46 -15
- package/views/dist/controls/choice/tokens.d.ts +0 -4
- package/views/dist/controls/choice/tokens.js +0 -1
- package/views/dist/controls/choice.css +3 -3
- package/views/dist/controls/controls.d.ts +6 -0
- package/views/dist/controls/controls.js +10 -2
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +19 -4
- package/views/dist/controls/field/field.js +63 -5
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +41 -16
- package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
- package/views/dist/controls/glyphs/glyphs.js +173 -0
- package/views/dist/controls/index.d.ts +4 -2
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/input/input.d.ts +12 -1
- package/views/dist/controls/input/input.js +10 -6
- package/views/dist/controls/input/save-mark.d.ts +8 -0
- package/views/dist/controls/input/save-mark.js +26 -0
- package/views/dist/controls/input/tokens.d.ts +20 -0
- package/views/dist/controls/input/tokens.js +5 -0
- package/views/dist/controls/input.css +49 -3
- package/views/dist/controls/internal/icons.js +10 -0
- package/views/dist/controls/internal/keep-focus.d.ts +2 -0
- package/views/dist/controls/internal/keep-focus.js +17 -0
- package/views/dist/controls/internal/watch-frame.d.ts +2 -0
- package/views/dist/controls/internal/watch-frame.js +33 -0
- package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
- package/views/dist/controls/markdown/map-markdown.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
- package/views/dist/controls/menu-list/menu-list.js +5 -4
- package/views/dist/controls/modal/modal.js +5 -1
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
- package/views/dist/controls/phone-header/header-bar.js +2 -2
- package/views/dist/controls/phone-header.css +11 -1
- package/views/dist/controls/picker/map-picker.js +3 -0
- package/views/dist/controls/picker/picker.d.ts +14 -0
- package/views/dist/controls/picker/picker.js +30 -10
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/radio/radio.d.ts +12 -3
- package/views/dist/controls/radio/radio.js +25 -5
- package/views/dist/controls/radio/tokens.d.ts +84 -0
- package/views/dist/controls/radio/tokens.js +21 -0
- package/views/dist/controls/radio.css +130 -3
- package/views/dist/controls/select/select.d.ts +12 -2
- package/views/dist/controls/select/select.js +15 -7
- package/views/dist/controls/select/tokens.d.ts +8 -0
- package/views/dist/controls/select/tokens.js +2 -0
- package/views/dist/controls/select.css +17 -0
- package/views/dist/controls/setting-row/looks.d.ts +10 -0
- package/views/dist/controls/setting-row/looks.js +22 -0
- package/views/dist/controls/setting-row/setting-row.d.ts +100 -0
- package/views/dist/controls/setting-row/setting-row.js +133 -0
- package/views/dist/controls/setting-row/tokens.d.ts +156 -0
- package/views/dist/controls/setting-row/tokens.js +41 -0
- package/views/dist/controls/setting-row.css +215 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
- package/views/dist/controls/sheet/bottom-sheet.js +6 -3
- package/views/dist/controls/sheet.css +4 -1
- package/views/dist/controls/sort-editor/sort-editor.js +3 -2
- package/views/dist/controls/sort-editor.css +8 -2
- package/views/dist/controls/switch-row/switch-row.d.ts +1 -15
- package/views/dist/controls/switch-row/switch-row.js +1 -9
- package/views/dist/controls/switch-row/tokens.d.ts +0 -12
- package/views/dist/controls/switch-row/tokens.js +0 -3
- package/views/dist/controls/switch-row.css +3 -7
- package/views/dist/controls/switch.css +17 -7
- package/views/dist/controls/tag/tag.d.ts +3 -1
- package/views/dist/controls/tag/tag.js +2 -2
- package/views/dist/controls/tag/tokens.d.ts +4 -0
- package/views/dist/controls/tag/tokens.js +1 -0
- package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
- package/views/dist/controls/tag-field/tag-field.js +11 -5
- package/views/dist/controls/tag-field/tokens.d.ts +16 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +19 -0
- package/views/dist/controls/tag.css +2 -0
- package/views/dist/controls/tokens.js +2 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
- package/views/dist/controls/toolbar/toolbar.js +22 -15
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
- package/views/dist/controls/toolbar-button.css +4 -0
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
- package/views/dist/controls/views-list/map-view-menu.js +25 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
- package/views/dist/controls/views-list/map-views-list-body.js +39 -21
- package/views/dist/controls/views-list/rules.d.ts +2 -0
- package/views/dist/controls/views-list/view-menu.d.ts +7 -0
- package/views/dist/controls/views-list/view-menu.js +28 -24
- package/views/dist/controls/views-list/words.d.ts +2 -0
- package/views/dist/controls/views-list/words.js +1 -1
- package/views/dist/editors/EditorPanel.js +2 -1
- package/views/dist/editors/edit-session.js +2 -5
- package/views/dist/field-row/FieldRow.d.ts +4 -2
- package/views/dist/field-row/FieldRow.js +67 -20
- package/views/dist/field-row/FieldRowLane.d.ts +7 -2
- package/views/dist/field-row/FieldRowLane.js +4 -3
- package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
- package/views/dist/field-row/editors/RowEditor.js +31 -1
- package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
- package/views/dist/field-row/field-row-button.d.ts +5 -0
- package/views/dist/field-row/field-row-button.js +2 -0
- package/views/dist/fields/binding.d.ts +3 -2
- package/views/dist/fields/binding.js +38 -5
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
- package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
- package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +6 -5
- package/views/dist/grid/chrome/GridRowCells.js +6 -9
- package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
- package/views/dist/grid/chrome/GridStructure.js +4 -4
- package/views/dist/grid/chrome/GridTable.js +5 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
- package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
- package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
- package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
- package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
- package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
- package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
- package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
- package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
- package/views/dist/grid/core/commit-model.d.ts +20 -2
- package/views/dist/grid/core/editing-controller.d.ts +18 -0
- package/views/dist/grid/core/editing-controller.js +188 -42
- package/views/dist/grid/core/editing-model.d.ts +3 -0
- package/views/dist/grid/core/editing-model.js +3 -0
- package/views/dist/grid/core/save-path.d.ts +24 -0
- package/views/dist/grid/core/save-path.js +122 -0
- package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
- package/views/dist/grid/core/spreadsheet-operations.js +23 -0
- package/views/dist/grid/index.d.ts +3 -2
- package/views/dist/grid/index.js +1 -0
- package/views/dist/internal/field-rows.d.ts +26 -0
- package/views/dist/internal/field-rows.js +8 -0
- package/views/dist/internal/page-close.d.ts +7 -0
- package/views/dist/internal/page-close.js +43 -0
- package/views/dist/list/browser-views-store.d.ts +10 -0
- package/views/dist/list/browser-views-store.js +182 -0
- package/views/dist/list/index.d.ts +23 -0
- package/views/dist/list/index.js +8 -0
- package/views/dist/list/menu.d.ts +31 -0
- package/views/dist/list/menu.js +76 -0
- package/views/dist/list/parts.d.ts +6 -0
- package/views/dist/list/parts.js +59 -0
- package/views/dist/list/registry.d.ts +11 -0
- package/views/dist/list/registry.js +31 -0
- package/views/dist/list/root.d.ts +40 -0
- package/views/dist/list/root.js +128 -0
- package/views/dist/list/slot.d.ts +14 -0
- package/views/dist/list/slot.js +22 -0
- package/views/dist/list/source.d.ts +11 -0
- package/views/dist/list/source.js +31 -0
- package/views/dist/list/store.d.ts +87 -0
- package/views/dist/list/store.js +115 -0
- package/views/dist/list/toolbar.d.ts +6 -0
- package/views/dist/list/toolbar.js +359 -0
- package/views/dist/list/views-axis.d.ts +5 -0
- package/views/dist/list/views-axis.js +96 -0
- package/views/dist/list/views-store.d.ts +41 -0
- package/views/dist/list/views-store.js +1 -0
- package/views/dist/list/views.d.ts +67 -0
- package/views/dist/list/views.js +400 -0
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/looks/pieces.js +2 -0
- package/views/dist/model/preferences.js +1 -1
- package/views/dist/model/prefs-buckets.js +1 -1
- package/views/dist/panels/index.d.ts +3 -1
- package/views/dist/panels/index.js +1 -0
- package/views/dist/panels/react/customize-body.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +10 -2
- package/views/dist/panels/react/toolbar/context.js +3 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
- package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
- package/views/dist/panels/react/views-row/PillGroup.js +16 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
- package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
- package/views/dist/panels/toolbar/edit-view.js +14 -0
- package/views/dist/panels/toolbar/model.d.ts +5 -0
- package/views/dist/panels/toolbar/model.js +7 -3
- package/views/dist/panels/view-state.d.ts +5 -3
- package/views/dist/panels/views-row/model.d.ts +19 -2
- package/views/dist/panels/views-row/model.js +14 -0
- package/views/dist/provider/ViewsProvider.d.ts +16 -7
- package/views/dist/provider/ViewsProvider.js +23 -5
- package/views/dist/provider/components.d.ts +43 -2
- package/views/dist/provider/context.d.ts +2 -1
- package/views/dist/provider/context.js +1 -1
- package/views/dist/provider/ports.d.ts +19 -12
- package/views/dist/provider/ports.js +69 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +583 -61
- package/views/dist/styles.unlayered.css +583 -61
- package/views/docs/contract.md +42 -31
- package/views/docs/controls/avatar.md +26 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/field.md +3 -0
- package/views/docs/controls/input.md +9 -0
- package/views/docs/controls/radio.md +33 -0
- package/views/docs/controls/select.md +6 -0
- package/views/docs/controls/setting-row.md +44 -0
- package/views/docs/controls/switch-row.md +0 -3
- package/views/docs/controls/tag-field.md +4 -0
- package/views/docs/controls/tag.md +1 -0
- package/views/docs/getting-started.md +2 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/columns.md +1 -1
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/the-grid.md +34 -7
- package/views/docs/guides/the-provider.md +4 -2
- package/views/docs/index.md +1 -0
- package/views/docs/reference/controls.md +54 -27
- package/views/docs/reference/editors-session.md +1 -1
- package/views/docs/reference/field-row.md +9 -1
- package/views/docs/reference/grid.md +14 -8
- package/views/docs/reference/list.md +227 -0
- package/views/docs/reference/looks.md +3 -0
- package/views/docs/reference/panels-react.md +17 -12
- package/views/docs/reference/panels.md +8 -5
- package/views/docs/reference/react.md +11 -9
- package/views/docs/reference/views.md +2 -2
- package/views/skills/views/SKILL.md +9 -6
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
.o-picker .o-list-row:is([data-selected], [aria-selected="true"]) > .o-picker-check { visibility: visible; }
|
|
29
29
|
/* Create below a line (Create: Below a line, Attio's): its words the text's, not the quieter ones. */
|
|
30
30
|
.o-list-row.o-picker-create-apart .o-list-main { color: var(--vk-fg); }
|
|
31
|
+
/* + Add while the app answers (Adding…): greyed, as a row that can't be picked is, wherever Create stands. */
|
|
32
|
+
.o-list-row.o-picker-create[data-disabled] .o-list-main { color: var(--vk-fg-disabled); }
|
|
31
33
|
|
|
32
34
|
/* ── The search: the shared line across a popup's top (popup-line.css), 6 above and below round its chips, 4 over the
|
|
33
35
|
rows. With nothing to search it stays, out of sight, so the keys still work; a letter typed brings it back holding the
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { OutOfFieldRows } from "../../internal/field-rows.js";
|
|
5
6
|
import { anchorElement, isElement, positionerAnchor } from "../internal/anchor.js";
|
|
6
7
|
import { closeReasonOf } from "../internal/close-reason.js";
|
|
7
8
|
import { phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
@@ -95,7 +96,7 @@ export function Popover({ open, defaultOpen, onOpenChange, trigger, anchor, side
|
|
|
95
96
|
setShown(next);
|
|
96
97
|
onOpenChange?.(next, { reason: reasonOf(details.reason), event: details.event });
|
|
97
98
|
};
|
|
98
|
-
return (_jsxs(BasePopover.Root, { open: isOpen, onOpenChange: change, children: [trigger && _jsx(BasePopover.Trigger, { ref: holdOpener, render: trigger }), _jsx(BasePopover.Portal, { container: host, children: _jsx(BasePopover.Positioner, { ref: setPositioner, className: "o-popover-positioner", anchor: placed, positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, children: _jsxs(BasePopover.Popup, { ref: popup, className: cx("o-popover", className), "data-kit": "popover", "aria-label": label, initialFocus: initialFocus, finalFocus: finalFocus, style: style, onClick: onPopupClick, "data-over": sideOffset < 0 ? "" : undefined, ...phoneMark(phone), ...popupData, children: [_jsx("div", { className: "o-popover-cut o-smooth", children: _jsx(InPane.Provider, { value: false, children: children }) }), _jsx(Scrollbar, {})] }) }) })] }));
|
|
99
|
+
return (_jsxs(BasePopover.Root, { open: isOpen, onOpenChange: change, children: [trigger && _jsx(BasePopover.Trigger, { ref: holdOpener, render: trigger }), _jsx(BasePopover.Portal, { container: host, children: _jsx(BasePopover.Positioner, { ref: setPositioner, className: "o-popover-positioner", anchor: placed, positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, children: _jsxs(BasePopover.Popup, { ref: popup, className: cx("o-popover", className), "data-kit": "popover", "aria-label": label, initialFocus: initialFocus, finalFocus: finalFocus, style: style, onClick: onPopupClick, "data-over": sideOffset < 0 ? "" : undefined, ...phoneMark(phone), ...popupData, children: [_jsx("div", { className: "o-popover-cut o-smooth", children: _jsx(InPane.Provider, { value: false, children: _jsx(OutOfFieldRows, { children: children }) }) }), _jsx(Scrollbar, {})] }) }) })] }));
|
|
99
100
|
}
|
|
100
101
|
export function PopoverTitle({ children, className }) {
|
|
101
102
|
return _jsx(BasePopover.Title, { className: cx("o-popover-title", className), children: children });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Radio as BaseRadio } from "@base-ui/react/radio";
|
|
3
3
|
import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
|
|
4
|
+
import type { OptionColour } from "../option/looks.js";
|
|
4
5
|
export interface RadioGroupProps extends Omit<React.ComponentProps<typeof BaseRadioGroup>, "className"> {
|
|
5
6
|
/** The group's name, above its choices ("Who can see this deal"). Without one, give it an aria-label. */
|
|
6
7
|
label?: React.ReactNode;
|
|
@@ -15,19 +16,27 @@ export interface RadioGroupProps extends Omit<React.ComponentProps<typeof BaseRa
|
|
|
15
16
|
}
|
|
16
17
|
/** Exactly one of a few choices, all of them in sight: its name, then its Radios. With a name, the group is a
|
|
17
18
|
* FieldSet, its name the legend (Base UI names the radio group by it). */
|
|
18
|
-
export declare function RadioGroup(
|
|
19
|
+
export declare function RadioGroup(props: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export interface RadioProps extends Omit<React.ComponentProps<typeof BaseRadio.Root>, "className"> {
|
|
20
21
|
/** The choice. Without one, give it an aria-label. */
|
|
21
22
|
label?: React.ReactNode;
|
|
22
23
|
/** A line under the label that explains it, or says why it is locked. */
|
|
23
24
|
note?: React.ReactNode;
|
|
24
25
|
/** Drawn as a card: an edge round the ring and its words, the whole card pressing it, the chosen one in
|
|
25
|
-
* the selected colours. For a few choices that each need their line read (a pipeline's start).
|
|
26
|
+
* the selected colours. For a few choices that each need their line read (a pipeline's start). On a phone the cards are
|
|
27
|
+
* iOS's ✓ rows on one card (VK-968). */
|
|
26
28
|
card?: boolean;
|
|
27
29
|
/** A mark in place of the ring (a layout's icon): a card, the mark over its name and its line, the chosen one ringed in
|
|
28
30
|
* the brand. Disabled, it stands dashed and greyed, with no line, and the arrows pass it by. */
|
|
29
31
|
mark?: React.ReactNode;
|
|
32
|
+
/** A colour in place of the ring: a round dot in one of the label colours, the chosen one ringed. Give it an aria-label,
|
|
33
|
+
* the colour's name (a workspace's colour). It wins over `mark` and `card`. */
|
|
34
|
+
swatch?: OptionColour;
|
|
35
|
+
/** A marked card's picture: what the app draws (Light, Dark or System as a little app), filling the card's width over
|
|
36
|
+
* its mark and its name, which stand side by side under it. A picture makes the card marked, with a mark or without. */
|
|
37
|
+
picture?: React.ReactNode;
|
|
30
38
|
className?: string;
|
|
31
39
|
}
|
|
32
|
-
/** One choice of a RadioGroup: a ring that fills with the brand and a dot when it is the one chosen.
|
|
40
|
+
/** One choice of a RadioGroup: a ring that fills with the brand and a dot when it is the one chosen. On a phone a group of cards
|
|
41
|
+
* is iOS's ✓ rows: one card, a line between each, the chosen one's ✓ at its end. */
|
|
33
42
|
export declare const Radio: React.ForwardRefExoticComponent<Omit<RadioProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -4,16 +4,36 @@ import * as React from "react";
|
|
|
4
4
|
import { Radio as BaseRadio } from "@base-ui/react/radio";
|
|
5
5
|
import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
|
|
6
6
|
import { cx } from "../../internal/cx.js";
|
|
7
|
+
import { AtSettingRowEnd } from "../../internal/field-rows.js";
|
|
7
8
|
import { FieldSet } from "../field/field.js";
|
|
8
9
|
import { phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
9
|
-
|
|
10
|
+
import { Select } from "../select/select.js";
|
|
11
|
+
export function RadioGroup(props) {
|
|
12
|
+
const end = React.useContext(AtSettingRowEnd), radios = radiosOf(props.children);
|
|
13
|
+
if (end && !radios.some((r) => r.props.swatch != null))
|
|
14
|
+
return _jsx(RadioSelect, { ...props, radios: radios, name: end.name });
|
|
15
|
+
return _jsx(RadioChoices, { ...props });
|
|
16
|
+
}
|
|
17
|
+
const radiosOf = (children) => React.Children.toArray(children).filter((c) => React.isValidElement(c) && c.type === Radio);
|
|
18
|
+
const asWords = (v) => (v == null ? undefined : String(v));
|
|
19
|
+
function RadioSelect({ radios, name, value, defaultValue, onValueChange, disabled, className, ...props }) {
|
|
20
|
+
const items = radios.map(({ props: r }) => ({ value: String(r.value), label: typeof r.label === "string" ? r.label : String(r.value) }));
|
|
21
|
+
return (_jsx(Select, { size: "md", className: cx("o-setting-row-select", className), items: items, value: asWords(value), defaultValue: asWords(defaultValue), disabled: disabled, "aria-label": props["aria-label"] ?? name ?? "Choose", onValueChange: (v) => { if (typeof v === "string")
|
|
22
|
+
onValueChange?.(v, undefined); } }));
|
|
23
|
+
}
|
|
24
|
+
function RadioChoices({ label, row = false, tiles = false, className, children, ...props }) {
|
|
10
25
|
const phone = usePhoneForm();
|
|
11
26
|
const group = (_jsx(BaseRadioGroup, { className: cx("o-radio-group", row && "o-radio-row", tiles && "o-radio-tiles", label == null && className), ...phoneMark(phone), ...props, children: children }));
|
|
12
27
|
return label != null ? _jsx(FieldSet, { legend: label, disabled: props.disabled, className: className, children: group }) : group;
|
|
13
28
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
const CHECK = (_jsx("svg", { className: "o-radio-check", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M5 12l5 5l10 -10" }) }));
|
|
30
|
+
export const Radio = React.forwardRef(function Radio({ label, note, card = false, mark, swatch, picture, className, ...props }, ref) {
|
|
31
|
+
const text = (label != null || note != null) && (_jsxs("span", { className: "o-choice-text", children: [label != null && _jsx("span", { className: "o-choice-label", children: label }), note != null && _jsx("span", { className: "o-choice-note", children: note })] }));
|
|
32
|
+
if (swatch != null) {
|
|
33
|
+
return (_jsxs("label", { className: cx("o-radio", "o-radio-swatched", className), "data-kit": "radio", children: [_jsx(BaseRadio.Root, { ref: ref, className: "o-radio-swatch", "data-colour": swatch, ...props }), text] }));
|
|
34
|
+
}
|
|
35
|
+
const pictured = picture != null, marked = mark != null || pictured;
|
|
36
|
+
return (_jsxs("label", { className: cx("o-radio", (card || marked) && "o-choice-card", marked && "o-radio-marked", pictured && "o-radio-pictured", className), "data-kit": "radio", children: [pictured && _jsx("span", { className: "o-radio-picture", "aria-hidden": "true", children: picture }), marked
|
|
17
37
|
? _jsx(BaseRadio.Root, { ref: ref, className: "o-radio-mark", ...props, children: mark })
|
|
18
|
-
: _jsx(BaseRadio.Root, { ref: ref, className: "o-radio-ring", ...props, children: _jsx(BaseRadio.Indicator, { keepMounted: true, className: "o-radio-dot"
|
|
38
|
+
: _jsx(BaseRadio.Root, { ref: ref, className: "o-radio-ring", ...props, children: _jsx(BaseRadio.Indicator, { keepMounted: true, className: "o-radio-dot", children: card && CHECK }) }), text] }));
|
|
19
39
|
});
|
|
@@ -14,6 +14,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
14
14
|
readonly name: "--vk-border-input-hovered";
|
|
15
15
|
readonly kind: "colour";
|
|
16
16
|
readonly outright: "--border-input-hovered";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-border-overlay-card";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--border-overlay-card";
|
|
17
21
|
}, {
|
|
18
22
|
readonly name: "--vk-border-selected";
|
|
19
23
|
readonly kind: "colour";
|
|
@@ -54,6 +58,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
54
58
|
readonly name: "--vk-ease-out";
|
|
55
59
|
readonly kind: "motion";
|
|
56
60
|
readonly outright: "--ease-out";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-fg";
|
|
63
|
+
readonly kind: "colour";
|
|
64
|
+
readonly outright: "--text";
|
|
57
65
|
}, {
|
|
58
66
|
readonly name: "--vk-fg-accent";
|
|
59
67
|
readonly kind: "colour";
|
|
@@ -74,6 +82,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
74
82
|
readonly name: "--vk-fg-subtle";
|
|
75
83
|
readonly kind: "colour";
|
|
76
84
|
readonly outright: "--text-subtle";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-fg-subtlest";
|
|
87
|
+
readonly kind: "colour";
|
|
88
|
+
readonly outright: "--text-subtlest";
|
|
77
89
|
}, {
|
|
78
90
|
readonly name: "--vk-focus-offset";
|
|
79
91
|
readonly kind: "size";
|
|
@@ -82,6 +94,14 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
82
94
|
readonly name: "--vk-focus-width";
|
|
83
95
|
readonly kind: "size";
|
|
84
96
|
readonly outright: "--focus-width";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "--vk-font-size-base";
|
|
99
|
+
readonly kind: "size";
|
|
100
|
+
readonly outright: "--text-base";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "--vk-font-weight-medium";
|
|
103
|
+
readonly kind: "size";
|
|
104
|
+
readonly outright: "--font-weight-medium";
|
|
85
105
|
}, {
|
|
86
106
|
readonly name: "--vk-font-weight-normal";
|
|
87
107
|
readonly kind: "size";
|
|
@@ -98,6 +118,66 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
98
118
|
readonly name: "--vk-input";
|
|
99
119
|
readonly kind: "colour";
|
|
100
120
|
readonly outright: "--background-input";
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "--vk-line-height-base";
|
|
123
|
+
readonly kind: "size";
|
|
124
|
+
readonly outright: "--text-base--line-height";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "--vk-label-amber";
|
|
127
|
+
readonly kind: "colour";
|
|
128
|
+
readonly outright: "--label-amber";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "--vk-label-amber-fill";
|
|
131
|
+
readonly kind: "colour";
|
|
132
|
+
readonly outright: "--label-amber-fill";
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "--vk-label-blue";
|
|
135
|
+
readonly kind: "colour";
|
|
136
|
+
readonly outright: "--label-blue";
|
|
137
|
+
}, {
|
|
138
|
+
readonly name: "--vk-label-blue-fill";
|
|
139
|
+
readonly kind: "colour";
|
|
140
|
+
readonly outright: "--label-blue-fill";
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "--vk-label-green";
|
|
143
|
+
readonly kind: "colour";
|
|
144
|
+
readonly outright: "--label-green";
|
|
145
|
+
}, {
|
|
146
|
+
readonly name: "--vk-label-green-fill";
|
|
147
|
+
readonly kind: "colour";
|
|
148
|
+
readonly outright: "--label-green-fill";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "--vk-label-pink";
|
|
151
|
+
readonly kind: "colour";
|
|
152
|
+
readonly outright: "--label-pink";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "--vk-label-pink-fill";
|
|
155
|
+
readonly kind: "colour";
|
|
156
|
+
readonly outright: "--label-pink-fill";
|
|
157
|
+
}, {
|
|
158
|
+
readonly name: "--vk-label-purple";
|
|
159
|
+
readonly kind: "colour";
|
|
160
|
+
readonly outright: "--label-purple";
|
|
161
|
+
}, {
|
|
162
|
+
readonly name: "--vk-label-purple-fill";
|
|
163
|
+
readonly kind: "colour";
|
|
164
|
+
readonly outright: "--label-purple-fill";
|
|
165
|
+
}, {
|
|
166
|
+
readonly name: "--vk-label-red";
|
|
167
|
+
readonly kind: "colour";
|
|
168
|
+
readonly outright: "--label-red";
|
|
169
|
+
}, {
|
|
170
|
+
readonly name: "--vk-label-red-fill";
|
|
171
|
+
readonly kind: "colour";
|
|
172
|
+
readonly outright: "--label-red-fill";
|
|
173
|
+
}, {
|
|
174
|
+
readonly name: "--vk-label-teal";
|
|
175
|
+
readonly kind: "colour";
|
|
176
|
+
readonly outright: "--label-teal";
|
|
177
|
+
}, {
|
|
178
|
+
readonly name: "--vk-label-teal-fill";
|
|
179
|
+
readonly kind: "colour";
|
|
180
|
+
readonly outright: "--label-teal-fill";
|
|
101
181
|
}, {
|
|
102
182
|
readonly name: "--vk-neutral";
|
|
103
183
|
readonly kind: "colour";
|
|
@@ -114,6 +194,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
114
194
|
readonly name: "--vk-radius-lg";
|
|
115
195
|
readonly kind: "size";
|
|
116
196
|
readonly outright: "--radius-lg";
|
|
197
|
+
}, {
|
|
198
|
+
readonly name: "--vk-radius-sm";
|
|
199
|
+
readonly kind: "size";
|
|
200
|
+
readonly outright: "--radius-sm";
|
|
117
201
|
}, {
|
|
118
202
|
readonly name: "--vk-radius-xl";
|
|
119
203
|
readonly kind: "size";
|
|
@@ -3,6 +3,7 @@ export const RADIO_TOKENS = [
|
|
|
3
3
|
{ name: "--vk-border-danger", kind: "colour", outright: "--border-danger" },
|
|
4
4
|
{ name: "--vk-border-input", kind: "colour", outright: "--border-input" },
|
|
5
5
|
{ name: "--vk-border-input-hovered", kind: "colour", outright: "--border-input-hovered" },
|
|
6
|
+
{ name: "--vk-border-overlay-card", kind: "colour", outright: "--border-overlay-card" },
|
|
6
7
|
{ name: "--vk-border-selected", kind: "colour", outright: "--border-selected" },
|
|
7
8
|
{ name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
|
|
8
9
|
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
@@ -13,21 +14,41 @@ export const RADIO_TOKENS = [
|
|
|
13
14
|
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
14
15
|
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
15
16
|
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
17
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
16
18
|
{ name: "--vk-fg-accent", kind: "colour", outright: "--text-brand" },
|
|
17
19
|
{ name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
|
|
18
20
|
{ name: "--vk-fg-inverse", kind: "colour", outright: "--text-inverse" },
|
|
19
21
|
{ name: "--vk-fg-on-brand", kind: "colour", outright: "--text-brand-inverse" },
|
|
20
22
|
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
23
|
+
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
21
24
|
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
22
25
|
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
26
|
+
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
27
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
23
28
|
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
24
29
|
{ name: "--vk-ground", kind: "colour", outright: "--surface" },
|
|
25
30
|
{ name: "--vk-hovered", kind: "colour", outright: "--surface-hovered" },
|
|
26
31
|
{ name: "--vk-input", kind: "colour", outright: "--background-input" },
|
|
32
|
+
{ name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
|
|
33
|
+
{ name: "--vk-label-amber", kind: "colour", outright: "--label-amber" },
|
|
34
|
+
{ name: "--vk-label-amber-fill", kind: "colour", outright: "--label-amber-fill" },
|
|
35
|
+
{ name: "--vk-label-blue", kind: "colour", outright: "--label-blue" },
|
|
36
|
+
{ name: "--vk-label-blue-fill", kind: "colour", outright: "--label-blue-fill" },
|
|
37
|
+
{ name: "--vk-label-green", kind: "colour", outright: "--label-green" },
|
|
38
|
+
{ name: "--vk-label-green-fill", kind: "colour", outright: "--label-green-fill" },
|
|
39
|
+
{ name: "--vk-label-pink", kind: "colour", outright: "--label-pink" },
|
|
40
|
+
{ name: "--vk-label-pink-fill", kind: "colour", outright: "--label-pink-fill" },
|
|
41
|
+
{ name: "--vk-label-purple", kind: "colour", outright: "--label-purple" },
|
|
42
|
+
{ name: "--vk-label-purple-fill", kind: "colour", outright: "--label-purple-fill" },
|
|
43
|
+
{ name: "--vk-label-red", kind: "colour", outright: "--label-red" },
|
|
44
|
+
{ name: "--vk-label-red-fill", kind: "colour", outright: "--label-red-fill" },
|
|
45
|
+
{ name: "--vk-label-teal", kind: "colour", outright: "--label-teal" },
|
|
46
|
+
{ name: "--vk-label-teal-fill", kind: "colour", outright: "--label-teal-fill" },
|
|
27
47
|
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
28
48
|
{ name: "--vk-overlay-card", kind: "colour", outright: "--surface-overlay-card" },
|
|
29
49
|
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
30
50
|
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
51
|
+
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
31
52
|
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
32
53
|
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
33
54
|
];
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
/* Marked cards in a row: two across, as New view's layouts; one under another on a phone. Marked cards, as a row or as tiles, keep
|
|
71
71
|
room on every side for what stands outside a card's edge, the chosen one's ring and the focus outline, so a holder that clips
|
|
72
72
|
its sides (the Pane's body) never cuts either (KIT-816); the map's tiles stand as far in. */
|
|
73
|
-
.o-radio-group.o-radio-row:has(> .o-radio-marked.o-choice-card) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
73
|
+
.o-radio-group.o-radio-row:has(> .o-radio-marked.o-choice-card):not(:has(> .o-radio-pictured)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
74
74
|
.o-radio-group:where(.o-radio-row, .o-radio-tiles):has(> .o-radio-marked.o-choice-card) { padding: calc(var(--vk-focus-width) + var(--vk-focus-offset)); }
|
|
75
75
|
|
|
76
76
|
/* ── Tiles: marked cards three across, each centred, its mark over its name in the card's quieter words; chosen, the mark
|
|
@@ -93,12 +93,139 @@
|
|
|
93
93
|
.o-choice-card.o-radio-marked:has(> [data-disabled]) { border-style: dashed; border-color: var(--vk-border-input); box-shadow: none; background-color: transparent; cursor: not-allowed; }
|
|
94
94
|
.o-choice-card.o-radio-marked:has(> [data-disabled]) :is(.o-radio-mark, .o-choice-label, .o-choice-note) { color: var(--vk-fg-disabled); }
|
|
95
95
|
|
|
96
|
+
/* ── A swatch (VK-920; the settings canvas, round 2, Workspace's Colour): a label colour in place of the ring, a 24px dot
|
|
97
|
+
named by its aria-label. Chosen, a thin ring of the ground and the selected colour just outside it; under the pointer the
|
|
98
|
+
same ring in the field's hovered edge; focus outlines it outside that ring; disabled, grey and dashed, which the arrows pass
|
|
99
|
+
by, its ring kept in the field's edge when it is the chosen one. A row of them stands 10 apart. ──────────────────────────────────────────────────────────────────────────────────── */
|
|
100
|
+
.o-radio-swatched { align-items: center; }
|
|
101
|
+
.o-radio-swatch {
|
|
102
|
+
flex: none; box-sizing: border-box; width: calc(var(--vk-spacing) * 6); height: calc(var(--vk-spacing) * 6);
|
|
103
|
+
border-radius: var(--vk-radius-full); outline: none; transition: box-shadow var(--vk-duration-fast) var(--vk-ease-out);
|
|
104
|
+
}
|
|
105
|
+
.o-radio-swatch[data-colour="blue"] { background-color: var(--vk-label-blue-fill); }
|
|
106
|
+
.o-radio-swatch[data-colour="green"] { background-color: var(--vk-label-green-fill); }
|
|
107
|
+
.o-radio-swatch[data-colour="amber"] { background-color: var(--vk-label-amber-fill); }
|
|
108
|
+
.o-radio-swatch[data-colour="red"] { background-color: var(--vk-label-red-fill); }
|
|
109
|
+
.o-radio-swatch[data-colour="purple"] { background-color: var(--vk-label-purple-fill); }
|
|
110
|
+
.o-radio-swatch[data-colour="pink"] { background-color: var(--vk-label-pink-fill); }
|
|
111
|
+
.o-radio-swatch[data-colour="teal"] { background-color: var(--vk-label-teal-fill); }
|
|
112
|
+
.o-radio-swatch[data-colour="grey"] { background-color: var(--vk-neutral); }
|
|
113
|
+
.o-radio-swatch[data-force="hover"]:not([data-checked], [data-disabled]) { box-shadow: 0 0 0 var(--vk-focus-offset) var(--vk-ground), 0 0 0 calc(var(--vk-focus-offset) + var(--vk-focus-width)) var(--vk-border-input-hovered); }
|
|
114
|
+
@media (hover: hover) { .o-radio:hover > .o-radio-swatch:not([data-checked], [data-disabled]) { box-shadow: 0 0 0 var(--vk-focus-offset) var(--vk-ground), 0 0 0 calc(var(--vk-focus-offset) + var(--vk-focus-width)) var(--vk-border-input-hovered); } }
|
|
115
|
+
.o-radio-swatch[data-checked] { box-shadow: 0 0 0 var(--vk-focus-offset) var(--vk-ground), 0 0 0 calc(var(--vk-focus-offset) + var(--vk-focus-width)) var(--vk-border-selected); }
|
|
116
|
+
.o-radio-swatch:is(:focus-visible, [data-force="focus"]) { outline: var(--vk-focus-width) solid var(--vk-border-brand); outline-offset: calc(var(--vk-focus-offset) * 2 + var(--vk-focus-width)); }
|
|
117
|
+
.o-radio-swatch[data-disabled] { background-color: var(--vk-neutral); border: var(--vk-border-width) dashed var(--vk-border-input); box-shadow: none; }
|
|
118
|
+
.o-radio-swatch[data-disabled][data-checked] { box-shadow: 0 0 0 var(--vk-focus-offset) var(--vk-ground), 0 0 0 calc(var(--vk-focus-offset) + var(--vk-focus-width)) var(--vk-border-input); }
|
|
119
|
+
.o-radio:has(> .o-radio-swatch[data-disabled]) { cursor: not-allowed; }
|
|
120
|
+
.o-radio-group.o-radio-row:has(> .o-radio-swatched) { gap: calc(var(--vk-spacing) * 2.5); align-items: center; min-height: calc(var(--vk-spacing) * 9); }
|
|
121
|
+
|
|
122
|
+
/* ── A marked card's picture (VK-920; round 2, Preferences' Appearance): what the app draws, the card's width and 120 tall,
|
|
123
|
+
its mark and its name side by side and centred under it, in the card's quieter words; chosen, ringed as any marked card,
|
|
124
|
+
its words in the text colour, the name a little heavier, the mark not in the brand. A row of them stands one beside
|
|
125
|
+
another at equal widths, on a phone too. ──────────────────────────────────────────────────────────────────────────── */
|
|
126
|
+
.o-choice-card.o-radio-marked.o-radio-pictured {
|
|
127
|
+
display: grid; grid-template-columns: minmax(0, 1fr) auto auto minmax(0, 1fr); align-items: center; column-gap: calc(var(--vk-spacing) * 2); row-gap: 0;
|
|
128
|
+
padding: calc(var(--vk-spacing) * 1.5) calc(var(--vk-spacing) * 1.5) 0; color: var(--vk-fg-subtle);
|
|
129
|
+
}
|
|
130
|
+
.o-radio-picture {
|
|
131
|
+
grid-column: 1 / -1; justify-self: stretch; display: flex; box-sizing: border-box; height: calc(var(--vk-spacing) * 30); overflow: hidden;
|
|
132
|
+
border: var(--vk-border-width) solid var(--vk-border-subtle); border-radius: var(--vk-radius-sm);
|
|
133
|
+
}
|
|
134
|
+
.o-radio-pictured > :is(.o-radio-mark, .o-choice-text) { min-height: calc(var(--vk-spacing) * 11); display: flex; align-items: center; }
|
|
135
|
+
/* The picture spans the card; the mark and the name stand in the two middle columns, centred as a pair under it. */
|
|
136
|
+
.o-radio-pictured > .o-radio-mark { grid-column: 2; }
|
|
137
|
+
.o-radio-pictured > .o-choice-text { grid-column: 3; }
|
|
138
|
+
.o-radio-pictured > .o-radio-mark, .o-radio-pictured > .o-radio-mark[data-checked] { color: inherit; }
|
|
139
|
+
.o-radio-pictured > .o-radio-mark > svg { width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); }
|
|
140
|
+
.o-radio-pictured .o-choice-label { font-weight: var(--vk-font-weight-normal); color: inherit; }
|
|
141
|
+
.o-choice-card.o-radio-pictured:has(> [data-checked]) { color: var(--vk-fg); }
|
|
142
|
+
.o-choice-card.o-radio-pictured:has(> [data-checked]) .o-choice-label { font-weight: var(--vk-font-weight-medium); }
|
|
143
|
+
.o-radio-group.o-radio-row:has(> .o-radio-pictured) { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-columns: none; gap: calc(var(--vk-spacing) * 3); }
|
|
144
|
+
|
|
96
145
|
/* On a phone (`data-vk-phone`, the group's own mark from the device, or a phone frame round it): marked cards one under
|
|
97
146
|
another, tiles on one card. */
|
|
98
|
-
.o-radio-group.o-radio-row:where([data-vk-phone], [data-vk-phone] *):has(> .o-radio-marked.o-choice-card) { grid-template-columns: minmax(0, 1fr); }
|
|
147
|
+
.o-radio-group.o-radio-row:where([data-vk-phone], [data-vk-phone] *):has(> .o-radio-marked.o-choice-card):not(:has(> .o-radio-pictured)) { grid-template-columns: minmax(0, 1fr); }
|
|
99
148
|
.o-radio-group.o-radio-tiles:where([data-vk-phone], [data-vk-phone] *):has(> .o-choice-card) { gap: calc(var(--vk-spacing) * 2); padding: calc(var(--vk-spacing) * 3); border-radius: var(--vk-radius-xl); background-color: var(--vk-overlay-card); }
|
|
100
149
|
.o-radio-tiles:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card.o-radio-marked { justify-content: center; min-height: calc(var(--vk-spacing) * 18); }
|
|
101
150
|
.o-radio-tiles:where([data-vk-phone], [data-vk-phone] *) > .o-radio-marked > .o-radio-mark > svg { width: calc(var(--vk-spacing) * 5.5); height: calc(var(--vk-spacing) * 5.5); }
|
|
102
151
|
|
|
103
|
-
|
|
152
|
+
/* ── On a phone, the swatches and the pictured cards (VK-955; the settings canvas, round 3, the iOS round: look-ios.mjs, .sws
|
|
153
|
+
and .pics): each row a card of its own, the overlay card's ground and corner, as the tiles are on a phone. The swatches 28
|
|
154
|
+
across, 13 apart, each in its colour's bold shade, as round 3 draws them (the label's own hue, grey the quietest text; VK-963),
|
|
155
|
+
the chosen one ringed in the text colour just outside a gap of the card's ground. The pictured cards drop
|
|
156
|
+
their edge, ring and ground: each a phone, 46 × 88, framed in the field's edge, over its name; the chosen one framed in
|
|
157
|
+
the brand, its name a pill in the brand; no mark, the radio itself kept for the keys and focus, which rings the card. The
|
|
158
|
+
three stand spaced around their card. ──────────────────────────────────────────────────────────────────────────────── */
|
|
159
|
+
.o-radio-group.o-radio-row:where([data-vk-phone], [data-vk-phone] *):has(> .o-radio-swatched) {
|
|
160
|
+
gap: calc(var(--vk-spacing) * 3.25); min-height: 0; padding: calc(var(--vk-spacing) * 3.5) calc(var(--vk-spacing) * 4.5);
|
|
161
|
+
border-radius: var(--vk-radius-xl); background-color: var(--vk-overlay-card);
|
|
162
|
+
}
|
|
163
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch { width: calc(var(--vk-spacing) * 7); height: calc(var(--vk-spacing) * 7); }
|
|
164
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="blue"]:not([data-disabled]) { background-color: var(--vk-label-blue); }
|
|
165
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="green"]:not([data-disabled]) { background-color: var(--vk-label-green); }
|
|
166
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="amber"]:not([data-disabled]) { background-color: var(--vk-label-amber); }
|
|
167
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="red"]:not([data-disabled]) { background-color: var(--vk-label-red); }
|
|
168
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="purple"]:not([data-disabled]) { background-color: var(--vk-label-purple); }
|
|
169
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="pink"]:not([data-disabled]) { background-color: var(--vk-label-pink); }
|
|
170
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="teal"]:not([data-disabled]) { background-color: var(--vk-label-teal); }
|
|
171
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-colour="grey"]:not([data-disabled]) { background-color: var(--vk-fg-subtlest); }
|
|
172
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-force="hover"]:not([data-checked], [data-disabled]) { box-shadow: 0 0 0 var(--vk-focus-offset) var(--vk-overlay-card), 0 0 0 calc(var(--vk-focus-offset) + var(--vk-focus-width)) var(--vk-border-input-hovered); }
|
|
173
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-checked]:not([data-disabled]) { box-shadow: 0 0 0 var(--vk-focus-offset) var(--vk-overlay-card), 0 0 0 calc(var(--vk-focus-offset) + var(--vk-focus-width)) var(--vk-fg); }
|
|
174
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-swatched > .o-radio-swatch[data-disabled][data-checked] { box-shadow: 0 0 0 var(--vk-focus-offset) var(--vk-overlay-card), 0 0 0 calc(var(--vk-focus-offset) + var(--vk-focus-width)) var(--vk-border-input); }
|
|
175
|
+
|
|
176
|
+
.o-radio-group.o-radio-row:where([data-vk-phone], [data-vk-phone] *):has(> .o-radio-pictured) {
|
|
177
|
+
display: flex; justify-content: space-around; gap: 0; padding: calc(var(--vk-spacing) * 4.5) calc(var(--vk-spacing) * 2.5) calc(var(--vk-spacing) * 4);
|
|
178
|
+
border-radius: var(--vk-radius-xl); background-color: var(--vk-overlay-card);
|
|
179
|
+
}
|
|
180
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card.o-radio-marked.o-radio-pictured {
|
|
181
|
+
position: relative; display: flex; flex-direction: column; align-items: center; gap: calc(var(--vk-spacing) * 2.5); width: auto; padding: 0;
|
|
182
|
+
border: 0 none; box-shadow: none; background-color: transparent; color: var(--vk-fg);
|
|
183
|
+
}
|
|
184
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-pictured > .o-radio-picture {
|
|
185
|
+
flex: none; width: calc(var(--vk-spacing) * 11.5); height: calc(var(--vk-spacing) * 22);
|
|
186
|
+
border: var(--vk-focus-width) solid var(--vk-border-input); border-radius: var(--vk-radius-lg);
|
|
187
|
+
transition: border-color var(--vk-duration-fast) var(--vk-ease-out);
|
|
188
|
+
}
|
|
189
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-pictured:has(> [data-checked]) > .o-radio-picture { border-color: var(--vk-brand); }
|
|
190
|
+
/* The radio itself, out of sight: still the one the keys move and focus lands on. */
|
|
191
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-pictured > .o-radio-mark { position: absolute; width: 1px; height: 1px; min-height: 0; overflow: hidden; clip-path: inset(50%); }
|
|
192
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-pictured > .o-choice-text {
|
|
193
|
+
min-height: calc(var(--vk-spacing) * 6.25); padding: 0 calc(var(--vk-spacing) * 2.75); border-radius: var(--vk-radius-full);
|
|
194
|
+
transition: background-color var(--vk-duration-fast) var(--vk-ease-out), color var(--vk-duration-fast) var(--vk-ease-out);
|
|
195
|
+
}
|
|
196
|
+
.o-radio-row:where([data-vk-phone], [data-vk-phone] *) > .o-radio-pictured:has(> [data-checked]) > .o-choice-text { background-color: var(--vk-brand); color: var(--vk-fg-on-brand); }
|
|
197
|
+
|
|
198
|
+
/* ── On a phone, a group of cards (VK-968; the settings canvas, round 3, the iOS round: look-ios.mjs, .grp, .r and .ck): iOS's
|
|
199
|
+
✓ rows, on one card in the overlay card's ground and corner, as the swatches and the tiles stand on a phone; each row 52 at
|
|
200
|
+
least, 16 in, its label in the base words and its line under it in the quietest, a rule between each from the words, which a
|
|
201
|
+
place may stop --field-rows-line-end short of the right edge, as Field rows' rule; no edge and no ground of its own. Its ring
|
|
202
|
+
stands at the row's end, 20 square and bare: chosen, the ✓ in the accent; else nothing. The ring keeps the keys and the focus. */
|
|
203
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *):has(> .o-choice-card:not(.o-radio-marked)) {
|
|
204
|
+
gap: 0; overflow: hidden; border-radius: var(--vk-radius-xl); background-color: var(--vk-overlay-card);
|
|
205
|
+
}
|
|
206
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) {
|
|
207
|
+
display: flex; align-items: center; gap: calc(var(--vk-spacing) * 3); min-height: calc(var(--vk-spacing) * 13);
|
|
208
|
+
padding: calc(var(--vk-spacing) * 2.5) calc(var(--vk-spacing) * 4); border: 0; border-radius: 0; box-shadow: none; background-color: transparent;
|
|
209
|
+
}
|
|
210
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) + .o-choice-card {
|
|
211
|
+
background-image: linear-gradient(var(--vk-border-overlay-card), var(--vk-border-overlay-card)); background-repeat: no-repeat;
|
|
212
|
+
background-size: calc(100% - var(--vk-spacing) * 4 - var(--field-rows-line-end, 0px)) var(--vk-border-width); background-position: calc(var(--vk-spacing) * 4) 0;
|
|
213
|
+
}
|
|
214
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) > .o-choice-text { flex: 1 1 auto; min-width: 0; }
|
|
215
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) .o-choice-label {
|
|
216
|
+
font-size: var(--vk-font-size-base); line-height: calc(var(--vk-font-size-base) * var(--vk-line-height-base)); font-weight: var(--vk-font-weight-normal);
|
|
217
|
+
}
|
|
218
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) .o-choice-note { color: var(--vk-fg-subtlest); }
|
|
219
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) > .o-radio-ring {
|
|
220
|
+
order: 1; width: calc(var(--vk-spacing) * 5); height: calc(var(--vk-spacing) * 5); margin: 0; border: 0; border-radius: var(--vk-radius-sm); background-color: transparent;
|
|
221
|
+
}
|
|
222
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) .o-radio-dot { display: contents; }
|
|
223
|
+
.o-radio-check { display: none; }
|
|
224
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) .o-radio-check {
|
|
225
|
+
display: block; width: calc(var(--vk-spacing) * 5); height: calc(var(--vk-spacing) * 5); stroke-width: 2.4; color: var(--vk-fg-accent); visibility: hidden;
|
|
226
|
+
}
|
|
227
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) > [data-checked] .o-radio-check { visibility: visible; }
|
|
228
|
+
.o-radio-group:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card:not(.o-radio-marked) > [data-disabled] .o-radio-check { color: var(--vk-fg-disabled); }
|
|
229
|
+
|
|
230
|
+
@media (prefers-reduced-motion: reduce) { .o-radio-ring, .o-radio-dot, .o-radio-mark, .o-radio-swatch, .o-radio-picture, .o-radio-pictured > .o-choice-text { transition: none; } }
|
|
104
231
|
}
|
|
@@ -22,6 +22,10 @@ export interface SelectItem {
|
|
|
22
22
|
interface SelectFieldProps {
|
|
23
23
|
/** What the field holds, above it. Without one, give it an aria-label. */
|
|
24
24
|
label?: React.ReactNode;
|
|
25
|
+
/** Where its label stands: over the box (the default), or inside it before its value, in the quieter words, the box the
|
|
26
|
+
* outline Button's own (its ground, edge and depth) and as wide as what it holds: a filter, Person Anyone ⌄. A field typed
|
|
27
|
+
* into keeps it over the box. */
|
|
28
|
+
labelAt?: "above" | "inside";
|
|
25
29
|
placeholder?: string;
|
|
26
30
|
/** Its height, as the Input's and the Button's: 24 and 28px in dense rows (24 with 12px words), 32 in
|
|
27
31
|
* toolbars, 36 (md) beside other fields, 44 on the phone. */
|
|
@@ -36,8 +40,14 @@ interface SelectFieldProps {
|
|
|
36
40
|
disabled?: boolean;
|
|
37
41
|
"aria-label"?: string;
|
|
38
42
|
className?: string;
|
|
39
|
-
/** The field drawn as under the pointer or in focus, as a page that shows it draws it. */
|
|
40
|
-
"data-force"?: "hover" | "focus";
|
|
43
|
+
/** The field drawn as under the pointer or in focus, as a page that shows it draws it; saved, its Saved held. */
|
|
44
|
+
"data-force"?: "hover" | "focus" | "saved";
|
|
45
|
+
/** The app saving what was picked (VK-921): the Spinner at the field's end, before its chevron, the field busy. It wins
|
|
46
|
+
* over saved. */
|
|
47
|
+
saving?: boolean;
|
|
48
|
+
/** The save took: a check and Saved before the chevron, fading after --vk-saved-hold and then gone; a save that fails is
|
|
49
|
+
* the error instead. */
|
|
50
|
+
saved?: boolean;
|
|
41
51
|
}
|
|
42
52
|
/** The field alone: it owns no list. A press, or ↓ or ↑, tells its holder, which opens what it owns (a phone's date wheels, a step
|
|
43
53
|
* of a Sheet); while `open` it is drawn in the Select's own open state; its arrow down unless said. It shows what it holds, or
|
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
|
|
5
5
|
import { Field as BaseField } from "@base-ui/react/field";
|
|
6
6
|
import { Avatar } from "../avatar/avatar.js";
|
|
7
|
-
import { Button } from "../button/button.js";
|
|
7
|
+
import { Button, buttonClass } from "../button/button.js";
|
|
8
8
|
import { Field } from "../field/field.js";
|
|
9
9
|
import { Input, InputGroupAddon } from "../input/input.js";
|
|
10
10
|
import { Option, Options } from "../option/option.js";
|
|
@@ -19,6 +19,7 @@ import { Sheet, SheetBody, SheetHead } from "../sheet/bottom-sheet.js";
|
|
|
19
19
|
import { listSide } from "./side.js";
|
|
20
20
|
import { chipsThatFit } from "./fit.js";
|
|
21
21
|
import { filledMatch } from "./filled.js";
|
|
22
|
+
import { SaveMark } from "../input/save-mark.js";
|
|
22
23
|
const glyph = (paths, className, strokeWidth = 2) => (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: strokeWidth, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) }));
|
|
23
24
|
const CHEVRON = ["M6 9l6 6l6 -6"], PLUS = ["M12 5v14", "M5 12h14"], X = ["M18 6l-12 12", "M6 6l12 12"];
|
|
24
25
|
const SEARCH = ["M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0", "M21 21l-6 -6"];
|
|
@@ -80,7 +81,7 @@ function PickerSelect(p) {
|
|
|
80
81
|
if (placed.open !== open)
|
|
81
82
|
setPlaced({ open, side: open ? sideAsItOpens(p, f, box) : p.side ?? "bottom" });
|
|
82
83
|
const side = placed.side;
|
|
83
|
-
return (_jsxs(Labelled, { ...p, id: f.id, typed: typed, children: [_jsx(PickerUnder, { ...picker.props, empty: typed ? undefined : picker.props.empty, search: picker.words ?? p.search ?? (p.create || p.onSearch || p.footer ? "Search" : undefined), searchShown: typed || !!(p.search || p.create || p.onSearch || p.footer), searchIn: typed ? "box" : "list", open: open, onOpenChange: setOpen, disabled: disabled, box: typed ? (search) => _jsx(TypedBox, { p: p, f: f, trigger: trigger, field: field, hint: picker.words ?? p.search ?? placeholder, search: search }) : (_jsxs(BaseCombobox.Trigger, { ref: trigger, className:
|
|
84
|
+
return (_jsxs(Labelled, { ...p, id: f.id, typed: typed, children: [_jsx(PickerUnder, { ...picker.props, empty: typed ? undefined : picker.props.empty, search: picker.words ?? p.search ?? (p.create || p.onSearch || p.footer ? "Search" : undefined), searchShown: typed || !!(p.search || p.create || p.onSearch || p.footer), searchIn: typed ? "box" : "list", open: open, onOpenChange: setOpen, disabled: disabled, box: typed ? (search) => _jsx(TypedBox, { p: p, f: f, trigger: trigger, field: field, hint: picker.words ?? p.search ?? placeholder, search: search }) : (_jsxs(BaseCombobox.Trigger, { ref: trigger, className: boxClass(p), "data-force": p["data-force"], "data-kit": "select", ...mark, ...fieldAria(p, f.id), ...busy(p), children: [inside(p) && _jsx("span", { id: `${f.id}-label`, className: "o-select-label-in", children: p.label }), _jsx("span", { id: `${f.id}-value`, className: "contents", children: _jsx(Value, { chosen: f.chosen, multiple: multiple, chips: chips, placeholder: placeholder }) }), _jsx(SaveMark, { saving: p.saving, saved: p.saved }), _jsx(BaseCombobox.Icon, { className: "o-select-chevron", children: glyph(CHEVRON, "") })] })), panel: (list) => (_jsx(BaseCombobox.Portal, { container: host, children: _jsx(BaseCombobox.Positioner, { className: "o-list-positioner", side: side, sideOffset: gapOf(box ?? host), collisionPadding: edgeOf(box ?? host), align: p.align ?? "start", collisionAvoidance: { side: "none" }, anchor: typed ? field : undefined, children: _jsx(BaseCombobox.Popup, { ref: popup, className: "o-list o-select-list o-smooth o-smooth-ease", ...mark, "data-list-width": p.listWidth === "rows" ? "rows" : undefined, "aria-label": titleOf(p), children: list }) }, side) })) }), _jsx(FormValue, { p: p, f: f, focusBox: () => (typed ? field.current?.querySelector("input") : trigger.current)?.focus() })] }));
|
|
84
85
|
}
|
|
85
86
|
function TypedBox({ p, f, trigger, field, hint, search }) {
|
|
86
87
|
const { multiple, disabled } = p, q = search.typed, mark = phoneMark(usePhoneForm());
|
|
@@ -109,7 +110,7 @@ function TypedBox({ p, f, trigger, field, hint, search }) {
|
|
|
109
110
|
const one = !multiple && f.chosen.length === 1 ? f.chosen[0] : undefined;
|
|
110
111
|
const slot = one?.mark != null && (_jsxs(InputGroupAddon, { side: "start", className: "o-select-mark", "aria-hidden": "true", "data-searching": q !== one.label ? "" : undefined, children: [_jsx("span", { className: "o-select-mark-own", children: one.mark }), glyph(SEARCH, "o-select-mark-search")] }));
|
|
111
112
|
const box = (_jsx(Input, { combobox: true, chrome: "bare", ref: input, className: "o-select-typed-input", placeholder: multiple && f.chosen.length ? undefined : hint, onKeyDown: search.onKeyDown, ...search.attrs, ...(p.label != null ? {} : { "aria-label": p["aria-label"] }) }));
|
|
112
|
-
return (_jsxs(BaseCombobox.InputGroup, { ref: field, className: cx("o-input o-input-group o-select-field o-select-typed o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-kit": "select", ...mark, onMouseDown: keep, children: [slot, multiple ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "o-select-measure", "aria-hidden": "true", inert: true, children: _jsxs("span", { ref: measure, children: [f.chosen.map((i) => _jsx(Option, { icon: chipMark(i.mark), onRemove: () => { }, children: i.label }, i.value)), _jsx(Option, { count: n }), _jsx("span", { className: "o-select-measure-words", children: q })] }) }), _jsxs(BaseCombobox.Chips, { ref: chipsBox, className: "o-select-chips", children: [f.chosen.map((i, at) => _jsx(BaseCombobox.Chip, { "data-over": at >= fit ? "" : undefined, render: _jsx(Option, { icon: chipMark(i.mark), onRemove: () => f.setValue(f.value.filter((v) => v !== i.value)) }), children: i.label }, i.value)), fit < n && _jsx(Option, { count: n - fit }), box] })] })) : box, !small && !disabled && !p.readOnly && f.chosen.length > 0 && (_jsx(BaseCombobox.Clear, { render: (props) => _jsx(Button, { ...props, kind: "quiet", size: "2xs", shape: "icon", className: "o-select-clear", "aria-label": "Clear", icon: glyph(X, ""), children: null }) })), _jsx(BaseCombobox.Trigger, { ref: trigger, className: "o-select-chevron o-select-typed-trigger", tabIndex: -1, "aria-label": `Show every ${typeof p.label === "string" ? p.label.toLowerCase() : "choice"}`, children: glyph(CHEVRON, "") })] }));
|
|
113
|
+
return (_jsxs(BaseCombobox.InputGroup, { ref: field, className: cx("o-input o-input-group o-select-field o-select-typed o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-kit": "select", ...mark, ...busy(p), onMouseDown: keep, children: [slot, multiple ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "o-select-measure", "aria-hidden": "true", inert: true, children: _jsxs("span", { ref: measure, children: [f.chosen.map((i) => _jsx(Option, { icon: chipMark(i.mark), onRemove: () => { }, children: i.label }, i.value)), _jsx(Option, { count: n }), _jsx("span", { className: "o-select-measure-words", children: q })] }) }), _jsxs(BaseCombobox.Chips, { ref: chipsBox, className: "o-select-chips", children: [f.chosen.map((i, at) => _jsx(BaseCombobox.Chip, { "data-over": at >= fit ? "" : undefined, render: _jsx(Option, { icon: chipMark(i.mark), onRemove: () => f.setValue(f.value.filter((v) => v !== i.value)) }), children: i.label }, i.value)), fit < n && _jsx(Option, { count: n - fit }), box] })] })) : box, !small && !disabled && !p.readOnly && f.chosen.length > 0 && (_jsx(BaseCombobox.Clear, { render: (props) => _jsx(Button, { ...props, kind: "quiet", size: "2xs", shape: "icon", className: "o-select-clear", "aria-label": "Clear", icon: glyph(X, ""), children: null }) })), _jsx(SaveMark, { saving: p.saving, saved: p.saved }), _jsx(BaseCombobox.Trigger, { ref: trigger, className: "o-select-chevron o-select-typed-trigger", tabIndex: -1, "aria-label": `Show every ${typeof p.label === "string" ? p.label.toLowerCase() : "choice"}`, children: glyph(CHEVRON, "") })] }));
|
|
113
114
|
}
|
|
114
115
|
const gapOf = (at) => spacingPx(1, at), edgeOf = (at) => spacingPx(1.25, at);
|
|
115
116
|
function listNeed(at, rows, lines) {
|
|
@@ -193,13 +194,20 @@ function useField({ multiple, defaultValue, value: outside, onValueChange, items
|
|
|
193
194
|
return { items, add, value, setValue, chosen, id: React.useId() };
|
|
194
195
|
}
|
|
195
196
|
const sized = (size) => size && size !== "md" && `o-input-${size}`;
|
|
196
|
-
|
|
197
|
-
|
|
197
|
+
const inside = (p) => p.labelAt === "inside" && p.label != null && p.searchIn !== "field";
|
|
198
|
+
const GLASS_PILL = "o-glass o-glass-button o-glass-button-worded o-glass-button-sm";
|
|
199
|
+
const boxClass = (p, phone = false) => inside(p) ? cx("o-select-field", phone ? GLASS_PILL : buttonClass("outline", p.size ?? "md")) : cx("o-input o-select-field o-smooth o-smooth-ease", sized(p.size));
|
|
200
|
+
function Labelled({ label, labelAt, note, error, id, size, typed, disabled, className, children }) {
|
|
201
|
+
const within = inside({ label, labelAt, searchIn: typed ? "field" : "list" });
|
|
202
|
+
if (within)
|
|
203
|
+
label = undefined;
|
|
204
|
+
const cls = cx("o-select", size && size !== "md" && `o-select-${size}`, within && "o-select-inside", className);
|
|
198
205
|
return label != null || note != null || (error != null && error !== "")
|
|
199
206
|
? _jsx(Field, { label: label, note: note, error: error, disabled: disabled, nativeLabel: !!typed, labelId: `${id}-label`, className: cls, children: children })
|
|
200
207
|
: _jsx("div", { className: cls, children: children });
|
|
201
208
|
}
|
|
202
209
|
const fieldAria = (p, id) => (p.label != null ? { "aria-labelledby": `${id}-label ${id}-value` } : { "aria-label": p["aria-label"] });
|
|
210
|
+
const busy = (p) => (p.saving ? { "aria-busy": true } : {});
|
|
203
211
|
const ARROWS = { down: CHEVRON, right: ["M9 6l6 6l-6 6"] };
|
|
204
212
|
function AloneSelect({ opens, shown, open = false, onOpenChange, placeholder = "Choose", arrow = "down", ...p }) {
|
|
205
213
|
const id = React.useId(), own = React.useRef(null), pressedOpen = React.useRef(false), mark = phoneMark(usePhoneForm());
|
|
@@ -219,8 +227,8 @@ function AloneSelect({ opens, shown, open = false, onOpenChange, placeholder = "
|
|
|
219
227
|
onOpenChange?.(true);
|
|
220
228
|
} };
|
|
221
229
|
const empty = shown == null || shown === "" || shown === false;
|
|
222
|
-
return (_jsx(Labelled, { ...p, id: id, children: _jsxs(BaseField.Control, { render: _jsx("button", { type: "button" }), ref: own, disabled: p.disabled, className:
|
|
223
|
-
: _jsx("span", { className: "o-select-value", children: typeof shown === "string" ? _jsx("span", { className: "o-list-main", children: shown }) : shown }) }), arrow !== "none" && _jsx("span", { className: "o-select-chevron", "data-arrow": arrow, "aria-hidden": "true", children: glyph(ARROWS[arrow], "") })] }) }));
|
|
230
|
+
return (_jsx(Labelled, { ...p, id: id, children: _jsxs(BaseField.Control, { render: _jsx("button", { type: "button" }), ref: own, disabled: p.disabled, className: boxClass(p, !!mark), "data-force": p["data-force"], "data-kit": "select", ...mark, ...fieldAria(p, id), ...busy(p), "aria-haspopup": opens, "aria-expanded": open, "data-popup-open": open ? "" : undefined, onClick: press, onKeyDown: keys, children: [inside(p) && _jsx("span", { id: `${id}-label`, className: "o-select-label-in", children: p.label }), _jsx("span", { id: `${id}-value`, className: "contents", children: empty ? _jsx("span", { className: "o-select-value o-select-placeholder", children: placeholder })
|
|
231
|
+
: _jsx("span", { className: "o-select-value", children: typeof shown === "string" ? _jsx("span", { className: "o-list-main", children: shown }) : shown }) }), _jsx(SaveMark, { saving: p.saving, saved: p.saved }), arrow !== "none" && _jsx("span", { className: "o-select-chevron", "data-arrow": arrow, "aria-hidden": "true", children: glyph(ARROWS[arrow], "") })] }) }));
|
|
224
232
|
}
|
|
225
233
|
export function SelectShown({ items, defaultValue, multiple, chips, search, none, placeholder = "Choose", "aria-label": name }) {
|
|
226
234
|
const [value, setValue] = React.useState(defaultValue ?? (multiple ? [] : null));
|
|
@@ -2,6 +2,10 @@ export declare const SELECT_TOKENS: readonly [{
|
|
|
2
2
|
readonly name: "--vk-fg-disabled";
|
|
3
3
|
readonly kind: "colour";
|
|
4
4
|
readonly outright: "--text-disabled";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-fg-subtle";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--text-subtle";
|
|
5
9
|
}, {
|
|
6
10
|
readonly name: "--vk-fg-subtlest";
|
|
7
11
|
readonly kind: "colour";
|
|
@@ -10,6 +14,10 @@ export declare const SELECT_TOKENS: readonly [{
|
|
|
10
14
|
readonly name: "--vk-font-size-base";
|
|
11
15
|
readonly kind: "size";
|
|
12
16
|
readonly outright: "--text-base";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-font-weight-normal";
|
|
19
|
+
readonly kind: "size";
|
|
20
|
+
readonly outright: "--font-weight-normal";
|
|
13
21
|
}, {
|
|
14
22
|
readonly name: "--vk-spacing";
|
|
15
23
|
readonly kind: "size";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export const SELECT_TOKENS = [
|
|
2
2
|
{ name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
|
|
3
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
3
4
|
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
4
5
|
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
6
|
+
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
5
7
|
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
6
8
|
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
7
9
|
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|