@glasshome/ui 1.21.1 → 1.22.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 (146) 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/solid/sonner.d.ts +1 -0
  7. package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
  8. package/package.json +128 -126
  9. package/scripts/check-gallery.ts +142 -142
  10. package/scripts/check-pack.ts +13 -13
  11. package/scripts/check-structural-classes.ts +20 -20
  12. package/scripts/check-tokens.ts +27 -27
  13. package/scripts/check-ui-drift.mjs +103 -103
  14. package/src/index.ts +75 -80
  15. package/src/lib/alert-tones.ts +41 -41
  16. package/src/lib/anchor-placement.ts +21 -21
  17. package/src/lib/button-variants.ts +28 -28
  18. package/src/lib/card-classes.ts +9 -9
  19. package/src/lib/carousel-classes.ts +14 -14
  20. package/src/lib/glass-tone.ts +11 -11
  21. package/src/lib/input-classes.ts +6 -6
  22. package/src/lib/layers.ts +4 -4
  23. package/src/lib/logo-lockup.ts +8 -8
  24. package/src/lib/menu-classes.ts +2 -2
  25. package/src/lib/motion-classes.ts +8 -8
  26. package/src/lib/motion-window.ts +24 -24
  27. package/src/lib/overlay-classes.ts +6 -6
  28. package/src/lib/pill-classes.ts +3 -3
  29. package/src/lib/position-bar-classes.ts +1 -1
  30. package/src/lib/spotlight-geometry.ts +67 -67
  31. package/src/lib/thumb-classes.ts +2 -2
  32. package/src/lib/tier-badge.ts +16 -16
  33. package/src/lib/use-is-mobile.ts +17 -14
  34. package/src/lib/utils.ts +1 -1
  35. package/src/solid/accordion.tsx +41 -41
  36. package/src/solid/alert-dialog.tsx +95 -95
  37. package/src/solid/alert.tsx +88 -88
  38. package/src/solid/area-picker.tsx +204 -204
  39. package/src/solid/aspect-ratio.tsx +13 -13
  40. package/src/solid/avatar.tsx +27 -27
  41. package/src/solid/badge.tsx +49 -49
  42. package/src/solid/bottom-sheet/arbitration.ts +22 -22
  43. package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
  44. package/src/solid/bottom-sheet/drag-controller.ts +201 -201
  45. package/src/solid/bottom-sheet/focus-trap.ts +51 -47
  46. package/src/solid/bottom-sheet/index.ts +12 -12
  47. package/src/solid/bottom-sheet/keyboard.ts +25 -25
  48. package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
  49. package/src/solid/bottom-sheet/state-machine.ts +28 -28
  50. package/src/solid/bottom-sheet/velocity.ts +29 -29
  51. package/src/solid/breadcrumb.tsx +76 -76
  52. package/src/solid/button-group.tsx +46 -46
  53. package/src/solid/button.tsx +19 -19
  54. package/src/solid/card.tsx +67 -67
  55. package/src/solid/carousel.tsx +246 -246
  56. package/src/solid/charts.tsx +253 -253
  57. package/src/solid/checkbox.tsx +51 -51
  58. package/src/solid/collapsible.tsx +22 -22
  59. package/src/solid/color-disc.tsx +213 -213
  60. package/src/solid/color-slider.tsx +81 -81
  61. package/src/solid/color-wheel.tsx +61 -61
  62. package/src/solid/context-menu.tsx +63 -63
  63. package/src/solid/copy-button.tsx +31 -31
  64. package/src/solid/count-pill.tsx +11 -11
  65. package/src/solid/dashboard-preview.tsx +104 -104
  66. package/src/solid/data-table.tsx +228 -228
  67. package/src/solid/dialog-parts.tsx +127 -127
  68. package/src/solid/dialog.tsx +113 -113
  69. package/src/solid/dock-paging.ts +9 -9
  70. package/src/solid/dock.tsx +339 -339
  71. package/src/solid/docked-panel.tsx +35 -35
  72. package/src/solid/dropdown-menu.tsx +77 -77
  73. package/src/solid/empty.tsx +70 -70
  74. package/src/solid/entity-data.ts +38 -38
  75. package/src/solid/entity-selector.tsx +634 -634
  76. package/src/solid/field.tsx +205 -205
  77. package/src/solid/form.tsx +159 -159
  78. package/src/solid/hero-action.tsx +85 -85
  79. package/src/solid/hover-card.tsx +11 -11
  80. package/src/solid/icon-picker.tsx +401 -401
  81. package/src/solid/icon.tsx +101 -78
  82. package/src/solid/image-picker.tsx +416 -414
  83. package/src/solid/index.ts +265 -304
  84. package/src/solid/input-group.tsx +123 -123
  85. package/src/solid/input-otp.tsx +143 -143
  86. package/src/solid/input.tsx +4 -4
  87. package/src/solid/item.tsx +130 -130
  88. package/src/solid/kbd.tsx +20 -20
  89. package/src/solid/label.tsx +12 -12
  90. package/src/solid/list-reorder.ts +122 -122
  91. package/src/solid/logo.tsx +60 -60
  92. package/src/solid/media-copy.ts +21 -21
  93. package/src/solid/media-store.ts +56 -56
  94. package/src/solid/media-tile.tsx +85 -85
  95. package/src/solid/menu-parts.tsx +164 -164
  96. package/src/solid/number-field.tsx +56 -56
  97. package/src/solid/option-card.tsx +164 -164
  98. package/src/solid/ornament.tsx +43 -43
  99. package/src/solid/overlay.tsx +4 -4
  100. package/src/solid/page-header.tsx +75 -75
  101. package/src/solid/pagination.tsx +80 -80
  102. package/src/solid/password-input.tsx +51 -51
  103. package/src/solid/picker-row.tsx +83 -83
  104. package/src/solid/picker-search.tsx +65 -63
  105. package/src/solid/picker-trigger.tsx +59 -57
  106. package/src/solid/popover.tsx +54 -54
  107. package/src/solid/preview-tile.tsx +67 -67
  108. package/src/solid/progress.tsx +21 -21
  109. package/src/solid/radio-group.tsx +51 -51
  110. package/src/solid/resizable.tsx +128 -128
  111. package/src/solid/responsive-dialog.tsx +134 -134
  112. package/src/solid/schema-form.tsx +743 -743
  113. package/src/solid/scope-indicator.tsx +5 -5
  114. package/src/solid/scroll-area.tsx +16 -16
  115. package/src/solid/section-card.tsx +281 -281
  116. package/src/solid/select.tsx +101 -101
  117. package/src/solid/separator.tsx +25 -25
  118. package/src/solid/settings-row.tsx +122 -122
  119. package/src/solid/sheet.tsx +96 -96
  120. package/src/solid/skeleton.tsx +8 -8
  121. package/src/solid/slider.tsx +132 -132
  122. package/src/solid/sliding-indicator.tsx +280 -265
  123. package/src/solid/sonner.tsx +165 -164
  124. package/src/solid/spinner.tsx +12 -12
  125. package/src/solid/spotlight.tsx +140 -140
  126. package/src/solid/step-indicator.tsx +18 -18
  127. package/src/solid/swatch-picker.tsx +38 -38
  128. package/src/solid/switch.tsx +52 -52
  129. package/src/solid/table.tsx +63 -63
  130. package/src/solid/tabs.tsx +93 -93
  131. package/src/solid/textarea.tsx +8 -8
  132. package/src/solid/toggle-group.tsx +83 -83
  133. package/src/solid/toggle.tsx +33 -33
  134. package/src/solid/tooltip.tsx +16 -16
  135. package/src/solid/widget-card.tsx +90 -90
  136. package/src/solid/widget-identity.tsx +99 -99
  137. package/src/solid/widget-trust-badge.tsx +20 -20
  138. package/src/styles/globals.css +316 -319
  139. package/src/styles/theme.css +448 -448
  140. package/src/tokens/hex.ts +29 -29
  141. package/src/tokens/material.ts +75 -75
  142. package/src/tokens/presets.ts +303 -303
  143. package/src/tokens/readability.ts +32 -32
  144. package/src/tokens/theme-colors.ts +95 -95
  145. package/src/tokens/theme-css.ts +22 -22
  146. package/src/tokens/theme-recipe.ts +106 -106
