viewkitjs 0.30.1 → 0.31.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 +14 -0
- package/package.json +4 -2
- 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 +60 -0
- package/views/dist/controls/avatar/tokens.js +15 -0
- package/views/dist/controls/avatar.css +29 -15
- package/views/dist/controls/index.d.ts +3 -2
- package/views/dist/controls/index.js +2 -1
- package/views/dist/controls/input/input.d.ts +12 -1
- package/views/dist/controls/input/input.js +7 -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 +16 -0
- package/views/dist/controls/input/tokens.js +4 -0
- package/views/dist/controls/input.css +18 -0
- package/views/dist/controls/radio/radio.d.ts +7 -0
- package/views/dist/controls/radio/radio.js +8 -4
- package/views/dist/controls/radio/tokens.d.ts +40 -0
- package/views/dist/controls/radio/tokens.js +10 -0
- package/views/dist/controls/radio.css +52 -3
- package/views/dist/controls/select/select.d.ts +8 -2
- package/views/dist/controls/select/select.js +6 -4
- package/views/dist/controls/setting-row/looks.d.ts +10 -0
- package/views/dist/controls/setting-row/looks.js +17 -0
- package/views/dist/controls/setting-row/setting-row.d.ts +65 -0
- package/views/dist/controls/setting-row/setting-row.js +66 -0
- package/views/dist/controls/setting-row/tokens.d.ts +84 -0
- package/views/dist/controls/setting-row/tokens.js +23 -0
- package/views/dist/controls/setting-row.css +94 -0
- 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/tokens.js +2 -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/styles.css +182 -19
- package/views/dist/styles.unlayered.css +182 -19
- package/views/docs/controls/avatar.md +15 -0
- package/views/docs/controls/input.md +8 -0
- package/views/docs/controls/radio.md +18 -0
- package/views/docs/controls/select.md +4 -0
- package/views/docs/controls/setting-row.md +26 -0
- package/views/docs/reference/controls.md +25 -8
- package/views/docs/reference/looks.md +3 -0
|
@@ -11,9 +11,13 @@ export function RadioGroup({ label, row = false, tiles = false, className, child
|
|
|
11
11
|
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
12
|
return label != null ? _jsx(FieldSet, { legend: label, disabled: props.disabled, className: className, children: group }) : group;
|
|
13
13
|
}
|
|
14
|
-
export const Radio = React.forwardRef(function Radio({ label, note, card = false, mark, className, ...props }, ref) {
|
|
15
|
-
const
|
|
16
|
-
|
|
14
|
+
export const Radio = React.forwardRef(function Radio({ label, note, card = false, mark, swatch, picture, className, ...props }, ref) {
|
|
15
|
+
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
|
+
if (swatch != null) {
|
|
17
|
+
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] }));
|
|
18
|
+
}
|
|
19
|
+
const pictured = picture != null, marked = mark != null || pictured;
|
|
20
|
+
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
21
|
? _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" }) }),
|
|
22
|
+
: _jsx(BaseRadio.Root, { ref: ref, className: "o-radio-ring", ...props, children: _jsx(BaseRadio.Indicator, { keepMounted: true, className: "o-radio-dot" }) }), text] }));
|
|
19
23
|
});
|
|
@@ -54,6 +54,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
54
54
|
readonly name: "--vk-ease-out";
|
|
55
55
|
readonly kind: "motion";
|
|
56
56
|
readonly outright: "--ease-out";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-fg";
|
|
59
|
+
readonly kind: "colour";
|
|
60
|
+
readonly outright: "--text";
|
|
57
61
|
}, {
|
|
58
62
|
readonly name: "--vk-fg-accent";
|
|
59
63
|
readonly kind: "colour";
|
|
@@ -82,6 +86,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
82
86
|
readonly name: "--vk-focus-width";
|
|
83
87
|
readonly kind: "size";
|
|
84
88
|
readonly outright: "--focus-width";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "--vk-font-weight-medium";
|
|
91
|
+
readonly kind: "size";
|
|
92
|
+
readonly outright: "--font-weight-medium";
|
|
85
93
|
}, {
|
|
86
94
|
readonly name: "--vk-font-weight-normal";
|
|
87
95
|
readonly kind: "size";
|
|
@@ -98,6 +106,34 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
98
106
|
readonly name: "--vk-input";
|
|
99
107
|
readonly kind: "colour";
|
|
100
108
|
readonly outright: "--background-input";
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "--vk-label-amber-fill";
|
|
111
|
+
readonly kind: "colour";
|
|
112
|
+
readonly outright: "--label-amber-fill";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "--vk-label-blue-fill";
|
|
115
|
+
readonly kind: "colour";
|
|
116
|
+
readonly outright: "--label-blue-fill";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "--vk-label-green-fill";
|
|
119
|
+
readonly kind: "colour";
|
|
120
|
+
readonly outright: "--label-green-fill";
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "--vk-label-pink-fill";
|
|
123
|
+
readonly kind: "colour";
|
|
124
|
+
readonly outright: "--label-pink-fill";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "--vk-label-purple-fill";
|
|
127
|
+
readonly kind: "colour";
|
|
128
|
+
readonly outright: "--label-purple-fill";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "--vk-label-red-fill";
|
|
131
|
+
readonly kind: "colour";
|
|
132
|
+
readonly outright: "--label-red-fill";
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "--vk-label-teal-fill";
|
|
135
|
+
readonly kind: "colour";
|
|
136
|
+
readonly outright: "--label-teal-fill";
|
|
101
137
|
}, {
|
|
102
138
|
readonly name: "--vk-neutral";
|
|
103
139
|
readonly kind: "colour";
|
|
@@ -114,6 +150,10 @@ export declare const RADIO_TOKENS: readonly [{
|
|
|
114
150
|
readonly name: "--vk-radius-lg";
|
|
115
151
|
readonly kind: "size";
|
|
116
152
|
readonly outright: "--radius-lg";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "--vk-radius-sm";
|
|
155
|
+
readonly kind: "size";
|
|
156
|
+
readonly outright: "--radius-sm";
|
|
117
157
|
}, {
|
|
118
158
|
readonly name: "--vk-radius-xl";
|
|
119
159
|
readonly kind: "size";
|
|
@@ -13,6 +13,7 @@ export const RADIO_TOKENS = [
|
|
|
13
13
|
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
14
14
|
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
15
15
|
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
16
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
16
17
|
{ name: "--vk-fg-accent", kind: "colour", outright: "--text-brand" },
|
|
17
18
|
{ name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
|
|
18
19
|
{ name: "--vk-fg-inverse", kind: "colour", outright: "--text-inverse" },
|
|
@@ -20,14 +21,23 @@ export const RADIO_TOKENS = [
|
|
|
20
21
|
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
21
22
|
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
22
23
|
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
24
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
23
25
|
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
24
26
|
{ name: "--vk-ground", kind: "colour", outright: "--surface" },
|
|
25
27
|
{ name: "--vk-hovered", kind: "colour", outright: "--surface-hovered" },
|
|
26
28
|
{ name: "--vk-input", kind: "colour", outright: "--background-input" },
|
|
29
|
+
{ name: "--vk-label-amber-fill", kind: "colour", outright: "--label-amber-fill" },
|
|
30
|
+
{ name: "--vk-label-blue-fill", kind: "colour", outright: "--label-blue-fill" },
|
|
31
|
+
{ name: "--vk-label-green-fill", kind: "colour", outright: "--label-green-fill" },
|
|
32
|
+
{ name: "--vk-label-pink-fill", kind: "colour", outright: "--label-pink-fill" },
|
|
33
|
+
{ name: "--vk-label-purple-fill", kind: "colour", outright: "--label-purple-fill" },
|
|
34
|
+
{ name: "--vk-label-red-fill", kind: "colour", outright: "--label-red-fill" },
|
|
35
|
+
{ name: "--vk-label-teal-fill", kind: "colour", outright: "--label-teal-fill" },
|
|
27
36
|
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
28
37
|
{ name: "--vk-overlay-card", kind: "colour", outright: "--surface-overlay-card" },
|
|
29
38
|
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
30
39
|
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
40
|
+
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
31
41
|
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
32
42
|
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
33
43
|
];
|
|
@@ -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,61 @@
|
|
|
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
|
-
@media (prefers-reduced-motion: reduce) { .o-radio-ring, .o-radio-dot, .o-radio-mark { transition: none; } }
|
|
152
|
+
@media (prefers-reduced-motion: reduce) { .o-radio-ring, .o-radio-dot, .o-radio-mark, .o-radio-swatch { transition: none; } }
|
|
104
153
|
}
|
|
@@ -36,8 +36,14 @@ interface SelectFieldProps {
|
|
|
36
36
|
disabled?: boolean;
|
|
37
37
|
"aria-label"?: string;
|
|
38
38
|
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";
|
|
39
|
+
/** The field drawn as under the pointer or in focus, as a page that shows it draws it; saved, its Saved held. */
|
|
40
|
+
"data-force"?: "hover" | "focus" | "saved";
|
|
41
|
+
/** The app saving what was picked (VK-921): the Spinner at the field's end, before its chevron, the field busy. It wins
|
|
42
|
+
* over saved. */
|
|
43
|
+
saving?: boolean;
|
|
44
|
+
/** The save took: a check and Saved before the chevron, fading after --vk-saved-hold and then gone; a save that fails is
|
|
45
|
+
* the error instead. */
|
|
46
|
+
saved?: boolean;
|
|
41
47
|
}
|
|
42
48
|
/** 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
49
|
* 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
|
|
@@ -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: cx("o-input o-select-field o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-kit": "select", ...mark, ...fieldAria(p, f.id), children: [_jsx("span", { id: `${f.id}-value`, className: "contents", children: _jsx(Value, { chosen: f.chosen, multiple: multiple, chips: chips, placeholder: placeholder }) }), _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
|
+
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: cx("o-input o-select-field o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-kit": "select", ...mark, ...fieldAria(p, f.id), ...busy(p), children: [_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) {
|
|
@@ -200,6 +201,7 @@ function Labelled({ label, note, error, id, size, typed, disabled, className, ch
|
|
|
200
201
|
: _jsx("div", { className: cls, children: children });
|
|
201
202
|
}
|
|
202
203
|
const fieldAria = (p, id) => (p.label != null ? { "aria-labelledby": `${id}-label ${id}-value` } : { "aria-label": p["aria-label"] });
|
|
204
|
+
const busy = (p) => (p.saving ? { "aria-busy": true } : {});
|
|
203
205
|
const ARROWS = { down: CHEVRON, right: ["M9 6l6 6l-6 6"] };
|
|
204
206
|
function AloneSelect({ opens, shown, open = false, onOpenChange, placeholder = "Choose", arrow = "down", ...p }) {
|
|
205
207
|
const id = React.useId(), own = React.useRef(null), pressedOpen = React.useRef(false), mark = phoneMark(usePhoneForm());
|
|
@@ -219,8 +221,8 @@ function AloneSelect({ opens, shown, open = false, onOpenChange, placeholder = "
|
|
|
219
221
|
onOpenChange?.(true);
|
|
220
222
|
} };
|
|
221
223
|
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: cx("o-input o-select-field o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-kit": "select", ...mark, ...fieldAria(p, id), "aria-haspopup": opens, "aria-expanded": open, "data-popup-open": open ? "" : undefined, onClick: press, onKeyDown: keys, children: [_jsx("span", { id: `${id}-value`, className: "contents", children: empty ? _jsx("span", { className: "o-select-value o-select-placeholder", children: placeholder })
|
|
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], "") })] }) }));
|
|
224
|
+
return (_jsx(Labelled, { ...p, id: id, children: _jsxs(BaseField.Control, { render: _jsx("button", { type: "button" }), ref: own, disabled: p.disabled, className: cx("o-input o-select-field o-smooth o-smooth-ease", sized(p.size)), "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: [_jsx("span", { id: `${id}-value`, className: "contents", children: empty ? _jsx("span", { className: "o-select-value o-select-placeholder", children: placeholder })
|
|
225
|
+
: _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
226
|
}
|
|
225
227
|
export function SelectShown({ items, defaultValue, multiple, chips, search, none, placeholder = "Choose", "aria-label": name }) {
|
|
226
228
|
const [value, setValue] = React.useState(defaultValue ?? (multiple ? [] : null));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
export type SettingRowOptionId = "card" | "rows";
|
|
3
|
+
/** One value for every option. */
|
|
4
|
+
export type SettingRowPicks = Record<SettingRowOptionId, string>;
|
|
5
|
+
/** The setting row's options and looks. */
|
|
6
|
+
export declare const SETTING_ROW_LOOKS: PieceLooks<SettingRowOptionId>;
|
|
7
|
+
/** The options worn round `el`, each from the nearest frame that picks it; outside any frame, or a value it lacks, its default. */
|
|
8
|
+
export declare function settingRowWornOf(el: Element | null): SettingRowPicks;
|
|
9
|
+
/** The attributes the setting rows' options are set by. */
|
|
10
|
+
export declare const SETTING_ROW_ATTRS: string[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { lookWornOf } from "../../looks/looks.js";
|
|
2
|
+
const OUTRIGHT = { card: "outlined", rows: "snug" };
|
|
3
|
+
const ATTIO = { card: "raised", rows: "roomy" };
|
|
4
|
+
const options = [
|
|
5
|
+
{ id: "card", name: "Card", device: "desktop", def: OUTRIGHT.card, values: [{ id: "outlined", name: "Outlined" }, { id: "raised", name: "Raised" }] },
|
|
6
|
+
{ id: "rows", name: "Rows", device: "desktop", def: OUTRIGHT.rows, values: [{ id: "snug", name: "Snug" }, { id: "roomy", name: "Roomy" }] },
|
|
7
|
+
];
|
|
8
|
+
const looks = [
|
|
9
|
+
{ id: "outright", name: "Outright", picks: OUTRIGHT },
|
|
10
|
+
{ id: "attio", name: "Attio", picks: ATTIO },
|
|
11
|
+
];
|
|
12
|
+
export const SETTING_ROW_LOOKS = { id: "setting-row", name: "Setting row", options, looks };
|
|
13
|
+
const IDS = options.map((o) => o.id);
|
|
14
|
+
export function settingRowWornOf(el) {
|
|
15
|
+
return lookWornOf(SETTING_ROW_LOOKS, el, IDS);
|
|
16
|
+
}
|
|
17
|
+
export const SETTING_ROW_ATTRS = IDS.map((id) => `data-setting-row-${id}`);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type SelectListProps } from "../select/select.js";
|
|
3
|
+
import { type SwitchProps } from "../switch/switch.js";
|
|
4
|
+
/** A setting row's button: its words, an icon before them, what a press does. */
|
|
5
|
+
export interface SettingAction {
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: React.ReactNode;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface SettingRowBase {
|
|
12
|
+
/** The setting's name ("Weekly digest"). */
|
|
13
|
+
label: React.ReactNode;
|
|
14
|
+
/** The line under its name: what it does. */
|
|
15
|
+
note?: React.ReactNode;
|
|
16
|
+
/** An icon, standing in a 32 box at the row's start. */
|
|
17
|
+
icon?: React.ReactNode;
|
|
18
|
+
/** A mark at the row's start, as given (Google's, a team's letter). */
|
|
19
|
+
mark?: React.ReactNode;
|
|
20
|
+
/** Why it can't change: its control is shut, and this stands before it (on a phone, in place of its line). */
|
|
21
|
+
locked?: React.ReactNode;
|
|
22
|
+
/** A lone row: one action on its own, bare, with no card. */
|
|
23
|
+
alone?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
type No<K extends string> = {
|
|
27
|
+
[P in K]?: never;
|
|
28
|
+
};
|
|
29
|
+
export type SettingRowProps = SettingRowBase & (({
|
|
30
|
+
switch: Omit<SwitchProps, "locked">;
|
|
31
|
+
} & No<"select" | "action" | "onOpen" | "value">) | ({
|
|
32
|
+
select: Omit<SelectListProps, "label" | "size">;
|
|
33
|
+
} & No<"switch" | "action" | "onOpen" | "value">) | ({
|
|
34
|
+
action: SettingAction;
|
|
35
|
+
} & No<"switch" | "select" | "onOpen" | "value">) | ({
|
|
36
|
+
onOpen: () => void;
|
|
37
|
+
value?: React.ReactNode;
|
|
38
|
+
} & No<"switch" | "select" | "action">));
|
|
39
|
+
export interface SettingRowsProps {
|
|
40
|
+
/** The danger zone's: a red edge, each row's button the Button's danger kind, on a phone its names red. */
|
|
41
|
+
danger?: boolean;
|
|
42
|
+
/** Its form: the device's unless told (a PhoneHost screen, or below the app's line, is a phone's). */
|
|
43
|
+
form?: "computer" | "phone";
|
|
44
|
+
className?: string;
|
|
45
|
+
children: React.ReactNode;
|
|
46
|
+
}
|
|
47
|
+
/** Settings rows in a card, a line between each; `danger` the danger zone's. On a phone, Field rows' card. */
|
|
48
|
+
export declare function SettingRows({ danger, form, className, children }: SettingRowsProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
/** One setting as a row: its name and its line, its control at its end. */
|
|
50
|
+
export declare function SettingRow(props: SettingRowProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
/** A setting with a switch: the setting row's switch kind, its words pressing the Switch. */
|
|
52
|
+
export interface SwitchRowProps extends SwitchProps {
|
|
53
|
+
/** The setting's name ("Daily summary"), not the action. */
|
|
54
|
+
label: React.ReactNode;
|
|
55
|
+
/** A line under it: what it does, or why it is locked. */
|
|
56
|
+
note?: React.ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/** A setting in a settings list: its name and a line on the left, the switch on the right; the whole row presses it. */
|
|
59
|
+
export declare function SwitchRow({ label, note, locked, ...props }: SwitchRowProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
/** Settings rows in a bordered box, a line between each: the setting rows' card in its computer form on every device. */
|
|
61
|
+
export declare function SwitchRows({ className, children }: {
|
|
62
|
+
className?: string;
|
|
63
|
+
children: React.ReactNode;
|
|
64
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cx } from "../../internal/cx.js";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
6
|
+
import { Select } from "../select/select.js";
|
|
7
|
+
import { Switch } from "../switch/switch.js";
|
|
8
|
+
const Rows = React.createContext(null);
|
|
9
|
+
const CHEVRON = (_jsx("svg", { className: "o-setting-row-chevron", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M6 3.5 10.5 8 6 12.5" }) }));
|
|
10
|
+
export function SettingRows({ danger = false, form, className, children }) {
|
|
11
|
+
const phone = usePhoneForm(form);
|
|
12
|
+
return (_jsx("div", { className: cx("o-setting-rows o-smooth o-smooth-ease", danger && "o-setting-rows-danger", phone && "o-field-rows", className), "data-kit": "setting-row", ...phoneMark(phone), children: _jsx(Rows.Provider, { value: { danger, phone }, children: children }) }));
|
|
13
|
+
}
|
|
14
|
+
export function SettingRow(props) {
|
|
15
|
+
const rows = React.useContext(Rows), phone = !!rows?.phone && !props.alone, danger = !!rows?.danger;
|
|
16
|
+
const { label, note, icon, mark, locked, alone, className } = props;
|
|
17
|
+
const shut = locked != null && locked !== false;
|
|
18
|
+
const reason = shut && locked !== true ? locked : null;
|
|
19
|
+
const kind = props.switch ? "switch" : props.select ? "select" : props.action ? "action" : "open";
|
|
20
|
+
const root = { className: cx("o-setting-row", phone && "o-field-row", props.switch && "o-switch-row", className), "data-setting-row-kind": kind,
|
|
21
|
+
"data-locked": shut ? "" : undefined, "data-alone": alone ? "" : undefined };
|
|
22
|
+
const start = mark ?? (icon != null ? _jsx("span", { className: "o-setting-row-icon", "aria-hidden": "true", children: icon }) : null);
|
|
23
|
+
const line = phone && reason != null ? reason : note;
|
|
24
|
+
const words = (_jsxs("span", { className: "o-choice-text", children: [_jsx("span", { className: "o-choice-label", children: label }), line != null && _jsx("span", { className: "o-choice-note", children: line })] }));
|
|
25
|
+
const why = !phone && reason != null ? _jsx("span", { className: "o-setting-row-reason", children: reason }) : null;
|
|
26
|
+
const name = typeof label === "string" ? label : undefined;
|
|
27
|
+
if (props.switch) {
|
|
28
|
+
return _jsxs("label", { ...root, children: [start, words, why, _jsx(Switch, { ...props.switch, locked: shut })] });
|
|
29
|
+
}
|
|
30
|
+
if (props.select)
|
|
31
|
+
return _jsx(SelectRow, { root: root, start: start, words: words, why: why, name: name, select: props.select, shut: shut, phone: phone });
|
|
32
|
+
if (props.action) {
|
|
33
|
+
const a = props.action;
|
|
34
|
+
if (phone)
|
|
35
|
+
return _jsxs("button", { type: "button", ...root, disabled: shut || a.disabled, onClick: a.onClick, children: [start, words] });
|
|
36
|
+
return (_jsxs("div", { ...root, children: [start, words, _jsxs("span", { className: "o-setting-row-end", children: [why, _jsx(Button, { kind: danger ? "danger" : "outline", size: "sm", icon: a.icon, disabled: shut || a.disabled, onClick: a.onClick, children: a.label })] })] }));
|
|
37
|
+
}
|
|
38
|
+
return (_jsxs("button", { type: "button", ...root, disabled: shut, onClick: shut ? undefined : props.onOpen, children: [start, words, _jsxs("span", { className: "o-setting-row-end", children: [why, props.value != null && _jsx("span", { className: "o-setting-row-value", children: props.value }), CHEVRON] })] }));
|
|
39
|
+
}
|
|
40
|
+
const firstOf = (v) => (Array.isArray(v) ? v : v == null ? [] : [v]);
|
|
41
|
+
function SelectRow({ root, start, words, why, name, select, shut, phone }) {
|
|
42
|
+
const [own, setOwn] = React.useState(select.defaultValue ?? null), [open, setOpen] = React.useState(false);
|
|
43
|
+
const value = select.value !== undefined ? select.value : own;
|
|
44
|
+
const changed = (v) => { setOwn(v); select.onValueChange?.(v); };
|
|
45
|
+
const field = _jsx(Select, { ...select, value: value, onValueChange: changed, size: "md", disabled: shut || select.disabled, "aria-label": select["aria-label"] ?? name, className: cx("o-setting-row-select", select.className), ...(phone ? { open, onOpenChange: setOpen } : {}) });
|
|
46
|
+
if (!phone)
|
|
47
|
+
return _jsxs("div", { ...root, children: [start, words, _jsxs("span", { className: "o-setting-row-end", children: [why, field] })] });
|
|
48
|
+
const shown = firstOf(value).map((v) => findItem(select.items, v)?.label ?? v);
|
|
49
|
+
return (_jsxs("div", { ...root, children: [_jsxs("button", { type: "button", className: "o-setting-row-press", disabled: shut || select.disabled, onClick: () => setOpen(true), children: [start, words, _jsxs("span", { className: "o-setting-row-end", children: [shown.length > 0 && _jsx("span", { className: "o-setting-row-value", children: shown.join(", ") }), CHEVRON] })] }), _jsx("span", { hidden: true, children: field })] }));
|
|
50
|
+
}
|
|
51
|
+
const findItem = (items, v) => {
|
|
52
|
+
for (const i of items) {
|
|
53
|
+
if (i.value === v)
|
|
54
|
+
return i;
|
|
55
|
+
const deep = i.level && findItem(i.level, v);
|
|
56
|
+
if (deep)
|
|
57
|
+
return deep;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
};
|
|
61
|
+
export function SwitchRow({ label, note, locked, ...props }) {
|
|
62
|
+
return _jsx(SettingRow, { label: label, note: note, locked: locked || undefined, switch: props });
|
|
63
|
+
}
|
|
64
|
+
export function SwitchRows({ className, children }) {
|
|
65
|
+
return _jsx(SettingRows, { form: "computer", className: cx("o-switch-rows", className), children: children });
|
|
66
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export declare const SETTING_ROW_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--border";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-border-subtle";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--border-subtle";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-border-danger";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--border-danger";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-hovered";
|
|
15
|
+
readonly kind: "colour";
|
|
16
|
+
readonly outright: "--surface-hovered";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-raised";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--surface-raised";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-danger";
|
|
23
|
+
readonly kind: "colour";
|
|
24
|
+
readonly outright: "--text-danger";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-fg-subtle";
|
|
27
|
+
readonly kind: "colour";
|
|
28
|
+
readonly outright: "--text-subtle";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-fg-subtlest";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--text-subtlest";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-border-width";
|
|
35
|
+
readonly kind: "size";
|
|
36
|
+
readonly outright: "--border-width";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-corner-smoothing";
|
|
39
|
+
readonly kind: "size";
|
|
40
|
+
readonly outright: "--corner-smoothing";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-font-size-sm";
|
|
43
|
+
readonly kind: "size";
|
|
44
|
+
readonly outright: "--text-sm";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-font-size-xs";
|
|
47
|
+
readonly kind: "size";
|
|
48
|
+
readonly outright: "--text-xs";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-font-weight-medium";
|
|
51
|
+
readonly kind: "size";
|
|
52
|
+
readonly outright: "--font-weight-medium";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-line-height-sm";
|
|
55
|
+
readonly kind: "size";
|
|
56
|
+
readonly outright: "--text-sm--line-height";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-line-height-xs";
|
|
59
|
+
readonly kind: "size";
|
|
60
|
+
readonly outright: "--text-xs--line-height";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-radius-lg";
|
|
63
|
+
readonly kind: "size";
|
|
64
|
+
readonly outright: "--radius-lg";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-radius-md";
|
|
67
|
+
readonly kind: "size";
|
|
68
|
+
readonly outright: "--radius-md";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-spacing";
|
|
71
|
+
readonly kind: "size";
|
|
72
|
+
readonly outright: "--spacing";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-duration-fast";
|
|
75
|
+
readonly kind: "motion";
|
|
76
|
+
readonly outright: "--duration-fast";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-ease-out";
|
|
79
|
+
readonly kind: "motion";
|
|
80
|
+
readonly outright: "--ease-out";
|
|
81
|
+
}];
|
|
82
|
+
/** The card's own machinery: its edge and ground by the card picked, its rows' room by the rows picked, the size its smooth
|
|
83
|
+
* corner is fitted to. */
|
|
84
|
+
export declare const SETTING_ROW_PRIVATE: readonly ["--setting-rows-"];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const SETTING_ROW_TOKENS = [
|
|
2
|
+
{ name: "--vk-border", kind: "colour", outright: "--border" },
|
|
3
|
+
{ name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
|
|
4
|
+
{ name: "--vk-border-danger", kind: "colour", outright: "--border-danger" },
|
|
5
|
+
{ name: "--vk-hovered", kind: "colour", outright: "--surface-hovered" },
|
|
6
|
+
{ name: "--vk-raised", kind: "colour", outright: "--surface-raised" },
|
|
7
|
+
{ name: "--vk-danger", kind: "colour", outright: "--text-danger" },
|
|
8
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
9
|
+
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
10
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
11
|
+
{ name: "--vk-corner-smoothing", kind: "size", outright: "--corner-smoothing" },
|
|
12
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
13
|
+
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
14
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
15
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
16
|
+
{ name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
|
|
17
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
18
|
+
{ name: "--vk-radius-md", kind: "size", outright: "--radius-md" },
|
|
19
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
20
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
21
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
22
|
+
];
|
|
23
|
+
export const SETTING_ROW_PRIVATE = ["--setting-rows-"];
|