@glasshome/ui 1.42.0 → 1.43.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/dist/index.js +2 -2
- package/dist/lib/anchor-placement.d.ts +4 -0
- package/dist/lib/balance-rows.d.ts +10 -4
- package/dist/lib/behavior/anchored.d.ts +16 -2
- package/dist/lib/behavior/button-root.d.ts +7 -0
- package/dist/lib/behavior/collection.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +6 -4
- package/dist/lib/behavior/focus-scope.d.ts +7 -1
- package/dist/lib/behavior/hide-outside.d.ts +1 -1
- package/dist/lib/behavior/layer-stack.d.ts +3 -2
- package/dist/lib/behavior/menu.d.ts +59 -0
- package/dist/lib/behavior/modal-root.d.ts +2 -0
- package/dist/lib/behavior/range.d.ts +44 -0
- package/dist/lib/color/color.d.ts +41 -0
- package/dist/lib/color/index.d.ts +2 -0
- package/dist/lib/color/intl.d.ts +40 -0
- package/dist/lib/dock-slot-classes.d.ts +2 -0
- package/dist/lib/hold.d.ts +1 -1
- package/dist/lib/locale.d.ts +3 -0
- package/dist/lib/menu-classes.d.ts +2 -0
- package/dist/lib/motion-classes.d.ts +1 -1
- package/dist/lib/overlay-classes.d.ts +1 -0
- package/dist/lib/scroll-track.d.ts +3 -2
- package/dist/lib/section-tokens.d.ts +1 -1
- package/dist/lib/segment-classes.d.ts +2 -0
- package/dist/lib/shadow-layer.d.ts +0 -45
- package/dist/lib/toggle-set.d.ts +44 -0
- package/dist/lib/visually-hidden.d.ts +3 -0
- package/dist/solid/accordion.d.ts +35 -11
- package/dist/solid/avatar.d.ts +8 -4
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +1 -1
- package/dist/solid/button.d.ts +5 -4
- package/dist/solid/charts.d.ts +1 -1
- package/dist/solid/checkbox.d.ts +14 -4
- package/dist/solid/collapsible.d.ts +33 -5
- package/dist/solid/color-disc.d.ts +1 -1
- package/dist/solid/color-slider.d.ts +1 -1
- package/dist/solid/color-wheel.d.ts +1 -1
- package/dist/solid/context-menu.d.ts +58 -24
- package/dist/solid/dialog-parts.d.ts +8 -8
- package/dist/solid/dropdown-menu.d.ts +55 -24
- package/dist/solid/empty.d.ts +1 -1
- package/dist/solid/form.d.ts +5 -6
- package/dist/solid/hover-card.d.ts +65 -9
- package/dist/solid/index.d.ts +1 -1
- package/dist/solid/index.js +7725 -13458
- package/dist/solid/input-group.d.ts +6 -6
- package/dist/solid/item.d.ts +1 -1
- package/dist/solid/menu-parts.d.ts +175 -24
- package/dist/solid/option-card.d.ts +1 -4
- package/dist/solid/picker-row.d.ts +2 -0
- package/dist/solid/popover.d.ts +77 -12
- package/dist/solid/progress.d.ts +11 -3
- package/dist/solid/radio-group.d.ts +31 -6
- package/dist/solid/responsive-dialog.d.ts +1 -1
- package/dist/solid/scroll-area.d.ts +1 -1
- package/dist/solid/section-card.d.ts +2 -3
- package/dist/solid/select.d.ts +107 -10
- package/dist/solid/selection.d.ts +10 -1
- package/dist/solid/sheet.d.ts +1 -1
- package/dist/solid/sliding-indicator.d.ts +1 -1
- package/dist/solid/sonner.d.ts +1 -1
- package/dist/solid/toggle.d.ts +11 -3
- package/dist/solid/tooltip.d.ts +22 -22
- package/dist/tokens/index.js +54 -51
- package/dist/{utils-CxAii-e9.js → utils-3Codx-NZ.js} +527 -489
- package/package.json +3 -6
- package/src/lib/anchor-placement.ts +10 -3
- package/src/lib/balance-rows.ts +115 -40
- package/src/lib/behavior/anchored.ts +26 -8
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +66 -29
- package/src/lib/behavior/dismiss.ts +61 -21
- package/src/lib/behavior/focus-scope.ts +31 -6
- package/src/lib/behavior/hide-outside.ts +2 -2
- package/src/lib/behavior/layer-stack.ts +33 -8
- package/src/lib/behavior/menu.ts +470 -0
- package/src/lib/behavior/modal-root.tsx +24 -18
- package/src/lib/behavior/polymorphic.tsx +1 -1
- package/src/lib/behavior/presence.ts +1 -1
- package/src/lib/behavior/range.ts +212 -0
- package/src/lib/clipboard.ts +2 -3
- package/src/lib/color/color.ts +746 -0
- package/src/lib/color/index.ts +2 -0
- package/src/lib/color/intl.ts +60 -0
- package/src/lib/dock-slot-classes.ts +3 -0
- package/src/lib/hold.ts +1 -1
- package/src/lib/locale.ts +62 -0
- package/src/lib/menu-classes.ts +3 -0
- package/src/lib/motion-classes.ts +7 -7
- package/src/lib/overlay-classes.ts +1 -3
- package/src/lib/scroll-track.ts +11 -6
- package/src/lib/section-tokens.ts +1 -1
- package/src/lib/segment-classes.ts +3 -0
- package/src/lib/shadow-layer.ts +0 -118
- package/src/lib/toggle-set.ts +133 -0
- package/src/lib/visually-hidden.ts +15 -0
- package/src/solid/accordion.tsx +294 -20
- package/src/solid/area-picker.tsx +3 -2
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/bottom-sheet/bottom-sheet.tsx +1 -1
- package/src/solid/button.tsx +12 -6
- package/src/solid/charts.tsx +1 -1
- package/src/solid/checkbox.tsx +167 -44
- package/src/solid/collapsible.tsx +260 -12
- package/src/solid/color-disc.tsx +11 -12
- package/src/solid/color-slider.tsx +114 -47
- package/src/solid/color-wheel.tsx +137 -39
- package/src/solid/context-menu.tsx +285 -94
- package/src/solid/dialog-parts.tsx +9 -9
- package/src/solid/dock.tsx +3 -2
- package/src/solid/dropdown-menu.tsx +252 -115
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +3 -2
- package/src/solid/face-toggle.tsx +43 -18
- package/src/solid/form.tsx +5 -6
- package/src/solid/glyph-tile.tsx +48 -21
- package/src/solid/hover-card.tsx +287 -25
- package/src/solid/image-picker.tsx +2 -2
- package/src/solid/index.ts +1 -3
- package/src/solid/input-group.tsx +2 -2
- package/src/solid/item.tsx +1 -1
- package/src/solid/menu-parts.tsx +619 -145
- package/src/solid/option-card.tsx +6 -10
- package/src/solid/picker-row.tsx +5 -1
- package/src/solid/popover.tsx +424 -79
- package/src/solid/preview-tile.tsx +1 -1
- package/src/solid/progress.tsx +84 -15
- package/src/solid/radio-group.tsx +271 -34
- package/src/solid/responsive-dialog.tsx +1 -1
- package/src/solid/schema-form.tsx +1 -6
- package/src/solid/scroll-area.tsx +1 -1
- package/src/solid/section-card.tsx +3 -4
- package/src/solid/select.tsx +950 -95
- package/src/solid/selection.tsx +142 -66
- package/src/solid/sheet.tsx +1 -1
- package/src/solid/slider.tsx +115 -65
- package/src/solid/sliding-indicator.tsx +1 -1
- package/src/solid/sonner.tsx +1 -1
- package/src/solid/tabs.tsx +12 -6
- package/src/solid/term.tsx +3 -4
- package/src/solid/toggle-group.tsx +29 -99
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +24 -24
- package/src/styles/globals.css +61 -7
- package/src/styles/theme.css +7 -4
- package/src/tokens/material.ts +11 -2
package/src/solid/progress.tsx
CHANGED
|
@@ -1,21 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type Component,
|
|
3
|
+
type ComponentProps,
|
|
4
|
+
createMemo,
|
|
5
|
+
createUniqueId,
|
|
6
|
+
splitProps,
|
|
7
|
+
} from "solid-js";
|
|
8
|
+
import { merge } from "../lib/behavior/solid.js";
|
|
3
9
|
import { FIELD_CHROME } from "../lib/input-classes.js";
|
|
4
10
|
import { cn } from "../lib/utils.js";
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
type ProgressProps = Omit<ComponentProps<"div">, "children"> & {
|
|
13
|
+
value?: number;
|
|
14
|
+
minValue?: number;
|
|
15
|
+
maxValue?: number;
|
|
16
|
+
indeterminate?: boolean;
|
|
17
|
+
getValueLabel?: (params: { value: number; min: number; max: number }) => string;
|
|
18
|
+
tone?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const Progress: Component<ProgressProps> = (props) => {
|
|
22
|
+
const fallbackId = `progress-${createUniqueId()}`;
|
|
23
|
+
const [local, rest] = splitProps(props, [
|
|
24
|
+
"class",
|
|
25
|
+
"value",
|
|
26
|
+
"minValue",
|
|
27
|
+
"maxValue",
|
|
28
|
+
"indeterminate",
|
|
29
|
+
"getValueLabel",
|
|
30
|
+
"tone",
|
|
31
|
+
]);
|
|
32
|
+
const min = () => local.minValue ?? 0;
|
|
33
|
+
const max = () => local.maxValue ?? 100;
|
|
34
|
+
const value = () => Math.min(Math.max(local.value ?? 0, min()), max());
|
|
35
|
+
const share = () => (value() - min()) / (max() - min());
|
|
36
|
+
const percent = createMemo(() => new Intl.NumberFormat(undefined, { style: "percent" }));
|
|
37
|
+
const valueText = () => {
|
|
38
|
+
if (local.indeterminate) return undefined;
|
|
39
|
+
if (local.getValueLabel) return local.getValueLabel({ value: value(), min: min(), max: max() });
|
|
40
|
+
return percent().format(share());
|
|
41
|
+
};
|
|
42
|
+
const markers = {
|
|
43
|
+
get "data-progress"() {
|
|
44
|
+
if (local.indeterminate) return undefined;
|
|
45
|
+
return share() === 1 ? "complete" : "loading";
|
|
46
|
+
},
|
|
47
|
+
get "data-indeterminate"() {
|
|
48
|
+
return local.indeterminate ? "" : undefined;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
10
52
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
53
|
+
<div
|
|
54
|
+
{...merge(
|
|
55
|
+
{
|
|
56
|
+
id: fallbackId,
|
|
57
|
+
role: "progressbar" as const,
|
|
58
|
+
get "aria-valuenow"() {
|
|
59
|
+
return local.indeterminate ? undefined : value();
|
|
60
|
+
},
|
|
61
|
+
get "aria-valuemin"() {
|
|
62
|
+
return min();
|
|
63
|
+
},
|
|
64
|
+
get "aria-valuemax"() {
|
|
65
|
+
return max();
|
|
66
|
+
},
|
|
67
|
+
get "aria-valuetext"() {
|
|
68
|
+
return valueText();
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
markers,
|
|
72
|
+
{ "data-slot": "progress" },
|
|
73
|
+
rest,
|
|
74
|
+
{
|
|
75
|
+
get class() {
|
|
76
|
+
return cn(
|
|
77
|
+
FIELD_CHROME,
|
|
78
|
+
"relative h-2 w-full overflow-hidden rounded-full",
|
|
79
|
+
local.class,
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
)}
|
|
16
84
|
>
|
|
17
|
-
<
|
|
18
|
-
<
|
|
85
|
+
<div {...markers} class="h-full w-full">
|
|
86
|
+
<div
|
|
87
|
+
{...markers}
|
|
19
88
|
data-slot="progress-indicator"
|
|
20
89
|
class="glass glass-tint transition-glass h-full w-full flex-1"
|
|
21
90
|
style={{
|
|
@@ -23,8 +92,8 @@ const Progress: Component<
|
|
|
23
92
|
transform: `translateX(-${100 - (local.value || 0)}%)`,
|
|
24
93
|
}}
|
|
25
94
|
/>
|
|
26
|
-
</
|
|
27
|
-
</
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
28
97
|
);
|
|
29
98
|
};
|
|
30
99
|
|
|
@@ -1,28 +1,158 @@
|
|
|
1
|
-
import { RadioGroup as RadioGroupPrimitive } from "@kobalte/core/radio-group";
|
|
2
1
|
import {
|
|
3
2
|
children,
|
|
4
|
-
type Component,
|
|
5
3
|
type ComponentProps,
|
|
4
|
+
createContext,
|
|
5
|
+
createSignal,
|
|
6
|
+
createUniqueId,
|
|
7
|
+
type JSX,
|
|
6
8
|
type ParentComponent,
|
|
7
9
|
Show,
|
|
8
10
|
splitProps,
|
|
11
|
+
useContext,
|
|
9
12
|
} from "solid-js";
|
|
10
|
-
import {
|
|
13
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
14
|
+
import { trackFocus } from "../lib/behavior/focus-scope.js";
|
|
15
|
+
import { callEventHandler, effect } from "../lib/behavior/solid.js";
|
|
11
16
|
import { FIELD_CHROME } from "../lib/input-classes.js";
|
|
12
17
|
import { cn } from "../lib/utils.js";
|
|
18
|
+
import { VISUALLY_HIDDEN } from "../lib/visually-hidden.js";
|
|
19
|
+
|
|
20
|
+
type RadioGroupContextValue = {
|
|
21
|
+
id: () => string;
|
|
22
|
+
name: () => string;
|
|
23
|
+
isSelectedValue: (value: string) => boolean;
|
|
24
|
+
select: (value: string) => void;
|
|
25
|
+
disabled: () => boolean;
|
|
26
|
+
required: () => boolean;
|
|
27
|
+
readOnly: () => boolean;
|
|
28
|
+
defaultValue: () => string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const RadioGroupContext = createContext<RadioGroupContextValue>();
|
|
32
|
+
|
|
33
|
+
function useRadioGroup(): RadioGroupContextValue {
|
|
34
|
+
const context = useContext(RadioGroupContext);
|
|
35
|
+
if (!context) throw new Error("RadioGroupItem renders inside a RadioGroup");
|
|
36
|
+
return context;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const formState = (group: RadioGroupContextValue) => ({
|
|
40
|
+
"data-required": group.required() ? "" : undefined,
|
|
41
|
+
"data-disabled": group.disabled() ? "" : undefined,
|
|
42
|
+
"data-readonly": group.readOnly() ? "" : undefined,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
type RadioGroupProps = Omit<ComponentProps<"div">, "onChange"> & {
|
|
46
|
+
value?: string;
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
onChange?: (value: string) => void;
|
|
49
|
+
name?: string;
|
|
50
|
+
orientation?: "horizontal" | "vertical";
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
required?: boolean;
|
|
53
|
+
readOnly?: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const RadioGroup = (props: RadioGroupProps) => {
|
|
57
|
+
const [local, rest] = splitProps(props, [
|
|
58
|
+
"class",
|
|
59
|
+
"value",
|
|
60
|
+
"defaultValue",
|
|
61
|
+
"onChange",
|
|
62
|
+
"name",
|
|
63
|
+
"orientation",
|
|
64
|
+
"disabled",
|
|
65
|
+
"required",
|
|
66
|
+
"readOnly",
|
|
67
|
+
"id",
|
|
68
|
+
"ref",
|
|
69
|
+
"aria-labelledby",
|
|
70
|
+
"children",
|
|
71
|
+
]);
|
|
72
|
+
const fallbackId = `radiogroup-${createUniqueId()}`;
|
|
73
|
+
const id = () => local.id ?? fallbackId;
|
|
74
|
+
const [root, setRoot] = createSignal<HTMLDivElement>();
|
|
75
|
+
const [selected, setSelected] = createControllableSignal({
|
|
76
|
+
value: () => local.value,
|
|
77
|
+
defaultValue: () => local.defaultValue ?? "",
|
|
78
|
+
onChange: (next) => local.onChange?.(next),
|
|
79
|
+
});
|
|
80
|
+
// A controlled group that keeps its value must put the browser's own checked state back.
|
|
81
|
+
const syncInputs = () => {
|
|
82
|
+
for (const input of root()?.querySelectorAll<HTMLInputElement>("[type='radio']") ?? []) {
|
|
83
|
+
input.checked = input.value === selected();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const context: RadioGroupContextValue = {
|
|
87
|
+
id,
|
|
88
|
+
name: () => local.name ?? id(),
|
|
89
|
+
isSelectedValue: (value) => value === selected(),
|
|
90
|
+
select: (value) => {
|
|
91
|
+
if (!local.readOnly && !local.disabled) setSelected(value);
|
|
92
|
+
syncInputs();
|
|
93
|
+
},
|
|
94
|
+
disabled: () => local.disabled ?? false,
|
|
95
|
+
required: () => local.required ?? false,
|
|
96
|
+
readOnly: () => local.readOnly ?? false,
|
|
97
|
+
defaultValue: () => local.defaultValue ?? "",
|
|
98
|
+
};
|
|
99
|
+
effect(root, (el) => {
|
|
100
|
+
if (!el) return;
|
|
101
|
+
// Space on the checked radio sends no click of its own, so a keyboard pick would never reach onPick.
|
|
102
|
+
const down = (event: KeyboardEvent) => {
|
|
103
|
+
arrowKeyHeld = event.key.startsWith("Arrow");
|
|
104
|
+
const target = event.target;
|
|
105
|
+
if (event.key === " " && target instanceof HTMLInputElement && target.checked) target.click();
|
|
106
|
+
};
|
|
107
|
+
const up = () => {
|
|
108
|
+
arrowKeyHeld = false;
|
|
109
|
+
};
|
|
110
|
+
el.addEventListener("keydown", down, true);
|
|
111
|
+
el.addEventListener("keyup", up, true);
|
|
112
|
+
return () => {
|
|
113
|
+
el.removeEventListener("keydown", down, true);
|
|
114
|
+
el.removeEventListener("keyup", up, true);
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
effect(
|
|
118
|
+
() => root()?.closest("form"),
|
|
119
|
+
(form) => {
|
|
120
|
+
if (!form) return;
|
|
121
|
+
const reset = () => setSelected(local.defaultValue ?? "");
|
|
122
|
+
form.addEventListener("reset", reset);
|
|
123
|
+
return () => form.removeEventListener("reset", reset);
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
const labelledBy = () =>
|
|
127
|
+
[local["aria-labelledby"], local["aria-labelledby"] && rest["aria-label"] ? id() : undefined]
|
|
128
|
+
.filter(Boolean)
|
|
129
|
+
.join(" ") || undefined;
|
|
13
130
|
|
|
14
|
-
const RadioGroup: Component<ComponentProps<typeof RadioGroupPrimitive>> = (props) => {
|
|
15
|
-
const [local, rest] = splitProps(props, ["class"]);
|
|
16
131
|
return (
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
132
|
+
<RadioGroupContext.Provider value={context}>
|
|
133
|
+
<div
|
|
134
|
+
ref={(el) => {
|
|
135
|
+
setRoot(el);
|
|
136
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
137
|
+
}}
|
|
138
|
+
role="radiogroup"
|
|
139
|
+
id={id()}
|
|
140
|
+
aria-labelledby={labelledBy()}
|
|
141
|
+
aria-orientation={local.orientation ?? "vertical"}
|
|
142
|
+
aria-required={local.required || undefined}
|
|
143
|
+
aria-disabled={local.disabled || undefined}
|
|
144
|
+
aria-readonly={local.readOnly || undefined}
|
|
145
|
+
{...formState(context)}
|
|
146
|
+
data-slot="radio-group"
|
|
147
|
+
class={cn("flex flex-col gap-3", local.class)}
|
|
148
|
+
{...rest}
|
|
149
|
+
>
|
|
150
|
+
{local.children}
|
|
151
|
+
</div>
|
|
152
|
+
</RadioGroupContext.Provider>
|
|
22
153
|
);
|
|
23
154
|
};
|
|
24
155
|
|
|
25
|
-
// Its own component so the children resolve once, under the item's Kobalte context.
|
|
26
156
|
const RadioGroupItemContent: ParentComponent = (props) => {
|
|
27
157
|
const content = children(() => props.children);
|
|
28
158
|
return (
|
|
@@ -34,26 +164,126 @@ const RadioGroupItemContent: ParentComponent = (props) => {
|
|
|
34
164
|
);
|
|
35
165
|
};
|
|
36
166
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
167
|
+
type RadioGroupItemProps = Omit<ComponentProps<"div">, "onClick"> & {
|
|
168
|
+
value: string;
|
|
169
|
+
disabled?: boolean;
|
|
170
|
+
showControl?: boolean;
|
|
171
|
+
/** Presses do nothing; unlike `disabled` it keeps focus. */
|
|
172
|
+
busy?: boolean;
|
|
173
|
+
onClick?: JSX.EventHandlerUnion<HTMLDivElement, MouseEvent>;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const RadioGroupItem = (props: RadioGroupItemProps) => {
|
|
177
|
+
const group = useRadioGroup();
|
|
178
|
+
const [local, rest] = splitProps(props, [
|
|
179
|
+
"class",
|
|
180
|
+
"children",
|
|
181
|
+
"showControl",
|
|
182
|
+
"busy",
|
|
183
|
+
"value",
|
|
184
|
+
"disabled",
|
|
185
|
+
"id",
|
|
186
|
+
"ref",
|
|
187
|
+
"onClick",
|
|
188
|
+
]);
|
|
189
|
+
const fallbackId = `${group.id()}-item-${createUniqueId()}`;
|
|
190
|
+
const id = () => local.id ?? fallbackId;
|
|
191
|
+
const disabled = () => group.disabled() || (local.disabled ?? false);
|
|
192
|
+
const checked = () => group.isSelectedValue(local.value);
|
|
193
|
+
const [item, setItem] = createSignal<HTMLDivElement>();
|
|
194
|
+
const [input, setInput] = createSignal<HTMLInputElement>();
|
|
195
|
+
const state = () => ({
|
|
196
|
+
...formState(group),
|
|
197
|
+
"data-disabled": disabled() ? "" : undefined,
|
|
198
|
+
"data-checked": checked() ? "" : undefined,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
effect(
|
|
202
|
+
() => [input(), local.value === group.defaultValue()] as const,
|
|
203
|
+
([el, isDefault]) => {
|
|
204
|
+
if (el) el.defaultChecked = isDefault;
|
|
205
|
+
},
|
|
206
|
+
);
|
|
207
|
+
let inputFocus: ReturnType<typeof trackFocus> | undefined;
|
|
208
|
+
effect(input, (el) => {
|
|
209
|
+
if (!el) return;
|
|
210
|
+
const tracked = trackFocus(el);
|
|
211
|
+
inputFocus = tracked;
|
|
212
|
+
return tracked.stop;
|
|
213
|
+
});
|
|
214
|
+
// Bound on the elements, since Solid's delegated handlers never reach inside a closed shadow root.
|
|
215
|
+
effect(item, (node) => {
|
|
216
|
+
if (!node) return;
|
|
217
|
+
const pointerdown = (event: PointerEvent) => {
|
|
218
|
+
if (inputFocus?.has()) event.preventDefault();
|
|
219
|
+
};
|
|
220
|
+
const click = (event: MouseEvent) =>
|
|
221
|
+
callEventHandler(
|
|
222
|
+
event as MouseEvent & { currentTarget: HTMLDivElement; target: Element },
|
|
223
|
+
local.onClick,
|
|
224
|
+
);
|
|
225
|
+
node.addEventListener("pointerdown", pointerdown);
|
|
226
|
+
node.addEventListener("click", click);
|
|
227
|
+
return () => {
|
|
228
|
+
node.removeEventListener("pointerdown", pointerdown);
|
|
229
|
+
node.removeEventListener("click", click);
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const change = (event: Event) => {
|
|
234
|
+
const target = event.currentTarget as HTMLInputElement;
|
|
235
|
+
if (target.checked) group.select(local.value);
|
|
236
|
+
target.checked = checked();
|
|
237
|
+
};
|
|
238
|
+
|
|
41
239
|
return (
|
|
42
|
-
<
|
|
240
|
+
<div
|
|
241
|
+
ref={(el) => {
|
|
242
|
+
setItem(el);
|
|
243
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
244
|
+
}}
|
|
245
|
+
role="group"
|
|
246
|
+
id={id()}
|
|
247
|
+
{...state()}
|
|
43
248
|
data-slot="radio-group-item"
|
|
44
249
|
class={cn("flex", local.class)}
|
|
45
250
|
{...rest}
|
|
46
251
|
>
|
|
47
|
-
<
|
|
48
|
-
|
|
252
|
+
<input
|
|
253
|
+
ref={setInput}
|
|
254
|
+
type="radio"
|
|
255
|
+
id={`${id()}-input`}
|
|
256
|
+
name={group.name()}
|
|
257
|
+
value={local.value}
|
|
258
|
+
checked={checked()}
|
|
259
|
+
required={group.required()}
|
|
260
|
+
disabled={disabled()}
|
|
261
|
+
readOnly={group.readOnly()}
|
|
262
|
+
style={VISUALLY_HIDDEN}
|
|
263
|
+
aria-labelledby={`${id()}-label`}
|
|
264
|
+
{...state()}
|
|
265
|
+
class="peer"
|
|
266
|
+
aria-busy={local.busy || undefined}
|
|
267
|
+
aria-disabled={local.busy || undefined}
|
|
268
|
+
on:click={(event) => {
|
|
269
|
+
if (local.busy) event.preventDefault();
|
|
270
|
+
}}
|
|
271
|
+
on:change={change}
|
|
272
|
+
/>
|
|
273
|
+
<label
|
|
274
|
+
for={`${id()}-input`}
|
|
275
|
+
id={`${id()}-label`}
|
|
276
|
+
{...state()}
|
|
49
277
|
data-slot="radio-group-item-label"
|
|
50
278
|
class="flex flex-1 cursor-pointer items-center gap-2.5 select-none data-[disabled]:cursor-not-allowed"
|
|
51
279
|
>
|
|
52
280
|
<Show when={local.showControl ?? true}>
|
|
53
|
-
<
|
|
281
|
+
<div
|
|
282
|
+
id={`${id()}-control`}
|
|
283
|
+
{...state()}
|
|
54
284
|
data-slot="radio-group-item-control"
|
|
55
285
|
class={cn(
|
|
56
|
-
"transition-glass relative flex aspect-square size-7 shrink-0 items-center justify-center overflow-hidden rounded-full duration-
|
|
286
|
+
"transition-glass relative flex aspect-square size-7 shrink-0 items-center justify-center overflow-hidden rounded-full duration-(--duration-expand) ease-out active:scale-90",
|
|
57
287
|
FIELD_CHROME,
|
|
58
288
|
"peer-focus-visible:ring-ring/50 peer-focus-visible:ring-[3px] peer-focus-visible:[--glass-edge:var(--ring)]",
|
|
59
289
|
"data-[invalid]:ring-destructive/20 data-[disabled]:opacity-40 data-[invalid]:[--glass-edge:var(--destructive)]",
|
|
@@ -61,26 +291,33 @@ const RadioGroupItem: Component<
|
|
|
61
291
|
>
|
|
62
292
|
{/* Gradient backgrounds can't transition; the glass rides an inner element
|
|
63
293
|
that animates in. */}
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
294
|
+
<Show when={checked()}>
|
|
295
|
+
<div
|
|
296
|
+
id={`${id()}-indicator`}
|
|
297
|
+
{...state()}
|
|
298
|
+
data-slot="radio-group-item-indicator"
|
|
299
|
+
class="glass glass-tint zoom-in-50 fade-in animate-in absolute inset-0 grid place-items-center rounded-full duration-(--duration-expand) [--glass-tone:var(--primary)] [--glass-wash:90%]"
|
|
300
|
+
>
|
|
301
|
+
<span
|
|
302
|
+
data-slot="radio-group-item-dot"
|
|
303
|
+
class="color-calc:[background:oklch(from_var(--primary)_calc((0.42_-_l)*100)_0_0)] dark:color-calc:[background:oklch(from_var(--primary)_calc((0.6_-_l)*100)_0_0)] bg-primary-foreground size-[36%] rounded-full"
|
|
304
|
+
/>
|
|
305
|
+
</div>
|
|
306
|
+
</Show>
|
|
307
|
+
</div>
|
|
74
308
|
</Show>
|
|
75
309
|
<RadioGroupItemContent>{local.children}</RadioGroupItemContent>
|
|
76
|
-
</
|
|
77
|
-
</
|
|
310
|
+
</label>
|
|
311
|
+
</div>
|
|
78
312
|
);
|
|
79
313
|
};
|
|
80
314
|
|
|
315
|
+
let arrowKeyHeld = false;
|
|
316
|
+
|
|
81
317
|
// A press on the label reaches the item twice: once itself, once as the input click it forwards.
|
|
318
|
+
// An arrow key checks the next radio with a click of its own, which picks nothing.
|
|
82
319
|
function isItemActivation(event: MouseEvent): boolean {
|
|
83
|
-
return event.target instanceof HTMLInputElement;
|
|
320
|
+
return event.target instanceof HTMLInputElement && !(event.detail === 0 && arrowKeyHeld);
|
|
84
321
|
}
|
|
85
322
|
|
|
86
|
-
export { isItemActivation, RadioGroup, RadioGroupItem };
|
|
323
|
+
export { isItemActivation, RadioGroup, RadioGroupItem, useRadioGroup };
|
|
@@ -50,7 +50,7 @@ interface ResponsiveDialogProps {
|
|
|
50
50
|
keep?: boolean;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/** Centred
|
|
53
|
+
/** Centred dialog from `sm` up, drag-to-dismiss bottom sheet below it.
|
|
54
54
|
* Both branches render the same parts, so a call site never branches. */
|
|
55
55
|
const ResponsiveDialog: ParentComponent<ResponsiveDialogProps> = (props) => {
|
|
56
56
|
const [open, setOpen] = createControllableSignal<boolean>({
|
|
@@ -72,12 +72,7 @@ export const SCHEMA_FORM_FORM_TYPES = [
|
|
|
72
72
|
|
|
73
73
|
const warnedLegacyAreaKeys = new Set<string>();
|
|
74
74
|
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated Removed in the next major. Before the SDK had `field.area()`,
|
|
77
|
-
* an area picker was inferred from the property name alone, so a field had to
|
|
78
|
-
* be called `areaId` to get one and any other name silently rendered a text
|
|
79
|
-
* input. Declare `field.area()` instead — it works under any name.
|
|
80
|
-
*/
|
|
75
|
+
/** @deprecated `field.area()`; removed in 2.0.0. */
|
|
81
76
|
function isLegacyAreaKey(key: string, prop: ExtendedJSONSchema): boolean {
|
|
82
77
|
const lower = key.toLowerCase();
|
|
83
78
|
if (prop.type !== "string" || (lower !== "areaid" && lower !== "area_id")) return false;
|
|
@@ -19,7 +19,7 @@ const ScrollArea: ParentComponent<ComponentProps<"div">> = (props) => {
|
|
|
19
19
|
);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
/** @deprecated
|
|
22
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
23
23
|
const ScrollBar: Component<ComponentProps<"div"> & { orientation?: "vertical" | "horizontal" }> = (
|
|
24
24
|
_props,
|
|
25
25
|
) => null;
|
|
@@ -256,7 +256,7 @@ const ICON_DIMENSIONS: Record<SectionIconSize, string> = {
|
|
|
256
256
|
lg: "size-12 sm:size-14 [&>[data-slot=icon]]:text-[24px] sm:[&>[data-slot=icon]]:text-[28px]",
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
/** @deprecated
|
|
259
|
+
/** @deprecated Pass a CSS color to `tone`; removed in 2.0.0. */
|
|
260
260
|
const LEGACY_TONES: Record<string, string | undefined> = {
|
|
261
261
|
neutral: undefined,
|
|
262
262
|
primary: "var(--primary)",
|
|
@@ -319,8 +319,7 @@ function SectionHeading(props: { children: JSX.Element; class?: string }) {
|
|
|
319
319
|
);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
/** @deprecated
|
|
323
|
-
* inside a card, `FieldLegend` for a titled group of form rows. */
|
|
322
|
+
/** @deprecated `SectionGroup`, or `FieldLegend` for a titled group of form rows; removed in 2.0.0. */
|
|
324
323
|
export function SectionSubtitle(props: { children: JSX.Element; class?: string }) {
|
|
325
324
|
return <SectionHeading class={props.class}>{props.children}</SectionHeading>;
|
|
326
325
|
}
|
|
@@ -357,7 +356,7 @@ export function SectionGroup(props: {
|
|
|
357
356
|
);
|
|
358
357
|
}
|
|
359
358
|
|
|
360
|
-
/** @deprecated SectionMeta
|
|
359
|
+
/** @deprecated `SectionMeta`, or `FieldLegend` for a titled group of rows; removed in 2.0.0. */
|
|
361
360
|
export function SectionLabel(props: { children: JSX.Element; class?: string }) {
|
|
362
361
|
return <SectionMeta class={cn("font-medium", props.class)}>{props.children}</SectionMeta>;
|
|
363
362
|
}
|