@glasshome/ui 1.21.1 → 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 (145) 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/index.d.ts +9 -9
  5. package/dist/solid/index.js +5431 -5424
  6. package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
  7. package/package.json +128 -126
  8. package/scripts/check-gallery.ts +142 -142
  9. package/scripts/check-pack.ts +13 -13
  10. package/scripts/check-structural-classes.ts +20 -20
  11. package/scripts/check-tokens.ts +27 -27
  12. package/scripts/check-ui-drift.mjs +103 -103
  13. package/src/index.ts +75 -80
  14. package/src/lib/alert-tones.ts +41 -41
  15. package/src/lib/anchor-placement.ts +21 -21
  16. package/src/lib/button-variants.ts +28 -28
  17. package/src/lib/card-classes.ts +9 -9
  18. package/src/lib/carousel-classes.ts +14 -14
  19. package/src/lib/glass-tone.ts +11 -11
  20. package/src/lib/input-classes.ts +6 -6
  21. package/src/lib/layers.ts +4 -4
  22. package/src/lib/logo-lockup.ts +8 -8
  23. package/src/lib/menu-classes.ts +2 -2
  24. package/src/lib/motion-classes.ts +8 -8
  25. package/src/lib/motion-window.ts +24 -24
  26. package/src/lib/overlay-classes.ts +6 -6
  27. package/src/lib/pill-classes.ts +3 -3
  28. package/src/lib/position-bar-classes.ts +1 -1
  29. package/src/lib/spotlight-geometry.ts +67 -67
  30. package/src/lib/thumb-classes.ts +2 -2
  31. package/src/lib/tier-badge.ts +16 -16
  32. package/src/lib/use-is-mobile.ts +17 -14
  33. package/src/lib/utils.ts +1 -1
  34. package/src/solid/accordion.tsx +41 -41
  35. package/src/solid/alert-dialog.tsx +95 -95
  36. package/src/solid/alert.tsx +88 -88
  37. package/src/solid/area-picker.tsx +204 -204
  38. package/src/solid/aspect-ratio.tsx +13 -13
  39. package/src/solid/avatar.tsx +27 -27
  40. package/src/solid/badge.tsx +49 -49
  41. package/src/solid/bottom-sheet/arbitration.ts +22 -22
  42. package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
  43. package/src/solid/bottom-sheet/drag-controller.ts +201 -201
  44. package/src/solid/bottom-sheet/focus-trap.ts +51 -47
  45. package/src/solid/bottom-sheet/index.ts +12 -12
  46. package/src/solid/bottom-sheet/keyboard.ts +25 -25
  47. package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
  48. package/src/solid/bottom-sheet/state-machine.ts +28 -28
  49. package/src/solid/bottom-sheet/velocity.ts +29 -29
  50. package/src/solid/breadcrumb.tsx +76 -76
  51. package/src/solid/button-group.tsx +46 -46
  52. package/src/solid/button.tsx +19 -19
  53. package/src/solid/card.tsx +67 -67
  54. package/src/solid/carousel.tsx +246 -246
  55. package/src/solid/charts.tsx +253 -253
  56. package/src/solid/checkbox.tsx +51 -51
  57. package/src/solid/collapsible.tsx +22 -22
  58. package/src/solid/color-disc.tsx +213 -213
  59. package/src/solid/color-slider.tsx +81 -81
  60. package/src/solid/color-wheel.tsx +61 -61
  61. package/src/solid/context-menu.tsx +63 -63
  62. package/src/solid/copy-button.tsx +31 -31
  63. package/src/solid/count-pill.tsx +11 -11
  64. package/src/solid/dashboard-preview.tsx +104 -104
  65. package/src/solid/data-table.tsx +228 -228
  66. package/src/solid/dialog-parts.tsx +127 -127
  67. package/src/solid/dialog.tsx +113 -113
  68. package/src/solid/dock-paging.ts +9 -9
  69. package/src/solid/dock.tsx +339 -339
  70. package/src/solid/docked-panel.tsx +35 -35
  71. package/src/solid/dropdown-menu.tsx +77 -77
  72. package/src/solid/empty.tsx +70 -70
  73. package/src/solid/entity-data.ts +38 -38
  74. package/src/solid/entity-selector.tsx +634 -634
  75. package/src/solid/field.tsx +205 -205
  76. package/src/solid/form.tsx +159 -159
  77. package/src/solid/hero-action.tsx +85 -85
  78. package/src/solid/hover-card.tsx +11 -11
  79. package/src/solid/icon-picker.tsx +401 -401
  80. package/src/solid/icon.tsx +101 -78
  81. package/src/solid/image-picker.tsx +416 -414
  82. package/src/solid/index.ts +265 -304
  83. package/src/solid/input-group.tsx +123 -123
  84. package/src/solid/input-otp.tsx +143 -143
  85. package/src/solid/input.tsx +4 -4
  86. package/src/solid/item.tsx +130 -130
  87. package/src/solid/kbd.tsx +20 -20
  88. package/src/solid/label.tsx +12 -12
  89. package/src/solid/list-reorder.ts +122 -122
  90. package/src/solid/logo.tsx +60 -60
  91. package/src/solid/media-copy.ts +21 -21
  92. package/src/solid/media-store.ts +56 -56
  93. package/src/solid/media-tile.tsx +85 -85
  94. package/src/solid/menu-parts.tsx +164 -164
  95. package/src/solid/number-field.tsx +56 -56
  96. package/src/solid/option-card.tsx +164 -164
  97. package/src/solid/ornament.tsx +43 -43
  98. package/src/solid/overlay.tsx +4 -4
  99. package/src/solid/page-header.tsx +75 -75
  100. package/src/solid/pagination.tsx +80 -80
  101. package/src/solid/password-input.tsx +51 -51
  102. package/src/solid/picker-row.tsx +83 -83
  103. package/src/solid/picker-search.tsx +65 -63
  104. package/src/solid/picker-trigger.tsx +59 -57
  105. package/src/solid/popover.tsx +54 -54
  106. package/src/solid/preview-tile.tsx +67 -67
  107. package/src/solid/progress.tsx +21 -21
  108. package/src/solid/radio-group.tsx +51 -51
  109. package/src/solid/resizable.tsx +128 -128
  110. package/src/solid/responsive-dialog.tsx +134 -134
  111. package/src/solid/schema-form.tsx +743 -743
  112. package/src/solid/scope-indicator.tsx +5 -5
  113. package/src/solid/scroll-area.tsx +16 -16
  114. package/src/solid/section-card.tsx +281 -281
  115. package/src/solid/select.tsx +101 -101
  116. package/src/solid/separator.tsx +25 -25
  117. package/src/solid/settings-row.tsx +122 -122
  118. package/src/solid/sheet.tsx +96 -96
  119. package/src/solid/skeleton.tsx +8 -8
  120. package/src/solid/slider.tsx +132 -132
  121. package/src/solid/sliding-indicator.tsx +280 -265
  122. package/src/solid/sonner.tsx +164 -164
  123. package/src/solid/spinner.tsx +12 -12
  124. package/src/solid/spotlight.tsx +140 -140
  125. package/src/solid/step-indicator.tsx +18 -18
  126. package/src/solid/swatch-picker.tsx +38 -38
  127. package/src/solid/switch.tsx +52 -52
  128. package/src/solid/table.tsx +63 -63
  129. package/src/solid/tabs.tsx +93 -93
  130. package/src/solid/textarea.tsx +8 -8
  131. package/src/solid/toggle-group.tsx +83 -83
  132. package/src/solid/toggle.tsx +33 -33
  133. package/src/solid/tooltip.tsx +16 -16
  134. package/src/solid/widget-card.tsx +90 -90
  135. package/src/solid/widget-identity.tsx +99 -99
  136. package/src/solid/widget-trust-badge.tsx +20 -20
  137. package/src/styles/globals.css +316 -319
  138. package/src/styles/theme.css +448 -448
  139. package/src/tokens/hex.ts +29 -29
  140. package/src/tokens/material.ts +75 -75
  141. package/src/tokens/presets.ts +303 -303
  142. package/src/tokens/readability.ts +32 -32
  143. package/src/tokens/theme-colors.ts +95 -95
  144. package/src/tokens/theme-css.ts +22 -22
  145. package/src/tokens/theme-recipe.ts +106 -106
