@glasshome/ui 1.21.0 → 1.21.2

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 (154) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/lib/use-is-mobile.d.ts +3 -1
  4. package/dist/solid/alert-dialog.d.ts +7 -1
  5. package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
  6. package/dist/solid/dialog-parts.d.ts +3 -2
  7. package/dist/solid/dialog.d.ts +7 -1
  8. package/dist/solid/docked-panel.d.ts +7 -1
  9. package/dist/solid/index.d.ts +9 -9
  10. package/dist/solid/index.js +5456 -5447
  11. package/dist/solid/media-store.d.ts +4 -1
  12. package/dist/solid/option-card.d.ts +4 -1
  13. package/dist/solid/responsive-dialog.d.ts +7 -1
  14. package/dist/solid/sheet.d.ts +7 -1
  15. package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
  16. package/package.json +128 -126
  17. package/scripts/check-gallery.ts +142 -142
  18. package/scripts/check-pack.ts +13 -13
  19. package/scripts/check-structural-classes.ts +20 -20
  20. package/scripts/check-tokens.ts +27 -27
  21. package/scripts/check-ui-drift.mjs +103 -103
  22. package/src/index.ts +75 -80
  23. package/src/lib/alert-tones.ts +41 -41
  24. package/src/lib/anchor-placement.ts +21 -21
  25. package/src/lib/button-variants.ts +28 -28
  26. package/src/lib/card-classes.ts +9 -9
  27. package/src/lib/carousel-classes.ts +14 -14
  28. package/src/lib/glass-tone.ts +11 -11
  29. package/src/lib/input-classes.ts +6 -6
  30. package/src/lib/layers.ts +4 -4
  31. package/src/lib/logo-lockup.ts +8 -8
  32. package/src/lib/menu-classes.ts +2 -2
  33. package/src/lib/motion-classes.ts +8 -8
  34. package/src/lib/motion-window.ts +24 -24
  35. package/src/lib/overlay-classes.ts +6 -6
  36. package/src/lib/pill-classes.ts +3 -3
  37. package/src/lib/position-bar-classes.ts +1 -1
  38. package/src/lib/spotlight-geometry.ts +67 -67
  39. package/src/lib/thumb-classes.ts +2 -2
  40. package/src/lib/tier-badge.ts +16 -16
  41. package/src/lib/use-is-mobile.ts +17 -14
  42. package/src/lib/utils.ts +1 -1
  43. package/src/solid/accordion.tsx +41 -41
  44. package/src/solid/alert-dialog.tsx +95 -95
  45. package/src/solid/alert.tsx +88 -88
  46. package/src/solid/area-picker.tsx +204 -204
  47. package/src/solid/aspect-ratio.tsx +13 -13
  48. package/src/solid/avatar.tsx +27 -27
  49. package/src/solid/badge.tsx +49 -49
  50. package/src/solid/bottom-sheet/arbitration.ts +22 -22
  51. package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
  52. package/src/solid/bottom-sheet/drag-controller.ts +201 -201
  53. package/src/solid/bottom-sheet/focus-trap.ts +51 -47
  54. package/src/solid/bottom-sheet/index.ts +12 -12
  55. package/src/solid/bottom-sheet/keyboard.ts +25 -25
  56. package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
  57. package/src/solid/bottom-sheet/state-machine.ts +28 -28
  58. package/src/solid/bottom-sheet/velocity.ts +29 -29
  59. package/src/solid/breadcrumb.tsx +76 -76
  60. package/src/solid/button-group.tsx +46 -46
  61. package/src/solid/button.tsx +19 -19
  62. package/src/solid/card.tsx +67 -67
  63. package/src/solid/carousel.tsx +246 -246
  64. package/src/solid/charts.tsx +253 -253
  65. package/src/solid/checkbox.tsx +51 -51
  66. package/src/solid/collapsible.tsx +22 -22
  67. package/src/solid/color-disc.tsx +213 -213
  68. package/src/solid/color-slider.tsx +81 -81
  69. package/src/solid/color-wheel.tsx +61 -61
  70. package/src/solid/context-menu.tsx +63 -63
  71. package/src/solid/copy-button.tsx +31 -31
  72. package/src/solid/count-pill.tsx +11 -11
  73. package/src/solid/dashboard-preview.tsx +104 -104
  74. package/src/solid/data-table.tsx +228 -228
  75. package/src/solid/dialog-parts.tsx +129 -129
  76. package/src/solid/dialog.tsx +113 -113
  77. package/src/solid/dock-paging.ts +9 -9
  78. package/src/solid/dock.tsx +339 -338
  79. package/src/solid/docked-panel.tsx +35 -35
  80. package/src/solid/dropdown-menu.tsx +77 -77
  81. package/src/solid/empty.tsx +70 -70
  82. package/src/solid/entity-data.ts +38 -38
  83. package/src/solid/entity-selector.tsx +634 -634
  84. package/src/solid/field.tsx +205 -205
  85. package/src/solid/form.tsx +159 -159
  86. package/src/solid/hero-action.tsx +85 -85
  87. package/src/solid/hover-card.tsx +11 -11
  88. package/src/solid/icon-picker.tsx +401 -401
  89. package/src/solid/icon.tsx +101 -78
  90. package/src/solid/image-picker.tsx +416 -414
  91. package/src/solid/index.ts +265 -304
  92. package/src/solid/input-group.tsx +123 -123
  93. package/src/solid/input-otp.tsx +143 -143
  94. package/src/solid/input.tsx +4 -4
  95. package/src/solid/item.tsx +130 -130
  96. package/src/solid/kbd.tsx +20 -20
  97. package/src/solid/label.tsx +12 -12
  98. package/src/solid/list-reorder.ts +122 -122
  99. package/src/solid/logo.tsx +60 -60
  100. package/src/solid/media-copy.ts +21 -21
  101. package/src/solid/media-store.ts +60 -57
  102. package/src/solid/media-tile.tsx +85 -85
  103. package/src/solid/menu-parts.tsx +164 -164
  104. package/src/solid/number-field.tsx +56 -56
  105. package/src/solid/option-card.tsx +168 -165
  106. package/src/solid/ornament.tsx +43 -43
  107. package/src/solid/overlay.tsx +4 -4
  108. package/src/solid/page-header.tsx +75 -75
  109. package/src/solid/pagination.tsx +80 -80
  110. package/src/solid/password-input.tsx +51 -51
  111. package/src/solid/picker-row.tsx +83 -83
  112. package/src/solid/picker-search.tsx +65 -63
  113. package/src/solid/picker-trigger.tsx +59 -57
  114. package/src/solid/popover.tsx +54 -54
  115. package/src/solid/preview-tile.tsx +67 -67
  116. package/src/solid/progress.tsx +21 -21
  117. package/src/solid/radio-group.tsx +51 -51
  118. package/src/solid/resizable.tsx +128 -128
  119. package/src/solid/responsive-dialog.tsx +134 -134
  120. package/src/solid/schema-form.tsx +746 -739
  121. package/src/solid/scope-indicator.tsx +5 -5
  122. package/src/solid/scroll-area.tsx +16 -16
  123. package/src/solid/section-card.tsx +281 -281
  124. package/src/solid/select.tsx +101 -101
  125. package/src/solid/separator.tsx +25 -25
  126. package/src/solid/settings-row.tsx +122 -122
  127. package/src/solid/sheet.tsx +96 -96
  128. package/src/solid/skeleton.tsx +8 -8
  129. package/src/solid/slider.tsx +132 -132
  130. package/src/solid/sliding-indicator.tsx +280 -265
  131. package/src/solid/sonner.tsx +164 -164
  132. package/src/solid/spinner.tsx +12 -12
  133. package/src/solid/spotlight.tsx +140 -140
  134. package/src/solid/step-indicator.tsx +18 -18
  135. package/src/solid/swatch-picker.tsx +38 -38
  136. package/src/solid/switch.tsx +52 -52
  137. package/src/solid/table.tsx +63 -63
  138. package/src/solid/tabs.tsx +93 -93
  139. package/src/solid/textarea.tsx +8 -8
  140. package/src/solid/toggle-group.tsx +83 -83
  141. package/src/solid/toggle.tsx +33 -33
  142. package/src/solid/tooltip.tsx +16 -16
  143. package/src/solid/widget-card.tsx +90 -90
  144. package/src/solid/widget-identity.tsx +99 -99
  145. package/src/solid/widget-trust-badge.tsx +20 -20
  146. package/src/styles/globals.css +316 -319
  147. package/src/styles/theme.css +448 -448
  148. package/src/tokens/hex.ts +29 -29
  149. package/src/tokens/material.ts +75 -75
  150. package/src/tokens/presets.ts +303 -303
  151. package/src/tokens/readability.ts +32 -32
  152. package/src/tokens/theme-colors.ts +95 -95
  153. package/src/tokens/theme-css.ts +22 -22
  154. package/src/tokens/theme-recipe.ts +106 -106
