@glasshome/ui 1.41.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/SPEC.md +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/lib/anchor-placement.d.ts +34 -0
- package/dist/lib/balance-rows.d.ts +10 -4
- package/dist/lib/behavior/anchored.d.ts +26 -0
- package/dist/lib/behavior/button-root.d.ts +7 -0
- package/dist/lib/behavior/collection.d.ts +32 -0
- package/dist/lib/behavior/controllable.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +13 -0
- package/dist/lib/behavior/focus-scope.d.ts +24 -0
- package/dist/lib/behavior/hide-outside.d.ts +7 -0
- package/dist/lib/behavior/layer-stack.d.ts +34 -0
- package/dist/lib/behavior/menu.d.ts +59 -0
- package/dist/lib/behavior/modal-root.d.ts +68 -0
- package/dist/lib/behavior/polymorphic.d.ts +6 -0
- package/dist/lib/behavior/presence.d.ts +18 -0
- package/dist/lib/behavior/range.d.ts +44 -0
- package/dist/lib/behavior/solid.d.ts +13 -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 +5 -2
- package/dist/lib/overlay-classes.d.ts +4 -0
- package/dist/lib/page-cover.d.ts +8 -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 -43
- 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/alert-dialog.d.ts +5 -8
- package/dist/solid/avatar.d.ts +8 -4
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -2
- package/dist/solid/bottom-sheet/constants.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 +53 -16
- package/dist/solid/dialog.d.ts +7 -10
- 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 +5 -2
- package/dist/solid/index.js +8671 -14317
- 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 +3 -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 +6 -9
- package/dist/solid/sliding-indicator.d.ts +1 -1
- package/dist/solid/sonner.d.ts +1 -1
- package/dist/solid/stale-veil.d.ts +7 -0
- package/dist/solid/tabs.d.ts +28 -9
- package/dist/solid/toggle-group.d.ts +30 -5
- package/dist/solid/toggle.d.ts +11 -3
- package/dist/solid/tooltip.d.ts +71 -9
- package/dist/tokens/index.js +54 -51
- package/dist/{utils-CGN4X-2O.js → utils-3Codx-NZ.js} +848 -618
- package/package.json +6 -7
- package/src/index.ts +1 -0
- package/src/lib/anchor-placement.ts +77 -4
- package/src/lib/balance-rows.ts +115 -40
- package/src/lib/behavior/anchored.ts +106 -0
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +218 -0
- package/src/lib/behavior/controllable.ts +22 -0
- package/src/lib/behavior/dismiss.ts +185 -0
- package/src/lib/behavior/focus-scope.ts +227 -0
- package/src/lib/behavior/hide-outside.ts +85 -0
- package/src/lib/behavior/layer-stack.ts +150 -0
- package/src/lib/behavior/menu.ts +470 -0
- package/src/lib/behavior/modal-root.tsx +452 -0
- package/src/lib/behavior/polymorphic.tsx +30 -0
- package/src/lib/behavior/presence.ts +89 -0
- package/src/lib/behavior/range.ts +212 -0
- package/src/lib/behavior/solid.ts +30 -0
- package/src/lib/clipboard.ts +4 -4
- 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 +33 -8
- package/src/lib/overlay-classes.ts +8 -3
- package/src/lib/page-cover.ts +47 -0
- 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 -136
- 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/alert-dialog.tsx +36 -85
- package/src/solid/area-picker.tsx +5 -3
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/badge.tsx +5 -5
- package/src/solid/bottom-sheet/bottom-sheet.tsx +73 -129
- 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/button.tsx +12 -6
- package/src/solid/card.tsx +5 -4
- 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 +287 -86
- package/src/solid/dialog-parts.tsx +135 -46
- package/src/solid/dialog.tsx +44 -76
- package/src/solid/dock-edit.tsx +5 -4
- package/src/solid/dock.tsx +6 -5
- package/src/solid/dropdown-menu.tsx +252 -107
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +5 -3
- package/src/solid/face-toggle.tsx +43 -18
- package/src/solid/form.tsx +9 -9
- package/src/solid/glyph-tile.tsx +48 -21
- package/src/solid/hover-card.tsx +288 -21
- package/src/solid/icon-picker.tsx +2 -1
- package/src/solid/image-picker.tsx +6 -5
- package/src/solid/index.ts +5 -4
- package/src/solid/input-group.tsx +7 -5
- package/src/solid/input-otp.tsx +2 -1
- package/src/solid/item.tsx +5 -5
- package/src/solid/logo.tsx +5 -4
- package/src/solid/menu-parts.tsx +619 -145
- package/src/solid/option-card.tsx +6 -10
- package/src/solid/picker-row.tsx +10 -5
- package/src/solid/picker-search.tsx +2 -1
- package/src/solid/popover.tsx +424 -71
- 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 +10 -10
- 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 +48 -80
- 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/spotlight.tsx +23 -11
- package/src/solid/stale-veil.tsx +20 -0
- package/src/solid/switch.tsx +8 -6
- package/src/solid/tabs.tsx +377 -52
- package/src/solid/term.tsx +3 -4
- package/src/solid/toggle-group.tsx +237 -95
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +285 -26
- package/src/styles/globals.css +64 -10
- package/src/styles/theme.css +12 -4
- package/src/tokens/material.ts +11 -2
- 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
package/src/solid/slider.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Slider as KSlider } from "@kobalte/core/slider";
|
|
2
1
|
import type { Component } from "solid-js";
|
|
3
|
-
import {
|
|
2
|
+
import { createMemo, createSignal, For } from "solid-js";
|
|
3
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
4
|
+
import { alongTrack, createDrag, createRange } from "../lib/behavior/range.js";
|
|
4
5
|
import { FIELD_CHROME, FOCUS_RING } from "../lib/input-classes.js";
|
|
6
|
+
import { locale, readingDirection } from "../lib/locale.js";
|
|
5
7
|
import { THUMB_CLASS, THUMB_RAIL_BLEED, THUMB_RAIL_PAD } from "../lib/thumb-classes.js";
|
|
6
8
|
import { cn } from "../lib/utils.js";
|
|
7
9
|
|
|
@@ -32,118 +34,166 @@ interface SliderProps {
|
|
|
32
34
|
"aria-labelledby"?: string;
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
const decimal = new Intl.NumberFormat(locale, { style: "decimal" });
|
|
38
|
+
const rtl = readingDirection === "rtl";
|
|
39
|
+
const START = rtl ? "right" : "left";
|
|
40
|
+
const END = rtl ? "left" : "right";
|
|
41
|
+
const THUMB_SHIFT = rtl ? "translateX(50%)" : "translateX(-50%)";
|
|
42
|
+
|
|
35
43
|
const Slider: Component<SliderProps> = (props) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]);
|
|
44
|
+
const min = () => props.min ?? 0;
|
|
45
|
+
const max = () => props.max ?? 100;
|
|
46
|
+
const disabled = () => props.disabled ?? false;
|
|
47
|
+
const range = createRange({
|
|
48
|
+
values: () => props.value,
|
|
49
|
+
defaultValues: () => props.defaultValue ?? [min()],
|
|
50
|
+
min,
|
|
51
|
+
max,
|
|
52
|
+
step: () => props.step ?? 1,
|
|
53
|
+
minStepsBetween: () => props.minStepsBetweenThumbs ?? 0,
|
|
54
|
+
disabled,
|
|
55
|
+
onChange: (values) => props.onChange?.(values),
|
|
56
|
+
onChangeEnd: (values) => props.onChangeEnd?.(values),
|
|
57
|
+
});
|
|
58
|
+
const indices = createMemo(() => range.values().map((_, i) => i), [], {
|
|
59
|
+
equals: (a, b) => a.length === b.length,
|
|
60
|
+
});
|
|
61
|
+
const percents = () => range.values().map((v) => range.fraction(v) * 100);
|
|
62
|
+
const [thumbs, setThumbs] = createSignal<HTMLElement[]>([]);
|
|
63
|
+
let active = 0;
|
|
64
|
+
let grab = 0;
|
|
65
|
+
|
|
66
|
+
const drag = createDrag({
|
|
67
|
+
disabled,
|
|
68
|
+
start: (e, rect) => {
|
|
69
|
+
const thumb = (e.target as Element).closest('[data-slot="slider-thumb"]');
|
|
70
|
+
const pressed = thumbs().findIndex((el) => el === thumb);
|
|
71
|
+
const at = alongTrack(e, rect);
|
|
72
|
+
if (pressed >= 0) {
|
|
73
|
+
active = pressed;
|
|
74
|
+
grab = at - range.fraction(range.values()[pressed] ?? 0);
|
|
75
|
+
} else {
|
|
76
|
+
const raw = min() + at * (max() - min());
|
|
77
|
+
grab = 0;
|
|
78
|
+
active = range.closestThumb(raw);
|
|
79
|
+
range.setThumb(active, raw);
|
|
80
|
+
}
|
|
81
|
+
focusWithoutTracking(thumbs()[active]);
|
|
82
|
+
},
|
|
83
|
+
move: (e, rect) => range.setThumb(active, range.valueAt(alongTrack(e, rect) - grab)),
|
|
84
|
+
end: range.dragEnd,
|
|
85
|
+
});
|
|
55
86
|
|
|
56
87
|
const markerPct = (v: number) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
return max === min ? 0 : ((v - min) / (max - min)) * 100;
|
|
88
|
+
const span = max() - min();
|
|
89
|
+
return span === 0 ? 0 : ((v - min()) / span) * 100;
|
|
60
90
|
};
|
|
61
91
|
|
|
92
|
+
const disabledMark = () => (disabled() ? "" : undefined);
|
|
93
|
+
|
|
62
94
|
return (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
defaultValue={local.defaultValue}
|
|
66
|
-
minValue={local.min ?? 0}
|
|
67
|
-
maxValue={local.max ?? 100}
|
|
68
|
-
step={local.step ?? 1}
|
|
69
|
-
minStepsBetweenThumbs={local.minStepsBetweenThumbs}
|
|
70
|
-
disabled={local.disabled}
|
|
71
|
-
onChange={local.onChange}
|
|
72
|
-
onChangeEnd={local.onChangeEnd}
|
|
95
|
+
<div
|
|
96
|
+
role="group"
|
|
73
97
|
data-slot="slider"
|
|
98
|
+
data-orientation="horizontal"
|
|
99
|
+
data-disabled={disabledMark()}
|
|
74
100
|
class={cn(
|
|
75
101
|
// The rail wears the shared toggle/rail chrome, so it reads as an empty
|
|
76
102
|
// well in both themes (a field's light-theme fill rises to the card).
|
|
77
103
|
"relative flex w-full touch-none items-center rounded-xl select-none",
|
|
78
104
|
THUMB_RAIL_PAD,
|
|
79
105
|
FIELD_CHROME,
|
|
80
|
-
|
|
81
|
-
|
|
106
|
+
disabled() && "cursor-not-allowed opacity-50",
|
|
107
|
+
props.class,
|
|
82
108
|
)}
|
|
83
109
|
>
|
|
84
|
-
<
|
|
110
|
+
<div
|
|
85
111
|
data-slot="slider-track"
|
|
112
|
+
data-orientation="horizontal"
|
|
113
|
+
data-disabled={disabledMark()}
|
|
86
114
|
class={cn(
|
|
87
115
|
"relative h-7 w-full",
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
disabled() ? "cursor-not-allowed" : "cursor-pointer",
|
|
117
|
+
props.trackClass,
|
|
90
118
|
)}
|
|
119
|
+
on:pointerdown={drag.onPointerDown}
|
|
120
|
+
on:pointermove={drag.onPointerMove}
|
|
121
|
+
on:pointerup={drag.onPointerUp}
|
|
122
|
+
on:pointercancel={drag.onPointerCancel}
|
|
91
123
|
>
|
|
92
|
-
<
|
|
124
|
+
<div
|
|
93
125
|
data-slot="slider-fill"
|
|
126
|
+
data-orientation="horizontal"
|
|
127
|
+
data-disabled={disabledMark()}
|
|
94
128
|
class={cn(
|
|
95
129
|
// The fill sits sunk inside the recessed rail: the tinted-surface
|
|
96
130
|
// outer drop shadow would read as a halo leaking out of the groove.
|
|
97
131
|
"glass glass-tint absolute inset-y-0 rounded-xl [--glass-drop:0%] [--glass-wash:90%]",
|
|
98
132
|
THUMB_RAIL_BLEED,
|
|
99
|
-
Array.isArray(
|
|
133
|
+
Array.isArray(props.fillTone) && "glass-edge-gradient",
|
|
100
134
|
)}
|
|
101
|
-
style={
|
|
102
|
-
|
|
135
|
+
style={{
|
|
136
|
+
[START]: `${percents().length > 1 ? Math.min(...percents()) : 0}%`,
|
|
137
|
+
[END]: `${100 - Math.max(...percents())}%`,
|
|
138
|
+
...(Array.isArray(props.fillTone)
|
|
103
139
|
? {
|
|
104
|
-
"--glass-tone":
|
|
105
|
-
"--glass-tone-2":
|
|
140
|
+
"--glass-tone": props.fillTone[0],
|
|
141
|
+
"--glass-tone-2": props.fillTone[1],
|
|
106
142
|
"--glass-wash-2": "var(--glass-wash)",
|
|
107
143
|
"--glass-wash-angle": "90deg",
|
|
108
144
|
}
|
|
109
|
-
: { "--glass-tone":
|
|
110
|
-
}
|
|
145
|
+
: { "--glass-tone": props.fillTone ?? "var(--material-accent)" }),
|
|
146
|
+
}}
|
|
111
147
|
/>
|
|
112
|
-
<
|
|
148
|
+
<For each={props.markers ?? []}>
|
|
113
149
|
{(marker) => (
|
|
114
150
|
<span
|
|
115
151
|
data-slot="slider-marker"
|
|
116
152
|
class="pointer-events-none absolute top-1/2 h-3 w-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full"
|
|
117
153
|
style={{
|
|
118
|
-
left: `${markerPct(marker
|
|
154
|
+
left: `${markerPct(marker)}%`,
|
|
119
155
|
background: "color-mix(in oklab, var(--foreground) 60%, transparent)",
|
|
120
156
|
}}
|
|
121
157
|
/>
|
|
122
158
|
)}
|
|
123
|
-
</
|
|
124
|
-
<
|
|
125
|
-
{(
|
|
126
|
-
<
|
|
159
|
+
</For>
|
|
160
|
+
<For each={indices()}>
|
|
161
|
+
{(index) => (
|
|
162
|
+
<span
|
|
163
|
+
ref={(el) => setThumbs((all) => Object.assign(all.slice(), { [index]: el }))}
|
|
164
|
+
role="slider"
|
|
127
165
|
data-slot="slider-thumb"
|
|
166
|
+
data-orientation="horizontal"
|
|
167
|
+
data-disabled={disabledMark()}
|
|
168
|
+
tabIndex={disabled() ? undefined : 0}
|
|
169
|
+
aria-label={props["aria-label"]}
|
|
170
|
+
aria-labelledby={props["aria-labelledby"]}
|
|
171
|
+
aria-valuemin={min()}
|
|
172
|
+
aria-valuemax={max()}
|
|
173
|
+
aria-valuenow={range.values()[index]}
|
|
174
|
+
aria-valuetext={decimal.format(range.values()[index] ?? 0)}
|
|
175
|
+
aria-orientation="horizontal"
|
|
176
|
+
aria-disabled={disabled() || undefined}
|
|
128
177
|
class={cn(
|
|
129
178
|
THUMB_CLASS,
|
|
130
179
|
FOCUS_RING,
|
|
131
|
-
"absolute top-0 transition-transform duration-
|
|
132
|
-
|
|
133
|
-
|
|
180
|
+
"absolute top-0 transition-transform duration-(--duration-expand) ease-out hover:scale-125 active:scale-110",
|
|
181
|
+
disabled() && "cursor-not-allowed",
|
|
182
|
+
props.thumbClass,
|
|
134
183
|
)}
|
|
135
|
-
aria-label={local["aria-label"]}
|
|
136
|
-
aria-labelledby={local["aria-labelledby"]}
|
|
137
184
|
style={{
|
|
138
|
-
|
|
185
|
+
[START]: `calc(${percents()[index] ?? 0}%)`,
|
|
186
|
+
transform: THUMB_SHIFT,
|
|
187
|
+
"touch-action": "none",
|
|
188
|
+
background: props.thumbColors?.[index] ?? "var(--material-control-knob)",
|
|
139
189
|
}}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
190
|
+
on:keydown={(e) => range.keyDown(e, index)}
|
|
191
|
+
onBlur={range.blur}
|
|
192
|
+
/>
|
|
143
193
|
)}
|
|
144
|
-
</
|
|
145
|
-
</
|
|
146
|
-
</
|
|
194
|
+
</For>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
147
197
|
);
|
|
148
198
|
};
|
|
149
199
|
|
|
@@ -75,7 +75,7 @@ const STRETCH_PX = 6; // grow along travel
|
|
|
75
75
|
const SQUASH_PX = 6; // pinch perpendicular
|
|
76
76
|
const DEFORM_MAX = 0.14;
|
|
77
77
|
|
|
78
|
-
/** @deprecated
|
|
78
|
+
/** @deprecated `SelectionScope` with a `SelectionHighlight` in each item; removed in 2.0.0. */
|
|
79
79
|
export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
80
80
|
const [local, rest] = splitProps(props, [
|
|
81
81
|
"active",
|
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/spotlight.tsx
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from "solid-js";
|
|
10
10
|
import { Portal } from "solid-js/web";
|
|
11
11
|
import { usePortalMount } from "./portal-mount.js";
|
|
12
|
+
import { createDismiss } from "../lib/behavior/dismiss.js";
|
|
13
|
+
import { registerLayer } from "../lib/behavior/layer-stack.js";
|
|
12
14
|
import { Z_CLASS } from "../lib/layers.js";
|
|
13
15
|
import { SCRIM_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
|
|
14
16
|
import { OVERLAY_SURFACE_OPAQUE, PANEL_TAIL, SCRIM_CLASS } from "../lib/overlay-classes.js";
|
|
@@ -54,7 +56,20 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
54
56
|
{ width: BUBBLE_DEFAULT_WIDTH, height: 96 },
|
|
55
57
|
{ equals: sameFields },
|
|
56
58
|
);
|
|
57
|
-
|
|
59
|
+
const [bubble, setBubble] = createSignal<HTMLDivElement>();
|
|
60
|
+
const handle = registerLayer({
|
|
61
|
+
element: bubble,
|
|
62
|
+
open: () => true,
|
|
63
|
+
kind: "tour",
|
|
64
|
+
escape: () => props.onSkip !== undefined,
|
|
65
|
+
dismiss: () => props.onSkip?.(),
|
|
66
|
+
});
|
|
67
|
+
createDismiss({
|
|
68
|
+
layer: handle,
|
|
69
|
+
outsidePress: () => false,
|
|
70
|
+
escapeFrom: "document",
|
|
71
|
+
onDismiss: () => props.onSkip?.(),
|
|
72
|
+
});
|
|
58
73
|
|
|
59
74
|
const anchorEl = () => props.anchor ?? props.target;
|
|
60
75
|
|
|
@@ -70,10 +85,11 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
70
85
|
const anchor = anchorEl();
|
|
71
86
|
/* Same element as target: reuse its box instead of measuring it twice a tick. */
|
|
72
87
|
setAnchorBox(anchor === props.target ? targetBox : rectToBox(anchor));
|
|
73
|
-
|
|
88
|
+
const node = bubble();
|
|
89
|
+
if (node)
|
|
74
90
|
setBubbleSize({
|
|
75
|
-
width:
|
|
76
|
-
height:
|
|
91
|
+
width: node.offsetWidth || BUBBLE_DEFAULT_WIDTH,
|
|
92
|
+
height: node.offsetHeight || 96,
|
|
77
93
|
});
|
|
78
94
|
};
|
|
79
95
|
|
|
@@ -97,7 +113,8 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
97
113
|
const observer = new ResizeObserver(measure);
|
|
98
114
|
if (target) observer.observe(target);
|
|
99
115
|
if (anchor && anchor !== target) observer.observe(anchor);
|
|
100
|
-
|
|
116
|
+
const node = bubble();
|
|
117
|
+
if (node) observer.observe(node);
|
|
101
118
|
onCleanup(() => {
|
|
102
119
|
cancelAnimationFrame(raf);
|
|
103
120
|
observer.disconnect();
|
|
@@ -105,16 +122,11 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
105
122
|
});
|
|
106
123
|
|
|
107
124
|
onMount(() => {
|
|
108
|
-
const onKey = (e: KeyboardEvent) => {
|
|
109
|
-
if (e.key === "Escape") props.onSkip?.();
|
|
110
|
-
};
|
|
111
125
|
window.addEventListener("resize", measure);
|
|
112
126
|
window.addEventListener("scroll", measure, { capture: true, passive: true });
|
|
113
|
-
document.addEventListener("keydown", onKey);
|
|
114
127
|
onCleanup(() => {
|
|
115
128
|
window.removeEventListener("resize", measure);
|
|
116
129
|
window.removeEventListener("scroll", measure, { capture: true });
|
|
117
|
-
document.removeEventListener("keydown", onKey);
|
|
118
130
|
});
|
|
119
131
|
});
|
|
120
132
|
|
|
@@ -142,7 +154,7 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
142
154
|
/>
|
|
143
155
|
</Show>
|
|
144
156
|
<div
|
|
145
|
-
ref={
|
|
157
|
+
ref={setBubble}
|
|
146
158
|
data-slot="spotlight-bubble"
|
|
147
159
|
data-side={place().side}
|
|
148
160
|
class={cn(TRAVEL_MOTION, Z_CLASS.overlay, "fixed top-0 left-0 w-96", props.class)}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Component, Show } from "solid-js";
|
|
2
|
+
import { VEIL_MOTION } from "../lib/motion-classes.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
|
|
5
|
+
/** Fills its positioned parent; no z-index, so it paints over earlier siblings: render it last. */
|
|
6
|
+
const StaleVeil: Component<{ shown: boolean; class?: string }> = (props) => (
|
|
7
|
+
<Show when={props.shown}>
|
|
8
|
+
<div
|
|
9
|
+
data-slot="stale-veil"
|
|
10
|
+
aria-hidden="true"
|
|
11
|
+
class={cn(
|
|
12
|
+
"bg-background/40 pointer-events-none absolute inset-0 rounded-[inherit]",
|
|
13
|
+
VEIL_MOTION,
|
|
14
|
+
props.class,
|
|
15
|
+
)}
|
|
16
|
+
/>
|
|
17
|
+
</Show>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export { StaleVeil };
|
package/src/solid/switch.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Component, type ComponentProps,
|
|
1
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
2
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
2
3
|
import { CONTROL_ON, FIELD_CHROME, FOCUS_RING } from "../lib/input-classes.js";
|
|
3
4
|
import { THUMB_CLASS } from "../lib/thumb-classes.js";
|
|
4
5
|
import { cn } from "../lib/utils.js";
|
|
@@ -20,8 +21,11 @@ const Switch: Component<SwitchProps> = (props) => {
|
|
|
20
21
|
"name",
|
|
21
22
|
"busy",
|
|
22
23
|
]);
|
|
23
|
-
const [
|
|
24
|
-
|
|
24
|
+
const [checked, setChecked] = createControllableSignal<boolean>({
|
|
25
|
+
value: () => local.checked,
|
|
26
|
+
defaultValue: () => props.defaultChecked ?? false,
|
|
27
|
+
onChange: (next) => local.onChange?.(next),
|
|
28
|
+
});
|
|
25
29
|
|
|
26
30
|
return (
|
|
27
31
|
<button
|
|
@@ -44,9 +48,7 @@ const Switch: Component<SwitchProps> = (props) => {
|
|
|
44
48
|
)}
|
|
45
49
|
onClick={() => {
|
|
46
50
|
if (local.busy) return;
|
|
47
|
-
|
|
48
|
-
setUncontrolled(next);
|
|
49
|
-
local.onChange?.(next);
|
|
51
|
+
setChecked(!checked());
|
|
50
52
|
}}
|
|
51
53
|
>
|
|
52
54
|
<span
|