@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.
Files changed (188) hide show
  1. package/SPEC.md +5 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/lib/anchor-placement.d.ts +34 -0
  5. package/dist/lib/balance-rows.d.ts +10 -4
  6. package/dist/lib/behavior/anchored.d.ts +26 -0
  7. package/dist/lib/behavior/button-root.d.ts +7 -0
  8. package/dist/lib/behavior/collection.d.ts +32 -0
  9. package/dist/lib/behavior/controllable.d.ts +8 -0
  10. package/dist/lib/behavior/dismiss.d.ts +13 -0
  11. package/dist/lib/behavior/focus-scope.d.ts +24 -0
  12. package/dist/lib/behavior/hide-outside.d.ts +7 -0
  13. package/dist/lib/behavior/layer-stack.d.ts +34 -0
  14. package/dist/lib/behavior/menu.d.ts +59 -0
  15. package/dist/lib/behavior/modal-root.d.ts +68 -0
  16. package/dist/lib/behavior/polymorphic.d.ts +6 -0
  17. package/dist/lib/behavior/presence.d.ts +18 -0
  18. package/dist/lib/behavior/range.d.ts +44 -0
  19. package/dist/lib/behavior/solid.d.ts +13 -0
  20. package/dist/lib/color/color.d.ts +41 -0
  21. package/dist/lib/color/index.d.ts +2 -0
  22. package/dist/lib/color/intl.d.ts +40 -0
  23. package/dist/lib/dock-slot-classes.d.ts +2 -0
  24. package/dist/lib/hold.d.ts +1 -1
  25. package/dist/lib/locale.d.ts +3 -0
  26. package/dist/lib/menu-classes.d.ts +2 -0
  27. package/dist/lib/motion-classes.d.ts +5 -2
  28. package/dist/lib/overlay-classes.d.ts +4 -0
  29. package/dist/lib/page-cover.d.ts +8 -0
  30. package/dist/lib/scroll-track.d.ts +3 -2
  31. package/dist/lib/section-tokens.d.ts +1 -1
  32. package/dist/lib/segment-classes.d.ts +2 -0
  33. package/dist/lib/shadow-layer.d.ts +0 -43
  34. package/dist/lib/toggle-set.d.ts +44 -0
  35. package/dist/lib/visually-hidden.d.ts +3 -0
  36. package/dist/solid/accordion.d.ts +35 -11
  37. package/dist/solid/alert-dialog.d.ts +5 -8
  38. package/dist/solid/avatar.d.ts +8 -4
  39. package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -2
  40. package/dist/solid/bottom-sheet/constants.d.ts +1 -1
  41. package/dist/solid/button.d.ts +5 -4
  42. package/dist/solid/charts.d.ts +1 -1
  43. package/dist/solid/checkbox.d.ts +14 -4
  44. package/dist/solid/collapsible.d.ts +33 -5
  45. package/dist/solid/color-disc.d.ts +1 -1
  46. package/dist/solid/color-slider.d.ts +1 -1
  47. package/dist/solid/color-wheel.d.ts +1 -1
  48. package/dist/solid/context-menu.d.ts +58 -24
  49. package/dist/solid/dialog-parts.d.ts +53 -16
  50. package/dist/solid/dialog.d.ts +7 -10
  51. package/dist/solid/dropdown-menu.d.ts +55 -24
  52. package/dist/solid/empty.d.ts +1 -1
  53. package/dist/solid/form.d.ts +5 -6
  54. package/dist/solid/hover-card.d.ts +65 -9
  55. package/dist/solid/index.d.ts +5 -2
  56. package/dist/solid/index.js +8671 -14317
  57. package/dist/solid/input-group.d.ts +6 -6
  58. package/dist/solid/item.d.ts +1 -1
  59. package/dist/solid/menu-parts.d.ts +175 -24
  60. package/dist/solid/option-card.d.ts +1 -4
  61. package/dist/solid/picker-row.d.ts +2 -0
  62. package/dist/solid/popover.d.ts +77 -12
  63. package/dist/solid/progress.d.ts +11 -3
  64. package/dist/solid/radio-group.d.ts +31 -6
  65. package/dist/solid/responsive-dialog.d.ts +3 -1
  66. package/dist/solid/scroll-area.d.ts +1 -1
  67. package/dist/solid/section-card.d.ts +2 -3
  68. package/dist/solid/select.d.ts +107 -10
  69. package/dist/solid/selection.d.ts +10 -1
  70. package/dist/solid/sheet.d.ts +6 -9
  71. package/dist/solid/sliding-indicator.d.ts +1 -1
  72. package/dist/solid/sonner.d.ts +1 -1
  73. package/dist/solid/stale-veil.d.ts +7 -0
  74. package/dist/solid/tabs.d.ts +28 -9
  75. package/dist/solid/toggle-group.d.ts +30 -5
  76. package/dist/solid/toggle.d.ts +11 -3
  77. package/dist/solid/tooltip.d.ts +71 -9
  78. package/dist/tokens/index.js +54 -51
  79. package/dist/{utils-CGN4X-2O.js → utils-3Codx-NZ.js} +848 -618
  80. package/package.json +6 -7
  81. package/src/index.ts +1 -0
  82. package/src/lib/anchor-placement.ts +77 -4
  83. package/src/lib/balance-rows.ts +115 -40
  84. package/src/lib/behavior/anchored.ts +106 -0
  85. package/src/lib/behavior/button-root.tsx +103 -0
  86. package/src/lib/behavior/collection.ts +218 -0
  87. package/src/lib/behavior/controllable.ts +22 -0
  88. package/src/lib/behavior/dismiss.ts +185 -0
  89. package/src/lib/behavior/focus-scope.ts +227 -0
  90. package/src/lib/behavior/hide-outside.ts +85 -0
  91. package/src/lib/behavior/layer-stack.ts +150 -0
  92. package/src/lib/behavior/menu.ts +470 -0
  93. package/src/lib/behavior/modal-root.tsx +452 -0
  94. package/src/lib/behavior/polymorphic.tsx +30 -0
  95. package/src/lib/behavior/presence.ts +89 -0
  96. package/src/lib/behavior/range.ts +212 -0
  97. package/src/lib/behavior/solid.ts +30 -0
  98. package/src/lib/clipboard.ts +4 -4
  99. package/src/lib/color/color.ts +746 -0
  100. package/src/lib/color/index.ts +2 -0
  101. package/src/lib/color/intl.ts +60 -0
  102. package/src/lib/dock-slot-classes.ts +3 -0
  103. package/src/lib/hold.ts +1 -1
  104. package/src/lib/locale.ts +62 -0
  105. package/src/lib/menu-classes.ts +3 -0
  106. package/src/lib/motion-classes.ts +33 -8
  107. package/src/lib/overlay-classes.ts +8 -3
  108. package/src/lib/page-cover.ts +47 -0
  109. package/src/lib/scroll-track.ts +11 -6
  110. package/src/lib/section-tokens.ts +1 -1
  111. package/src/lib/segment-classes.ts +3 -0
  112. package/src/lib/shadow-layer.ts +0 -136
  113. package/src/lib/toggle-set.ts +133 -0
  114. package/src/lib/visually-hidden.ts +15 -0
  115. package/src/solid/accordion.tsx +294 -20
  116. package/src/solid/alert-dialog.tsx +36 -85
  117. package/src/solid/area-picker.tsx +5 -3
  118. package/src/solid/avatar.tsx +98 -24
  119. package/src/solid/badge.tsx +5 -5
  120. package/src/solid/bottom-sheet/bottom-sheet.tsx +73 -129
  121. package/src/solid/bottom-sheet/constants.ts +3 -1
  122. package/src/solid/bottom-sheet/drag-controller.ts +11 -0
  123. package/src/solid/breadcrumb.tsx +4 -4
  124. package/src/solid/button-group.tsx +4 -4
  125. package/src/solid/button.tsx +12 -6
  126. package/src/solid/card.tsx +5 -4
  127. package/src/solid/charts.tsx +1 -1
  128. package/src/solid/checkbox.tsx +167 -44
  129. package/src/solid/collapsible.tsx +260 -12
  130. package/src/solid/color-disc.tsx +11 -12
  131. package/src/solid/color-slider.tsx +114 -47
  132. package/src/solid/color-wheel.tsx +137 -39
  133. package/src/solid/context-menu.tsx +287 -86
  134. package/src/solid/dialog-parts.tsx +135 -46
  135. package/src/solid/dialog.tsx +44 -76
  136. package/src/solid/dock-edit.tsx +5 -4
  137. package/src/solid/dock.tsx +6 -5
  138. package/src/solid/dropdown-menu.tsx +252 -107
  139. package/src/solid/empty.tsx +1 -1
  140. package/src/solid/entity-selector.tsx +5 -3
  141. package/src/solid/face-toggle.tsx +43 -18
  142. package/src/solid/form.tsx +9 -9
  143. package/src/solid/glyph-tile.tsx +48 -21
  144. package/src/solid/hover-card.tsx +288 -21
  145. package/src/solid/icon-picker.tsx +2 -1
  146. package/src/solid/image-picker.tsx +6 -5
  147. package/src/solid/index.ts +5 -4
  148. package/src/solid/input-group.tsx +7 -5
  149. package/src/solid/input-otp.tsx +2 -1
  150. package/src/solid/item.tsx +5 -5
  151. package/src/solid/logo.tsx +5 -4
  152. package/src/solid/menu-parts.tsx +619 -145
  153. package/src/solid/option-card.tsx +6 -10
  154. package/src/solid/picker-row.tsx +10 -5
  155. package/src/solid/picker-search.tsx +2 -1
  156. package/src/solid/popover.tsx +424 -71
  157. package/src/solid/preview-tile.tsx +1 -1
  158. package/src/solid/progress.tsx +84 -15
  159. package/src/solid/radio-group.tsx +271 -34
  160. package/src/solid/responsive-dialog.tsx +10 -10
  161. package/src/solid/schema-form.tsx +1 -6
  162. package/src/solid/scroll-area.tsx +1 -1
  163. package/src/solid/section-card.tsx +3 -4
  164. package/src/solid/select.tsx +950 -95
  165. package/src/solid/selection.tsx +142 -66
  166. package/src/solid/sheet.tsx +48 -80
  167. package/src/solid/slider.tsx +115 -65
  168. package/src/solid/sliding-indicator.tsx +1 -1
  169. package/src/solid/sonner.tsx +1 -1
  170. package/src/solid/spotlight.tsx +23 -11
  171. package/src/solid/stale-veil.tsx +20 -0
  172. package/src/solid/switch.tsx +8 -6
  173. package/src/solid/tabs.tsx +377 -52
  174. package/src/solid/term.tsx +3 -4
  175. package/src/solid/toggle-group.tsx +237 -95
  176. package/src/solid/toggle.tsx +43 -9
  177. package/src/solid/tooltip.tsx +285 -26
  178. package/src/styles/globals.css +64 -10
  179. package/src/styles/theme.css +12 -4
  180. package/src/tokens/material.ts +11 -2
  181. package/dist/lib/when-animations-settle.d.ts +0 -4
  182. package/dist/solid/bottom-sheet/focus-trap.d.ts +0 -6
  183. package/dist/solid/bottom-sheet/scroll-lock.d.ts +0 -2
  184. package/dist/solid/bottom-sheet/sheet-motion.d.ts +0 -1
  185. package/src/lib/when-animations-settle.ts +0 -12
  186. package/src/solid/bottom-sheet/focus-trap.ts +0 -63
  187. package/src/solid/bottom-sheet/scroll-lock.ts +0 -66
  188. package/src/solid/bottom-sheet/sheet-motion.ts +0 -4
