@adamosuiteservices/ui 2.14.2 → 2.15.1
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/combobox-DGuQtXjP.js +608 -0
- package/dist/combobox-hTCtPMUL.cjs +40 -0
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/components/ui/combobox/combobox.d.ts +5 -1
- package/dist/components/ui/date-picker-selector/date-picker-selector.d.ts +5 -1
- package/dist/components/ui/file-upload/file-upload.d.ts +4 -1
- package/dist/components/ui/slider/slider.d.ts +1 -1
- package/dist/components/ui/switch/switch.d.ts +1 -1
- package/dist/date-picker-selector.cjs +1 -1
- package/dist/date-picker-selector.js +38 -28
- package/dist/field.cjs +2 -2
- package/dist/field.js +2 -2
- package/dist/file-upload.cjs +5 -3
- package/dist/file-upload.js +191 -150
- package/dist/slider.cjs +5 -5
- package/dist/slider.js +196 -177
- package/dist/styles.css +1 -1
- package/dist/switch.cjs +3 -3
- package/dist/switch.js +105 -85
- package/docs/components/ui/accordion-rounded.md +2 -6
- package/docs/components/ui/avatar.md +3 -1
- package/docs/components/ui/button.md +22 -16
- package/docs/components/ui/card.md +49 -31
- package/docs/components/ui/checkbox.md +44 -8
- package/docs/components/ui/combobox.md +62 -4
- package/docs/components/ui/date-picker-selector.md +90 -26
- package/docs/components/ui/file-upload.md +364 -95
- package/docs/components/ui/icon.md +1 -1
- package/docs/components/ui/input.md +4 -1
- package/docs/components/ui/radio-group.md +1 -1
- package/docs/components/ui/select.md +51 -34
- package/docs/components/ui/sheet.md +3 -9
- package/docs/components/ui/slider.md +120 -99
- package/docs/components/ui/switch.md +408 -408
- package/docs/components/ui/textarea.md +37 -22
- package/docs/components/ui/tooltip.md +5 -2
- package/docs/components/ui/typography.md +63 -39
- package/package.json +1 -1
- package/dist/combobox-CCJGIMFQ.cjs +0 -40
- package/dist/combobox-Cj-GEp-T.js +0 -604
package/dist/file-upload.js
CHANGED
|
@@ -1,110 +1,120 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-BzflLqGi.js";
|
|
2
|
-
import { B as
|
|
3
|
-
import { I as
|
|
4
|
-
import { T as
|
|
5
|
-
import { c as
|
|
6
|
-
import { useState as
|
|
7
|
-
function
|
|
8
|
-
isDragging:
|
|
9
|
-
isMultiple:
|
|
10
|
-
invalid:
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import { B as O } from "./button-B0lWuG-D.js";
|
|
3
|
+
import { I as L } from "./icon-DKAhvlX_.js";
|
|
4
|
+
import { T as y } from "./typography-MnY0LQoZ.js";
|
|
5
|
+
import { c as v } from "./index-CRiPKpXj.js";
|
|
6
|
+
import { useState as B, useRef as W, useEffect as X } from "react";
|
|
7
|
+
function Y({
|
|
8
|
+
isDragging: n,
|
|
9
|
+
isMultiple: d,
|
|
10
|
+
invalid: a,
|
|
11
|
+
disabled: r,
|
|
12
|
+
accept: m,
|
|
13
|
+
acceptedExtensions: l,
|
|
13
14
|
maxSizeInMB: c,
|
|
14
|
-
maxFiles:
|
|
15
|
-
labels:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
maxFiles: x,
|
|
16
|
+
labels: f,
|
|
17
|
+
input: b,
|
|
18
|
+
onDragOver: D,
|
|
19
|
+
onDragLeave: w,
|
|
20
|
+
onDrop: C,
|
|
21
|
+
onFileChange: A
|
|
20
22
|
}) {
|
|
23
|
+
const p = b?.id || `file-upload-${Math.random().toString(36).substring(2, 11)}`;
|
|
21
24
|
return /* @__PURE__ */ e.jsxs(
|
|
22
25
|
"div",
|
|
23
26
|
{
|
|
24
|
-
onDragOver:
|
|
25
|
-
onDragLeave:
|
|
26
|
-
onDrop:
|
|
27
|
-
className:
|
|
27
|
+
onDragOver: r ? void 0 : D,
|
|
28
|
+
onDragLeave: r ? void 0 : w,
|
|
29
|
+
onDrop: r ? void 0 : C,
|
|
30
|
+
className: v(
|
|
28
31
|
`
|
|
29
32
|
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
30
33
|
adm:border-2
|
|
31
34
|
`,
|
|
32
35
|
"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",
|
|
33
36
|
{
|
|
34
|
-
"adm:border-primary":
|
|
35
|
-
"adm:border-destructive": r,
|
|
36
|
-
"adm:border-input": !
|
|
37
|
+
"adm:border-primary": n && !a && !r,
|
|
38
|
+
"adm:border-destructive": a && !r,
|
|
39
|
+
"adm:border-input": !n && !a,
|
|
40
|
+
"adm:cursor-not-allowed adm:opacity-50": r
|
|
37
41
|
}
|
|
38
42
|
),
|
|
39
43
|
children: [
|
|
40
44
|
/* @__PURE__ */ e.jsx(
|
|
41
45
|
"div",
|
|
42
46
|
{
|
|
43
|
-
className:
|
|
47
|
+
className: v(
|
|
44
48
|
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
45
|
-
r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
49
|
+
a && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
46
50
|
),
|
|
47
51
|
children: /* @__PURE__ */ e.jsx(
|
|
48
|
-
|
|
52
|
+
L,
|
|
49
53
|
{
|
|
50
54
|
symbol: "text_snippet",
|
|
51
|
-
className: r ? "adm:text-destructive" : "adm:text-primary"
|
|
55
|
+
className: a && !r ? "adm:text-destructive" : "adm:text-primary"
|
|
52
56
|
}
|
|
53
57
|
)
|
|
54
58
|
}
|
|
55
59
|
),
|
|
56
60
|
/* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
|
|
57
|
-
/* @__PURE__ */ e.jsx(
|
|
58
|
-
/* @__PURE__ */ e.jsxs("label", { htmlFor:
|
|
61
|
+
/* @__PURE__ */ e.jsx(y, { color: a && !r ? "destructive" : void 0, children: f?.dragDrop || (d ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
|
|
62
|
+
/* @__PURE__ */ e.jsxs("label", { htmlFor: p, children: [
|
|
59
63
|
/* @__PURE__ */ e.jsx(
|
|
60
64
|
"input",
|
|
61
65
|
{
|
|
62
|
-
|
|
66
|
+
...b,
|
|
67
|
+
id: p,
|
|
63
68
|
type: "file",
|
|
64
|
-
accept:
|
|
65
|
-
multiple:
|
|
66
|
-
onChange:
|
|
69
|
+
accept: m,
|
|
70
|
+
multiple: d,
|
|
71
|
+
onChange: A,
|
|
72
|
+
disabled: r,
|
|
67
73
|
className: "adm:hidden"
|
|
68
74
|
}
|
|
69
75
|
),
|
|
70
76
|
/* @__PURE__ */ e.jsx(
|
|
71
|
-
|
|
77
|
+
O,
|
|
72
78
|
{
|
|
73
79
|
asChild: !0,
|
|
74
80
|
type: "button",
|
|
75
81
|
variant: "link",
|
|
76
|
-
className: "adm:cursor-pointer",
|
|
77
|
-
|
|
82
|
+
className: v("adm:cursor-pointer", r && `
|
|
83
|
+
adm:pointer-events-none
|
|
84
|
+
`),
|
|
85
|
+
disabled: r,
|
|
86
|
+
children: /* @__PURE__ */ e.jsx("span", { children: f?.selectFile || (d ? "Select files" : "Select the file") })
|
|
78
87
|
}
|
|
79
88
|
)
|
|
80
89
|
] })
|
|
81
90
|
] }),
|
|
82
|
-
/* @__PURE__ */ e.jsx(
|
|
91
|
+
/* @__PURE__ */ e.jsx(y, { className: "adm:text-center", color: a && !r ? "destructive" : "muted", children: f?.fileRequirements || (l && l.length > 0 ? `Allowed files: ${l.join(", ")}. Maximum size ${c} MB${d ? `. Up to ${x} files` : ""}.` : `Maximum size ${c} MB${d ? `. Up to ${x} files` : ""}.`) })
|
|
83
92
|
]
|
|
84
93
|
}
|
|
85
94
|
);
|
|
86
95
|
}
|
|
87
|
-
function
|
|
96
|
+
function Z({ file: n, invalid: d, disabled: a, onRemove: r }) {
|
|
88
97
|
return /* @__PURE__ */ e.jsxs(
|
|
89
98
|
"div",
|
|
90
99
|
{
|
|
91
|
-
className:
|
|
100
|
+
className: v(
|
|
92
101
|
"adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",
|
|
93
|
-
|
|
102
|
+
d && !a ? "adm:border-destructive adm:bg-destructive/5" : "adm:border-input adm:bg-muted",
|
|
103
|
+
a && "adm:cursor-not-allowed adm:opacity-50"
|
|
94
104
|
),
|
|
95
105
|
children: [
|
|
96
106
|
/* @__PURE__ */ e.jsx(
|
|
97
107
|
"div",
|
|
98
108
|
{
|
|
99
|
-
className:
|
|
109
|
+
className: v(
|
|
100
110
|
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
101
|
-
|
|
111
|
+
d && !a ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
102
112
|
),
|
|
103
113
|
children: /* @__PURE__ */ e.jsx(
|
|
104
|
-
|
|
114
|
+
L,
|
|
105
115
|
{
|
|
106
116
|
symbol: "text_snippet",
|
|
107
|
-
className:
|
|
117
|
+
className: d && !a ? "adm:text-destructive" : "adm:text-primary"
|
|
108
118
|
}
|
|
109
119
|
)
|
|
110
120
|
}
|
|
@@ -116,161 +126,192 @@ function q({ file: s, invalid: t, onRemove: r }) {
|
|
|
116
126
|
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
117
127
|
`,
|
|
118
128
|
children: [
|
|
119
|
-
/* @__PURE__ */ e.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ e.jsx(
|
|
120
|
-
/* @__PURE__ */ e.jsxs(
|
|
121
|
-
(
|
|
129
|
+
/* @__PURE__ */ e.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ e.jsx(y, { className: "adm:truncate adm:font-semibold", children: n.name }) }),
|
|
130
|
+
/* @__PURE__ */ e.jsxs(y, { className: "adm:shrink-0", color: "muted", children: [
|
|
131
|
+
(n.size / 1024 / 1024).toFixed(1),
|
|
122
132
|
" MB"
|
|
123
133
|
] })
|
|
124
134
|
]
|
|
125
135
|
}
|
|
126
136
|
),
|
|
127
137
|
/* @__PURE__ */ e.jsx(
|
|
128
|
-
|
|
138
|
+
O,
|
|
129
139
|
{
|
|
130
140
|
variant: "destructive-medium",
|
|
131
141
|
onClick: r,
|
|
132
142
|
type: "button",
|
|
133
|
-
|
|
143
|
+
disabled: a,
|
|
144
|
+
children: /* @__PURE__ */ e.jsx(L, { symbol: "delete", className: "adm:text-destructive" })
|
|
134
145
|
}
|
|
135
146
|
)
|
|
136
147
|
]
|
|
137
148
|
}
|
|
138
149
|
);
|
|
139
150
|
}
|
|
140
|
-
function
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
/* @__PURE__ */ e.jsx(
|
|
151
|
+
function I({ files: n, isMultiple: d, invalid: a, disabled: r, labels: m, onRemoveFile: l, onClearAll: c }) {
|
|
152
|
+
return n.length === 0 ? null : /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
|
|
153
|
+
d && n.length > 1 && /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
|
|
154
|
+
/* @__PURE__ */ e.jsx(y, { className: "adm:text-sm adm:font-medium", color: a && !r ? "destructive" : void 0, children: m?.filesSelected?.(n.length) || `${n.length} file${n.length !== 1 ? "s" : ""} selected` }),
|
|
144
155
|
/* @__PURE__ */ e.jsx(
|
|
145
|
-
|
|
156
|
+
O,
|
|
146
157
|
{
|
|
147
158
|
variant: "ghost",
|
|
148
159
|
size: "sm",
|
|
149
160
|
onClick: c,
|
|
150
161
|
type: "button",
|
|
162
|
+
disabled: r,
|
|
151
163
|
children: "Clear all"
|
|
152
164
|
}
|
|
153
165
|
)
|
|
154
166
|
] }),
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
n.map((x, f) => /* @__PURE__ */ e.jsx(
|
|
168
|
+
Z,
|
|
157
169
|
{
|
|
158
|
-
file:
|
|
159
|
-
invalid:
|
|
160
|
-
|
|
170
|
+
file: x,
|
|
171
|
+
invalid: a,
|
|
172
|
+
disabled: r,
|
|
173
|
+
onRemove: () => l(f)
|
|
161
174
|
},
|
|
162
|
-
`${
|
|
175
|
+
`${x.name}-${f}`
|
|
163
176
|
))
|
|
164
177
|
] });
|
|
165
178
|
}
|
|
166
|
-
function
|
|
167
|
-
className:
|
|
168
|
-
selectedFile:
|
|
169
|
-
selectedFiles:
|
|
170
|
-
onFileSelect:
|
|
171
|
-
onFilesSelect:
|
|
172
|
-
onInvalidFile:
|
|
173
|
-
acceptedExtensions:
|
|
174
|
-
maxSizeInMB:
|
|
175
|
-
maxFiles:
|
|
176
|
-
multiple:
|
|
177
|
-
filesPosition:
|
|
178
|
-
invalid:
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
function ae({
|
|
180
|
+
className: n,
|
|
181
|
+
selectedFile: d,
|
|
182
|
+
selectedFiles: a,
|
|
183
|
+
onFileSelect: r,
|
|
184
|
+
onFilesSelect: m,
|
|
185
|
+
onInvalidFile: l,
|
|
186
|
+
acceptedExtensions: c,
|
|
187
|
+
maxSizeInMB: x = 50,
|
|
188
|
+
maxFiles: f = 10,
|
|
189
|
+
multiple: b = !1,
|
|
190
|
+
filesPosition: D = "below",
|
|
191
|
+
invalid: w = !1,
|
|
192
|
+
disabled: C = !1,
|
|
193
|
+
"aria-invalid": A,
|
|
194
|
+
labels: p,
|
|
195
|
+
input: T,
|
|
196
|
+
...U
|
|
181
197
|
}) {
|
|
182
|
-
const [
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const i = Array.from(a.dataTransfer.files).filter(y);
|
|
189
|
-
if (i.length > 0) {
|
|
190
|
-
const w = [...r || [], ...i].slice(0, h);
|
|
191
|
-
d && d(w);
|
|
198
|
+
const [V, R] = B(!1), [_, M] = B(!1), j = W(null);
|
|
199
|
+
X(() => {
|
|
200
|
+
const t = () => {
|
|
201
|
+
if (j.current) {
|
|
202
|
+
const i = j.current.closest("fieldset");
|
|
203
|
+
M(i?.disabled ?? !1);
|
|
192
204
|
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
205
|
+
};
|
|
206
|
+
t();
|
|
207
|
+
const s = new MutationObserver(t);
|
|
208
|
+
if (j.current) {
|
|
209
|
+
const i = j.current.closest("fieldset");
|
|
210
|
+
i && s.observe(i, { attributes: !0, attributeFilter: ["disabled"] });
|
|
196
211
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
return () => s.disconnect();
|
|
213
|
+
}, []);
|
|
214
|
+
const q = c?.join(",") || "", G = x * 1024 * 1024, o = b || a !== void 0 || m !== void 0, h = o ? a || [] : d ? [d] : [], N = w || A, u = C || _, H = (t) => {
|
|
215
|
+
u || (t.preventDefault(), R(!0));
|
|
216
|
+
}, J = (t) => {
|
|
217
|
+
u || (t.preventDefault(), R(!1));
|
|
218
|
+
}, K = (t) => {
|
|
219
|
+
if (!u)
|
|
220
|
+
if (t.preventDefault(), R(!1), o) {
|
|
221
|
+
const i = Array.from(t.dataTransfer.files).filter($);
|
|
222
|
+
if (i.length > 0) {
|
|
223
|
+
const F = [...a || [], ...i].slice(0, f);
|
|
224
|
+
m && m(F);
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
const s = t.dataTransfer.files[0];
|
|
228
|
+
s && $(s) && r && r(s);
|
|
229
|
+
}
|
|
230
|
+
}, Q = (t) => {
|
|
231
|
+
if (!u) {
|
|
232
|
+
if (o) {
|
|
233
|
+
const i = (t.target.files ? Array.from(t.target.files) : []).filter($);
|
|
234
|
+
if (i.length > 0) {
|
|
235
|
+
const F = [...a || [], ...i].slice(0, f);
|
|
236
|
+
m && m(F);
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
const s = t.target.files?.[0];
|
|
240
|
+
s && $(s) && r && r(s);
|
|
203
241
|
}
|
|
204
|
-
|
|
205
|
-
const n = a.target.files?.[0];
|
|
206
|
-
n && y(n) && l && l(n);
|
|
242
|
+
t.target.value = "";
|
|
207
243
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
},
|
|
216
|
-
const
|
|
217
|
-
return !i &&
|
|
218
|
-
},
|
|
219
|
-
|
|
244
|
+
}, k = (t) => {
|
|
245
|
+
if (!u)
|
|
246
|
+
if (o) {
|
|
247
|
+
const s = h.filter((i, g) => g !== t);
|
|
248
|
+
m && m(s);
|
|
249
|
+
} else
|
|
250
|
+
r && r(null);
|
|
251
|
+
}, $ = (t) => {
|
|
252
|
+
const s = t.name.substring(t.name.lastIndexOf(".")), i = !c || c.length === 0 || c.includes(s.toLowerCase()), g = t.size <= G;
|
|
253
|
+
return !i && l ? l(t, "extension") : !g && l && l(t, "size"), i && g;
|
|
254
|
+
}, z = () => {
|
|
255
|
+
u || (o ? m && m([]) : r && r(null));
|
|
220
256
|
};
|
|
221
|
-
return /* @__PURE__ */ e.jsxs("div", { className:
|
|
222
|
-
|
|
223
|
-
|
|
257
|
+
return /* @__PURE__ */ e.jsxs("div", { ref: j, className: v("adm:flex adm:flex-col adm:gap-4", n), ...U, children: [
|
|
258
|
+
o && D === "above" && /* @__PURE__ */ e.jsx(
|
|
259
|
+
I,
|
|
224
260
|
{
|
|
225
|
-
files:
|
|
226
|
-
isMultiple:
|
|
227
|
-
invalid:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
261
|
+
files: h,
|
|
262
|
+
isMultiple: o,
|
|
263
|
+
invalid: N,
|
|
264
|
+
disabled: u,
|
|
265
|
+
labels: p,
|
|
266
|
+
onRemoveFile: k,
|
|
267
|
+
onClearAll: z
|
|
231
268
|
}
|
|
232
269
|
),
|
|
233
|
-
(
|
|
234
|
-
|
|
270
|
+
(o || h.length === 0) && /* @__PURE__ */ e.jsx(
|
|
271
|
+
Y,
|
|
235
272
|
{
|
|
236
|
-
isDragging:
|
|
237
|
-
isMultiple:
|
|
238
|
-
invalid:
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
273
|
+
isDragging: V,
|
|
274
|
+
isMultiple: o,
|
|
275
|
+
invalid: N,
|
|
276
|
+
disabled: u,
|
|
277
|
+
accept: q,
|
|
278
|
+
acceptedExtensions: c,
|
|
279
|
+
maxSizeInMB: x,
|
|
280
|
+
maxFiles: f,
|
|
281
|
+
labels: p,
|
|
282
|
+
input: T,
|
|
283
|
+
onDragOver: H,
|
|
284
|
+
onDragLeave: J,
|
|
285
|
+
onDrop: K,
|
|
286
|
+
onFileChange: Q
|
|
248
287
|
}
|
|
249
288
|
),
|
|
250
|
-
!
|
|
251
|
-
|
|
289
|
+
!o && h.length > 0 && /* @__PURE__ */ e.jsx(
|
|
290
|
+
I,
|
|
252
291
|
{
|
|
253
|
-
files:
|
|
254
|
-
isMultiple:
|
|
255
|
-
invalid:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
292
|
+
files: h,
|
|
293
|
+
isMultiple: o,
|
|
294
|
+
invalid: N,
|
|
295
|
+
disabled: u,
|
|
296
|
+
labels: p,
|
|
297
|
+
onRemoveFile: k,
|
|
298
|
+
onClearAll: z
|
|
259
299
|
}
|
|
260
300
|
),
|
|
261
|
-
|
|
262
|
-
|
|
301
|
+
o && D === "below" && /* @__PURE__ */ e.jsx(
|
|
302
|
+
I,
|
|
263
303
|
{
|
|
264
|
-
files:
|
|
265
|
-
isMultiple:
|
|
266
|
-
invalid:
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
304
|
+
files: h,
|
|
305
|
+
isMultiple: o,
|
|
306
|
+
invalid: N,
|
|
307
|
+
disabled: u,
|
|
308
|
+
labels: p,
|
|
309
|
+
onRemoveFile: k,
|
|
310
|
+
onClearAll: z
|
|
270
311
|
}
|
|
271
312
|
)
|
|
272
313
|
] });
|
|
273
314
|
}
|
|
274
315
|
export {
|
|
275
|
-
|
|
316
|
+
ae as FileUpload
|
|
276
317
|
};
|
package/dist/slider.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./jsx-runtime-BB_1_6y_.cjs"),ce=require("react"),U=require("./index-C8ni3LLa.cjs"),P=require("./index-BWaO7kQK.cjs"),_=require("./index-_XxjJPRD.cjs"),ue=require("./index-cwZN7ZY3.cjs"),Y=require("./index-Da298sEl.cjs"),me=require("./index-DYxWvftI.cjs"),fe=require("./index-bSPhqlcX.cjs"),K=require("./index-CocSS1YK.cjs"),N=require("./index-DoxiiusW.cjs");function pe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=pe(ce);var X=["PageUp","PageDown"],G=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],W={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},C="Slider",[V,xe,Se]=Y.createCollection(C),[J]=ue.createContextScope(C,[Se]),[he,k]=J(C),Q=l.forwardRef((e,t)=>{const{name:n,min:o=0,max:s=100,step:d=1,orientation:r="horizontal",disabled:a=!1,minStepsBetweenThumbs:f=0,defaultValue:v=[o],value:S,onValueChange:i=()=>{},onValueCommit:u=()=>{},inverted:h=!1,form:w,...x}=e,m=l.useRef(new Set),c=l.useRef(0),b=r==="horizontal"?ge:ve,[g=[],M]=P.useControllableState({prop:S,defaultProp:v,onChange:R=>{[...m.current][c.current]?.focus(),i(R)}}),T=l.useRef(g);function B(R){const E=ye(g,R);A(R,E)}function de(R){A(R,c.current)}function le(){const R=T.current[c.current];g[c.current]!==R&&u(g)}function A(R,E,{commit:z}={commit:!1}){const F=_e(d),H=Ce(Math.round((R-o)/d)*d+o,F),I=U.clamp(H,[o,s]);M((D=[])=>{const y=we(D,I,E);if(De(y,f*d)){c.current=y.indexOf(I);const L=String(y)!==String(D);return L&&z&&u(y),L?y:D}else return D})}return p.jsxRuntimeExports.jsx(he,{scope:e.__scopeSlider,name:n,disabled:a,min:o,max:s,valueIndexToChangeRef:c,thumbs:m.current,values:g,orientation:r,form:w,children:p.jsxRuntimeExports.jsx(V.Provider,{scope:e.__scopeSlider,children:p.jsxRuntimeExports.jsx(V.Slot,{scope:e.__scopeSlider,children:p.jsxRuntimeExports.jsx(b,{"aria-disabled":a,"data-disabled":a?"":void 0,...x,ref:t,onPointerDown:P.composeEventHandlers(x.onPointerDown,()=>{a||(T.current=g)}),min:o,max:s,inverted:h,onSlideStart:a?void 0:B,onSlideMove:a?void 0:de,onSlideEnd:a?void 0:le,onHomeKeyDown:()=>!a&&A(o,0,{commit:!0}),onEndKeyDown:()=>!a&&A(s,g.length-1,{commit:!0}),onStepKeyDown:({event:R,direction:E})=>{if(!a){const H=X.includes(R.key)||R.shiftKey&&G.includes(R.key)?10:1,I=c.current,D=g[I],y=d*H*E;A(D+y,I,{commit:!0})}}})})})})});Q.displayName=C;var[Z,ee]=J(C,{startEdge:"left",endEdge:"right",size:"width",direction:1}),ge=l.forwardRef((e,t)=>{const{min:n,max:o,dir:s,inverted:d,onSlideStart:r,onSlideMove:a,onSlideEnd:f,onStepKeyDown:v,...S}=e,[i,u]=l.useState(null),h=_.useComposedRefs(t,b=>u(b)),w=l.useRef(void 0),x=Y.useDirection(s),m=x==="ltr",c=m&&!d||!m&&d;function j(b){const g=w.current||i.getBoundingClientRect(),M=[0,g.width],B=q(M,c?[n,o]:[o,n]);return w.current=g,B(b-g.left)}return p.jsxRuntimeExports.jsx(Z,{scope:e.__scopeSlider,startEdge:c?"left":"right",endEdge:c?"right":"left",direction:c?1:-1,size:"width",children:p.jsxRuntimeExports.jsx(te,{dir:x,"data-orientation":"horizontal",...S,ref:h,style:{...S.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:b=>{const g=j(b.clientX);r?.(g)},onSlideMove:b=>{const g=j(b.clientX);a?.(g)},onSlideEnd:()=>{w.current=void 0,f?.()},onStepKeyDown:b=>{const M=W[c?"from-left":"from-right"].includes(b.key);v?.({event:b,direction:M?-1:1})}})})}),ve=l.forwardRef((e,t)=>{const{min:n,max:o,inverted:s,onSlideStart:d,onSlideMove:r,onSlideEnd:a,onStepKeyDown:f,...v}=e,S=l.useRef(null),i=_.useComposedRefs(t,S),u=l.useRef(void 0),h=!s;function w(x){const m=u.current||S.current.getBoundingClientRect(),c=[0,m.height],b=q(c,h?[o,n]:[n,o]);return u.current=m,b(x-m.top)}return p.jsxRuntimeExports.jsx(Z,{scope:e.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:p.jsxRuntimeExports.jsx(te,{"data-orientation":"vertical",...v,ref:i,style:{...v.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const m=w(x.clientY);d?.(m)},onSlideMove:x=>{const m=w(x.clientY);r?.(m)},onSlideEnd:()=>{u.current=void 0,a?.()},onStepKeyDown:x=>{const c=W[h?"from-bottom":"from-top"].includes(x.key);f?.({event:x,direction:c?-1:1})}})})}),te=l.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:s,onSlideEnd:d,onHomeKeyDown:r,onEndKeyDown:a,onStepKeyDown:f,...v}=e,S=k(C,n);return p.jsxRuntimeExports.jsx(K.Primitive.span,{...v,ref:t,onKeyDown:P.composeEventHandlers(e.onKeyDown,i=>{i.key==="Home"?(r(i),i.preventDefault()):i.key==="End"?(a(i),i.preventDefault()):X.concat(G).includes(i.key)&&(f(i),i.preventDefault())}),onPointerDown:P.composeEventHandlers(e.onPointerDown,i=>{const u=i.target;u.setPointerCapture(i.pointerId),i.preventDefault(),S.thumbs.has(u)?u.focus():o(i)}),onPointerMove:P.composeEventHandlers(e.onPointerMove,i=>{i.target.hasPointerCapture(i.pointerId)&&s(i)}),onPointerUp:P.composeEventHandlers(e.onPointerUp,i=>{const u=i.target;u.hasPointerCapture(i.pointerId)&&(u.releasePointerCapture(i.pointerId),d(i))})})}),ne="SliderTrack",oe=l.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,s=k(ne,n);return p.jsxRuntimeExports.jsx(K.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...o,ref:t})});oe.displayName=ne;var O="SliderRange",re=l.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,s=k(O,n),d=ee(O,n),r=l.useRef(null),a=_.useComposedRefs(t,r),f=s.values.length,v=s.values.map(u=>ae(u,s.min,s.max)),S=f>1?Math.min(...v):0,i=100-Math.max(...v);return p.jsxRuntimeExports.jsx(K.Primitive.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...o,ref:a,style:{...e.style,[d.startEdge]:S+"%",[d.endEdge]:i+"%"}})});re.displayName=O;var $="SliderThumb",ie=l.forwardRef((e,t)=>{const n=xe(e.__scopeSlider),[o,s]=l.useState(null),d=_.useComposedRefs(t,a=>s(a)),r=l.useMemo(()=>o?n().findIndex(a=>a.ref.current===o):-1,[n,o]);return p.jsxRuntimeExports.jsx(be,{...e,ref:d,index:r})}),be=l.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:s,...d}=e,r=k($,n),a=ee($,n),[f,v]=l.useState(null),S=_.useComposedRefs(t,j=>v(j)),i=f?r.form||!!f.closest("form"):!0,u=fe.useSize(f),h=r.values[o],w=h===void 0?0:ae(h,r.min,r.max),x=Ee(o,r.values.length),m=u?.[a.size],c=m?Pe(m,w,a.direction):0;return l.useEffect(()=>{if(f)return r.thumbs.add(f),()=>{r.thumbs.delete(f)}},[f,r.thumbs]),p.jsxRuntimeExports.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${w}% + ${c}px)`},children:[p.jsxRuntimeExports.jsx(V.ItemSlot,{scope:e.__scopeSlider,children:p.jsxRuntimeExports.jsx(K.Primitive.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":r.min,"aria-valuenow":h,"aria-valuemax":r.max,"aria-orientation":r.orientation,"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,tabIndex:r.disabled?void 0:0,...d,ref:S,style:h===void 0?{display:"none"}:e.style,onFocus:P.composeEventHandlers(e.onFocus,()=>{r.valueIndexToChangeRef.current=o})})}),i&&p.jsxRuntimeExports.jsx(se,{name:s??(r.name?r.name+(r.values.length>1?"[]":""):void 0),form:r.form,value:h},o)]})});ie.displayName=$;var Re="RadioBubbleInput",se=l.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const s=l.useRef(null),d=_.useComposedRefs(s,o),r=me.usePrevious(t);return l.useEffect(()=>{const a=s.current;if(!a)return;const f=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(f,"value").set;if(r!==t&&S){const i=new Event("input",{bubbles:!0});S.call(a,t),a.dispatchEvent(i)}},[r,t]),p.jsxRuntimeExports.jsx(K.Primitive.input,{style:{display:"none"},...n,ref:d,defaultValue:t})});se.displayName=Re;function we(e=[],t,n){const o=[...e];return o[n]=t,o.sort((s,d)=>s-d)}function ae(e,t,n){const d=100/(n-t)*(e-t);return U.clamp(d,[0,100])}function Ee(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function ye(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),o=Math.min(...n);return n.indexOf(o)}function Pe(e,t,n){const o=e/2,d=q([0,50],[0,o]);return(o-d(t)*n)*n}function je(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function De(e,t){if(t>0){const n=je(e);return Math.min(...n)>=t}return!0}function q(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function _e(e){return(String(e).split(".")[1]||"").length}function Ce(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Me=Q,Ae=oe,Ie=re,Ke=ie;function ke({className:e,defaultValue:t,value:n,min:o=0,max:s=100,theme:d,colorSlide:r,disabled:a,...f}){const[v,S]=l.useState(!1),i=l.useRef(null);l.useEffect(()=>{const x=()=>{if(i.current){const c=i.current.closest("fieldset");S(c?.disabled??!1)}};x();const m=new MutationObserver(x);if(i.current){const c=i.current.closest("fieldset");c&&m.observe(c,{attributes:!0,attributeFilter:["disabled"]})}return()=>m.disconnect()},[]);const u=a||v,h=l.useMemo(()=>Array.isArray(n)?n:Array.isArray(t)?t:[o,s],[n,t,o,s]),w=l.useMemo(()=>{if(r){if(r==="full")return{background:"linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff0000)"};if(Array.isArray(r)&&r.length===2)return{background:`linear-gradient(to right, ${r[0]}, ${r[1]})`}}},[r]);return p.jsxRuntimeExports.jsxs(Me,{ref:i,"data-slot":"slider","data-theme":d,defaultValue:t,value:n,min:o,max:s,disabled:u,className:N.cn(`
|
|
2
2
|
adm:relative adm:flex adm:w-full adm:touch-none adm:items-center
|
|
3
3
|
adm:select-none
|
|
4
4
|
adm:data-disabled:opacity-50
|
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
adm:data-[orientation=vertical]:min-h-44
|
|
7
7
|
adm:data-[orientation=vertical]:w-auto
|
|
8
8
|
adm:data-[orientation=vertical]:flex-col
|
|
9
|
-
`,e),...
|
|
9
|
+
`,e),...f,children:[p.jsxRuntimeExports.jsx(Ae,{"data-slot":"slider-track",className:N.cn(`
|
|
10
10
|
adm:relative adm:grow adm:overflow-hidden adm:rounded-full
|
|
11
11
|
adm:data-[orientation=horizontal]:h-1.5
|
|
12
12
|
adm:data-[orientation=horizontal]:w-full
|
|
13
13
|
adm:data-[orientation=vertical]:h-full
|
|
14
14
|
adm:data-[orientation=vertical]:w-1.5
|
|
15
|
-
`,r?"":"adm:bg-muted"),style:r?
|
|
15
|
+
`,r?"":"adm:bg-muted"),style:r?w:void 0,children:p.jsxRuntimeExports.jsx(Ie,{"data-slot":"slider-range",className:N.cn(`
|
|
16
16
|
adm:absolute
|
|
17
17
|
adm:data-[orientation=horizontal]:h-full
|
|
18
18
|
adm:data-[orientation=vertical]:w-full
|
|
19
|
-
`,r?"adm:bg-transparent":"adm:bg-primary")})}),Array.from({length:
|
|
19
|
+
`,r?"adm:bg-transparent":"adm:bg-primary")})}),Array.from({length:h.length},(x,m)=>p.jsxRuntimeExports.jsx(Ke,{"data-slot":"slider-thumb",className:`
|
|
20
20
|
adm:block adm:size-4 adm:shrink-0 adm:rounded-full adm:border
|
|
21
21
|
adm:border-primary adm:bg-white adm:shadow-sm adm:ring-ring/50
|
|
22
22
|
adm:transition-[color,box-shadow]
|
|
23
23
|
adm:hover:ring-4
|
|
24
24
|
adm:focus-visible:ring-4 adm:focus-visible:outline-hidden
|
|
25
25
|
adm:disabled:pointer-events-none adm:disabled:opacity-50
|
|
26
|
-
`},
|
|
26
|
+
`},m))]})}exports.Slider=ke;
|