package/src/tokens/hex.ts CHANGED
@@ -6,45 +6,45 @@ import { parseOklch } from "./theme-colors.js";
6
6
  * For renderers that cannot parse oklch (librsvg, sharp SVG, canvas fills).
7
7
  */
8
8
  export function oklchToHex(oklch: string): string {
9
- const parsed = parseOklch(oklch);
10
- if (!parsed) throw new Error(`oklchToHex: cannot parse "${oklch}"`);
11
- let rgb = oklchToLinearSrgb(parsed.l, parsed.c, parsed.h);
12
- if (!inGamut(rgb)) {
13
- let lo = 0;
14
- let hi = parsed.c;
15
- for (let i = 0; i < 40; i++) {
16
- const mid = (lo + hi) / 2;
17
- if (inGamut(oklchToLinearSrgb(parsed.l, mid, parsed.h))) lo = mid;
18
- else hi = mid;
19
- }
20
- rgb = oklchToLinearSrgb(parsed.l, lo, parsed.h);
21
- }
22
- return `#${rgb.map(linearToByte).map(toHexByte).join("")}`;
9
+ const parsed = parseOklch(oklch);
10
+ if (!parsed) throw new Error(`oklchToHex: cannot parse "${oklch}"`);
11
+ let rgb = oklchToLinearSrgb(parsed.l, parsed.c, parsed.h);
12
+ if (!inGamut(rgb)) {
13
+ let lo = 0;
14
+ let hi = parsed.c;
15
+ for (let i = 0; i < 40; i++) {
16
+ const mid = (lo + hi) / 2;
17
+ if (inGamut(oklchToLinearSrgb(parsed.l, mid, parsed.h))) lo = mid;
18
+ else hi = mid;
19
+ }
20
+ rgb = oklchToLinearSrgb(parsed.l, lo, parsed.h);
21
+ }
22
+ return `#${rgb.map(linearToByte).map(toHexByte).join("")}`;
23
23
  }
