viewkitjs 0.31.0 → 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 +129 -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 +5 -1
- 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 +3 -3
- package/views/dist/controls/avatar/avatar.js +1 -1
- package/views/dist/controls/avatar/tokens.d.ts +44 -0
- package/views/dist/controls/avatar/tokens.js +11 -0
- package/views/dist/controls/avatar.css +22 -5
- 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 +2 -1
- package/views/dist/controls/index.js +2 -1
- package/views/dist/controls/input/input.js +5 -2
- package/views/dist/controls/input/tokens.d.ts +4 -0
- package/views/dist/controls/input/tokens.js +1 -0
- package/views/dist/controls/input.css +31 -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 +5 -3
- package/views/dist/controls/radio/radio.js +18 -2
- package/views/dist/controls/radio/tokens.d.ts +44 -0
- package/views/dist/controls/radio/tokens.js +11 -0
- package/views/dist/controls/radio.css +79 -1
- package/views/dist/controls/select/select.d.ts +4 -0
- package/views/dist/controls/select/select.js +11 -5
- 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 +1 -1
- package/views/dist/controls/setting-row/looks.js +9 -4
- package/views/dist/controls/setting-row/setting-row.d.ts +45 -10
- package/views/dist/controls/setting-row/setting-row.js +82 -15
- package/views/dist/controls/setting-row/tokens.d.ts +74 -2
- package/views/dist/controls/setting-row/tokens.js +19 -1
- package/views/dist/controls/setting-row.css +135 -14
- 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/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/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/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 +418 -59
- package/views/dist/styles.unlayered.css +418 -59
- package/views/docs/contract.md +42 -31
- package/views/docs/controls/avatar.md +11 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/field.md +3 -0
- package/views/docs/controls/input.md +1 -0
- package/views/docs/controls/radio.md +16 -1
- package/views/docs/controls/select.md +2 -0
- package/views/docs/controls/setting-row.md +18 -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 +35 -25
- 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 +1 -1
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* The phone's header bar, the one row a page and a sheet's head both draw, and the soft edge it stands on. Every value it draws
|
|
2
2
|
with is a public name (controls/phone-header/tokens.ts); this file only says which name each part takes: 44 tall on the page's
|
|
3
3
|
padding (--page-padding; in a sheet, the sheet's), its title centred between its two places, whatever stands in them, and cut
|
|
4
|
-
before it reaches them. --hd-bar-room is the room standing over it: the soft edge starts that far above it and ends just past
|
|
4
|
+
before it reaches them; a record's mark, when it has one, beside its title. --hd-bar-room is the room standing over it: the soft edge starts that far above it and ends just past
|
|
5
5
|
it, so it always reaches the top of what it stands in. What an app sets once is a data attribute on the frame around it
|
|
6
6
|
(looks.ts):
|
|
7
7
|
|
|
@@ -44,6 +44,16 @@
|
|
|
44
44
|
/* Its title at the left: after what stands on its left, taking the room there is. */
|
|
45
45
|
.o-hd-bar[data-title-at="left"] { grid-template-columns: auto minmax(0, 1fr) auto; }
|
|
46
46
|
.o-hd-bar[data-title-at="left"] > .o-hd-bar-title { text-align: start; }
|
|
47
|
+
/* A record's mark beside its title (data-mark): its own column, as wide as the mark, so it never shrinks while the words cut with
|
|
48
|
+
… beside it, 8 apart; the two stand together, centred, or at the left after what stands there. With a description the mark
|
|
49
|
+
stands beside both lines. */
|
|
50
|
+
.o-hd-bar[data-mark] > .o-hd-bar-title {
|
|
51
|
+
grid-template-columns: max-content minmax(0, max-content); column-gap: calc(var(--vk-spacing) * 2);
|
|
52
|
+
justify-content: center; align-items: center; text-align: start;
|
|
53
|
+
}
|
|
54
|
+
.o-hd-bar[data-mark][data-title-at="left"] > .o-hd-bar-title { justify-content: start; }
|
|
55
|
+
.o-hd-bar-mark { display: flex; overflow: visible; }
|
|
56
|
+
.o-hd-bar-mark:has(~ .o-hd-bar-description) { grid-row: span 2; }
|
|
47
57
|
/* Flat: no soft edge, and a smaller title. What it stands on is its place's: the page's header on a page, the Sheet's in a sheet. */
|
|
48
58
|
[data-phone-header-surface="flat"] .o-hd-bar > .o-hd-bar-edge { display: none; }
|
|
49
59
|
[data-phone-header-surface="flat"] .o-hd-bar > .o-hd-bar-title { font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
@@ -41,6 +41,9 @@ export function pickerWordsOf(say) {
|
|
|
41
41
|
noneTyped: (typed) => say({ key: "views.picker.none-typed", values: { typed } }),
|
|
42
42
|
create: (typed) => say({ key: "views.picker.create", values: { typed } }),
|
|
43
43
|
createButton: say({ key: "views.picker.create-button" }),
|
|
44
|
+
add: (value) => say({ key: "views.editors.add-option", values: { value } }),
|
|
45
|
+
adding: (value) => say({ key: "views.editors.adding-option", values: { value } }),
|
|
46
|
+
addButton: say({ key: "views.editors.values-add" }),
|
|
44
47
|
loadingMore: say({ key: "views.picker.loading-more" }),
|
|
45
48
|
chosen: (count) => say({ key: "views.picker.chosen", values: { count } }),
|
|
46
49
|
clearAll: say({ key: "views.picker.clear-all" }),
|
|
@@ -21,6 +21,12 @@ export interface PickerWords {
|
|
|
21
21
|
create: (typed: string) => string;
|
|
22
22
|
/** A phone's bar's Create. */
|
|
23
23
|
createButton: string;
|
|
24
|
+
/** + Add's row, after the matches (`onAdd`). */
|
|
25
|
+
add: (typed: string) => string;
|
|
26
|
+
/** + Add's row while the app answers. */
|
|
27
|
+
adding: (typed: string) => string;
|
|
28
|
+
/** A phone's bar's + Add. */
|
|
29
|
+
addButton: string;
|
|
24
30
|
loadingMore: string;
|
|
25
31
|
chosen: (count: number) => string;
|
|
26
32
|
clearAll: string;
|
|
@@ -69,6 +75,14 @@ export interface PickerProps {
|
|
|
69
75
|
search?: string;
|
|
70
76
|
/** Takes new values: handed what was typed, it makes the value and returns it, which is then picked. */
|
|
71
77
|
onCreate?: (typed: string) => string;
|
|
78
|
+
/** Asks the app to add what was typed (ViewKit's + Add): offered where Create is, a row after the matches reading Add “word”
|
|
79
|
+
* (on a phone the bar's Add), which picks nothing: the app's option comes back in `items` and is picked by its holder.
|
|
80
|
+
* Handed instead of `onCreate`. */
|
|
81
|
+
onAdd?: (typed: string) => void;
|
|
82
|
+
/** The add in flight, its word: its row reads Adding “word”… and can't be pressed, whatever is typed. */
|
|
83
|
+
adding?: string;
|
|
84
|
+
/** The last add refused, or failed: the app's words, shown where its row was until something else is typed. */
|
|
85
|
+
addRefused?: string;
|
|
72
86
|
/** The values come from the server: handed each query; `items` are its answer, shown as they are. */
|
|
73
87
|
onSearch?: (query: string) => void;
|
|
74
88
|
/** What the list is doing besides showing its rows. */
|
|
@@ -47,6 +47,9 @@ export const PICKER_WORDS = {
|
|
|
47
47
|
noneTyped: (typed) => `Nothing matches “${typed}”.`,
|
|
48
48
|
create: (typed) => `Create “${typed}”`,
|
|
49
49
|
createButton: "Create",
|
|
50
|
+
add: (typed) => `Add “${typed}”`,
|
|
51
|
+
adding: (typed) => `Adding “${typed}”…`,
|
|
52
|
+
addButton: "Add",
|
|
50
53
|
loadingMore: "Loading more…",
|
|
51
54
|
chosen: (count) => `${count} chosen`,
|
|
52
55
|
clearAll: "Clear all",
|
|
@@ -182,6 +185,7 @@ function usePickerAt(props, under) {
|
|
|
182
185
|
const w = { ...PICKER_WORDS, ...props.words };
|
|
183
186
|
const menuWords = { ...props.menuWords, ...(props.words ? { picker: props.words } : {}) };
|
|
184
187
|
const onValueChange = readOnly ? () => { } : props.onValueChange, onCreate = readOnly ? undefined : props.onCreate;
|
|
188
|
+
const onAdd = readOnly ? undefined : props.onAdd, add = !!onAdd, adding = onAdd ? props.adding : undefined;
|
|
185
189
|
const host = React.useContext(PhoneHost), small = usePhone();
|
|
186
190
|
const form = props.form ?? (host || small ? "phone" : "computer");
|
|
187
191
|
const inBox = under?.searchIn === "box", inBoxNow = React.useRef(inBox);
|
|
@@ -313,10 +317,18 @@ function usePickerAt(props, under) {
|
|
|
313
317
|
setAhead(heldNow.current); }, [props.firstFollows, heldKey]);
|
|
314
318
|
const listFirst = !!multiple && worn.picked === "first" && form === "computer";
|
|
315
319
|
const firstOnes = new Set(listFirst && !find.trim() ? ahead : []);
|
|
316
|
-
const server = !!onSearch, create = !!onCreate, own = (props.draft ?? "own") === "own";
|
|
320
|
+
const server = !!onSearch, create = !!onCreate || add, own = (props.draft ?? "own") === "own";
|
|
317
321
|
const openPath = openLevels(items, opened);
|
|
318
322
|
const level = openPath[openPath.length - 1];
|
|
319
|
-
const
|
|
323
|
+
const found = doing ? [] : pickerRows({ items: listed, known: items, query: find, picked: held, empty: multiple ? undefined : empty, create, server, more: !!onMore, first: listFirst ? ahead : undefined, open: level ? openPath : undefined, levelRow: !byHolder });
|
|
324
|
+
const rows = adding === undefined ? found : (() => {
|
|
325
|
+
const out = found.filter((r) => r.kind !== "create"), at = out.findIndex((r) => r.kind === "more");
|
|
326
|
+
out.splice(at < 0 ? out.length : at, 0, { kind: "create", typed: adding });
|
|
327
|
+
return out;
|
|
328
|
+
})();
|
|
329
|
+
const [refusal, setRefusal] = React.useState(null);
|
|
330
|
+
React.useLayoutEffect(() => { setRefusal(onAdd && props.addRefused !== undefined ? { words: props.addRefused, typed: find.trim() } : null); }, [props.addRefused]);
|
|
331
|
+
const refused = refusal && adding === undefined && fold(refusal.typed) === fold(find.trim()) ? refusal.words : undefined;
|
|
320
332
|
const shown = inBox || !!level || (props.searchShown ?? (worn.search === "always" || searchShown({ count: items.length, create, server, query })));
|
|
321
333
|
const none = !items.length && !find && !!nothingYet;
|
|
322
334
|
typedNow.current = query;
|
|
@@ -349,7 +361,7 @@ function usePickerAt(props, under) {
|
|
|
349
361
|
if (added?.kind === "action")
|
|
350
362
|
return added.action.onSelect();
|
|
351
363
|
if (added?.kind === "create")
|
|
352
|
-
return onValueChange([...held, make(added.typed)]);
|
|
364
|
+
return onAdd ? onAdd(added.typed) : onValueChange([...held, make(added.typed)]);
|
|
353
365
|
onValueChange(next.filter((e) => e.kind === "item").map((e) => e.item.value));
|
|
354
366
|
if (inBox)
|
|
355
367
|
ask("");
|
|
@@ -369,6 +381,8 @@ function usePickerAt(props, under) {
|
|
|
369
381
|
return next.action.onSelect();
|
|
370
382
|
if (next.kind === "item" && next.item.disabled)
|
|
371
383
|
return;
|
|
384
|
+
if (next.kind === "create" && onAdd)
|
|
385
|
+
return onAdd(next.typed);
|
|
372
386
|
onValueChange(next.kind === "item" ? next.item.value : next.kind === "create" ? make(next.typed) : null);
|
|
373
387
|
onDone?.();
|
|
374
388
|
};
|
|
@@ -576,8 +590,12 @@ function usePickerAt(props, under) {
|
|
|
576
590
|
return (_jsxs("div", { className: "o-list-row o-smooth o-smooth-ease o-picker-parent", "data-parent": "", "aria-hidden": "true", children: [_jsx(Face, { item: r.item }), _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: _jsx(Name, { item: r.item }) }) })] }, "parent"));
|
|
577
591
|
if (r.kind === "empty")
|
|
578
592
|
return (_jsx(BaseCombobox.Item, { ref: keepsToItsList, value: { key: "empty", kind: "empty", label: r.label }, className: "o-list-row o-smooth o-smooth-ease o-list-clear o-picker-empty", "data-name": r.label, children: _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: r.label }) }) }, "empty"));
|
|
579
|
-
if (r.kind === "create")
|
|
580
|
-
return (
|
|
593
|
+
if (r.kind === "create" && refused !== undefined)
|
|
594
|
+
return (_jsx("div", { className: "o-picker-message", role: "alert", children: _jsx("span", { className: "o-picker-message-text", children: refused }) }, "create"));
|
|
595
|
+
if (r.kind === "create") {
|
|
596
|
+
const busy = adding !== undefined;
|
|
597
|
+
return (_jsxs(BaseCombobox.Item, { ref: foot ? staysInView : keepsToItsList, value: { key: "create", kind: "create", typed: r.typed }, disabled: busy, className: cx("o-list-row o-smooth o-smooth-ease o-list-clear o-picker-create", worn.create === "apart" && "o-picker-create-apart"), children: [busy ? _jsx(Spinner, { size: 16, label: "" }) : glyph(PLUS, "o-list-plus"), _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: around(add ? (busy ? w.adding(r.typed) : w.add(r.typed)) : w.create(r.typed), r.typed) }) })] }, "create"));
|
|
598
|
+
}
|
|
581
599
|
return _jsx(React.Fragment, {}, i);
|
|
582
600
|
};
|
|
583
601
|
const action = (a, foot = false) => (_jsxs(BaseCombobox.Item, { ref: foot ? staysInView : keepsToItsList, value: { key: `action:${a.id}`, kind: "action", action: a }, className: "o-list-row o-smooth o-smooth-ease o-picker-action", children: [_jsx("span", { className: "o-picker-icon", children: a.icon }), _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: a.label }) }), a.keys?.length ? _jsx(Kbd, { keys: a.keys }) : null] }, a.id));
|
|
@@ -722,6 +740,7 @@ function usePickerAt(props, under) {
|
|
|
722
740
|
const parent = listRows[0]?.kind === "parent" ? listRows[0] : undefined;
|
|
723
741
|
const rest = listRows.filter((r) => r.kind === "item" && !isKept(r.item.value));
|
|
724
742
|
const creatable = create && !!typed && !exactMatch(level?.level ?? items, query);
|
|
743
|
+
const addable = add && (adding !== undefined || (creatable && refused === undefined));
|
|
725
744
|
const leave = () => { setDraft(holdingNow.current); ask(""); onDone?.(); };
|
|
726
745
|
const createTyped = () => {
|
|
727
746
|
const v = make(typed);
|
|
@@ -786,10 +805,11 @@ function usePickerAt(props, under) {
|
|
|
786
805
|
const under = !!props.actionsUnder && !none;
|
|
787
806
|
const menu = under ? [] : actions.map((a) => ({ icon: a.icon, label: a.label, onSelect: a.onSelect }));
|
|
788
807
|
const underActions = under && !typed && actions.length > 0 && (_jsx("div", { className: "o-picker-under", children: actions.map((a) => _jsx(Button, { kind: "outline", size: "44", icon: a.icon, onClick: a.onSelect, children: a.label }, a.id)) }));
|
|
789
|
-
const showBar = !none && (pill || creatable || menu.length > 0 || (!!level && !byHolder));
|
|
808
|
+
const showBar = !none && (pill || creatable || addable || menu.length > 0 || (!!level && !byHolder));
|
|
790
809
|
const bar = showBar && (_jsxs("div", { className: "o-picker-bar", children: [level && !byHolder && _jsx(GlassButton, { "aria-label": w.back(level.label), icon: glyph(BACK), className: "o-picker-round", "data-back": "", onMouseDown: (e) => e.preventDefault(), onClick: () => back() }), pill && (_jsxs(InputGroup, { size: "lg", className: "o-picker-pill", ...pillTap, children: [_jsx(InputGroupAddon, { side: "start", children: glyph(SEARCH) }), _jsx(Input, { combobox: true, autofill: false, ref: pillInput, placeholder: search, "aria-label": search ?? label, onKeyDown: (e) => { if (!backKey(e))
|
|
791
|
-
enter(e); } })] })),
|
|
792
|
-
:
|
|
810
|
+
enter(e); } })] })), addable ? _jsx(Button, { kind: "primary", size: "lg", icon: glyph(PLUS), loading: adding !== undefined, className: "o-picker-create-button", onClick: () => onAdd(typed), children: w.addButton })
|
|
811
|
+
: creatable && !add ? _jsx(Button, { kind: "primary", size: "lg", icon: glyph(PLUS), className: "o-picker-create-button", onClick: createTyped, children: w.createButton })
|
|
812
|
+
: menu.length > 0 && _jsx(Menu, { label: label, entries: menu, words: menuWords, trigger: _jsx(GlassButton, { "aria-label": w.actions, icon: glyph(DOTS), className: "o-picker-round" }) })] }));
|
|
793
813
|
const menuOpen = (item) => (menuOpenFor(item.value) ? { "data-menu-open": "" } : {});
|
|
794
814
|
const heldHere = (v) => inPlace && kept.includes(v);
|
|
795
815
|
const rowValue = (item) => (heldHere(item.value) && !changing ? { key: `unpick:${item.value}`, kind: "unpick", item } : itemEntry(item));
|
|
@@ -804,7 +824,7 @@ function usePickerAt(props, under) {
|
|
|
804
824
|
return (_jsxs(BaseCombobox.Group, { className: "o-picker-group", children: [g.name && _jsx(BaseCombobox.GroupLabel, { className: "o-picker-label", children: g.name }), _jsx("div", { className: "o-picker-card o-picker-list", "data-heading": g.name || undefined, children: rows })] }, g.name || "-"));
|
|
805
825
|
});
|
|
806
826
|
})() : null;
|
|
807
|
-
const body = (_jsxs(BaseCombobox.Root, { inline: true, open: true, multiple: changing, value: (changing ? kept.map((v) => itemEntry(itemOf(v))) : held[0] != null ? { key: `unpick:${held[0]}`, kind: "unpick", item: itemOf(held[0]) } : null), onValueChange: (v, d) => tap(v, d), inputValue: query, onInputValueChange: ask, autoHighlight: true, itemToStringValue: (e) => e.key, itemToStringLabel: (e) => entryLabel(e), isItemEqualToValue: (a, b) => a.key === b.key, children: [_jsxs("div", { ref: placeRoot, className: "o-picker", "data-kit": "picker", "data-picker-form": "phone", ...phoneMark(!!host || small), "data-typed": typed ? "" : undefined, style: room ? { "--picker-room": `${room.height}px`, "--picker-under": `${room.under}px` } : undefined, children: [none ? (_jsxs("div", { className: "o-picker-note o-picker-first", children: [_jsxs("span", { children: [_jsx("b", { children: nothingYet.text }), nothingYet.line && _jsxs(_Fragment, { children: [_jsx("br", {}), nothingYet.line] })] }), _jsx(Button, { kind: "primary", size: "lg", icon: glyph(PLUS), onClick: nothingYet.onAction, children: nothingYet.action })] })) : (_jsxs(_Fragment, { children: [_jsxs(BaseCombobox.List, { className: "o-picker-phone", "aria-label": label, children: [keptItems.length > 0 && (_jsxs(BaseCombobox.Group, { className: "o-picker-group", children: [_jsx(BaseCombobox.GroupLabel, { className: "o-picker-label", children: label_ }), _jsx("div", { className: "o-picker-card o-picker-selected", children: keptItems.map((item, i) => (_jsx(BaseCombobox.Item, { ref: keepsToItsList, index: at(i, false), value: changing ? itemEntry(item) : { key: `unpick:${item.value}`, kind: "unpick", item }, className: "o-picker-row", ...menuOpen(item), children: _jsx(PhoneRow, { item: item, kind: worn.kind, you: w.you, circle: fixed ? "fixed" : "on", box: boxes, lead: changing && !own && props.lead ? _jsx(LeadMark, { lead: props.lead, value: item.value }) : undefined, menu: hasMenu(item) ? rowTrigger(item) : undefined }) }, item.value))) })] })), headed && !note && cards, !headed && (parent || (!note && rest.length > 0)) && (_jsxs("div", { className: "o-picker-card o-picker-list", children: [parent && _jsx("div", { className: "o-picker-row o-picker-parent", "data-parent": "", "aria-hidden": "true", children: _jsx(PhoneRow, { item: parent.item, kind: worn.kind, you: w.you, circle: null }) }), !note && rest.length > 0 && (parent ? _jsx("div", { className: "o-picker-level", children: listed }) : listed)] }))] }), note, underActions, onMore && !doing && _jsxs("div", { ref: more, className: "o-picker-more", children: [_jsx(Spinner, { size: 16, label: "" }), w.loadingMore] })] })), bar] }), rowMenuEl] }));
|
|
827
|
+
const body = (_jsxs(BaseCombobox.Root, { inline: true, open: true, multiple: changing, value: (changing ? kept.map((v) => itemEntry(itemOf(v))) : held[0] != null ? { key: `unpick:${held[0]}`, kind: "unpick", item: itemOf(held[0]) } : null), onValueChange: (v, d) => tap(v, d), inputValue: query, onInputValueChange: ask, autoHighlight: true, itemToStringValue: (e) => e.key, itemToStringLabel: (e) => entryLabel(e), isItemEqualToValue: (a, b) => a.key === b.key, children: [_jsxs("div", { ref: placeRoot, className: "o-picker", "data-kit": "picker", "data-picker-form": "phone", ...phoneMark(!!host || small), "data-typed": typed ? "" : undefined, style: room ? { "--picker-room": `${room.height}px`, "--picker-under": `${room.under}px` } : undefined, children: [none ? (_jsxs("div", { className: "o-picker-note o-picker-first", children: [_jsxs("span", { children: [_jsx("b", { children: nothingYet.text }), nothingYet.line && _jsxs(_Fragment, { children: [_jsx("br", {}), nothingYet.line] })] }), _jsx(Button, { kind: "primary", size: "lg", icon: glyph(PLUS), onClick: nothingYet.onAction, children: nothingYet.action })] })) : (_jsxs(_Fragment, { children: [_jsxs(BaseCombobox.List, { className: "o-picker-phone", "aria-label": label, children: [keptItems.length > 0 && (_jsxs(BaseCombobox.Group, { className: "o-picker-group", children: [_jsx(BaseCombobox.GroupLabel, { className: "o-picker-label", children: label_ }), _jsx("div", { className: "o-picker-card o-picker-selected", children: keptItems.map((item, i) => (_jsx(BaseCombobox.Item, { ref: keepsToItsList, index: at(i, false), value: changing ? itemEntry(item) : { key: `unpick:${item.value}`, kind: "unpick", item }, className: "o-picker-row", ...menuOpen(item), children: _jsx(PhoneRow, { item: item, kind: worn.kind, you: w.you, circle: fixed ? "fixed" : "on", box: boxes, lead: changing && !own && props.lead ? _jsx(LeadMark, { lead: props.lead, value: item.value }) : undefined, menu: hasMenu(item) ? rowTrigger(item) : undefined }) }, item.value))) })] })), headed && !note && cards, !headed && (parent || (!note && rest.length > 0)) && (_jsxs("div", { className: "o-picker-card o-picker-list", children: [parent && _jsx("div", { className: "o-picker-row o-picker-parent", "data-parent": "", "aria-hidden": "true", children: _jsx(PhoneRow, { item: parent.item, kind: worn.kind, you: w.you, circle: null }) }), !note && rest.length > 0 && (parent ? _jsx("div", { className: "o-picker-level", children: listed }) : listed)] }))] }), note, refused !== undefined && !doing && _jsx("div", { className: "o-picker-note", role: "alert", children: refused }), underActions, onMore && !doing && _jsxs("div", { ref: more, className: "o-picker-more", children: [_jsx(Spinner, { size: 16, label: "" }), w.loadingMore] })] })), bar] }), rowMenuEl] }));
|
|
808
828
|
const head = changing && own ? { left: _jsx(SheetButton, { onClick: leave, children: w.cancel }), right: _jsx(SheetButton, { kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: () => { onValueChange(draft); ask(""); onDone?.(); } }) }
|
|
809
829
|
: {};
|
|
810
830
|
return { body, head, step: changing && own ? "change" : null };
|
|
@@ -835,7 +855,7 @@ function usePickerAt(props, under) {
|
|
|
835
855
|
setListLit(byList);
|
|
836
856
|
};
|
|
837
857
|
const body = under ? (_jsxs(BaseCombobox.Root, { open: under.open, onOpenChange: (o, d) => {
|
|
838
|
-
if (!o && d.reason === "item-press" && litRow.current?.kind === "action") {
|
|
858
|
+
if (!o && d.reason === "item-press" && (litRow.current?.kind === "action" || (litRow.current?.kind === "create" && onAdd))) {
|
|
839
859
|
d.cancel();
|
|
840
860
|
return;
|
|
841
861
|
}
|
|
@@ -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 });
|
|
@@ -16,14 +16,15 @@ export interface RadioGroupProps extends Omit<React.ComponentProps<typeof BaseRa
|
|
|
16
16
|
}
|
|
17
17
|
/** Exactly one of a few choices, all of them in sight: its name, then its Radios. With a name, the group is a
|
|
18
18
|
* FieldSet, its name the legend (Base UI names the radio group by it). */
|
|
19
|
-
export declare function RadioGroup(
|
|
19
|
+
export declare function RadioGroup(props: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export interface RadioProps extends Omit<React.ComponentProps<typeof BaseRadio.Root>, "className"> {
|
|
21
21
|
/** The choice. Without one, give it an aria-label. */
|
|
22
22
|
label?: React.ReactNode;
|
|
23
23
|
/** A line under the label that explains it, or says why it is locked. */
|
|
24
24
|
note?: React.ReactNode;
|
|
25
25
|
/** Drawn as a card: an edge round the ring and its words, the whole card pressing it, the chosen one in
|
|
26
|
-
* 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). */
|
|
27
28
|
card?: boolean;
|
|
28
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
|
|
29
30
|
* the brand. Disabled, it stands dashed and greyed, with no line, and the arrows pass it by. */
|
|
@@ -36,5 +37,6 @@ export interface RadioProps extends Omit<React.ComponentProps<typeof BaseRadio.R
|
|
|
36
37
|
picture?: React.ReactNode;
|
|
37
38
|
className?: string;
|
|
38
39
|
}
|
|
39
|
-
/** 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. */
|
|
40
42
|
export declare const Radio: React.ForwardRefExoticComponent<Omit<RadioProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -4,13 +4,29 @@ 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
|
}
|
|
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" }) }));
|
|
14
30
|
export const Radio = React.forwardRef(function Radio({ label, note, card = false, mark, swatch, picture, className, ...props }, ref) {
|
|
15
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 })] }));
|
|
16
32
|
if (swatch != null) {
|
|
@@ -19,5 +35,5 @@ export const Radio = React.forwardRef(function Radio({ label, note, card = false
|
|
|
19
35
|
const pictured = picture != null, marked = mark != null || pictured;
|
|
20
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
|
|
21
37
|
? _jsx(BaseRadio.Root, { ref: ref, className: "o-radio-mark", ...props, children: mark })
|
|
22
|
-
: _jsx(BaseRadio.Root, { ref: ref, className: "o-radio-ring", ...props, children: _jsx(BaseRadio.Indicator, { keepMounted: true, className: "o-radio-dot" }) }), text] }));
|
|
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] }));
|
|
23
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";
|
|
@@ -78,6 +82,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
78
82
|
readonly name: "--vk-fg-subtle";
|
|
79
83
|
readonly kind: "colour";
|
|
80
84
|
readonly outright: "--text-subtle";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-fg-subtlest";
|
|
87
|
+
readonly kind: "colour";
|
|
88
|
+
readonly outright: "--text-subtlest";
|
|
81
89
|
}, {
|
|
82
90
|
readonly name: "--vk-focus-offset";
|
|
83
91
|
readonly kind: "size";
|
|
@@ -86,6 +94,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
86
94
|
readonly name: "--vk-focus-width";
|
|
87
95
|
readonly kind: "size";
|
|
88
96
|
readonly outright: "--focus-width";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "--vk-font-size-base";
|
|
99
|
+
readonly kind: "size";
|
|
100
|
+
readonly outright: "--text-base";
|
|
89
101
|
}, {
|
|
90
102
|
readonly name: "--vk-font-weight-medium";
|
|
91
103
|
readonly kind: "size";
|
|
@@ -106,30 +118,62 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
106
118
|
readonly name: "--vk-input";
|
|
107
119
|
readonly kind: "colour";
|
|
108
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";
|
|
109
129
|
}, {
|
|
110
130
|
readonly name: "--vk-label-amber-fill";
|
|
111
131
|
readonly kind: "colour";
|
|
112
132
|
readonly outright: "--label-amber-fill";
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "--vk-label-blue";
|
|
135
|
+
readonly kind: "colour";
|
|
136
|
+
readonly outright: "--label-blue";
|
|
113
137
|
}, {
|
|
114
138
|
readonly name: "--vk-label-blue-fill";
|
|
115
139
|
readonly kind: "colour";
|
|
116
140
|
readonly outright: "--label-blue-fill";
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "--vk-label-green";
|
|
143
|
+
readonly kind: "colour";
|
|
144
|
+
readonly outright: "--label-green";
|
|
117
145
|
}, {
|
|
118
146
|
readonly name: "--vk-label-green-fill";
|
|
119
147
|
readonly kind: "colour";
|
|
120
148
|
readonly outright: "--label-green-fill";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "--vk-label-pink";
|
|
151
|
+
readonly kind: "colour";
|
|
152
|
+
readonly outright: "--label-pink";
|
|
121
153
|
}, {
|
|
122
154
|
readonly name: "--vk-label-pink-fill";
|
|
123
155
|
readonly kind: "colour";
|
|
124
156
|
readonly outright: "--label-pink-fill";
|
|
157
|
+
}, {
|
|
158
|
+
readonly name: "--vk-label-purple";
|
|
159
|
+
readonly kind: "colour";
|
|
160
|
+
readonly outright: "--label-purple";
|
|
125
161
|
}, {
|
|
126
162
|
readonly name: "--vk-label-purple-fill";
|
|
127
163
|
readonly kind: "colour";
|
|
128
164
|
readonly outright: "--label-purple-fill";
|
|
165
|
+
}, {
|
|
166
|
+
readonly name: "--vk-label-red";
|
|
167
|
+
readonly kind: "colour";
|
|
168
|
+
readonly outright: "--label-red";
|
|
129
169
|
}, {
|
|
130
170
|
readonly name: "--vk-label-red-fill";
|
|
131
171
|
readonly kind: "colour";
|
|
132
172
|
readonly outright: "--label-red-fill";
|
|
173
|
+
}, {
|
|
174
|
+
readonly name: "--vk-label-teal";
|
|
175
|
+
readonly kind: "colour";
|
|
176
|
+
readonly outright: "--label-teal";
|
|
133
177
|
}, {
|
|
134
178
|
readonly name: "--vk-label-teal-fill";
|
|
135
179
|
readonly kind: "colour";
|
|
@@ -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" },
|
|
@@ -19,19 +20,29 @@ export const RADIO_TOKENS = [
|
|
|
19
20
|
{ name: "--vk-fg-inverse", kind: "colour", outright: "--text-inverse" },
|
|
20
21
|
{ name: "--vk-fg-on-brand", kind: "colour", outright: "--text-brand-inverse" },
|
|
21
22
|
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
23
|
+
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
22
24
|
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
23
25
|
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
26
|
+
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
24
27
|
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
25
28
|
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
26
29
|
{ name: "--vk-ground", kind: "colour", outright: "--surface" },
|
|
27
30
|
{ name: "--vk-hovered", kind: "colour", outright: "--surface-hovered" },
|
|
28
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" },
|
|
29
34
|
{ name: "--vk-label-amber-fill", kind: "colour", outright: "--label-amber-fill" },
|
|
35
|
+
{ name: "--vk-label-blue", kind: "colour", outright: "--label-blue" },
|
|
30
36
|
{ name: "--vk-label-blue-fill", kind: "colour", outright: "--label-blue-fill" },
|
|
37
|
+
{ name: "--vk-label-green", kind: "colour", outright: "--label-green" },
|
|
31
38
|
{ name: "--vk-label-green-fill", kind: "colour", outright: "--label-green-fill" },
|
|
39
|
+
{ name: "--vk-label-pink", kind: "colour", outright: "--label-pink" },
|
|
32
40
|
{ name: "--vk-label-pink-fill", kind: "colour", outright: "--label-pink-fill" },
|
|
41
|
+
{ name: "--vk-label-purple", kind: "colour", outright: "--label-purple" },
|
|
33
42
|
{ name: "--vk-label-purple-fill", kind: "colour", outright: "--label-purple-fill" },
|
|
43
|
+
{ name: "--vk-label-red", kind: "colour", outright: "--label-red" },
|
|
34
44
|
{ name: "--vk-label-red-fill", kind: "colour", outright: "--label-red-fill" },
|
|
45
|
+
{ name: "--vk-label-teal", kind: "colour", outright: "--label-teal" },
|
|
35
46
|
{ name: "--vk-label-teal-fill", kind: "colour", outright: "--label-teal-fill" },
|
|
36
47
|
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
37
48
|
{ name: "--vk-overlay-card", kind: "colour", outright: "--surface-overlay-card" },
|
|
@@ -149,5 +149,83 @@
|
|
|
149
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); }
|
|
150
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); }
|
|
151
151
|
|
|
152
|
-
|
|
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; } }
|
|
153
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. */
|
|
@@ -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";
|
|
@@ -81,7 +81,7 @@ function PickerSelect(p) {
|
|
|
81
81
|
if (placed.open !== open)
|
|
82
82
|
setPlaced({ open, side: open ? sideAsItOpens(p, f, box) : p.side ?? "bottom" });
|
|
83
83
|
const side = placed.side;
|
|
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:
|
|
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() })] }));
|
|
85
85
|
}
|
|
86
86
|
function TypedBox({ p, f, trigger, field, hint, search }) {
|
|
87
87
|
const { multiple, disabled } = p, q = search.typed, mark = phoneMark(usePhoneForm());
|
|
@@ -194,8 +194,14 @@ function useField({ multiple, defaultValue, value: outside, onValueChange, items
|
|
|
194
194
|
return { items, add, value, setValue, chosen, id: React.useId() };
|
|
195
195
|
}
|
|
196
196
|
const sized = (size) => size && size !== "md" && `o-input-${size}`;
|
|
197
|
-
|
|
198
|
-
|
|
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);
|
|
199
205
|
return label != null || note != null || (error != null && error !== "")
|
|
200
206
|
? _jsx(Field, { label: label, note: note, error: error, disabled: disabled, nativeLabel: !!typed, labelId: `${id}-label`, className: cls, children: children })
|
|
201
207
|
: _jsx("div", { className: cls, children: children });
|
|
@@ -221,7 +227,7 @@ function AloneSelect({ opens, shown, open = false, onOpenChange, placeholder = "
|
|
|
221
227
|
onOpenChange?.(true);
|
|
222
228
|
} };
|
|
223
229
|
const empty = shown == null || shown === "" || shown === false;
|
|
224
|
-
return (_jsx(Labelled, { ...p, id: id, children: _jsxs(BaseField.Control, { render: _jsx("button", { type: "button" }), ref: own, disabled: p.disabled, className:
|
|
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 })
|
|
225
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], "") })] }) }));
|
|
226
232
|
}
|
|
227
233
|
export function SelectShown({ items, defaultValue, multiple, chips, search, none, placeholder = "Choose", "aria-label": name }) {
|
|
@@ -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";
|