@page-speed/forms 0.4.8 → 0.5.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/core.cjs +89 -21
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +89 -21
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +94 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -2
- package/dist/index.d.ts +38 -2
- package/dist/index.js +89 -21
- package/dist/index.js.map +1 -1
- package/dist/inputs.cjs +935 -699
- package/dist/inputs.cjs.map +1 -1
- package/dist/inputs.d.cts +93 -182
- package/dist/inputs.d.ts +93 -182
- package/dist/inputs.js +932 -697
- package/dist/inputs.js.map +1 -1
- package/dist/{types-4ppM117e.d.cts → types-DuX3q6A4.d.cts} +1 -1
- package/dist/{types-4ppM117e.d.ts → types-DuX3q6A4.d.ts} +1 -1
- package/dist/validation-rules.d.cts +1 -1
- package/dist/validation-rules.d.ts +1 -1
- package/dist/validation-utils.d.cts +1 -1
- package/dist/validation-utils.d.ts +1 -1
- package/dist/validation-valibot.d.cts +1 -1
- package/dist/validation-valibot.d.ts +1 -1
- package/dist/validation.d.cts +1 -1
- package/dist/validation.d.ts +1 -1
- package/package.json +12 -2
package/dist/inputs.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React17 = require('react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
5
|
var tailwindMerge = require('tailwind-merge');
|
|
6
|
+
var radixUi = require('radix-ui');
|
|
6
7
|
var useOnClickOutside = require('@opensite/hooks/useOnClickOutside');
|
|
7
8
|
|
|
8
9
|
function _interopNamespace(e) {
|
|
@@ -23,7 +24,7 @@ function _interopNamespace(e) {
|
|
|
23
24
|
return Object.freeze(n);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
var
|
|
27
|
+
var React17__namespace = /*#__PURE__*/_interopNamespace(React17);
|
|
27
28
|
|
|
28
29
|
// src/inputs/TextInput.tsx
|
|
29
30
|
function cn(...inputs) {
|
|
@@ -31,6 +32,36 @@ function cn(...inputs) {
|
|
|
31
32
|
}
|
|
32
33
|
var INPUT_AUTOFILL_RESET_CLASSES = "autofill:bg-transparent autofill:text-foreground [&:-webkit-autofill]:[-webkit-text-fill-color:hsl(var(--foreground))] [&:-webkit-autofill]:[caret-color:hsl(var(--foreground))] [&:-webkit-autofill]:[box-shadow:0_0_0px_1000px_hsl(var(--background))_inset] [&:-webkit-autofill:hover]:[box-shadow:0_0_0px_1000px_hsl(var(--background))_inset] [&:-webkit-autofill:focus]:[box-shadow:0_0_0px_1000px_hsl(var(--background))_inset] [&:-webkit-autofill]:[transition:background-color_9999s_ease-out,color_9999s_ease-out]";
|
|
33
34
|
|
|
35
|
+
// src/components/ui/input.tsx
|
|
36
|
+
function Input({ className, type, ...props }) {
|
|
37
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
38
|
+
"input",
|
|
39
|
+
{
|
|
40
|
+
type,
|
|
41
|
+
"data-slot": "input",
|
|
42
|
+
className: cn(
|
|
43
|
+
// Core structure - no hardcoded colors, uses CSS variables
|
|
44
|
+
"flex h-9 w-full min-w-0 rounded-md border border-input",
|
|
45
|
+
"bg-transparent px-3 py-1 text-base shadow-sm",
|
|
46
|
+
"transition-colors outline-none md:text-sm",
|
|
47
|
+
// Focus state - uses ring-ring CSS variable (adapts to theme)
|
|
48
|
+
"focus-visible:ring-1 focus-visible:ring-ring",
|
|
49
|
+
// Error state - uses destructive CSS variables (adapts to theme)
|
|
50
|
+
"aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive",
|
|
51
|
+
// Disabled state - no color hardcoding
|
|
52
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
53
|
+
// File input specific - inherits text color from parent
|
|
54
|
+
"file:inline-flex file:h-7 file:border-0 file:bg-transparent",
|
|
55
|
+
"file:text-sm file:font-medium",
|
|
56
|
+
// Autofill reset - prevents browser from overriding our dynamic colors
|
|
57
|
+
INPUT_AUTOFILL_RESET_CLASSES,
|
|
58
|
+
className
|
|
59
|
+
),
|
|
60
|
+
...props
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
34
65
|
// src/inputs/TextInput.tsx
|
|
35
66
|
function TextInput({
|
|
36
67
|
name,
|
|
@@ -53,17 +84,8 @@ function TextInput({
|
|
|
53
84
|
onBlur?.();
|
|
54
85
|
};
|
|
55
86
|
const hasValue = String(value ?? "").trim().length > 0;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
59
|
-
"disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
60
|
-
INPUT_AUTOFILL_RESET_CLASSES,
|
|
61
|
-
!error && hasValue && "ring-2 ring-ring",
|
|
62
|
-
error && "border-destructive ring-1 ring-destructive",
|
|
63
|
-
className
|
|
64
|
-
);
|
|
65
|
-
return /* @__PURE__ */ React9__namespace.createElement(
|
|
66
|
-
"input",
|
|
87
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
88
|
+
Input,
|
|
67
89
|
{
|
|
68
90
|
type,
|
|
69
91
|
id,
|
|
@@ -74,7 +96,12 @@ function TextInput({
|
|
|
74
96
|
placeholder,
|
|
75
97
|
disabled,
|
|
76
98
|
required,
|
|
77
|
-
className:
|
|
99
|
+
className: cn(
|
|
100
|
+
// Valid value indicator - ring-2 when has value and no error
|
|
101
|
+
!error && hasValue && "ring-2 ring-ring",
|
|
102
|
+
// Error state - handled by Input component via aria-invalid
|
|
103
|
+
className
|
|
104
|
+
),
|
|
78
105
|
"aria-invalid": error || props["aria-invalid"],
|
|
79
106
|
"aria-describedby": props["aria-describedby"],
|
|
80
107
|
"aria-required": required || props["aria-required"],
|
|
@@ -83,6 +110,30 @@ function TextInput({
|
|
|
83
110
|
);
|
|
84
111
|
}
|
|
85
112
|
TextInput.displayName = "TextInput";
|
|
113
|
+
function Textarea({ className, ...props }) {
|
|
114
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
115
|
+
"textarea",
|
|
116
|
+
{
|
|
117
|
+
"data-slot": "textarea",
|
|
118
|
+
className: cn(
|
|
119
|
+
// Core structure - uses CSS variables only
|
|
120
|
+
"flex field-sizing-content min-h-16 w-full rounded-md border border-input",
|
|
121
|
+
"bg-transparent px-3 py-2 text-base shadow-xs",
|
|
122
|
+
"transition-[color,box-shadow] outline-none md:text-sm",
|
|
123
|
+
// Focus state - uses ring-ring CSS variable
|
|
124
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
125
|
+
// Error state - uses destructive CSS variables
|
|
126
|
+
"aria-invalid:border-destructive aria-invalid:ring-destructive/20",
|
|
127
|
+
// Disabled state
|
|
128
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
129
|
+
className
|
|
130
|
+
),
|
|
131
|
+
...props
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/inputs/TextArea.tsx
|
|
86
137
|
function TextArea({
|
|
87
138
|
name,
|
|
88
139
|
value,
|
|
@@ -107,17 +158,8 @@ function TextArea({
|
|
|
107
158
|
onBlur?.();
|
|
108
159
|
};
|
|
109
160
|
const hasValue = String(value ?? "").trim().length > 0;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
113
|
-
"disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
114
|
-
INPUT_AUTOFILL_RESET_CLASSES,
|
|
115
|
-
!error && hasValue && "ring-2 ring-ring",
|
|
116
|
-
error && "border-destructive ring-1 ring-destructive",
|
|
117
|
-
className
|
|
118
|
-
);
|
|
119
|
-
return /* @__PURE__ */ React9__namespace.createElement(
|
|
120
|
-
"textarea",
|
|
161
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
162
|
+
Textarea,
|
|
121
163
|
{
|
|
122
164
|
name,
|
|
123
165
|
value: value ?? "",
|
|
@@ -126,7 +168,12 @@ function TextArea({
|
|
|
126
168
|
placeholder,
|
|
127
169
|
disabled,
|
|
128
170
|
required,
|
|
129
|
-
className:
|
|
171
|
+
className: cn(
|
|
172
|
+
// Valid value indicator - ring-2 when has value and no error
|
|
173
|
+
!error && hasValue && "ring-2 ring-ring",
|
|
174
|
+
// Error state - handled by Textarea component via aria-invalid
|
|
175
|
+
className
|
|
176
|
+
),
|
|
130
177
|
rows,
|
|
131
178
|
cols,
|
|
132
179
|
maxLength,
|
|
@@ -140,6 +187,175 @@ function TextArea({
|
|
|
140
187
|
);
|
|
141
188
|
}
|
|
142
189
|
TextArea.displayName = "TextArea";
|
|
190
|
+
function Checkbox({
|
|
191
|
+
className,
|
|
192
|
+
...props
|
|
193
|
+
}) {
|
|
194
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
195
|
+
radixUi.Checkbox.Root,
|
|
196
|
+
{
|
|
197
|
+
"data-slot": "checkbox",
|
|
198
|
+
className: cn(
|
|
199
|
+
// Core structure - uses CSS variables
|
|
200
|
+
"peer size-4 shrink-0 rounded-[4px] border border-input bg-transparent shadow-xs",
|
|
201
|
+
"transition-shadow outline-none",
|
|
202
|
+
// Checked state - uses primary CSS variables
|
|
203
|
+
"data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
204
|
+
"data-[state=checked]:border-primary",
|
|
205
|
+
// Focus state - uses ring-ring CSS variable
|
|
206
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
207
|
+
// Error state - uses destructive CSS variables
|
|
208
|
+
"aria-invalid:border-destructive aria-invalid:ring-destructive/20",
|
|
209
|
+
// Disabled state
|
|
210
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
211
|
+
className
|
|
212
|
+
),
|
|
213
|
+
...props
|
|
214
|
+
},
|
|
215
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
216
|
+
radixUi.Checkbox.Indicator,
|
|
217
|
+
{
|
|
218
|
+
"data-slot": "checkbox-indicator",
|
|
219
|
+
className: "grid place-content-center text-current transition-none"
|
|
220
|
+
},
|
|
221
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
222
|
+
"svg",
|
|
223
|
+
{
|
|
224
|
+
className: "size-3.5",
|
|
225
|
+
viewBox: "0 0 24 24",
|
|
226
|
+
fill: "none",
|
|
227
|
+
stroke: "currentColor",
|
|
228
|
+
strokeWidth: "3",
|
|
229
|
+
strokeLinecap: "round",
|
|
230
|
+
strokeLinejoin: "round"
|
|
231
|
+
},
|
|
232
|
+
/* @__PURE__ */ React17__namespace.createElement("polyline", { points: "20 6 9 17 4 12" })
|
|
233
|
+
)
|
|
234
|
+
)
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
function Label({
|
|
238
|
+
className,
|
|
239
|
+
...props
|
|
240
|
+
}) {
|
|
241
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
242
|
+
radixUi.Label.Root,
|
|
243
|
+
{
|
|
244
|
+
"data-slot": "label",
|
|
245
|
+
className: cn(
|
|
246
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
247
|
+
className
|
|
248
|
+
),
|
|
249
|
+
...props
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// src/inputs/Checkbox.tsx
|
|
255
|
+
function Checkbox2({
|
|
256
|
+
name,
|
|
257
|
+
value,
|
|
258
|
+
onChange,
|
|
259
|
+
onBlur,
|
|
260
|
+
disabled = false,
|
|
261
|
+
required = false,
|
|
262
|
+
error = false,
|
|
263
|
+
className = "",
|
|
264
|
+
label,
|
|
265
|
+
description,
|
|
266
|
+
useChoiceCard = false,
|
|
267
|
+
...props
|
|
268
|
+
}) {
|
|
269
|
+
const checkboxId = props.id || `checkbox-${name}`;
|
|
270
|
+
const handleCheckedChange = (checked) => {
|
|
271
|
+
onChange(checked);
|
|
272
|
+
};
|
|
273
|
+
const handleBlur = () => {
|
|
274
|
+
onBlur?.();
|
|
275
|
+
};
|
|
276
|
+
const showChoiceCard = useChoiceCard || !!description;
|
|
277
|
+
const checkbox = /* @__PURE__ */ React17__namespace.createElement(React17__namespace.Fragment, null, /* @__PURE__ */ React17__namespace.createElement(
|
|
278
|
+
"input",
|
|
279
|
+
{
|
|
280
|
+
type: "checkbox",
|
|
281
|
+
name,
|
|
282
|
+
checked: value,
|
|
283
|
+
onChange: () => {
|
|
284
|
+
},
|
|
285
|
+
disabled,
|
|
286
|
+
required,
|
|
287
|
+
tabIndex: -1,
|
|
288
|
+
"aria-hidden": "true",
|
|
289
|
+
style: {
|
|
290
|
+
position: "absolute",
|
|
291
|
+
width: "1px",
|
|
292
|
+
height: "1px",
|
|
293
|
+
padding: 0,
|
|
294
|
+
margin: "-1px",
|
|
295
|
+
overflow: "hidden",
|
|
296
|
+
clip: "rect(0, 0, 0, 0)",
|
|
297
|
+
whiteSpace: "nowrap",
|
|
298
|
+
border: 0
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
302
|
+
Checkbox,
|
|
303
|
+
{
|
|
304
|
+
id: checkboxId,
|
|
305
|
+
checked: value,
|
|
306
|
+
onCheckedChange: handleCheckedChange,
|
|
307
|
+
onBlur: handleBlur,
|
|
308
|
+
disabled,
|
|
309
|
+
"aria-invalid": error || props["aria-invalid"],
|
|
310
|
+
"aria-describedby": description ? `${checkboxId}-description` : props["aria-describedby"],
|
|
311
|
+
"aria-required": required || props["aria-required"],
|
|
312
|
+
...props
|
|
313
|
+
}
|
|
314
|
+
));
|
|
315
|
+
if (!label) {
|
|
316
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className }, checkbox);
|
|
317
|
+
}
|
|
318
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
319
|
+
"label",
|
|
320
|
+
{
|
|
321
|
+
htmlFor: checkboxId,
|
|
322
|
+
className: cn(
|
|
323
|
+
"flex gap-3 p-3 duration-200",
|
|
324
|
+
showChoiceCard && "border rounded-lg hover:ring-2 hover:ring-ring/50",
|
|
325
|
+
showChoiceCard && value && "ring-2 ring-ring",
|
|
326
|
+
showChoiceCard && error && "border-destructive",
|
|
327
|
+
disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
|
|
328
|
+
className
|
|
329
|
+
)
|
|
330
|
+
},
|
|
331
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
className: cn(
|
|
335
|
+
"flex w-full gap-3",
|
|
336
|
+
showChoiceCard ? "items-start" : "items-center"
|
|
337
|
+
)
|
|
338
|
+
},
|
|
339
|
+
checkbox,
|
|
340
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "flex flex-col gap-1" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
341
|
+
Label,
|
|
342
|
+
{
|
|
343
|
+
htmlFor: checkboxId,
|
|
344
|
+
className: "cursor-pointer font-medium leading-none"
|
|
345
|
+
},
|
|
346
|
+
label
|
|
347
|
+
), description && /* @__PURE__ */ React17__namespace.createElement(
|
|
348
|
+
"p",
|
|
349
|
+
{
|
|
350
|
+
id: `${checkboxId}-description`,
|
|
351
|
+
className: "text-sm opacity-70 leading-snug"
|
|
352
|
+
},
|
|
353
|
+
description
|
|
354
|
+
))
|
|
355
|
+
)
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
Checkbox2.displayName = "Checkbox";
|
|
143
359
|
var LabelGroup = ({
|
|
144
360
|
labelHtmlFor,
|
|
145
361
|
required = false,
|
|
@@ -155,11 +371,11 @@ var LabelGroup = ({
|
|
|
155
371
|
variant === "legend" ? "mb-1.5" : "mb-1 block",
|
|
156
372
|
primaryClassName
|
|
157
373
|
);
|
|
158
|
-
const requiredIndicator = required ? /* @__PURE__ */
|
|
374
|
+
const requiredIndicator = required ? /* @__PURE__ */ React17__namespace.createElement("span", { className: "text-destructive pl-0.5", "aria-label": "required" }, "*") : null;
|
|
159
375
|
let primaryElement = null;
|
|
160
376
|
if (primary) {
|
|
161
377
|
if (variant === "label") {
|
|
162
|
-
primaryElement = /* @__PURE__ */
|
|
378
|
+
primaryElement = /* @__PURE__ */ React17__namespace.createElement(
|
|
163
379
|
"label",
|
|
164
380
|
{
|
|
165
381
|
htmlFor: labelHtmlFor,
|
|
@@ -170,12 +386,12 @@ var LabelGroup = ({
|
|
|
170
386
|
requiredIndicator
|
|
171
387
|
);
|
|
172
388
|
} else if (variant === "legend") {
|
|
173
|
-
primaryElement = /* @__PURE__ */
|
|
389
|
+
primaryElement = /* @__PURE__ */ React17__namespace.createElement("legend", { "data-slot": "field-legend", className: primaryClasses }, primary, requiredIndicator);
|
|
174
390
|
} else {
|
|
175
|
-
primaryElement = /* @__PURE__ */
|
|
391
|
+
primaryElement = /* @__PURE__ */ React17__namespace.createElement("div", { "data-slot": "field-label", className: primaryClasses }, primary, requiredIndicator);
|
|
176
392
|
}
|
|
177
393
|
}
|
|
178
|
-
const secondaryElement = secondary ? /* @__PURE__ */
|
|
394
|
+
const secondaryElement = secondary ? /* @__PURE__ */ React17__namespace.createElement(
|
|
179
395
|
"p",
|
|
180
396
|
{
|
|
181
397
|
"data-slot": "field-description",
|
|
@@ -186,148 +402,12 @@ var LabelGroup = ({
|
|
|
186
402
|
) : null;
|
|
187
403
|
if (!primaryElement && !secondaryElement) return null;
|
|
188
404
|
if (variant === "legend") {
|
|
189
|
-
return /* @__PURE__ */
|
|
405
|
+
return /* @__PURE__ */ React17__namespace.createElement(React17__namespace.Fragment, null, primaryElement, secondaryElement);
|
|
190
406
|
}
|
|
191
|
-
return /* @__PURE__ */
|
|
407
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex flex-1 flex-col gap-0.5" }, primaryElement, secondaryElement);
|
|
192
408
|
};
|
|
193
409
|
|
|
194
|
-
// src/inputs/
|
|
195
|
-
function Checkbox({
|
|
196
|
-
name,
|
|
197
|
-
value,
|
|
198
|
-
onChange,
|
|
199
|
-
onBlur,
|
|
200
|
-
disabled = false,
|
|
201
|
-
required = false,
|
|
202
|
-
error = false,
|
|
203
|
-
className = "",
|
|
204
|
-
indeterminate = false,
|
|
205
|
-
label,
|
|
206
|
-
description,
|
|
207
|
-
useChoiceCard = false,
|
|
208
|
-
...props
|
|
209
|
-
}) {
|
|
210
|
-
const inputRef = React9__namespace.useRef(null);
|
|
211
|
-
const checkboxId = props.id || `checkbox-${name}`;
|
|
212
|
-
React9__namespace.useEffect(() => {
|
|
213
|
-
if (inputRef.current) {
|
|
214
|
-
inputRef.current.indeterminate = indeterminate;
|
|
215
|
-
}
|
|
216
|
-
}, [indeterminate]);
|
|
217
|
-
const handleChange = (e) => {
|
|
218
|
-
onChange(e.target.checked);
|
|
219
|
-
};
|
|
220
|
-
const handleBlur = () => {
|
|
221
|
-
onBlur?.();
|
|
222
|
-
};
|
|
223
|
-
const isActive = value || indeterminate && !value;
|
|
224
|
-
const checkbox = /* @__PURE__ */ React9__namespace.createElement(
|
|
225
|
-
"div",
|
|
226
|
-
{
|
|
227
|
-
className: cn(
|
|
228
|
-
"relative inline-flex items-center justify-center",
|
|
229
|
-
!label && className
|
|
230
|
-
)
|
|
231
|
-
},
|
|
232
|
-
/* @__PURE__ */ React9__namespace.createElement(
|
|
233
|
-
"input",
|
|
234
|
-
{
|
|
235
|
-
ref: inputRef,
|
|
236
|
-
type: "checkbox",
|
|
237
|
-
id: checkboxId,
|
|
238
|
-
name,
|
|
239
|
-
checked: value,
|
|
240
|
-
onChange: handleChange,
|
|
241
|
-
onBlur: handleBlur,
|
|
242
|
-
disabled,
|
|
243
|
-
required,
|
|
244
|
-
className: "peer sr-only",
|
|
245
|
-
"aria-invalid": error || props["aria-invalid"],
|
|
246
|
-
"aria-describedby": description ? `${checkboxId}-description` : props["aria-describedby"],
|
|
247
|
-
"aria-required": required || props["aria-required"],
|
|
248
|
-
...props
|
|
249
|
-
}
|
|
250
|
-
),
|
|
251
|
-
/* @__PURE__ */ React9__namespace.createElement(
|
|
252
|
-
"div",
|
|
253
|
-
{
|
|
254
|
-
className: cn(
|
|
255
|
-
"flex shrink-0 items-center justify-center rounded-full border-2 transition-colors size-6",
|
|
256
|
-
!error && isActive && "border-primary bg-primary text-primary-foreground",
|
|
257
|
-
!error && !isActive && "border-input bg-transparent",
|
|
258
|
-
error && isActive && "border-destructive bg-destructive text-destructive-foreground",
|
|
259
|
-
error && !isActive && "border-destructive bg-transparent",
|
|
260
|
-
disabled && "opacity-50",
|
|
261
|
-
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
262
|
-
)
|
|
263
|
-
},
|
|
264
|
-
value && /* @__PURE__ */ React9__namespace.createElement(
|
|
265
|
-
"svg",
|
|
266
|
-
{
|
|
267
|
-
className: "size-3.5",
|
|
268
|
-
viewBox: "0 0 24 24",
|
|
269
|
-
fill: "none",
|
|
270
|
-
stroke: "currentColor",
|
|
271
|
-
strokeWidth: "3",
|
|
272
|
-
strokeLinecap: "round",
|
|
273
|
-
strokeLinejoin: "round"
|
|
274
|
-
},
|
|
275
|
-
/* @__PURE__ */ React9__namespace.createElement("polyline", { points: "20 6 9 17 4 12" })
|
|
276
|
-
),
|
|
277
|
-
indeterminate && !value && /* @__PURE__ */ React9__namespace.createElement(
|
|
278
|
-
"svg",
|
|
279
|
-
{
|
|
280
|
-
className: "size-3.5",
|
|
281
|
-
viewBox: "0 0 24 24",
|
|
282
|
-
fill: "none",
|
|
283
|
-
stroke: "currentColor",
|
|
284
|
-
strokeWidth: "3",
|
|
285
|
-
strokeLinecap: "round",
|
|
286
|
-
strokeLinejoin: "round"
|
|
287
|
-
},
|
|
288
|
-
/* @__PURE__ */ React9__namespace.createElement("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
289
|
-
)
|
|
290
|
-
)
|
|
291
|
-
);
|
|
292
|
-
if (label) {
|
|
293
|
-
return /* @__PURE__ */ React9__namespace.createElement(
|
|
294
|
-
"label",
|
|
295
|
-
{
|
|
296
|
-
className: cn(
|
|
297
|
-
"w-full h-full flex gap-3 p-3 duration-200",
|
|
298
|
-
useChoiceCard && "border rounded-lg hover:ring-2",
|
|
299
|
-
useChoiceCard && value && "ring-2",
|
|
300
|
-
disabled ? "opacity-50 cursor-not-allowed hover:ring-0" : "cursor-pointer",
|
|
301
|
-
className
|
|
302
|
-
),
|
|
303
|
-
htmlFor: checkboxId
|
|
304
|
-
},
|
|
305
|
-
/* @__PURE__ */ React9__namespace.createElement(
|
|
306
|
-
"div",
|
|
307
|
-
{
|
|
308
|
-
className: cn(
|
|
309
|
-
"flex w-full flex-row gap-2",
|
|
310
|
-
useChoiceCard ? "items-start" : "items-center"
|
|
311
|
-
)
|
|
312
|
-
},
|
|
313
|
-
checkbox,
|
|
314
|
-
/* @__PURE__ */ React9__namespace.createElement(
|
|
315
|
-
LabelGroup,
|
|
316
|
-
{
|
|
317
|
-
variant: "text",
|
|
318
|
-
primary: label,
|
|
319
|
-
secondary: description,
|
|
320
|
-
secondaryId: description ? `${checkboxId}-description` : void 0,
|
|
321
|
-
primaryClassName: "mb-0",
|
|
322
|
-
secondaryClassName: "text-xs opacity-75"
|
|
323
|
-
}
|
|
324
|
-
)
|
|
325
|
-
)
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
return checkbox;
|
|
329
|
-
}
|
|
330
|
-
Checkbox.displayName = "Checkbox";
|
|
410
|
+
// src/inputs/CheckboxGroup.tsx
|
|
331
411
|
function CheckboxGroup({
|
|
332
412
|
name,
|
|
333
413
|
value = [],
|
|
@@ -356,11 +436,11 @@ function CheckboxGroup({
|
|
|
356
436
|
).length;
|
|
357
437
|
const allSelected = selectedEnabledCount === enabledOptions.length;
|
|
358
438
|
const someSelected = selectedEnabledCount > 0 && !allSelected;
|
|
359
|
-
const useChoiceCard =
|
|
439
|
+
const useChoiceCard = React17__namespace.useMemo(() => {
|
|
360
440
|
if (!options) return false;
|
|
361
441
|
return options?.some((opt) => opt.description);
|
|
362
442
|
}, [options]);
|
|
363
|
-
const countableValue =
|
|
443
|
+
const countableValue = React17__namespace.useMemo(() => {
|
|
364
444
|
if (value?.length > 0) {
|
|
365
445
|
return value.length;
|
|
366
446
|
}
|
|
@@ -385,7 +465,7 @@ function CheckboxGroup({
|
|
|
385
465
|
onBlur?.();
|
|
386
466
|
};
|
|
387
467
|
const maxReached = Boolean(maxSelections && countableValue >= maxSelections);
|
|
388
|
-
const containerClass =
|
|
468
|
+
const containerClass = React17__namespace.useMemo(() => {
|
|
389
469
|
return cn(
|
|
390
470
|
"w-full gap-3 grid grid-cols-1 border-0 m-0 p-0 min-w-0",
|
|
391
471
|
(layout === "grid" || layout === "inline") && "md:grid-cols-2",
|
|
@@ -394,7 +474,7 @@ function CheckboxGroup({
|
|
|
394
474
|
}, [layout, className]);
|
|
395
475
|
const groupDescriptionId = description ? `${name}-description` : void 0;
|
|
396
476
|
const groupAriaDescribedBy = [props["aria-describedby"], groupDescriptionId].filter(Boolean).join(" ") || void 0;
|
|
397
|
-
return /* @__PURE__ */
|
|
477
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
398
478
|
"fieldset",
|
|
399
479
|
{
|
|
400
480
|
className: containerClass,
|
|
@@ -404,7 +484,7 @@ function CheckboxGroup({
|
|
|
404
484
|
"aria-required": required || props["aria-required"],
|
|
405
485
|
"aria-label": typeof label === "string" ? label : props["aria-label"]
|
|
406
486
|
},
|
|
407
|
-
/* @__PURE__ */
|
|
487
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
408
488
|
LabelGroup,
|
|
409
489
|
{
|
|
410
490
|
labelHtmlFor: name,
|
|
@@ -415,8 +495,8 @@ function CheckboxGroup({
|
|
|
415
495
|
primary: label
|
|
416
496
|
}
|
|
417
497
|
),
|
|
418
|
-
showSelectAll && enabledOptions.length > 0 && /* @__PURE__ */
|
|
419
|
-
|
|
498
|
+
showSelectAll && enabledOptions.length > 0 && /* @__PURE__ */ React17__namespace.createElement(
|
|
499
|
+
Checkbox2,
|
|
420
500
|
{
|
|
421
501
|
name: `${name}-select-all`,
|
|
422
502
|
id: `${name}-select-all`,
|
|
@@ -433,8 +513,8 @@ function CheckboxGroup({
|
|
|
433
513
|
options.map((option) => {
|
|
434
514
|
const isChecked = value.includes(option.value);
|
|
435
515
|
const isDisabled = disabled || option.disabled || maxReached && !isChecked;
|
|
436
|
-
return /* @__PURE__ */
|
|
437
|
-
|
|
516
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
517
|
+
Checkbox2,
|
|
438
518
|
{
|
|
439
519
|
key: option.value,
|
|
440
520
|
name,
|
|
@@ -451,7 +531,7 @@ function CheckboxGroup({
|
|
|
451
531
|
}
|
|
452
532
|
);
|
|
453
533
|
}),
|
|
454
|
-
(minSelections || maxSelections) && /* @__PURE__ */
|
|
534
|
+
(minSelections || maxSelections) && /* @__PURE__ */ React17__namespace.createElement(
|
|
455
535
|
"div",
|
|
456
536
|
{
|
|
457
537
|
className: cn(
|
|
@@ -460,12 +540,66 @@ function CheckboxGroup({
|
|
|
460
540
|
),
|
|
461
541
|
"aria-live": "polite"
|
|
462
542
|
},
|
|
463
|
-
minSelections && countableValue < minSelections && /* @__PURE__ */
|
|
464
|
-
maxSelections && /* @__PURE__ */
|
|
543
|
+
minSelections && countableValue < minSelections && /* @__PURE__ */ React17__namespace.createElement("span", null, "Select at least ", minSelections, " option", minSelections !== 1 ? "s" : ""),
|
|
544
|
+
maxSelections && /* @__PURE__ */ React17__namespace.createElement("span", null, countableValue, "/", maxSelections, " selected")
|
|
465
545
|
)
|
|
466
546
|
);
|
|
467
547
|
}
|
|
468
548
|
CheckboxGroup.displayName = "CheckboxGroup";
|
|
549
|
+
function RadioGroup({
|
|
550
|
+
className,
|
|
551
|
+
...props
|
|
552
|
+
}) {
|
|
553
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
554
|
+
radixUi.RadioGroup.Root,
|
|
555
|
+
{
|
|
556
|
+
"data-slot": "radio-group",
|
|
557
|
+
className: cn("grid gap-3", className),
|
|
558
|
+
...props
|
|
559
|
+
}
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
function RadioGroupItem({
|
|
563
|
+
className,
|
|
564
|
+
...props
|
|
565
|
+
}) {
|
|
566
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
567
|
+
radixUi.RadioGroup.Item,
|
|
568
|
+
{
|
|
569
|
+
"data-slot": "radio-group-item",
|
|
570
|
+
className: cn(
|
|
571
|
+
// Core structure - uses CSS variables
|
|
572
|
+
"aspect-square size-4 shrink-0 rounded-full border border-input bg-transparent shadow-xs",
|
|
573
|
+
"text-primary transition-[color,box-shadow] outline-none",
|
|
574
|
+
// Focus state - uses ring-ring CSS variable
|
|
575
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
576
|
+
// Error state - uses destructive CSS variables
|
|
577
|
+
"aria-invalid:border-destructive aria-invalid:ring-destructive/20",
|
|
578
|
+
// Disabled state
|
|
579
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
580
|
+
className
|
|
581
|
+
),
|
|
582
|
+
...props
|
|
583
|
+
},
|
|
584
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
585
|
+
radixUi.RadioGroup.Indicator,
|
|
586
|
+
{
|
|
587
|
+
"data-slot": "radio-group-indicator",
|
|
588
|
+
className: "relative flex items-center justify-center"
|
|
589
|
+
},
|
|
590
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
591
|
+
"svg",
|
|
592
|
+
{
|
|
593
|
+
className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2",
|
|
594
|
+
viewBox: "0 0 24 24"
|
|
595
|
+
},
|
|
596
|
+
/* @__PURE__ */ React17__namespace.createElement("circle", { cx: "12", cy: "12", r: "12" })
|
|
597
|
+
)
|
|
598
|
+
)
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// src/inputs/Radio.tsx
|
|
469
603
|
function Radio({
|
|
470
604
|
name,
|
|
471
605
|
value,
|
|
@@ -481,146 +615,433 @@ function Radio({
|
|
|
481
615
|
options,
|
|
482
616
|
...props
|
|
483
617
|
}) {
|
|
484
|
-
const
|
|
485
|
-
onChange(
|
|
486
|
-
};
|
|
487
|
-
const handleKeyDown = (e, currentIndex) => {
|
|
488
|
-
if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
|
489
|
-
e.preventDefault();
|
|
490
|
-
let nextIndex = (currentIndex + 1) % options.length;
|
|
491
|
-
let attempts = 0;
|
|
492
|
-
while (options[nextIndex].disabled && attempts < options.length && !disabled) {
|
|
493
|
-
nextIndex = (nextIndex + 1) % options.length;
|
|
494
|
-
attempts++;
|
|
495
|
-
}
|
|
496
|
-
if (!options[nextIndex].disabled) {
|
|
497
|
-
handleChange(options[nextIndex].value);
|
|
498
|
-
}
|
|
499
|
-
} else if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
|
500
|
-
e.preventDefault();
|
|
501
|
-
let prevIndex = (currentIndex - 1 + options.length) % options.length;
|
|
502
|
-
let attempts = 0;
|
|
503
|
-
while (options[prevIndex].disabled && attempts < options.length && !disabled) {
|
|
504
|
-
prevIndex = (prevIndex - 1 + options.length) % options.length;
|
|
505
|
-
attempts++;
|
|
506
|
-
}
|
|
507
|
-
if (!options[prevIndex].disabled) {
|
|
508
|
-
handleChange(options[prevIndex].value);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
618
|
+
const handleValueChange = (selectedValue) => {
|
|
619
|
+
onChange(selectedValue);
|
|
511
620
|
};
|
|
512
621
|
const handleBlur = () => {
|
|
513
622
|
onBlur?.();
|
|
514
623
|
};
|
|
515
|
-
const useChoiceCard =
|
|
624
|
+
const useChoiceCard = React17__namespace.useMemo(() => {
|
|
516
625
|
return options.some((option) => option.description);
|
|
517
626
|
}, [options]);
|
|
518
|
-
const containerClass = React9__namespace.useMemo(() => {
|
|
519
|
-
return cn(
|
|
520
|
-
"w-full gap-3 grid grid-cols-1 border-0 m-0 p-0 min-w-0",
|
|
521
|
-
(layout === "grid" || layout === "inline") && "md:grid-cols-2",
|
|
522
|
-
className
|
|
523
|
-
);
|
|
524
|
-
}, [layout, className]);
|
|
525
627
|
const groupDescriptionId = description ? `${name}-description` : void 0;
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
"fieldset",
|
|
628
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: cn("w-full", className) }, (label || description) && /* @__PURE__ */ React17__namespace.createElement("div", { className: "mb-3" }, label && /* @__PURE__ */ React17__namespace.createElement(Label, { className: "text-base font-medium block mb-1" }, label), description && /* @__PURE__ */ React17__namespace.createElement(
|
|
629
|
+
"p",
|
|
529
630
|
{
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
"aria-invalid": error || props["aria-invalid"],
|
|
533
|
-
"aria-describedby": groupAriaDescribedBy,
|
|
534
|
-
"aria-required": required || props["aria-required"],
|
|
535
|
-
"aria-label": typeof label === "string" ? label : props["aria-label"]
|
|
631
|
+
id: groupDescriptionId,
|
|
632
|
+
className: "text-sm opacity-70"
|
|
536
633
|
},
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
634
|
+
description
|
|
635
|
+
)), /* @__PURE__ */ React17__namespace.createElement(
|
|
636
|
+
RadioGroup,
|
|
637
|
+
{
|
|
638
|
+
name,
|
|
639
|
+
value,
|
|
640
|
+
onValueChange: handleValueChange,
|
|
641
|
+
onBlur: handleBlur,
|
|
642
|
+
disabled,
|
|
643
|
+
required,
|
|
644
|
+
className: cn(
|
|
645
|
+
"gap-3",
|
|
646
|
+
layout === "grid" && "grid grid-cols-1 md:grid-cols-2",
|
|
647
|
+
layout === "inline" && "flex flex-wrap"
|
|
648
|
+
),
|
|
649
|
+
"aria-invalid": error || props["aria-invalid"],
|
|
650
|
+
"aria-describedby": groupDescriptionId || props["aria-describedby"],
|
|
651
|
+
"aria-required": required || props["aria-required"]
|
|
652
|
+
},
|
|
653
|
+
options.map((option) => {
|
|
654
|
+
const isSelected = value === option.value;
|
|
548
655
|
const isDisabled = disabled || option.disabled;
|
|
549
656
|
const radioId = `${name}-${option.value}`;
|
|
550
|
-
const hasDescription = option.description
|
|
551
|
-
|
|
552
|
-
"input",
|
|
553
|
-
{
|
|
554
|
-
type: "radio",
|
|
555
|
-
id: radioId,
|
|
556
|
-
name,
|
|
557
|
-
value: option.value,
|
|
558
|
-
checked: isChecked,
|
|
559
|
-
onChange: (e) => handleChange(e.target.value),
|
|
560
|
-
onBlur: handleBlur,
|
|
561
|
-
disabled: isDisabled,
|
|
562
|
-
required,
|
|
563
|
-
className: "peer sr-only",
|
|
564
|
-
"aria-describedby": hasDescription ? `${radioId}-description` : props["aria-describedby"]
|
|
565
|
-
}
|
|
566
|
-
), /* @__PURE__ */ React9__namespace.createElement(
|
|
567
|
-
"div",
|
|
568
|
-
{
|
|
569
|
-
className: cn(
|
|
570
|
-
"flex shrink-0 items-center justify-center rounded-full border-2 transition-colors size-6",
|
|
571
|
-
!error && isChecked && "border-primary bg-transparent",
|
|
572
|
-
!error && !isChecked && "border-input bg-transparent",
|
|
573
|
-
error && isChecked && "border-destructive bg-transparent",
|
|
574
|
-
error && !isChecked && "border-destructive bg-transparent",
|
|
575
|
-
isDisabled && "opacity-50",
|
|
576
|
-
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
577
|
-
)
|
|
578
|
-
},
|
|
579
|
-
isChecked && /* @__PURE__ */ React9__namespace.createElement("div", { className: "size-3 rounded-full bg-primary" })
|
|
580
|
-
));
|
|
581
|
-
const labelContent = /* @__PURE__ */ React9__namespace.createElement(
|
|
582
|
-
LabelGroup,
|
|
583
|
-
{
|
|
584
|
-
variant: "text",
|
|
585
|
-
primary: option.label,
|
|
586
|
-
secondary: hasDescription ? option.description : void 0,
|
|
587
|
-
secondaryId: hasDescription ? `${radioId}-description` : void 0,
|
|
588
|
-
primaryClassName: "mb-0",
|
|
589
|
-
secondaryClassName: "text-xs opacity-75"
|
|
590
|
-
}
|
|
591
|
-
);
|
|
592
|
-
return /* @__PURE__ */ React9__namespace.createElement(
|
|
657
|
+
const hasDescription = !!option.description;
|
|
658
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
593
659
|
"label",
|
|
594
660
|
{
|
|
595
661
|
key: option.value,
|
|
596
|
-
className: cn(
|
|
597
|
-
"w-full h-full flex gap-3 p-3 duration-200",
|
|
598
|
-
useChoiceCard && "border rounded-lg hover:ring-2",
|
|
599
|
-
useChoiceCard && isChecked && "ring-2",
|
|
600
|
-
isDisabled ? "opacity-50 cursor-not-allowed hover:ring-0" : "cursor-pointer"
|
|
601
|
-
),
|
|
602
662
|
htmlFor: radioId,
|
|
603
|
-
|
|
604
|
-
|
|
663
|
+
className: cn(
|
|
664
|
+
"flex gap-3 p-3 duration-200",
|
|
665
|
+
useChoiceCard && "border rounded-lg hover:ring-2 hover:ring-ring/50",
|
|
666
|
+
useChoiceCard && isSelected && "ring-2 ring-ring",
|
|
667
|
+
useChoiceCard && error && "border-destructive",
|
|
668
|
+
isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"
|
|
669
|
+
)
|
|
605
670
|
},
|
|
606
|
-
/* @__PURE__ */
|
|
671
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
607
672
|
"div",
|
|
608
673
|
{
|
|
609
674
|
className: cn(
|
|
610
|
-
"flex w-full
|
|
675
|
+
"flex w-full gap-3",
|
|
611
676
|
useChoiceCard ? "items-start" : "items-center"
|
|
612
677
|
)
|
|
613
678
|
},
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
679
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
680
|
+
RadioGroupItem,
|
|
681
|
+
{
|
|
682
|
+
value: option.value,
|
|
683
|
+
id: radioId,
|
|
684
|
+
disabled: isDisabled,
|
|
685
|
+
className: "mt-0.5",
|
|
686
|
+
"aria-describedby": hasDescription ? `${radioId}-description` : void 0
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "flex flex-col gap-1 flex-1" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
690
|
+
Label,
|
|
691
|
+
{
|
|
692
|
+
htmlFor: radioId,
|
|
693
|
+
className: "cursor-pointer font-medium leading-none"
|
|
694
|
+
},
|
|
695
|
+
option.label
|
|
696
|
+
), option.description && /* @__PURE__ */ React17__namespace.createElement(
|
|
697
|
+
"p",
|
|
698
|
+
{
|
|
699
|
+
id: `${radioId}-description`,
|
|
700
|
+
className: "text-sm opacity-70 leading-snug"
|
|
701
|
+
},
|
|
702
|
+
option.description
|
|
703
|
+
))
|
|
617
704
|
)
|
|
618
705
|
);
|
|
619
706
|
})
|
|
620
|
-
);
|
|
707
|
+
));
|
|
621
708
|
}
|
|
622
709
|
Radio.displayName = "Radio";
|
|
710
|
+
function Switch({
|
|
711
|
+
className,
|
|
712
|
+
size = "default",
|
|
713
|
+
...props
|
|
714
|
+
}) {
|
|
715
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
716
|
+
radixUi.Switch.Root,
|
|
717
|
+
{
|
|
718
|
+
"data-slot": "switch",
|
|
719
|
+
"data-size": size,
|
|
720
|
+
className: cn(
|
|
721
|
+
// Core structure - uses CSS variables
|
|
722
|
+
"peer group/switch inline-flex shrink-0 items-center rounded-full",
|
|
723
|
+
"border border-transparent shadow-xs transition-all outline-none",
|
|
724
|
+
// State-based backgrounds - use CSS variables
|
|
725
|
+
"data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
726
|
+
// Focus state
|
|
727
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
728
|
+
// Disabled state
|
|
729
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
730
|
+
// Size variants
|
|
731
|
+
"data-[size=default]:h-[1.15rem] data-[size=default]:w-8",
|
|
732
|
+
"data-[size=sm]:h-3.5 data-[size=sm]:w-6",
|
|
733
|
+
className
|
|
734
|
+
),
|
|
735
|
+
...props
|
|
736
|
+
},
|
|
737
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
738
|
+
radixUi.Switch.Thumb,
|
|
739
|
+
{
|
|
740
|
+
"data-slot": "switch-thumb",
|
|
741
|
+
className: cn(
|
|
742
|
+
// Thumb appearance - inherits from parent theme
|
|
743
|
+
"bg-background pointer-events-none block rounded-full ring-0 transition-transform",
|
|
744
|
+
// Size variants
|
|
745
|
+
"group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3",
|
|
746
|
+
// Position based on state
|
|
747
|
+
"data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
|
748
|
+
)
|
|
749
|
+
}
|
|
750
|
+
)
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// src/inputs/Switch.tsx
|
|
755
|
+
function Switch2({
|
|
756
|
+
name,
|
|
757
|
+
value,
|
|
758
|
+
onChange,
|
|
759
|
+
onBlur,
|
|
760
|
+
disabled = false,
|
|
761
|
+
required = false,
|
|
762
|
+
error = false,
|
|
763
|
+
className = "",
|
|
764
|
+
label,
|
|
765
|
+
description,
|
|
766
|
+
size = "default",
|
|
767
|
+
...props
|
|
768
|
+
}) {
|
|
769
|
+
const switchId = props.id || `switch-${name}`;
|
|
770
|
+
const handleCheckedChange = (checked) => {
|
|
771
|
+
onChange(checked);
|
|
772
|
+
};
|
|
773
|
+
const handleBlur = () => {
|
|
774
|
+
onBlur?.();
|
|
775
|
+
};
|
|
776
|
+
const switchElement = /* @__PURE__ */ React17__namespace.createElement(
|
|
777
|
+
Switch,
|
|
778
|
+
{
|
|
779
|
+
id: switchId,
|
|
780
|
+
checked: value,
|
|
781
|
+
onCheckedChange: handleCheckedChange,
|
|
782
|
+
onBlur: handleBlur,
|
|
783
|
+
disabled,
|
|
784
|
+
size,
|
|
785
|
+
"aria-invalid": error || props["aria-invalid"],
|
|
786
|
+
"aria-describedby": description ? `${switchId}-description` : props["aria-describedby"],
|
|
787
|
+
"aria-required": required || props["aria-required"],
|
|
788
|
+
...props
|
|
789
|
+
}
|
|
790
|
+
);
|
|
791
|
+
if (!label) {
|
|
792
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className }, switchElement);
|
|
793
|
+
}
|
|
794
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
795
|
+
"label",
|
|
796
|
+
{
|
|
797
|
+
htmlFor: switchId,
|
|
798
|
+
className: cn(
|
|
799
|
+
"flex items-center gap-3 cursor-pointer",
|
|
800
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
801
|
+
className
|
|
802
|
+
)
|
|
803
|
+
},
|
|
804
|
+
switchElement,
|
|
805
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "flex flex-col gap-1" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
806
|
+
Label,
|
|
807
|
+
{
|
|
808
|
+
htmlFor: switchId,
|
|
809
|
+
className: "cursor-pointer font-medium leading-none"
|
|
810
|
+
},
|
|
811
|
+
label
|
|
812
|
+
), description && /* @__PURE__ */ React17__namespace.createElement(
|
|
813
|
+
"p",
|
|
814
|
+
{
|
|
815
|
+
id: `${switchId}-description`,
|
|
816
|
+
className: "text-sm opacity-70 leading-snug"
|
|
817
|
+
},
|
|
818
|
+
description
|
|
819
|
+
))
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
Switch2.displayName = "Switch";
|
|
623
823
|
function Select({
|
|
824
|
+
...props
|
|
825
|
+
}) {
|
|
826
|
+
return /* @__PURE__ */ React17__namespace.createElement(radixUi.Select.Root, { "data-slot": "select", ...props });
|
|
827
|
+
}
|
|
828
|
+
function SelectGroup({
|
|
829
|
+
...props
|
|
830
|
+
}) {
|
|
831
|
+
return /* @__PURE__ */ React17__namespace.createElement(radixUi.Select.Group, { "data-slot": "select-group", ...props });
|
|
832
|
+
}
|
|
833
|
+
function SelectValue({
|
|
834
|
+
...props
|
|
835
|
+
}) {
|
|
836
|
+
return /* @__PURE__ */ React17__namespace.createElement(radixUi.Select.Value, { "data-slot": "select-value", ...props });
|
|
837
|
+
}
|
|
838
|
+
function SelectTrigger({
|
|
839
|
+
className,
|
|
840
|
+
size = "default",
|
|
841
|
+
children,
|
|
842
|
+
...props
|
|
843
|
+
}) {
|
|
844
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
845
|
+
radixUi.Select.Trigger,
|
|
846
|
+
{
|
|
847
|
+
"data-slot": "select-trigger",
|
|
848
|
+
"data-size": size,
|
|
849
|
+
className: cn(
|
|
850
|
+
// Core structure - uses CSS variables
|
|
851
|
+
"flex w-fit items-center justify-between gap-2 rounded-md border border-input",
|
|
852
|
+
"bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs",
|
|
853
|
+
"transition-[color,box-shadow] outline-none",
|
|
854
|
+
// Focus state
|
|
855
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
856
|
+
// Error state
|
|
857
|
+
"aria-invalid:border-destructive aria-invalid:ring-destructive/20",
|
|
858
|
+
// Disabled state
|
|
859
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
860
|
+
// Size variants
|
|
861
|
+
"data-[size=default]:h-9 data-[size=sm]:h-8",
|
|
862
|
+
// Value styling
|
|
863
|
+
"*:data-[slot=select-value]:line-clamp-1",
|
|
864
|
+
"*:data-[slot=select-value]:flex",
|
|
865
|
+
"*:data-[slot=select-value]:items-center",
|
|
866
|
+
"*:data-[slot=select-value]:gap-2",
|
|
867
|
+
// SVG styling
|
|
868
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
869
|
+
className
|
|
870
|
+
),
|
|
871
|
+
...props
|
|
872
|
+
},
|
|
873
|
+
children,
|
|
874
|
+
/* @__PURE__ */ React17__namespace.createElement(radixUi.Select.Icon, { asChild: true }, /* @__PURE__ */ React17__namespace.createElement(
|
|
875
|
+
"svg",
|
|
876
|
+
{
|
|
877
|
+
className: "size-4 opacity-50",
|
|
878
|
+
viewBox: "0 0 24 24",
|
|
879
|
+
fill: "none",
|
|
880
|
+
stroke: "currentColor",
|
|
881
|
+
strokeWidth: "2",
|
|
882
|
+
strokeLinecap: "round",
|
|
883
|
+
strokeLinejoin: "round"
|
|
884
|
+
},
|
|
885
|
+
/* @__PURE__ */ React17__namespace.createElement("polyline", { points: "6 9 12 15 18 9" })
|
|
886
|
+
))
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
function SelectContent({
|
|
890
|
+
className,
|
|
891
|
+
children,
|
|
892
|
+
position = "item-aligned",
|
|
893
|
+
align = "center",
|
|
894
|
+
...props
|
|
895
|
+
}) {
|
|
896
|
+
return /* @__PURE__ */ React17__namespace.createElement(radixUi.Select.Portal, null, /* @__PURE__ */ React17__namespace.createElement(
|
|
897
|
+
radixUi.Select.Content,
|
|
898
|
+
{
|
|
899
|
+
"data-slot": "select-content",
|
|
900
|
+
className: cn(
|
|
901
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
902
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
903
|
+
className
|
|
904
|
+
),
|
|
905
|
+
position,
|
|
906
|
+
align,
|
|
907
|
+
...props
|
|
908
|
+
},
|
|
909
|
+
/* @__PURE__ */ React17__namespace.createElement(SelectScrollUpButton, null),
|
|
910
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
911
|
+
radixUi.Select.Viewport,
|
|
912
|
+
{
|
|
913
|
+
className: cn(
|
|
914
|
+
"p-1",
|
|
915
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
|
916
|
+
)
|
|
917
|
+
},
|
|
918
|
+
children
|
|
919
|
+
),
|
|
920
|
+
/* @__PURE__ */ React17__namespace.createElement(SelectScrollDownButton, null)
|
|
921
|
+
));
|
|
922
|
+
}
|
|
923
|
+
function SelectLabel({
|
|
924
|
+
className,
|
|
925
|
+
...props
|
|
926
|
+
}) {
|
|
927
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
928
|
+
radixUi.Select.Label,
|
|
929
|
+
{
|
|
930
|
+
"data-slot": "select-label",
|
|
931
|
+
className: cn("px-2 py-1.5 text-xs opacity-70", className),
|
|
932
|
+
...props
|
|
933
|
+
}
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
function SelectItem({
|
|
937
|
+
className,
|
|
938
|
+
children,
|
|
939
|
+
...props
|
|
940
|
+
}) {
|
|
941
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
942
|
+
radixUi.Select.Item,
|
|
943
|
+
{
|
|
944
|
+
"data-slot": "select-item",
|
|
945
|
+
className: cn(
|
|
946
|
+
// Core structure - inherits text color
|
|
947
|
+
"relative flex w-full cursor-default items-center gap-2 rounded-sm",
|
|
948
|
+
"py-1.5 pr-8 pl-2 text-sm outline-hidden select-none",
|
|
949
|
+
// Focus state - uses accent CSS variable
|
|
950
|
+
"focus:bg-accent focus:text-accent-foreground",
|
|
951
|
+
// Disabled state
|
|
952
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
953
|
+
// SVG styling
|
|
954
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
955
|
+
// Span styling
|
|
956
|
+
"*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
957
|
+
className
|
|
958
|
+
),
|
|
959
|
+
...props
|
|
960
|
+
},
|
|
961
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
962
|
+
"span",
|
|
963
|
+
{
|
|
964
|
+
"data-slot": "select-item-indicator",
|
|
965
|
+
className: "absolute right-2 flex size-3.5 items-center justify-center"
|
|
966
|
+
},
|
|
967
|
+
/* @__PURE__ */ React17__namespace.createElement(radixUi.Select.ItemIndicator, null, /* @__PURE__ */ React17__namespace.createElement(
|
|
968
|
+
"svg",
|
|
969
|
+
{
|
|
970
|
+
className: "size-4",
|
|
971
|
+
viewBox: "0 0 24 24",
|
|
972
|
+
fill: "none",
|
|
973
|
+
stroke: "currentColor",
|
|
974
|
+
strokeWidth: "3",
|
|
975
|
+
strokeLinecap: "round",
|
|
976
|
+
strokeLinejoin: "round"
|
|
977
|
+
},
|
|
978
|
+
/* @__PURE__ */ React17__namespace.createElement("polyline", { points: "20 6 9 17 4 12" })
|
|
979
|
+
))
|
|
980
|
+
),
|
|
981
|
+
/* @__PURE__ */ React17__namespace.createElement(radixUi.Select.ItemText, null, children)
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
function SelectScrollUpButton({
|
|
985
|
+
className,
|
|
986
|
+
...props
|
|
987
|
+
}) {
|
|
988
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
989
|
+
radixUi.Select.ScrollUpButton,
|
|
990
|
+
{
|
|
991
|
+
"data-slot": "select-scroll-up-button",
|
|
992
|
+
className: cn(
|
|
993
|
+
"flex cursor-default items-center justify-center py-1",
|
|
994
|
+
className
|
|
995
|
+
),
|
|
996
|
+
...props
|
|
997
|
+
},
|
|
998
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
999
|
+
"svg",
|
|
1000
|
+
{
|
|
1001
|
+
className: "size-4",
|
|
1002
|
+
viewBox: "0 0 24 24",
|
|
1003
|
+
fill: "none",
|
|
1004
|
+
stroke: "currentColor",
|
|
1005
|
+
strokeWidth: "2",
|
|
1006
|
+
strokeLinecap: "round",
|
|
1007
|
+
strokeLinejoin: "round"
|
|
1008
|
+
},
|
|
1009
|
+
/* @__PURE__ */ React17__namespace.createElement("polyline", { points: "18 15 12 9 6 15" })
|
|
1010
|
+
)
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
function SelectScrollDownButton({
|
|
1014
|
+
className,
|
|
1015
|
+
...props
|
|
1016
|
+
}) {
|
|
1017
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
1018
|
+
radixUi.Select.ScrollDownButton,
|
|
1019
|
+
{
|
|
1020
|
+
"data-slot": "select-scroll-down-button",
|
|
1021
|
+
className: cn(
|
|
1022
|
+
"flex cursor-default items-center justify-center py-1",
|
|
1023
|
+
className
|
|
1024
|
+
),
|
|
1025
|
+
...props
|
|
1026
|
+
},
|
|
1027
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1028
|
+
"svg",
|
|
1029
|
+
{
|
|
1030
|
+
className: "size-4",
|
|
1031
|
+
viewBox: "0 0 24 24",
|
|
1032
|
+
fill: "none",
|
|
1033
|
+
stroke: "currentColor",
|
|
1034
|
+
strokeWidth: "2",
|
|
1035
|
+
strokeLinecap: "round",
|
|
1036
|
+
strokeLinejoin: "round"
|
|
1037
|
+
},
|
|
1038
|
+
/* @__PURE__ */ React17__namespace.createElement("polyline", { points: "6 9 12 15 18 9" })
|
|
1039
|
+
)
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// src/inputs/Select.tsx
|
|
1044
|
+
function Select2({
|
|
624
1045
|
name,
|
|
625
1046
|
value,
|
|
626
1047
|
onChange,
|
|
@@ -631,290 +1052,104 @@ function Select({
|
|
|
631
1052
|
error = false,
|
|
632
1053
|
className = "",
|
|
633
1054
|
placeholder = "Select...",
|
|
634
|
-
searchable = true,
|
|
635
|
-
clearable = true,
|
|
636
|
-
loading = false,
|
|
637
1055
|
options = [],
|
|
638
1056
|
optionGroups = [],
|
|
639
1057
|
renderOption,
|
|
640
1058
|
...props
|
|
641
1059
|
}) {
|
|
642
|
-
const [
|
|
643
|
-
const
|
|
644
|
-
const [focusedIndex, setFocusedIndex] = React9__namespace.useState(-1);
|
|
645
|
-
const [hasInteracted, setHasInteracted] = React9__namespace.useState(false);
|
|
646
|
-
const triggerRef = React9__namespace.useRef(null);
|
|
647
|
-
const dropdownRef = React9__namespace.useRef(null);
|
|
648
|
-
const searchInputRef = React9__namespace.useRef(null);
|
|
649
|
-
const dropdownId = `${name}-dropdown`;
|
|
650
|
-
const allOptions = React9__namespace.useMemo(() => {
|
|
1060
|
+
const [hasInteracted, setHasInteracted] = React17__namespace.useState(false);
|
|
1061
|
+
const allOptions = React17__namespace.useMemo(() => {
|
|
651
1062
|
if (optionGroups.length > 0) {
|
|
652
1063
|
return optionGroups.flatMap((group) => group.options);
|
|
653
1064
|
}
|
|
654
1065
|
return options;
|
|
655
1066
|
}, [options, optionGroups]);
|
|
656
|
-
const filteredOptions = React9__namespace.useMemo(() => {
|
|
657
|
-
if (!searchQuery.trim()) {
|
|
658
|
-
return allOptions;
|
|
659
|
-
}
|
|
660
|
-
const query = searchQuery.toLowerCase();
|
|
661
|
-
return allOptions.filter((option) => {
|
|
662
|
-
const label = typeof option.label === "string" ? option.label : String(option.label);
|
|
663
|
-
return label.toLowerCase().includes(query);
|
|
664
|
-
});
|
|
665
|
-
}, [allOptions, searchQuery]);
|
|
666
|
-
const selectedOption = React9__namespace.useMemo(() => {
|
|
667
|
-
return allOptions.find((opt) => opt.value === value);
|
|
668
|
-
}, [allOptions, value]);
|
|
669
1067
|
const hasValue = Boolean(value);
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
setSearchQuery("");
|
|
674
|
-
setFocusedIndex(-1);
|
|
675
|
-
};
|
|
676
|
-
const handleClear = (e) => {
|
|
677
|
-
e.stopPropagation();
|
|
678
|
-
onChange("");
|
|
679
|
-
setSearchQuery("");
|
|
680
|
-
setFocusedIndex(-1);
|
|
1068
|
+
const selectValue = value ? String(value) : void 0;
|
|
1069
|
+
const handleValueChange = (newValue) => {
|
|
1070
|
+
onChange(newValue);
|
|
681
1071
|
};
|
|
682
|
-
const
|
|
683
|
-
if (
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
setHasInteracted(true);
|
|
688
|
-
}
|
|
689
|
-
if (newIsOpen && searchable && searchInputRef.current) {
|
|
690
|
-
setTimeout(() => searchInputRef.current?.focus(), 0);
|
|
691
|
-
}
|
|
692
|
-
if (newIsOpen) {
|
|
1072
|
+
const handleOpenChange = (open) => {
|
|
1073
|
+
if (open) {
|
|
1074
|
+
if (!hasInteracted) {
|
|
1075
|
+
setHasInteracted(true);
|
|
1076
|
+
}
|
|
693
1077
|
onFocus?.();
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
const handleSearchChange = (e) => {
|
|
697
|
-
setSearchQuery(e.target.value);
|
|
698
|
-
setFocusedIndex(0);
|
|
699
|
-
};
|
|
700
|
-
const handleKeyDown = (e) => {
|
|
701
|
-
if (disabled) return;
|
|
702
|
-
switch (e.key) {
|
|
703
|
-
case "ArrowDown":
|
|
704
|
-
e.preventDefault();
|
|
705
|
-
if (!isOpen) {
|
|
706
|
-
setIsOpen(true);
|
|
707
|
-
setFocusedIndex(0);
|
|
708
|
-
} else {
|
|
709
|
-
const enabledOptions = filteredOptions.filter((opt) => !opt.disabled);
|
|
710
|
-
if (enabledOptions.length > 0) {
|
|
711
|
-
const currentIndexInFiltered = focusedIndex;
|
|
712
|
-
const nextIndex = (currentIndexInFiltered + 1) % enabledOptions.length;
|
|
713
|
-
setFocusedIndex(filteredOptions.indexOf(enabledOptions[nextIndex]));
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
break;
|
|
717
|
-
case "ArrowUp":
|
|
718
|
-
e.preventDefault();
|
|
719
|
-
if (isOpen) {
|
|
720
|
-
const enabledOptions = filteredOptions.filter((opt) => !opt.disabled);
|
|
721
|
-
if (enabledOptions.length > 0) {
|
|
722
|
-
const currentIndexInFiltered = focusedIndex;
|
|
723
|
-
const prevIndex = (currentIndexInFiltered - 1 + enabledOptions.length) % enabledOptions.length;
|
|
724
|
-
setFocusedIndex(filteredOptions.indexOf(enabledOptions[prevIndex]));
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
break;
|
|
728
|
-
case "Enter":
|
|
729
|
-
e.preventDefault();
|
|
730
|
-
if (isOpen && focusedIndex >= 0 && focusedIndex < filteredOptions.length) {
|
|
731
|
-
const focusedOption = filteredOptions[focusedIndex];
|
|
732
|
-
if (!focusedOption.disabled) {
|
|
733
|
-
handleSelect(focusedOption.value);
|
|
734
|
-
}
|
|
735
|
-
} else if (!isOpen) {
|
|
736
|
-
setIsOpen(true);
|
|
737
|
-
}
|
|
738
|
-
break;
|
|
739
|
-
case "Escape":
|
|
740
|
-
e.preventDefault();
|
|
741
|
-
if (isOpen) {
|
|
742
|
-
setIsOpen(false);
|
|
743
|
-
setSearchQuery("");
|
|
744
|
-
setFocusedIndex(-1);
|
|
745
|
-
}
|
|
746
|
-
break;
|
|
747
|
-
case " ":
|
|
748
|
-
if (!isOpen && !searchable) {
|
|
749
|
-
e.preventDefault();
|
|
750
|
-
setIsOpen(true);
|
|
751
|
-
}
|
|
752
|
-
break;
|
|
753
|
-
default:
|
|
754
|
-
if (!searchable && e.key.length === 1 && !e.ctrlKey && !e.metaKey) {
|
|
755
|
-
const char = e.key.toLowerCase();
|
|
756
|
-
const matchingOption = filteredOptions.find((opt) => {
|
|
757
|
-
const label = typeof opt.label === "string" ? opt.label : String(opt.label);
|
|
758
|
-
return label.toLowerCase().startsWith(char) && !opt.disabled;
|
|
759
|
-
});
|
|
760
|
-
if (matchingOption) {
|
|
761
|
-
handleSelect(matchingOption.value);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
break;
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
|
-
const handleBlur = (event) => {
|
|
768
|
-
const nextTarget = event?.relatedTarget;
|
|
769
|
-
const focusStayedInside = !!triggerRef.current && triggerRef.current.contains(nextTarget) || !!dropdownRef.current && dropdownRef.current.contains(nextTarget);
|
|
770
|
-
if (!nextTarget || !focusStayedInside) {
|
|
1078
|
+
} else if (hasInteracted) {
|
|
771
1079
|
onBlur?.();
|
|
772
1080
|
}
|
|
773
1081
|
};
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
1082
|
+
return /* @__PURE__ */ React17__namespace.createElement(React17__namespace.Fragment, null, /* @__PURE__ */ React17__namespace.createElement(
|
|
1083
|
+
"input",
|
|
1084
|
+
{
|
|
1085
|
+
type: "hidden",
|
|
1086
|
+
name,
|
|
1087
|
+
value: value ?? "",
|
|
1088
|
+
disabled,
|
|
1089
|
+
required,
|
|
1090
|
+
tabIndex: -1,
|
|
1091
|
+
"aria-hidden": "true",
|
|
1092
|
+
style: {
|
|
1093
|
+
position: "absolute",
|
|
1094
|
+
width: "1px",
|
|
1095
|
+
height: "1px",
|
|
1096
|
+
padding: "0",
|
|
1097
|
+
margin: "-1px",
|
|
1098
|
+
overflow: "hidden",
|
|
1099
|
+
clip: "rect(0, 0, 0, 0)",
|
|
1100
|
+
whiteSpace: "nowrap",
|
|
1101
|
+
border: "0"
|
|
1102
|
+
}
|
|
781
1103
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
capture: true
|
|
785
|
-
});
|
|
786
|
-
const combinedClassName = cn("relative w-full", className);
|
|
787
|
-
return /* @__PURE__ */ React9__namespace.createElement(
|
|
788
|
-
"div",
|
|
1104
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
1105
|
+
Select,
|
|
789
1106
|
{
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1107
|
+
value: selectValue,
|
|
1108
|
+
onValueChange: handleValueChange,
|
|
1109
|
+
onOpenChange: handleOpenChange,
|
|
1110
|
+
disabled
|
|
793
1111
|
},
|
|
794
|
-
/* @__PURE__ */
|
|
795
|
-
|
|
796
|
-
{
|
|
797
|
-
name,
|
|
798
|
-
value,
|
|
799
|
-
onChange: () => {
|
|
800
|
-
},
|
|
801
|
-
disabled,
|
|
802
|
-
required,
|
|
803
|
-
"aria-hidden": "true",
|
|
804
|
-
tabIndex: -1,
|
|
805
|
-
style: { display: "none" }
|
|
806
|
-
},
|
|
807
|
-
/* @__PURE__ */ React9__namespace.createElement("option", { value: "" }, "Select..."),
|
|
808
|
-
allOptions.map((option) => /* @__PURE__ */ React9__namespace.createElement("option", { key: option.value, value: option.value }, typeof option.label === "string" ? option.label : option.value))
|
|
809
|
-
),
|
|
810
|
-
/* @__PURE__ */ React9__namespace.createElement(
|
|
811
|
-
"div",
|
|
1112
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1113
|
+
SelectTrigger,
|
|
812
1114
|
{
|
|
813
|
-
ref: triggerRef,
|
|
814
1115
|
className: cn(
|
|
815
|
-
|
|
816
|
-
"cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
1116
|
+
// Valid value indicator - ring-2 when has value and no error
|
|
817
1117
|
!error && hasValue && "ring-2 ring-ring",
|
|
818
|
-
|
|
819
|
-
|
|
1118
|
+
// Error state - handled by SelectTrigger via aria-invalid
|
|
1119
|
+
className
|
|
820
1120
|
),
|
|
821
|
-
onClick: handleToggle,
|
|
822
|
-
role: "combobox",
|
|
823
|
-
"aria-expanded": isOpen,
|
|
824
|
-
"aria-controls": dropdownId,
|
|
825
1121
|
"aria-invalid": error || props["aria-invalid"],
|
|
826
1122
|
"aria-describedby": props["aria-describedby"],
|
|
827
|
-
"aria-required": required || props["aria-required"]
|
|
828
|
-
"aria-disabled": disabled,
|
|
829
|
-
tabIndex: disabled ? -1 : 0
|
|
1123
|
+
"aria-required": required || props["aria-required"]
|
|
830
1124
|
},
|
|
831
|
-
/* @__PURE__ */
|
|
832
|
-
|
|
833
|
-
|
|
1125
|
+
/* @__PURE__ */ React17__namespace.createElement(SelectValue, { placeholder })
|
|
1126
|
+
),
|
|
1127
|
+
/* @__PURE__ */ React17__namespace.createElement(SelectContent, null, optionGroups.length > 0 ? (
|
|
1128
|
+
// Render grouped options
|
|
1129
|
+
optionGroups.map((group, groupIndex) => /* @__PURE__ */ React17__namespace.createElement(SelectGroup, { key: groupIndex }, /* @__PURE__ */ React17__namespace.createElement(SelectLabel, null, group.label), group.options.map((option) => /* @__PURE__ */ React17__namespace.createElement(
|
|
1130
|
+
SelectItem,
|
|
834
1131
|
{
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
"aria-label": "Clear selection",
|
|
839
|
-
tabIndex: -1
|
|
1132
|
+
key: option.value,
|
|
1133
|
+
value: option.value,
|
|
1134
|
+
disabled: option.disabled
|
|
840
1135
|
},
|
|
841
|
-
|
|
842
|
-
)
|
|
843
|
-
)
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
ref: dropdownRef,
|
|
848
|
-
id: dropdownId,
|
|
849
|
-
className: "absolute z-50 top-full mt-1 min-w-full overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",
|
|
850
|
-
role: "listbox"
|
|
851
|
-
},
|
|
852
|
-
searchable && /* @__PURE__ */ React9__namespace.createElement("div", { className: "p-2 border-b border-border" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
853
|
-
"input",
|
|
1136
|
+
renderOption ? renderOption(option) : option.label
|
|
1137
|
+
))))
|
|
1138
|
+
) : (
|
|
1139
|
+
// Render flat options
|
|
1140
|
+
allOptions.map((option) => /* @__PURE__ */ React17__namespace.createElement(
|
|
1141
|
+
SelectItem,
|
|
854
1142
|
{
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
),
|
|
861
|
-
placeholder: "Search...",
|
|
862
|
-
value: searchQuery,
|
|
863
|
-
onChange: handleSearchChange,
|
|
864
|
-
onClick: (e) => e.stopPropagation(),
|
|
865
|
-
"aria-label": "Search options"
|
|
866
|
-
}
|
|
867
|
-
)),
|
|
868
|
-
/* @__PURE__ */ React9__namespace.createElement("div", { className: "max-h-64 overflow-y-auto p-1" }, filteredOptions.length === 0 ? /* @__PURE__ */ React9__namespace.createElement("div", { className: "py-2 px-3 text-center text-sm " }, "No options found") : optionGroups.length > 0 ? (
|
|
869
|
-
// Render grouped options
|
|
870
|
-
optionGroups.map((group, groupIndex) => {
|
|
871
|
-
const groupOptions = group.options.filter(
|
|
872
|
-
(opt) => filteredOptions.includes(opt)
|
|
873
|
-
);
|
|
874
|
-
if (groupOptions.length === 0) return null;
|
|
875
|
-
return /* @__PURE__ */ React9__namespace.createElement("div", { key: groupIndex, className: "py-1" }, /* @__PURE__ */ React9__namespace.createElement("div", { className: "py-1.5 px-2 text-xs font-semibold " }, group.label), groupOptions.map((option) => {
|
|
876
|
-
const globalIndex = filteredOptions.indexOf(option);
|
|
877
|
-
const isSelected = value === option.value;
|
|
878
|
-
const isFocused = globalIndex === focusedIndex;
|
|
879
|
-
const isDisabled = option.disabled;
|
|
880
|
-
return /* @__PURE__ */ React9__namespace.createElement(
|
|
881
|
-
"div",
|
|
882
|
-
{
|
|
883
|
-
key: option.value,
|
|
884
|
-
className: `relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors hover:bg-muted ${isFocused ? "bg-muted" : ""} ${isSelected ? "font-medium bg-muted" : ""} ${isDisabled ? "pointer-events-none opacity-50" : ""}`,
|
|
885
|
-
onClick: () => !isDisabled && handleSelect(option.value),
|
|
886
|
-
role: "option",
|
|
887
|
-
"aria-selected": isSelected,
|
|
888
|
-
"aria-disabled": isDisabled
|
|
889
|
-
},
|
|
890
|
-
renderOption ? renderOption(option) : option.label
|
|
891
|
-
);
|
|
892
|
-
}));
|
|
893
|
-
})
|
|
894
|
-
) : (
|
|
895
|
-
// Render flat options
|
|
896
|
-
filteredOptions.map((option, index) => {
|
|
897
|
-
const isSelected = value === option.value;
|
|
898
|
-
const isFocused = index === focusedIndex;
|
|
899
|
-
const isDisabled = option.disabled;
|
|
900
|
-
return /* @__PURE__ */ React9__namespace.createElement(
|
|
901
|
-
"div",
|
|
902
|
-
{
|
|
903
|
-
key: option.value,
|
|
904
|
-
className: `relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors hover:bg-muted ${isFocused ? "bg-muted" : ""} ${isSelected ? "font-medium bg-muted" : ""} ${isDisabled ? "pointer-events-none opacity-50" : ""}`,
|
|
905
|
-
onClick: () => !isDisabled && handleSelect(option.value),
|
|
906
|
-
role: "option",
|
|
907
|
-
"aria-selected": isSelected,
|
|
908
|
-
"aria-disabled": isDisabled
|
|
909
|
-
},
|
|
910
|
-
renderOption ? renderOption(option) : option.label
|
|
911
|
-
);
|
|
912
|
-
})
|
|
1143
|
+
key: option.value,
|
|
1144
|
+
value: option.value,
|
|
1145
|
+
disabled: option.disabled
|
|
1146
|
+
},
|
|
1147
|
+
renderOption ? renderOption(option) : option.label
|
|
913
1148
|
))
|
|
914
|
-
)
|
|
915
|
-
);
|
|
1149
|
+
))
|
|
1150
|
+
));
|
|
916
1151
|
}
|
|
917
|
-
|
|
1152
|
+
Select2.displayName = "Select";
|
|
918
1153
|
function MultiSelect({
|
|
919
1154
|
name,
|
|
920
1155
|
value = [],
|
|
@@ -937,21 +1172,21 @@ function MultiSelect({
|
|
|
937
1172
|
renderValue,
|
|
938
1173
|
...props
|
|
939
1174
|
}) {
|
|
940
|
-
const [isOpen, setIsOpen] =
|
|
941
|
-
const [searchQuery, setSearchQuery] =
|
|
942
|
-
const [focusedIndex, setFocusedIndex] =
|
|
943
|
-
const [hasInteracted, setHasInteracted] =
|
|
944
|
-
const triggerRef =
|
|
945
|
-
const dropdownRef =
|
|
946
|
-
const searchInputRef =
|
|
1175
|
+
const [isOpen, setIsOpen] = React17__namespace.useState(false);
|
|
1176
|
+
const [searchQuery, setSearchQuery] = React17__namespace.useState("");
|
|
1177
|
+
const [focusedIndex, setFocusedIndex] = React17__namespace.useState(-1);
|
|
1178
|
+
const [hasInteracted, setHasInteracted] = React17__namespace.useState(false);
|
|
1179
|
+
const triggerRef = React17__namespace.useRef(null);
|
|
1180
|
+
const dropdownRef = React17__namespace.useRef(null);
|
|
1181
|
+
const searchInputRef = React17__namespace.useRef(null);
|
|
947
1182
|
const dropdownId = `${name}-dropdown`;
|
|
948
|
-
const allOptions =
|
|
1183
|
+
const allOptions = React17__namespace.useMemo(() => {
|
|
949
1184
|
if (optionGroups.length > 0) {
|
|
950
1185
|
return optionGroups.flatMap((group) => group.options);
|
|
951
1186
|
}
|
|
952
1187
|
return options;
|
|
953
1188
|
}, [options, optionGroups]);
|
|
954
|
-
const filteredOptions =
|
|
1189
|
+
const filteredOptions = React17__namespace.useMemo(() => {
|
|
955
1190
|
if (!searchQuery.trim()) {
|
|
956
1191
|
return allOptions;
|
|
957
1192
|
}
|
|
@@ -961,11 +1196,11 @@ function MultiSelect({
|
|
|
961
1196
|
return label.toLowerCase().includes(query);
|
|
962
1197
|
});
|
|
963
1198
|
}, [allOptions, searchQuery]);
|
|
964
|
-
const selectedOptions =
|
|
1199
|
+
const selectedOptions = React17__namespace.useMemo(() => {
|
|
965
1200
|
return allOptions.filter((opt) => value.includes(opt.value));
|
|
966
1201
|
}, [allOptions, value]);
|
|
967
1202
|
const hasValue = value.length > 0;
|
|
968
|
-
const isMaxReached =
|
|
1203
|
+
const isMaxReached = React17__namespace.useMemo(() => {
|
|
969
1204
|
return maxSelections !== void 0 && value.length >= maxSelections;
|
|
970
1205
|
}, [maxSelections, value.length]);
|
|
971
1206
|
const handleToggleOption = (optionValue) => {
|
|
@@ -1081,7 +1316,7 @@ function MultiSelect({
|
|
|
1081
1316
|
onBlur?.();
|
|
1082
1317
|
}
|
|
1083
1318
|
};
|
|
1084
|
-
const closeDropdown =
|
|
1319
|
+
const closeDropdown = React17__namespace.useCallback(() => {
|
|
1085
1320
|
if (!isOpen) return;
|
|
1086
1321
|
setIsOpen(false);
|
|
1087
1322
|
setSearchQuery("");
|
|
@@ -1094,14 +1329,14 @@ function MultiSelect({
|
|
|
1094
1329
|
capture: true
|
|
1095
1330
|
});
|
|
1096
1331
|
const combinedClassName = cn("relative w-full", className);
|
|
1097
|
-
return /* @__PURE__ */
|
|
1332
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
1098
1333
|
"div",
|
|
1099
1334
|
{
|
|
1100
1335
|
className: combinedClassName,
|
|
1101
1336
|
onKeyDown: handleKeyDown,
|
|
1102
1337
|
onBlur: handleBlur
|
|
1103
1338
|
},
|
|
1104
|
-
/* @__PURE__ */
|
|
1339
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1105
1340
|
"select",
|
|
1106
1341
|
{
|
|
1107
1342
|
name,
|
|
@@ -1115,10 +1350,10 @@ function MultiSelect({
|
|
|
1115
1350
|
style: { display: "none" },
|
|
1116
1351
|
multiple: true
|
|
1117
1352
|
},
|
|
1118
|
-
/* @__PURE__ */
|
|
1119
|
-
allOptions.map((option) => /* @__PURE__ */
|
|
1353
|
+
/* @__PURE__ */ React17__namespace.createElement("option", { value: "" }, "Select..."),
|
|
1354
|
+
allOptions.map((option) => /* @__PURE__ */ React17__namespace.createElement("option", { key: option.value, value: option.value }, typeof option.label === "string" ? option.label : option.value))
|
|
1120
1355
|
),
|
|
1121
|
-
/* @__PURE__ */
|
|
1356
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1122
1357
|
"div",
|
|
1123
1358
|
{
|
|
1124
1359
|
ref: triggerRef,
|
|
@@ -1139,13 +1374,13 @@ function MultiSelect({
|
|
|
1139
1374
|
"aria-disabled": disabled,
|
|
1140
1375
|
tabIndex: disabled ? -1 : 0
|
|
1141
1376
|
},
|
|
1142
|
-
/* @__PURE__ */
|
|
1377
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center flex-1 overflow-hidden" }, selectedOptions.length > 0 ? /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex flex-wrap gap-1" }, selectedOptions.map((option) => /* @__PURE__ */ React17__namespace.createElement(
|
|
1143
1378
|
"span",
|
|
1144
1379
|
{
|
|
1145
1380
|
key: option.value,
|
|
1146
1381
|
className: "inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium"
|
|
1147
1382
|
},
|
|
1148
|
-
renderValue ? renderValue(option) : /* @__PURE__ */
|
|
1383
|
+
renderValue ? renderValue(option) : /* @__PURE__ */ React17__namespace.createElement(React17__namespace.Fragment, null, /* @__PURE__ */ React17__namespace.createElement("span", { className: "max-w-40 overflow-hidden text-ellipsis whitespace-nowrap" }, option.label), !disabled && /* @__PURE__ */ React17__namespace.createElement(
|
|
1149
1384
|
"button",
|
|
1150
1385
|
{
|
|
1151
1386
|
type: "button",
|
|
@@ -1156,8 +1391,8 @@ function MultiSelect({
|
|
|
1156
1391
|
},
|
|
1157
1392
|
"\u2715"
|
|
1158
1393
|
))
|
|
1159
|
-
))) : /* @__PURE__ */
|
|
1160
|
-
/* @__PURE__ */
|
|
1394
|
+
))) : /* @__PURE__ */ React17__namespace.createElement("span", { className: "relative" }, placeholder)),
|
|
1395
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center gap-1 ml-2" }, loading && /* @__PURE__ */ React17__namespace.createElement("span", { className: "text-xs" }, "\u23F3"), clearable && value.length > 0 && !disabled && !loading && /* @__PURE__ */ React17__namespace.createElement(
|
|
1161
1396
|
"button",
|
|
1162
1397
|
{
|
|
1163
1398
|
type: "button",
|
|
@@ -1167,9 +1402,9 @@ function MultiSelect({
|
|
|
1167
1402
|
tabIndex: -1
|
|
1168
1403
|
},
|
|
1169
1404
|
"\u2715"
|
|
1170
|
-
), /* @__PURE__ */
|
|
1405
|
+
), /* @__PURE__ */ React17__namespace.createElement("span", { className: "text-xs leading-none", "aria-hidden": "true" }, isOpen ? "\u25B2" : "\u25BC"))
|
|
1171
1406
|
),
|
|
1172
|
-
isOpen && /* @__PURE__ */
|
|
1407
|
+
isOpen && /* @__PURE__ */ React17__namespace.createElement(
|
|
1173
1408
|
"div",
|
|
1174
1409
|
{
|
|
1175
1410
|
ref: dropdownRef,
|
|
@@ -1178,7 +1413,7 @@ function MultiSelect({
|
|
|
1178
1413
|
role: "listbox",
|
|
1179
1414
|
"aria-multiselectable": "true"
|
|
1180
1415
|
},
|
|
1181
|
-
searchable && /* @__PURE__ */
|
|
1416
|
+
searchable && /* @__PURE__ */ React17__namespace.createElement("div", { className: "p-2 border-b border-border" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1182
1417
|
"input",
|
|
1183
1418
|
{
|
|
1184
1419
|
ref: searchInputRef,
|
|
@@ -1194,7 +1429,7 @@ function MultiSelect({
|
|
|
1194
1429
|
"aria-label": "Search options"
|
|
1195
1430
|
}
|
|
1196
1431
|
)),
|
|
1197
|
-
showSelectAll && filteredOptions.length > 0 && /* @__PURE__ */
|
|
1432
|
+
showSelectAll && filteredOptions.length > 0 && /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex gap-2 p-2 border-b border-border" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1198
1433
|
"button",
|
|
1199
1434
|
{
|
|
1200
1435
|
type: "button",
|
|
@@ -1203,7 +1438,7 @@ function MultiSelect({
|
|
|
1203
1438
|
disabled
|
|
1204
1439
|
},
|
|
1205
1440
|
"Select All"
|
|
1206
|
-
), value.length > 0 && /* @__PURE__ */
|
|
1441
|
+
), value.length > 0 && /* @__PURE__ */ React17__namespace.createElement(
|
|
1207
1442
|
"button",
|
|
1208
1443
|
{
|
|
1209
1444
|
type: "button",
|
|
@@ -1213,20 +1448,20 @@ function MultiSelect({
|
|
|
1213
1448
|
},
|
|
1214
1449
|
"Clear All"
|
|
1215
1450
|
)),
|
|
1216
|
-
isMaxReached && /* @__PURE__ */
|
|
1217
|
-
/* @__PURE__ */
|
|
1451
|
+
isMaxReached && /* @__PURE__ */ React17__namespace.createElement("div", { className: "px-2 py-1 text-xs font-medium text-amber-600 bg-destructive/80 text-destructive-foreground border-b border-destructive" }, "Maximum ", maxSelections, " selection", maxSelections !== 1 ? "s" : "", " ", "reached"),
|
|
1452
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "max-h-64 overflow-y-auto p-1" }, filteredOptions.length === 0 ? /* @__PURE__ */ React17__namespace.createElement("div", { className: "px-2 py-1 text-center text-sm" }, "No options found") : optionGroups.length > 0 ? (
|
|
1218
1453
|
// Render grouped options
|
|
1219
1454
|
optionGroups.map((group, groupIndex) => {
|
|
1220
1455
|
const groupOptions = group.options.filter(
|
|
1221
1456
|
(opt) => filteredOptions.includes(opt)
|
|
1222
1457
|
);
|
|
1223
1458
|
if (groupOptions.length === 0) return null;
|
|
1224
|
-
return /* @__PURE__ */
|
|
1459
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { key: groupIndex, className: "py-1" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "py-1.5 px-2 text-xs font-semibold " }, group.label), groupOptions.map((option) => {
|
|
1225
1460
|
const globalIndex = filteredOptions.indexOf(option);
|
|
1226
1461
|
const isSelected = value.includes(option.value);
|
|
1227
1462
|
const isFocused = globalIndex === focusedIndex;
|
|
1228
1463
|
const isDisabled = option.disabled || isMaxReached && !isSelected;
|
|
1229
|
-
return /* @__PURE__ */
|
|
1464
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
1230
1465
|
"div",
|
|
1231
1466
|
{
|
|
1232
1467
|
key: option.value,
|
|
@@ -1241,8 +1476,8 @@ function MultiSelect({
|
|
|
1241
1476
|
"aria-selected": isSelected,
|
|
1242
1477
|
"aria-disabled": isDisabled
|
|
1243
1478
|
},
|
|
1244
|
-
/* @__PURE__ */
|
|
1245
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ React17__namespace.createElement("span", { className: "text-base leading-none" }, isSelected ? "\u2611" : "\u2610"),
|
|
1480
|
+
/* @__PURE__ */ React17__namespace.createElement("span", { className: "flex-1" }, renderOption ? renderOption(option) : option.label)
|
|
1246
1481
|
);
|
|
1247
1482
|
}));
|
|
1248
1483
|
})
|
|
@@ -1252,7 +1487,7 @@ function MultiSelect({
|
|
|
1252
1487
|
const isSelected = value.includes(option.value);
|
|
1253
1488
|
const isFocused = index === focusedIndex;
|
|
1254
1489
|
const isDisabled = option.disabled || isMaxReached && !isSelected;
|
|
1255
|
-
return /* @__PURE__ */
|
|
1490
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
1256
1491
|
"div",
|
|
1257
1492
|
{
|
|
1258
1493
|
key: option.value,
|
|
@@ -1267,8 +1502,8 @@ function MultiSelect({
|
|
|
1267
1502
|
"aria-selected": isSelected,
|
|
1268
1503
|
"aria-disabled": isDisabled
|
|
1269
1504
|
},
|
|
1270
|
-
/* @__PURE__ */
|
|
1271
|
-
/* @__PURE__ */
|
|
1505
|
+
/* @__PURE__ */ React17__namespace.createElement("span", { className: "text-base leading-none" }, isSelected ? "\u2611" : "\u2610"),
|
|
1506
|
+
/* @__PURE__ */ React17__namespace.createElement("span", { className: "flex-1" }, renderOption ? renderOption(option) : option.label)
|
|
1272
1507
|
);
|
|
1273
1508
|
})
|
|
1274
1509
|
))
|
|
@@ -1301,14 +1536,14 @@ function FileInput({
|
|
|
1301
1536
|
onFileRemove,
|
|
1302
1537
|
...props
|
|
1303
1538
|
}) {
|
|
1304
|
-
const inputRef =
|
|
1305
|
-
const [dragActive, setDragActive] =
|
|
1306
|
-
const [cropperOpen, setCropperOpen] =
|
|
1307
|
-
const [imageToCrop, setImageToCrop] =
|
|
1308
|
-
const [crop, setCrop] =
|
|
1309
|
-
const [zoom, setZoom] =
|
|
1310
|
-
const [croppedAreaPixels, setCroppedAreaPixels] =
|
|
1311
|
-
const validateFile =
|
|
1539
|
+
const inputRef = React17__namespace.useRef(null);
|
|
1540
|
+
const [dragActive, setDragActive] = React17__namespace.useState(false);
|
|
1541
|
+
const [cropperOpen, setCropperOpen] = React17__namespace.useState(false);
|
|
1542
|
+
const [imageToCrop, setImageToCrop] = React17__namespace.useState(null);
|
|
1543
|
+
const [crop, setCrop] = React17__namespace.useState({ x: 0, y: 0 });
|
|
1544
|
+
const [zoom, setZoom] = React17__namespace.useState(1);
|
|
1545
|
+
const [croppedAreaPixels, setCroppedAreaPixels] = React17__namespace.useState(null);
|
|
1546
|
+
const validateFile = React17__namespace.useCallback(
|
|
1312
1547
|
(file) => {
|
|
1313
1548
|
if (accept) {
|
|
1314
1549
|
const acceptedTypes = accept.split(",").map((t) => t.trim());
|
|
@@ -1343,7 +1578,7 @@ function FileInput({
|
|
|
1343
1578
|
},
|
|
1344
1579
|
[accept, maxSize]
|
|
1345
1580
|
);
|
|
1346
|
-
const handleFiles =
|
|
1581
|
+
const handleFiles = React17__namespace.useCallback(
|
|
1347
1582
|
(fileList) => {
|
|
1348
1583
|
if (!fileList || fileList.length === 0) return;
|
|
1349
1584
|
const newFiles = Array.from(fileList);
|
|
@@ -1394,7 +1629,7 @@ function FileInput({
|
|
|
1394
1629
|
onValidationError
|
|
1395
1630
|
]
|
|
1396
1631
|
);
|
|
1397
|
-
const createCroppedImage =
|
|
1632
|
+
const createCroppedImage = React17__namespace.useCallback(
|
|
1398
1633
|
async (imageUrl, cropArea) => {
|
|
1399
1634
|
return new Promise((resolve, reject) => {
|
|
1400
1635
|
const image = new Image();
|
|
@@ -1438,7 +1673,7 @@ function FileInput({
|
|
|
1438
1673
|
},
|
|
1439
1674
|
[]
|
|
1440
1675
|
);
|
|
1441
|
-
const handleCropSave =
|
|
1676
|
+
const handleCropSave = React17__namespace.useCallback(async () => {
|
|
1442
1677
|
if (!imageToCrop || !croppedAreaPixels) return;
|
|
1443
1678
|
try {
|
|
1444
1679
|
const croppedBlob = await createCroppedImage(
|
|
@@ -1471,7 +1706,7 @@ function FileInput({
|
|
|
1471
1706
|
onChange,
|
|
1472
1707
|
multiple
|
|
1473
1708
|
]);
|
|
1474
|
-
const handleCropCancel =
|
|
1709
|
+
const handleCropCancel = React17__namespace.useCallback(() => {
|
|
1475
1710
|
if (imageToCrop) {
|
|
1476
1711
|
URL.revokeObjectURL(imageToCrop.url);
|
|
1477
1712
|
}
|
|
@@ -1481,13 +1716,13 @@ function FileInput({
|
|
|
1481
1716
|
setZoom(1);
|
|
1482
1717
|
setCroppedAreaPixels(null);
|
|
1483
1718
|
}, [imageToCrop]);
|
|
1484
|
-
const onCropChange =
|
|
1719
|
+
const onCropChange = React17__namespace.useCallback((crop2) => {
|
|
1485
1720
|
setCrop(crop2);
|
|
1486
1721
|
}, []);
|
|
1487
|
-
const onZoomChange =
|
|
1722
|
+
const onZoomChange = React17__namespace.useCallback((zoom2) => {
|
|
1488
1723
|
setZoom(zoom2);
|
|
1489
1724
|
}, []);
|
|
1490
|
-
const onCropCompleteInternal =
|
|
1725
|
+
const onCropCompleteInternal = React17__namespace.useCallback(
|
|
1491
1726
|
(_, croppedAreaPixels2) => {
|
|
1492
1727
|
setCroppedAreaPixels(croppedAreaPixels2);
|
|
1493
1728
|
},
|
|
@@ -1548,7 +1783,7 @@ function FileInput({
|
|
|
1548
1783
|
}
|
|
1549
1784
|
return null;
|
|
1550
1785
|
};
|
|
1551
|
-
|
|
1786
|
+
React17__namespace.useEffect(() => {
|
|
1552
1787
|
return () => {
|
|
1553
1788
|
value.forEach((file) => {
|
|
1554
1789
|
const previewUrl = getPreviewUrl(file);
|
|
@@ -1562,7 +1797,7 @@ function FileInput({
|
|
|
1562
1797
|
};
|
|
1563
1798
|
}, [value, imageToCrop]);
|
|
1564
1799
|
const combinedClassName = `${className}`.trim();
|
|
1565
|
-
return /* @__PURE__ */
|
|
1800
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: combinedClassName }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1566
1801
|
"input",
|
|
1567
1802
|
{
|
|
1568
1803
|
ref: inputRef,
|
|
@@ -1579,7 +1814,7 @@ function FileInput({
|
|
|
1579
1814
|
"aria-required": required || props["aria-required"],
|
|
1580
1815
|
style: { display: "none" }
|
|
1581
1816
|
}
|
|
1582
|
-
), /* @__PURE__ */
|
|
1817
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
1583
1818
|
"div",
|
|
1584
1819
|
{
|
|
1585
1820
|
className: `flex min-h-32 w-full cursor-pointer items-center justify-center rounded-md border-2 border-dashed border-input bg-transparent p-6 transition-colors hover:bg-primary/50 hover:border-ring ${dragActive ? "bg-primary text-primary-foreground border-ring" : ""} ${disabled ? "cursor-not-allowed opacity-50" : ""} ${error ? "border-destructive" : ""}`,
|
|
@@ -1594,7 +1829,7 @@ function FileInput({
|
|
|
1594
1829
|
"aria-label": placeholder,
|
|
1595
1830
|
"aria-disabled": disabled
|
|
1596
1831
|
},
|
|
1597
|
-
/* @__PURE__ */
|
|
1832
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "flex flex-col items-center gap-2 text-center" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1598
1833
|
"svg",
|
|
1599
1834
|
{
|
|
1600
1835
|
width: "48",
|
|
@@ -1607,19 +1842,19 @@ function FileInput({
|
|
|
1607
1842
|
strokeLinejoin: "round",
|
|
1608
1843
|
"aria-hidden": "true"
|
|
1609
1844
|
},
|
|
1610
|
-
/* @__PURE__ */
|
|
1611
|
-
/* @__PURE__ */
|
|
1612
|
-
/* @__PURE__ */
|
|
1613
|
-
), /* @__PURE__ */
|
|
1614
|
-
), value.length > 0 && /* @__PURE__ */
|
|
1845
|
+
/* @__PURE__ */ React17__namespace.createElement("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1846
|
+
/* @__PURE__ */ React17__namespace.createElement("polyline", { points: "17 8 12 3 7 8" }),
|
|
1847
|
+
/* @__PURE__ */ React17__namespace.createElement("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
|
|
1848
|
+
), /* @__PURE__ */ React17__namespace.createElement("p", { className: "text-sm font-medium" }, value.length > 0 ? `${value.length} file(s) selected` : placeholder), accept && /* @__PURE__ */ React17__namespace.createElement("p", { className: "text-xs" }, "Accepted: ", accept), maxSize && /* @__PURE__ */ React17__namespace.createElement("p", { className: "text-xs " }, "Max size: ", formatFileSize(maxSize)))
|
|
1849
|
+
), value.length > 0 && /* @__PURE__ */ React17__namespace.createElement("ul", { className: "flex flex-col gap-2 mt-4", role: "list" }, value.map((file, index) => {
|
|
1615
1850
|
const previewUrl = showPreview ? getPreviewUrl(file) : null;
|
|
1616
|
-
return /* @__PURE__ */
|
|
1851
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
1617
1852
|
"li",
|
|
1618
1853
|
{
|
|
1619
1854
|
key: `${file.name}-${index}`,
|
|
1620
1855
|
className: "flex items-center gap-3 p-3 rounded-md border border-border bg-card text-card-foreground hover:bg-primary/50 transition-colors"
|
|
1621
1856
|
},
|
|
1622
|
-
previewUrl && /* @__PURE__ */
|
|
1857
|
+
previewUrl && /* @__PURE__ */ React17__namespace.createElement(
|
|
1623
1858
|
"img",
|
|
1624
1859
|
{
|
|
1625
1860
|
src: previewUrl,
|
|
@@ -1629,7 +1864,7 @@ function FileInput({
|
|
|
1629
1864
|
height: "48"
|
|
1630
1865
|
}
|
|
1631
1866
|
),
|
|
1632
|
-
/* @__PURE__ */
|
|
1867
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "flex flex-col flex-1 min-w-0" }, /* @__PURE__ */ React17__namespace.createElement("span", { className: "text-sm font-medium truncate" }, file.name), /* @__PURE__ */ React17__namespace.createElement("span", { className: "text-xs" }, formatFileSize(file.size)), showProgress && uploadProgress[file.name] !== void 0 && /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center gap-2 mt-1" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1633
1868
|
"div",
|
|
1634
1869
|
{
|
|
1635
1870
|
className: "h-1.5 bg-muted rounded-full overflow-hidden flex-1",
|
|
@@ -1639,15 +1874,15 @@ function FileInput({
|
|
|
1639
1874
|
"aria-valuemax": 100,
|
|
1640
1875
|
"aria-label": `Upload progress: ${uploadProgress[file.name]}%`
|
|
1641
1876
|
},
|
|
1642
|
-
/* @__PURE__ */
|
|
1877
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1643
1878
|
"div",
|
|
1644
1879
|
{
|
|
1645
1880
|
className: "h-full bg-primary transition-all",
|
|
1646
1881
|
style: { width: `${uploadProgress[file.name]}%` }
|
|
1647
1882
|
}
|
|
1648
1883
|
)
|
|
1649
|
-
), /* @__PURE__ */
|
|
1650
|
-
enableCropping && file.type.startsWith("image/") && /* @__PURE__ */
|
|
1884
|
+
), /* @__PURE__ */ React17__namespace.createElement("span", { className: "text-xs " }, uploadProgress[file.name], "%"))),
|
|
1885
|
+
enableCropping && file.type.startsWith("image/") && /* @__PURE__ */ React17__namespace.createElement(
|
|
1651
1886
|
"button",
|
|
1652
1887
|
{
|
|
1653
1888
|
type: "button",
|
|
@@ -1659,7 +1894,7 @@ function FileInput({
|
|
|
1659
1894
|
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground transition-colors",
|
|
1660
1895
|
"aria-label": `Crop ${file.name}`
|
|
1661
1896
|
},
|
|
1662
|
-
/* @__PURE__ */
|
|
1897
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1663
1898
|
"svg",
|
|
1664
1899
|
{
|
|
1665
1900
|
width: "20",
|
|
@@ -1672,11 +1907,11 @@ function FileInput({
|
|
|
1672
1907
|
strokeLinejoin: "round",
|
|
1673
1908
|
"aria-hidden": "true"
|
|
1674
1909
|
},
|
|
1675
|
-
/* @__PURE__ */
|
|
1676
|
-
/* @__PURE__ */
|
|
1910
|
+
/* @__PURE__ */ React17__namespace.createElement("path", { d: "M6.13 1L6 16a2 2 0 0 0 2 2h15" }),
|
|
1911
|
+
/* @__PURE__ */ React17__namespace.createElement("path", { d: "M1 6.13L16 6a2 2 0 0 1 2 2v15" })
|
|
1677
1912
|
)
|
|
1678
1913
|
),
|
|
1679
|
-
/* @__PURE__ */
|
|
1914
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1680
1915
|
"button",
|
|
1681
1916
|
{
|
|
1682
1917
|
type: "button",
|
|
@@ -1688,7 +1923,7 @@ function FileInput({
|
|
|
1688
1923
|
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground transition-colors",
|
|
1689
1924
|
"aria-label": `Remove ${file.name}`
|
|
1690
1925
|
},
|
|
1691
|
-
/* @__PURE__ */
|
|
1926
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1692
1927
|
"svg",
|
|
1693
1928
|
{
|
|
1694
1929
|
width: "20",
|
|
@@ -1701,19 +1936,19 @@ function FileInput({
|
|
|
1701
1936
|
strokeLinejoin: "round",
|
|
1702
1937
|
"aria-hidden": "true"
|
|
1703
1938
|
},
|
|
1704
|
-
/* @__PURE__ */
|
|
1705
|
-
/* @__PURE__ */
|
|
1939
|
+
/* @__PURE__ */ React17__namespace.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1940
|
+
/* @__PURE__ */ React17__namespace.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1706
1941
|
)
|
|
1707
1942
|
)
|
|
1708
1943
|
);
|
|
1709
|
-
})), cropperOpen && imageToCrop && /* @__PURE__ */
|
|
1944
|
+
})), cropperOpen && imageToCrop && /* @__PURE__ */ React17__namespace.createElement("div", { className: "fixed inset-0 z-50 flex items-center justify-center" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1710
1945
|
"div",
|
|
1711
1946
|
{
|
|
1712
1947
|
className: "absolute inset-0 bg-black/50",
|
|
1713
1948
|
onClick: handleCropCancel,
|
|
1714
1949
|
"aria-label": "Close cropper"
|
|
1715
1950
|
}
|
|
1716
|
-
), /* @__PURE__ */
|
|
1951
|
+
), /* @__PURE__ */ React17__namespace.createElement("div", { className: "relative bg-popover border border-border rounded-lg shadow-lg max-w-3xl w-full mx-4" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center justify-between p-4 border-b border-border" }, /* @__PURE__ */ React17__namespace.createElement("h3", { className: "text-lg font-semibold" }, "Crop Image"), /* @__PURE__ */ React17__namespace.createElement(
|
|
1717
1952
|
"button",
|
|
1718
1953
|
{
|
|
1719
1954
|
type: "button",
|
|
@@ -1722,7 +1957,7 @@ function FileInput({
|
|
|
1722
1957
|
"aria-label": "Close"
|
|
1723
1958
|
},
|
|
1724
1959
|
"\u2715"
|
|
1725
|
-
)), /* @__PURE__ */
|
|
1960
|
+
)), /* @__PURE__ */ React17__namespace.createElement("div", { className: "p-4" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1726
1961
|
"div",
|
|
1727
1962
|
{
|
|
1728
1963
|
className: "relative w-full h-96 bg-muted rounded-md overflow-hidden",
|
|
@@ -1744,7 +1979,7 @@ function FileInput({
|
|
|
1744
1979
|
document.addEventListener("mouseup", handleMouseUp);
|
|
1745
1980
|
}
|
|
1746
1981
|
},
|
|
1747
|
-
/* @__PURE__ */
|
|
1982
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1748
1983
|
"img",
|
|
1749
1984
|
{
|
|
1750
1985
|
src: imageToCrop.url,
|
|
@@ -1779,7 +2014,7 @@ function FileInput({
|
|
|
1779
2014
|
}
|
|
1780
2015
|
}
|
|
1781
2016
|
),
|
|
1782
|
-
/* @__PURE__ */
|
|
2017
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
1783
2018
|
"div",
|
|
1784
2019
|
{
|
|
1785
2020
|
className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 border-2 border-primary rounded pointer-events-none",
|
|
@@ -1788,9 +2023,9 @@ function FileInput({
|
|
|
1788
2023
|
aspectRatio: cropAspectRatio ? String(cropAspectRatio) : void 0
|
|
1789
2024
|
}
|
|
1790
2025
|
},
|
|
1791
|
-
/* @__PURE__ */
|
|
2026
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { className: "absolute inset-0 grid grid-cols-3 grid-rows-3" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-b border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-b border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-r border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "border-r border-primary/30" }), /* @__PURE__ */ React17__namespace.createElement("div", null))
|
|
1792
2027
|
)
|
|
1793
|
-
), /* @__PURE__ */
|
|
2028
|
+
), /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center gap-3 mt-4" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1794
2029
|
"label",
|
|
1795
2030
|
{
|
|
1796
2031
|
htmlFor: "zoom-slider",
|
|
@@ -1799,7 +2034,7 @@ function FileInput({
|
|
|
1799
2034
|
"Zoom: ",
|
|
1800
2035
|
zoom.toFixed(1),
|
|
1801
2036
|
"x"
|
|
1802
|
-
), /* @__PURE__ */
|
|
2037
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
1803
2038
|
"input",
|
|
1804
2039
|
{
|
|
1805
2040
|
id: "zoom-slider",
|
|
@@ -1812,7 +2047,7 @@ function FileInput({
|
|
|
1812
2047
|
className: "flex-1 h-2 bg-muted rounded-lg appearance-none cursor-pointer",
|
|
1813
2048
|
"aria-label": "Zoom level"
|
|
1814
2049
|
}
|
|
1815
|
-
))), /* @__PURE__ */
|
|
2050
|
+
))), /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center justify-end gap-2 p-4 border-t border-border" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1816
2051
|
"button",
|
|
1817
2052
|
{
|
|
1818
2053
|
type: "button",
|
|
@@ -1820,7 +2055,7 @@ function FileInput({
|
|
|
1820
2055
|
onClick: handleCropCancel
|
|
1821
2056
|
},
|
|
1822
2057
|
"Cancel"
|
|
1823
|
-
), /* @__PURE__ */
|
|
2058
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
1824
2059
|
"button",
|
|
1825
2060
|
{
|
|
1826
2061
|
type: "button",
|
|
@@ -1862,14 +2097,14 @@ function DatePicker({
|
|
|
1862
2097
|
showIcon = true,
|
|
1863
2098
|
...props
|
|
1864
2099
|
}) {
|
|
1865
|
-
const [isOpen, setIsOpen] =
|
|
1866
|
-
const [hasInteracted, setHasInteracted] =
|
|
1867
|
-
const [selectedMonth, setSelectedMonth] =
|
|
2100
|
+
const [isOpen, setIsOpen] = React17__namespace.useState(false);
|
|
2101
|
+
const [hasInteracted, setHasInteracted] = React17__namespace.useState(false);
|
|
2102
|
+
const [selectedMonth, setSelectedMonth] = React17__namespace.useState(
|
|
1868
2103
|
value || /* @__PURE__ */ new Date()
|
|
1869
2104
|
);
|
|
1870
|
-
const inputRef =
|
|
1871
|
-
const dropdownRef =
|
|
1872
|
-
|
|
2105
|
+
const inputRef = React17__namespace.useRef(null);
|
|
2106
|
+
const dropdownRef = React17__namespace.useRef(null);
|
|
2107
|
+
React17__namespace.useEffect(() => {
|
|
1873
2108
|
if (value) {
|
|
1874
2109
|
setSelectedMonth(value);
|
|
1875
2110
|
}
|
|
@@ -1901,7 +2136,7 @@ function DatePicker({
|
|
|
1901
2136
|
if (isDateDisabled && isDateDisabled(date)) return true;
|
|
1902
2137
|
return false;
|
|
1903
2138
|
};
|
|
1904
|
-
const closeCalendar =
|
|
2139
|
+
const closeCalendar = React17__namespace.useCallback(() => {
|
|
1905
2140
|
if (!isOpen) return;
|
|
1906
2141
|
setIsOpen(false);
|
|
1907
2142
|
if (hasInteracted) {
|
|
@@ -1955,7 +2190,7 @@ function DatePicker({
|
|
|
1955
2190
|
const handleNextMonth = () => {
|
|
1956
2191
|
setSelectedMonth(new Date(year, month + 1, 1));
|
|
1957
2192
|
};
|
|
1958
|
-
return /* @__PURE__ */
|
|
2193
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { role: "grid", "aria-label": "Calendar", className: "w-[248px] max-w-full" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center justify-between pb-3" }, /* @__PURE__ */ React17__namespace.createElement(
|
|
1959
2194
|
"button",
|
|
1960
2195
|
{
|
|
1961
2196
|
type: "button",
|
|
@@ -1964,7 +2199,7 @@ function DatePicker({
|
|
|
1964
2199
|
"aria-label": "Previous month"
|
|
1965
2200
|
},
|
|
1966
2201
|
"\u2039"
|
|
1967
|
-
), /* @__PURE__ */
|
|
2202
|
+
), /* @__PURE__ */ React17__namespace.createElement("div", { className: "font-medium text-sm" }, `${monthNames[month]} ${year}`), /* @__PURE__ */ React17__namespace.createElement(
|
|
1968
2203
|
"button",
|
|
1969
2204
|
{
|
|
1970
2205
|
type: "button",
|
|
@@ -1973,13 +2208,13 @@ function DatePicker({
|
|
|
1973
2208
|
"aria-label": "Next month"
|
|
1974
2209
|
},
|
|
1975
2210
|
"\u203A"
|
|
1976
|
-
)), /* @__PURE__ */
|
|
2211
|
+
)), /* @__PURE__ */ React17__namespace.createElement(
|
|
1977
2212
|
"div",
|
|
1978
2213
|
{
|
|
1979
2214
|
className: "grid gap-1 text-xs text-muted-foreground",
|
|
1980
2215
|
style: dayGridStyle
|
|
1981
2216
|
},
|
|
1982
|
-
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */
|
|
2217
|
+
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React17__namespace.createElement(
|
|
1983
2218
|
"div",
|
|
1984
2219
|
{
|
|
1985
2220
|
key: day,
|
|
@@ -1987,14 +2222,14 @@ function DatePicker({
|
|
|
1987
2222
|
},
|
|
1988
2223
|
day
|
|
1989
2224
|
))
|
|
1990
|
-
), /* @__PURE__ */
|
|
2225
|
+
), /* @__PURE__ */ React17__namespace.createElement("div", { className: "grid gap-1", style: dayGridStyle }, days.map((date, index) => {
|
|
1991
2226
|
if (!date) {
|
|
1992
|
-
return /* @__PURE__ */
|
|
2227
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { key: `empty-${index}`, className: "h-8 w-8" });
|
|
1993
2228
|
}
|
|
1994
2229
|
const isSelected = value && date.toDateString() === value.toDateString();
|
|
1995
2230
|
const isToday = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
1996
2231
|
const disabled2 = isDisabled(date);
|
|
1997
|
-
return /* @__PURE__ */
|
|
2232
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
1998
2233
|
"button",
|
|
1999
2234
|
{
|
|
2000
2235
|
key: date.toISOString(),
|
|
@@ -2015,20 +2250,20 @@ function DatePicker({
|
|
|
2015
2250
|
})));
|
|
2016
2251
|
};
|
|
2017
2252
|
const combinedClassName = cn("relative", className);
|
|
2018
|
-
return /* @__PURE__ */
|
|
2253
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: combinedClassName, onBlur: handleBlur }, /* @__PURE__ */ React17__namespace.createElement(
|
|
2019
2254
|
"input",
|
|
2020
2255
|
{
|
|
2021
2256
|
type: "hidden",
|
|
2022
2257
|
name,
|
|
2023
2258
|
value: value ? value.toISOString() : ""
|
|
2024
2259
|
}
|
|
2025
|
-
), /* @__PURE__ */
|
|
2260
|
+
), /* @__PURE__ */ React17__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React17__namespace.createElement(
|
|
2026
2261
|
"span",
|
|
2027
2262
|
{
|
|
2028
2263
|
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
2029
2264
|
"aria-hidden": "true"
|
|
2030
2265
|
},
|
|
2031
|
-
/* @__PURE__ */
|
|
2266
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
2032
2267
|
"svg",
|
|
2033
2268
|
{
|
|
2034
2269
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2041,9 +2276,9 @@ function DatePicker({
|
|
|
2041
2276
|
strokeLinejoin: "round",
|
|
2042
2277
|
strokeWidth: "2"
|
|
2043
2278
|
},
|
|
2044
|
-
/* @__PURE__ */
|
|
2279
|
+
/* @__PURE__ */ React17__namespace.createElement("path", { d: "M8 2v4m8-4v4m5 8V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8M3 10h18m-5 10l2 2l4-4" })
|
|
2045
2280
|
)
|
|
2046
|
-
), /* @__PURE__ */
|
|
2281
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
2047
2282
|
"input",
|
|
2048
2283
|
{
|
|
2049
2284
|
ref: inputRef,
|
|
@@ -2068,7 +2303,7 @@ function DatePicker({
|
|
|
2068
2303
|
"aria-required": required || props["aria-required"],
|
|
2069
2304
|
readOnly: true
|
|
2070
2305
|
}
|
|
2071
|
-
), clearable && value && !disabled && /* @__PURE__ */
|
|
2306
|
+
), clearable && value && !disabled && /* @__PURE__ */ React17__namespace.createElement(
|
|
2072
2307
|
"button",
|
|
2073
2308
|
{
|
|
2074
2309
|
type: "button",
|
|
@@ -2078,7 +2313,7 @@ function DatePicker({
|
|
|
2078
2313
|
tabIndex: -1
|
|
2079
2314
|
},
|
|
2080
2315
|
"\u2715"
|
|
2081
|
-
)), isOpen && !disabled && /* @__PURE__ */
|
|
2316
|
+
)), isOpen && !disabled && /* @__PURE__ */ React17__namespace.createElement(
|
|
2082
2317
|
"div",
|
|
2083
2318
|
{
|
|
2084
2319
|
ref: dropdownRef,
|
|
@@ -2145,11 +2380,11 @@ function TimePicker({
|
|
|
2145
2380
|
showIcon = true,
|
|
2146
2381
|
...props
|
|
2147
2382
|
}) {
|
|
2148
|
-
const inputRef =
|
|
2149
|
-
const [nativeValue, setNativeValue] =
|
|
2383
|
+
const inputRef = React17__namespace.useRef(null);
|
|
2384
|
+
const [nativeValue, setNativeValue] = React17__namespace.useState(
|
|
2150
2385
|
normalizeToNativeTime(value)
|
|
2151
2386
|
);
|
|
2152
|
-
|
|
2387
|
+
React17__namespace.useEffect(() => {
|
|
2153
2388
|
setNativeValue(normalizeToNativeTime(value));
|
|
2154
2389
|
}, [value]);
|
|
2155
2390
|
const handleChange = (e) => {
|
|
@@ -2165,13 +2400,13 @@ function TimePicker({
|
|
|
2165
2400
|
};
|
|
2166
2401
|
const hasValue = Boolean(value);
|
|
2167
2402
|
const stepInSeconds = Math.max(1, minuteStep * 60);
|
|
2168
|
-
return /* @__PURE__ */
|
|
2403
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: cn("relative", className) }, /* @__PURE__ */ React17__namespace.createElement("input", { type: "hidden", name, value }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React17__namespace.createElement(
|
|
2169
2404
|
"span",
|
|
2170
2405
|
{
|
|
2171
2406
|
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
2172
2407
|
"aria-hidden": "true"
|
|
2173
2408
|
},
|
|
2174
|
-
/* @__PURE__ */
|
|
2409
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
2175
2410
|
"svg",
|
|
2176
2411
|
{
|
|
2177
2412
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2184,10 +2419,10 @@ function TimePicker({
|
|
|
2184
2419
|
strokeLinejoin: "round",
|
|
2185
2420
|
strokeWidth: "2"
|
|
2186
2421
|
},
|
|
2187
|
-
/* @__PURE__ */
|
|
2188
|
-
/* @__PURE__ */
|
|
2422
|
+
/* @__PURE__ */ React17__namespace.createElement("circle", { cx: "12", cy: "12", r: "10" }),
|
|
2423
|
+
/* @__PURE__ */ React17__namespace.createElement("path", { d: "M12 6v6l4 2" })
|
|
2189
2424
|
)
|
|
2190
|
-
), /* @__PURE__ */
|
|
2425
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
2191
2426
|
"input",
|
|
2192
2427
|
{
|
|
2193
2428
|
ref: inputRef,
|
|
@@ -2215,7 +2450,7 @@ function TimePicker({
|
|
|
2215
2450
|
"aria-required": required || props["aria-required"],
|
|
2216
2451
|
...props
|
|
2217
2452
|
}
|
|
2218
|
-
), clearable && value && !disabled && /* @__PURE__ */
|
|
2453
|
+
), clearable && value && !disabled && /* @__PURE__ */ React17__namespace.createElement(
|
|
2219
2454
|
"button",
|
|
2220
2455
|
{
|
|
2221
2456
|
type: "button",
|
|
@@ -2268,17 +2503,17 @@ function DateRangePicker({
|
|
|
2268
2503
|
separator = " - ",
|
|
2269
2504
|
...props
|
|
2270
2505
|
}) {
|
|
2271
|
-
const [isOpen, setIsOpen] =
|
|
2272
|
-
const [hasInteracted, setHasInteracted] =
|
|
2273
|
-
const [selectedMonth, setSelectedMonth] =
|
|
2506
|
+
const [isOpen, setIsOpen] = React17__namespace.useState(false);
|
|
2507
|
+
const [hasInteracted, setHasInteracted] = React17__namespace.useState(false);
|
|
2508
|
+
const [selectedMonth, setSelectedMonth] = React17__namespace.useState(
|
|
2274
2509
|
value.start || /* @__PURE__ */ new Date()
|
|
2275
2510
|
);
|
|
2276
|
-
const [rangeStart, setRangeStart] =
|
|
2277
|
-
const [rangeEnd, setRangeEnd] =
|
|
2278
|
-
const [hoverDate, setHoverDate] =
|
|
2279
|
-
const triggerRef =
|
|
2280
|
-
const dropdownRef =
|
|
2281
|
-
|
|
2511
|
+
const [rangeStart, setRangeStart] = React17__namespace.useState(value.start);
|
|
2512
|
+
const [rangeEnd, setRangeEnd] = React17__namespace.useState(value.end);
|
|
2513
|
+
const [hoverDate, setHoverDate] = React17__namespace.useState(null);
|
|
2514
|
+
const triggerRef = React17__namespace.useRef(null);
|
|
2515
|
+
const dropdownRef = React17__namespace.useRef(null);
|
|
2516
|
+
React17__namespace.useEffect(() => {
|
|
2282
2517
|
setRangeStart(value.start);
|
|
2283
2518
|
setRangeEnd(value.end);
|
|
2284
2519
|
if (value.start) {
|
|
@@ -2327,7 +2562,7 @@ function DateRangePicker({
|
|
|
2327
2562
|
if (isDateDisabled && isDateDisabled(date)) return true;
|
|
2328
2563
|
return false;
|
|
2329
2564
|
};
|
|
2330
|
-
const closeCalendar =
|
|
2565
|
+
const closeCalendar = React17__namespace.useCallback(() => {
|
|
2331
2566
|
if (!isOpen) return;
|
|
2332
2567
|
setIsOpen(false);
|
|
2333
2568
|
if (hasInteracted) {
|
|
@@ -2377,7 +2612,7 @@ function DateRangePicker({
|
|
|
2377
2612
|
for (let day = 1; day <= daysInMonth; day++) {
|
|
2378
2613
|
days.push(new Date(year, month, day));
|
|
2379
2614
|
}
|
|
2380
|
-
return /* @__PURE__ */
|
|
2615
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: "w-[240px] max-w-full" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center justify-between pb-3" }, controls?.prev ? /* @__PURE__ */ React17__namespace.createElement(
|
|
2381
2616
|
"button",
|
|
2382
2617
|
{
|
|
2383
2618
|
type: "button",
|
|
@@ -2386,7 +2621,7 @@ function DateRangePicker({
|
|
|
2386
2621
|
"aria-label": "Previous month"
|
|
2387
2622
|
},
|
|
2388
2623
|
"\u2039"
|
|
2389
|
-
) : /* @__PURE__ */
|
|
2624
|
+
) : /* @__PURE__ */ React17__namespace.createElement("div", { className: "h-8 w-8", "aria-hidden": "true" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "font-medium text-sm" }, `${monthNames[month]} ${year}`), controls?.next ? /* @__PURE__ */ React17__namespace.createElement(
|
|
2390
2625
|
"button",
|
|
2391
2626
|
{
|
|
2392
2627
|
type: "button",
|
|
@@ -2395,13 +2630,13 @@ function DateRangePicker({
|
|
|
2395
2630
|
"aria-label": "Next month"
|
|
2396
2631
|
},
|
|
2397
2632
|
"\u203A"
|
|
2398
|
-
) : /* @__PURE__ */
|
|
2633
|
+
) : /* @__PURE__ */ React17__namespace.createElement("div", { className: "h-8 w-8", "aria-hidden": "true" })), /* @__PURE__ */ React17__namespace.createElement(
|
|
2399
2634
|
"div",
|
|
2400
2635
|
{
|
|
2401
2636
|
className: "grid gap-1 text-xs text-muted-foreground",
|
|
2402
2637
|
style: dayGridStyle
|
|
2403
2638
|
},
|
|
2404
|
-
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */
|
|
2639
|
+
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React17__namespace.createElement(
|
|
2405
2640
|
"div",
|
|
2406
2641
|
{
|
|
2407
2642
|
key: `${month}-${day}`,
|
|
@@ -2409,9 +2644,9 @@ function DateRangePicker({
|
|
|
2409
2644
|
},
|
|
2410
2645
|
day
|
|
2411
2646
|
))
|
|
2412
|
-
), /* @__PURE__ */
|
|
2647
|
+
), /* @__PURE__ */ React17__namespace.createElement("div", { className: "grid gap-1", style: dayGridStyle }, days.map((date, index) => {
|
|
2413
2648
|
if (!date) {
|
|
2414
|
-
return /* @__PURE__ */
|
|
2649
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { key: `empty-${month}-${index}`, className: "h-8 w-8" });
|
|
2415
2650
|
}
|
|
2416
2651
|
const isStart = rangeStart && date.toDateString() === rangeStart.toDateString();
|
|
2417
2652
|
const isEnd = rangeEnd && date.toDateString() === rangeEnd.toDateString();
|
|
@@ -2423,7 +2658,7 @@ function DateRangePicker({
|
|
|
2423
2658
|
);
|
|
2424
2659
|
const isToday = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
2425
2660
|
const disabled2 = isDisabled(date);
|
|
2426
|
-
return /* @__PURE__ */
|
|
2661
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
2427
2662
|
"button",
|
|
2428
2663
|
{
|
|
2429
2664
|
key: date.toISOString(),
|
|
@@ -2448,27 +2683,27 @@ function DateRangePicker({
|
|
|
2448
2683
|
};
|
|
2449
2684
|
const combinedClassName = cn("relative", className);
|
|
2450
2685
|
const displayValue = rangeStart && rangeEnd ? `${formatDate2(rangeStart, format)}${separator}${formatDate2(rangeEnd, format)}` : rangeStart ? formatDate2(rangeStart, format) : "";
|
|
2451
|
-
return /* @__PURE__ */
|
|
2686
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: combinedClassName, onBlur: handleBlur }, /* @__PURE__ */ React17__namespace.createElement(
|
|
2452
2687
|
"input",
|
|
2453
2688
|
{
|
|
2454
2689
|
type: "hidden",
|
|
2455
2690
|
name: `${name}[start]`,
|
|
2456
2691
|
value: rangeStart ? rangeStart.toISOString() : ""
|
|
2457
2692
|
}
|
|
2458
|
-
), /* @__PURE__ */
|
|
2693
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
2459
2694
|
"input",
|
|
2460
2695
|
{
|
|
2461
2696
|
type: "hidden",
|
|
2462
2697
|
name: `${name}[end]`,
|
|
2463
2698
|
value: rangeEnd ? rangeEnd.toISOString() : ""
|
|
2464
2699
|
}
|
|
2465
|
-
), /* @__PURE__ */
|
|
2700
|
+
), /* @__PURE__ */ React17__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React17__namespace.createElement(
|
|
2466
2701
|
"span",
|
|
2467
2702
|
{
|
|
2468
2703
|
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
2469
2704
|
"aria-hidden": "true"
|
|
2470
2705
|
},
|
|
2471
|
-
/* @__PURE__ */
|
|
2706
|
+
/* @__PURE__ */ React17__namespace.createElement(
|
|
2472
2707
|
"svg",
|
|
2473
2708
|
{
|
|
2474
2709
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2481,9 +2716,9 @@ function DateRangePicker({
|
|
|
2481
2716
|
strokeLinejoin: "round",
|
|
2482
2717
|
strokeWidth: "2"
|
|
2483
2718
|
},
|
|
2484
|
-
/* @__PURE__ */
|
|
2719
|
+
/* @__PURE__ */ React17__namespace.createElement("path", { d: "M8 2v4m8-4v4m5 8V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8M3 10h18m-5 10l2 2l4-4" })
|
|
2485
2720
|
)
|
|
2486
|
-
), /* @__PURE__ */
|
|
2721
|
+
), /* @__PURE__ */ React17__namespace.createElement(
|
|
2487
2722
|
"input",
|
|
2488
2723
|
{
|
|
2489
2724
|
ref: triggerRef,
|
|
@@ -2508,7 +2743,7 @@ function DateRangePicker({
|
|
|
2508
2743
|
"aria-required": required || props["aria-required"],
|
|
2509
2744
|
readOnly: true
|
|
2510
2745
|
}
|
|
2511
|
-
), clearable && (rangeStart || rangeEnd) && !disabled && /* @__PURE__ */
|
|
2746
|
+
), clearable && (rangeStart || rangeEnd) && !disabled && /* @__PURE__ */ React17__namespace.createElement(
|
|
2512
2747
|
"button",
|
|
2513
2748
|
{
|
|
2514
2749
|
type: "button",
|
|
@@ -2518,14 +2753,14 @@ function DateRangePicker({
|
|
|
2518
2753
|
tabIndex: -1
|
|
2519
2754
|
},
|
|
2520
2755
|
"\u2715"
|
|
2521
|
-
)), isOpen && !disabled && /* @__PURE__ */
|
|
2756
|
+
)), isOpen && !disabled && /* @__PURE__ */ React17__namespace.createElement(
|
|
2522
2757
|
"div",
|
|
2523
2758
|
{
|
|
2524
2759
|
ref: dropdownRef,
|
|
2525
2760
|
className: "absolute z-50 top-full mt-1 w-fit rounded-md border border-border bg-popover text-popover-foreground shadow-md p-3"
|
|
2526
2761
|
},
|
|
2527
|
-
/* @__PURE__ */
|
|
2528
|
-
rangeStart && !rangeEnd && /* @__PURE__ */
|
|
2762
|
+
/* @__PURE__ */ React17__namespace.createElement("div", { role: "grid", "aria-label": "Calendar" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "grid gap-4", style: monthsGridStyle }, renderMonth(selectedMonth, { prev: true }), renderMonth(addMonths(selectedMonth, 1), { next: true }))),
|
|
2763
|
+
rangeStart && !rangeEnd && /* @__PURE__ */ React17__namespace.createElement("div", { className: "text-xs text-center pt-2 border-t border-border mt-2" }, "Select end date")
|
|
2529
2764
|
));
|
|
2530
2765
|
}
|
|
2531
2766
|
DateRangePicker.displayName = "DateRangePicker";
|
|
@@ -2597,11 +2832,11 @@ function RichTextEditor({
|
|
|
2597
2832
|
],
|
|
2598
2833
|
...props
|
|
2599
2834
|
}) {
|
|
2600
|
-
const [currentMode, setCurrentMode] =
|
|
2601
|
-
const [content, setContent] =
|
|
2602
|
-
const editorRef =
|
|
2603
|
-
const textareaRef =
|
|
2604
|
-
|
|
2835
|
+
const [currentMode, setCurrentMode] = React17__namespace.useState(mode);
|
|
2836
|
+
const [content, setContent] = React17__namespace.useState(value);
|
|
2837
|
+
const editorRef = React17__namespace.useRef(null);
|
|
2838
|
+
const textareaRef = React17__namespace.useRef(null);
|
|
2839
|
+
React17__namespace.useEffect(() => {
|
|
2605
2840
|
setContent(value);
|
|
2606
2841
|
if (currentMode === "wysiwyg" && editorRef.current) {
|
|
2607
2842
|
editorRef.current.innerHTML = value;
|
|
@@ -2689,7 +2924,7 @@ function RichTextEditor({
|
|
|
2689
2924
|
}
|
|
2690
2925
|
}
|
|
2691
2926
|
};
|
|
2692
|
-
const hasValue =
|
|
2927
|
+
const hasValue = React17__namespace.useMemo(() => {
|
|
2693
2928
|
if (!content) return false;
|
|
2694
2929
|
const stripped = content.replace(/<[^>]+>/g, "").trim();
|
|
2695
2930
|
return stripped.length > 0;
|
|
@@ -2706,10 +2941,10 @@ function RichTextEditor({
|
|
|
2706
2941
|
maxHeight,
|
|
2707
2942
|
overflowY: maxHeight ? "auto" : void 0
|
|
2708
2943
|
};
|
|
2709
|
-
return /* @__PURE__ */
|
|
2944
|
+
return /* @__PURE__ */ React17__namespace.createElement("div", { className: combinedClassName }, /* @__PURE__ */ React17__namespace.createElement("input", { type: "hidden", name, value: content }), showToolbar && /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center justify-between p-2 border-b border-border bg-muted/50" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "flex items-center gap-1" }, toolbarButtons.map((buttonName) => {
|
|
2710
2945
|
const button = toolbarConfig[buttonName];
|
|
2711
2946
|
if (!button) return null;
|
|
2712
|
-
return /* @__PURE__ */
|
|
2947
|
+
return /* @__PURE__ */ React17__namespace.createElement(
|
|
2713
2948
|
"button",
|
|
2714
2949
|
{
|
|
2715
2950
|
key: buttonName,
|
|
@@ -2722,7 +2957,7 @@ function RichTextEditor({
|
|
|
2722
2957
|
},
|
|
2723
2958
|
button.icon
|
|
2724
2959
|
);
|
|
2725
|
-
})), allowModeSwitch && /* @__PURE__ */
|
|
2960
|
+
})), allowModeSwitch && /* @__PURE__ */ React17__namespace.createElement(
|
|
2726
2961
|
"button",
|
|
2727
2962
|
{
|
|
2728
2963
|
type: "button",
|
|
@@ -2733,7 +2968,7 @@ function RichTextEditor({
|
|
|
2733
2968
|
"aria-label": `Switch to ${currentMode === "wysiwyg" ? "Markdown" : "WYSIWYG"}`
|
|
2734
2969
|
},
|
|
2735
2970
|
currentMode === "wysiwyg" ? "MD" : "WYSIWYG"
|
|
2736
|
-
)), /* @__PURE__ */
|
|
2971
|
+
)), /* @__PURE__ */ React17__namespace.createElement("div", { style: editorStyle }, currentMode === "wysiwyg" ? /* @__PURE__ */ React17__namespace.createElement(
|
|
2737
2972
|
"div",
|
|
2738
2973
|
{
|
|
2739
2974
|
ref: editorRef,
|
|
@@ -2748,7 +2983,7 @@ function RichTextEditor({
|
|
|
2748
2983
|
"aria-required": required || props["aria-required"],
|
|
2749
2984
|
suppressContentEditableWarning: true
|
|
2750
2985
|
}
|
|
2751
|
-
) : /* @__PURE__ */
|
|
2986
|
+
) : /* @__PURE__ */ React17__namespace.createElement(
|
|
2752
2987
|
"textarea",
|
|
2753
2988
|
{
|
|
2754
2989
|
ref: textareaRef,
|
|
@@ -2771,7 +3006,7 @@ function RichTextEditor({
|
|
|
2771
3006
|
}
|
|
2772
3007
|
RichTextEditor.displayName = "RichTextEditor";
|
|
2773
3008
|
|
|
2774
|
-
exports.Checkbox =
|
|
3009
|
+
exports.Checkbox = Checkbox2;
|
|
2775
3010
|
exports.CheckboxGroup = CheckboxGroup;
|
|
2776
3011
|
exports.DatePicker = DatePicker;
|
|
2777
3012
|
exports.DateRangePicker = DateRangePicker;
|
|
@@ -2779,7 +3014,8 @@ exports.FileInput = FileInput;
|
|
|
2779
3014
|
exports.MultiSelect = MultiSelect;
|
|
2780
3015
|
exports.Radio = Radio;
|
|
2781
3016
|
exports.RichTextEditor = RichTextEditor;
|
|
2782
|
-
exports.Select =
|
|
3017
|
+
exports.Select = Select2;
|
|
3018
|
+
exports.Switch = Switch2;
|
|
2783
3019
|
exports.TextArea = TextArea;
|
|
2784
3020
|
exports.TextInput = TextInput;
|
|
2785
3021
|
exports.TimePicker = TimePicker;
|