@glasshome/ui 1.42.0 → 1.44.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 +8 -5
- 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 -3
- 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 +9 -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 +62 -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 +2 -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/data-table.d.ts +4 -2
- 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 +7752 -13493
- 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-BbIeGt7o.js} +376 -314
- 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 +41 -9
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +56 -28
- package/src/lib/behavior/dismiss.ts +61 -21
- package/src/lib/behavior/focus-scope.ts +75 -9
- package/src/lib/behavior/hide-outside.ts +2 -2
- package/src/lib/behavior/layer-stack.ts +33 -8
- package/src/lib/behavior/menu.ts +462 -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 +8 -9
- 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 +4 -4
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/bottom-sheet/arbitration.ts +4 -11
- package/src/solid/bottom-sheet/bottom-sheet.tsx +4 -5
- package/src/solid/bottom-sheet/drag-controller.ts +7 -20
- 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/data-table.tsx +48 -22
- package/src/solid/dialog-parts.tsx +39 -17
- package/src/solid/dock.tsx +44 -43
- package/src/solid/dropdown-menu.tsx +252 -115
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +3 -3
- 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/icon-picker.tsx +1 -2
- 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 +610 -155
- package/src/solid/option-card.tsx +7 -13
- package/src/solid/picker-row.tsx +5 -1
- package/src/solid/popover.tsx +423 -80
- 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 +939 -95
- package/src/solid/selection.tsx +165 -74
- package/src/solid/sheet.tsx +1 -1
- package/src/solid/slider.tsx +115 -65
- package/src/solid/sliding-indicator.tsx +4 -16
- 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 +34 -101
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +24 -24
- package/src/styles/globals.css +61 -50
- package/src/styles/theme.css +12 -6
- package/src/tokens/material.ts +11 -2
package/src/solid/sonner.tsx
CHANGED
|
@@ -186,7 +186,7 @@ const toast = Object.assign(
|
|
|
186
186
|
warning: show("warning"),
|
|
187
187
|
info: show("info"),
|
|
188
188
|
message: show("message"),
|
|
189
|
-
/** @deprecated
|
|
189
|
+
/** @deprecated `toast.promise`; removed in 2.0.0. */
|
|
190
190
|
loading: (message: ToastMessage, data: ExternalToast = {}) => {
|
|
191
191
|
const { description, icon, action, ...rest } = data;
|
|
192
192
|
return sonnerToast.custom(
|
package/src/solid/tabs.tsx
CHANGED
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
} from "solid-js";
|
|
15
15
|
import { type Collection, createCollection } from "../lib/behavior/collection.js";
|
|
16
16
|
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
17
|
-
import { CANDIDATES, focusWithoutTracking,
|
|
17
|
+
import { CANDIDATES, focusWithoutTracking, trackFocus } from "../lib/behavior/focus-scope.js";
|
|
18
18
|
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
19
19
|
import { effect, merge } from "../lib/behavior/solid.js";
|
|
20
20
|
import { TRACK_SURFACE } from "../lib/card-classes.js";
|
|
21
21
|
import { PRESS_DIP, SETTLE_MOTION } from "../lib/motion-classes.js";
|
|
22
22
|
import { SCROLL_TRACK_FADE, trackScroll } from "../lib/scroll-track.js";
|
|
23
|
-
import { SEGMENT_ITEM } from "../lib/segment-classes.js";
|
|
23
|
+
import { SEGMENT_ITEM, SEGMENT_RADIUS } from "../lib/segment-classes.js";
|
|
24
24
|
import { cn } from "../lib/utils.js";
|
|
25
25
|
import { Icon } from "./icon.js";
|
|
26
26
|
import { SelectionHighlight, SelectionScope } from "./selection.js";
|
|
@@ -181,7 +181,7 @@ const TabsList: Component<TabsListProps> = (props) => {
|
|
|
181
181
|
const [el, setEl] = createSignal<HTMLElement>();
|
|
182
182
|
onMount(() => {
|
|
183
183
|
const listEl = el();
|
|
184
|
-
if (listEl) onCleanup(trackScroll(listEl, "[data-selected]",
|
|
184
|
+
if (listEl) onCleanup(trackScroll(listEl, "[data-selected]", ctx.value));
|
|
185
185
|
});
|
|
186
186
|
onCleanup(() => ctx.setList(undefined));
|
|
187
187
|
|
|
@@ -224,7 +224,11 @@ const TabsList: Component<TabsListProps> = (props) => {
|
|
|
224
224
|
>
|
|
225
225
|
{/* w-max so triggers keep their natural width and the track scrolls;
|
|
226
226
|
w-full alone squeezed them past the rounded edge, unreachable. */}
|
|
227
|
-
<SelectionScope
|
|
227
|
+
<SelectionScope
|
|
228
|
+
marker="selected"
|
|
229
|
+
radius={SEGMENT_RADIUS}
|
|
230
|
+
class="flex h-full w-max min-w-full items-center gap-1"
|
|
231
|
+
>
|
|
228
232
|
{local.children}
|
|
229
233
|
</SelectionScope>
|
|
230
234
|
</Polymorphic>
|
|
@@ -268,6 +272,7 @@ const TabsTrigger: Component<TabsTriggerProps> = (props) => {
|
|
|
268
272
|
effect(el, (node) => {
|
|
269
273
|
if (!node) return;
|
|
270
274
|
let mousePressed = false;
|
|
275
|
+
const focused = trackFocus(node);
|
|
271
276
|
const choose = () => {
|
|
272
277
|
if (disabled()) return;
|
|
273
278
|
ctx.select(local.value);
|
|
@@ -280,7 +285,7 @@ const TabsTrigger: Component<TabsTriggerProps> = (props) => {
|
|
|
280
285
|
};
|
|
281
286
|
const click = (event: MouseEvent) => {
|
|
282
287
|
// WebKit leaves a clicked button unfocused.
|
|
283
|
-
if (!disabled() && !
|
|
288
|
+
if (!disabled() && !focused.has()) focusWithoutTracking(node);
|
|
284
289
|
if (event.detail === 0 || !mousePressed) choose();
|
|
285
290
|
mousePressed = false;
|
|
286
291
|
};
|
|
@@ -289,6 +294,7 @@ const TabsTrigger: Component<TabsTriggerProps> = (props) => {
|
|
|
289
294
|
node.addEventListener("click", click);
|
|
290
295
|
node.addEventListener("focus", focus);
|
|
291
296
|
return () => {
|
|
297
|
+
focused.stop();
|
|
292
298
|
node.removeEventListener("pointerdown", pointerdown);
|
|
293
299
|
node.removeEventListener("click", click);
|
|
294
300
|
node.removeEventListener("focus", focus);
|
|
@@ -349,7 +355,7 @@ const TabsTrigger: Component<TabsTriggerProps> = (props) => {
|
|
|
349
355
|
},
|
|
350
356
|
})}
|
|
351
357
|
>
|
|
352
|
-
<SelectionHighlight />
|
|
358
|
+
<SelectionHighlight active={selected()} />
|
|
353
359
|
{local.icon && (
|
|
354
360
|
<Icon
|
|
355
361
|
data-slot={local.inline ? "tabs-trigger-inline-icon" : "tabs-trigger-icon"}
|
package/src/solid/term.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Popover as PopoverPrimitive } from "@kobalte/core/popover";
|
|
2
1
|
import { type JSX, Show } from "solid-js";
|
|
3
2
|
import { cn } from "../lib/utils.js";
|
|
4
3
|
import { Icon } from "./icon.js";
|
|
5
|
-
import { Popover, PopoverContent } from "./popover.js";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
6
5
|
import { SectionIcon } from "./section-card.js";
|
|
7
6
|
|
|
8
7
|
export interface TermDefinition {
|
|
@@ -17,7 +16,7 @@ export interface TermDefinition {
|
|
|
17
16
|
export function Term(props: { term: TermDefinition; children?: JSX.Element; class?: string }) {
|
|
18
17
|
return (
|
|
19
18
|
<Popover>
|
|
20
|
-
<
|
|
19
|
+
<PopoverTrigger
|
|
21
20
|
data-slot="term"
|
|
22
21
|
class={cn(
|
|
23
22
|
"decoration-muted-foreground/60 hover:decoration-foreground cursor-help underline decoration-dotted underline-offset-4 outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-[var(--material-accent)]",
|
|
@@ -25,7 +24,7 @@ export function Term(props: { term: TermDefinition; children?: JSX.Element; clas
|
|
|
25
24
|
)}
|
|
26
25
|
>
|
|
27
26
|
{props.children ?? props.term.title}
|
|
28
|
-
</
|
|
27
|
+
</PopoverTrigger>
|
|
29
28
|
<PopoverContent class="flex w-72 items-start gap-3 text-left">
|
|
30
29
|
<SectionIcon icon={props.term.icon} tone="var(--material-accent)" size="sm" />
|
|
31
30
|
<div class="flex min-w-0 flex-col gap-1">
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
type ComponentProps,
|
|
7
7
|
createContext,
|
|
8
8
|
createSignal,
|
|
9
|
-
createUniqueId,
|
|
10
9
|
type JSX,
|
|
11
10
|
onCleanup,
|
|
12
11
|
onMount,
|
|
@@ -16,14 +15,14 @@ import {
|
|
|
16
15
|
useContext,
|
|
17
16
|
type ValidComponent,
|
|
18
17
|
} from "solid-js";
|
|
19
|
-
import { type Collection, createCollection } from "../lib/behavior/collection.js";
|
|
20
18
|
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
21
|
-
import { focusWithoutTracking, hasFocus } from "../lib/behavior/focus-scope.js";
|
|
22
19
|
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
23
|
-
import {
|
|
24
|
-
import { BALANCED_ROWS, balanceRows } from "../lib/balance-rows.js";
|
|
20
|
+
import { merge, omit } from "../lib/behavior/solid.js";
|
|
21
|
+
import { BALANCE_CONTENT, BALANCED_ROWS, balanceRows } from "../lib/balance-rows.js";
|
|
25
22
|
import { TRACK_SURFACE } from "../lib/card-classes.js";
|
|
26
23
|
import { SCROLL_TRACK_FADE, trackScroll } from "../lib/scroll-track.js";
|
|
24
|
+
import { SEGMENT_RADIUS } from "../lib/segment-classes.js";
|
|
25
|
+
import { createToggleItem, createToggleSet, type ToggleSet } from "../lib/toggle-set.js";
|
|
27
26
|
import { cn } from "../lib/utils.js";
|
|
28
27
|
import { SelectionHighlight, SelectionScope } from "./selection.js";
|
|
29
28
|
import { toggleVariants } from "./toggle.js";
|
|
@@ -59,14 +58,13 @@ type ToggleGroupProps = Omit<ComponentProps<"div">, "onChange"> &
|
|
|
59
58
|
// Single-select paints the pressed segment with the selection highlight; multi-select has none.
|
|
60
59
|
type ToggleGroupContextValue = VariantProps<typeof toggleVariants> & {
|
|
61
60
|
sliding: boolean;
|
|
62
|
-
id: Accessor<string>;
|
|
63
|
-
orientation: Accessor<Orientation>;
|
|
64
61
|
disabled: Accessor<boolean>;
|
|
65
|
-
|
|
66
|
-
toggle: (value: string) => void;
|
|
67
|
-
collection: Collection;
|
|
62
|
+
set: ToggleSet;
|
|
68
63
|
};
|
|
69
64
|
|
|
65
|
+
// A stacked item keeps its control height: flex-1 in a column would shrink it to its text.
|
|
66
|
+
const STACKED_ITEMS = "[&_[data-slot=toggle-group-item]]:flex-none";
|
|
67
|
+
|
|
70
68
|
const ToggleGroupContext = createContext<ToggleGroupContextValue | null>(null);
|
|
71
69
|
|
|
72
70
|
const useToggleGroup = (): ToggleGroupContextValue => {
|
|
@@ -108,8 +106,6 @@ const ToggleGroup: ParentComponent<ToggleGroupProps> = (props) => {
|
|
|
108
106
|
const sliding = () => !props.multiple;
|
|
109
107
|
const orientation = () => props.orientation ?? "horizontal";
|
|
110
108
|
const vertical = () => orientation() === "vertical";
|
|
111
|
-
const fallbackId = `group-${createUniqueId()}`;
|
|
112
|
-
const id = () => props.id ?? fallbackId;
|
|
113
109
|
const [values, setValues] = createControllableSignal<string[]>({
|
|
114
110
|
value: () => toList(props.value),
|
|
115
111
|
defaultValue: () => toList(props.defaultValue) ?? [],
|
|
@@ -121,29 +117,21 @@ const ToggleGroup: ParentComponent<ToggleGroupProps> = (props) => {
|
|
|
121
117
|
});
|
|
122
118
|
const [root, setRoot] = createSignal<HTMLElement>();
|
|
123
119
|
const [scope, setScope] = createSignal<HTMLElement>();
|
|
124
|
-
const
|
|
120
|
+
const set = createToggleSet({
|
|
125
121
|
root,
|
|
126
122
|
itemSelector: `${ITEM}[data-key]`,
|
|
123
|
+
values,
|
|
124
|
+
setValues,
|
|
125
|
+
multiple: () => props.multiple ?? false,
|
|
127
126
|
orientation,
|
|
128
|
-
|
|
129
|
-
loop: () => true,
|
|
130
|
-
dir: () => (root()?.closest("[dir]")?.getAttribute("dir") === "rtl" ? "rtl" : "ltr"),
|
|
131
|
-
preferred: values,
|
|
127
|
+
id: () => props.id,
|
|
132
128
|
});
|
|
133
129
|
|
|
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
|
-
|
|
142
130
|
onMount(() => {
|
|
143
131
|
const el = root();
|
|
144
132
|
if (!el) return;
|
|
145
|
-
if (props.scroll) onCleanup(trackScroll(el, "[data-pressed]",
|
|
146
|
-
else if (!vertical()) onCleanup(balanceRows(el, scope() ?? el, ITEM));
|
|
133
|
+
if (props.scroll) onCleanup(trackScroll(el, "[data-pressed]", values));
|
|
134
|
+
else if (!vertical()) onCleanup(balanceRows(el, scope() ?? el, ITEM, set.members));
|
|
147
135
|
});
|
|
148
136
|
|
|
149
137
|
const context: ToggleGroupContextValue = {
|
|
@@ -156,12 +144,8 @@ const ToggleGroup: ParentComponent<ToggleGroupProps> = (props) => {
|
|
|
156
144
|
get sliding() {
|
|
157
145
|
return sliding();
|
|
158
146
|
},
|
|
159
|
-
id,
|
|
160
|
-
orientation,
|
|
161
147
|
disabled: () => props.disabled ?? false,
|
|
162
|
-
|
|
163
|
-
toggle,
|
|
164
|
-
collection,
|
|
148
|
+
set,
|
|
165
149
|
};
|
|
166
150
|
|
|
167
151
|
return (
|
|
@@ -175,7 +159,7 @@ const ToggleGroup: ParentComponent<ToggleGroupProps> = (props) => {
|
|
|
175
159
|
},
|
|
176
160
|
role: "group",
|
|
177
161
|
get id() {
|
|
178
|
-
return id();
|
|
162
|
+
return set.id();
|
|
179
163
|
},
|
|
180
164
|
get "data-orientation"() {
|
|
181
165
|
return orientation();
|
|
@@ -189,17 +173,20 @@ const ToggleGroup: ParentComponent<ToggleGroupProps> = (props) => {
|
|
|
189
173
|
get "data-scroll"() {
|
|
190
174
|
return props.scroll ? "" : undefined;
|
|
191
175
|
},
|
|
192
|
-
|
|
176
|
+
get [BALANCED_ROWS]() {
|
|
177
|
+
return props.scroll || vertical() || sliding() ? undefined : "";
|
|
178
|
+
},
|
|
179
|
+
"on:keydown": (event: KeyboardEvent) => set.collection.onKeyDown(event),
|
|
193
180
|
get class() {
|
|
194
181
|
return cn(
|
|
195
182
|
`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
183
|
props.scroll
|
|
197
184
|
? `flex [scrollbar-width:none] flex-nowrap overflow-x-auto ${SCROLL_TRACK_FADE}`
|
|
198
185
|
: vertical()
|
|
199
|
-
?
|
|
186
|
+
? `flex flex-col items-stretch ${STACKED_ITEMS}`
|
|
200
187
|
: sliding()
|
|
201
188
|
? "flex"
|
|
202
|
-
:
|
|
189
|
+
: undefined,
|
|
203
190
|
props.class,
|
|
204
191
|
);
|
|
205
192
|
},
|
|
@@ -212,13 +199,15 @@ const ToggleGroup: ParentComponent<ToggleGroupProps> = (props) => {
|
|
|
212
199
|
<SelectionScope
|
|
213
200
|
ref={setScope}
|
|
214
201
|
marker="pressed"
|
|
202
|
+
radius={SEGMENT_RADIUS}
|
|
215
203
|
tone={props.tone}
|
|
204
|
+
{...{ [BALANCED_ROWS]: props.scroll || vertical() ? undefined : "" }}
|
|
216
205
|
class={
|
|
217
206
|
props.scroll
|
|
218
207
|
? "flex w-max flex-nowrap items-center"
|
|
219
208
|
: vertical()
|
|
220
|
-
?
|
|
221
|
-
:
|
|
209
|
+
? `flex w-full flex-col items-stretch gap-y-0.5 ${STACKED_ITEMS}`
|
|
210
|
+
: "w-full items-center gap-y-1"
|
|
222
211
|
}
|
|
223
212
|
>
|
|
224
213
|
{props.children}
|
|
@@ -252,80 +241,24 @@ const ToggleGroupItem: Component<ToggleGroupItemProps> = (props) => {
|
|
|
252
241
|
"ref",
|
|
253
242
|
"as",
|
|
254
243
|
]);
|
|
255
|
-
const fallbackId = `${context.id()}-item-${createUniqueId()}`;
|
|
256
|
-
const [el, setEl] = createSignal<HTMLElement>();
|
|
257
244
|
const disabled = () => local.disabled || context.disabled();
|
|
258
|
-
|
|
259
|
-
onCleanup(() => context.collection.refresh());
|
|
260
|
-
const pressed = () => context.isPressed(local.value);
|
|
261
|
-
const state: ToggleGroupItemState = { pressed };
|
|
245
|
+
const item = createToggleItem(context.set, { value: () => local.value, disabled });
|
|
262
246
|
const content = children(() => {
|
|
263
247
|
const body = local.children;
|
|
264
|
-
return typeof body === "function" ? 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
|
-
};
|
|
248
|
+
return typeof body === "function" ? body({ pressed: item.pressed }) : body;
|
|
295
249
|
});
|
|
296
250
|
|
|
297
251
|
return (
|
|
298
252
|
<Polymorphic
|
|
299
|
-
{...merge({ "data-slot": "toggle-group-item" }, rest, {
|
|
253
|
+
{...merge({ "data-slot": "toggle-group-item" }, rest, item.props, {
|
|
300
254
|
as: local.as,
|
|
301
255
|
defaultAs: "button" as ValidComponent,
|
|
302
256
|
ref: (node: HTMLElement) => {
|
|
303
|
-
|
|
257
|
+
item.ref(node);
|
|
304
258
|
if (typeof local.ref === "function") local.ref(node as HTMLButtonElement);
|
|
305
259
|
},
|
|
306
260
|
get id() {
|
|
307
|
-
return local.id ??
|
|
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();
|
|
261
|
+
return local.id ?? item.props.id;
|
|
329
262
|
},
|
|
330
263
|
get "data-variant"() {
|
|
331
264
|
return context.variant || local.variant;
|
|
@@ -349,8 +282,8 @@ const ToggleGroupItem: Component<ToggleGroupItemProps> = (props) => {
|
|
|
349
282
|
},
|
|
350
283
|
})}
|
|
351
284
|
>
|
|
352
|
-
<SelectionHighlight />
|
|
353
|
-
{content()}
|
|
285
|
+
<SelectionHighlight active={item.pressed()} />
|
|
286
|
+
<span {...{ [BALANCE_CONTENT]: "" }}>{content()}</span>
|
|
354
287
|
</Polymorphic>
|
|
355
288
|
);
|
|
356
289
|
};
|
package/src/solid/toggle.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ToggleButton as ToggleButtonPrimitive } from "@kobalte/core/toggle-button";
|
|
2
1
|
import { cva, type VariantProps } from "cva";
|
|
3
|
-
import { type
|
|
2
|
+
import { type Accessor, children, type JSX, splitProps } from "solid-js";
|
|
3
|
+
import { ButtonRoot, type ButtonRootProps } from "../lib/behavior/button-root.js";
|
|
4
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
5
|
+
import { callEventHandler } from "../lib/behavior/solid.js";
|
|
4
6
|
import { OUTLINE_SURFACE } from "../lib/button-variants.js";
|
|
5
7
|
import { CONTROL_H } from "../lib/input-classes.js";
|
|
6
8
|
import { SEGMENT_ITEM } from "../lib/segment-classes.js";
|
|
@@ -36,13 +38,39 @@ const TOGGLE_HOVER: Record<"default" | "outline", string> = {
|
|
|
36
38
|
outline: "",
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
type ToggleProps = Omit<ButtonRootProps<"button">, "children" | "onChange"> &
|
|
42
|
+
VariantProps<typeof toggleVariants> & {
|
|
43
|
+
pressed?: boolean;
|
|
44
|
+
defaultPressed?: boolean;
|
|
45
|
+
onChange?: (pressed: boolean) => void;
|
|
46
|
+
children?: JSX.Element | ((state: { pressed: Accessor<boolean> }) => JSX.Element);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function Toggle(props: ToggleProps) {
|
|
50
|
+
const [local, rest] = splitProps(props, [
|
|
51
|
+
"class",
|
|
52
|
+
"variant",
|
|
53
|
+
"size",
|
|
54
|
+
"pressed",
|
|
55
|
+
"defaultPressed",
|
|
56
|
+
"onChange",
|
|
57
|
+
"onClick",
|
|
58
|
+
"children",
|
|
59
|
+
]);
|
|
60
|
+
const [pressed, setPressed] = createControllableSignal({
|
|
61
|
+
value: () => local.pressed,
|
|
62
|
+
defaultValue: () => local.defaultPressed ?? false,
|
|
63
|
+
onChange: (next) => local.onChange?.(next),
|
|
64
|
+
});
|
|
65
|
+
const content = children(() => {
|
|
66
|
+
const body = local.children;
|
|
67
|
+
return typeof body === "function" ? body({ pressed }) : body;
|
|
68
|
+
});
|
|
43
69
|
return (
|
|
44
|
-
<
|
|
70
|
+
<ButtonRoot
|
|
45
71
|
data-slot="toggle"
|
|
72
|
+
aria-pressed={pressed()}
|
|
73
|
+
data-pressed={pressed() ? "" : undefined}
|
|
46
74
|
class={cn(
|
|
47
75
|
toggleVariants({ variant: local.variant, size: local.size }),
|
|
48
76
|
TOGGLE_HOVER[local.variant ?? "default"],
|
|
@@ -50,8 +78,14 @@ const Toggle: Component<
|
|
|
50
78
|
local.class,
|
|
51
79
|
)}
|
|
52
80
|
{...rest}
|
|
53
|
-
|
|
81
|
+
onClick={(event: MouseEvent & { currentTarget: HTMLButtonElement; target: Element }) => {
|
|
82
|
+
callEventHandler(event, local.onClick);
|
|
83
|
+
if (!rest.disabled) setPressed(!pressed());
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{content()}
|
|
87
|
+
</ButtonRoot>
|
|
54
88
|
);
|
|
55
|
-
}
|
|
89
|
+
}
|
|
56
90
|
|
|
57
91
|
export { Toggle, toggleVariants };
|
package/src/solid/tooltip.tsx
CHANGED
|
@@ -38,52 +38,52 @@ interface TooltipRootProps {
|
|
|
38
38
|
openDelay?: number;
|
|
39
39
|
closeDelay?: number;
|
|
40
40
|
children?: JSX.Element;
|
|
41
|
-
/** @deprecated Ignored. */
|
|
41
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
42
42
|
id?: string;
|
|
43
|
-
/** @deprecated Ignored. */
|
|
43
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
44
44
|
disabled?: boolean;
|
|
45
|
-
/** @deprecated Ignored. */
|
|
45
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
46
46
|
skipDelayDuration?: number;
|
|
47
|
-
/** @deprecated Ignored. */
|
|
47
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
48
48
|
triggerOnFocusOnly?: boolean;
|
|
49
|
-
/** @deprecated Ignored. */
|
|
49
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
50
50
|
ignoreSafeArea?: boolean;
|
|
51
|
-
/** @deprecated Ignored. */
|
|
51
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
52
52
|
forceMount?: boolean;
|
|
53
|
-
/** @deprecated Ignored. */
|
|
53
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
54
54
|
getAnchorRect?: (anchor?: HTMLElement) => unknown;
|
|
55
|
-
/** @deprecated Ignored. */
|
|
55
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
56
56
|
shift?: number;
|
|
57
|
-
/** @deprecated Ignored. */
|
|
57
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
58
58
|
flip?: boolean | string;
|
|
59
|
-
/** @deprecated Ignored. */
|
|
59
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
60
60
|
slide?: boolean;
|
|
61
|
-
/** @deprecated Ignored. */
|
|
61
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
62
62
|
overlap?: boolean;
|
|
63
|
-
/** @deprecated Ignored. */
|
|
63
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
64
64
|
sameWidth?: boolean;
|
|
65
|
-
/** @deprecated Ignored. */
|
|
65
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
66
66
|
fitViewport?: boolean;
|
|
67
|
-
/** @deprecated Ignored. */
|
|
67
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
68
68
|
hideWhenDetached?: boolean;
|
|
69
|
-
/** @deprecated Ignored. */
|
|
69
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
70
70
|
detachedPadding?: number;
|
|
71
|
-
/** @deprecated Ignored. */
|
|
71
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
72
72
|
arrowPadding?: number;
|
|
73
|
-
/** @deprecated Ignored. */
|
|
73
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
74
74
|
overflowPadding?: number;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
interface TooltipContentProps extends ComponentProps<"div"> {
|
|
78
|
-
/** @deprecated Ignored. */
|
|
78
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
79
79
|
forceMount?: boolean;
|
|
80
|
-
/** @deprecated Ignored. */
|
|
80
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
81
81
|
onEscapeKeyDown?: (event: Event) => void;
|
|
82
|
-
/** @deprecated Ignored. */
|
|
82
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
83
83
|
onPointerDownOutside?: (event: Event) => void;
|
|
84
|
-
/** @deprecated Ignored. */
|
|
84
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
85
85
|
onFocusOutside?: (event: Event) => void;
|
|
86
|
-
/** @deprecated Ignored. */
|
|
86
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
87
87
|
onInteractOutside?: (event: Event) => void;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -291,10 +291,10 @@ const TooltipContent: Component<TooltipContentProps> = (props) => {
|
|
|
291
291
|
);
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
-
/** @deprecated
|
|
294
|
+
/** @deprecated Drop the wrapper; the content portals itself; removed in 2.0.0. */
|
|
295
295
|
const TooltipPortal: Component<{ children?: JSX.Element }> = (props) => <>{props.children}</>;
|
|
296
296
|
|
|
297
|
-
/** @deprecated
|
|
297
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
298
298
|
const TooltipArrow: Component = () => null;
|
|
299
299
|
|
|
300
300
|
const Tooltip = Object.assign(TooltipRoot, {
|
package/src/styles/globals.css
CHANGED
|
@@ -418,21 +418,17 @@
|
|
|
418
418
|
background:
|
|
419
419
|
var(--glass-grain, none),
|
|
420
420
|
radial-gradient(
|
|
421
|
-
var(--glass-sheen, 120% 120%) at
|
|
422
|
-
calc(50% + (-28% * var(--_material-light-cos) + 42% * var(--_material-light-sin)))
|
|
423
|
-
calc(50% + (-28% * var(--_material-light-sin) - 42% * var(--_material-light-cos))),
|
|
421
|
+
var(--glass-sheen, 120% 120%) at var(--_material-sheen-at),
|
|
424
422
|
oklch(1 0 0 / calc(var(--glass-light) * var(--_material-sheen))),
|
|
425
423
|
transparent 58%
|
|
426
424
|
),
|
|
427
425
|
radial-gradient(
|
|
428
|
-
120% 120% at
|
|
429
|
-
calc(50% + (32% * var(--_material-light-sin) + 50% * var(--_material-light-cos))),
|
|
426
|
+
120% 120% at var(--_material-shade-at),
|
|
430
427
|
oklch(0 0 0 / calc(var(--glass-shade) * var(--_material-sheen))),
|
|
431
428
|
transparent 58%
|
|
432
429
|
),
|
|
433
430
|
radial-gradient(
|
|
434
|
-
circle at
|
|
435
|
-
calc(50% - 12% * var(--_material-light-cos)),
|
|
431
|
+
circle at var(--_material-relief-at),
|
|
436
432
|
oklch(1 0 0 / calc(0.07 * var(--_material-face-raised) * var(--_material-relief))),
|
|
437
433
|
transparent 70%
|
|
438
434
|
),
|
|
@@ -787,49 +783,6 @@
|
|
|
787
783
|
}
|
|
788
784
|
}
|
|
789
785
|
|
|
790
|
-
/* Children arrive one after another. Mount-only (a CSS animation runs when
|
|
791
|
-
* the child is inserted), so a live re-render never re-staggers; a child
|
|
792
|
-
* added later takes its own slot, capped so a long list never waits. The
|
|
793
|
-
* travel is `translate`, never `transform`, so a positioned child (the
|
|
794
|
-
* sliding indicator) keeps its own transform. A group is transparent: its
|
|
795
|
-
* rows take slots, it does not. Slots come from --i: nth-child below for a
|
|
796
|
-
* flat list, or written inline by a part that knows its true order. */
|
|
797
|
-
@keyframes stagger-in {
|
|
798
|
-
from {
|
|
799
|
-
opacity: 0;
|
|
800
|
-
/* Upward: a child of a scroll container must not extend its scrollable
|
|
801
|
-
* height mid-animation, and rows trail a downward-growing edge. */
|
|
802
|
-
translate: 0 -8px;
|
|
803
|
-
}
|
|
804
|
-
to {
|
|
805
|
-
opacity: 1;
|
|
806
|
-
translate: 0 0;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
.gh-stagger > :not([role="group"], [data-selection-flyer]),
|
|
810
|
-
.gh-stagger > [role="group"] > * {
|
|
811
|
-
animation: stagger-in calc(var(--duration-morph) * 0.5) var(--ease-emphasis) both;
|
|
812
|
-
animation-delay: calc(var(--stagger-base, 80ms) + var(--i, 0) * var(--stagger-step, 60ms));
|
|
813
|
-
}
|
|
814
|
-
.gh-stagger > :nth-child(2) {
|
|
815
|
-
--i: 1;
|
|
816
|
-
}
|
|
817
|
-
.gh-stagger > :nth-child(3) {
|
|
818
|
-
--i: 2;
|
|
819
|
-
}
|
|
820
|
-
.gh-stagger > :nth-child(4) {
|
|
821
|
-
--i: 3;
|
|
822
|
-
}
|
|
823
|
-
.gh-stagger > :nth-child(5) {
|
|
824
|
-
--i: 4;
|
|
825
|
-
}
|
|
826
|
-
.gh-stagger > :nth-child(6) {
|
|
827
|
-
--i: 5;
|
|
828
|
-
}
|
|
829
|
-
.gh-stagger > :nth-child(n + 7) {
|
|
830
|
-
--i: 6;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
786
|
/* Selection (solid/selection.tsx). Plain CSS on data attributes: a published widget compiles its
|
|
834
787
|
* utilities from the ui source it was built against, so a new utility here would be missing there. */
|
|
835
788
|
[data-selection-highlight],
|
|
@@ -862,6 +815,25 @@
|
|
|
862
815
|
[data-on][data-selection-highlight][data-landing] {
|
|
863
816
|
visibility: hidden;
|
|
864
817
|
}
|
|
818
|
+
/* Balanced rows (lib/balance-rows.ts): a wrapping row until the column count is known. */
|
|
819
|
+
@layer base {
|
|
820
|
+
[data-balanced-rows] {
|
|
821
|
+
display: flex;
|
|
822
|
+
flex-wrap: wrap;
|
|
823
|
+
}
|
|
824
|
+
[data-balanced-rows][data-balanced] {
|
|
825
|
+
display: grid;
|
|
826
|
+
grid-auto-flow: row;
|
|
827
|
+
grid-template-columns: repeat(var(--balance-columns), minmax(max-content, 1fr));
|
|
828
|
+
}
|
|
829
|
+
[data-balance-content] {
|
|
830
|
+
display: inline-flex;
|
|
831
|
+
width: max-content;
|
|
832
|
+
align-items: center;
|
|
833
|
+
justify-content: center;
|
|
834
|
+
gap: inherit;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
865
837
|
/* Its transparent border is part of the segment the old indicator covered. */
|
|
866
838
|
[data-slot="toggle-group-item"] {
|
|
867
839
|
--selection-inset: -1px;
|
|
@@ -875,6 +847,45 @@
|
|
|
875
847
|
}
|
|
876
848
|
[data-selection-flyer][data-flying] {
|
|
877
849
|
display: block;
|
|
850
|
+
animation-name: selection-glide-a, selection-squash-a;
|
|
851
|
+
animation-duration: var(--duration-slide);
|
|
852
|
+
animation-timing-function: ease-in-out;
|
|
853
|
+
}
|
|
854
|
+
/* A second name per flight restarts the keyframes when a flight redirects mid-air. */
|
|
855
|
+
[data-selection-flyer][data-flying="b"] {
|
|
856
|
+
animation-name: selection-glide-b, selection-squash-b;
|
|
857
|
+
}
|
|
858
|
+
@keyframes selection-glide-a {
|
|
859
|
+
from {
|
|
860
|
+
translate: var(--selection-from);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
@keyframes selection-glide-b {
|
|
864
|
+
from {
|
|
865
|
+
translate: var(--selection-from);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
@keyframes selection-squash-a {
|
|
869
|
+
from {
|
|
870
|
+
scale: var(--selection-scale-from);
|
|
871
|
+
}
|
|
872
|
+
50% {
|
|
873
|
+
scale: var(--selection-scale-peak);
|
|
874
|
+
}
|
|
875
|
+
to {
|
|
876
|
+
scale: 1 1;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
@keyframes selection-squash-b {
|
|
880
|
+
from {
|
|
881
|
+
scale: var(--selection-scale-from);
|
|
882
|
+
}
|
|
883
|
+
50% {
|
|
884
|
+
scale: var(--selection-scale-peak);
|
|
885
|
+
}
|
|
886
|
+
to {
|
|
887
|
+
scale: 1 1;
|
|
888
|
+
}
|
|
878
889
|
}
|
|
879
890
|
|
|
880
891
|
/* Icon: the box a glyph sits in, sized by its width/height attributes. */
|