@@ -1,12 +1,12 @@
1
1
  import { DropdownMenu as MenuPrimitive } from "@kobalte/core/dropdown-menu";
2
2
  import {
3
- type Component,
4
- type ComponentProps,
5
- createSignal,
6
- onCleanup,
7
- onMount,
8
- type ParentComponent,
9
- splitProps,
3
+ type Component,
4
+ type ComponentProps,
5
+ createSignal,
6
+ onCleanup,
7
+ onMount,
8
+ type ParentComponent,
9
+ splitProps,
10
10
  } from "solid-js";
11
11
  import { glassToneText } from "../lib/glass-tone.js";
12
12
  import { MENU_ITEM, MENU_ITEM_BASE, MENU_LABEL, MENU_SEPARATOR } from "../lib/menu-classes.js";
@@ -35,214 +35,214 @@ export const MENU_CONTENT_CLASS = cn(FLOATING_PANEL, "min-w-[8rem] overflow-hidd
35
35
  * since --glass-tone does not inherit and the indicator is a sibling, not
36
36
  * an ancestor, of the rows it highlights. */
37
37
  export const MenuContentIndicator: ParentComponent = (props) => {
38
- let containerRef: HTMLDivElement | undefined;
39
- const [tone, setTone] = createSignal<string | undefined>(undefined);
40
-
41
- const syncTone = () => {
42
- const highlighted = containerRef?.querySelector<HTMLElement>("[data-highlighted]");
43
- setTone(highlighted?.style.getPropertyValue("--glass-tone") || undefined);
44
- };
45
-
46
- onMount(() => {
47
- if (!containerRef) return;
48
- const mo = new MutationObserver(syncTone);
49
- mo.observe(containerRef, {
50
- subtree: true,
51
- attributes: true,
52
- attributeFilter: ["data-highlighted"],
53
- });
54
- containerRef.addEventListener("focusin", syncTone);
55
- syncTone();
56
- onCleanup(() => {
57
- mo.disconnect();
58
- containerRef?.removeEventListener("focusin", syncTone);
59
- });
60
- });
61
-
62
- return (
63
- <SlidingIndicator
64
- ref={containerRef}
65
- // The one element between role="menu" and its role="menuitem" rows:
66
- // an unnamed div there breaks the menu's ownership in the a11y tree.
67
- role="none"
68
- class={STAGGER}
69
- activeSelector="[data-highlighted]"
70
- orientation="vertical"
71
- indicatorClass="rounded-sm"
72
- indicatorTone={tone()}
73
- >
74
- {props.children}
75
- </SlidingIndicator>
76
- );
38
+ let containerRef: HTMLDivElement | undefined;
39
+ const [tone, setTone] = createSignal<string | undefined>(undefined);
40
+
41
+ const syncTone = () => {
42
+ const highlighted = containerRef?.querySelector<HTMLElement>("[data-highlighted]");
43
+ setTone(highlighted?.style.getPropertyValue("--glass-tone") || undefined);
44
+ };
45
+
46
+ onMount(() => {
47
+ if (!containerRef) return;
48
+ const mo = new MutationObserver(syncTone);
49
+ mo.observe(containerRef, {
50
+ subtree: true,
51
+ attributes: true,
52
+ attributeFilter: ["data-highlighted"],
53
+ });
54
+ containerRef.addEventListener("focusin", syncTone);
55
+ syncTone();
56
+ onCleanup(() => {
57
+ mo.disconnect();
58
+ containerRef?.removeEventListener("focusin", syncTone);
59
+ });
60
+ });
61
+
62
+ return (
63
+ <SlidingIndicator
64
+ ref={containerRef}
65
+ // The one element between role="menu" and its role="menuitem" rows:
66
+ // an unnamed div there breaks the menu's ownership in the a11y tree.
67
+ role="none"
68
+ class={STAGGER}
69
+ activeSelector="[data-highlighted]"
70
+ orientation="vertical"
71
+ indicatorClass="rounded-sm"
72
+ indicatorTone={tone()}
73
+ >
74
+ {props.children}
75
+ </SlidingIndicator>
76
+ );
77
77
  };
78
78
 
79
79
  type ToneProps = {
80
- tone?: string;
81
- /** @deprecated pass `tone="var(--destructive)"` instead */
82
- variant?: "default" | "destructive";
80
+ tone?: string;
81
+ /** @deprecated pass `tone="var(--destructive)"` instead */
82
+ variant?: "default" | "destructive";
83
83
  };
84
84
 
85
85
  function resolveTone(local: ToneProps): string | undefined {
86
- return local.tone ?? (local.variant === "destructive" ? "var(--destructive)" : undefined);
86
+ return local.tone ?? (local.variant === "destructive" ? "var(--destructive)" : undefined);
87
87
  }
88
88
 
89
89
  function toneStyle(tone: string | undefined) {
90
- return tone ? { "--glass-tone": tone, color: glassToneText(tone) } : undefined;
90
+ return tone ? { "--glass-tone": tone, color: glassToneText(tone) } : undefined;
91
91
  }
92
92
 
93
93
  type MenuItemProps = ComponentProps<typeof MenuPrimitive.Item> &
94
- ToneProps & { inset?: boolean; slotName: string; style?: Record<string, string> };
94
+ ToneProps & { inset?: boolean; slotName: string; style?: Record<string, string> };
95
95
 
96
96
  /* True order among the menu's rows, labels and separators, for the stagger:
97
97
  * nth-child restarts inside a group, the DOM order does not. Refs fire before
98
98
  * insertion, hence the microtask. */
99
99
  function writeRowIndex(el: HTMLElement) {
100
- queueMicrotask(() => {
101
- const menu = el.closest('[role="menu"], [role="listbox"]');
102
- if (!menu) return;
103
- const i = Array.from(menu.querySelectorAll("[data-stagger-row]")).indexOf(el);
104
- if (i >= 0) el.style.setProperty("--i", String(i));
105
- });
100
+ queueMicrotask(() => {
101
+ const menu = el.closest('[role="menu"], [role="listbox"]');
102
+ if (!menu) return;
103
+ const i = Array.from(menu.querySelectorAll("[data-stagger-row]")).indexOf(el);
104
+ if (i >= 0) el.style.setProperty("--i", String(i));
105
+ });
106
106
  }
107
107
 
108
108
  export const MenuItemPart: Component<MenuItemProps> = (props) => {
109
- const [local, rest] = splitProps(props, [
110
- "class",
111
- "inset",
112
- "tone",
113
- "variant",
114
- "slotName",
115
- "style",
116
- ]);
117
- const tone = () => resolveTone(local);
118
- return (
119
- <MenuPrimitive.Item
120
- ref={writeRowIndex}
121
- data-stagger-row=""
122
- data-slot={local.slotName}
123
- data-inset={local.inset}
124
- data-tone={tone() ? "" : undefined}
125
- class={cn(MENU_ITEM, local.inset && "pl-8", local.class)}
126
- style={{ ...toneStyle(tone()), ...local.style }}
127
- {...rest}
128
- />
129
- );
109
+ const [local, rest] = splitProps(props, [
110
+ "class",
111
+ "inset",
112
+ "tone",
113
+ "variant",
114
+ "slotName",
115
+ "style",
116
+ ]);
117
+ const tone = () => resolveTone(local);
118
+ return (
119
+ <MenuPrimitive.Item
120
+ ref={writeRowIndex}
121
+ data-stagger-row=""
122
+ data-slot={local.slotName}
123
+ data-inset={local.inset}
124
+ data-tone={tone() ? "" : undefined}
125
+ class={cn(MENU_ITEM, local.inset && "pl-8", local.class)}
126
+ style={{ ...toneStyle(tone()), ...local.style }}
127
+ {...rest}
128
+ />
129
+ );
130
130
  };
131
131
 
132
132
  type MenuLabelProps = ComponentProps<typeof MenuPrimitive.GroupLabel> & {
133
- inset?: boolean;
134
- slotName: string;
133
+ inset?: boolean;
134
+ slotName: string;
135
135
  };
136
136
 
137
137
  export const MenuLabelPart: Component<MenuLabelProps> = (props) => {
138
- const [local, rest] = splitProps(props, ["class", "inset", "slotName"]);
139
- return (
140
- <MenuPrimitive.GroupLabel
141
- ref={writeRowIndex}
142
- data-stagger-row=""
143
- data-slot={local.slotName}
144
- data-inset={local.inset}
145
- class={cn(MENU_LABEL, local.inset && "pl-8", local.class)}
146
- {...rest}
147
- />
148
- );
138
+ const [local, rest] = splitProps(props, ["class", "inset", "slotName"]);
139
+ return (
140
+ <MenuPrimitive.GroupLabel
141
+ ref={writeRowIndex}
142
+ data-stagger-row=""
143
+ data-slot={local.slotName}
144
+ data-inset={local.inset}
145
+ class={cn(MENU_LABEL, local.inset && "pl-8", local.class)}
146
+ {...rest}
147
+ />
148
+ );
149
149
  };
150
150
 
151
151
  type MenuSeparatorProps = ComponentProps<typeof MenuPrimitive.Separator> & { slotName: string };
152
152
 
153
153
  export const MenuSeparatorPart: Component<MenuSeparatorProps> = (props) => {
154
- const [local, rest] = splitProps(props, ["class", "slotName"]);
155
- return (
156
- <MenuPrimitive.Separator
157
- ref={writeRowIndex}
158
- data-stagger-row=""
159
- data-slot={local.slotName}
160
- class={cn(MENU_SEPARATOR, local.class)}
161
- {...rest}
162
- />
163
- );
154
+ const [local, rest] = splitProps(props, ["class", "slotName"]);
155
+ return (
156
+ <MenuPrimitive.Separator
157
+ ref={writeRowIndex}
158
+ data-stagger-row=""
159
+ data-slot={local.slotName}
160
+ class={cn(MENU_SEPARATOR, local.class)}
161
+ {...rest}
162
+ />
163
+ );
164
164
  };
165
165
 
166
166
  type MenuSubTriggerProps = ComponentProps<typeof MenuPrimitive.SubTrigger> & {
167
- inset?: boolean;
168
- slotName: string;
167
+ inset?: boolean;
168
+ slotName: string;
169
169
  };
170
170
 
171
171
  export const MenuSubTriggerPart: ParentComponent<MenuSubTriggerProps> = (props) => {
172
- const [local, rest] = splitProps(props, ["class", "children", "inset", "slotName"]);
173
- return (
174
- <MenuPrimitive.SubTrigger
175
- ref={writeRowIndex}
176
- data-stagger-row=""
177
- data-slot={local.slotName}
178
- data-inset={local.inset}
179
- class={cn(MENU_ITEM, local.inset && "pl-8", local.class)}
180
- {...rest}
181
- >
182
- {local.children}
183
- <Icon icon="lucide:chevron-right" width={16} height={16} class="ml-auto" />
184
- </MenuPrimitive.SubTrigger>
185
- );
172
+ const [local, rest] = splitProps(props, ["class", "children", "inset", "slotName"]);
173
+ return (
174
+ <MenuPrimitive.SubTrigger
175
+ ref={writeRowIndex}
176
+ data-stagger-row=""
177
+ data-slot={local.slotName}
178
+ data-inset={local.inset}
179
+ class={cn(MENU_ITEM, local.inset && "pl-8", local.class)}
180
+ {...rest}
181
+ >
182
+ {local.children}
183
+ <Icon icon="lucide:chevron-right" width={16} height={16} class="ml-auto" />
184
+ </MenuPrimitive.SubTrigger>
185
+ );
186
186
  };
187
187
 
188
188
  type MenuSubContentProps = ComponentProps<typeof MenuPrimitive.SubContent> & { slotName: string };
189
189
 
190
190
  export const MenuSubContentPart: ParentComponent<MenuSubContentProps> = (props) => {
191
- const [local, rest] = splitProps(props, ["class", "children", "slotName"]);
192
- return (
193
- <MenuPrimitive.SubContent
194
- data-slot={local.slotName}
195
- class={cn(MENU_CONTENT_CLASS, local.class)}
196
- {...rest}
197
- >
198
- <MenuContentIndicator>{local.children}</MenuContentIndicator>
199
- </MenuPrimitive.SubContent>
200
- );
191
+ const [local, rest] = splitProps(props, ["class", "children", "slotName"]);
192
+ return (
193
+ <MenuPrimitive.SubContent
194
+ data-slot={local.slotName}
195
+ class={cn(MENU_CONTENT_CLASS, local.class)}
196
+ {...rest}
197
+ >
198
+ <MenuContentIndicator>{local.children}</MenuContentIndicator>
199
+ </MenuPrimitive.SubContent>
200
+ );
201
201
  };
202
202
 
203
203
  type MenuCheckboxItemProps = ComponentProps<typeof MenuPrimitive.CheckboxItem> & {
204
- slotName: string;
204
+ slotName: string;
205
205
  };
206
206
 
207
207
  export const MenuCheckboxItemPart: ParentComponent<MenuCheckboxItemProps> = (props) => {
208
- const [local, rest] = splitProps(props, ["class", "children", "slotName"]);
209
- return (
210
- <MenuPrimitive.CheckboxItem
211
- ref={writeRowIndex}
212
- data-stagger-row=""
213
- data-slot={local.slotName}
214
- class={cn(MENU_ITEM_BASE, "py-1.5 pr-2 pl-8", local.class)}
215
- {...rest}
216
- >
217
- <span class="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
218
- <MenuPrimitive.ItemIndicator>
219
- <Icon icon="lucide:check" width={16} height={16} class="size-4" />
220
- </MenuPrimitive.ItemIndicator>
221
- </span>
222
- {local.children}
223
- </MenuPrimitive.CheckboxItem>
224
- );
208
+ const [local, rest] = splitProps(props, ["class", "children", "slotName"]);
209
+ return (
210
+ <MenuPrimitive.CheckboxItem
211
+ ref={writeRowIndex}
212
+ data-stagger-row=""
213
+ data-slot={local.slotName}
214
+ class={cn(MENU_ITEM_BASE, "py-1.5 pr-2 pl-8", local.class)}
215
+ {...rest}
216
+ >
217
+ <span class="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
218
+ <MenuPrimitive.ItemIndicator>
219
+ <Icon icon="lucide:check" width={16} height={16} class="size-4" />
220
+ </MenuPrimitive.ItemIndicator>
221
+ </span>
222
+ {local.children}
223
+ </MenuPrimitive.CheckboxItem>
224
+ );
225
225
  };
226
226
 
227
227
  type MenuRadioItemProps = ComponentProps<typeof MenuPrimitive.RadioItem> & { slotName: string };
228
228
 
229
229
  export const MenuRadioItemPart: ParentComponent<MenuRadioItemProps> = (props) => {
230
- const [local, rest] = splitProps(props, ["class", "children", "slotName"]);
231
- return (
232
- <MenuPrimitive.RadioItem
233
- ref={writeRowIndex}
234
- data-stagger-row=""
235
- data-slot={local.slotName}
236
- class={cn(MENU_ITEM_BASE, "py-1.5 pr-2 pl-8", local.class)}
237
- {...rest}
238
- >
239
- <span class="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
240
- <MenuPrimitive.ItemIndicator>
241
- {/* mdi:circle is filled; lucide:circle is stroke-only and invisible at 8px. */}
242
- <Icon icon="mdi:circle" width={8} height={8} class="size-2" />
243
- </MenuPrimitive.ItemIndicator>
244
- </span>
245
- {local.children}
246
- </MenuPrimitive.RadioItem>
247
- );
230
+ const [local, rest] = splitProps(props, ["class", "children", "slotName"]);
231
+ return (
232
+ <MenuPrimitive.RadioItem
233
+ ref={writeRowIndex}
234
+ data-stagger-row=""
235
+ data-slot={local.slotName}
236
+ class={cn(MENU_ITEM_BASE, "py-1.5 pr-2 pl-8", local.class)}
237
+ {...rest}
238
+ >
239
+ <span class="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
240
+ <MenuPrimitive.ItemIndicator>
241
+ {/* mdi:circle is filled; lucide:circle is stroke-only and invisible at 8px. */}
242
+ <Icon icon="mdi:circle" width={8} height={8} class="size-2" />
243
+ </MenuPrimitive.ItemIndicator>
244
+ </span>
245
+ {local.children}
246
+ </MenuPrimitive.RadioItem>
247
+ );
248
248
  };
@@ -9,64 +9,64 @@ const SPINNER_COLUMN = "w-10";
9
9
  const SPINNER_RESERVE = "pr-10";
10
10
 
11
11
  const NumberField: Component<Omit<ComponentProps<"input">, "type">> = (props) => {
12
- const [local, others] = splitProps(props, ["class", "step", "min", "max"]);
13
- let ref: HTMLInputElement | undefined;
14
- const step = () => Number(local.step ?? 1) || 1;
12
+ const [local, others] = splitProps(props, ["class", "step", "min", "max"]);
13
+ let ref: HTMLInputElement | undefined;
14
+ const step = () => Number(local.step ?? 1) || 1;
15
15
 
16
- const nudge = (dir: 1 | -1) => {
17
- if (!ref) return;
18
- let next = (Number(ref.value) || 0) + dir * step();
19
- if (local.min != null) next = Math.max(Number(local.min), next);
20
- if (local.max != null) next = Math.min(Number(local.max), next);
21
- ref.value = String(next);
22
- ref.dispatchEvent(new Event("input", { bubbles: true }));
23
- };
16
+ const nudge = (dir: 1 | -1) => {
17
+ if (!ref) return;
18
+ let next = (Number(ref.value) || 0) + dir * step();
19
+ if (local.min != null) next = Math.max(Number(local.min), next);
20
+ if (local.max != null) next = Math.min(Number(local.max), next);
21
+ ref.value = String(next);
22
+ ref.dispatchEvent(new Event("input", { bubbles: true }));
23
+ };
24
24
 
25
- return (
26
- <div data-slot="number-field-root" class="relative">
27
- <input
28
- ref={ref}
29
- type="number"
30
- data-slot="number-field"
31
- step={local.step}
32
- min={local.min}
33
- max={local.max}
34
- class={cn(
35
- INPUT_CLASS,
36
- SPINNER_RESERVE,
37
- "[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
38
- local.class,
39
- )}
40
- {...others}
41
- />
42
- <div
43
- data-slot="number-field-spinner"
44
- class={cn(
45
- "absolute inset-y-0 right-0 flex flex-col divide-y divide-border overflow-hidden rounded-r-md border-border border-l",
46
- SPINNER_COLUMN,
47
- )}
48
- >
49
- <button
50
- type="button"
51
- tabindex={-1}
52
- aria-label="Increment"
53
- onClick={() => nudge(1)}
54
- class="flex flex-1 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground active:bg-muted"
55
- >
56
- <Icon icon="lucide:chevron-up" width={16} height={16} class="size-4" />
57
- </button>
58
- <button
59
- type="button"
60
- tabindex={-1}
61
- aria-label="Decrement"
62
- onClick={() => nudge(-1)}
63
- class="flex flex-1 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground active:bg-muted"
64
- >
65
- <Icon icon="lucide:chevron-down" width={16} height={16} class="size-4" />
66
- </button>
67
- </div>
68
- </div>
69
- );
25
+ return (
26
+ <div data-slot="number-field-root" class="relative">
27
+ <input
28
+ ref={ref}
29
+ type="number"
30
+ data-slot="number-field"
31
+ step={local.step}
32
+ min={local.min}
33
+ max={local.max}
34
+ class={cn(
35
+ INPUT_CLASS,
36
+ SPINNER_RESERVE,
37
+ "[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
38
+ local.class,
39
+ )}
40
+ {...others}
41
+ />
42
+ <div
43
+ data-slot="number-field-spinner"
44
+ class={cn(
45
+ "divide-border border-border absolute inset-y-0 right-0 flex flex-col divide-y overflow-hidden rounded-r-md border-l",
46
+ SPINNER_COLUMN,
47
+ )}
48
+ >
49
+ <button
50
+ type="button"
51
+ tabindex={-1}
52
+ aria-label="Increment"
53
+ onClick={() => nudge(1)}
54
+ class="text-muted-foreground hover:bg-muted hover:text-foreground active:bg-muted flex flex-1 items-center justify-center transition-colors"
55
+ >
56
+ <Icon icon="lucide:chevron-up" width={16} height={16} class="size-4" />
57
+ </button>
58
+ <button
59
+ type="button"
60
+ tabindex={-1}
61
+ aria-label="Decrement"
62
+ onClick={() => nudge(-1)}
63
+ class="text-muted-foreground hover:bg-muted hover:text-foreground active:bg-muted flex flex-1 items-center justify-center transition-colors"
64
+ >
65
+ <Icon icon="lucide:chevron-down" width={16} height={16} class="size-4" />
66
+ </button>
67
+ </div>
68
+ </div>
69
+ );
70
70
  };
71
71
 
72
72
  export { NumberField };