@warmio/ui 1.0.0 → 1.2.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.
@@ -0,0 +1,333 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-VIB7OX7D.js";
4
+
5
+ // ../ui/src/warmio/dropdown-menu.tsx
6
+ import * as React from "react";
7
+ import { Menu as MenuPrimitive } from "@base-ui/react/menu";
8
+ import { CheckIcon } from "lucide-react";
9
+
10
+ // ../ui/src/lib/interaction-feedback.ts
11
+ import { play, setEnabled } from "cuelume";
12
+
13
+ // ../ui/src/lib/haptic.ts
14
+ var supportsHaptic = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(pointer: coarse)").matches : false;
15
+ function getWarmCapacitor(win) {
16
+ return win?.Capacitor;
17
+ }
18
+ function isIosCapacitorApp(win = typeof window === "undefined" ? void 0 : window) {
19
+ const capacitor = getWarmCapacitor(win);
20
+ return capacitor?.getPlatform?.() === "ios" && capacitor?.isNativePlatform?.() === true;
21
+ }
22
+ function hasVibrate(nav) {
23
+ return "vibrate" in nav && typeof nav.vibrate === "function";
24
+ }
25
+ function triggerIosCapacitorHaptic() {
26
+ const haptics = getWarmCapacitor(typeof window === "undefined" ? void 0 : window)?.Plugins?.Haptics;
27
+ void haptics?.impact?.({ style: "LIGHT" }).catch(() => {
28
+ });
29
+ }
30
+ function haptic(pattern = 50) {
31
+ try {
32
+ if (isIosCapacitorApp()) {
33
+ triggerIosCapacitorHaptic();
34
+ return;
35
+ }
36
+ if (!supportsHaptic) return;
37
+ if (hasVibrate(navigator)) {
38
+ navigator.vibrate(pattern);
39
+ return;
40
+ }
41
+ const label = document.createElement("label");
42
+ label.ariaHidden = "true";
43
+ label.style.display = "none";
44
+ const input = document.createElement("input");
45
+ input.type = "checkbox";
46
+ input.setAttribute("switch", "");
47
+ label.appendChild(input);
48
+ try {
49
+ document.head.appendChild(label);
50
+ label.click();
51
+ } finally {
52
+ document.head.removeChild(label);
53
+ }
54
+ } catch {
55
+ }
56
+ }
57
+
58
+ // ../ui/src/lib/interaction-feedback.ts
59
+ var soundByIntent = {
60
+ press: "press",
61
+ selection: "tick",
62
+ toggle: "toggle"
63
+ };
64
+ var soundsEnabled = false;
65
+ setEnabled(false);
66
+ function triggerInteractionFeedback(intent, options = {}) {
67
+ if (options.haptic) {
68
+ haptic();
69
+ }
70
+ if (!soundsEnabled) return;
71
+ if (typeof document !== "undefined" && document.hidden) return;
72
+ try {
73
+ play(soundByIntent[intent]);
74
+ } catch {
75
+ }
76
+ }
77
+
78
+ // ../ui/src/warmio/dropdown-menu.tsx
79
+ import { jsx, jsxs } from "react/jsx-runtime";
80
+ function DropdownMenu(props) {
81
+ return /* @__PURE__ */ jsx(MenuPrimitive.Root, { ...props });
82
+ }
83
+ function DropdownMenuTrigger({
84
+ asChild = false,
85
+ children,
86
+ render,
87
+ className: _className,
88
+ style: _style,
89
+ ...props
90
+ }) {
91
+ const resolvedRender = render ?? (asChild && React.isValidElement(children) ? children : void 0);
92
+ return /* @__PURE__ */ jsx(MenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", render: resolvedRender, ...props, children: resolvedRender ? void 0 : children });
93
+ }
94
+ var dropdownMenuContentSizeClasses = {
95
+ default: "w-(--anchor-width) min-w-32",
96
+ auto: "w-auto min-w-[14rem]",
97
+ sidebar: "w-(--sidebar-width)"
98
+ };
99
+ var dropdownMenuContentSpacingClasses = {
100
+ default: "",
101
+ roomy: "flex flex-col gap-2"
102
+ };
103
+ function DropdownMenuContent({
104
+ align = "start",
105
+ alignOffset = 0,
106
+ side = "bottom",
107
+ sideOffset = 4,
108
+ portal = true,
109
+ size = "default",
110
+ spacing = "default",
111
+ children,
112
+ ref,
113
+ className: _className,
114
+ style: _style,
115
+ ...props
116
+ }) {
117
+ const content = /* @__PURE__ */ jsx(
118
+ MenuPrimitive.Positioner,
119
+ {
120
+ align,
121
+ alignOffset,
122
+ side,
123
+ sideOffset,
124
+ className: "isolate z-50 outline-none",
125
+ children: /* @__PURE__ */ jsx(
126
+ MenuPrimitive.Popup,
127
+ {
128
+ ref,
129
+ "data-slot": "dropdown-menu-content",
130
+ className: cn(
131
+ "z-[var(--z-popover)] max-h-(--available-height) origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-2 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none",
132
+ dropdownMenuContentSizeClasses[size],
133
+ dropdownMenuContentSpacingClasses[spacing],
134
+ "data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
135
+ "data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:animate-none"
136
+ ),
137
+ ...props,
138
+ children
139
+ }
140
+ )
141
+ }
142
+ );
143
+ return portal ? /* @__PURE__ */ jsx(MenuPrimitive.Portal, { children: content }) : content;
144
+ }
145
+ function DropdownMenuGroup({
146
+ className: _className,
147
+ style: _style,
148
+ ...props
149
+ }) {
150
+ return /* @__PURE__ */ jsx(MenuPrimitive.Group, { "data-slot": "dropdown-menu-group", ...props });
151
+ }
152
+ function DropdownMenuItem({
153
+ className: _className,
154
+ inset,
155
+ variant = "default",
156
+ ref,
157
+ style: _style,
158
+ ...props
159
+ }) {
160
+ return /* @__PURE__ */ jsx(
161
+ MenuPrimitive.Item,
162
+ {
163
+ ref,
164
+ "data-slot": "dropdown-menu-item",
165
+ "data-inset": inset,
166
+ "data-variant": variant,
167
+ className: "group/dropdown-menu-item relative flex w-full cursor-default items-center gap-2 rounded-lg px-2 py-2 text-sm outline-hidden select-none not-data-[variant=destructive]:focus:bg-sidebar-accent not-data-[variant=destructive]:focus:text-sidebar-accent-foreground not-data-[variant=destructive]:focus:**:text-sidebar-accent-foreground data-inset:pl-6 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
168
+ ...props
169
+ }
170
+ );
171
+ }
172
+ function DropdownMenuLinkItem({
173
+ className: _className,
174
+ children,
175
+ href,
176
+ inset,
177
+ variant = "default",
178
+ ref,
179
+ style: _style,
180
+ ...props
181
+ }) {
182
+ return /* @__PURE__ */ jsx(
183
+ MenuPrimitive.Item,
184
+ {
185
+ ref,
186
+ "data-slot": "dropdown-menu-item",
187
+ "data-inset": inset,
188
+ "data-variant": variant,
189
+ className: "group/dropdown-menu-item relative flex w-full cursor-default items-center gap-2 rounded-lg px-2 py-2 text-sm outline-hidden select-none not-data-[variant=destructive]:focus:bg-sidebar-accent not-data-[variant=destructive]:focus:text-sidebar-accent-foreground not-data-[variant=destructive]:focus:**:text-sidebar-accent-foreground data-inset:pl-6 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
190
+ render: /* @__PURE__ */ jsx("a", { href, children }),
191
+ ...props
192
+ }
193
+ );
194
+ }
195
+ function DropdownMenuCheckboxItem({
196
+ children,
197
+ checked,
198
+ inset,
199
+ className: _className,
200
+ ref,
201
+ style: _style,
202
+ onCheckedChange,
203
+ ...props
204
+ }) {
205
+ const handleCheckedChange = (nextChecked, eventDetails) => {
206
+ triggerInteractionFeedback("toggle");
207
+ onCheckedChange?.(nextChecked, eventDetails);
208
+ };
209
+ return /* @__PURE__ */ jsxs(
210
+ MenuPrimitive.CheckboxItem,
211
+ {
212
+ ref,
213
+ "data-slot": "dropdown-menu-checkbox-item",
214
+ "data-inset": inset,
215
+ className: "relative flex cursor-default items-center gap-2 rounded-lg py-2 pr-6 pl-2 text-sm outline-hidden select-none focus:bg-sidebar-accent focus:text-sidebar-accent-foreground focus:**:text-sidebar-accent-foreground data-inset:pl-6 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
216
+ checked,
217
+ onCheckedChange: handleCheckedChange,
218
+ ...props,
219
+ children: [
220
+ /* @__PURE__ */ jsx(
221
+ "span",
222
+ {
223
+ className: "pointer-events-none absolute right-2 flex items-center justify-center",
224
+ "data-slot": "dropdown-menu-checkbox-item-indicator",
225
+ children: /* @__PURE__ */ jsx(MenuPrimitive.CheckboxItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) })
226
+ }
227
+ ),
228
+ children
229
+ ]
230
+ }
231
+ );
232
+ }
233
+ function DropdownMenuRadioGroup({
234
+ className: _className,
235
+ onValueChange,
236
+ style: _style,
237
+ ...props
238
+ }) {
239
+ const handleValueChange = (value, eventDetails) => {
240
+ triggerInteractionFeedback("selection");
241
+ onValueChange?.(value, eventDetails);
242
+ };
243
+ return /* @__PURE__ */ jsx(
244
+ MenuPrimitive.RadioGroup,
245
+ {
246
+ "data-slot": "dropdown-menu-radio-group",
247
+ onValueChange: handleValueChange,
248
+ ...props
249
+ }
250
+ );
251
+ }
252
+ function DropdownMenuRadioItem({
253
+ children,
254
+ inset,
255
+ className: _className,
256
+ presentation,
257
+ ref,
258
+ style: _style,
259
+ ...props
260
+ }) {
261
+ return /* @__PURE__ */ jsxs(
262
+ MenuPrimitive.RadioItem,
263
+ {
264
+ ref,
265
+ "data-slot": "dropdown-menu-radio-item",
266
+ "data-inset": inset,
267
+ className: cn(
268
+ "relative flex cursor-default items-center gap-2 rounded-lg py-2 pr-6 pl-2 text-sm outline-hidden select-none focus:bg-sidebar-accent focus:text-sidebar-accent-foreground focus:**:text-sidebar-accent-foreground data-inset:pl-6 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
269
+ presentation === "selectMenu" && "min-h-12 text-base"
270
+ ),
271
+ ...props,
272
+ children: [
273
+ /* @__PURE__ */ jsx(
274
+ "span",
275
+ {
276
+ className: "pointer-events-none absolute right-2 flex items-center justify-center",
277
+ "data-slot": "dropdown-menu-radio-item-indicator",
278
+ children: /* @__PURE__ */ jsx(MenuPrimitive.RadioItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) })
279
+ }
280
+ ),
281
+ children
282
+ ]
283
+ }
284
+ );
285
+ }
286
+ function DropdownMenuLabel({
287
+ className: _className,
288
+ inset,
289
+ ref,
290
+ style: _style,
291
+ ...props
292
+ }) {
293
+ return /* @__PURE__ */ jsx(
294
+ MenuPrimitive.GroupLabel,
295
+ {
296
+ ref,
297
+ "data-slot": "dropdown-menu-label",
298
+ "data-inset": inset,
299
+ className: "px-2 py-2 text-xs font-bold text-muted-foreground data-inset:pl-6",
300
+ ...props
301
+ }
302
+ );
303
+ }
304
+ function DropdownMenuSeparator({
305
+ className: _className,
306
+ ref,
307
+ style: _style,
308
+ ...props
309
+ }) {
310
+ return /* @__PURE__ */ jsx(
311
+ MenuPrimitive.Separator,
312
+ {
313
+ ref,
314
+ "data-slot": "dropdown-menu-separator",
315
+ className: "mx-0 my-0 h-px bg-border",
316
+ ...props
317
+ }
318
+ );
319
+ }
320
+
321
+ export {
322
+ DropdownMenu,
323
+ DropdownMenuTrigger,
324
+ DropdownMenuContent,
325
+ DropdownMenuGroup,
326
+ DropdownMenuItem,
327
+ DropdownMenuLinkItem,
328
+ DropdownMenuCheckboxItem,
329
+ DropdownMenuRadioGroup,
330
+ DropdownMenuRadioItem,
331
+ DropdownMenuLabel,
332
+ DropdownMenuSeparator
333
+ };
@@ -0,0 +1,74 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-VIB7OX7D.js";
4
+
5
+ // ../ui/src/components/button.variants.ts
6
+ import { cva } from "class-variance-authority";
7
+ var buttonVariants = cva(
8
+ "group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-inset focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-inset aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: "border-[color:var(--button-primary-border)] bg-[var(--button-primary-bg)] bg-[image:var(--button-primary-gradient)] text-[color:var(--button-primary-foreground)] shadow-[var(--button-primary-shadow)] hover:bg-[var(--button-primary-hover)] active:bg-[var(--button-primary-active)]",
13
+ outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
14
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
15
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
16
+ destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
17
+ link: "underline-offset-4 decoration-current hover:underline"
18
+ },
19
+ size: {
20
+ default: "h-9 gap-2 rounded-lg px-3 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",
21
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
22
+ sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
23
+ md: "h-9 gap-2 rounded-lg px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",
24
+ lg: "h-11 gap-2 rounded-xl px-5 text-base has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",
25
+ xl: "h-12 gap-2 rounded-xl px-6 text-base has-data-[icon=inline-end]:pr-5 has-data-[icon=inline-start]:pl-5",
26
+ option: "h-auto min-h-16 items-start justify-start gap-2 whitespace-normal rounded-xl px-3 py-3 text-sm",
27
+ icon: "size-9",
28
+ "icon-round": "size-9 rounded-full",
29
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
30
+ "icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
31
+ "icon-lg": "size-10",
32
+ "icon-xl": "size-11 rounded-lg",
33
+ "input-icon": "h-full w-10 rounded-l-none"
34
+ }
35
+ },
36
+ defaultVariants: {
37
+ variant: "default",
38
+ size: "default"
39
+ }
40
+ }
41
+ );
42
+
43
+ // ../ui/src/components/button.tsx
44
+ import * as React from "react";
45
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
46
+ import { jsx } from "react/jsx-runtime";
47
+ function Button({
48
+ className,
49
+ variant = "default",
50
+ size = "default",
51
+ asChild = false,
52
+ render,
53
+ children,
54
+ ...props
55
+ }) {
56
+ const resolvedRender = render ?? (asChild && React.isValidElement(children) ? children : void 0);
57
+ return /* @__PURE__ */ jsx(
58
+ ButtonPrimitive,
59
+ {
60
+ "data-slot": "button",
61
+ "data-variant": variant,
62
+ "data-size": size,
63
+ className: cn(buttonVariants({ variant, size }), className),
64
+ ...props,
65
+ render: resolvedRender,
66
+ children: resolvedRender ? void 0 : children
67
+ }
68
+ );
69
+ }
70
+
71
+ export {
72
+ buttonVariants,
73
+ Button
74
+ };