24
24
 
25
25
  function oklchToLinearSrgb(L: number, C: number, hDeg: number): [number, number, number] {
26
- const h = (hDeg * Math.PI) / 180;
27
- const a = C * Math.cos(h);
28
- const b = C * Math.sin(h);
29
- const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
30
- const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
31
- const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
32
- return [
33
- 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
34
- -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
35
- -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
36
- ];
26
+ const h = (hDeg * Math.PI) / 180;
27
+ const a = C * Math.cos(h);
28
+ const b = C * Math.sin(h);
29
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
30
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
31
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
32
+ return [
33
+ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
34
+ -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
35
+ -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
36
+ ];
37
37
  }
38
38
 
39
39
  function inGamut(rgb: [number, number, number]): boolean {
40
- return rgb.every((x) => x >= -1e-6 && x <= 1 + 1e-6);
40
+ return rgb.every((x) => x >= -1e-6 && x <= 1 + 1e-6);
41
41
  }
42
42
 
43
43
  function linearToByte(x: number): number {
44
- const v = x <= 0.0031308 ? 12.92 * x : 1.055 * Math.max(0, x) ** (1 / 2.4) - 0.055;
45
- return Math.round(Math.min(1, Math.max(0, v)) * 255);
44
+ const v = x <= 0.0031308 ? 12.92 * x : 1.055 * Math.max(0, x) ** (1 / 2.4) - 0.055;
45
+ return Math.round(Math.min(1, Math.max(0, v)) * 255);
46
46
  }
47
47
 
48
48
  function toHexByte(n: number): string {
49
- return n.toString(16).padStart(2, "0");
49
+ return n.toString(16).padStart(2, "0");
50
50
  }
@@ -6,39 +6,39 @@ export type MaterialPresetId = "frosted" | "paper" | "neon" | "chalk";
6
6
 
7
7
  /** Tier 2 of the glass formula: what every surface's knobs are multiplied by. The homeowner's dials. */
8
8
  export interface MaterialDials {
9
- /** Backdrop blur radius, px. */
10
- blur: number;
11
- /** How much of the card colour a surface keeps, %; the rest is the wallpaper. */
12
- clarity: number;
13
- /** Scales sheen, shade, rim and lift together. */
14
- depth: number;
15
- /** Scales the tone wash. */
16
- tint: number;
17
- /** Outer bloom radius in the surface's own hue, px. */
18
- glow: number;
19
- /** 0..1; above 0 every surface is hand-inked: a drawn line over a hand-laid fill. */
20
- ink: number;
9
+ /** Backdrop blur radius, px. */
10
+ blur: number;
11
+ /** How much of the card colour a surface keeps, %; the rest is the wallpaper. */
12
+ clarity: number;
13
+ /** Scales sheen, shade, rim and lift together. */
14
+ depth: number;
15
+ /** Scales the tone wash. */
16
+ tint: number;
17
+ /** Outer bloom radius in the surface's own hue, px. */
18
+ glow: number;
19
+ /** 0..1; above 0 every surface is hand-inked: a drawn line over a hand-laid fill. */
20
+ ink: number;
21
21
  }
