@moondreamsdev/dreamer-ui 1.0.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/README.md +52 -0
- package/dist/core/components/button/Button.d.ts +10 -0
- package/dist/core/components/button/LoadingDots.d.ts +1 -0
- package/dist/core/components/button/index.d.ts +3 -0
- package/dist/core/components/button/variants.d.ts +34 -0
- package/dist/core/components/checkbox/Checkbox.d.ts +11 -0
- package/dist/core/components/checkbox/hooks.d.ts +1 -0
- package/dist/core/components/checkbox/index.d.ts +1 -0
- package/dist/core/components/input/Input.d.ts +11 -0
- package/dist/core/components/input/index.d.ts +1 -0
- package/dist/core/components/input/variants.d.ts +20 -0
- package/dist/core/components/label/index.d.ts +1 -0
- package/dist/core/components/label/label.d.ts +9 -0
- package/dist/core/components/radiogroup/RadioGroup.d.ts +19 -0
- package/dist/core/components/radiogroup/RadioGroupItem.d.ts +12 -0
- package/dist/core/components/radiogroup/RadioInput.d.ts +9 -0
- package/dist/core/components/radiogroup/hooks.d.ts +1 -0
- package/dist/core/components/radiogroup/index.d.ts +3 -0
- package/dist/core/components/textarea/CharacterCount.d.ts +6 -0
- package/dist/core/components/textarea/Textarea.d.ts +14 -0
- package/dist/core/components/textarea/hooks.d.ts +1 -0
- package/dist/core/components/textarea/index.d.ts +1 -0
- package/dist/core/components/textarea/variants.d.ts +19 -0
- package/dist/core/shared/forms/StatusHelpMessage.d.ts +7 -0
- package/dist/core/shared/forms/index.d.ts +1 -0
- package/dist/core/symbols/Check.d.ts +4 -0
- package/dist/core/symbols/CheckCircled.d.ts +3 -0
- package/dist/core/symbols/ExclamationTriangle.d.ts +3 -0
- package/dist/core/symbols/EyeClosed.d.ts +3 -0
- package/dist/core/symbols/EyeOpened.d.ts +3 -0
- package/dist/core/symbols/QuestionMarkCircled.d.ts +4 -0
- package/dist/core/symbols/index.d.ts +5 -0
- package/dist/core/util/join.d.ts +8 -0
- package/dist/core/utilities/Slot.d.ts +7 -0
- package/dist/dreamer-ui.css +1 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +732 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +67 -0
@@ -0,0 +1,732 @@
|
|
1
|
+
import { jsx as i, jsxs as x } from "react/jsx-runtime";
|
2
|
+
import B, { useState as L, useEffect as N, useCallback as E, useId as A, useMemo as j, isValidElement as S, cloneElement as V, createElement as z } from "react";
|
3
|
+
function C(...e) {
|
4
|
+
return e.filter((r) => typeof r == "string" && r).join(" ").trim() || void 0;
|
5
|
+
}
|
6
|
+
function F() {
|
7
|
+
const [e, t] = L(0);
|
8
|
+
return N(() => {
|
9
|
+
const r = setInterval(() => {
|
10
|
+
t((n) => (n + 1) % 3);
|
11
|
+
}, 500);
|
12
|
+
return () => clearInterval(r);
|
13
|
+
}, []), /* @__PURE__ */ i("div", { className: "absolute inset-0 inline-flex items-center justify-center gap-x-2 align-middle", children: [0, 1, 2].map((r) => /* @__PURE__ */ i(
|
14
|
+
"div",
|
15
|
+
{
|
16
|
+
className: C(
|
17
|
+
"rounded-full transition-all duration-500 ease-in-out size-[0.35em] bg-current",
|
18
|
+
e === r && "transform -translate-y-1"
|
19
|
+
)
|
20
|
+
},
|
21
|
+
r
|
22
|
+
)) });
|
23
|
+
}
|
24
|
+
const q = {
|
25
|
+
base: "",
|
26
|
+
primary: "bg-primary text-primary-foreground hover:bg-primary/85 disabled:bg-muted disabled:text-muted-foreground",
|
27
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/85 disabled:bg-muted/80 disabled:text-muted-foreground/80",
|
28
|
+
tertiary: "text-primary hover:text-primary-foreground disabled:text-muted",
|
29
|
+
outline: "border border-primary text-primary hover:border-primary-foreground hover:text-primary-foreground disabled:border-muted disabled:text-muted",
|
30
|
+
link: "underline-offset-4 hover:underline disabled:underline disabled:text-muted",
|
31
|
+
danger: "bg-danger text-danger-foreground hover:bg-danger/85 disabled:bg-muted disabled:text-muted-foreground"
|
32
|
+
}, H = {
|
33
|
+
stripped: "",
|
34
|
+
fitted: "size-fit",
|
35
|
+
sm: "px-2 py-1 text-sm",
|
36
|
+
md: "px-4 py-2 text-base",
|
37
|
+
lg: "px-6 py-3 text-lg",
|
38
|
+
icon: "p-1 w-fit aspect-square",
|
39
|
+
full: "p-2 w-full"
|
40
|
+
}, G = {
|
41
|
+
none: "rounded-none",
|
42
|
+
sm: "rounded-sm",
|
43
|
+
md: "rounded-md",
|
44
|
+
lg: "rounded-lg",
|
45
|
+
full: "rounded-full"
|
46
|
+
}, R = {
|
47
|
+
variant: "primary",
|
48
|
+
size: "md",
|
49
|
+
rounded: "md"
|
50
|
+
};
|
51
|
+
function oe({
|
52
|
+
variant: e = R.variant,
|
53
|
+
size: t,
|
54
|
+
rounded: r = R.rounded,
|
55
|
+
loading: n,
|
56
|
+
linkTo: a,
|
57
|
+
linkProps: o,
|
58
|
+
type: d = "button",
|
59
|
+
className: l,
|
60
|
+
...u
|
61
|
+
}) {
|
62
|
+
let b;
|
63
|
+
e === "link" && !t ? b = "fitted" : b = t || R.size;
|
64
|
+
const s = C(
|
65
|
+
"appearance-none focus:outline-none focus:ring not-disabled:hover:cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed transition-all",
|
66
|
+
q[e],
|
67
|
+
H[b],
|
68
|
+
G[r],
|
69
|
+
n && "relative pointer-events-none",
|
70
|
+
a && "relative",
|
71
|
+
l
|
72
|
+
);
|
73
|
+
return /* @__PURE__ */ x(
|
74
|
+
"button",
|
75
|
+
{
|
76
|
+
...u,
|
77
|
+
role: a ? "link" : u.role,
|
78
|
+
"aria-label": u["aria-label"] || (o == null ? void 0 : o["aria-label"]),
|
79
|
+
"aria-description": u["aria-description"] || (o == null ? void 0 : o["aria-description"]),
|
80
|
+
"aria-disabled": u.disabled || n,
|
81
|
+
"aria-busy": n,
|
82
|
+
type: d,
|
83
|
+
className: s,
|
84
|
+
children: [
|
85
|
+
n && /* @__PURE__ */ i(F, {}),
|
86
|
+
/* @__PURE__ */ i("span", { className: C(n && "invisible"), children: u.children }),
|
87
|
+
a && !u.disabled && /* @__PURE__ */ i(
|
88
|
+
"a",
|
89
|
+
{
|
90
|
+
...o,
|
91
|
+
"aria-hidden": !0,
|
92
|
+
href: a,
|
93
|
+
target: (o == null ? void 0 : o.target) || "_blank",
|
94
|
+
rel: (o == null ? void 0 : o.rel) || "noreferrer",
|
95
|
+
className: "absolute inset-0"
|
96
|
+
}
|
97
|
+
)
|
98
|
+
]
|
99
|
+
}
|
100
|
+
);
|
101
|
+
}
|
102
|
+
function K({ size: e = 15, color: t = "currentColor" }) {
|
103
|
+
return /* @__PURE__ */ i("svg", { width: e, height: e, className: "inline", viewBox: "0 0 15 15", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ i(
|
104
|
+
"path",
|
105
|
+
{
|
106
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
107
|
+
fill: t,
|
108
|
+
fillRule: "evenodd",
|
109
|
+
clipRule: "evenodd"
|
110
|
+
}
|
111
|
+
) });
|
112
|
+
}
|
113
|
+
function T(e) {
|
114
|
+
const [t, r] = L(""), n = E((a) => {
|
115
|
+
let o = a, d = "";
|
116
|
+
for (; o && !d; ) {
|
117
|
+
const l = window.getComputedStyle(o).backgroundColor;
|
118
|
+
l && l !== "transparent" && l !== "rgba(0, 0, 0, 0)" && (d = l), o = o.parentElement;
|
119
|
+
}
|
120
|
+
return d || "transparent";
|
121
|
+
}, []);
|
122
|
+
return N(() => {
|
123
|
+
const a = document.getElementById(e);
|
124
|
+
if (a) {
|
125
|
+
const o = n(a.parentElement);
|
126
|
+
r(o);
|
127
|
+
}
|
128
|
+
}, [e, n]), t;
|
129
|
+
}
|
130
|
+
function se({
|
131
|
+
ref: e,
|
132
|
+
id: t,
|
133
|
+
size: r = 20,
|
134
|
+
color: n,
|
135
|
+
filled: a = !1,
|
136
|
+
rounded: o = !0,
|
137
|
+
checked: d = !1,
|
138
|
+
onCheckedChange: l,
|
139
|
+
disabled: u,
|
140
|
+
className: b = "",
|
141
|
+
...m
|
142
|
+
}) {
|
143
|
+
const s = A(), v = j(() => t || `checkbox-${s}`, [t, s]), f = T(v), [c, g] = L(d);
|
144
|
+
N(() => {
|
145
|
+
g(d);
|
146
|
+
}, [d]);
|
147
|
+
const w = () => {
|
148
|
+
u || (g(!c), l == null || l(!c));
|
149
|
+
}, h = (y) => {
|
150
|
+
y.key === " " && (y.preventDefault(), w());
|
151
|
+
}, p = C(
|
152
|
+
"flex items-center justify-center border outline outline-transparent focus:outline-current focus:outline-offset-2",
|
153
|
+
o && "rounded",
|
154
|
+
u && "opacity-40 cursor-not-allowed",
|
155
|
+
!u && "cursor-pointer",
|
156
|
+
b
|
157
|
+
);
|
158
|
+
return /* @__PURE__ */ i(
|
159
|
+
"button",
|
160
|
+
{
|
161
|
+
id: v,
|
162
|
+
type: "button",
|
163
|
+
ref: e,
|
164
|
+
tabIndex: 0,
|
165
|
+
role: "checkbox",
|
166
|
+
onClick: w,
|
167
|
+
"aria-checked": c,
|
168
|
+
"aria-disabled": u,
|
169
|
+
onKeyDownCapture: h,
|
170
|
+
style: {
|
171
|
+
width: r,
|
172
|
+
height: r,
|
173
|
+
color: n,
|
174
|
+
backgroundColor: c && a ? "currentcolor" : "transparent"
|
175
|
+
},
|
176
|
+
className: p,
|
177
|
+
...m,
|
178
|
+
children: c && /* @__PURE__ */ i(K, { size: r, color: a ? f : void 0 })
|
179
|
+
}
|
180
|
+
);
|
181
|
+
}
|
182
|
+
function U({ size: e = 15 }) {
|
183
|
+
return /* @__PURE__ */ i("svg", { width: e, height: e, className: "inline", viewBox: "0 0 15 15", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ i(
|
184
|
+
"path",
|
185
|
+
{
|
186
|
+
d: "M7.49991 0.877045C3.84222 0.877045 0.877075 3.84219 0.877075 7.49988C0.877075 11.1575 3.84222 14.1227 7.49991 14.1227C11.1576 14.1227 14.1227 11.1575 14.1227 7.49988C14.1227 3.84219 11.1576 0.877045 7.49991 0.877045ZM1.82708 7.49988C1.82708 4.36686 4.36689 1.82704 7.49991 1.82704C10.6329 1.82704 13.1727 4.36686 13.1727 7.49988C13.1727 10.6329 10.6329 13.1727 7.49991 13.1727C4.36689 13.1727 1.82708 10.6329 1.82708 7.49988ZM10.1589 5.53774C10.3178 5.31191 10.2636 5.00001 10.0378 4.84109C9.81194 4.68217 9.50004 4.73642 9.34112 4.96225L6.51977 8.97154L5.35681 7.78706C5.16334 7.59002 4.84677 7.58711 4.64973 7.78058C4.45268 7.97404 4.44978 8.29061 4.64325 8.48765L6.22658 10.1003C6.33054 10.2062 6.47617 10.2604 6.62407 10.2483C6.77197 10.2363 6.90686 10.1591 6.99226 10.0377L10.1589 5.53774Z",
|
187
|
+
fill: "currentColor",
|
188
|
+
fillRule: "evenodd",
|
189
|
+
clipRule: "evenodd"
|
190
|
+
}
|
191
|
+
) });
|
192
|
+
}
|
193
|
+
function Q({ size: e = 15 }) {
|
194
|
+
return /* @__PURE__ */ i("svg", { width: e, height: e, className: "inline", viewBox: "0 0 15 15", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ i(
|
195
|
+
"path",
|
196
|
+
{
|
197
|
+
d: "M8.4449 0.608765C8.0183 -0.107015 6.9817 -0.107015 6.55509 0.608766L0.161178 11.3368C-0.275824 12.07 0.252503 13 1.10608 13H13.8939C14.7475 13 15.2758 12.07 14.8388 11.3368L8.4449 0.608765ZM7.4141 1.12073C7.45288 1.05566 7.54712 1.05566 7.5859 1.12073L13.9798 11.8488C14.0196 11.9154 13.9715 12 13.8939 12H1.10608C1.02849 12 0.980454 11.9154 1.02018 11.8488L7.4141 1.12073ZM6.8269 4.48611C6.81221 4.10423 7.11783 3.78663 7.5 3.78663C7.88217 3.78663 8.18778 4.10423 8.1731 4.48612L8.01921 8.48701C8.00848 8.766 7.7792 8.98664 7.5 8.98664C7.2208 8.98664 6.99151 8.766 6.98078 8.48701L6.8269 4.48611ZM8.24989 10.476C8.24989 10.8902 7.9141 11.226 7.49989 11.226C7.08567 11.226 6.74989 10.8902 6.74989 10.476C6.74989 10.0618 7.08567 9.72599 7.49989 9.72599C7.9141 9.72599 8.24989 10.0618 8.24989 10.476Z",
|
198
|
+
fill: "currentColor",
|
199
|
+
fillRule: "evenodd",
|
200
|
+
clipRule: "evenodd"
|
201
|
+
}
|
202
|
+
) });
|
203
|
+
}
|
204
|
+
function W({ size: e = 15 }) {
|
205
|
+
return /* @__PURE__ */ i("svg", { width: e, height: e, className: "inline", viewBox: "0 0 15 15", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ i(
|
206
|
+
"path",
|
207
|
+
{
|
208
|
+
d: "M14.7649 6.07596C14.9991 6.22231 15.0703 6.53079 14.9239 6.76495C14.4849 7.46743 13.9632 8.10645 13.3702 8.66305L14.5712 9.86406C14.7664 10.0593 14.7664 10.3759 14.5712 10.5712C14.3759 10.7664 14.0593 10.7664 13.8641 10.5712L12.6011 9.30817C11.805 9.90283 10.9089 10.3621 9.93375 10.651L10.383 12.3277C10.4544 12.5944 10.2961 12.8685 10.0294 12.94C9.76267 13.0115 9.4885 12.8532 9.41704 12.5865L8.95917 10.8775C8.48743 10.958 8.00036 10.9999 7.50001 10.9999C6.99965 10.9999 6.51257 10.958 6.04082 10.8775L5.58299 12.5864C5.51153 12.8532 5.23737 13.0115 4.97064 12.94C4.7039 12.8686 4.5456 12.5944 4.61706 12.3277L5.06625 10.651C4.09111 10.3621 3.19503 9.90282 2.3989 9.30815L1.1359 10.5712C0.940638 10.7664 0.624058 10.7664 0.428798 10.5712C0.233537 10.3759 0.233537 10.0593 0.428798 9.86405L1.62982 8.66303C1.03682 8.10643 0.515113 7.46742 0.0760677 6.76495C-0.0702867 6.53079 0.000898544 6.22231 0.235065 6.07596C0.469231 5.9296 0.777703 6.00079 0.924058 6.23496C1.40354 7.00213 1.989 7.68057 2.66233 8.2427C2.67315 8.25096 2.6837 8.25972 2.69397 8.26898C4.00897 9.35527 5.65537 9.99991 7.50001 9.99991C10.3078 9.99991 12.6564 8.5063 14.076 6.23495C14.2223 6.00079 14.5308 5.9296 14.7649 6.07596Z",
|
209
|
+
fill: "currentColor",
|
210
|
+
fillRule: "evenodd",
|
211
|
+
clipRule: "evenodd"
|
212
|
+
}
|
213
|
+
) });
|
214
|
+
}
|
215
|
+
function _({ size: e = 15 }) {
|
216
|
+
return /* @__PURE__ */ i("svg", { width: e, height: e, className: "inline", viewBox: "0 0 15 15", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ i(
|
217
|
+
"path",
|
218
|
+
{
|
219
|
+
d: "M7.5 11C4.80285 11 2.52952 9.62184 1.09622 7.50001C2.52952 5.37816 4.80285 4 7.5 4C10.1971 4 12.4705 5.37816 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11ZM7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C1.65639 10.2936 4.30786 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C13.3436 4.70638 10.6921 3 7.5 3ZM7.5 9.5C8.60457 9.5 9.5 8.60457 9.5 7.5C9.5 6.39543 8.60457 5.5 7.5 5.5C6.39543 5.5 5.5 6.39543 5.5 7.5C5.5 8.60457 6.39543 9.5 7.5 9.5Z",
|
220
|
+
fill: "currentColor",
|
221
|
+
fillRule: "evenodd",
|
222
|
+
clipRule: "evenodd"
|
223
|
+
}
|
224
|
+
) });
|
225
|
+
}
|
226
|
+
function J({ size: e = 15, color: t = "currentColor" }) {
|
227
|
+
return /* @__PURE__ */ i("svg", { width: e, height: e, className: "inline", viewBox: "0 0 15 15", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ i(
|
228
|
+
"path",
|
229
|
+
{
|
230
|
+
d: "M0.877075 7.49972C0.877075 3.84204 3.84222 0.876892 7.49991 0.876892C11.1576 0.876892 14.1227 3.84204 14.1227 7.49972C14.1227 11.1574 11.1576 14.1226 7.49991 14.1226C3.84222 14.1226 0.877075 11.1574 0.877075 7.49972ZM7.49991 1.82689C4.36689 1.82689 1.82708 4.36671 1.82708 7.49972C1.82708 10.6327 4.36689 13.1726 7.49991 13.1726C10.6329 13.1726 13.1727 10.6327 13.1727 7.49972C13.1727 4.36671 10.6329 1.82689 7.49991 1.82689ZM8.24993 10.5C8.24993 10.9142 7.91414 11.25 7.49993 11.25C7.08571 11.25 6.74993 10.9142 6.74993 10.5C6.74993 10.0858 7.08571 9.75 7.49993 9.75C7.91414 9.75 8.24993 10.0858 8.24993 10.5ZM6.05003 6.25C6.05003 5.57211 6.63511 4.925 7.50003 4.925C8.36496 4.925 8.95003 5.57211 8.95003 6.25C8.95003 6.74118 8.68002 6.99212 8.21447 7.27494C8.16251 7.30651 8.10258 7.34131 8.03847 7.37854L8.03841 7.37858C7.85521 7.48497 7.63788 7.61119 7.47449 7.73849C7.23214 7.92732 6.95003 8.23198 6.95003 8.7C6.95004 9.00376 7.19628 9.25 7.50004 9.25C7.8024 9.25 8.04778 9.00601 8.05002 8.70417L8.05056 8.7033C8.05924 8.6896 8.08493 8.65735 8.15058 8.6062C8.25207 8.52712 8.36508 8.46163 8.51567 8.37436L8.51571 8.37433C8.59422 8.32883 8.68296 8.27741 8.78559 8.21506C9.32004 7.89038 10.05 7.35382 10.05 6.25C10.05 4.92789 8.93511 3.825 7.50003 3.825C6.06496 3.825 4.95003 4.92789 4.95003 6.25C4.95003 6.55376 5.19628 6.8 5.50003 6.8C5.80379 6.8 6.05003 6.55376 6.05003 6.25Z",
|
231
|
+
fill: t,
|
232
|
+
fillRule: "evenodd",
|
233
|
+
clipRule: "evenodd"
|
234
|
+
}
|
235
|
+
) });
|
236
|
+
}
|
237
|
+
const X = {
|
238
|
+
base: "",
|
239
|
+
default: "ring ring-transparent focus:ring-primary-foreground not-disabled:data-error:ring-danger not-disabled:data-success:ring-success",
|
240
|
+
underline: "border-b border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-danger not-disabled:data-success:border-success",
|
241
|
+
outline: "border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-danger not-disabled:data-success:border-success"
|
242
|
+
}, Y = {
|
243
|
+
none: "rounded-none",
|
244
|
+
sm: "rounded-sm",
|
245
|
+
md: "rounded-md",
|
246
|
+
lg: "rounded-lg",
|
247
|
+
full: "px-3 rounded-full"
|
248
|
+
}, I = {
|
249
|
+
variant: "default",
|
250
|
+
rounded: "none"
|
251
|
+
};
|
252
|
+
function $({ elementId: e, type: t, message: r }) {
|
253
|
+
return N(() => {
|
254
|
+
const n = document.getElementById(e);
|
255
|
+
if (n) {
|
256
|
+
if (!r && t === "error") {
|
257
|
+
n.removeAttribute("data-error");
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
if (!r && t === "success") {
|
261
|
+
n.removeAttribute("data-success");
|
262
|
+
return;
|
263
|
+
}
|
264
|
+
return n.setAttribute("aria-describedby", `${e}-${t}-message`), n.setAttribute("aria-invalid", t === "error" ? "true" : "false"), t === "error" && n.setAttribute("data-error", "true"), t === "success" && n.setAttribute("data-success", "true"), () => {
|
265
|
+
n.removeAttribute("aria-describedby"), n.removeAttribute("aria-invalid"), n.removeAttribute("data-error"), n.removeAttribute("data-success");
|
266
|
+
};
|
267
|
+
}
|
268
|
+
}, [e, t, r]), r ? /* @__PURE__ */ x(
|
269
|
+
"small",
|
270
|
+
{
|
271
|
+
className: C(
|
272
|
+
"mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-start",
|
273
|
+
t === "error" && "text-danger",
|
274
|
+
t === "success" && "text-success"
|
275
|
+
),
|
276
|
+
role: "status",
|
277
|
+
children: [
|
278
|
+
t === "error" ? /* @__PURE__ */ i(Q, {}) : /* @__PURE__ */ i(U, {}),
|
279
|
+
/* @__PURE__ */ i("span", { id: `${e}-${t}-message`, children: r })
|
280
|
+
]
|
281
|
+
}
|
282
|
+
) : null;
|
283
|
+
}
|
284
|
+
function ie({
|
285
|
+
variant: e = I.variant,
|
286
|
+
rounded: t,
|
287
|
+
displayOnlyMode: r = !1,
|
288
|
+
errorMessage: n,
|
289
|
+
successMessage: a,
|
290
|
+
type: o = "text",
|
291
|
+
className: d,
|
292
|
+
...l
|
293
|
+
}) {
|
294
|
+
const u = A(), [b, m] = L(!1);
|
295
|
+
let s = t;
|
296
|
+
e === "outline" && !t && (s = "md"), s = s || I.rounded;
|
297
|
+
const c = C(
|
298
|
+
"appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all",
|
299
|
+
"file:mr-2 file:border-0 file:rounded-md file:px-1.5 file:py-1 file:bg-primary hover:file:bg-primary/85 file:text-sm file:font-medium file:text-foreground file:transition-colors",
|
300
|
+
!r && X[e],
|
301
|
+
!r && Y[s],
|
302
|
+
o === "password" && "pr-10",
|
303
|
+
!r && "px-2 py-1",
|
304
|
+
r && "pointer-events-none",
|
305
|
+
d
|
306
|
+
);
|
307
|
+
return /* @__PURE__ */ x("div", { className: C(r && "cursor-text"), style: { height: l.height, width: l.width }, children: [
|
308
|
+
/* @__PURE__ */ x("div", { className: C(o === "password" && "relative"), children: [
|
309
|
+
/* @__PURE__ */ i(
|
310
|
+
"input",
|
311
|
+
{
|
312
|
+
...l,
|
313
|
+
id: u,
|
314
|
+
type: o === "password" && b ? "text" : o,
|
315
|
+
"aria-disabled": l.disabled,
|
316
|
+
readOnly: r,
|
317
|
+
"aria-readonly": r || l["aria-readonly"],
|
318
|
+
"data-error": n ? !0 : void 0,
|
319
|
+
"data-success": a ? !0 : void 0,
|
320
|
+
className: c
|
321
|
+
}
|
322
|
+
),
|
323
|
+
o === "password" && /* @__PURE__ */ i(
|
324
|
+
"button",
|
325
|
+
{
|
326
|
+
onClick: () => m(!b),
|
327
|
+
className: "absolute inset-y-0 right-0 px-2 hover:cursor-pointer",
|
328
|
+
"aria-label": "Toggle password visibility",
|
329
|
+
"data-state": b ? "visible" : "hidden",
|
330
|
+
children: b ? /* @__PURE__ */ i(_, { size: 20 }) : /* @__PURE__ */ i(W, { size: 20 })
|
331
|
+
}
|
332
|
+
)
|
333
|
+
] }),
|
334
|
+
!r && /* @__PURE__ */ i($, { elementId: u, type: "error", message: n }),
|
335
|
+
!r && /* @__PURE__ */ i($, { elementId: u, type: "success", message: a })
|
336
|
+
] });
|
337
|
+
}
|
338
|
+
function de({
|
339
|
+
display: e = "inline",
|
340
|
+
width: t = "fit-content",
|
341
|
+
className: r = "",
|
342
|
+
required: n,
|
343
|
+
helpMessage: a,
|
344
|
+
suffix: o,
|
345
|
+
htmlFor: d,
|
346
|
+
children: l,
|
347
|
+
...u
|
348
|
+
}) {
|
349
|
+
const b = A(), m = C("font-medium", e, r), s = a ? `${d ?? b}-help` : void 0;
|
350
|
+
return /* @__PURE__ */ x("div", { style: { display: e === "inline" ? "inline-flex" : "flex", width: t }, className: "relative", children: [
|
351
|
+
/* @__PURE__ */ x("label", { className: m, htmlFor: d, ...u, children: [
|
352
|
+
l,
|
353
|
+
n && /* @__PURE__ */ i("span", { className: "text-red-500 font-medium ml-1", "aria-label": "required", children: "*" })
|
354
|
+
] }),
|
355
|
+
a && /* @__PURE__ */ i(
|
356
|
+
"span",
|
357
|
+
{
|
358
|
+
className: "text-gray-500 ml-1 size-fit -translate-y-1/3",
|
359
|
+
"aria-describedby": s,
|
360
|
+
"aria-label": "Help information",
|
361
|
+
title: a,
|
362
|
+
children: /* @__PURE__ */ i(J, {})
|
363
|
+
}
|
364
|
+
),
|
365
|
+
a && /* @__PURE__ */ i("div", { id: s, className: "sr-only", children: a }),
|
366
|
+
o && /* @__PURE__ */ i("span", { className: "ml-1", children: o })
|
367
|
+
] });
|
368
|
+
}
|
369
|
+
function M({ itemId: e, checked: t, onChange: r, name: n, disabled: a = !1, className: o = "" }) {
|
370
|
+
const d = "relative inline-flex items-center justify-center rounded-full", l = () => {
|
371
|
+
a || r();
|
372
|
+
}, u = C(
|
373
|
+
d,
|
374
|
+
!t && "hover:border-current/60",
|
375
|
+
!a && "border-current cursor-pointer",
|
376
|
+
a && "border-muted/60 cursor-not-allowed",
|
377
|
+
o
|
378
|
+
);
|
379
|
+
return /* @__PURE__ */ i(
|
380
|
+
"div",
|
381
|
+
{
|
382
|
+
id: e,
|
383
|
+
role: "radio",
|
384
|
+
tabIndex: -1,
|
385
|
+
"aria-checked": t,
|
386
|
+
"aria-disabled": a,
|
387
|
+
"aria-description": `Radio button for ${n}`,
|
388
|
+
"aria-labelledby": `${e}-label`,
|
389
|
+
onClick: l,
|
390
|
+
className: u,
|
391
|
+
style: {
|
392
|
+
width: "1em",
|
393
|
+
height: "1em",
|
394
|
+
padding: "0.1em",
|
395
|
+
borderWidth: "0.06em"
|
396
|
+
},
|
397
|
+
children: t && /* @__PURE__ */ i(
|
398
|
+
"div",
|
399
|
+
{
|
400
|
+
className: C("size-full aspect-square rounded-full", a && "bg-muted/60", !a && "bg-current")
|
401
|
+
}
|
402
|
+
)
|
403
|
+
}
|
404
|
+
);
|
405
|
+
}
|
406
|
+
function D({
|
407
|
+
value: e,
|
408
|
+
children: t,
|
409
|
+
className: r = "",
|
410
|
+
isSelected: n = !1,
|
411
|
+
onChange: a,
|
412
|
+
disabled: o = !1,
|
413
|
+
hideInput: d = !1,
|
414
|
+
description: l,
|
415
|
+
name: u
|
416
|
+
}) {
|
417
|
+
const m = `radio-${A()}-${e}`, s = () => {
|
418
|
+
o || a == null || a(e);
|
419
|
+
};
|
420
|
+
return /* @__PURE__ */ x(
|
421
|
+
"div",
|
422
|
+
{
|
423
|
+
title: l,
|
424
|
+
className: C(
|
425
|
+
"relative flex items-center",
|
426
|
+
r,
|
427
|
+
// Uses text color for borders
|
428
|
+
d && `p-2 border-2 focus-within:border-dashed focus-within:${o ? "border-current/50" : "border-current/80"}`,
|
429
|
+
d && !n && `border-transparent ${o ? "" : "not-focus-within:hover:border-border/60"}`,
|
430
|
+
d && n && "border-border",
|
431
|
+
o && "opacity-60 cursor-not-allowed"
|
432
|
+
),
|
433
|
+
style: {
|
434
|
+
gap: "0.5em"
|
435
|
+
},
|
436
|
+
children: [
|
437
|
+
!d && /* @__PURE__ */ i(
|
438
|
+
M,
|
439
|
+
{
|
440
|
+
itemId: m,
|
441
|
+
name: u || "",
|
442
|
+
checked: n,
|
443
|
+
onChange: s,
|
444
|
+
disabled: o,
|
445
|
+
className: C(d && "")
|
446
|
+
}
|
447
|
+
),
|
448
|
+
/* @__PURE__ */ i(
|
449
|
+
"div",
|
450
|
+
{
|
451
|
+
id: d ? m : void 0,
|
452
|
+
tabIndex: d ? -1 : void 0,
|
453
|
+
role: d ? "radio" : void 0,
|
454
|
+
onClick: d ? s : void 0,
|
455
|
+
"aria-checked": d ? n ? "true" : "false" : void 0,
|
456
|
+
"aria-disabled": d ? o : void 0,
|
457
|
+
"aria-description": d ? l || `Radio button for ${u}` : void 0,
|
458
|
+
"aria-labelledby": d ? `${m}-label` : void 0,
|
459
|
+
className: C(d && "size-full", typeof t == "object" && "grow focus:outline-none"),
|
460
|
+
children: /* @__PURE__ */ i(
|
461
|
+
"label",
|
462
|
+
{
|
463
|
+
id: `${m}-label`,
|
464
|
+
onClick: d ? void 0 : s,
|
465
|
+
className: C(o && "cursor-not-allowed", !o && "cursor-pointer"),
|
466
|
+
children: t
|
467
|
+
}
|
468
|
+
)
|
469
|
+
}
|
470
|
+
)
|
471
|
+
]
|
472
|
+
}
|
473
|
+
);
|
474
|
+
}
|
475
|
+
function O(e, t) {
|
476
|
+
const [r, n] = L(t), [a, o] = L(-1), [d, l] = L(!1), u = E((f, c) => {
|
477
|
+
var h;
|
478
|
+
const g = f[c];
|
479
|
+
g.hasAttribute("disabled") || g.getAttribute("aria-disabled") === "true" || ((h = f[c]) == null || h.click(), o(c));
|
480
|
+
}, []), b = E(
|
481
|
+
(f, c) => {
|
482
|
+
var w;
|
483
|
+
if (f.preventDefault(), d || !c.length) return;
|
484
|
+
const g = t !== -1 ? t : 0;
|
485
|
+
(w = c[g]) == null || w.focus(), n(g), t !== -1 && u(c, g);
|
486
|
+
},
|
487
|
+
[t, d, u]
|
488
|
+
), m = E(
|
489
|
+
(f) => {
|
490
|
+
var h;
|
491
|
+
if (!f.shiftKey)
|
492
|
+
return;
|
493
|
+
f.preventDefault();
|
494
|
+
const c = Array.from(
|
495
|
+
document.querySelectorAll(
|
496
|
+
'a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
|
497
|
+
)
|
498
|
+
).filter((p) => !p.hasAttribute("disabled") && p.tabIndex >= 0), g = c.findIndex((p) => p.id === e), w = g > 0 ? g - 1 : c.length - 1;
|
499
|
+
(h = c[w]) == null || h.focus();
|
500
|
+
},
|
501
|
+
[e]
|
502
|
+
), s = E(
|
503
|
+
(f, c) => {
|
504
|
+
var y;
|
505
|
+
if (!c.length) return;
|
506
|
+
const g = f.target;
|
507
|
+
if (!c.some((k) => k.id === g.id)) return;
|
508
|
+
const h = r !== -1 ? r : 0;
|
509
|
+
let p = h;
|
510
|
+
switch (f.key) {
|
511
|
+
case "ArrowUp":
|
512
|
+
case "ArrowLeft":
|
513
|
+
f.preventDefault(), p = h > 0 ? h - 1 : c.length - 1;
|
514
|
+
break;
|
515
|
+
case "ArrowDown":
|
516
|
+
case "ArrowRight":
|
517
|
+
f.preventDefault(), p = (h + 1) % c.length;
|
518
|
+
break;
|
519
|
+
// Select the option when the space key is pressed
|
520
|
+
case " ":
|
521
|
+
f.preventDefault(), u(c, h);
|
522
|
+
return;
|
523
|
+
case "Tab":
|
524
|
+
m(f);
|
525
|
+
return;
|
526
|
+
default:
|
527
|
+
return;
|
528
|
+
}
|
529
|
+
(y = c[p]) == null || y.focus(), n(p), a !== -1 && u(c, p);
|
530
|
+
},
|
531
|
+
[r, a, m, u]
|
532
|
+
), v = E(() => {
|
533
|
+
const f = document.querySelector(`[id="${e}"][role="radiogroup"]`);
|
534
|
+
return f ? Array.from(f.querySelectorAll('[role="radio"]')) : [];
|
535
|
+
}, [e]);
|
536
|
+
N(() => {
|
537
|
+
const f = document.querySelector(`[id="${e}"][role="radiogroup"]`);
|
538
|
+
if (!f) return;
|
539
|
+
const c = v(), g = (y) => b(y, c), w = (y) => s(y, c), h = () => l(!0), p = () => l(!1);
|
540
|
+
return document.addEventListener("keydown", w), f.addEventListener("focus", g), f.addEventListener("mousedown", h), document.addEventListener("mouseup", p), () => {
|
541
|
+
document.removeEventListener("keydown", w), f.removeEventListener("focus", g), f.removeEventListener("mousedown", h), document.removeEventListener("mouseup", p);
|
542
|
+
};
|
543
|
+
}, [e, v, b, s]);
|
544
|
+
}
|
545
|
+
function le({
|
546
|
+
options: e = [],
|
547
|
+
value: t,
|
548
|
+
onChange: r,
|
549
|
+
name: n,
|
550
|
+
children: a,
|
551
|
+
className: o = "",
|
552
|
+
childrenClassName: d = "",
|
553
|
+
hideInputs: l = !1
|
554
|
+
}) {
|
555
|
+
const u = A(), b = n || `radio-group-${u}`;
|
556
|
+
O(
|
557
|
+
b,
|
558
|
+
e.findIndex((s) => s === t)
|
559
|
+
);
|
560
|
+
const m = j(() => e.reduce((s, v) => (typeof v == "string" ? s.some((f) => f.value === v) || s.push({ label: v, value: v }) : s.push(v), s), []), [e]);
|
561
|
+
return /* @__PURE__ */ x("div", { id: b, role: "radiogroup", tabIndex: 0, className: C(o, "focus:outline-none"), children: [
|
562
|
+
m.length > 0 && m.map((s, v) => /* @__PURE__ */ i(
|
563
|
+
D,
|
564
|
+
{
|
565
|
+
value: s.value,
|
566
|
+
isSelected: t === s.value,
|
567
|
+
onChange: r,
|
568
|
+
name: b,
|
569
|
+
disabled: s.disabled,
|
570
|
+
description: s.description,
|
571
|
+
hideInput: l,
|
572
|
+
className: d,
|
573
|
+
children: s.label
|
574
|
+
},
|
575
|
+
`${s.value}-${v}`
|
576
|
+
)),
|
577
|
+
m.length === 0 && a && B.Children.map(a, (s) => B.isValidElement(s) && s.type === D ? /* @__PURE__ */ i(
|
578
|
+
D,
|
579
|
+
{
|
580
|
+
...s.props,
|
581
|
+
className: C(d, s.props.className),
|
582
|
+
hideInput: s.props.hideInput || l,
|
583
|
+
isSelected: t === s.props.value,
|
584
|
+
onChange: r,
|
585
|
+
name: b,
|
586
|
+
children: s.props.children
|
587
|
+
}
|
588
|
+
) : null)
|
589
|
+
] });
|
590
|
+
}
|
591
|
+
function P(e, t) {
|
592
|
+
N(() => {
|
593
|
+
const r = document.getElementById(e);
|
594
|
+
if (!r)
|
595
|
+
return;
|
596
|
+
if (!t) {
|
597
|
+
r.style.height = "auto";
|
598
|
+
return;
|
599
|
+
}
|
600
|
+
const n = () => {
|
601
|
+
r.style.height = "auto", r.style.height = `${r.scrollHeight}px`;
|
602
|
+
};
|
603
|
+
return n(), r.addEventListener("input", n), r.addEventListener("resize", n), window.addEventListener("resize", n), () => {
|
604
|
+
r.removeEventListener("input", n), r.removeEventListener("resize", n), window.removeEventListener("resize", n);
|
605
|
+
};
|
606
|
+
}, [e, t]);
|
607
|
+
}
|
608
|
+
const ee = {
|
609
|
+
base: "",
|
610
|
+
"left-line": "border-l border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-danger not-disabled:data-success:border-success",
|
611
|
+
outline: "border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-danger not-disabled:data-success:border-success"
|
612
|
+
}, re = {
|
613
|
+
none: "rounded-none",
|
614
|
+
sm: "rounded-sm",
|
615
|
+
md: "rounded-md",
|
616
|
+
lg: "rounded-lg",
|
617
|
+
full: "px-3 rounded-full"
|
618
|
+
}, Z = {
|
619
|
+
variant: "outline",
|
620
|
+
rounded: "none"
|
621
|
+
};
|
622
|
+
function te({ elementId: e, maxLength: t }) {
|
623
|
+
const [r, n] = L(0);
|
624
|
+
return N(() => {
|
625
|
+
const a = document.getElementById(e);
|
626
|
+
if (!a)
|
627
|
+
return;
|
628
|
+
const o = () => {
|
629
|
+
const d = a.value.length;
|
630
|
+
n(d);
|
631
|
+
const l = d >= t;
|
632
|
+
a.setAttribute("aria-describedby", `${e}-character-count`), a.setAttribute("aria-invalid", l ? "true" : "false"), l ? a.setAttribute("data-error", "true") : a.removeAttribute("data-error");
|
633
|
+
};
|
634
|
+
return o(), a.addEventListener("input", o), a.setAttribute("maxlength", String(t)), () => {
|
635
|
+
a.removeEventListener("input", o), a.removeAttribute("maxlength"), a.removeAttribute("aria-describedby"), a.removeAttribute("aria-invalid"), a.removeAttribute("data-error");
|
636
|
+
};
|
637
|
+
}, [e, t]), /* @__PURE__ */ i(
|
638
|
+
"small",
|
639
|
+
{
|
640
|
+
className: C(
|
641
|
+
"mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-end",
|
642
|
+
r >= t && "text-danger",
|
643
|
+
r < t && "text-current"
|
644
|
+
),
|
645
|
+
role: "status",
|
646
|
+
children: /* @__PURE__ */ x("span", { id: `${e}-character-count`, children: [
|
647
|
+
r,
|
648
|
+
" / ",
|
649
|
+
t,
|
650
|
+
" characters"
|
651
|
+
] })
|
652
|
+
}
|
653
|
+
);
|
654
|
+
}
|
655
|
+
function ue({
|
656
|
+
variant: e = Z.variant,
|
657
|
+
rounded: t,
|
658
|
+
displayOnlyMode: r = !1,
|
659
|
+
errorMessage: n,
|
660
|
+
successMessage: a,
|
661
|
+
hideResizeHandle: o = !1,
|
662
|
+
autoExpand: d = !1,
|
663
|
+
characterLimit: l = 0,
|
664
|
+
className: u,
|
665
|
+
...b
|
666
|
+
}) {
|
667
|
+
const m = A();
|
668
|
+
P(m, d || r);
|
669
|
+
let s = t;
|
670
|
+
e === "outline" && !t && (s = "md"), s = s || Z.rounded;
|
671
|
+
let v = o;
|
672
|
+
(r || e === "left-line" && !o) && (v = !0);
|
673
|
+
const c = C(
|
674
|
+
"appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all",
|
675
|
+
!r && ee[e],
|
676
|
+
!r && re[s],
|
677
|
+
!r && "px-2 py-1",
|
678
|
+
r && "pointer-events-none",
|
679
|
+
v && "no-resize-handle",
|
680
|
+
u
|
681
|
+
);
|
682
|
+
return /* @__PURE__ */ x("div", { className: C("-space-y-1.5", r && "cursor-text"), children: [
|
683
|
+
/* @__PURE__ */ i(
|
684
|
+
"textarea",
|
685
|
+
{
|
686
|
+
...b,
|
687
|
+
id: m,
|
688
|
+
"aria-disabled": b.disabled,
|
689
|
+
readOnly: r,
|
690
|
+
"aria-readonly": r || b["aria-readonly"],
|
691
|
+
style: {
|
692
|
+
resize: d ? "none" : void 0
|
693
|
+
},
|
694
|
+
className: c
|
695
|
+
}
|
696
|
+
),
|
697
|
+
l > 0 && /* @__PURE__ */ i(te, { elementId: m, maxLength: l }),
|
698
|
+
!r && /* @__PURE__ */ i($, { elementId: m, type: "error", message: n }),
|
699
|
+
!r && /* @__PURE__ */ i($, { elementId: m, type: "success", message: a })
|
700
|
+
] });
|
701
|
+
}
|
702
|
+
function ce({ children: e, ref: t, ...r }) {
|
703
|
+
if (S(e)) {
|
704
|
+
let n = { ...r };
|
705
|
+
return e.props && (n = { ...n, ...e.props }), V(e, {
|
706
|
+
...n,
|
707
|
+
ref: (a) => {
|
708
|
+
typeof t == "function" ? t(a) : t && (t.current = a);
|
709
|
+
}
|
710
|
+
});
|
711
|
+
}
|
712
|
+
return z("div", { ...r, ref: t }, e);
|
713
|
+
}
|
714
|
+
export {
|
715
|
+
oe as Button,
|
716
|
+
F as ButtonLoadingDots,
|
717
|
+
U as CheckCircled,
|
718
|
+
se as Checkbox,
|
719
|
+
Q as ExclamationTriangle,
|
720
|
+
W as EyeClosed,
|
721
|
+
_ as EyeOpened,
|
722
|
+
ie as Input,
|
723
|
+
de as Label,
|
724
|
+
J as QuestionMarkCircled,
|
725
|
+
le as RadioGroup,
|
726
|
+
D as RadioGroupItem,
|
727
|
+
M as RadioInput,
|
728
|
+
ce as Slot,
|
729
|
+
ue as Textarea,
|
730
|
+
C as join
|
731
|
+
};
|
732
|
+
//# sourceMappingURL=index.esm.js.map
|