@@ -1,14 +1,14 @@
1
1
  import type { IconifyIcon } from "@iconify/types";
2
2
  import { iconToSVG } from "@iconify/utils";
3
- import { createMemo, createSignal, type JSX, splitProps } from "solid-js";
3
+ import { batch, createMemo, createSignal, type JSX, type Signal, splitProps } from "solid-js";
4
4
 
5
5
  export type IconData = IconifyIcon;
6
6
 
7
7
  export interface IconSource {
8
- /** Icons known at build time, keyed `prefix:name`. */
9
- bundled: Record<string, IconData>;
10
- /** Resolves the rest in one batch; a name the source does not have maps to null. */
11
- load?: (names: string[]) => Promise<Record<string, IconData | null>>;
8
+ /** Icons known at build time, keyed `prefix:name`. */
9
+ bundled: Record<string, IconData>;
10
+ /** Resolves the rest in one batch; a name the source does not have maps to null. */
11
+ load?: (names: string[]) => Promise<Record<string, IconData | null>>;
12
12
  }
13
13
 
14
14
  /**
@@ -18,109 +18,132 @@ export interface IconSource {
18
18
  */
19
19
  let source: IconSource | undefined;
20
20
  const loaded = new Map<string, IconData | null>();
21
+ // A new source re-resolves every icon; a batch landing wakes only the names it answered.
21
22
  const [generation, setGeneration] = createSignal(0);
