@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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/use-is-mobile.d.ts +3 -1
- package/dist/solid/index.d.ts +9 -9
- package/dist/solid/index.js +5431 -5424
- package/dist/solid/sonner.d.ts +1 -0
- package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
- package/package.json +128 -126
- package/scripts/check-gallery.ts +142 -142
- package/scripts/check-pack.ts +13 -13
- package/scripts/check-structural-classes.ts +20 -20
- package/scripts/check-tokens.ts +27 -27
- package/scripts/check-ui-drift.mjs +103 -103
- package/src/index.ts +75 -80
- package/src/lib/alert-tones.ts +41 -41
- package/src/lib/anchor-placement.ts +21 -21
- package/src/lib/button-variants.ts +28 -28
- package/src/lib/card-classes.ts +9 -9
- package/src/lib/carousel-classes.ts +14 -14
- package/src/lib/glass-tone.ts +11 -11
- package/src/lib/input-classes.ts +6 -6
- package/src/lib/layers.ts +4 -4
- package/src/lib/logo-lockup.ts +8 -8
- package/src/lib/menu-classes.ts +2 -2
- package/src/lib/motion-classes.ts +8 -8
- package/src/lib/motion-window.ts +24 -24
- package/src/lib/overlay-classes.ts +6 -6
- package/src/lib/pill-classes.ts +3 -3
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/spotlight-geometry.ts +67 -67
- package/src/lib/thumb-classes.ts +2 -2
- package/src/lib/tier-badge.ts +16 -16
- package/src/lib/use-is-mobile.ts +17 -14
- package/src/lib/utils.ts +1 -1
- package/src/solid/accordion.tsx +41 -41
- package/src/solid/alert-dialog.tsx +95 -95
- package/src/solid/alert.tsx +88 -88
- package/src/solid/area-picker.tsx +204 -204
- package/src/solid/aspect-ratio.tsx +13 -13
- package/src/solid/avatar.tsx +27 -27
- package/src/solid/badge.tsx +49 -49
- package/src/solid/bottom-sheet/arbitration.ts +22 -22
- package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
- package/src/solid/bottom-sheet/drag-controller.ts +201 -201
- package/src/solid/bottom-sheet/focus-trap.ts +51 -47
- package/src/solid/bottom-sheet/index.ts +12 -12
- package/src/solid/bottom-sheet/keyboard.ts +25 -25
- package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
- package/src/solid/bottom-sheet/state-machine.ts +28 -28
- package/src/solid/bottom-sheet/velocity.ts +29 -29
- package/src/solid/breadcrumb.tsx +76 -76
- package/src/solid/button-group.tsx +46 -46
- package/src/solid/button.tsx +19 -19
- package/src/solid/card.tsx +67 -67
- package/src/solid/carousel.tsx +246 -246
- package/src/solid/charts.tsx +253 -253
- package/src/solid/checkbox.tsx +51 -51
- package/src/solid/collapsible.tsx +22 -22
- package/src/solid/color-disc.tsx +213 -213
- package/src/solid/color-slider.tsx +81 -81
- package/src/solid/color-wheel.tsx +61 -61
- package/src/solid/context-menu.tsx +63 -63
- package/src/solid/copy-button.tsx +31 -31
- package/src/solid/count-pill.tsx +11 -11
- package/src/solid/dashboard-preview.tsx +104 -104
- package/src/solid/data-table.tsx +228 -228
- package/src/solid/dialog-parts.tsx +127 -127
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -339
- package/src/solid/docked-panel.tsx +35 -35
- package/src/solid/dropdown-menu.tsx +77 -77
- package/src/solid/empty.tsx +70 -70
- package/src/solid/entity-data.ts +38 -38
- package/src/solid/entity-selector.tsx +634 -634
- package/src/solid/field.tsx +205 -205
- package/src/solid/form.tsx +159 -159
- package/src/solid/hero-action.tsx +85 -85
- package/src/solid/hover-card.tsx +11 -11
- package/src/solid/icon-picker.tsx +401 -401
- package/src/solid/icon.tsx +101 -78
- package/src/solid/image-picker.tsx +416 -414
- package/src/solid/index.ts +265 -304
- package/src/solid/input-group.tsx +123 -123
- package/src/solid/input-otp.tsx +143 -143
- package/src/solid/input.tsx +4 -4
- package/src/solid/item.tsx +130 -130
- package/src/solid/kbd.tsx +20 -20
- package/src/solid/label.tsx +12 -12
- package/src/solid/list-reorder.ts +122 -122
- package/src/solid/logo.tsx +60 -60
- package/src/solid/media-copy.ts +21 -21
- package/src/solid/media-store.ts +56 -56
- package/src/solid/media-tile.tsx +85 -85
- package/src/solid/menu-parts.tsx +164 -164
- package/src/solid/number-field.tsx +56 -56
- package/src/solid/option-card.tsx +164 -164
- package/src/solid/ornament.tsx +43 -43
- package/src/solid/overlay.tsx +4 -4
- package/src/solid/page-header.tsx +75 -75
- package/src/solid/pagination.tsx +80 -80
- package/src/solid/password-input.tsx +51 -51
- package/src/solid/picker-row.tsx +83 -83
- package/src/solid/picker-search.tsx +65 -63
- package/src/solid/picker-trigger.tsx +59 -57
- package/src/solid/popover.tsx +54 -54
- package/src/solid/preview-tile.tsx +67 -67
- package/src/solid/progress.tsx +21 -21
- package/src/solid/radio-group.tsx +51 -51
- package/src/solid/resizable.tsx +128 -128
- package/src/solid/responsive-dialog.tsx +134 -134
- package/src/solid/schema-form.tsx +743 -743
- package/src/solid/scope-indicator.tsx +5 -5
- package/src/solid/scroll-area.tsx +16 -16
- package/src/solid/section-card.tsx +281 -281
- package/src/solid/select.tsx +101 -101
- package/src/solid/separator.tsx +25 -25
- package/src/solid/settings-row.tsx +122 -122
- package/src/solid/sheet.tsx +96 -96
- package/src/solid/skeleton.tsx +8 -8
- package/src/solid/slider.tsx +132 -132
- package/src/solid/sliding-indicator.tsx +280 -265
- package/src/solid/sonner.tsx +165 -164
- package/src/solid/spinner.tsx +12 -12
- package/src/solid/spotlight.tsx +140 -140
- package/src/solid/step-indicator.tsx +18 -18
- package/src/solid/swatch-picker.tsx +38 -38
- package/src/solid/switch.tsx +52 -52
- package/src/solid/table.tsx +63 -63
- package/src/solid/tabs.tsx +93 -93
- package/src/solid/textarea.tsx +8 -8
- package/src/solid/toggle-group.tsx +83 -83
- package/src/solid/toggle.tsx +33 -33
- package/src/solid/tooltip.tsx +16 -16
- package/src/solid/widget-card.tsx +90 -90
- package/src/solid/widget-identity.tsx +99 -99
- package/src/solid/widget-trust-badge.tsx +20 -20
- package/src/styles/globals.css +316 -319
- package/src/styles/theme.css +448 -448
- package/src/tokens/hex.ts +29 -29
- package/src/tokens/material.ts +75 -75
- package/src/tokens/presets.ts +303 -303
- package/src/tokens/readability.ts +32 -32
- package/src/tokens/theme-colors.ts +95 -95
- package/src/tokens/theme-css.ts +22 -22
- package/src/tokens/theme-recipe.ts +106 -106
package/src/solid/menu-parts.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DropdownMenu as MenuPrimitive } from "@kobalte/core/dropdown-menu";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
86
|
+
return local.tone ?? (local.variant === "destructive" ? "var(--destructive)" : undefined);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function toneStyle(tone: string | undefined) {
|
|
90
|
-
|
|
90
|
+
return tone ? { "--glass-tone": tone, color: glassToneText(tone) } : undefined;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
type MenuItemProps = ComponentProps<typeof MenuPrimitive.Item> &
|
|
94
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
134
|
-
|
|
133
|
+
inset?: boolean;
|
|
134
|
+
slotName: string;
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
export const MenuLabelPart: Component<MenuLabelProps> = (props) => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
168
|
-
|
|
167
|
+
inset?: boolean;
|
|
168
|
+
slotName: string;
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
export const MenuSubTriggerPart: ParentComponent<MenuSubTriggerProps> = (props) => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
204
|
+
slotName: string;
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
export const MenuCheckboxItemPart: ParentComponent<MenuCheckboxItemProps> = (props) => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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 };
|