@glasshome/ui 1.10.0 → 1.10.1

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 (103) hide show
  1. package/package.json +5 -2
  2. package/scripts/check-pack.ts +32 -0
  3. package/src/index.ts +111 -0
  4. package/src/solid/accordion.tsx +60 -0
  5. package/src/solid/alert-dialog.tsx +148 -0
  6. package/src/solid/alert.tsx +118 -0
  7. package/src/solid/area-picker.tsx +225 -0
  8. package/src/solid/aspect-ratio.tsx +21 -0
  9. package/src/solid/avatar.tsx +41 -0
  10. package/src/solid/badge.tsx +74 -0
  11. package/src/solid/bottom-sheet/arbitration.ts +40 -0
  12. package/src/solid/bottom-sheet/bottom-sheet.tsx +457 -0
  13. package/src/solid/bottom-sheet/constants.ts +8 -0
  14. package/src/solid/bottom-sheet/drag-controller.ts +221 -0
  15. package/src/solid/bottom-sheet/focus-trap.ts +56 -0
  16. package/src/solid/bottom-sheet/index.ts +14 -0
  17. package/src/solid/bottom-sheet/keyboard.ts +35 -0
  18. package/src/solid/bottom-sheet/scroll-lock.ts +64 -0
  19. package/src/solid/bottom-sheet/state-machine.ts +40 -0
  20. package/src/solid/bottom-sheet/velocity.ts +42 -0
  21. package/src/solid/breadcrumb.tsx +105 -0
  22. package/src/solid/button-group.tsx +66 -0
  23. package/src/solid/button.tsx +20 -0
  24. package/src/solid/card.tsx +101 -0
  25. package/src/solid/carousel.tsx +302 -0
  26. package/src/solid/charts.tsx +338 -0
  27. package/src/solid/checkbox.tsx +70 -0
  28. package/src/solid/collapsible.tsx +38 -0
  29. package/src/solid/color-slider.tsx +98 -0
  30. package/src/solid/color-wheel.tsx +77 -0
  31. package/src/solid/context-menu.tsx +109 -0
  32. package/src/solid/copy-button.tsx +46 -0
  33. package/src/solid/count-pill.tsx +24 -0
  34. package/src/solid/data-table.tsx +248 -0
  35. package/src/solid/dialog-parts.tsx +242 -0
  36. package/src/solid/dialog.tsx +121 -0
  37. package/src/solid/dock.tsx +186 -0
  38. package/src/solid/dropdown-menu.tsx +130 -0
  39. package/src/solid/empty.tsx +99 -0
  40. package/src/solid/entity-data.ts +78 -0
  41. package/src/solid/entity-selector.tsx +697 -0
  42. package/src/solid/field.tsx +253 -0
  43. package/src/solid/form.tsx +231 -0
  44. package/src/solid/hero-action.tsx +117 -0
  45. package/src/solid/hover-card.tsx +26 -0
  46. package/src/solid/icon-picker.tsx +432 -0
  47. package/src/solid/icon.tsx +20 -0
  48. package/src/solid/image-picker.tsx +380 -0
  49. package/src/solid/index.ts +417 -0
  50. package/src/solid/input-group.tsx +170 -0
  51. package/src/solid/input-otp.tsx +175 -0
  52. package/src/solid/input.tsx +12 -0
  53. package/src/solid/item.tsx +179 -0
  54. package/src/solid/kbd.tsx +30 -0
  55. package/src/solid/label.tsx +19 -0
  56. package/src/solid/list-reorder.ts +148 -0
  57. package/src/solid/logo.tsx +79 -0
  58. package/src/solid/media-copy.ts +37 -0
  59. package/src/solid/media-store.ts +110 -0
  60. package/src/solid/media-tile.tsx +100 -0
  61. package/src/solid/menu-parts.tsx +248 -0
  62. package/src/solid/number-field.tsx +72 -0
  63. package/src/solid/option-card.tsx +218 -0
  64. package/src/solid/ornament.tsx +53 -0
  65. package/src/solid/overlay.tsx +16 -0
  66. package/src/solid/page-header.tsx +102 -0
  67. package/src/solid/pagination.tsx +111 -0
  68. package/src/solid/password-input.tsx +69 -0
  69. package/src/solid/picker-row.tsx +102 -0
  70. package/src/solid/picker-search.tsx +78 -0
  71. package/src/solid/popover.tsx +103 -0
  72. package/src/solid/progress.tsx +31 -0
  73. package/src/solid/radio-group.tsx +60 -0
  74. package/src/solid/resizable.tsx +149 -0
  75. package/src/solid/responsive-dialog.tsx +180 -0
  76. package/src/solid/schema-form.tsx +830 -0
  77. package/src/solid/scope-indicator.tsx +13 -0
  78. package/src/solid/scroll-area.tsx +27 -0
  79. package/src/solid/section-card.tsx +358 -0
  80. package/src/solid/select.tsx +139 -0
  81. package/src/solid/separator.tsx +35 -0
  82. package/src/solid/settings-row.tsx +159 -0
  83. package/src/solid/sheet.tsx +157 -0
  84. package/src/solid/skeleton.tsx +15 -0
  85. package/src/solid/slider.tsx +148 -0
  86. package/src/solid/sliding-indicator.tsx +294 -0
  87. package/src/solid/sonner.tsx +219 -0
  88. package/src/solid/spinner.tsx +20 -0
  89. package/src/solid/step-indicator.tsx +30 -0
  90. package/src/solid/switch.tsx +62 -0
  91. package/src/solid/table.tsx +98 -0
  92. package/src/solid/tabs.tsx +86 -0
  93. package/src/solid/textarea.tsx +16 -0
  94. package/src/solid/toggle-group.tsx +102 -0
  95. package/src/solid/toggle.tsx +57 -0
  96. package/src/solid/tooltip.tsx +38 -0
  97. package/src/solid/widget-card.tsx +117 -0
  98. package/src/solid/widget-identity.tsx +135 -0
  99. package/src/solid/widget-trust-badge.tsx +37 -0
  100. package/src/tokens/hex.ts +50 -0
  101. package/src/tokens/index.ts +8 -0
  102. package/src/tokens/presets.ts +192 -0
  103. package/src/tokens/theme-colors.ts +147 -0
