@versaur/react 1.0.12 → 1.0.14
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/blocks.d.ts +1 -117
- package/dist/blocks.js +495 -714
- package/dist/drawer-DRv9k7lp.js +120 -0
- package/dist/forms.d.ts +125 -0
- package/dist/forms.js +618 -321
- package/dist/helpers-DTL6qrTe.js +129 -0
- package/dist/{overlay-parts-Zq9CuT31.js → overlay-parts-CFeD8VN0.js} +3 -3
- package/dist/primitive.d.ts +6 -6
- package/dist/primitive.js +8 -9
- package/dist/tooltip-BMKVL6jz.js +170 -0
- package/dist/utils.d.ts +87 -0
- package/dist/utils.js +62 -5
- package/package.json +2 -2
- package/dist/tooltip-Zuq8gd0f.js +0 -210
- package/dist/use-data-attrs-iPFyfiKN.js +0 -16
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as o, jsxs as w, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import { drawerStyles as L } from "@versaur/core/blocks";
|
|
3
|
+
import { overlayPartsStyles as i } from "@versaur/core/utils";
|
|
4
|
+
import { XIcon as j } from "@versaur/icons";
|
|
5
|
+
import F, { useRef as H, useEffect as n, useCallback as A, createContext as I, forwardRef as u, useContext as P } from "react";
|
|
6
|
+
import { u as S, B as M } from "./helpers-DTL6qrTe.js";
|
|
7
|
+
import { c as D } from "./cx-B9vmfsc1.js";
|
|
8
|
+
import { O as X, c as q, a as z } from "./overlay-parts-CFeD8VN0.js";
|
|
9
|
+
const y = F.forwardRef(
|
|
10
|
+
({ isOpen: e, onOpenChange: t, children: a, onClick: s, ...d }, l) => {
|
|
11
|
+
const m = H(null), c = l || m;
|
|
12
|
+
n(() => {
|
|
13
|
+
const r = c.current;
|
|
14
|
+
if (r) {
|
|
15
|
+
if (e)
|
|
16
|
+
try {
|
|
17
|
+
r.showModal(), document.documentElement.style.overflow = "hidden";
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
r.close(), document.documentElement.style.overflow = "";
|
|
22
|
+
return () => {
|
|
23
|
+
document.documentElement.style.overflow = "";
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}, [e, c]), n(() => {
|
|
27
|
+
const r = c.current;
|
|
28
|
+
if (!r)
|
|
29
|
+
return;
|
|
30
|
+
const f = () => t == null ? void 0 : t(!1), v = (b) => {
|
|
31
|
+
b.preventDefault(), t == null || t(!1);
|
|
32
|
+
};
|
|
33
|
+
return r.addEventListener("close", f), r.addEventListener("cancel", v), () => {
|
|
34
|
+
r.removeEventListener("close", f), r.removeEventListener("cancel", v);
|
|
35
|
+
};
|
|
36
|
+
}, [t, c]);
|
|
37
|
+
const R = A(
|
|
38
|
+
(r) => {
|
|
39
|
+
r.target === r.currentTarget && (t == null || t(!1)), s == null || s(r);
|
|
40
|
+
},
|
|
41
|
+
[t, s]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ o("dialog", { ...d, ref: c, onClick: R, children: a });
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
y.displayName = "Dialog";
|
|
47
|
+
const G = y, N = I(void 0), J = () => {
|
|
48
|
+
const e = P(N);
|
|
49
|
+
if (!e)
|
|
50
|
+
throw new Error("Drawer subcomponents must be used within Drawer");
|
|
51
|
+
return e;
|
|
52
|
+
}, x = u(
|
|
53
|
+
({ open: e, onOpenChange: t, placement: a = "right", children: s, className: d, ...l }, m) => {
|
|
54
|
+
const c = S({
|
|
55
|
+
placement: a
|
|
56
|
+
});
|
|
57
|
+
return /* @__PURE__ */ o(N.Provider, { value: { onClose: () => t == null ? void 0 : t(!1) }, children: /* @__PURE__ */ o(
|
|
58
|
+
G,
|
|
59
|
+
{
|
|
60
|
+
ref: m,
|
|
61
|
+
isOpen: e,
|
|
62
|
+
onOpenChange: t,
|
|
63
|
+
className: D(e && L.drawer, d),
|
|
64
|
+
...c,
|
|
65
|
+
...l,
|
|
66
|
+
children: /* @__PURE__ */ o("div", { className: i.content, children: s })
|
|
67
|
+
}
|
|
68
|
+
) });
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
x.displayName = "Drawer";
|
|
72
|
+
const E = u(({ onClick: e, ...t }, a) => {
|
|
73
|
+
const { onClose: s } = J();
|
|
74
|
+
return /* @__PURE__ */ o(
|
|
75
|
+
M,
|
|
76
|
+
{
|
|
77
|
+
ref: a,
|
|
78
|
+
variant: "ghost",
|
|
79
|
+
as: j,
|
|
80
|
+
"aria-label": "Close",
|
|
81
|
+
onClick: (l) => {
|
|
82
|
+
s(), e == null || e(l);
|
|
83
|
+
},
|
|
84
|
+
className: i.closeButton,
|
|
85
|
+
...t
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
E.displayName = "Drawer.CloseButton";
|
|
90
|
+
const B = u(
|
|
91
|
+
({ action: e, children: t, tabs: a, className: s, ...d }, l) => /* @__PURE__ */ w(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
ref: l,
|
|
95
|
+
className: D(i.header, s),
|
|
96
|
+
...d,
|
|
97
|
+
...e && { "data-action": "" },
|
|
98
|
+
...a && { "data-tabs": "" },
|
|
99
|
+
children: [
|
|
100
|
+
e ? /* @__PURE__ */ w(T, { children: [
|
|
101
|
+
/* @__PURE__ */ o("div", { className: i.headerTop, children: e }),
|
|
102
|
+
t && /* @__PURE__ */ o("div", { className: i.headerContent, children: t })
|
|
103
|
+
] }) : /* @__PURE__ */ o("div", { className: i.headerTop, children: t }),
|
|
104
|
+
a
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
B.displayName = "Drawer.Header";
|
|
110
|
+
const $ = Object.assign(x, {
|
|
111
|
+
Body: z,
|
|
112
|
+
CloseButton: E,
|
|
113
|
+
Footer: q,
|
|
114
|
+
Header: B,
|
|
115
|
+
Title: X
|
|
116
|
+
});
|
|
117
|
+
export {
|
|
118
|
+
$ as D,
|
|
119
|
+
G as a
|
|
120
|
+
};
|
package/dist/forms.d.ts
CHANGED
|
@@ -213,6 +213,131 @@ declare interface ChipInputSingleProps extends ChipInputBaseProps {
|
|
|
213
213
|
onChange: (value: string) => void;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
export declare const ComboboxInput: ForwardRefExoticComponent<ComboboxInputRootProps & RefAttributes<HTMLDivElement>> & {
|
|
217
|
+
Button: ForwardRefExoticComponent<ComboboxInputButtonProps & RefAttributes<HTMLButtonElement>>;
|
|
218
|
+
Listbox: ForwardRefExoticComponent<ComboboxInputListboxProps & RefAttributes<HTMLUListElement>>;
|
|
219
|
+
Drawer: ForwardRefExoticComponent<ComboboxInputListboxProps & RefAttributes<HTMLUListElement>>;
|
|
220
|
+
Option: ForwardRefExoticComponent<ComboboxInputOptionProps & RefAttributes<HTMLLIElement>>;
|
|
221
|
+
SelectionChips: ForwardRefExoticComponent<ComboboxInputSelectionChipsProps & RefAttributes<HTMLDivElement>>;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Props for ComboboxInput.Button subcomponent
|
|
226
|
+
*/
|
|
227
|
+
export declare interface ComboboxInputButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
|
|
228
|
+
/**
|
|
229
|
+
* Label text or content (default: "Select ..." or "${count} selected")
|
|
230
|
+
*/
|
|
231
|
+
children?: ReactNode;
|
|
232
|
+
/**
|
|
233
|
+
* Left icon element
|
|
234
|
+
*/
|
|
235
|
+
iconLeft?: ReactNode;
|
|
236
|
+
/**
|
|
237
|
+
* Right icon element (default: ChevronDown)
|
|
238
|
+
*/
|
|
239
|
+
iconRight?: ReactNode;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Props for ComboboxInput.Listbox subcomponent
|
|
244
|
+
*/
|
|
245
|
+
export declare interface ComboboxInputListboxProps extends Omit<HTMLAttributes<HTMLUListElement>, "role"> {
|
|
246
|
+
/**
|
|
247
|
+
* List items (Option elements)
|
|
248
|
+
*/
|
|
249
|
+
children?: ReactNode;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Props for ComboboxInput.Option subcomponent
|
|
254
|
+
*/
|
|
255
|
+
export declare interface ComboboxInputOptionProps extends Omit<HTMLAttributes<HTMLLIElement>, "children" | "role"> {
|
|
256
|
+
/**
|
|
257
|
+
* Option value
|
|
258
|
+
*/
|
|
259
|
+
value: string;
|
|
260
|
+
/**
|
|
261
|
+
* Display label (children)
|
|
262
|
+
*/
|
|
263
|
+
children?: ReactNode;
|
|
264
|
+
/**
|
|
265
|
+
* Disabled state for this option
|
|
266
|
+
*/
|
|
267
|
+
disabled?: boolean;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Root props for ComboboxInput
|
|
272
|
+
*/
|
|
273
|
+
export declare interface ComboboxInputRootProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
274
|
+
/**
|
|
275
|
+
* Selected values (array)
|
|
276
|
+
*/
|
|
277
|
+
value: string[];
|
|
278
|
+
/**
|
|
279
|
+
* Change handler for selected values
|
|
280
|
+
*/
|
|
281
|
+
onChange: (value: string[]) => void;
|
|
282
|
+
/**
|
|
283
|
+
* Display variant
|
|
284
|
+
* @default "popup"
|
|
285
|
+
*/
|
|
286
|
+
variant?: ComboboxInputVariant;
|
|
287
|
+
/**
|
|
288
|
+
* Placeholder text when no values selected
|
|
289
|
+
* @default "Select…"
|
|
290
|
+
*/
|
|
291
|
+
placeholder?: string;
|
|
292
|
+
/**
|
|
293
|
+
* Disabled state
|
|
294
|
+
*/
|
|
295
|
+
disabled?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Invalid/error state
|
|
298
|
+
*/
|
|
299
|
+
invalid?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Label for the input
|
|
302
|
+
*/
|
|
303
|
+
label?: ReactNode;
|
|
304
|
+
/**
|
|
305
|
+
* Helper text shown below
|
|
306
|
+
*/
|
|
307
|
+
helper?: ReactNode;
|
|
308
|
+
/**
|
|
309
|
+
* Error message shown below
|
|
310
|
+
*/
|
|
311
|
+
error?: ReactNode;
|
|
312
|
+
/**
|
|
313
|
+
* Required indicator
|
|
314
|
+
*/
|
|
315
|
+
required?: boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Left icon element
|
|
318
|
+
*/
|
|
319
|
+
iconLeft?: ReactNode;
|
|
320
|
+
/**
|
|
321
|
+
* Right icon element (typically filled by the component's chevron)
|
|
322
|
+
*/
|
|
323
|
+
iconRight?: ReactNode;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Props for ComboboxInput.SelectionChips subcomponent
|
|
328
|
+
*/
|
|
329
|
+
export declare interface ComboboxInputSelectionChipsProps extends HTMLAttributes<HTMLDivElement> {
|
|
330
|
+
/**
|
|
331
|
+
* Container for chip elements (renders null if empty)
|
|
332
|
+
*/
|
|
333
|
+
children?: ReactNode;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* ComboboxInput variant: 'popup' uses Popover API + CSS Anchor Positioning, 'drawer' uses Drawer component
|
|
338
|
+
*/
|
|
339
|
+
export declare type ComboboxInputVariant = "popup" | "drawer";
|
|
340
|
+
|
|
216
341
|
/**
|
|
217
342
|
* ErrorText component for form field error messages
|
|
218
343
|
* Internal primitive - not exported from main package
|