22
22
 
23
23
  /** Terms a preset turns on; inert at zero, never a homeowner dial. */
24
24
  export interface MaterialTerms {
25
- /** Edge width, px. */
26
- edgeWidth: number;
27
- /** 0..1, how far the edge moves toward the material ink. */
28
- edgeInk: number;
29
- /** 0..1, how far the edge moves toward the surface's own hue (its tone, else the accent). */
30
- edgeAccent: number;
31
- /** 0..1, how far the Ink line moves from the mode's ink toward the foreground: chalk on a dark board. */
32
- inkLift: number;
25
+ /** Edge width, px. */
26
+ edgeWidth: number;
27
+ /** 0..1, how far the edge moves toward the material ink. */
28
+ edgeInk: number;
29
+ /** 0..1, how far the edge moves toward the surface's own hue (its tone, else the accent). */
30
+ edgeAccent: number;
31
+ /** 0..1, how far the Ink line moves from the mode's ink toward the foreground: chalk on a dark board. */
32
+ inkLift: number;
33
33
  }
34
34
 
35
35
  export type MaterialSpec = MaterialDials & MaterialTerms;
36
36
 
37
37
  /** What was chosen, never what was computed. */
38
38
  export interface Material {
39
- v: typeof MATERIAL_VERSION;
40
- preset: MaterialPresetId;
41
- dials?: Partial<MaterialDials>;
39
+ v: typeof MATERIAL_VERSION;
40
+ preset: MaterialPresetId;
41
+ dials?: Partial<MaterialDials>;
42
42
  }
43
43
 
44
44
  export type BlurMode = "dynamic" | "performant" | "none";
@@ -46,71 +46,71 @@ export type BlurMode = "dynamic" | "performant" | "none";
46
46
  const PLAIN: MaterialTerms = { edgeWidth: 1, edgeInk: 0, edgeAccent: 0, inkLift: 0 };
47
47
 
48
48
  export const MATERIAL_PRESETS: Record<MaterialPresetId, MaterialSpec> = {
49
- /** Today's glass: translucent, blurred, lit rim. */
50
- frosted: { blur: 24, clarity: 60, depth: 1, tint: 1, glow: 0, ink: 0, ...PLAIN },
51
- /** Opaque matte stock, a faint inked cut edge, calm tint; the Ink dial draws on it. */
52
- paper: { blur: 0, clarity: 100, depth: 0.5, tint: 0.85, glow: 0, ink: 0, ...PLAIN, edgeInk: 0.3 },
53
- /** Near-opaque dark tile, thin tube of its own hue at the edge, bloom around it. */
54
- neon: {
55
- blur: 8,
56
- clarity: 92,
57
- depth: 0.4,
58
- tint: 0.9,
59
- edgeWidth: 1.5,
60
- edgeInk: 0,
61
- edgeAccent: 1,
62
- inkLift: 0,
63
- glow: 18,
64
- ink: 0,
65
- },
66
- /** Matte board, the Ink body drawn in the foreground colour. */
67
- chalk: { blur: 0, clarity: 100, depth: 0.3, tint: 0.7, glow: 0, ink: 1, ...PLAIN, inkLift: 1 },
49
+ /** Today's glass: translucent, blurred, lit rim. */
50
+ frosted: { blur: 24, clarity: 60, depth: 1, tint: 1, glow: 0, ink: 0, ...PLAIN },
51
+ /** Opaque matte stock, a faint inked cut edge, calm tint; the Ink dial draws on it. */
52
+ paper: { blur: 0, clarity: 100, depth: 0.5, tint: 0.85, glow: 0, ink: 0, ...PLAIN, edgeInk: 0.3 },
53
+ /** Near-opaque dark tile, thin tube of its own hue at the edge, bloom around it. */
54
+ neon: {
55
+ blur: 8,
56
+ clarity: 92,
57
+ depth: 0.4,
58
+ tint: 0.9,
59
+ edgeWidth: 1.5,
60
+ edgeInk: 0,
61
+ edgeAccent: 1,
62
+ inkLift: 0,
63
+ glow: 18,
64
+ ink: 0,
65
+ },
66
+ /** Matte board, the Ink body drawn in the foreground colour. */
67
+ chalk: { blur: 0, clarity: 100, depth: 0.3, tint: 0.7, glow: 0, ink: 1, ...PLAIN, inkLift: 1 },
68
68
  };