@@ -0,0 +1,432 @@
1
+ import { createMemo, createSignal, For, Show } from "solid-js";
2
+ import { STAGGER } from "../lib/motion-classes.js";
3
+ import { PICKER_LIST, PICKER_TRIGGER } from "../lib/picker-classes.js";
4
+ import { CHIP, ICON_PILL_TINT } from "../lib/pill-classes.js";
5
+ import { cn } from "../lib/utils.js";
6
+ import { Icon } from "./icon.js";
7
+ import { PickerSearch } from "./picker-search.js";
8
+ import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
9
+
10
+ const ICON_LIBRARIES = [
11
+ { prefix: "", label: "All" },
12
+ { prefix: "mdi", label: "MDI" },
13
+ { prefix: "lucide", label: "Lucide" },
14
+ { prefix: "solar", label: "Solar" },
15
+ { prefix: "tabler", label: "Tabler" },
16
+ { prefix: "ph", label: "Phosphor" },
17
+ { prefix: "fluent", label: "Fluent" },
18
+ ] as const;
19
+
20
+ const COMMON_ICONS: Record<string, string[]> = {
21
+ mdi: [
22
+ "mdi:home",
23
+ "mdi:home-outline",
24
+ "mdi:lightbulb",
25
+ "mdi:lightbulb-outline",
26
+ "mdi:lamp",
27
+ "mdi:ceiling-light",
28
+ "mdi:floor-lamp",
29
+ "mdi:led-strip",
30
+ "mdi:power-plug",
31
+ "mdi:power-socket",
32
+ "mdi:toggle-switch",
33
+ "mdi:thermometer",
34
+ "mdi:thermostat",
35
+ "mdi:air-conditioner",
36
+ "mdi:fan",
37
+ "mdi:water",
38
+ "mdi:fire",
39
+ "mdi:snowflake",
40
+ "mdi:weather-partly-cloudy",
41
+ "mdi:lock",
42
+ "mdi:lock-open",
43
+ "mdi:door",
44
+ "mdi:door-open",
45
+ "mdi:window-closed",
46
+ "mdi:window-open",
47
+ "mdi:garage",
48
+ "mdi:gate",
49
+ "mdi:blinds",
50
+ "mdi:television",
51
+ "mdi:speaker",
52
+ "mdi:cast",
53
+ "mdi:camera",
54
+ "mdi:cctv",
55
+ "mdi:motion-sensor",
56
+ "mdi:smoke-detector",
57
+ "mdi:bell",
58
+ "mdi:battery",
59
+ "mdi:solar-power",
60
+ "mdi:robot-vacuum",
61
+ "mdi:washing-machine",
62
+ "mdi:fridge",
63
+ "mdi:stove",
64
+ "mdi:bed",
65
+ "mdi:sofa",
66
+ "mdi:shower",
67
+ "mdi:car",
68
+ "mdi:wifi",
69
+ "mdi:router-wireless",
70
+ "mdi:view-dashboard",
71
+ "mdi:cog",
72
+ "mdi:star",
73
+ "mdi:heart",
74
+ "mdi:shield-home",
75
+ "mdi:home-floor-1",
76
+ "mdi:home-floor-2",
77
+ "mdi:home-floor-3",
78
+ "mdi:home-group",
79
+ "mdi:office-building",
80
+ ],
81
+ lucide: [
82
+ "lucide:home",
83
+ "lucide:lightbulb",
84
+ "lucide:lamp",
85
+ "lucide:lamp-desk",
86
+ "lucide:plug",
87
+ "lucide:power",
88
+ "lucide:thermometer",
89
+ "lucide:flame",
90
+ "lucide:snowflake",
91
+ "lucide:wind",
92
+ "lucide:droplets",
93
+ "lucide:sun",
94
+ "lucide:cloud-sun",
95
+ "lucide:lock",
96
+ "lucide:lock-open",
97
+ "lucide:door-open",
98
+ "lucide:door-closed",
99
+ "lucide:blinds",
100
+ "lucide:tv",
101
+ "lucide:speaker",
102
+ "lucide:camera",
103
+ "lucide:bell",
104
+ "lucide:battery",
105
+ "lucide:car",
106
+ "lucide:wifi",
107
+ "lucide:router",
108
+ "lucide:layout-dashboard",
109
+ "lucide:settings",
110
+ "lucide:star",
111
+ "lucide:heart",
112
+ "lucide:shield",
113
+ "lucide:eye",
114
+ "lucide:zap",
115
+ "lucide:clock",
116
+ "lucide:calendar",
117
+ "lucide:link",
118
+ "lucide:image",
119
+ "lucide:music",
120
+ "lucide:map-pin",
121
+ "lucide:user",
122
+ ],
123
+ solar: [
124
+ "solar:home-bold",
125
+ "solar:home-linear",
126
+ "solar:lamp-bold",
127
+ "solar:lightbulb-bolt-bold",
128
+ "solar:plug-circle-bold",
129
+ "solar:temperature-bold",
130
+ "solar:fire-bold",
131
+ "solar:snowflake-bold",
132
+ "solar:lock-bold",
133
+ "solar:lock-unlocked-bold",
134
+ "solar:tv-bold",
135
+ "solar:speaker-bold",
136
+ "solar:camera-bold",
137
+ "solar:bell-bold",
138
+ "solar:battery-charge-bold",
139
+ "solar:wi-fi-router-bold",
140
+ "solar:widget-bold",
141
+ "solar:settings-bold",
142
+ "solar:star-bold",
143
+ "solar:heart-bold",
144
+ "solar:shield-bold",
145
+ "solar:eye-bold",
146
+ "solar:bolt-bold",
147
+ "solar:clock-circle-bold",
148
+ "solar:calendar-bold",
149
+ "solar:link-bold",
150
+ "solar:gallery-bold",
151
+ "solar:music-note-bold",
152
+ "solar:map-point-bold",
153
+ "solar:user-bold",
154
+ ],
155
+ tabler: [
156
+ "tabler:home",
157
+ "tabler:bulb",
158
+ "tabler:lamp",
159
+ "tabler:plug",
160
+ "tabler:power",
161
+ "tabler:temperature",
162
+ "tabler:flame",
163
+ "tabler:snowflake",
164
+ "tabler:wind",
165
+ "tabler:droplet",
166
+ "tabler:sun",
167
+ "tabler:cloud",
168
+ "tabler:lock",
169
+ "tabler:lock-open",
170
+ "tabler:door",
171
+ "tabler:window",
172
+ "tabler:device-tv",
173
+ "tabler:speaker",
174
+ "tabler:camera",
175
+ "tabler:bell",
176
+ "tabler:battery",
177
+ "tabler:car",
178
+ "tabler:wifi",
179
+ "tabler:router",
180
+ "tabler:dashboard",
181
+ "tabler:settings",
182
+ "tabler:star",
183
+ "tabler:heart",
184
+ "tabler:shield",
185
+ "tabler:eye",
186
+ ],
187
+ ph: [
188
+ "ph:house-bold",
189
+ "ph:lightbulb-bold",
190
+ "ph:lamp-bold",
191
+ "ph:plug-bold",
192
+ "ph:power-bold",
193
+ "ph:thermometer-bold",
194
+ "ph:fire-bold",
195
+ "ph:snowflake-bold",
196
+ "ph:wind-bold",
197
+ "ph:drop-bold",
198
+ "ph:sun-bold",
199
+ "ph:cloud-sun-bold",
200
+ "ph:lock-bold",
201
+ "ph:lock-open-bold",
202
+ "ph:door-bold",
203
+ "ph:television-bold",
204
+ "ph:speaker-high-bold",
205
+ "ph:camera-bold",
206
+ "ph:bell-bold",
207
+ "ph:battery-charging-bold",
208
+ "ph:car-bold",
209
+ "ph:wifi-high-bold",
210
+ "ph:squares-four-bold",
211
+ "ph:gear-bold",
212
+ "ph:star-bold",
213
+ "ph:heart-bold",
214
+ "ph:shield-bold",
215
+ "ph:eye-bold",
216
+ "ph:lightning-bold",
217
+ "ph:clock-bold",
218
+ ],
219
+ fluent: [
220
+ "fluent:home-24-filled",
221
+ "fluent:lightbulb-24-filled",
222
+ "fluent:plug-connected-24-filled",
223
+ "fluent:power-24-filled",
224
+ "fluent:temperature-24-filled",
225
+ "fluent:fire-24-filled",
226
+ "fluent:weather-snowflake-24-filled",
227
+ "fluent:lock-closed-24-filled",
228
+ "fluent:lock-open-24-filled",
229
+ "fluent:door-24-filled",
230
+ "fluent:tv-24-filled",
231
+ "fluent:speaker-2-24-filled",
232
+ "fluent:camera-24-filled",
233
+ "fluent:alert-24-filled",
234
+ "fluent:battery-charge-24-filled",
235
+ "fluent:vehicle-car-24-filled",
236
+ "fluent:wifi-1-24-filled",
237
+ "fluent:board-24-filled",
238
+ "fluent:settings-24-filled",
239
+ "fluent:star-24-filled",
240
+ "fluent:heart-24-filled",
241
+ "fluent:shield-24-filled",
242
+ "fluent:eye-24-filled",
243
+ "fluent:flash-24-filled",
244
+ "fluent:clock-24-filled",
245
+ "fluent:calendar-24-filled",
246
+ "fluent:link-24-filled",
247
+ "fluent:image-24-filled",
248
+ "fluent:music-note-1-24-filled",
249
+ "fluent:person-24-filled",
250
+ ],
251
+ };
252
+
253
+ export interface IconPickerProps {
254
+ value: string;
255
+ onChange: (value: string) => void;
256
+ placeholder?: string;
257
+ class?: string;
258
+ /**
259
+ * Host-provided icon search. The design system carries no network or CSP
260
+ * policy of its own: dash proxies the Iconify API same-origin so its
261
+ * connect-src allowlist stays free of third-party origins. Without this the
262
+ * picker still works, showing the curated set only.
263
+ */
264
+ searchIcons?: (query: string, prefix: string) => Promise<string[]>;
265
+ /** Id of the element naming the trigger, for forms that label it outside. */
266
+ "aria-labelledby"?: string;
267
+ }
268
+
269
+ export function IconPicker(props: IconPickerProps) {
270
+ const [open, setOpen] = createSignal(false);
271
+ const [search, setSearch] = createSignal("");
272
+ const [activeLib, setActiveLib] = createSignal("");
273
+ const [apiResults, setApiResults] = createSignal<string[]>([]);
274
+ const [loading, setLoading] = createSignal(false);
275
+
276
+ let debounceTimer: ReturnType<typeof setTimeout> | undefined;
277
+ let searchRef: HTMLInputElement | undefined;
278
+
279
+ const searchIcons = (query: string, prefix: string) => {
280
+ clearTimeout(debounceTimer);
281
+ if (!query.trim()) {
282
+ setApiResults([]);
283
+ return;
284
+ }
285
+ const search = props.searchIcons;
286
+ if (!search) return;
287
+ setLoading(true);
288
+ debounceTimer = setTimeout(async () => {
289
+ try {
290
+ setApiResults(await search(query, prefix));
291
+ } catch {
292
+ setApiResults([]);
293
+ } finally {
294
+ setLoading(false);
295
+ }
296
+ }, 300);
297
+ };
298
+
299
+ const defaultIcons = createMemo(() => {
300
+ const lib = activeLib();
301
+ if (!lib) {
302
+ return Object.values(COMMON_ICONS).flat().slice(0, 60);
303
+ }
304
+ return COMMON_ICONS[lib] ?? [];
305
+ });
306
+
307
+ const displayIcons = createMemo(() => {
308
+ const q = search().toLowerCase().trim();
309
+ if (!q) return defaultIcons();
310
+ if (apiResults().length > 0) return apiResults();
311
+ return defaultIcons().filter((icon) => icon.toLowerCase().includes(q));
312
+ });
313
+
314
+ const selectIcon = (icon: string) => {
315
+ props.onChange(icon);
316
+ setOpen(false);
317
+ setSearch("");
318
+ };
319
+
320
+ const handleLibChange = (prefix: string) => {
321
+ setActiveLib(prefix);
322
+ setApiResults([]);
323
+ if (search().trim()) {
324
+ searchIcons(search(), prefix);
325
+ }
326
+ };
327
+
328
+ return (
329
+ <Popover surface="field" open={open()} onOpenChange={setOpen} modal>
330
+ <PopoverAnchor as="div" class={props.class}>
331
+ <button
332
+ type="button"
333
+ data-slot="icon-picker-trigger"
334
+ data-expanded={open() || undefined}
335
+ aria-labelledby={props["aria-labelledby"]}
336
+ class={PICKER_TRIGGER}
337
+ onClick={() => setOpen(!open())}
338
+ >
339
+ <Show
340
+ when={props.value.trim()}
341
+ fallback={
342
+ <span class="flex-1 text-left text-muted-foreground">
343
+ {props.placeholder ?? "mdi:home"}
344
+ </span>
345
+ }
346
+ >
347
+ <Icon icon={props.value.trim()} width={18} height={18} class="shrink-0" />
348
+ <span class="flex-1 truncate text-left">{props.value}</span>
349
+ </Show>
350
+ <Icon
351
+ icon="mdi:chevron-down"
352
+ width={16}
353
+ height={16}
354
+ class="shrink-0 text-muted-foreground"
355
+ />
356
+ </button>
357
+ </PopoverAnchor>
358
+ <PopoverContent
359
+ onOpenAutoFocus={(e) => {
360
+ e.preventDefault();
361
+ // preventScroll: the panel is portalled at (0,0) until the popper places it,
362
+ // so a plain focus() scrolls the page to the top.
363
+ searchRef?.focus({ preventScroll: true });
364
+ }}
365
+ onInteractOutside={() => setOpen(false)}
366
+ >
367
+ <div class="flex flex-col">
368
+ <PickerSearch
369
+ inputRef={(el) => {
370
+ searchRef = el;
371
+ }}
372
+ value={search()}
373
+ onValueChange={(next) => {
374
+ setSearch(next);
375
+ searchIcons(next, activeLib());
376
+ }}
377
+ placeholder="Search icons..."
378
+ aria-label="Search icons"
379
+ />
380
+ <div class="flex flex-wrap gap-1 border-border/50 border-b px-2 py-1.5">
381
+ <For each={ICON_LIBRARIES}>
382
+ {(lib) => (
383
+ <button
384
+ type="button"
385
+ data-slot="icon-picker-library"
386
+ aria-pressed={activeLib() === lib.prefix}
387
+ class={cn(
388
+ CHIP,
389
+ "cursor-pointer transition-glass",
390
+ activeLib() === lib.prefix
391
+ ? "[--glass-tone:var(--primary)]"
392
+ : "text-muted-foreground [--glass-base:transparent] [--glass-edge:transparent] [--glass-light:0] [--glass-rim:0] hover:text-foreground",
393
+ )}
394
+ onClick={() => handleLibChange(lib.prefix)}
395
+ >
396
+ {lib.label}
397
+ </button>
398
+ )}
399
+ </For>
400
+ </div>
401
+ <div class={cn(PICKER_LIST, "p-2")}>
402
+ <Show when={loading() && displayIcons().length === 0}>
403
+ <div class="py-4 text-center text-muted-foreground text-sm">Searching...</div>
404
+ </Show>
405
+ <Show when={!loading() && search().trim() && displayIcons().length === 0}>
406
+ <div class="py-4 text-center text-muted-foreground text-sm">No icons found</div>
407
+ </Show>
408
+ <div class={cn("grid grid-cols-6 gap-1", STAGGER)}>
409
+ <For each={displayIcons()}>
410
+ {(icon) => (
411
+ <button
412
+ type="button"
413
+ aria-pressed={props.value === icon}
414
+ class={cn(
415
+ "mx-auto flex size-11 cursor-pointer items-center justify-center rounded-full transition-glass hover:bg-accent",
416
+ props.value === icon &&
417
+ `${ICON_PILL_TINT} text-foreground [--glass-tone:var(--primary)] hover:bg-transparent`,
418
+ )}
419
+ onClick={() => selectIcon(icon)}
420
+ title={icon}
421
+ >
422
+ <Icon icon={icon} width={22} height={22} />
423
+ </button>
424
+ )}
425
+ </For>
426
+ </div>
427
+ </div>
428
+ </div>
429
+ </PopoverContent>
430
+ </Popover>
431
+ );
432
+ }
@@ -0,0 +1,20 @@
1
+ import "iconify-icon";
2
+ import type { IconifyIconProperties } from "iconify-icon";
3
+ import type { JSX } from "solid-js";
4
+
5
+ declare module "solid-js" {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ "iconify-icon": HTMLAttributes<HTMLElement> &
9
+ IconifyIconProperties & { rotate?: string | number };
10
+ }
11
+ }
12
+ }
13
+
14
+ export type IconProps = JSX.IntrinsicElements["iconify-icon"];
15
+
16
+ /* The host-registered <iconify-icon> element. Kept off the barrel: see the
17
+ * import-order note in index.ts. */
18
+ export function Icon(props: IconProps) {
19
+ return <iconify-icon {...props} />;
20
+ }