@@ -1,7 +1,9 @@
1
- import { Slider as KSlider } from "@kobalte/core/slider";
2
1
  import type { Component } from "solid-js";
3
- import { Index, splitProps } from "solid-js";
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 [local] = splitProps(props, [
37
- "value",
38
- "defaultValue",
39
- "min",
40
- "max",
41
- "step",
42
- "disabled",
43
- "onChange",
44
- "onChangeEnd",
45
- "class",
46
- "trackClass",
47
- "thumbClass",
48
- "thumbColors",
49
- "fillTone",
50
- "markers",
51
- "minStepsBetweenThumbs",
52
- "aria-label",
53
- "aria-labelledby",
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 min = local.min ?? 0;
58
- const max = local.max ?? 100;
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
- <KSlider
64
- value={local.value}
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
- local.disabled && "cursor-not-allowed opacity-50",
81
- local.class,
106
+ disabled() && "cursor-not-allowed opacity-50",
107
+ props.class,
82
108
  )}
83
109
  >
84
- <KSlider.Track
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
- local.disabled ? "cursor-not-allowed" : "cursor-pointer",
89
- local.trackClass,
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
- <KSlider.Fill
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(local.fillTone) && "glass-edge-gradient",
133
+ Array.isArray(props.fillTone) && "glass-edge-gradient",
100
134
  )}
