@page-speed/forms 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -616
- package/dist/core.cjs +103 -10
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +15 -4
- package/dist/core.d.ts +15 -4
- package/dist/core.js +104 -12
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +103 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +104 -12
- package/dist/index.js.map +1 -1
- package/dist/inputs.cjs +582 -189
- package/dist/inputs.cjs.map +1 -1
- package/dist/inputs.d.cts +143 -2
- package/dist/inputs.d.ts +143 -2
- package/dist/inputs.js +581 -189
- package/dist/inputs.js.map +1 -1
- package/dist/{types-BBif0kuP.d.cts → types-4ppM117e.d.cts} +53 -1
- package/dist/{types-BBif0kuP.d.ts → types-4ppM117e.d.ts} +53 -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 +2 -2
package/dist/inputs.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React9 = require('react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
5
|
var tailwindMerge = require('tailwind-merge');
|
|
6
6
|
var useOnClickOutside = require('@opensite/hooks/useOnClickOutside');
|
|
@@ -23,7 +23,7 @@ function _interopNamespace(e) {
|
|
|
23
23
|
return Object.freeze(n);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var React9__namespace = /*#__PURE__*/_interopNamespace(React9);
|
|
27
27
|
|
|
28
28
|
// src/inputs/TextInput.tsx
|
|
29
29
|
function cn(...inputs) {
|
|
@@ -62,7 +62,7 @@ function TextInput({
|
|
|
62
62
|
error && "border-destructive ring-1 ring-destructive",
|
|
63
63
|
className
|
|
64
64
|
);
|
|
65
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
66
66
|
"input",
|
|
67
67
|
{
|
|
68
68
|
type,
|
|
@@ -116,7 +116,7 @@ function TextArea({
|
|
|
116
116
|
error && "border-destructive ring-1 ring-destructive",
|
|
117
117
|
className
|
|
118
118
|
);
|
|
119
|
-
return /* @__PURE__ */
|
|
119
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
120
120
|
"textarea",
|
|
121
121
|
{
|
|
122
122
|
name,
|
|
@@ -155,11 +155,11 @@ var LabelGroup = ({
|
|
|
155
155
|
variant === "legend" ? "mb-1.5" : "mb-1 block",
|
|
156
156
|
primaryClassName
|
|
157
157
|
);
|
|
158
|
-
const requiredIndicator = required ? /* @__PURE__ */
|
|
158
|
+
const requiredIndicator = required ? /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-destructive pl-0.5", "aria-label": "required" }, "*") : null;
|
|
159
159
|
let primaryElement = null;
|
|
160
160
|
if (primary) {
|
|
161
161
|
if (variant === "label") {
|
|
162
|
-
primaryElement = /* @__PURE__ */
|
|
162
|
+
primaryElement = /* @__PURE__ */ React9__namespace.createElement(
|
|
163
163
|
"label",
|
|
164
164
|
{
|
|
165
165
|
htmlFor: labelHtmlFor,
|
|
@@ -170,12 +170,12 @@ var LabelGroup = ({
|
|
|
170
170
|
requiredIndicator
|
|
171
171
|
);
|
|
172
172
|
} else if (variant === "legend") {
|
|
173
|
-
primaryElement = /* @__PURE__ */
|
|
173
|
+
primaryElement = /* @__PURE__ */ React9__namespace.createElement("legend", { "data-slot": "field-legend", className: primaryClasses }, primary, requiredIndicator);
|
|
174
174
|
} else {
|
|
175
|
-
primaryElement = /* @__PURE__ */
|
|
175
|
+
primaryElement = /* @__PURE__ */ React9__namespace.createElement("div", { "data-slot": "field-label", className: primaryClasses }, primary, requiredIndicator);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
const secondaryElement = secondary ? /* @__PURE__ */
|
|
178
|
+
const secondaryElement = secondary ? /* @__PURE__ */ React9__namespace.createElement(
|
|
179
179
|
"p",
|
|
180
180
|
{
|
|
181
181
|
"data-slot": "field-description",
|
|
@@ -185,7 +185,10 @@ var LabelGroup = ({
|
|
|
185
185
|
secondary
|
|
186
186
|
) : null;
|
|
187
187
|
if (!primaryElement && !secondaryElement) return null;
|
|
188
|
-
|
|
188
|
+
if (variant === "legend") {
|
|
189
|
+
return /* @__PURE__ */ React9__namespace.createElement(React9__namespace.Fragment, null, primaryElement, secondaryElement);
|
|
190
|
+
}
|
|
191
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex flex-1 flex-col gap-0.5" }, primaryElement, secondaryElement);
|
|
189
192
|
};
|
|
190
193
|
|
|
191
194
|
// src/inputs/Checkbox.tsx
|
|
@@ -204,9 +207,9 @@ function Checkbox({
|
|
|
204
207
|
useChoiceCard = false,
|
|
205
208
|
...props
|
|
206
209
|
}) {
|
|
207
|
-
const inputRef =
|
|
210
|
+
const inputRef = React9__namespace.useRef(null);
|
|
208
211
|
const checkboxId = props.id || `checkbox-${name}`;
|
|
209
|
-
|
|
212
|
+
React9__namespace.useEffect(() => {
|
|
210
213
|
if (inputRef.current) {
|
|
211
214
|
inputRef.current.indeterminate = indeterminate;
|
|
212
215
|
}
|
|
@@ -218,7 +221,7 @@ function Checkbox({
|
|
|
218
221
|
onBlur?.();
|
|
219
222
|
};
|
|
220
223
|
const isActive = value || indeterminate && !value;
|
|
221
|
-
const checkbox = /* @__PURE__ */
|
|
224
|
+
const checkbox = /* @__PURE__ */ React9__namespace.createElement(
|
|
222
225
|
"div",
|
|
223
226
|
{
|
|
224
227
|
className: cn(
|
|
@@ -226,7 +229,7 @@ function Checkbox({
|
|
|
226
229
|
!label && className
|
|
227
230
|
)
|
|
228
231
|
},
|
|
229
|
-
/* @__PURE__ */
|
|
232
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
230
233
|
"input",
|
|
231
234
|
{
|
|
232
235
|
ref: inputRef,
|
|
@@ -245,7 +248,7 @@ function Checkbox({
|
|
|
245
248
|
...props
|
|
246
249
|
}
|
|
247
250
|
),
|
|
248
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
249
252
|
"div",
|
|
250
253
|
{
|
|
251
254
|
className: cn(
|
|
@@ -258,7 +261,7 @@ function Checkbox({
|
|
|
258
261
|
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
259
262
|
)
|
|
260
263
|
},
|
|
261
|
-
value && /* @__PURE__ */
|
|
264
|
+
value && /* @__PURE__ */ React9__namespace.createElement(
|
|
262
265
|
"svg",
|
|
263
266
|
{
|
|
264
267
|
className: "size-3.5",
|
|
@@ -269,9 +272,9 @@ function Checkbox({
|
|
|
269
272
|
strokeLinecap: "round",
|
|
270
273
|
strokeLinejoin: "round"
|
|
271
274
|
},
|
|
272
|
-
/* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ React9__namespace.createElement("polyline", { points: "20 6 9 17 4 12" })
|
|
273
276
|
),
|
|
274
|
-
indeterminate && !value && /* @__PURE__ */
|
|
277
|
+
indeterminate && !value && /* @__PURE__ */ React9__namespace.createElement(
|
|
275
278
|
"svg",
|
|
276
279
|
{
|
|
277
280
|
className: "size-3.5",
|
|
@@ -282,12 +285,12 @@ function Checkbox({
|
|
|
282
285
|
strokeLinecap: "round",
|
|
283
286
|
strokeLinejoin: "round"
|
|
284
287
|
},
|
|
285
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ React9__namespace.createElement("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
286
289
|
)
|
|
287
290
|
)
|
|
288
291
|
);
|
|
289
292
|
if (label) {
|
|
290
|
-
return /* @__PURE__ */
|
|
293
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
291
294
|
"label",
|
|
292
295
|
{
|
|
293
296
|
className: cn(
|
|
@@ -299,7 +302,7 @@ function Checkbox({
|
|
|
299
302
|
),
|
|
300
303
|
htmlFor: checkboxId
|
|
301
304
|
},
|
|
302
|
-
/* @__PURE__ */
|
|
305
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
303
306
|
"div",
|
|
304
307
|
{
|
|
305
308
|
className: cn(
|
|
@@ -308,7 +311,7 @@ function Checkbox({
|
|
|
308
311
|
)
|
|
309
312
|
},
|
|
310
313
|
checkbox,
|
|
311
|
-
/* @__PURE__ */
|
|
314
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
312
315
|
LabelGroup,
|
|
313
316
|
{
|
|
314
317
|
variant: "text",
|
|
@@ -353,11 +356,11 @@ function CheckboxGroup({
|
|
|
353
356
|
).length;
|
|
354
357
|
const allSelected = selectedEnabledCount === enabledOptions.length;
|
|
355
358
|
const someSelected = selectedEnabledCount > 0 && !allSelected;
|
|
356
|
-
const useChoiceCard =
|
|
359
|
+
const useChoiceCard = React9__namespace.useMemo(() => {
|
|
357
360
|
if (!options) return false;
|
|
358
361
|
return options?.some((opt) => opt.description);
|
|
359
362
|
}, [options]);
|
|
360
|
-
const countableValue =
|
|
363
|
+
const countableValue = React9__namespace.useMemo(() => {
|
|
361
364
|
if (value?.length > 0) {
|
|
362
365
|
return value.length;
|
|
363
366
|
}
|
|
@@ -382,7 +385,7 @@ function CheckboxGroup({
|
|
|
382
385
|
onBlur?.();
|
|
383
386
|
};
|
|
384
387
|
const maxReached = Boolean(maxSelections && countableValue >= maxSelections);
|
|
385
|
-
const containerClass =
|
|
388
|
+
const containerClass = React9__namespace.useMemo(() => {
|
|
386
389
|
return cn(
|
|
387
390
|
"w-full gap-3 grid grid-cols-1 border-0 m-0 p-0 min-w-0",
|
|
388
391
|
(layout === "grid" || layout === "inline") && "md:grid-cols-2",
|
|
@@ -391,7 +394,7 @@ function CheckboxGroup({
|
|
|
391
394
|
}, [layout, className]);
|
|
392
395
|
const groupDescriptionId = description ? `${name}-description` : void 0;
|
|
393
396
|
const groupAriaDescribedBy = [props["aria-describedby"], groupDescriptionId].filter(Boolean).join(" ") || void 0;
|
|
394
|
-
return /* @__PURE__ */
|
|
397
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
395
398
|
"fieldset",
|
|
396
399
|
{
|
|
397
400
|
className: containerClass,
|
|
@@ -401,7 +404,7 @@ function CheckboxGroup({
|
|
|
401
404
|
"aria-required": required || props["aria-required"],
|
|
402
405
|
"aria-label": typeof label === "string" ? label : props["aria-label"]
|
|
403
406
|
},
|
|
404
|
-
/* @__PURE__ */
|
|
407
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
405
408
|
LabelGroup,
|
|
406
409
|
{
|
|
407
410
|
labelHtmlFor: name,
|
|
@@ -412,7 +415,7 @@ function CheckboxGroup({
|
|
|
412
415
|
primary: label
|
|
413
416
|
}
|
|
414
417
|
),
|
|
415
|
-
showSelectAll && enabledOptions.length > 0 && /* @__PURE__ */
|
|
418
|
+
showSelectAll && enabledOptions.length > 0 && /* @__PURE__ */ React9__namespace.createElement(
|
|
416
419
|
Checkbox,
|
|
417
420
|
{
|
|
418
421
|
name: `${name}-select-all`,
|
|
@@ -430,7 +433,7 @@ function CheckboxGroup({
|
|
|
430
433
|
options.map((option) => {
|
|
431
434
|
const isChecked = value.includes(option.value);
|
|
432
435
|
const isDisabled = disabled || option.disabled || maxReached && !isChecked;
|
|
433
|
-
return /* @__PURE__ */
|
|
436
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
434
437
|
Checkbox,
|
|
435
438
|
{
|
|
436
439
|
key: option.value,
|
|
@@ -448,7 +451,7 @@ function CheckboxGroup({
|
|
|
448
451
|
}
|
|
449
452
|
);
|
|
450
453
|
}),
|
|
451
|
-
(minSelections || maxSelections) && /* @__PURE__ */
|
|
454
|
+
(minSelections || maxSelections) && /* @__PURE__ */ React9__namespace.createElement(
|
|
452
455
|
"div",
|
|
453
456
|
{
|
|
454
457
|
className: cn(
|
|
@@ -457,8 +460,8 @@ function CheckboxGroup({
|
|
|
457
460
|
),
|
|
458
461
|
"aria-live": "polite"
|
|
459
462
|
},
|
|
460
|
-
minSelections && countableValue < minSelections && /* @__PURE__ */
|
|
461
|
-
maxSelections && /* @__PURE__ */
|
|
463
|
+
minSelections && countableValue < minSelections && /* @__PURE__ */ React9__namespace.createElement("span", null, "Select at least ", minSelections, " option", minSelections !== 1 ? "s" : ""),
|
|
464
|
+
maxSelections && /* @__PURE__ */ React9__namespace.createElement("span", null, countableValue, "/", maxSelections, " selected")
|
|
462
465
|
)
|
|
463
466
|
);
|
|
464
467
|
}
|
|
@@ -509,10 +512,10 @@ function Radio({
|
|
|
509
512
|
const handleBlur = () => {
|
|
510
513
|
onBlur?.();
|
|
511
514
|
};
|
|
512
|
-
const useChoiceCard =
|
|
515
|
+
const useChoiceCard = React9__namespace.useMemo(() => {
|
|
513
516
|
return options.some((option) => option.description);
|
|
514
517
|
}, [options]);
|
|
515
|
-
const containerClass =
|
|
518
|
+
const containerClass = React9__namespace.useMemo(() => {
|
|
516
519
|
return cn(
|
|
517
520
|
"w-full gap-3 grid grid-cols-1 border-0 m-0 p-0 min-w-0",
|
|
518
521
|
(layout === "grid" || layout === "inline") && "md:grid-cols-2",
|
|
@@ -521,7 +524,7 @@ function Radio({
|
|
|
521
524
|
}, [layout, className]);
|
|
522
525
|
const groupDescriptionId = description ? `${name}-description` : void 0;
|
|
523
526
|
const groupAriaDescribedBy = [props["aria-describedby"], groupDescriptionId].filter(Boolean).join(" ") || void 0;
|
|
524
|
-
return /* @__PURE__ */
|
|
527
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
525
528
|
"fieldset",
|
|
526
529
|
{
|
|
527
530
|
className: containerClass,
|
|
@@ -531,7 +534,7 @@ function Radio({
|
|
|
531
534
|
"aria-required": required || props["aria-required"],
|
|
532
535
|
"aria-label": typeof label === "string" ? label : props["aria-label"]
|
|
533
536
|
},
|
|
534
|
-
/* @__PURE__ */
|
|
537
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
535
538
|
LabelGroup,
|
|
536
539
|
{
|
|
537
540
|
variant: "legend",
|
|
@@ -545,7 +548,7 @@ function Radio({
|
|
|
545
548
|
const isDisabled = disabled || option.disabled;
|
|
546
549
|
const radioId = `${name}-${option.value}`;
|
|
547
550
|
const hasDescription = option.description != null && option.description !== "";
|
|
548
|
-
const radioIndicator = /* @__PURE__ */
|
|
551
|
+
const radioIndicator = /* @__PURE__ */ React9__namespace.createElement("div", { className: "relative inline-flex items-center justify-center" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
549
552
|
"input",
|
|
550
553
|
{
|
|
551
554
|
type: "radio",
|
|
@@ -560,7 +563,7 @@ function Radio({
|
|
|
560
563
|
className: "peer sr-only",
|
|
561
564
|
"aria-describedby": hasDescription ? `${radioId}-description` : props["aria-describedby"]
|
|
562
565
|
}
|
|
563
|
-
), /* @__PURE__ */
|
|
566
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
564
567
|
"div",
|
|
565
568
|
{
|
|
566
569
|
className: cn(
|
|
@@ -573,9 +576,9 @@ function Radio({
|
|
|
573
576
|
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring/50 peer-focus-visible:ring-offset-1"
|
|
574
577
|
)
|
|
575
578
|
},
|
|
576
|
-
isChecked && /* @__PURE__ */
|
|
579
|
+
isChecked && /* @__PURE__ */ React9__namespace.createElement("div", { className: "size-3 rounded-full bg-primary" })
|
|
577
580
|
));
|
|
578
|
-
const labelContent = /* @__PURE__ */
|
|
581
|
+
const labelContent = /* @__PURE__ */ React9__namespace.createElement(
|
|
579
582
|
LabelGroup,
|
|
580
583
|
{
|
|
581
584
|
variant: "text",
|
|
@@ -586,7 +589,7 @@ function Radio({
|
|
|
586
589
|
secondaryClassName: "text-xs opacity-75"
|
|
587
590
|
}
|
|
588
591
|
);
|
|
589
|
-
return /* @__PURE__ */
|
|
592
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
590
593
|
"label",
|
|
591
594
|
{
|
|
592
595
|
key: option.value,
|
|
@@ -600,7 +603,7 @@ function Radio({
|
|
|
600
603
|
onKeyDown: (e) => handleKeyDown(e, index),
|
|
601
604
|
tabIndex: isDisabled ? -1 : 0
|
|
602
605
|
},
|
|
603
|
-
/* @__PURE__ */
|
|
606
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
604
607
|
"div",
|
|
605
608
|
{
|
|
606
609
|
className: cn(
|
|
@@ -609,7 +612,7 @@ function Radio({
|
|
|
609
612
|
)
|
|
610
613
|
},
|
|
611
614
|
!useChoiceCard && radioIndicator,
|
|
612
|
-
|
|
615
|
+
labelContent,
|
|
613
616
|
useChoiceCard && radioIndicator
|
|
614
617
|
)
|
|
615
618
|
);
|
|
@@ -636,19 +639,20 @@ function Select({
|
|
|
636
639
|
renderOption,
|
|
637
640
|
...props
|
|
638
641
|
}) {
|
|
639
|
-
const [isOpen, setIsOpen] =
|
|
640
|
-
const [searchQuery, setSearchQuery] =
|
|
641
|
-
const [focusedIndex, setFocusedIndex] =
|
|
642
|
-
const
|
|
643
|
-
const
|
|
642
|
+
const [isOpen, setIsOpen] = React9__namespace.useState(false);
|
|
643
|
+
const [searchQuery, setSearchQuery] = React9__namespace.useState("");
|
|
644
|
+
const [focusedIndex, setFocusedIndex] = React9__namespace.useState(-1);
|
|
645
|
+
const triggerRef = React9__namespace.useRef(null);
|
|
646
|
+
const dropdownRef = React9__namespace.useRef(null);
|
|
647
|
+
const searchInputRef = React9__namespace.useRef(null);
|
|
644
648
|
const dropdownId = `${name}-dropdown`;
|
|
645
|
-
const allOptions =
|
|
649
|
+
const allOptions = React9__namespace.useMemo(() => {
|
|
646
650
|
if (optionGroups.length > 0) {
|
|
647
651
|
return optionGroups.flatMap((group) => group.options);
|
|
648
652
|
}
|
|
649
653
|
return options;
|
|
650
654
|
}, [options, optionGroups]);
|
|
651
|
-
const filteredOptions =
|
|
655
|
+
const filteredOptions = React9__namespace.useMemo(() => {
|
|
652
656
|
if (!searchQuery.trim()) {
|
|
653
657
|
return allOptions;
|
|
654
658
|
}
|
|
@@ -658,7 +662,7 @@ function Select({
|
|
|
658
662
|
return label.toLowerCase().includes(query);
|
|
659
663
|
});
|
|
660
664
|
}, [allOptions, searchQuery]);
|
|
661
|
-
const selectedOption =
|
|
665
|
+
const selectedOption = React9__namespace.useMemo(() => {
|
|
662
666
|
return allOptions.find((opt) => opt.value === value);
|
|
663
667
|
}, [allOptions, value]);
|
|
664
668
|
const hasValue = Boolean(value);
|
|
@@ -758,28 +762,29 @@ function Select({
|
|
|
758
762
|
};
|
|
759
763
|
const handleBlur = (event) => {
|
|
760
764
|
const nextTarget = event?.relatedTarget;
|
|
761
|
-
|
|
765
|
+
const focusStayedInside = !!triggerRef.current && triggerRef.current.contains(nextTarget) || !!dropdownRef.current && dropdownRef.current.contains(nextTarget);
|
|
766
|
+
if (!nextTarget || !focusStayedInside) {
|
|
762
767
|
onBlur?.();
|
|
763
768
|
}
|
|
764
769
|
};
|
|
765
|
-
const closeDropdown =
|
|
766
|
-
if (!isOpen) return;
|
|
770
|
+
const closeDropdown = React9__namespace.useCallback(() => {
|
|
767
771
|
setIsOpen(false);
|
|
768
772
|
setSearchQuery("");
|
|
769
773
|
setFocusedIndex(-1);
|
|
770
774
|
onBlur?.();
|
|
771
|
-
}, [
|
|
772
|
-
useOnClickOutside.useOnClickOutside(
|
|
775
|
+
}, [onBlur]);
|
|
776
|
+
useOnClickOutside.useOnClickOutside([triggerRef, dropdownRef], closeDropdown, void 0, {
|
|
777
|
+
capture: true
|
|
778
|
+
});
|
|
773
779
|
const combinedClassName = cn("relative w-full", className);
|
|
774
|
-
return /* @__PURE__ */
|
|
780
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
775
781
|
"div",
|
|
776
782
|
{
|
|
777
|
-
ref: selectRef,
|
|
778
783
|
className: combinedClassName,
|
|
779
784
|
onKeyDown: handleKeyDown,
|
|
780
785
|
onBlur: handleBlur
|
|
781
786
|
},
|
|
782
|
-
/* @__PURE__ */
|
|
787
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
783
788
|
"select",
|
|
784
789
|
{
|
|
785
790
|
name,
|
|
@@ -792,12 +797,13 @@ function Select({
|
|
|
792
797
|
tabIndex: -1,
|
|
793
798
|
style: { display: "none" }
|
|
794
799
|
},
|
|
795
|
-
/* @__PURE__ */
|
|
796
|
-
allOptions.map((option) => /* @__PURE__ */
|
|
800
|
+
/* @__PURE__ */ React9__namespace.createElement("option", { value: "" }, "Select..."),
|
|
801
|
+
allOptions.map((option) => /* @__PURE__ */ React9__namespace.createElement("option", { key: option.value, value: option.value }, typeof option.label === "string" ? option.label : option.value))
|
|
797
802
|
),
|
|
798
|
-
/* @__PURE__ */
|
|
803
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
799
804
|
"div",
|
|
800
805
|
{
|
|
806
|
+
ref: triggerRef,
|
|
801
807
|
className: cn(
|
|
802
808
|
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm",
|
|
803
809
|
"cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
@@ -815,8 +821,8 @@ function Select({
|
|
|
815
821
|
"aria-disabled": disabled,
|
|
816
822
|
tabIndex: disabled ? -1 : 0
|
|
817
823
|
},
|
|
818
|
-
/* @__PURE__ */
|
|
819
|
-
/* @__PURE__ */
|
|
824
|
+
/* @__PURE__ */ React9__namespace.createElement("span", { className: "flex items-center flex-1 overflow-hidden text-ellipsis" }, selectedOption ? renderOption ? renderOption(selectedOption) : selectedOption.label : /* @__PURE__ */ React9__namespace.createElement("span", { className: "relative" }, placeholder)),
|
|
825
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center gap-1 ml-2" }, loading && /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-xs" }, "\u23F3"), clearable && value && !disabled && !loading && /* @__PURE__ */ React9__namespace.createElement(
|
|
820
826
|
"button",
|
|
821
827
|
{
|
|
822
828
|
type: "button",
|
|
@@ -826,16 +832,17 @@ function Select({
|
|
|
826
832
|
tabIndex: -1
|
|
827
833
|
},
|
|
828
834
|
"\u2715"
|
|
829
|
-
), /* @__PURE__ */
|
|
835
|
+
), /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-xs leading-none", "aria-hidden": "true" }, isOpen ? "\u25B2" : "\u25BC"))
|
|
830
836
|
),
|
|
831
|
-
isOpen && /* @__PURE__ */
|
|
837
|
+
isOpen && /* @__PURE__ */ React9__namespace.createElement(
|
|
832
838
|
"div",
|
|
833
839
|
{
|
|
840
|
+
ref: dropdownRef,
|
|
834
841
|
id: dropdownId,
|
|
835
842
|
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",
|
|
836
843
|
role: "listbox"
|
|
837
844
|
},
|
|
838
|
-
searchable && /* @__PURE__ */
|
|
845
|
+
searchable && /* @__PURE__ */ React9__namespace.createElement("div", { className: "p-2 border-b border-border" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
839
846
|
"input",
|
|
840
847
|
{
|
|
841
848
|
ref: searchInputRef,
|
|
@@ -851,19 +858,19 @@ function Select({
|
|
|
851
858
|
"aria-label": "Search options"
|
|
852
859
|
}
|
|
853
860
|
)),
|
|
854
|
-
/* @__PURE__ */
|
|
861
|
+
/* @__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 ? (
|
|
855
862
|
// Render grouped options
|
|
856
863
|
optionGroups.map((group, groupIndex) => {
|
|
857
864
|
const groupOptions = group.options.filter(
|
|
858
865
|
(opt) => filteredOptions.includes(opt)
|
|
859
866
|
);
|
|
860
867
|
if (groupOptions.length === 0) return null;
|
|
861
|
-
return /* @__PURE__ */
|
|
868
|
+
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) => {
|
|
862
869
|
const globalIndex = filteredOptions.indexOf(option);
|
|
863
870
|
const isSelected = value === option.value;
|
|
864
871
|
const isFocused = globalIndex === focusedIndex;
|
|
865
872
|
const isDisabled = option.disabled;
|
|
866
|
-
return /* @__PURE__ */
|
|
873
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
867
874
|
"div",
|
|
868
875
|
{
|
|
869
876
|
key: option.value,
|
|
@@ -883,7 +890,7 @@ function Select({
|
|
|
883
890
|
const isSelected = value === option.value;
|
|
884
891
|
const isFocused = index === focusedIndex;
|
|
885
892
|
const isDisabled = option.disabled;
|
|
886
|
-
return /* @__PURE__ */
|
|
893
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
887
894
|
"div",
|
|
888
895
|
{
|
|
889
896
|
key: option.value,
|
|
@@ -901,6 +908,360 @@ function Select({
|
|
|
901
908
|
);
|
|
902
909
|
}
|
|
903
910
|
Select.displayName = "Select";
|
|
911
|
+
function MultiSelect({
|
|
912
|
+
name,
|
|
913
|
+
value = [],
|
|
914
|
+
onChange,
|
|
915
|
+
onBlur,
|
|
916
|
+
onFocus,
|
|
917
|
+
disabled = false,
|
|
918
|
+
required = false,
|
|
919
|
+
error = false,
|
|
920
|
+
className = "",
|
|
921
|
+
placeholder = "Select...",
|
|
922
|
+
searchable = true,
|
|
923
|
+
clearable = true,
|
|
924
|
+
loading = false,
|
|
925
|
+
maxSelections,
|
|
926
|
+
showSelectAll = false,
|
|
927
|
+
options = [],
|
|
928
|
+
optionGroups = [],
|
|
929
|
+
renderOption,
|
|
930
|
+
renderValue,
|
|
931
|
+
...props
|
|
932
|
+
}) {
|
|
933
|
+
const [isOpen, setIsOpen] = React9__namespace.useState(false);
|
|
934
|
+
const [searchQuery, setSearchQuery] = React9__namespace.useState("");
|
|
935
|
+
const [focusedIndex, setFocusedIndex] = React9__namespace.useState(-1);
|
|
936
|
+
const triggerRef = React9__namespace.useRef(null);
|
|
937
|
+
const dropdownRef = React9__namespace.useRef(null);
|
|
938
|
+
const searchInputRef = React9__namespace.useRef(null);
|
|
939
|
+
const dropdownId = `${name}-dropdown`;
|
|
940
|
+
const allOptions = React9__namespace.useMemo(() => {
|
|
941
|
+
if (optionGroups.length > 0) {
|
|
942
|
+
return optionGroups.flatMap((group) => group.options);
|
|
943
|
+
}
|
|
944
|
+
return options;
|
|
945
|
+
}, [options, optionGroups]);
|
|
946
|
+
const filteredOptions = React9__namespace.useMemo(() => {
|
|
947
|
+
if (!searchQuery.trim()) {
|
|
948
|
+
return allOptions;
|
|
949
|
+
}
|
|
950
|
+
const query = searchQuery.toLowerCase();
|
|
951
|
+
return allOptions.filter((option) => {
|
|
952
|
+
const label = typeof option.label === "string" ? option.label : String(option.label);
|
|
953
|
+
return label.toLowerCase().includes(query);
|
|
954
|
+
});
|
|
955
|
+
}, [allOptions, searchQuery]);
|
|
956
|
+
const selectedOptions = React9__namespace.useMemo(() => {
|
|
957
|
+
return allOptions.filter((opt) => value.includes(opt.value));
|
|
958
|
+
}, [allOptions, value]);
|
|
959
|
+
const hasValue = value.length > 0;
|
|
960
|
+
const isMaxReached = React9__namespace.useMemo(() => {
|
|
961
|
+
return maxSelections !== void 0 && value.length >= maxSelections;
|
|
962
|
+
}, [maxSelections, value.length]);
|
|
963
|
+
const handleToggleOption = (optionValue) => {
|
|
964
|
+
const isSelected = value.includes(optionValue);
|
|
965
|
+
if (isSelected) {
|
|
966
|
+
onChange(value.filter((v) => v !== optionValue));
|
|
967
|
+
} else {
|
|
968
|
+
if (!isMaxReached) {
|
|
969
|
+
onChange([...value, optionValue]);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
setSearchQuery("");
|
|
973
|
+
};
|
|
974
|
+
const handleSelectAll = () => {
|
|
975
|
+
const enabledOptions = filteredOptions.filter((opt) => !opt.disabled);
|
|
976
|
+
const allValues = enabledOptions.map((opt) => opt.value);
|
|
977
|
+
onChange(allValues);
|
|
978
|
+
setSearchQuery("");
|
|
979
|
+
};
|
|
980
|
+
const handleClearAll = (e) => {
|
|
981
|
+
e.stopPropagation();
|
|
982
|
+
onChange([]);
|
|
983
|
+
setSearchQuery("");
|
|
984
|
+
setFocusedIndex(-1);
|
|
985
|
+
};
|
|
986
|
+
const handleRemoveValue = (optionValue, e) => {
|
|
987
|
+
e.stopPropagation();
|
|
988
|
+
onChange(value.filter((v) => v !== optionValue));
|
|
989
|
+
};
|
|
990
|
+
const handleToggle = () => {
|
|
991
|
+
if (disabled) return;
|
|
992
|
+
const newIsOpen = !isOpen;
|
|
993
|
+
setIsOpen(newIsOpen);
|
|
994
|
+
if (newIsOpen && searchable && searchInputRef.current) {
|
|
995
|
+
setTimeout(() => searchInputRef.current?.focus(), 0);
|
|
996
|
+
}
|
|
997
|
+
if (newIsOpen) {
|
|
998
|
+
onFocus?.();
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
const handleSearchChange = (e) => {
|
|
1002
|
+
setSearchQuery(e.target.value);
|
|
1003
|
+
setFocusedIndex(0);
|
|
1004
|
+
};
|
|
1005
|
+
const handleKeyDown = (e) => {
|
|
1006
|
+
if (disabled) return;
|
|
1007
|
+
switch (e.key) {
|
|
1008
|
+
case "ArrowDown":
|
|
1009
|
+
e.preventDefault();
|
|
1010
|
+
if (!isOpen) {
|
|
1011
|
+
setIsOpen(true);
|
|
1012
|
+
setFocusedIndex(0);
|
|
1013
|
+
} else {
|
|
1014
|
+
const enabledOptions = filteredOptions.filter((opt) => !opt.disabled);
|
|
1015
|
+
if (enabledOptions.length > 0) {
|
|
1016
|
+
const currentIndexInFiltered = focusedIndex;
|
|
1017
|
+
const nextIndex = (currentIndexInFiltered + 1) % enabledOptions.length;
|
|
1018
|
+
setFocusedIndex(filteredOptions.indexOf(enabledOptions[nextIndex]));
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
break;
|
|
1022
|
+
case "ArrowUp":
|
|
1023
|
+
e.preventDefault();
|
|
1024
|
+
if (isOpen) {
|
|
1025
|
+
const enabledOptions = filteredOptions.filter((opt) => !opt.disabled);
|
|
1026
|
+
if (enabledOptions.length > 0) {
|
|
1027
|
+
const currentIndexInFiltered = focusedIndex;
|
|
1028
|
+
const prevIndex = (currentIndexInFiltered - 1 + enabledOptions.length) % enabledOptions.length;
|
|
1029
|
+
setFocusedIndex(filteredOptions.indexOf(enabledOptions[prevIndex]));
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
break;
|
|
1033
|
+
case "Enter":
|
|
1034
|
+
e.preventDefault();
|
|
1035
|
+
if (isOpen && focusedIndex >= 0 && focusedIndex < filteredOptions.length) {
|
|
1036
|
+
const focusedOption = filteredOptions[focusedIndex];
|
|
1037
|
+
if (!focusedOption.disabled) {
|
|
1038
|
+
handleToggleOption(focusedOption.value);
|
|
1039
|
+
}
|
|
1040
|
+
} else if (!isOpen) {
|
|
1041
|
+
setIsOpen(true);
|
|
1042
|
+
}
|
|
1043
|
+
break;
|
|
1044
|
+
case "Escape":
|
|
1045
|
+
e.preventDefault();
|
|
1046
|
+
if (isOpen) {
|
|
1047
|
+
setIsOpen(false);
|
|
1048
|
+
setSearchQuery("");
|
|
1049
|
+
setFocusedIndex(-1);
|
|
1050
|
+
}
|
|
1051
|
+
break;
|
|
1052
|
+
case " ":
|
|
1053
|
+
if (isOpen && focusedIndex >= 0 && focusedIndex < filteredOptions.length) {
|
|
1054
|
+
e.preventDefault();
|
|
1055
|
+
const focusedOption = filteredOptions[focusedIndex];
|
|
1056
|
+
if (!focusedOption.disabled) {
|
|
1057
|
+
handleToggleOption(focusedOption.value);
|
|
1058
|
+
}
|
|
1059
|
+
} else if (!isOpen && !searchable) {
|
|
1060
|
+
e.preventDefault();
|
|
1061
|
+
setIsOpen(true);
|
|
1062
|
+
}
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
const handleBlur = (event) => {
|
|
1067
|
+
const nextTarget = event?.relatedTarget;
|
|
1068
|
+
const focusStayedInside = !!triggerRef.current && triggerRef.current.contains(nextTarget) || !!dropdownRef.current && dropdownRef.current.contains(nextTarget);
|
|
1069
|
+
if (!nextTarget || !focusStayedInside) {
|
|
1070
|
+
onBlur?.();
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
const closeDropdown = React9__namespace.useCallback(() => {
|
|
1074
|
+
setIsOpen(false);
|
|
1075
|
+
setSearchQuery("");
|
|
1076
|
+
setFocusedIndex(-1);
|
|
1077
|
+
onBlur?.();
|
|
1078
|
+
}, [onBlur]);
|
|
1079
|
+
useOnClickOutside.useOnClickOutside([triggerRef, dropdownRef], closeDropdown, void 0, {
|
|
1080
|
+
capture: true
|
|
1081
|
+
});
|
|
1082
|
+
const combinedClassName = cn("relative w-full", className);
|
|
1083
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
1084
|
+
"div",
|
|
1085
|
+
{
|
|
1086
|
+
className: combinedClassName,
|
|
1087
|
+
onKeyDown: handleKeyDown,
|
|
1088
|
+
onBlur: handleBlur
|
|
1089
|
+
},
|
|
1090
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1091
|
+
"select",
|
|
1092
|
+
{
|
|
1093
|
+
name,
|
|
1094
|
+
value,
|
|
1095
|
+
onChange: () => {
|
|
1096
|
+
},
|
|
1097
|
+
disabled,
|
|
1098
|
+
required,
|
|
1099
|
+
"aria-hidden": "true",
|
|
1100
|
+
tabIndex: -1,
|
|
1101
|
+
style: { display: "none" },
|
|
1102
|
+
multiple: true
|
|
1103
|
+
},
|
|
1104
|
+
/* @__PURE__ */ React9__namespace.createElement("option", { value: "" }, "Select..."),
|
|
1105
|
+
allOptions.map((option) => /* @__PURE__ */ React9__namespace.createElement("option", { key: option.value, value: option.value }, typeof option.label === "string" ? option.label : option.value))
|
|
1106
|
+
),
|
|
1107
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1108
|
+
"div",
|
|
1109
|
+
{
|
|
1110
|
+
ref: triggerRef,
|
|
1111
|
+
className: cn(
|
|
1112
|
+
"flex min-h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm",
|
|
1113
|
+
"cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
1114
|
+
!error && hasValue && "ring-2 ring-ring",
|
|
1115
|
+
disabled && "cursor-not-allowed opacity-50 pointer-events-none",
|
|
1116
|
+
error && "border-destructive ring-1 ring-destructive"
|
|
1117
|
+
),
|
|
1118
|
+
onClick: handleToggle,
|
|
1119
|
+
role: "combobox",
|
|
1120
|
+
"aria-expanded": isOpen,
|
|
1121
|
+
"aria-controls": dropdownId,
|
|
1122
|
+
"aria-invalid": error || props["aria-invalid"],
|
|
1123
|
+
"aria-describedby": props["aria-describedby"],
|
|
1124
|
+
"aria-required": required || props["aria-required"],
|
|
1125
|
+
"aria-disabled": disabled,
|
|
1126
|
+
tabIndex: disabled ? -1 : 0
|
|
1127
|
+
},
|
|
1128
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center flex-1 overflow-hidden" }, selectedOptions.length > 0 ? /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex flex-wrap gap-1" }, selectedOptions.map((option) => /* @__PURE__ */ React9__namespace.createElement(
|
|
1129
|
+
"span",
|
|
1130
|
+
{
|
|
1131
|
+
key: option.value,
|
|
1132
|
+
className: "inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium"
|
|
1133
|
+
},
|
|
1134
|
+
renderValue ? renderValue(option) : /* @__PURE__ */ React9__namespace.createElement(React9__namespace.Fragment, null, /* @__PURE__ */ React9__namespace.createElement("span", { className: "max-w-40 overflow-hidden text-ellipsis whitespace-nowrap" }, option.label), !disabled && /* @__PURE__ */ React9__namespace.createElement(
|
|
1135
|
+
"button",
|
|
1136
|
+
{
|
|
1137
|
+
type: "button",
|
|
1138
|
+
className: "flex items-center justify-center h-3.5 w-3.5 rounded-sm border-none bg-transparent cursor-pointer text-[0.625rem] p-0 transition-opacity hover:opacity-70",
|
|
1139
|
+
onClick: (e) => handleRemoveValue(option.value, e),
|
|
1140
|
+
"aria-label": `Remove ${option.label}`,
|
|
1141
|
+
tabIndex: -1
|
|
1142
|
+
},
|
|
1143
|
+
"\u2715"
|
|
1144
|
+
))
|
|
1145
|
+
))) : /* @__PURE__ */ React9__namespace.createElement("span", { className: "relative" }, placeholder)),
|
|
1146
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center gap-1 ml-2" }, loading && /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-xs" }, "\u23F3"), clearable && value.length > 0 && !disabled && !loading && /* @__PURE__ */ React9__namespace.createElement(
|
|
1147
|
+
"button",
|
|
1148
|
+
{
|
|
1149
|
+
type: "button",
|
|
1150
|
+
className: "flex items-center justify-center h-4 w-4 rounded-sm border-none bg-transparent cursor-pointer text-xs p-0 transition-opacity hover:opacity-70",
|
|
1151
|
+
onClick: handleClearAll,
|
|
1152
|
+
"aria-label": "Clear all selections",
|
|
1153
|
+
tabIndex: -1
|
|
1154
|
+
},
|
|
1155
|
+
"\u2715"
|
|
1156
|
+
), /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-xs leading-none", "aria-hidden": "true" }, isOpen ? "\u25B2" : "\u25BC"))
|
|
1157
|
+
),
|
|
1158
|
+
isOpen && /* @__PURE__ */ React9__namespace.createElement(
|
|
1159
|
+
"div",
|
|
1160
|
+
{
|
|
1161
|
+
ref: dropdownRef,
|
|
1162
|
+
id: dropdownId,
|
|
1163
|
+
className: "absolute z-50 top-full mt-1 w-full overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",
|
|
1164
|
+
role: "listbox",
|
|
1165
|
+
"aria-multiselectable": "true"
|
|
1166
|
+
},
|
|
1167
|
+
searchable && /* @__PURE__ */ React9__namespace.createElement("div", { className: "p-2 border-b border-border" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1168
|
+
"input",
|
|
1169
|
+
{
|
|
1170
|
+
ref: searchInputRef,
|
|
1171
|
+
type: "text",
|
|
1172
|
+
className: cn(
|
|
1173
|
+
"w-full border border-input rounded px-2 py-1 text-sm bg-transparent outline-none focus:ring-1 focus:ring-ring",
|
|
1174
|
+
INPUT_AUTOFILL_RESET_CLASSES
|
|
1175
|
+
),
|
|
1176
|
+
placeholder: "Search...",
|
|
1177
|
+
value: searchQuery,
|
|
1178
|
+
onChange: handleSearchChange,
|
|
1179
|
+
onClick: (e) => e.stopPropagation(),
|
|
1180
|
+
"aria-label": "Search options"
|
|
1181
|
+
}
|
|
1182
|
+
)),
|
|
1183
|
+
showSelectAll && filteredOptions.length > 0 && /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex gap-2 p-2 border-b border-border" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1184
|
+
"button",
|
|
1185
|
+
{
|
|
1186
|
+
type: "button",
|
|
1187
|
+
className: "flex-1 px-3 py-1.5 text-xs font-medium rounded border border-input bg-transparent hover:bg-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1188
|
+
onClick: handleSelectAll,
|
|
1189
|
+
disabled
|
|
1190
|
+
},
|
|
1191
|
+
"Select All"
|
|
1192
|
+
), value.length > 0 && /* @__PURE__ */ React9__namespace.createElement(
|
|
1193
|
+
"button",
|
|
1194
|
+
{
|
|
1195
|
+
type: "button",
|
|
1196
|
+
className: "flex-1 px-3 py-1.5 text-xs font-medium rounded border border-input bg-transparent hover:bg-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1197
|
+
onClick: handleClearAll,
|
|
1198
|
+
disabled
|
|
1199
|
+
},
|
|
1200
|
+
"Clear All"
|
|
1201
|
+
)),
|
|
1202
|
+
isMaxReached && /* @__PURE__ */ React9__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"),
|
|
1203
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { className: "max-h-64 overflow-y-auto p-1" }, filteredOptions.length === 0 ? /* @__PURE__ */ React9__namespace.createElement("div", { className: "px-2 py-1 text-center text-sm" }, "No options found") : optionGroups.length > 0 ? (
|
|
1204
|
+
// Render grouped options
|
|
1205
|
+
optionGroups.map((group, groupIndex) => {
|
|
1206
|
+
const groupOptions = group.options.filter(
|
|
1207
|
+
(opt) => filteredOptions.includes(opt)
|
|
1208
|
+
);
|
|
1209
|
+
if (groupOptions.length === 0) return null;
|
|
1210
|
+
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) => {
|
|
1211
|
+
const globalIndex = filteredOptions.indexOf(option);
|
|
1212
|
+
const isSelected = value.includes(option.value);
|
|
1213
|
+
const isFocused = globalIndex === focusedIndex;
|
|
1214
|
+
const isDisabled = option.disabled || isMaxReached && !isSelected;
|
|
1215
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
1216
|
+
"div",
|
|
1217
|
+
{
|
|
1218
|
+
key: option.value,
|
|
1219
|
+
className: cn(
|
|
1220
|
+
"relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 px-2 text-sm outline-none transition-colors hover:bg-muted",
|
|
1221
|
+
isFocused && "bg-muted",
|
|
1222
|
+
isSelected && "font-medium",
|
|
1223
|
+
isDisabled && "pointer-events-none opacity-50"
|
|
1224
|
+
),
|
|
1225
|
+
onClick: () => !isDisabled && handleToggleOption(option.value),
|
|
1226
|
+
role: "option",
|
|
1227
|
+
"aria-selected": isSelected,
|
|
1228
|
+
"aria-disabled": isDisabled
|
|
1229
|
+
},
|
|
1230
|
+
/* @__PURE__ */ React9__namespace.createElement("span", { className: "text-base leading-none" }, isSelected ? "\u2611" : "\u2610"),
|
|
1231
|
+
/* @__PURE__ */ React9__namespace.createElement("span", { className: "flex-1" }, renderOption ? renderOption(option) : option.label)
|
|
1232
|
+
);
|
|
1233
|
+
}));
|
|
1234
|
+
})
|
|
1235
|
+
) : (
|
|
1236
|
+
// Render flat options
|
|
1237
|
+
filteredOptions.map((option, index) => {
|
|
1238
|
+
const isSelected = value.includes(option.value);
|
|
1239
|
+
const isFocused = index === focusedIndex;
|
|
1240
|
+
const isDisabled = option.disabled || isMaxReached && !isSelected;
|
|
1241
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
1242
|
+
"div",
|
|
1243
|
+
{
|
|
1244
|
+
key: option.value,
|
|
1245
|
+
className: cn(
|
|
1246
|
+
"relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 px-2 text-sm outline-none transition-colors hover:bg-muted",
|
|
1247
|
+
isFocused && "bg-muted",
|
|
1248
|
+
isSelected && "font-medium bg-muted",
|
|
1249
|
+
isDisabled && "pointer-events-none opacity-50"
|
|
1250
|
+
),
|
|
1251
|
+
onClick: () => !isDisabled && handleToggleOption(option.value),
|
|
1252
|
+
role: "option",
|
|
1253
|
+
"aria-selected": isSelected,
|
|
1254
|
+
"aria-disabled": isDisabled
|
|
1255
|
+
},
|
|
1256
|
+
/* @__PURE__ */ React9__namespace.createElement("span", { className: "text-base leading-none" }, isSelected ? "\u2611" : "\u2610"),
|
|
1257
|
+
/* @__PURE__ */ React9__namespace.createElement("span", { className: "flex-1" }, renderOption ? renderOption(option) : option.label)
|
|
1258
|
+
);
|
|
1259
|
+
})
|
|
1260
|
+
))
|
|
1261
|
+
)
|
|
1262
|
+
);
|
|
1263
|
+
}
|
|
1264
|
+
MultiSelect.displayName = "MultiSelect";
|
|
904
1265
|
function FileInput({
|
|
905
1266
|
name,
|
|
906
1267
|
value = [],
|
|
@@ -926,14 +1287,14 @@ function FileInput({
|
|
|
926
1287
|
onFileRemove,
|
|
927
1288
|
...props
|
|
928
1289
|
}) {
|
|
929
|
-
const inputRef =
|
|
930
|
-
const [dragActive, setDragActive] =
|
|
931
|
-
const [cropperOpen, setCropperOpen] =
|
|
932
|
-
const [imageToCrop, setImageToCrop] =
|
|
933
|
-
const [crop, setCrop] =
|
|
934
|
-
const [zoom, setZoom] =
|
|
935
|
-
const [croppedAreaPixels, setCroppedAreaPixels] =
|
|
936
|
-
const validateFile =
|
|
1290
|
+
const inputRef = React9__namespace.useRef(null);
|
|
1291
|
+
const [dragActive, setDragActive] = React9__namespace.useState(false);
|
|
1292
|
+
const [cropperOpen, setCropperOpen] = React9__namespace.useState(false);
|
|
1293
|
+
const [imageToCrop, setImageToCrop] = React9__namespace.useState(null);
|
|
1294
|
+
const [crop, setCrop] = React9__namespace.useState({ x: 0, y: 0 });
|
|
1295
|
+
const [zoom, setZoom] = React9__namespace.useState(1);
|
|
1296
|
+
const [croppedAreaPixels, setCroppedAreaPixels] = React9__namespace.useState(null);
|
|
1297
|
+
const validateFile = React9__namespace.useCallback(
|
|
937
1298
|
(file) => {
|
|
938
1299
|
if (accept) {
|
|
939
1300
|
const acceptedTypes = accept.split(",").map((t) => t.trim());
|
|
@@ -968,7 +1329,7 @@ function FileInput({
|
|
|
968
1329
|
},
|
|
969
1330
|
[accept, maxSize]
|
|
970
1331
|
);
|
|
971
|
-
const handleFiles =
|
|
1332
|
+
const handleFiles = React9__namespace.useCallback(
|
|
972
1333
|
(fileList) => {
|
|
973
1334
|
if (!fileList || fileList.length === 0) return;
|
|
974
1335
|
const newFiles = Array.from(fileList);
|
|
@@ -1019,7 +1380,7 @@ function FileInput({
|
|
|
1019
1380
|
onValidationError
|
|
1020
1381
|
]
|
|
1021
1382
|
);
|
|
1022
|
-
const createCroppedImage =
|
|
1383
|
+
const createCroppedImage = React9__namespace.useCallback(
|
|
1023
1384
|
async (imageUrl, cropArea) => {
|
|
1024
1385
|
return new Promise((resolve, reject) => {
|
|
1025
1386
|
const image = new Image();
|
|
@@ -1063,7 +1424,7 @@ function FileInput({
|
|
|
1063
1424
|
},
|
|
1064
1425
|
[]
|
|
1065
1426
|
);
|
|
1066
|
-
const handleCropSave =
|
|
1427
|
+
const handleCropSave = React9__namespace.useCallback(async () => {
|
|
1067
1428
|
if (!imageToCrop || !croppedAreaPixels) return;
|
|
1068
1429
|
try {
|
|
1069
1430
|
const croppedBlob = await createCroppedImage(
|
|
@@ -1096,7 +1457,7 @@ function FileInput({
|
|
|
1096
1457
|
onChange,
|
|
1097
1458
|
multiple
|
|
1098
1459
|
]);
|
|
1099
|
-
const handleCropCancel =
|
|
1460
|
+
const handleCropCancel = React9__namespace.useCallback(() => {
|
|
1100
1461
|
if (imageToCrop) {
|
|
1101
1462
|
URL.revokeObjectURL(imageToCrop.url);
|
|
1102
1463
|
}
|
|
@@ -1106,13 +1467,13 @@ function FileInput({
|
|
|
1106
1467
|
setZoom(1);
|
|
1107
1468
|
setCroppedAreaPixels(null);
|
|
1108
1469
|
}, [imageToCrop]);
|
|
1109
|
-
const onCropChange =
|
|
1470
|
+
const onCropChange = React9__namespace.useCallback((crop2) => {
|
|
1110
1471
|
setCrop(crop2);
|
|
1111
1472
|
}, []);
|
|
1112
|
-
const onZoomChange =
|
|
1473
|
+
const onZoomChange = React9__namespace.useCallback((zoom2) => {
|
|
1113
1474
|
setZoom(zoom2);
|
|
1114
1475
|
}, []);
|
|
1115
|
-
const onCropCompleteInternal =
|
|
1476
|
+
const onCropCompleteInternal = React9__namespace.useCallback(
|
|
1116
1477
|
(_, croppedAreaPixels2) => {
|
|
1117
1478
|
setCroppedAreaPixels(croppedAreaPixels2);
|
|
1118
1479
|
},
|
|
@@ -1173,7 +1534,7 @@ function FileInput({
|
|
|
1173
1534
|
}
|
|
1174
1535
|
return null;
|
|
1175
1536
|
};
|
|
1176
|
-
|
|
1537
|
+
React9__namespace.useEffect(() => {
|
|
1177
1538
|
return () => {
|
|
1178
1539
|
value.forEach((file) => {
|
|
1179
1540
|
const previewUrl = getPreviewUrl(file);
|
|
@@ -1187,7 +1548,7 @@ function FileInput({
|
|
|
1187
1548
|
};
|
|
1188
1549
|
}, [value, imageToCrop]);
|
|
1189
1550
|
const combinedClassName = `${className}`.trim();
|
|
1190
|
-
return /* @__PURE__ */
|
|
1551
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { className: combinedClassName }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1191
1552
|
"input",
|
|
1192
1553
|
{
|
|
1193
1554
|
ref: inputRef,
|
|
@@ -1204,7 +1565,7 @@ function FileInput({
|
|
|
1204
1565
|
"aria-required": required || props["aria-required"],
|
|
1205
1566
|
style: { display: "none" }
|
|
1206
1567
|
}
|
|
1207
|
-
), /* @__PURE__ */
|
|
1568
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
1208
1569
|
"div",
|
|
1209
1570
|
{
|
|
1210
1571
|
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" : ""}`,
|
|
@@ -1219,7 +1580,7 @@ function FileInput({
|
|
|
1219
1580
|
"aria-label": placeholder,
|
|
1220
1581
|
"aria-disabled": disabled
|
|
1221
1582
|
},
|
|
1222
|
-
/* @__PURE__ */
|
|
1583
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { className: "flex flex-col items-center gap-2 text-center" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1223
1584
|
"svg",
|
|
1224
1585
|
{
|
|
1225
1586
|
width: "48",
|
|
@@ -1232,19 +1593,19 @@ function FileInput({
|
|
|
1232
1593
|
strokeLinejoin: "round",
|
|
1233
1594
|
"aria-hidden": "true"
|
|
1234
1595
|
},
|
|
1235
|
-
/* @__PURE__ */
|
|
1236
|
-
/* @__PURE__ */
|
|
1237
|
-
/* @__PURE__ */
|
|
1238
|
-
), /* @__PURE__ */
|
|
1239
|
-
), value.length > 0 && /* @__PURE__ */
|
|
1596
|
+
/* @__PURE__ */ React9__namespace.createElement("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1597
|
+
/* @__PURE__ */ React9__namespace.createElement("polyline", { points: "17 8 12 3 7 8" }),
|
|
1598
|
+
/* @__PURE__ */ React9__namespace.createElement("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
|
|
1599
|
+
), /* @__PURE__ */ React9__namespace.createElement("p", { className: "text-sm font-medium" }, value.length > 0 ? `${value.length} file(s) selected` : placeholder), accept && /* @__PURE__ */ React9__namespace.createElement("p", { className: "text-xs" }, "Accepted: ", accept), maxSize && /* @__PURE__ */ React9__namespace.createElement("p", { className: "text-xs " }, "Max size: ", formatFileSize(maxSize)))
|
|
1600
|
+
), value.length > 0 && /* @__PURE__ */ React9__namespace.createElement("ul", { className: "flex flex-col gap-2 mt-4", role: "list" }, value.map((file, index) => {
|
|
1240
1601
|
const previewUrl = showPreview ? getPreviewUrl(file) : null;
|
|
1241
|
-
return /* @__PURE__ */
|
|
1602
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
1242
1603
|
"li",
|
|
1243
1604
|
{
|
|
1244
1605
|
key: `${file.name}-${index}`,
|
|
1245
1606
|
className: "flex items-center gap-3 p-3 rounded-md border border-border bg-card text-card-foreground hover:bg-primary/50 transition-colors"
|
|
1246
1607
|
},
|
|
1247
|
-
previewUrl && /* @__PURE__ */
|
|
1608
|
+
previewUrl && /* @__PURE__ */ React9__namespace.createElement(
|
|
1248
1609
|
"img",
|
|
1249
1610
|
{
|
|
1250
1611
|
src: previewUrl,
|
|
@@ -1254,7 +1615,7 @@ function FileInput({
|
|
|
1254
1615
|
height: "48"
|
|
1255
1616
|
}
|
|
1256
1617
|
),
|
|
1257
|
-
/* @__PURE__ */
|
|
1618
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { className: "flex flex-col flex-1 min-w-0" }, /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-sm font-medium truncate" }, file.name), /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-xs" }, formatFileSize(file.size)), showProgress && uploadProgress[file.name] !== void 0 && /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center gap-2 mt-1" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1258
1619
|
"div",
|
|
1259
1620
|
{
|
|
1260
1621
|
className: "h-1.5 bg-muted rounded-full overflow-hidden flex-1",
|
|
@@ -1264,15 +1625,15 @@ function FileInput({
|
|
|
1264
1625
|
"aria-valuemax": 100,
|
|
1265
1626
|
"aria-label": `Upload progress: ${uploadProgress[file.name]}%`
|
|
1266
1627
|
},
|
|
1267
|
-
/* @__PURE__ */
|
|
1628
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1268
1629
|
"div",
|
|
1269
1630
|
{
|
|
1270
1631
|
className: "h-full bg-primary transition-all",
|
|
1271
1632
|
style: { width: `${uploadProgress[file.name]}%` }
|
|
1272
1633
|
}
|
|
1273
1634
|
)
|
|
1274
|
-
), /* @__PURE__ */
|
|
1275
|
-
enableCropping && file.type.startsWith("image/") && /* @__PURE__ */
|
|
1635
|
+
), /* @__PURE__ */ React9__namespace.createElement("span", { className: "text-xs " }, uploadProgress[file.name], "%"))),
|
|
1636
|
+
enableCropping && file.type.startsWith("image/") && /* @__PURE__ */ React9__namespace.createElement(
|
|
1276
1637
|
"button",
|
|
1277
1638
|
{
|
|
1278
1639
|
type: "button",
|
|
@@ -1284,7 +1645,7 @@ function FileInput({
|
|
|
1284
1645
|
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground transition-colors",
|
|
1285
1646
|
"aria-label": `Crop ${file.name}`
|
|
1286
1647
|
},
|
|
1287
|
-
/* @__PURE__ */
|
|
1648
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1288
1649
|
"svg",
|
|
1289
1650
|
{
|
|
1290
1651
|
width: "20",
|
|
@@ -1297,11 +1658,11 @@ function FileInput({
|
|
|
1297
1658
|
strokeLinejoin: "round",
|
|
1298
1659
|
"aria-hidden": "true"
|
|
1299
1660
|
},
|
|
1300
|
-
/* @__PURE__ */
|
|
1301
|
-
/* @__PURE__ */
|
|
1661
|
+
/* @__PURE__ */ React9__namespace.createElement("path", { d: "M6.13 1L6 16a2 2 0 0 0 2 2h15" }),
|
|
1662
|
+
/* @__PURE__ */ React9__namespace.createElement("path", { d: "M1 6.13L16 6a2 2 0 0 1 2 2v15" })
|
|
1302
1663
|
)
|
|
1303
1664
|
),
|
|
1304
|
-
/* @__PURE__ */
|
|
1665
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1305
1666
|
"button",
|
|
1306
1667
|
{
|
|
1307
1668
|
type: "button",
|
|
@@ -1313,7 +1674,7 @@ function FileInput({
|
|
|
1313
1674
|
className: "flex items-center justify-center h-8 w-8 rounded border-none bg-transparent hover:bg-primary hover:text-primary-foreground transition-colors",
|
|
1314
1675
|
"aria-label": `Remove ${file.name}`
|
|
1315
1676
|
},
|
|
1316
|
-
/* @__PURE__ */
|
|
1677
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1317
1678
|
"svg",
|
|
1318
1679
|
{
|
|
1319
1680
|
width: "20",
|
|
@@ -1326,19 +1687,19 @@ function FileInput({
|
|
|
1326
1687
|
strokeLinejoin: "round",
|
|
1327
1688
|
"aria-hidden": "true"
|
|
1328
1689
|
},
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1690
|
+
/* @__PURE__ */ React9__namespace.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1691
|
+
/* @__PURE__ */ React9__namespace.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1331
1692
|
)
|
|
1332
1693
|
)
|
|
1333
1694
|
);
|
|
1334
|
-
})), cropperOpen && imageToCrop && /* @__PURE__ */
|
|
1695
|
+
})), cropperOpen && imageToCrop && /* @__PURE__ */ React9__namespace.createElement("div", { className: "fixed inset-0 z-50 flex items-center justify-center" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1335
1696
|
"div",
|
|
1336
1697
|
{
|
|
1337
1698
|
className: "absolute inset-0 bg-black/50",
|
|
1338
1699
|
onClick: handleCropCancel,
|
|
1339
1700
|
"aria-label": "Close cropper"
|
|
1340
1701
|
}
|
|
1341
|
-
), /* @__PURE__ */
|
|
1702
|
+
), /* @__PURE__ */ React9__namespace.createElement("div", { className: "relative bg-popover border border-border rounded-lg shadow-lg max-w-3xl w-full mx-4" }, /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center justify-between p-4 border-b border-border" }, /* @__PURE__ */ React9__namespace.createElement("h3", { className: "text-lg font-semibold" }, "Crop Image"), /* @__PURE__ */ React9__namespace.createElement(
|
|
1342
1703
|
"button",
|
|
1343
1704
|
{
|
|
1344
1705
|
type: "button",
|
|
@@ -1347,7 +1708,7 @@ function FileInput({
|
|
|
1347
1708
|
"aria-label": "Close"
|
|
1348
1709
|
},
|
|
1349
1710
|
"\u2715"
|
|
1350
|
-
)), /* @__PURE__ */
|
|
1711
|
+
)), /* @__PURE__ */ React9__namespace.createElement("div", { className: "p-4" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1351
1712
|
"div",
|
|
1352
1713
|
{
|
|
1353
1714
|
className: "relative w-full h-96 bg-muted rounded-md overflow-hidden",
|
|
@@ -1369,7 +1730,7 @@ function FileInput({
|
|
|
1369
1730
|
document.addEventListener("mouseup", handleMouseUp);
|
|
1370
1731
|
}
|
|
1371
1732
|
},
|
|
1372
|
-
/* @__PURE__ */
|
|
1733
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1373
1734
|
"img",
|
|
1374
1735
|
{
|
|
1375
1736
|
src: imageToCrop.url,
|
|
@@ -1404,7 +1765,7 @@ function FileInput({
|
|
|
1404
1765
|
}
|
|
1405
1766
|
}
|
|
1406
1767
|
),
|
|
1407
|
-
/* @__PURE__ */
|
|
1768
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1408
1769
|
"div",
|
|
1409
1770
|
{
|
|
1410
1771
|
className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 border-2 border-primary rounded pointer-events-none",
|
|
@@ -1413,9 +1774,9 @@ function FileInput({
|
|
|
1413
1774
|
aspectRatio: cropAspectRatio ? String(cropAspectRatio) : void 0
|
|
1414
1775
|
}
|
|
1415
1776
|
},
|
|
1416
|
-
/* @__PURE__ */
|
|
1777
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { className: "absolute inset-0 grid grid-cols-3 grid-rows-3" }, /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-b border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-r border-b border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-b border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-r border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "border-r border-primary/30" }), /* @__PURE__ */ React9__namespace.createElement("div", null))
|
|
1417
1778
|
)
|
|
1418
|
-
), /* @__PURE__ */
|
|
1779
|
+
), /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center gap-3 mt-4" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1419
1780
|
"label",
|
|
1420
1781
|
{
|
|
1421
1782
|
htmlFor: "zoom-slider",
|
|
@@ -1424,7 +1785,7 @@ function FileInput({
|
|
|
1424
1785
|
"Zoom: ",
|
|
1425
1786
|
zoom.toFixed(1),
|
|
1426
1787
|
"x"
|
|
1427
|
-
), /* @__PURE__ */
|
|
1788
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
1428
1789
|
"input",
|
|
1429
1790
|
{
|
|
1430
1791
|
id: "zoom-slider",
|
|
@@ -1437,7 +1798,7 @@ function FileInput({
|
|
|
1437
1798
|
className: "flex-1 h-2 bg-muted rounded-lg appearance-none cursor-pointer",
|
|
1438
1799
|
"aria-label": "Zoom level"
|
|
1439
1800
|
}
|
|
1440
|
-
))), /* @__PURE__ */
|
|
1801
|
+
))), /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center justify-end gap-2 p-4 border-t border-border" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1441
1802
|
"button",
|
|
1442
1803
|
{
|
|
1443
1804
|
type: "button",
|
|
@@ -1445,7 +1806,7 @@ function FileInput({
|
|
|
1445
1806
|
onClick: handleCropCancel
|
|
1446
1807
|
},
|
|
1447
1808
|
"Cancel"
|
|
1448
|
-
), /* @__PURE__ */
|
|
1809
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
1449
1810
|
"button",
|
|
1450
1811
|
{
|
|
1451
1812
|
type: "button",
|
|
@@ -1487,13 +1848,13 @@ function DatePicker({
|
|
|
1487
1848
|
showIcon = true,
|
|
1488
1849
|
...props
|
|
1489
1850
|
}) {
|
|
1490
|
-
const [isOpen, setIsOpen] =
|
|
1491
|
-
const [selectedMonth, setSelectedMonth] =
|
|
1851
|
+
const [isOpen, setIsOpen] = React9__namespace.useState(false);
|
|
1852
|
+
const [selectedMonth, setSelectedMonth] = React9__namespace.useState(
|
|
1492
1853
|
value || /* @__PURE__ */ new Date()
|
|
1493
1854
|
);
|
|
1494
|
-
const
|
|
1495
|
-
const
|
|
1496
|
-
|
|
1855
|
+
const inputRef = React9__namespace.useRef(null);
|
|
1856
|
+
const dropdownRef = React9__namespace.useRef(null);
|
|
1857
|
+
React9__namespace.useEffect(() => {
|
|
1497
1858
|
if (value) {
|
|
1498
1859
|
setSelectedMonth(value);
|
|
1499
1860
|
}
|
|
@@ -1519,12 +1880,20 @@ function DatePicker({
|
|
|
1519
1880
|
if (isDateDisabled && isDateDisabled(date)) return true;
|
|
1520
1881
|
return false;
|
|
1521
1882
|
};
|
|
1522
|
-
const closeCalendar =
|
|
1523
|
-
if (!isOpen) return;
|
|
1883
|
+
const closeCalendar = React9__namespace.useCallback(() => {
|
|
1524
1884
|
setIsOpen(false);
|
|
1525
1885
|
onBlur?.();
|
|
1526
|
-
}, [
|
|
1527
|
-
useOnClickOutside.useOnClickOutside(
|
|
1886
|
+
}, [onBlur]);
|
|
1887
|
+
useOnClickOutside.useOnClickOutside([inputRef, dropdownRef], closeCalendar, void 0, {
|
|
1888
|
+
capture: true
|
|
1889
|
+
});
|
|
1890
|
+
const handleBlur = (event) => {
|
|
1891
|
+
const nextTarget = event?.relatedTarget;
|
|
1892
|
+
const focusStayedInside = !!inputRef.current && inputRef.current.contains(nextTarget) || !!dropdownRef.current && dropdownRef.current.contains(nextTarget);
|
|
1893
|
+
if (!nextTarget || !focusStayedInside) {
|
|
1894
|
+
onBlur?.();
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1528
1897
|
const dayGridStyle = {
|
|
1529
1898
|
gridTemplateColumns: "repeat(7, minmax(0, 1fr))"
|
|
1530
1899
|
};
|
|
@@ -1562,7 +1931,7 @@ function DatePicker({
|
|
|
1562
1931
|
const handleNextMonth = () => {
|
|
1563
1932
|
setSelectedMonth(new Date(year, month + 1, 1));
|
|
1564
1933
|
};
|
|
1565
|
-
return /* @__PURE__ */
|
|
1934
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { role: "grid", "aria-label": "Calendar", className: "w-[248px] max-w-full" }, /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center justify-between pb-3" }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1566
1935
|
"button",
|
|
1567
1936
|
{
|
|
1568
1937
|
type: "button",
|
|
@@ -1571,7 +1940,7 @@ function DatePicker({
|
|
|
1571
1940
|
"aria-label": "Previous month"
|
|
1572
1941
|
},
|
|
1573
1942
|
"\u2039"
|
|
1574
|
-
), /* @__PURE__ */
|
|
1943
|
+
), /* @__PURE__ */ React9__namespace.createElement("div", { className: "font-medium text-sm" }, `${monthNames[month]} ${year}`), /* @__PURE__ */ React9__namespace.createElement(
|
|
1575
1944
|
"button",
|
|
1576
1945
|
{
|
|
1577
1946
|
type: "button",
|
|
@@ -1580,13 +1949,13 @@ function DatePicker({
|
|
|
1580
1949
|
"aria-label": "Next month"
|
|
1581
1950
|
},
|
|
1582
1951
|
"\u203A"
|
|
1583
|
-
)), /* @__PURE__ */
|
|
1952
|
+
)), /* @__PURE__ */ React9__namespace.createElement(
|
|
1584
1953
|
"div",
|
|
1585
1954
|
{
|
|
1586
1955
|
className: "grid gap-1 text-xs text-muted-foreground",
|
|
1587
1956
|
style: dayGridStyle
|
|
1588
1957
|
},
|
|
1589
|
-
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */
|
|
1958
|
+
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React9__namespace.createElement(
|
|
1590
1959
|
"div",
|
|
1591
1960
|
{
|
|
1592
1961
|
key: day,
|
|
@@ -1594,14 +1963,14 @@ function DatePicker({
|
|
|
1594
1963
|
},
|
|
1595
1964
|
day
|
|
1596
1965
|
))
|
|
1597
|
-
), /* @__PURE__ */
|
|
1966
|
+
), /* @__PURE__ */ React9__namespace.createElement("div", { className: "grid gap-1", style: dayGridStyle }, days.map((date, index) => {
|
|
1598
1967
|
if (!date) {
|
|
1599
|
-
return /* @__PURE__ */
|
|
1968
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { key: `empty-${index}`, className: "h-8 w-8" });
|
|
1600
1969
|
}
|
|
1601
1970
|
const isSelected = value && date.toDateString() === value.toDateString();
|
|
1602
1971
|
const isToday = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
1603
1972
|
const disabled2 = isDisabled(date);
|
|
1604
|
-
return /* @__PURE__ */
|
|
1973
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
1605
1974
|
"button",
|
|
1606
1975
|
{
|
|
1607
1976
|
key: date.toISOString(),
|
|
@@ -1622,20 +1991,20 @@ function DatePicker({
|
|
|
1622
1991
|
})));
|
|
1623
1992
|
};
|
|
1624
1993
|
const combinedClassName = cn("relative", className);
|
|
1625
|
-
return /* @__PURE__ */
|
|
1994
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { className: combinedClassName, onBlur: handleBlur }, /* @__PURE__ */ React9__namespace.createElement(
|
|
1626
1995
|
"input",
|
|
1627
1996
|
{
|
|
1628
1997
|
type: "hidden",
|
|
1629
1998
|
name,
|
|
1630
1999
|
value: value ? value.toISOString() : ""
|
|
1631
2000
|
}
|
|
1632
|
-
), /* @__PURE__ */
|
|
2001
|
+
), /* @__PURE__ */ React9__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React9__namespace.createElement(
|
|
1633
2002
|
"span",
|
|
1634
2003
|
{
|
|
1635
2004
|
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
1636
2005
|
"aria-hidden": "true"
|
|
1637
2006
|
},
|
|
1638
|
-
/* @__PURE__ */
|
|
2007
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1639
2008
|
"svg",
|
|
1640
2009
|
{
|
|
1641
2010
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1648,9 +2017,9 @@ function DatePicker({
|
|
|
1648
2017
|
strokeLinejoin: "round",
|
|
1649
2018
|
strokeWidth: "2"
|
|
1650
2019
|
},
|
|
1651
|
-
/* @__PURE__ */
|
|
2020
|
+
/* @__PURE__ */ React9__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" })
|
|
1652
2021
|
)
|
|
1653
|
-
), /* @__PURE__ */
|
|
2022
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
1654
2023
|
"input",
|
|
1655
2024
|
{
|
|
1656
2025
|
ref: inputRef,
|
|
@@ -1667,7 +2036,6 @@ function DatePicker({
|
|
|
1667
2036
|
),
|
|
1668
2037
|
value: displayValue,
|
|
1669
2038
|
onClick: handleToggle,
|
|
1670
|
-
onBlur,
|
|
1671
2039
|
disabled,
|
|
1672
2040
|
required,
|
|
1673
2041
|
placeholder,
|
|
@@ -1676,7 +2044,7 @@ function DatePicker({
|
|
|
1676
2044
|
"aria-required": required || props["aria-required"],
|
|
1677
2045
|
readOnly: true
|
|
1678
2046
|
}
|
|
1679
|
-
), clearable && value && !disabled && /* @__PURE__ */
|
|
2047
|
+
), clearable && value && !disabled && /* @__PURE__ */ React9__namespace.createElement(
|
|
1680
2048
|
"button",
|
|
1681
2049
|
{
|
|
1682
2050
|
type: "button",
|
|
@@ -1686,7 +2054,14 @@ function DatePicker({
|
|
|
1686
2054
|
tabIndex: -1
|
|
1687
2055
|
},
|
|
1688
2056
|
"\u2715"
|
|
1689
|
-
)), isOpen && !disabled && /* @__PURE__ */
|
|
2057
|
+
)), isOpen && !disabled && /* @__PURE__ */ React9__namespace.createElement(
|
|
2058
|
+
"div",
|
|
2059
|
+
{
|
|
2060
|
+
ref: dropdownRef,
|
|
2061
|
+
className: "absolute z-50 top-full mt-1 w-fit rounded-md border border-border bg-popover text-popover-foreground shadow-md p-3"
|
|
2062
|
+
},
|
|
2063
|
+
renderCalendar()
|
|
2064
|
+
));
|
|
1690
2065
|
}
|
|
1691
2066
|
DatePicker.displayName = "DatePicker";
|
|
1692
2067
|
function normalizeToNativeTime(value) {
|
|
@@ -1746,11 +2121,11 @@ function TimePicker({
|
|
|
1746
2121
|
showIcon = true,
|
|
1747
2122
|
...props
|
|
1748
2123
|
}) {
|
|
1749
|
-
const inputRef =
|
|
1750
|
-
const [nativeValue, setNativeValue] =
|
|
2124
|
+
const inputRef = React9__namespace.useRef(null);
|
|
2125
|
+
const [nativeValue, setNativeValue] = React9__namespace.useState(
|
|
1751
2126
|
normalizeToNativeTime(value)
|
|
1752
2127
|
);
|
|
1753
|
-
|
|
2128
|
+
React9__namespace.useEffect(() => {
|
|
1754
2129
|
setNativeValue(normalizeToNativeTime(value));
|
|
1755
2130
|
}, [value]);
|
|
1756
2131
|
const handleChange = (e) => {
|
|
@@ -1766,13 +2141,13 @@ function TimePicker({
|
|
|
1766
2141
|
};
|
|
1767
2142
|
const hasValue = Boolean(value);
|
|
1768
2143
|
const stepInSeconds = Math.max(1, minuteStep * 60);
|
|
1769
|
-
return /* @__PURE__ */
|
|
2144
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { className: cn("relative", className) }, /* @__PURE__ */ React9__namespace.createElement("input", { type: "hidden", name, value }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React9__namespace.createElement(
|
|
1770
2145
|
"span",
|
|
1771
2146
|
{
|
|
1772
2147
|
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
1773
2148
|
"aria-hidden": "true"
|
|
1774
2149
|
},
|
|
1775
|
-
/* @__PURE__ */
|
|
2150
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
1776
2151
|
"svg",
|
|
1777
2152
|
{
|
|
1778
2153
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1785,10 +2160,10 @@ function TimePicker({
|
|
|
1785
2160
|
strokeLinejoin: "round",
|
|
1786
2161
|
strokeWidth: "2"
|
|
1787
2162
|
},
|
|
1788
|
-
/* @__PURE__ */
|
|
1789
|
-
/* @__PURE__ */
|
|
2163
|
+
/* @__PURE__ */ React9__namespace.createElement("circle", { cx: "12", cy: "12", r: "10" }),
|
|
2164
|
+
/* @__PURE__ */ React9__namespace.createElement("path", { d: "M12 6v6l4 2" })
|
|
1790
2165
|
)
|
|
1791
|
-
), /* @__PURE__ */
|
|
2166
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
1792
2167
|
"input",
|
|
1793
2168
|
{
|
|
1794
2169
|
ref: inputRef,
|
|
@@ -1816,7 +2191,7 @@ function TimePicker({
|
|
|
1816
2191
|
"aria-required": required || props["aria-required"],
|
|
1817
2192
|
...props
|
|
1818
2193
|
}
|
|
1819
|
-
), clearable && value && !disabled && /* @__PURE__ */
|
|
2194
|
+
), clearable && value && !disabled && /* @__PURE__ */ React9__namespace.createElement(
|
|
1820
2195
|
"button",
|
|
1821
2196
|
{
|
|
1822
2197
|
type: "button",
|
|
@@ -1869,15 +2244,16 @@ function DateRangePicker({
|
|
|
1869
2244
|
separator = " - ",
|
|
1870
2245
|
...props
|
|
1871
2246
|
}) {
|
|
1872
|
-
const [isOpen, setIsOpen] =
|
|
1873
|
-
const [selectedMonth, setSelectedMonth] =
|
|
2247
|
+
const [isOpen, setIsOpen] = React9__namespace.useState(false);
|
|
2248
|
+
const [selectedMonth, setSelectedMonth] = React9__namespace.useState(
|
|
1874
2249
|
value.start || /* @__PURE__ */ new Date()
|
|
1875
2250
|
);
|
|
1876
|
-
const [rangeStart, setRangeStart] =
|
|
1877
|
-
const [rangeEnd, setRangeEnd] =
|
|
1878
|
-
const [hoverDate, setHoverDate] =
|
|
1879
|
-
const
|
|
1880
|
-
|
|
2251
|
+
const [rangeStart, setRangeStart] = React9__namespace.useState(value.start);
|
|
2252
|
+
const [rangeEnd, setRangeEnd] = React9__namespace.useState(value.end);
|
|
2253
|
+
const [hoverDate, setHoverDate] = React9__namespace.useState(null);
|
|
2254
|
+
const triggerRef = React9__namespace.useRef(null);
|
|
2255
|
+
const dropdownRef = React9__namespace.useRef(null);
|
|
2256
|
+
React9__namespace.useEffect(() => {
|
|
1881
2257
|
setRangeStart(value.start);
|
|
1882
2258
|
setRangeEnd(value.end);
|
|
1883
2259
|
if (value.start) {
|
|
@@ -1920,12 +2296,20 @@ function DateRangePicker({
|
|
|
1920
2296
|
if (isDateDisabled && isDateDisabled(date)) return true;
|
|
1921
2297
|
return false;
|
|
1922
2298
|
};
|
|
1923
|
-
const closeCalendar =
|
|
1924
|
-
if (!isOpen) return;
|
|
2299
|
+
const closeCalendar = React9__namespace.useCallback(() => {
|
|
1925
2300
|
setIsOpen(false);
|
|
1926
2301
|
onBlur?.();
|
|
1927
|
-
}, [
|
|
1928
|
-
useOnClickOutside.useOnClickOutside(
|
|
2302
|
+
}, [onBlur]);
|
|
2303
|
+
useOnClickOutside.useOnClickOutside([triggerRef, dropdownRef], closeCalendar, void 0, {
|
|
2304
|
+
capture: true
|
|
2305
|
+
});
|
|
2306
|
+
const handleBlur = (event) => {
|
|
2307
|
+
const nextTarget = event?.relatedTarget;
|
|
2308
|
+
const focusStayedInside = !!triggerRef.current && triggerRef.current.contains(nextTarget) || !!dropdownRef.current && dropdownRef.current.contains(nextTarget);
|
|
2309
|
+
if (!nextTarget || !focusStayedInside) {
|
|
2310
|
+
onBlur?.();
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
1929
2313
|
const dayGridStyle = {
|
|
1930
2314
|
gridTemplateColumns: "repeat(7, minmax(0, 1fr))"
|
|
1931
2315
|
};
|
|
@@ -1959,7 +2343,7 @@ function DateRangePicker({
|
|
|
1959
2343
|
for (let day = 1; day <= daysInMonth; day++) {
|
|
1960
2344
|
days.push(new Date(year, month, day));
|
|
1961
2345
|
}
|
|
1962
|
-
return /* @__PURE__ */
|
|
2346
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { className: "w-[240px] max-w-full" }, /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center justify-between pb-3" }, controls?.prev ? /* @__PURE__ */ React9__namespace.createElement(
|
|
1963
2347
|
"button",
|
|
1964
2348
|
{
|
|
1965
2349
|
type: "button",
|
|
@@ -1968,7 +2352,7 @@ function DateRangePicker({
|
|
|
1968
2352
|
"aria-label": "Previous month"
|
|
1969
2353
|
},
|
|
1970
2354
|
"\u2039"
|
|
1971
|
-
) : /* @__PURE__ */
|
|
2355
|
+
) : /* @__PURE__ */ React9__namespace.createElement("div", { className: "h-8 w-8", "aria-hidden": "true" }), /* @__PURE__ */ React9__namespace.createElement("div", { className: "font-medium text-sm" }, `${monthNames[month]} ${year}`), controls?.next ? /* @__PURE__ */ React9__namespace.createElement(
|
|
1972
2356
|
"button",
|
|
1973
2357
|
{
|
|
1974
2358
|
type: "button",
|
|
@@ -1977,13 +2361,13 @@ function DateRangePicker({
|
|
|
1977
2361
|
"aria-label": "Next month"
|
|
1978
2362
|
},
|
|
1979
2363
|
"\u203A"
|
|
1980
|
-
) : /* @__PURE__ */
|
|
2364
|
+
) : /* @__PURE__ */ React9__namespace.createElement("div", { className: "h-8 w-8", "aria-hidden": "true" })), /* @__PURE__ */ React9__namespace.createElement(
|
|
1981
2365
|
"div",
|
|
1982
2366
|
{
|
|
1983
2367
|
className: "grid gap-1 text-xs text-muted-foreground",
|
|
1984
2368
|
style: dayGridStyle
|
|
1985
2369
|
},
|
|
1986
|
-
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */
|
|
2370
|
+
["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((day) => /* @__PURE__ */ React9__namespace.createElement(
|
|
1987
2371
|
"div",
|
|
1988
2372
|
{
|
|
1989
2373
|
key: `${month}-${day}`,
|
|
@@ -1991,9 +2375,9 @@ function DateRangePicker({
|
|
|
1991
2375
|
},
|
|
1992
2376
|
day
|
|
1993
2377
|
))
|
|
1994
|
-
), /* @__PURE__ */
|
|
2378
|
+
), /* @__PURE__ */ React9__namespace.createElement("div", { className: "grid gap-1", style: dayGridStyle }, days.map((date, index) => {
|
|
1995
2379
|
if (!date) {
|
|
1996
|
-
return /* @__PURE__ */
|
|
2380
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { key: `empty-${month}-${index}`, className: "h-8 w-8" });
|
|
1997
2381
|
}
|
|
1998
2382
|
const isStart = rangeStart && date.toDateString() === rangeStart.toDateString();
|
|
1999
2383
|
const isEnd = rangeEnd && date.toDateString() === rangeEnd.toDateString();
|
|
@@ -2005,7 +2389,7 @@ function DateRangePicker({
|
|
|
2005
2389
|
);
|
|
2006
2390
|
const isToday = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
2007
2391
|
const disabled2 = isDisabled(date);
|
|
2008
|
-
return /* @__PURE__ */
|
|
2392
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
2009
2393
|
"button",
|
|
2010
2394
|
{
|
|
2011
2395
|
key: date.toISOString(),
|
|
@@ -2030,27 +2414,27 @@ function DateRangePicker({
|
|
|
2030
2414
|
};
|
|
2031
2415
|
const combinedClassName = cn("relative", className);
|
|
2032
2416
|
const displayValue = rangeStart && rangeEnd ? `${formatDate2(rangeStart, format)}${separator}${formatDate2(rangeEnd, format)}` : rangeStart ? formatDate2(rangeStart, format) : "";
|
|
2033
|
-
return /* @__PURE__ */
|
|
2417
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { className: combinedClassName, onBlur: handleBlur }, /* @__PURE__ */ React9__namespace.createElement(
|
|
2034
2418
|
"input",
|
|
2035
2419
|
{
|
|
2036
2420
|
type: "hidden",
|
|
2037
2421
|
name: `${name}[start]`,
|
|
2038
2422
|
value: rangeStart ? rangeStart.toISOString() : ""
|
|
2039
2423
|
}
|
|
2040
|
-
), /* @__PURE__ */
|
|
2424
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
2041
2425
|
"input",
|
|
2042
2426
|
{
|
|
2043
2427
|
type: "hidden",
|
|
2044
2428
|
name: `${name}[end]`,
|
|
2045
2429
|
value: rangeEnd ? rangeEnd.toISOString() : ""
|
|
2046
2430
|
}
|
|
2047
|
-
), /* @__PURE__ */
|
|
2431
|
+
), /* @__PURE__ */ React9__namespace.createElement("div", { className: "relative" }, showIcon && /* @__PURE__ */ React9__namespace.createElement(
|
|
2048
2432
|
"span",
|
|
2049
2433
|
{
|
|
2050
2434
|
className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",
|
|
2051
2435
|
"aria-hidden": "true"
|
|
2052
2436
|
},
|
|
2053
|
-
/* @__PURE__ */
|
|
2437
|
+
/* @__PURE__ */ React9__namespace.createElement(
|
|
2054
2438
|
"svg",
|
|
2055
2439
|
{
|
|
2056
2440
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2063,11 +2447,12 @@ function DateRangePicker({
|
|
|
2063
2447
|
strokeLinejoin: "round",
|
|
2064
2448
|
strokeWidth: "2"
|
|
2065
2449
|
},
|
|
2066
|
-
/* @__PURE__ */
|
|
2450
|
+
/* @__PURE__ */ React9__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" })
|
|
2067
2451
|
)
|
|
2068
|
-
), /* @__PURE__ */
|
|
2452
|
+
), /* @__PURE__ */ React9__namespace.createElement(
|
|
2069
2453
|
"input",
|
|
2070
2454
|
{
|
|
2455
|
+
ref: triggerRef,
|
|
2071
2456
|
type: "text",
|
|
2072
2457
|
className: cn(
|
|
2073
2458
|
"flex h-9 w-full rounded-md border border-input bg-transparent py-1 text-base shadow-sm transition-colors",
|
|
@@ -2081,7 +2466,6 @@ function DateRangePicker({
|
|
|
2081
2466
|
),
|
|
2082
2467
|
value: displayValue,
|
|
2083
2468
|
onClick: handleToggle,
|
|
2084
|
-
onBlur,
|
|
2085
2469
|
disabled,
|
|
2086
2470
|
required,
|
|
2087
2471
|
placeholder,
|
|
@@ -2090,7 +2474,7 @@ function DateRangePicker({
|
|
|
2090
2474
|
"aria-required": required || props["aria-required"],
|
|
2091
2475
|
readOnly: true
|
|
2092
2476
|
}
|
|
2093
|
-
), clearable && (rangeStart || rangeEnd) && !disabled && /* @__PURE__ */
|
|
2477
|
+
), clearable && (rangeStart || rangeEnd) && !disabled && /* @__PURE__ */ React9__namespace.createElement(
|
|
2094
2478
|
"button",
|
|
2095
2479
|
{
|
|
2096
2480
|
type: "button",
|
|
@@ -2100,7 +2484,15 @@ function DateRangePicker({
|
|
|
2100
2484
|
tabIndex: -1
|
|
2101
2485
|
},
|
|
2102
2486
|
"\u2715"
|
|
2103
|
-
)), isOpen && !disabled && /* @__PURE__ */
|
|
2487
|
+
)), isOpen && !disabled && /* @__PURE__ */ React9__namespace.createElement(
|
|
2488
|
+
"div",
|
|
2489
|
+
{
|
|
2490
|
+
ref: dropdownRef,
|
|
2491
|
+
className: "absolute z-50 top-full mt-1 w-fit rounded-md border border-border bg-popover text-popover-foreground shadow-md p-3"
|
|
2492
|
+
},
|
|
2493
|
+
/* @__PURE__ */ React9__namespace.createElement("div", { role: "grid", "aria-label": "Calendar" }, /* @__PURE__ */ React9__namespace.createElement("div", { className: "grid gap-4", style: monthsGridStyle }, renderMonth(selectedMonth, { prev: true }), renderMonth(addMonths(selectedMonth, 1), { next: true }))),
|
|
2494
|
+
rangeStart && !rangeEnd && /* @__PURE__ */ React9__namespace.createElement("div", { className: "text-xs text-center pt-2 border-t border-border mt-2" }, "Select end date")
|
|
2495
|
+
));
|
|
2104
2496
|
}
|
|
2105
2497
|
DateRangePicker.displayName = "DateRangePicker";
|
|
2106
2498
|
function htmlToMarkdown(html) {
|
|
@@ -2171,11 +2563,11 @@ function RichTextEditor({
|
|
|
2171
2563
|
],
|
|
2172
2564
|
...props
|
|
2173
2565
|
}) {
|
|
2174
|
-
const [currentMode, setCurrentMode] =
|
|
2175
|
-
const [content, setContent] =
|
|
2176
|
-
const editorRef =
|
|
2177
|
-
const textareaRef =
|
|
2178
|
-
|
|
2566
|
+
const [currentMode, setCurrentMode] = React9__namespace.useState(mode);
|
|
2567
|
+
const [content, setContent] = React9__namespace.useState(value);
|
|
2568
|
+
const editorRef = React9__namespace.useRef(null);
|
|
2569
|
+
const textareaRef = React9__namespace.useRef(null);
|
|
2570
|
+
React9__namespace.useEffect(() => {
|
|
2179
2571
|
setContent(value);
|
|
2180
2572
|
if (currentMode === "wysiwyg" && editorRef.current) {
|
|
2181
2573
|
editorRef.current.innerHTML = value;
|
|
@@ -2263,7 +2655,7 @@ function RichTextEditor({
|
|
|
2263
2655
|
}
|
|
2264
2656
|
}
|
|
2265
2657
|
};
|
|
2266
|
-
const hasValue =
|
|
2658
|
+
const hasValue = React9__namespace.useMemo(() => {
|
|
2267
2659
|
if (!content) return false;
|
|
2268
2660
|
const stripped = content.replace(/<[^>]+>/g, "").trim();
|
|
2269
2661
|
return stripped.length > 0;
|
|
@@ -2280,10 +2672,10 @@ function RichTextEditor({
|
|
|
2280
2672
|
maxHeight,
|
|
2281
2673
|
overflowY: maxHeight ? "auto" : void 0
|
|
2282
2674
|
};
|
|
2283
|
-
return /* @__PURE__ */
|
|
2675
|
+
return /* @__PURE__ */ React9__namespace.createElement("div", { className: combinedClassName }, /* @__PURE__ */ React9__namespace.createElement("input", { type: "hidden", name, value: content }), showToolbar && /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center justify-between p-2 border-b border-border bg-muted/50" }, /* @__PURE__ */ React9__namespace.createElement("div", { className: "flex items-center gap-1" }, toolbarButtons.map((buttonName) => {
|
|
2284
2676
|
const button = toolbarConfig[buttonName];
|
|
2285
2677
|
if (!button) return null;
|
|
2286
|
-
return /* @__PURE__ */
|
|
2678
|
+
return /* @__PURE__ */ React9__namespace.createElement(
|
|
2287
2679
|
"button",
|
|
2288
2680
|
{
|
|
2289
2681
|
key: buttonName,
|
|
@@ -2296,7 +2688,7 @@ function RichTextEditor({
|
|
|
2296
2688
|
},
|
|
2297
2689
|
button.icon
|
|
2298
2690
|
);
|
|
2299
|
-
})), allowModeSwitch && /* @__PURE__ */
|
|
2691
|
+
})), allowModeSwitch && /* @__PURE__ */ React9__namespace.createElement(
|
|
2300
2692
|
"button",
|
|
2301
2693
|
{
|
|
2302
2694
|
type: "button",
|
|
@@ -2307,7 +2699,7 @@ function RichTextEditor({
|
|
|
2307
2699
|
"aria-label": `Switch to ${currentMode === "wysiwyg" ? "Markdown" : "WYSIWYG"}`
|
|
2308
2700
|
},
|
|
2309
2701
|
currentMode === "wysiwyg" ? "MD" : "WYSIWYG"
|
|
2310
|
-
)), /* @__PURE__ */
|
|
2702
|
+
)), /* @__PURE__ */ React9__namespace.createElement("div", { style: editorStyle }, currentMode === "wysiwyg" ? /* @__PURE__ */ React9__namespace.createElement(
|
|
2311
2703
|
"div",
|
|
2312
2704
|
{
|
|
2313
2705
|
ref: editorRef,
|
|
@@ -2322,7 +2714,7 @@ function RichTextEditor({
|
|
|
2322
2714
|
"aria-required": required || props["aria-required"],
|
|
2323
2715
|
suppressContentEditableWarning: true
|
|
2324
2716
|
}
|
|
2325
|
-
) : /* @__PURE__ */
|
|
2717
|
+
) : /* @__PURE__ */ React9__namespace.createElement(
|
|
2326
2718
|
"textarea",
|
|
2327
2719
|
{
|
|
2328
2720
|
ref: textareaRef,
|
|
@@ -2350,6 +2742,7 @@ exports.CheckboxGroup = CheckboxGroup;
|
|
|
2350
2742
|
exports.DatePicker = DatePicker;
|
|
2351
2743
|
exports.DateRangePicker = DateRangePicker;
|
|
2352
2744
|
exports.FileInput = FileInput;
|
|
2745
|
+
exports.MultiSelect = MultiSelect;
|
|
2353
2746
|
exports.Radio = Radio;
|
|
2354
2747
|
exports.RichTextEditor = RichTextEditor;
|
|
2355
2748
|
exports.Select = Select;
|