69
69
 
70
70
  export const FROSTED: Material = { v: 1, preset: "frosted" };
71
71
 
72
72
  const RANGE: Record<keyof MaterialDials, [number, number]> = {
73
- blur: [0, 48],
74
- clarity: [0, 100],
75
- depth: [0, 2],
76
- tint: [0, 2],
77
- glow: [0, 40],
78
- ink: [0, 1],
73
+ blur: [0, 48],
74
+ clarity: [0, 100],
75
+ depth: [0, 2],
76
+ tint: [0, 2],
77
+ glow: [0, 40],
78
+ ink: [0, 1],
79
79
  };
80
80
 
81
81
  /** Below this the text floor fails over a busy wallpaper with nothing blurred behind it. */
82
82
  const NO_BLUR_CLARITY_FLOOR = 85;
83
83
 
84
84
  export function materialDials(material: Material): MaterialDials {
85
- const merged = { ...MATERIAL_PRESETS[material.preset], ...material.dials };
86
- return {
87
- blur: clamp(merged.blur, ...RANGE.blur),
88
- clarity: clamp(merged.clarity, ...RANGE.clarity),
89
- depth: clamp(merged.depth, ...RANGE.depth),
90
- tint: clamp(merged.tint, ...RANGE.tint),
91
- glow: clamp(merged.glow, ...RANGE.glow),
92
- ink: clamp(merged.ink, ...RANGE.ink),
93
- };
85
+ const merged = { ...MATERIAL_PRESETS[material.preset], ...material.dials };
86
+ return {
87
+ blur: clamp(merged.blur, ...RANGE.blur),
88
+ clarity: clamp(merged.clarity, ...RANGE.clarity),
89
+ depth: clamp(merged.depth, ...RANGE.depth),
90
+ tint: clamp(merged.tint, ...RANGE.tint),
91
+ glow: clamp(merged.glow, ...RANGE.glow),
92
+ ink: clamp(merged.ink, ...RANGE.ink),
93
+ };
94
94
  }
95
95
 
96
96
  export function resolveMaterial(
97
- material: Material,
98
- blurMode: BlurMode,
97
+ material: Material,
98
+ blurMode: BlurMode,
99
99
  ): Record<`--material-${string}`, string> {
100
- const d = materialDials(material);
101
- const t = MATERIAL_PRESETS[material.preset];
102
- const blur = blurMode === "none" ? 0 : d.blur;
103
- const clarity = blurMode === "none" ? Math.max(d.clarity, NO_BLUR_CLARITY_FLOOR) : d.clarity;
104
- return {
105
- "--material-blur": `${blur}px`,
106
- "--material-clarity": `${clarity}%`,
107
- "--material-depth": `${d.depth}`,
108
- "--material-tint": `${d.tint}`,
109
- "--material-edge-width": `${t.edgeWidth}px`,
110
- "--material-edge-ink": `${t.edgeInk}`,
111
- "--material-edge-accent": `${t.edgeAccent}`,
112
- "--material-glow": `${d.glow}px`,
113
- "--material-ink-level": `${d.ink}`,
114
- "--material-ink-lift": `${t.inkLift}`,
115
- };
100
+ const d = materialDials(material);
101
+ const t = MATERIAL_PRESETS[material.preset];
102
+ const blur = blurMode === "none" ? 0 : d.blur;
103
+ const clarity = blurMode === "none" ? Math.max(d.clarity, NO_BLUR_CLARITY_FLOOR) : d.clarity;
104
+ return {
105
+ "--material-blur": `${blur}px`,
106
+ "--material-clarity": `${clarity}%`,
107
+ "--material-depth": `${d.depth}`,
108
+ "--material-tint": `${d.tint}`,
109
+ "--material-edge-width": `${t.edgeWidth}px`,
110
+ "--material-edge-ink": `${t.edgeInk}`,
111
+ "--material-edge-accent": `${t.edgeAccent}`,
112
+ "--material-glow": `${d.glow}px`,
113
+ "--material-ink-level": `${d.ink}`,
114
+ "--material-ink-lift": `${t.inkLift}`,
115
+ };
116
116
  }