101
- style={
102
- Array.isArray(local.fillTone)
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": local.fillTone[0],
105
- "--glass-tone-2": local.fillTone[1],
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": local.fillTone ?? "var(--material-accent)" }
110
- }
145
+ : { "--glass-tone": props.fillTone ?? "var(--material-accent)" }),
146
+ }}
111
147
  />
112
- <Index each={local.markers ?? []}>
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
- </Index>
124
- <Index each={local.value ?? local.defaultValue ?? [0]}>
125
- {(_, thumbIndex) => (
126
- <KSlider.Thumb
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-200 ease-out hover:scale-125 active:scale-110",
132
- local.disabled && "cursor-not-allowed",
133
- local.thumbClass,
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
- background: local.thumbColors?.[thumbIndex] ?? "var(--material-control-knob)",
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
- <KSlider.Input />
142
- </KSlider.Thumb>
190
+ on:keydown={(e) => range.keyDown(e, index)}
191
+ onBlur={range.blur}
192
+ />
143
193
  )}
144
- </Index>
145
- </KSlider.Track>
146
- </KSlider>
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 Use `SelectionScope` with a `SelectionHighlight` in each item; removed in 2.0. */
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",
@@ -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 Use `toast.promise`, which ends the loading toast when the promise settles. Removed in 2.0.0. */
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(
@@ -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
- let bubble: HTMLDivElement | undefined;
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
- if (bubble)
88
+ const node = bubble();
89
+ if (node)
74
90
  setBubbleSize({
75
- width: bubble.offsetWidth || BUBBLE_DEFAULT_WIDTH,
76
- height: bubble.offsetHeight || 96,
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
- if (bubble) observer.observe(bubble);
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={bubble}
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 };
@@ -1,4 +1,5 @@
1
- import { type Component, type ComponentProps, createSignal, splitProps } from "solid-js";
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 [uncontrolled, setUncontrolled] = createSignal(props.defaultChecked ?? false);
24
- const checked = () => local.checked ?? uncontrolled();
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
- const next = !checked();
48
- setUncontrolled(next);
49
- local.onChange?.(next);
51
+ setChecked(!checked());
50
52
  }}
51
53
  >
52
54
  <span