23
+ const arrivals = new Map<string, Signal<number>>();
24
+ const arrivalOf = (name: string) => {
25
+ let signal = arrivals.get(name);
26
+ if (!signal) {
27
+ signal = createSignal(0);
28
+ arrivals.set(name, signal);
29
+ }
30
+ return signal;
31
+ };
22
32
  let pending = new Set<string>();
33
+ // Queued or in flight: a lookup while the batch is out waits for it, never asks again.
34
+ const requested = new Set<string>();
23
35
  let flush: Promise<void> | null = null;
24
36
 
25
37
  /** Host apps call this once at startup; every mounted Icon re-resolves. */
26
38
  export function provideIcons(next: IconSource): void {
27
- source = next;
28
- loaded.clear();
29
- setGeneration((g) => g + 1);
39
+ source = next;
40
+ loaded.clear();
41
+ requested.clear();
42
+ setGeneration((g) => g + 1);
30
43
  }
31
44
 
32
45
  function request(name: string): void {
33
- const load = source?.load;
34
- if (!load || pending.has(name)) return;
35
- pending.add(name);
36
- if (flush) return;
37
- flush = Promise.resolve().then(async () => {
38
- const names = [...pending];
39
- pending = new Set();
40
- flush = null;
41
- let result: Record<string, IconData | null> = {};
42
- try {
43
- result = await load(names);
44
- } catch {
45
- result = {};
46
- }
47
- for (const n of names) loaded.set(n, result[n] ?? null);
48
- setGeneration((g) => g + 1);
49
- });
46
+ const load = source?.load;
47
+ if (!load || requested.has(name)) return;
48
+ requested.add(name);
49
+ pending.add(name);
50
+ if (flush) return;
51
+ flush = Promise.resolve().then(async () => {
52
+ const names = [...pending];
53
+ pending = new Set();
54
+ flush = null;
55
+ let result: Record<string, IconData | null> = {};
56
+ try {
57
+ result = await load(names);
58
+ } catch {
59
+ result = {};
60
+ }
61
+ if (source?.load !== load) return;
62
+ batch(() => {
63
+ for (const n of names) {
64
+ loaded.set(n, result[n] ?? null);
65
+ requested.delete(n);
66
+ arrivals.get(n)?.[1]((v) => v + 1);
67
+ }
68
+ });
69
+ });
50
70
  }
51
71
 
52
72
  function lookup(name: string): IconData | undefined {
53
- generation();
54
- const bundled = source?.bundled[name];
55
- if (bundled) return bundled;
56
- if (loaded.has(name)) return loaded.get(name) ?? undefined;
57
- request(name);
58
- return undefined;
73
+ generation();
74
+ const bundled = source?.bundled[name];
75
+ if (bundled) return bundled;
76
+ if (loaded.has(name)) return loaded.get(name) ?? undefined;
77
+ arrivalOf(name)[0]();
78
+ request(name);
79
+ return undefined;
59
80
  }
60
81
 
61
82
  interface TrustedPolicy {
62
- createHTML(input: string): string;
83
+ createHTML(input: string): string;
63
84
  }
64
85
  let policy: TrustedPolicy | null | undefined;
65
86
 
66
87
  // Icon bodies come from the build or the host's own icon route; under a
67
88
  // require-trusted-types-for CSP the assignment still needs a policy.
