@glasshome/ui 1.40.0 → 1.42.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/SPEC.md +25 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/lib/anchor-placement.d.ts +30 -0
- package/dist/lib/behavior/anchored.d.ts +12 -0
- package/dist/lib/behavior/collection.d.ts +24 -0
- package/dist/lib/behavior/controllable.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +11 -0
- package/dist/lib/behavior/focus-scope.d.ts +18 -0
- package/dist/lib/behavior/hide-outside.d.ts +7 -0
- package/dist/lib/behavior/layer-stack.d.ts +33 -0
- package/dist/lib/behavior/modal-root.d.ts +66 -0
- package/dist/lib/behavior/polymorphic.d.ts +6 -0
- package/dist/lib/behavior/presence.d.ts +18 -0
- package/dist/lib/behavior/solid.d.ts +13 -0
- package/dist/lib/motion-classes.d.ts +5 -2
- package/dist/lib/overlay-classes.d.ts +4 -1
- package/dist/lib/page-cover.d.ts +8 -0
- package/dist/lib/shadow-layer.d.ts +8 -6
- package/dist/solid/alert-dialog.d.ts +13 -15
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -6
- package/dist/solid/bottom-sheet/constants.d.ts +1 -1
- package/dist/solid/confirm-dialog.d.ts +22 -0
- package/dist/solid/dialog-parts.d.ts +78 -15
- package/dist/solid/dialog.d.ts +9 -15
- package/dist/solid/docked-panel.d.ts +1 -5
- package/dist/solid/icon-nodes.d.ts +13 -0
- package/dist/solid/index.d.ts +9 -5
- package/dist/solid/index.js +8211 -7974
- package/dist/solid/responsive-dialog.d.ts +5 -6
- package/dist/solid/sheet.d.ts +6 -13
- package/dist/solid/stale-veil.d.ts +7 -0
- package/dist/solid/tabs.d.ts +29 -8
- package/dist/solid/toggle-group.d.ts +30 -5
- package/dist/solid/tooltip.d.ts +71 -9
- package/dist/{utils-DXEj_oXa.js → utils-CxAii-e9.js} +606 -414
- package/package.json +4 -2
- package/src/index.ts +1 -0
- package/src/lib/anchor-placement.ts +68 -2
- package/src/lib/behavior/anchored.ts +88 -0
- package/src/lib/behavior/collection.ts +181 -0
- package/src/lib/behavior/controllable.ts +22 -0
- package/src/lib/behavior/dismiss.ts +145 -0
- package/src/lib/behavior/focus-scope.ts +202 -0
- package/src/lib/behavior/hide-outside.ts +85 -0
- package/src/lib/behavior/layer-stack.ts +125 -0
- package/src/lib/behavior/modal-root.tsx +446 -0
- package/src/lib/behavior/polymorphic.tsx +30 -0
- package/src/lib/behavior/presence.ts +89 -0
- package/src/lib/behavior/solid.ts +30 -0
- package/src/lib/clipboard.ts +3 -2
- package/src/lib/motion-classes.ts +27 -2
- package/src/lib/overlay-classes.ts +9 -4
- package/src/lib/page-cover.ts +47 -0
- package/src/lib/shadow-layer.ts +48 -66
- package/src/solid/alert-dialog.tsx +45 -81
- package/src/solid/alert.tsx +1 -1
- package/src/solid/area-picker.tsx +2 -1
- package/src/solid/badge.tsx +5 -5
- package/src/solid/bottom-sheet/bottom-sheet.tsx +72 -128
- package/src/solid/bottom-sheet/constants.ts +3 -1
- package/src/solid/bottom-sheet/drag-controller.ts +11 -0
- package/src/solid/breadcrumb.tsx +4 -4
- package/src/solid/button-group.tsx +4 -4
- package/src/solid/card.tsx +5 -4
- package/src/solid/confirm-dialog.tsx +62 -0
- package/src/solid/context-menu.tsx +12 -2
- package/src/solid/dialog-parts.tsx +181 -42
- package/src/solid/dialog.tsx +46 -74
- package/src/solid/dock-edit.tsx +5 -4
- package/src/solid/dock.tsx +3 -3
- package/src/solid/dropdown-menu.tsx +15 -7
- package/src/solid/entity-selector.tsx +2 -1
- package/src/solid/form.tsx +4 -3
- package/src/solid/hover-card.tsx +7 -2
- package/src/solid/icon-nodes.ts +71 -0
- package/src/solid/icon-picker.tsx +2 -1
- package/src/solid/icon.tsx +42 -39
- package/src/solid/image-picker.tsx +14 -13
- package/src/solid/index.ts +9 -2
- package/src/solid/input-group.tsx +5 -3
- package/src/solid/input-otp.tsx +2 -1
- package/src/solid/item.tsx +4 -4
- package/src/solid/logo.tsx +5 -4
- package/src/solid/picker-row.tsx +5 -4
- package/src/solid/picker-search.tsx +2 -1
- package/src/solid/popover.tsx +18 -10
- package/src/solid/responsive-dialog.tsx +17 -10
- package/src/solid/sheet.tsx +47 -79
- package/src/solid/spotlight.tsx +23 -11
- package/src/solid/stale-veil.tsx +20 -0
- package/src/solid/switch.tsx +8 -6
- package/src/solid/tabs.tsx +373 -53
- package/src/solid/toggle-group.tsx +305 -93
- package/src/solid/tooltip.tsx +285 -26
- package/src/styles/globals.css +6 -2
- package/src/styles/theme.css +10 -5
- package/dist/lib/when-animations-settle.d.ts +0 -4
- package/dist/solid/bottom-sheet/focus-trap.d.ts +0 -6
- package/dist/solid/bottom-sheet/scroll-lock.d.ts +0 -2
- package/dist/solid/bottom-sheet/sheet-motion.d.ts +0 -1
- package/src/lib/when-animations-settle.ts +0 -12
- package/src/solid/bottom-sheet/focus-trap.ts +0 -63
- package/src/solid/bottom-sheet/scroll-lock.ts +0 -66
- package/src/solid/bottom-sheet/sheet-motion.ts +0 -4
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { ToggleGroup as ToggleGroupPrimitive } from "@kobalte/core/toggle-group";
|
|
2
1
|
import type { VariantProps } from "cva";
|
|
3
2
|
import {
|
|
3
|
+
type Accessor,
|
|
4
|
+
children,
|
|
4
5
|
type Component,
|
|
5
6
|
type ComponentProps,
|
|
6
7
|
createContext,
|
|
7
|
-
|
|
8
|
+
createSignal,
|
|
9
|
+
createUniqueId,
|
|
10
|
+
type JSX,
|
|
8
11
|
onCleanup,
|
|
9
12
|
onMount,
|
|
13
|
+
type ParentComponent,
|
|
10
14
|
Show,
|
|
11
15
|
splitProps,
|
|
12
16
|
useContext,
|
|
17
|
+
type ValidComponent,
|
|
13
18
|
} from "solid-js";
|
|
19
|
+
import { type Collection, createCollection } from "../lib/behavior/collection.js";
|
|
20
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
21
|
+
import { focusWithoutTracking, hasFocus } from "../lib/behavior/focus-scope.js";
|
|
22
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
23
|
+
import { effect, merge, omit } from "../lib/behavior/solid.js";
|
|
14
24
|
import { BALANCED_ROWS, balanceRows } from "../lib/balance-rows.js";
|
|
15
25
|
import { TRACK_SURFACE } from "../lib/card-classes.js";
|
|
16
26
|
import { SCROLL_TRACK_FADE, trackScroll } from "../lib/scroll-track.js";
|
|
@@ -18,128 +28,330 @@ import { cn } from "../lib/utils.js";
|
|
|
18
28
|
import { SelectionHighlight, SelectionScope } from "./selection.js";
|
|
19
29
|
import { toggleVariants } from "./toggle.js";
|
|
20
30
|
|
|
31
|
+
type Orientation = "horizontal" | "vertical";
|
|
32
|
+
|
|
33
|
+
type SingleSelection = {
|
|
34
|
+
multiple?: false;
|
|
35
|
+
value?: string | null;
|
|
36
|
+
defaultValue?: string | null;
|
|
37
|
+
onChange?: (value: string | null) => void;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type MultipleSelection = {
|
|
41
|
+
multiple: true;
|
|
42
|
+
value?: string[];
|
|
43
|
+
defaultValue?: string[];
|
|
44
|
+
onChange?: (value: string[]) => void;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type ToggleGroupProps = Omit<ComponentProps<"div">, "onChange"> &
|
|
48
|
+
VariantProps<typeof toggleVariants> &
|
|
49
|
+
(SingleSelection | MultipleSelection) & {
|
|
50
|
+
as?: ValidComponent;
|
|
51
|
+
orientation?: Orientation;
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/** CSS colour for the selected segment's glass. Default `var(--material-accent)`. */
|
|
54
|
+
tone?: string;
|
|
55
|
+
/** One row that scrolls sideways when it outgrows its container, instead of wrapping. */
|
|
56
|
+
scroll?: boolean;
|
|
57
|
+
};
|
|
58
|
+
|
|
21
59
|
// Single-select paints the pressed segment with the selection highlight; multi-select has none.
|
|
22
|
-
type ToggleGroupContextValue = VariantProps<typeof toggleVariants> & {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
type ToggleGroupContextValue = VariantProps<typeof toggleVariants> & {
|
|
61
|
+
sliding: boolean;
|
|
62
|
+
id: Accessor<string>;
|
|
63
|
+
orientation: Accessor<Orientation>;
|
|
64
|
+
disabled: Accessor<boolean>;
|
|
65
|
+
isPressed: (value: string) => boolean;
|
|
66
|
+
toggle: (value: string) => void;
|
|
67
|
+
collection: Collection;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const ToggleGroupContext = createContext<ToggleGroupContextValue | null>(null);
|
|
71
|
+
|
|
72
|
+
const useToggleGroup = (): ToggleGroupContextValue => {
|
|
73
|
+
const ctx = useContext(ToggleGroupContext);
|
|
74
|
+
if (!ctx) throw new Error("ToggleGroupItem renders inside a ToggleGroup");
|
|
75
|
+
return ctx;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const ITEM = '[data-slot="toggle-group-item"]';
|
|
79
|
+
|
|
80
|
+
const toList = (value: string | string[] | null | undefined): string[] | undefined => {
|
|
81
|
+
if (value === undefined) return undefined;
|
|
82
|
+
if (value === null) return [];
|
|
83
|
+
return typeof value === "string" ? [value] : value;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const sameList = (a: string[], b: string[]) =>
|
|
87
|
+
a.length === b.length && a.every((v, i) => v === b[i]);
|
|
88
|
+
|
|
89
|
+
const ToggleGroup: ParentComponent<ToggleGroupProps> = (props) => {
|
|
90
|
+
const rest = omit(
|
|
91
|
+
props,
|
|
40
92
|
"class",
|
|
41
93
|
"variant",
|
|
42
94
|
"size",
|
|
43
95
|
"tone",
|
|
44
96
|
"scroll",
|
|
45
97
|
"children",
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
98
|
+
"value",
|
|
99
|
+
"defaultValue",
|
|
100
|
+
"onChange",
|
|
101
|
+
"multiple",
|
|
102
|
+
"orientation",
|
|
103
|
+
"disabled",
|
|
104
|
+
"id",
|
|
105
|
+
"ref",
|
|
106
|
+
"as",
|
|
107
|
+
);
|
|
108
|
+
const sliding = () => !props.multiple;
|
|
109
|
+
const orientation = () => props.orientation ?? "horizontal";
|
|
110
|
+
const vertical = () => orientation() === "vertical";
|
|
111
|
+
const fallbackId = `group-${createUniqueId()}`;
|
|
112
|
+
const id = () => props.id ?? fallbackId;
|
|
113
|
+
const [values, setValues] = createControllableSignal<string[]>({
|
|
114
|
+
value: () => toList(props.value),
|
|
115
|
+
defaultValue: () => toList(props.defaultValue) ?? [],
|
|
116
|
+
equals: sameList,
|
|
117
|
+
onChange: (next) => {
|
|
118
|
+
if (props.multiple) props.onChange?.(next);
|
|
119
|
+
else props.onChange?.(next[0] ?? null);
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
const [root, setRoot] = createSignal<HTMLElement>();
|
|
123
|
+
const [scope, setScope] = createSignal<HTMLElement>();
|
|
124
|
+
const collection = createCollection({
|
|
125
|
+
root,
|
|
126
|
+
itemSelector: `${ITEM}[data-key]`,
|
|
127
|
+
orientation,
|
|
128
|
+
focus: "roving",
|
|
129
|
+
loop: () => true,
|
|
130
|
+
dir: () => (root()?.closest("[dir]")?.getAttribute("dir") === "rtl" ? "rtl" : "ltr"),
|
|
131
|
+
preferred: values,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const toggle = (value: string) => {
|
|
135
|
+
const current = values();
|
|
136
|
+
const pressed = current.includes(value);
|
|
137
|
+
if (props.multiple)
|
|
138
|
+
setValues(pressed ? current.filter((v) => v !== value) : [...current, value]);
|
|
139
|
+
else setValues(pressed ? [] : [value]);
|
|
140
|
+
};
|
|
141
|
+
|
|
55
142
|
onMount(() => {
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
143
|
+
const el = root();
|
|
144
|
+
if (!el) return;
|
|
145
|
+
if (props.scroll) onCleanup(trackScroll(el, "[data-pressed]", "data-pressed"));
|
|
146
|
+
else if (!vertical()) onCleanup(balanceRows(el, scope() ?? el, ITEM));
|
|
60
147
|
});
|
|
148
|
+
|
|
149
|
+
const context: ToggleGroupContextValue = {
|
|
150
|
+
get variant() {
|
|
151
|
+
return props.variant;
|
|
152
|
+
},
|
|
153
|
+
get size() {
|
|
154
|
+
return props.size;
|
|
155
|
+
},
|
|
156
|
+
get sliding() {
|
|
157
|
+
return sliding();
|
|
158
|
+
},
|
|
159
|
+
id,
|
|
160
|
+
orientation,
|
|
161
|
+
disabled: () => props.disabled ?? false,
|
|
162
|
+
isPressed: (value) => values().includes(value),
|
|
163
|
+
toggle,
|
|
164
|
+
collection,
|
|
165
|
+
};
|
|
166
|
+
|
|
61
167
|
return (
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
168
|
+
<Polymorphic
|
|
169
|
+
{...merge({ "data-slot": "toggle-group" }, rest, {
|
|
170
|
+
as: props.as,
|
|
171
|
+
defaultAs: "div" as ValidComponent,
|
|
172
|
+
ref: (el: HTMLElement) => {
|
|
173
|
+
setRoot(el);
|
|
174
|
+
if (typeof props.ref === "function") props.ref(el as HTMLDivElement);
|
|
175
|
+
},
|
|
176
|
+
role: "group",
|
|
177
|
+
get id() {
|
|
178
|
+
return id();
|
|
179
|
+
},
|
|
180
|
+
get "data-orientation"() {
|
|
181
|
+
return orientation();
|
|
182
|
+
},
|
|
183
|
+
get "data-variant"() {
|
|
184
|
+
return props.variant;
|
|
185
|
+
},
|
|
186
|
+
get "data-size"() {
|
|
187
|
+
return props.size;
|
|
188
|
+
},
|
|
189
|
+
get "data-scroll"() {
|
|
190
|
+
return props.scroll ? "" : undefined;
|
|
191
|
+
},
|
|
192
|
+
"on:keydown": (event: KeyboardEvent) => collection.onKeyDown(event),
|
|
193
|
+
get class() {
|
|
194
|
+
return cn(
|
|
195
|
+
`group/toggle-group w-fit max-w-full items-center gap-y-1 rounded-lg data-[wrapped]:w-full ${TRACK_SURFACE} p-1 data-[variant=outline]:shadow-xs`,
|
|
196
|
+
props.scroll
|
|
197
|
+
? `flex [scrollbar-width:none] flex-nowrap overflow-x-auto ${SCROLL_TRACK_FADE}`
|
|
198
|
+
: vertical()
|
|
199
|
+
? "flex flex-col items-stretch"
|
|
200
|
+
: sliding()
|
|
201
|
+
? "flex"
|
|
202
|
+
: BALANCED_ROWS,
|
|
203
|
+
props.class,
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
})}
|
|
80
207
|
>
|
|
81
|
-
<ToggleGroupContext.Provider
|
|
82
|
-
|
|
83
|
-
>
|
|
84
|
-
<Show when={sliding()} fallback={local.children}>
|
|
208
|
+
<ToggleGroupContext.Provider value={context}>
|
|
209
|
+
<Show when={sliding()} fallback={props.children}>
|
|
85
210
|
{/* w-full, not w-fit: a shrink-to-fit root still sizes to content, and a
|
|
86
211
|
`class="w-full"` root can finally let its items share the width. */}
|
|
87
212
|
<SelectionScope
|
|
88
|
-
ref={
|
|
213
|
+
ref={setScope}
|
|
89
214
|
marker="pressed"
|
|
90
|
-
tone={
|
|
215
|
+
tone={props.tone}
|
|
91
216
|
class={
|
|
92
|
-
|
|
217
|
+
props.scroll
|
|
93
218
|
? "flex w-max flex-nowrap items-center"
|
|
94
219
|
: vertical()
|
|
95
220
|
? "flex w-full flex-col items-stretch gap-y-0.5"
|
|
96
221
|
: `w-full items-center gap-y-1 ${BALANCED_ROWS}`
|
|
97
222
|
}
|
|
98
223
|
>
|
|
99
|
-
{
|
|
224
|
+
{props.children}
|
|
100
225
|
</SelectionScope>
|
|
101
226
|
</Show>
|
|
102
227
|
</ToggleGroupContext.Provider>
|
|
103
|
-
</
|
|
228
|
+
</Polymorphic>
|
|
104
229
|
);
|
|
105
230
|
};
|
|
106
231
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
232
|
+
type ToggleGroupItemState = { pressed: Accessor<boolean> };
|
|
233
|
+
|
|
234
|
+
type ToggleGroupItemProps = Omit<ComponentProps<"button">, "children"> &
|
|
235
|
+
VariantProps<typeof toggleVariants> & {
|
|
236
|
+
as?: ValidComponent;
|
|
237
|
+
value: string;
|
|
238
|
+
disabled?: boolean;
|
|
239
|
+
children?: JSX.Element | ((state: ToggleGroupItemState) => JSX.Element);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const ToggleGroupItem: Component<ToggleGroupItemProps> = (props) => {
|
|
243
|
+
const context = useToggleGroup();
|
|
244
|
+
const [local, rest] = splitProps(props, [
|
|
245
|
+
"class",
|
|
246
|
+
"variant",
|
|
247
|
+
"size",
|
|
248
|
+
"children",
|
|
249
|
+
"value",
|
|
250
|
+
"disabled",
|
|
251
|
+
"id",
|
|
252
|
+
"ref",
|
|
253
|
+
"as",
|
|
254
|
+
]);
|
|
255
|
+
const fallbackId = `${context.id()}-item-${createUniqueId()}`;
|
|
256
|
+
const [el, setEl] = createSignal<HTMLElement>();
|
|
257
|
+
const disabled = () => local.disabled || context.disabled();
|
|
258
|
+
effect(disabled, () => context.collection.refresh());
|
|
259
|
+
onCleanup(() => context.collection.refresh());
|
|
260
|
+
const pressed = () => context.isPressed(local.value);
|
|
261
|
+
const state: ToggleGroupItemState = { pressed };
|
|
262
|
+
const content = children(() => {
|
|
263
|
+
const body = local.children;
|
|
264
|
+
return typeof body === "function" ? body(state) : body;
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
effect(el, (node) => {
|
|
268
|
+
if (!node) return;
|
|
269
|
+
let mousePressed = false;
|
|
270
|
+
const choose = () => {
|
|
271
|
+
if (disabled()) return;
|
|
272
|
+
context.toggle(local.value);
|
|
273
|
+
context.collection.highlight(local.value, "pointer");
|
|
274
|
+
};
|
|
275
|
+
// A mouse toggles on press, so focus lands on an item already toggled and is announced so.
|
|
276
|
+
const pointerdown = (event: PointerEvent) => {
|
|
277
|
+
mousePressed = event.pointerType === "mouse" && event.button === 0;
|
|
278
|
+
if (mousePressed) choose();
|
|
279
|
+
};
|
|
280
|
+
const click = (event: MouseEvent) => {
|
|
281
|
+
// WebKit leaves a clicked button unfocused.
|
|
282
|
+
if (!disabled() && !hasFocus(node)) focusWithoutTracking(node);
|
|
283
|
+
if (event.detail === 0 || !mousePressed) choose();
|
|
284
|
+
mousePressed = false;
|
|
285
|
+
};
|
|
286
|
+
const focus = () => context.collection.highlight(local.value, "pointer");
|
|
287
|
+
node.addEventListener("pointerdown", pointerdown);
|
|
288
|
+
node.addEventListener("click", click);
|
|
289
|
+
node.addEventListener("focus", focus);
|
|
290
|
+
return () => {
|
|
291
|
+
node.removeEventListener("pointerdown", pointerdown);
|
|
292
|
+
node.removeEventListener("click", click);
|
|
293
|
+
node.removeEventListener("focus", focus);
|
|
294
|
+
};
|
|
295
|
+
});
|
|
112
296
|
|
|
113
297
|
return (
|
|
114
|
-
<
|
|
115
|
-
data-slot
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
298
|
+
<Polymorphic
|
|
299
|
+
{...merge({ "data-slot": "toggle-group-item" }, rest, {
|
|
300
|
+
as: local.as,
|
|
301
|
+
defaultAs: "button" as ValidComponent,
|
|
302
|
+
ref: (node: HTMLElement) => {
|
|
303
|
+
setEl(node);
|
|
304
|
+
if (typeof local.ref === "function") local.ref(node as HTMLButtonElement);
|
|
305
|
+
},
|
|
306
|
+
get id() {
|
|
307
|
+
return local.id ?? fallbackId;
|
|
308
|
+
},
|
|
309
|
+
get tabIndex() {
|
|
310
|
+
return context.collection.tabIndex(local.value);
|
|
311
|
+
},
|
|
312
|
+
get disabled() {
|
|
313
|
+
return disabled();
|
|
314
|
+
},
|
|
315
|
+
get "aria-pressed"() {
|
|
316
|
+
return pressed();
|
|
317
|
+
},
|
|
318
|
+
get "data-pressed"() {
|
|
319
|
+
return pressed() ? "" : undefined;
|
|
320
|
+
},
|
|
321
|
+
get "data-disabled"() {
|
|
322
|
+
return disabled() ? "" : undefined;
|
|
323
|
+
},
|
|
324
|
+
get "data-key"() {
|
|
325
|
+
return local.value;
|
|
326
|
+
},
|
|
327
|
+
get "data-orientation"() {
|
|
328
|
+
return context.orientation();
|
|
329
|
+
},
|
|
330
|
+
get "data-variant"() {
|
|
331
|
+
return context.variant || local.variant;
|
|
332
|
+
},
|
|
333
|
+
get "data-size"() {
|
|
334
|
+
return context.size || local.size;
|
|
335
|
+
},
|
|
336
|
+
get class() {
|
|
337
|
+
return cn(
|
|
338
|
+
toggleVariants({
|
|
339
|
+
variant: context.variant || local.variant,
|
|
340
|
+
size: context.size || local.size,
|
|
341
|
+
}),
|
|
342
|
+
"relative isolate min-w-max flex-1 shrink-0 rounded-md px-4 shadow-none focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first-of-type:border-l",
|
|
343
|
+
// A hover fill would read as a second, squarer selection, so hover only tints the text.
|
|
344
|
+
context.sliding
|
|
345
|
+
? "hover:text-(--material-accent)"
|
|
346
|
+
: "data-[pressed]:bg-muted data-[pressed]:text-foreground not-data-[pressed]:hover:text-(--material-accent)",
|
|
347
|
+
local.class,
|
|
348
|
+
);
|
|
349
|
+
},
|
|
350
|
+
})}
|
|
131
351
|
>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<>
|
|
137
|
-
<SelectionHighlight />
|
|
138
|
-
{typeof content === "function" ? content(state) : content}
|
|
139
|
-
</>
|
|
140
|
-
);
|
|
141
|
-
}}
|
|
142
|
-
</ToggleGroupPrimitive.Item>
|
|
352
|
+
<SelectionHighlight />
|
|
353
|
+
{content()}
|
|
354
|
+
</Polymorphic>
|
|
143
355
|
);
|
|
144
356
|
};
|
|
145
357
|
|