68
89
  function trusted(html: string): string {
69
- if (policy === undefined) {
70
- const tt = (
71
- globalThis as {
72
- trustedTypes?: { createPolicy(name: string, rules: TrustedPolicy): TrustedPolicy };
73
- }
74
- ).trustedTypes;
75
- try {
76
- policy = tt ? tt.createPolicy("glasshome-ui", { createHTML: (s) => s }) : null;
77
- } catch {
78
- policy = null;
79
- }
80
- }
81
- return policy ? policy.createHTML(html) : html;
90
+ if (policy === undefined) {
91
+ const tt = (
92
+ globalThis as {
93
+ trustedTypes?: { createPolicy(name: string, rules: TrustedPolicy): TrustedPolicy };
94
+ }
95
+ ).trustedTypes;
96
+ try {
97
+ policy = tt ? tt.createPolicy("glasshome-ui", { createHTML: (s) => s }) : null;
98
+ } catch {
99
+ policy = null;
100
+ }
101
+ }
102
+ return policy ? policy.createHTML(html) : html;
82
103
  }
83
104
 
84
- export interface IconProps
85
- extends Omit<JSX.SvgSVGAttributes<SVGSVGElement>, "width" | "height" | "children"> {
86
- /** `prefix:name`, e.g. `lucide:plus`. */
87
- icon: string;
88
- /** Unitless = px; both omitted = 1em, one omitted = the icon's own ratio. */
89
- width?: number | string;
90
- height?: number | string;
105
+ export interface IconProps extends Omit<
106
+ JSX.SvgSVGAttributes<SVGSVGElement>,
107
+ "width" | "height" | "children"
108
+ > {
109
+ /** `prefix:name`, e.g. `lucide:plus`. */
110
+ icon: string;
111
+ /** Unitless = px; both omitted = 1em, one omitted = the icon's own ratio. */
112
+ width?: number | string;
113
+ height?: number | string;
91
114
  }
92
115
 
93
116
  const EMPTY = { attributes: { viewBox: "0 0 16 16", width: "1em", height: "1em" }, body: "" };
94
117
 
95
118
  /** One inline `<svg>` per icon: no shadow root, no observer, rendered once and kept. */
96
119
  export function Icon(props: IconProps) {
97
- const [local, rest] = splitProps(props, ["icon", "width", "height"]);
98
- const built = createMemo(() => {
99
- const data = lookup(local.icon);
100
- const size = {
101
- width: local.width == null ? null : String(local.width),
102
- height: local.height == null ? null : String(local.height),
103
- };
104
- if (!data) return { ...EMPTY, attributes: { ...EMPTY.attributes, ...sizeOrDefault(size) } };
105
- return iconToSVG(data, size);
106
- });
107
- return (
108
- <svg
109
- xmlns="http://www.w3.org/2000/svg"
110
- data-slot="icon"
111
- data-icon={local.icon}
112
- aria-hidden="true"
113
- fill="currentColor"
114
- {...rest}
115
- viewBox={built().attributes.viewBox}
116
- width={built().attributes.width}
117
- height={built().attributes.height}
118
- innerHTML={trusted(built().body)}
119
- />
120
- );
120
+ const [local, rest] = splitProps(props, ["icon", "width", "height"]);
121
+ const built = createMemo(() => {
122
+ const data = lookup(local.icon);
123
+ const size = {
124
+ width: local.width == null ? null : String(local.width),
125
+ height: local.height == null ? null : String(local.height),
126
+ };
127
+ if (!data) return { ...EMPTY, attributes: { ...EMPTY.attributes, ...sizeOrDefault(size) } };
128
+ return iconToSVG(data, size);
129
+ });
130
+ return (
131
+ <svg
132
+ xmlns="http://www.w3.org/2000/svg"
133
+ data-slot="icon"
134
+ data-icon={local.icon}
135
+ aria-hidden="true"
136
+ fill="currentColor"
137
+ {...rest}
138
+ viewBox={built().attributes.viewBox}
139
+ width={built().attributes.width}
140
+ height={built().attributes.height}
141
+ innerHTML={trusted(built().body)}
142
+ />
143
+ );
121
144
  }
122
145
 
123
146
  function sizeOrDefault(size: { width: string | null; height: string | null }) {
124
- if (size.width == null && size.height == null) return { width: "1em", height: "1em" };
125
- return { width: size.width ?? size.height ?? "1em", height: size.height ?? size.width ?? "1em" };
147
+ if (size.width == null && size.height == null) return { width: "1em", height: "1em" };
148
+ return { width: size.width ?? size.height ?? "1em", height: size.height ?? size.width ?? "1em" };
126
149
  }