@ikatec/nebula-react 1.0.14 → 1.0.16
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/index.d.mts +118 -57
- package/dist/index.d.ts +118 -57
- package/dist/index.js +1512 -328
- package/dist/index.mjs +1482 -308
- package/package.json +7 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React8 from 'react';
|
|
2
|
-
import React8__default, {
|
|
2
|
+
import React8__default, { createContext, forwardRef, useMemo, useState, useEffect, useCallback, useContext, useRef } from 'react';
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import { extendTailwindMerge } from 'tailwind-merge';
|
|
@@ -7,6 +7,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
7
7
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
8
8
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
9
9
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
10
|
+
import { ChevronRight, Check, Circle, CircleX, Eye, EyeOff, X, Minus, ClockIcon, ChevronsLeft, ChevronLeft, ChevronsRight, MoreHorizontal, ChevronDown, ChevronLeftIcon, ChevronDownIcon, ChevronRightIcon, CalendarIcon, ImageUpIcon, XIcon, PhoneIcon, FileTextIcon, FileAudioIcon, FileVideoIcon, Info, CircleCheckBig } from 'lucide-react';
|
|
10
11
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
11
12
|
import Select, { components } from 'react-select';
|
|
12
13
|
import Creatable from 'react-select/creatable';
|
|
@@ -22,6 +23,9 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
|
22
23
|
import { Toaster as Toaster$1, toast as toast$1 } from 'sonner';
|
|
23
24
|
import * as RPNInput from 'react-phone-number-input';
|
|
24
25
|
import flags from 'react-phone-number-input/flags';
|
|
26
|
+
import { formatDate, isValid, addMonths, isSameDay, isBefore, isAfter } from 'date-fns';
|
|
27
|
+
import { DayPicker } from 'react-day-picker';
|
|
28
|
+
import { ptBR, enUS, es } from 'react-day-picker/locale';
|
|
25
29
|
|
|
26
30
|
// src/button.tsx
|
|
27
31
|
|
|
@@ -495,193 +499,6 @@ var TableCell = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__
|
|
|
495
499
|
TableCell.displayName = "TableCell";
|
|
496
500
|
var TableCaption = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("caption", { ref, className: cn("mt-4 text-sm", className), ...props }));
|
|
497
501
|
TableCaption.displayName = "TableCaption";
|
|
498
|
-
|
|
499
|
-
// ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
|
|
500
|
-
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
501
|
-
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
502
|
-
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
503
|
-
}).join(" ").trim();
|
|
504
|
-
|
|
505
|
-
// ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
|
|
506
|
-
var defaultAttributes = {
|
|
507
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
508
|
-
width: 24,
|
|
509
|
-
height: 24,
|
|
510
|
-
viewBox: "0 0 24 24",
|
|
511
|
-
fill: "none",
|
|
512
|
-
stroke: "currentColor",
|
|
513
|
-
strokeWidth: 2,
|
|
514
|
-
strokeLinecap: "round",
|
|
515
|
-
strokeLinejoin: "round"
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
// ../../node_modules/lucide-react/dist/esm/Icon.js
|
|
519
|
-
var Icon = forwardRef(
|
|
520
|
-
({
|
|
521
|
-
color: color2 = "currentColor",
|
|
522
|
-
size: size4 = 24,
|
|
523
|
-
strokeWidth = 2,
|
|
524
|
-
absoluteStrokeWidth,
|
|
525
|
-
className = "",
|
|
526
|
-
children,
|
|
527
|
-
iconNode,
|
|
528
|
-
...rest
|
|
529
|
-
}, ref) => {
|
|
530
|
-
return createElement(
|
|
531
|
-
"svg",
|
|
532
|
-
{
|
|
533
|
-
ref,
|
|
534
|
-
...defaultAttributes,
|
|
535
|
-
width: size4,
|
|
536
|
-
height: size4,
|
|
537
|
-
stroke: color2,
|
|
538
|
-
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size4) : strokeWidth,
|
|
539
|
-
className: mergeClasses("lucide", className),
|
|
540
|
-
...rest
|
|
541
|
-
},
|
|
542
|
-
[
|
|
543
|
-
...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
|
|
544
|
-
...Array.isArray(children) ? children : [children]
|
|
545
|
-
]
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
);
|
|
549
|
-
|
|
550
|
-
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
551
|
-
var createLucideIcon = (iconName, iconNode) => {
|
|
552
|
-
const Component = forwardRef(
|
|
553
|
-
({ className, ...props }, ref) => createElement(Icon, {
|
|
554
|
-
ref,
|
|
555
|
-
iconNode,
|
|
556
|
-
className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
|
|
557
|
-
...props
|
|
558
|
-
})
|
|
559
|
-
);
|
|
560
|
-
Component.displayName = `${iconName}`;
|
|
561
|
-
return Component;
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
// ../../node_modules/lucide-react/dist/esm/icons/check.js
|
|
565
|
-
var __iconNode = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
566
|
-
var Check = createLucideIcon("Check", __iconNode);
|
|
567
|
-
|
|
568
|
-
// ../../node_modules/lucide-react/dist/esm/icons/chevron-down.js
|
|
569
|
-
var __iconNode2 = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
|
|
570
|
-
var ChevronDown = createLucideIcon("ChevronDown", __iconNode2);
|
|
571
|
-
|
|
572
|
-
// ../../node_modules/lucide-react/dist/esm/icons/chevron-left.js
|
|
573
|
-
var __iconNode3 = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
|
|
574
|
-
var ChevronLeft = createLucideIcon("ChevronLeft", __iconNode3);
|
|
575
|
-
|
|
576
|
-
// ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
|
|
577
|
-
var __iconNode4 = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
|
|
578
|
-
var ChevronRight = createLucideIcon("ChevronRight", __iconNode4);
|
|
579
|
-
|
|
580
|
-
// ../../node_modules/lucide-react/dist/esm/icons/chevrons-left.js
|
|
581
|
-
var __iconNode5 = [
|
|
582
|
-
["path", { d: "m11 17-5-5 5-5", key: "13zhaf" }],
|
|
583
|
-
["path", { d: "m18 17-5-5 5-5", key: "h8a8et" }]
|
|
584
|
-
];
|
|
585
|
-
var ChevronsLeft = createLucideIcon("ChevronsLeft", __iconNode5);
|
|
586
|
-
|
|
587
|
-
// ../../node_modules/lucide-react/dist/esm/icons/chevrons-right.js
|
|
588
|
-
var __iconNode6 = [
|
|
589
|
-
["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
|
|
590
|
-
["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
|
|
591
|
-
];
|
|
592
|
-
var ChevronsRight = createLucideIcon("ChevronsRight", __iconNode6);
|
|
593
|
-
|
|
594
|
-
// ../../node_modules/lucide-react/dist/esm/icons/circle-check-big.js
|
|
595
|
-
var __iconNode7 = [
|
|
596
|
-
["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
|
|
597
|
-
["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
|
|
598
|
-
];
|
|
599
|
-
var CircleCheckBig = createLucideIcon("CircleCheckBig", __iconNode7);
|
|
600
|
-
|
|
601
|
-
// ../../node_modules/lucide-react/dist/esm/icons/circle-x.js
|
|
602
|
-
var __iconNode8 = [
|
|
603
|
-
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
604
|
-
["path", { d: "m15 9-6 6", key: "1uzhvr" }],
|
|
605
|
-
["path", { d: "m9 9 6 6", key: "z0biqf" }]
|
|
606
|
-
];
|
|
607
|
-
var CircleX = createLucideIcon("CircleX", __iconNode8);
|
|
608
|
-
|
|
609
|
-
// ../../node_modules/lucide-react/dist/esm/icons/circle.js
|
|
610
|
-
var __iconNode9 = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
|
|
611
|
-
var Circle = createLucideIcon("Circle", __iconNode9);
|
|
612
|
-
|
|
613
|
-
// ../../node_modules/lucide-react/dist/esm/icons/ellipsis.js
|
|
614
|
-
var __iconNode10 = [
|
|
615
|
-
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
|
|
616
|
-
["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
|
|
617
|
-
["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
|
|
618
|
-
];
|
|
619
|
-
var Ellipsis = createLucideIcon("Ellipsis", __iconNode10);
|
|
620
|
-
|
|
621
|
-
// ../../node_modules/lucide-react/dist/esm/icons/eye-off.js
|
|
622
|
-
var __iconNode11 = [
|
|
623
|
-
[
|
|
624
|
-
"path",
|
|
625
|
-
{
|
|
626
|
-
d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
|
|
627
|
-
key: "ct8e1f"
|
|
628
|
-
}
|
|
629
|
-
],
|
|
630
|
-
["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
|
|
631
|
-
[
|
|
632
|
-
"path",
|
|
633
|
-
{
|
|
634
|
-
d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
|
|
635
|
-
key: "13bj9a"
|
|
636
|
-
}
|
|
637
|
-
],
|
|
638
|
-
["path", { d: "m2 2 20 20", key: "1ooewy" }]
|
|
639
|
-
];
|
|
640
|
-
var EyeOff = createLucideIcon("EyeOff", __iconNode11);
|
|
641
|
-
|
|
642
|
-
// ../../node_modules/lucide-react/dist/esm/icons/eye.js
|
|
643
|
-
var __iconNode12 = [
|
|
644
|
-
[
|
|
645
|
-
"path",
|
|
646
|
-
{
|
|
647
|
-
d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
|
|
648
|
-
key: "1nclc0"
|
|
649
|
-
}
|
|
650
|
-
],
|
|
651
|
-
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
|
|
652
|
-
];
|
|
653
|
-
var Eye = createLucideIcon("Eye", __iconNode12);
|
|
654
|
-
|
|
655
|
-
// ../../node_modules/lucide-react/dist/esm/icons/info.js
|
|
656
|
-
var __iconNode13 = [
|
|
657
|
-
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
658
|
-
["path", { d: "M12 16v-4", key: "1dtifu" }],
|
|
659
|
-
["path", { d: "M12 8h.01", key: "e9boi3" }]
|
|
660
|
-
];
|
|
661
|
-
var Info = createLucideIcon("Info", __iconNode13);
|
|
662
|
-
|
|
663
|
-
// ../../node_modules/lucide-react/dist/esm/icons/minus.js
|
|
664
|
-
var __iconNode14 = [["path", { d: "M5 12h14", key: "1ays0h" }]];
|
|
665
|
-
var Minus = createLucideIcon("Minus", __iconNode14);
|
|
666
|
-
|
|
667
|
-
// ../../node_modules/lucide-react/dist/esm/icons/phone.js
|
|
668
|
-
var __iconNode15 = [
|
|
669
|
-
[
|
|
670
|
-
"path",
|
|
671
|
-
{
|
|
672
|
-
d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",
|
|
673
|
-
key: "foiqr5"
|
|
674
|
-
}
|
|
675
|
-
]
|
|
676
|
-
];
|
|
677
|
-
var Phone = createLucideIcon("Phone", __iconNode15);
|
|
678
|
-
|
|
679
|
-
// ../../node_modules/lucide-react/dist/esm/icons/x.js
|
|
680
|
-
var __iconNode16 = [
|
|
681
|
-
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
682
|
-
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
683
|
-
];
|
|
684
|
-
var X = createLucideIcon("X", __iconNode16);
|
|
685
502
|
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
686
503
|
var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
687
504
|
var DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
@@ -1287,15 +1104,29 @@ var messages3 = {
|
|
|
1287
1104
|
};
|
|
1288
1105
|
var input_phone_default = messages3;
|
|
1289
1106
|
|
|
1107
|
+
// src/i18n/messages/en/time-picker.ts
|
|
1108
|
+
var messages4 = {
|
|
1109
|
+
label: "Time"
|
|
1110
|
+
};
|
|
1111
|
+
var time_picker_default = messages4;
|
|
1112
|
+
|
|
1113
|
+
// src/i18n/messages/en/file-upload.ts
|
|
1114
|
+
var messages5 = {
|
|
1115
|
+
deleteAll: "Remove all"
|
|
1116
|
+
};
|
|
1117
|
+
var file_upload_default = messages5;
|
|
1118
|
+
|
|
1290
1119
|
// src/i18n/messages/en/index.ts
|
|
1291
1120
|
var enMessages = {
|
|
1292
1121
|
pagination: pagination_default,
|
|
1293
1122
|
inputSelect: input_select_default,
|
|
1294
|
-
inputPhone: input_phone_default
|
|
1123
|
+
inputPhone: input_phone_default,
|
|
1124
|
+
timePicker: time_picker_default,
|
|
1125
|
+
fileUpload: file_upload_default
|
|
1295
1126
|
};
|
|
1296
1127
|
|
|
1297
1128
|
// src/i18n/messages/es/pagination.ts
|
|
1298
|
-
var
|
|
1129
|
+
var messages6 = {
|
|
1299
1130
|
totalResultsLabel(pagesSize, totalResults) {
|
|
1300
1131
|
if (totalResults < pagesSize) {
|
|
1301
1132
|
pagesSize = totalResults;
|
|
@@ -1306,16 +1137,16 @@ var messages4 = {
|
|
|
1306
1137
|
return `P\xE1gina ${currentPage} de ${totalPages}`;
|
|
1307
1138
|
}
|
|
1308
1139
|
};
|
|
1309
|
-
var pagination_default2 =
|
|
1140
|
+
var pagination_default2 = messages6;
|
|
1310
1141
|
|
|
1311
1142
|
// src/i18n/messages/es/input-select.ts
|
|
1312
|
-
var
|
|
1143
|
+
var messages7 = {
|
|
1313
1144
|
noOptions: "No hay opciones disponibles"
|
|
1314
1145
|
};
|
|
1315
|
-
var input_select_default2 =
|
|
1146
|
+
var input_select_default2 = messages7;
|
|
1316
1147
|
|
|
1317
1148
|
// src/i18n/messages/es/input-phone.ts
|
|
1318
|
-
var
|
|
1149
|
+
var messages8 = {
|
|
1319
1150
|
countries: {
|
|
1320
1151
|
empty: "Seleccionar",
|
|
1321
1152
|
AF: "Afganist\xE1n",
|
|
@@ -1565,17 +1396,31 @@ var messages6 = {
|
|
|
1565
1396
|
ZW: "Zimbabue"
|
|
1566
1397
|
}
|
|
1567
1398
|
};
|
|
1568
|
-
var input_phone_default2 =
|
|
1399
|
+
var input_phone_default2 = messages8;
|
|
1400
|
+
|
|
1401
|
+
// src/i18n/messages/es/time-picker.ts
|
|
1402
|
+
var messages9 = {
|
|
1403
|
+
label: "Tiempo"
|
|
1404
|
+
};
|
|
1405
|
+
var time_picker_default2 = messages9;
|
|
1406
|
+
|
|
1407
|
+
// src/i18n/messages/es/file-upload.ts
|
|
1408
|
+
var messages10 = {
|
|
1409
|
+
deleteAll: "Remover todos"
|
|
1410
|
+
};
|
|
1411
|
+
var file_upload_default2 = messages10;
|
|
1569
1412
|
|
|
1570
1413
|
// src/i18n/messages/es/index.ts
|
|
1571
1414
|
var esMessages = {
|
|
1572
1415
|
pagination: pagination_default2,
|
|
1573
1416
|
inputSelect: input_select_default2,
|
|
1574
|
-
inputPhone: input_phone_default2
|
|
1417
|
+
inputPhone: input_phone_default2,
|
|
1418
|
+
timePicker: time_picker_default2,
|
|
1419
|
+
fileUpload: file_upload_default2
|
|
1575
1420
|
};
|
|
1576
1421
|
|
|
1577
1422
|
// src/i18n/messages/pt-br/pagination.ts
|
|
1578
|
-
var
|
|
1423
|
+
var messages11 = {
|
|
1579
1424
|
totalResultsLabel(pagesSize, totalResults) {
|
|
1580
1425
|
if (totalResults < pagesSize) {
|
|
1581
1426
|
pagesSize = totalResults;
|
|
@@ -1586,16 +1431,16 @@ var messages7 = {
|
|
|
1586
1431
|
return `P\xE1gina ${currentPage} de ${totalPages}`;
|
|
1587
1432
|
}
|
|
1588
1433
|
};
|
|
1589
|
-
var pagination_default3 =
|
|
1434
|
+
var pagination_default3 = messages11;
|
|
1590
1435
|
|
|
1591
1436
|
// src/i18n/messages/pt-br/input-select.ts
|
|
1592
|
-
var
|
|
1437
|
+
var messages12 = {
|
|
1593
1438
|
noOptions: "Nenhuma op\xE7\xE3o dispon\xEDvel"
|
|
1594
1439
|
};
|
|
1595
|
-
var input_select_default3 =
|
|
1440
|
+
var input_select_default3 = messages12;
|
|
1596
1441
|
|
|
1597
1442
|
// src/i18n/messages/pt-br/input-phone.ts
|
|
1598
|
-
var
|
|
1443
|
+
var messages13 = {
|
|
1599
1444
|
countries: {
|
|
1600
1445
|
empty: "Selecione",
|
|
1601
1446
|
AF: "Afeganist\xE3o",
|
|
@@ -1845,13 +1690,27 @@ var messages9 = {
|
|
|
1845
1690
|
ZW: "Zimb\xE1bue"
|
|
1846
1691
|
}
|
|
1847
1692
|
};
|
|
1848
|
-
var input_phone_default3 =
|
|
1693
|
+
var input_phone_default3 = messages13;
|
|
1694
|
+
|
|
1695
|
+
// src/i18n/messages/pt-br/time-picker.ts
|
|
1696
|
+
var messages14 = {
|
|
1697
|
+
label: "Hor\xE1rio"
|
|
1698
|
+
};
|
|
1699
|
+
var time_picker_default3 = messages14;
|
|
1700
|
+
|
|
1701
|
+
// src/i18n/messages/pt-br/file-upload.ts
|
|
1702
|
+
var messages15 = {
|
|
1703
|
+
deleteAll: "Remover todos"
|
|
1704
|
+
};
|
|
1705
|
+
var file_upload_default3 = messages15;
|
|
1849
1706
|
|
|
1850
1707
|
// src/i18n/messages/pt-br/index.ts
|
|
1851
1708
|
var ptBrMessages = {
|
|
1852
1709
|
pagination: pagination_default3,
|
|
1853
1710
|
inputSelect: input_select_default3,
|
|
1854
|
-
inputPhone: input_phone_default3
|
|
1711
|
+
inputPhone: input_phone_default3,
|
|
1712
|
+
timePicker: time_picker_default3,
|
|
1713
|
+
fileUpload: file_upload_default3
|
|
1855
1714
|
};
|
|
1856
1715
|
|
|
1857
1716
|
// src/i18n/message-storage-handler.ts
|
|
@@ -1876,7 +1735,7 @@ var setNebulaLanguage = (language) => {
|
|
|
1876
1735
|
}
|
|
1877
1736
|
localStorage.setItem(getNebulaI18nStorageKey(), language);
|
|
1878
1737
|
};
|
|
1879
|
-
var
|
|
1738
|
+
var messages16 = /* @__PURE__ */ new Map([
|
|
1880
1739
|
[null, enMessages],
|
|
1881
1740
|
[void 0, enMessages],
|
|
1882
1741
|
["en-US", enMessages],
|
|
@@ -1894,14 +1753,14 @@ var NebulaI18nProvider = ({
|
|
|
1894
1753
|
() => customI18nStorageKey ?? localStorageKey,
|
|
1895
1754
|
[customI18nStorageKey]
|
|
1896
1755
|
);
|
|
1897
|
-
const [
|
|
1898
|
-
|
|
1756
|
+
const [messages17, setMessages] = useState(
|
|
1757
|
+
messages16.get(getNebulaLanguage()) ?? messages16.get("en-US")
|
|
1899
1758
|
);
|
|
1900
1759
|
const handleStorageChange = useCallback(
|
|
1901
1760
|
({ detail }) => {
|
|
1902
1761
|
if (detail.key === storageKey) {
|
|
1903
1762
|
setMessages(
|
|
1904
|
-
|
|
1763
|
+
messages16.get(detail.value) ?? messages16.get("en-US")
|
|
1905
1764
|
);
|
|
1906
1765
|
}
|
|
1907
1766
|
},
|
|
@@ -1941,7 +1800,16 @@ var NebulaI18nProvider = ({
|
|
|
1941
1800
|
localStorage.removeItem(localStorageKey);
|
|
1942
1801
|
localStorage.setItem(customNebulaI18nStorageKey, customI18nStorageKey);
|
|
1943
1802
|
}, [customI18nStorageKey]);
|
|
1944
|
-
return /* @__PURE__ */ jsx(
|
|
1803
|
+
return /* @__PURE__ */ jsx(
|
|
1804
|
+
NebulaI18nContext.Provider,
|
|
1805
|
+
{
|
|
1806
|
+
value: {
|
|
1807
|
+
messages: messages17,
|
|
1808
|
+
locale: getNebulaLanguage()
|
|
1809
|
+
},
|
|
1810
|
+
children
|
|
1811
|
+
}
|
|
1812
|
+
);
|
|
1945
1813
|
};
|
|
1946
1814
|
var useNebulaI18n = () => {
|
|
1947
1815
|
const context = useContext(NebulaI18nContext);
|
|
@@ -1958,7 +1826,7 @@ var Pagination = ({
|
|
|
1958
1826
|
onChangePage,
|
|
1959
1827
|
...props
|
|
1960
1828
|
}) => {
|
|
1961
|
-
const { messages:
|
|
1829
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
1962
1830
|
const totalPages = useMemo(() => {
|
|
1963
1831
|
return Math.ceil(total / (pageSize || 1));
|
|
1964
1832
|
}, [total, pageSize]);
|
|
@@ -1991,13 +1859,13 @@ var Pagination = ({
|
|
|
1991
1859
|
}, [totalPages, pageSize, total]);
|
|
1992
1860
|
const totalResultsLabel = useMemo(() => {
|
|
1993
1861
|
if (page === totalPages) {
|
|
1994
|
-
return
|
|
1862
|
+
return messages17.pagination.totalResultsLabel(lastPageSize, total);
|
|
1995
1863
|
}
|
|
1996
|
-
return
|
|
1997
|
-
}, [
|
|
1864
|
+
return messages17.pagination.totalResultsLabel(pageSize, total);
|
|
1865
|
+
}, [messages17.pagination, pageSize, total, page, totalPages, lastPageSize]);
|
|
1998
1866
|
const currentPageLabel = useMemo(
|
|
1999
|
-
() =>
|
|
2000
|
-
[
|
|
1867
|
+
() => messages17.pagination.currentPageLabel(normalizedPage, totalPages),
|
|
1868
|
+
[messages17.pagination, normalizedPage, totalPages]
|
|
2001
1869
|
);
|
|
2002
1870
|
return /* @__PURE__ */ jsxs(
|
|
2003
1871
|
"nav",
|
|
@@ -2270,7 +2138,7 @@ var createStyledSelect = (BaseSelect, displayName) => {
|
|
|
2270
2138
|
isError = false,
|
|
2271
2139
|
...props
|
|
2272
2140
|
}) => {
|
|
2273
|
-
const { messages:
|
|
2141
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
2274
2142
|
const customClassNames = useMemo(() => {
|
|
2275
2143
|
return {
|
|
2276
2144
|
control: (props2) => controlStyles(props2, isError),
|
|
@@ -2317,7 +2185,7 @@ var createStyledSelect = (BaseSelect, displayName) => {
|
|
|
2317
2185
|
isDisabled: disabled,
|
|
2318
2186
|
components: customComponents,
|
|
2319
2187
|
classNames: customClassNames,
|
|
2320
|
-
noOptionsMessage: () => /* @__PURE__ */ jsx("p", { children:
|
|
2188
|
+
noOptionsMessage: () => /* @__PURE__ */ jsx("p", { children: messages17.inputSelect.noOptions }),
|
|
2321
2189
|
...props
|
|
2322
2190
|
}
|
|
2323
2191
|
);
|
|
@@ -2333,7 +2201,15 @@ var StyledAsyncCreatable = createStyledSelect(
|
|
|
2333
2201
|
"AsyncCreatable"
|
|
2334
2202
|
);
|
|
2335
2203
|
var InputText = React8.forwardRef(
|
|
2336
|
-
({
|
|
2204
|
+
({
|
|
2205
|
+
className,
|
|
2206
|
+
icon,
|
|
2207
|
+
isError = false,
|
|
2208
|
+
onClean,
|
|
2209
|
+
iconPlacement = "start",
|
|
2210
|
+
disabled,
|
|
2211
|
+
...props
|
|
2212
|
+
}, ref) => {
|
|
2337
2213
|
const initialInputType = props.type || "text";
|
|
2338
2214
|
const [type, setType] = React8.useState(initialInputType);
|
|
2339
2215
|
const iconClass = {
|
|
@@ -2341,60 +2217,79 @@ var InputText = React8.forwardRef(
|
|
|
2341
2217
|
"text-inputText-icon-default focus:text-inputText-icon-focus": !isError && !props.value,
|
|
2342
2218
|
"text-inputText-icon-filled focus:text-inputText-icon-filled": !isError && !!props.value
|
|
2343
2219
|
};
|
|
2344
|
-
return /* @__PURE__ */ jsxs(
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
{
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2220
|
+
return /* @__PURE__ */ jsxs(
|
|
2221
|
+
"div",
|
|
2222
|
+
{
|
|
2223
|
+
className: cn("relative w-full", {
|
|
2224
|
+
"pointer-events-none": disabled
|
|
2225
|
+
}),
|
|
2226
|
+
children: [
|
|
2227
|
+
/* @__PURE__ */ jsx(
|
|
2228
|
+
"input",
|
|
2229
|
+
{
|
|
2230
|
+
ref,
|
|
2231
|
+
className: cn(
|
|
2232
|
+
"w-full h-10 outline-none rounded-input text-sm leading-none font-medium",
|
|
2233
|
+
"bg-inputText-background-default disabled:bg-inputText-background-disabled",
|
|
2234
|
+
"border border-inputText-border-default focus:ring-[3px] focus:ring-inputText-border-focus focus:border-inputText-border-focus",
|
|
2235
|
+
"text-inputText-text-filled focus:text-inputText-text-focus placeholder:text-inputText-text-default disabled:text-inputText-text-disabled",
|
|
2236
|
+
"disabled:cursor-not-allowed",
|
|
2237
|
+
{
|
|
2238
|
+
"pl-10 pr-4": !!icon && iconPlacement === "start",
|
|
2239
|
+
"pr-10 pl-4": !!icon && iconPlacement === "end" && initialInputType !== "password",
|
|
2240
|
+
"px-4": !icon,
|
|
2241
|
+
"border-inputText-border-danger focus:border-inputText-border-danger focus:ring-button-danger-border-focus": isError
|
|
2242
|
+
},
|
|
2243
|
+
className
|
|
2244
|
+
),
|
|
2245
|
+
...props,
|
|
2246
|
+
disabled,
|
|
2247
|
+
type
|
|
2248
|
+
}
|
|
2351
2249
|
),
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
) }),
|
|
2355
|
-
/* @__PURE__ */ jsx(
|
|
2356
|
-
"input",
|
|
2357
|
-
{
|
|
2358
|
-
ref,
|
|
2359
|
-
className: cn(
|
|
2360
|
-
"w-full h-10 outline-none rounded-input text-sm leading-none font-medium",
|
|
2361
|
-
"bg-inputText-background-default disabled:bg-inputText-background-disabled",
|
|
2362
|
-
"border border-inputText-border-default focus:ring-[3px] focus:ring-inputText-border-focus focus:border-inputText-border-focus",
|
|
2363
|
-
"text-inputText-text-filled focus:text-inputText-text-focus placeholder:text-inputText-text-default disabled:text-inputText-text-disabled",
|
|
2364
|
-
"disabled:cursor-not-allowed",
|
|
2250
|
+
onClean && props.value && /* @__PURE__ */ jsx(
|
|
2251
|
+
"button",
|
|
2365
2252
|
{
|
|
2366
|
-
|
|
2367
|
-
"
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2253
|
+
type: "button",
|
|
2254
|
+
className: cn("absolute top-1/2 transform -translate-y-1/2", {
|
|
2255
|
+
"right-10": initialInputType === "password" || iconPlacement === "end",
|
|
2256
|
+
"right-4": initialInputType === "text" && iconPlacement === "start"
|
|
2257
|
+
}),
|
|
2258
|
+
onClick: onClean,
|
|
2259
|
+
children: /* @__PURE__ */ jsx(CircleX, { className: cn("w-4 h-4", iconClass) })
|
|
2260
|
+
}
|
|
2371
2261
|
),
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
"
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2262
|
+
initialInputType === "password" && /* @__PURE__ */ jsx(
|
|
2263
|
+
"button",
|
|
2264
|
+
{
|
|
2265
|
+
type: "button",
|
|
2266
|
+
className: "nebula-ds absolute right-4 top-1/2 transform -translate-y-1/2",
|
|
2267
|
+
onClick: () => setType((prev) => prev === "text" ? "password" : "text"),
|
|
2268
|
+
children: type === "text" ? /* @__PURE__ */ jsx(Eye, { className: cn("w-4 h-4", iconClass) }) : /* @__PURE__ */ jsx(EyeOff, { className: cn("w-4 h-4", iconClass) })
|
|
2269
|
+
}
|
|
2270
|
+
),
|
|
2271
|
+
icon && /* @__PURE__ */ jsx(
|
|
2272
|
+
"span",
|
|
2273
|
+
{
|
|
2274
|
+
className: cn("absolute top-1/2 transform -translate-y-1/2", {
|
|
2275
|
+
"left-4": iconPlacement === "start",
|
|
2276
|
+
"right-4": iconPlacement === "end" && initialInputType !== "password"
|
|
2277
|
+
}),
|
|
2278
|
+
children: /* @__PURE__ */ jsx(
|
|
2279
|
+
"span",
|
|
2280
|
+
{
|
|
2281
|
+
className: cn(
|
|
2282
|
+
"w-4 h-4 flex items-center justify-center disabled:text-inputText-icon-disabled",
|
|
2283
|
+
iconClass
|
|
2284
|
+
),
|
|
2285
|
+
children: icon
|
|
2286
|
+
}
|
|
2287
|
+
)
|
|
2288
|
+
}
|
|
2289
|
+
)
|
|
2290
|
+
]
|
|
2291
|
+
}
|
|
2292
|
+
);
|
|
2398
2293
|
}
|
|
2399
2294
|
);
|
|
2400
2295
|
InputText.displayName = "InputText";
|
|
@@ -2867,7 +2762,7 @@ var BreadcrumbEllipsis = ({
|
|
|
2867
2762
|
),
|
|
2868
2763
|
...props,
|
|
2869
2764
|
children: [
|
|
2870
|
-
/* @__PURE__ */ jsx(
|
|
2765
|
+
/* @__PURE__ */ jsx(MoreHorizontal, { className: "nebula-ds h-3 w-3" }),
|
|
2871
2766
|
/* @__PURE__ */ jsx("span", { className: "nebula-ds sr-only", children: "More" })
|
|
2872
2767
|
]
|
|
2873
2768
|
}
|
|
@@ -3293,13 +3188,13 @@ function custom(message, options) {
|
|
|
3293
3188
|
}
|
|
3294
3189
|
);
|
|
3295
3190
|
}
|
|
3296
|
-
async function promise(promise2,
|
|
3191
|
+
async function promise(promise2, messages17, options) {
|
|
3297
3192
|
const loadingToast = toast$1.custom(
|
|
3298
3193
|
(t) => /* @__PURE__ */ jsx(
|
|
3299
3194
|
ToastComponent,
|
|
3300
3195
|
{
|
|
3301
3196
|
type: "info",
|
|
3302
|
-
message:
|
|
3197
|
+
message: messages17.loading,
|
|
3303
3198
|
options,
|
|
3304
3199
|
t
|
|
3305
3200
|
}
|
|
@@ -3313,7 +3208,7 @@ async function promise(promise2, messages11, options) {
|
|
|
3313
3208
|
ToastComponent,
|
|
3314
3209
|
{
|
|
3315
3210
|
type: "success",
|
|
3316
|
-
message:
|
|
3211
|
+
message: messages17.success,
|
|
3317
3212
|
options,
|
|
3318
3213
|
t
|
|
3319
3214
|
}
|
|
@@ -3328,7 +3223,7 @@ async function promise(promise2, messages11, options) {
|
|
|
3328
3223
|
ToastComponent,
|
|
3329
3224
|
{
|
|
3330
3225
|
type: "error",
|
|
3331
|
-
message:
|
|
3226
|
+
message: messages17.error,
|
|
3332
3227
|
options,
|
|
3333
3228
|
t
|
|
3334
3229
|
}
|
|
@@ -3498,12 +3393,12 @@ var CountrySelect = ({
|
|
|
3498
3393
|
const handleSelect = (event) => {
|
|
3499
3394
|
onChange(event.target.value);
|
|
3500
3395
|
};
|
|
3501
|
-
const { messages:
|
|
3502
|
-
const { countries } =
|
|
3396
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
3397
|
+
const { countries } = messages17.inputPhone;
|
|
3503
3398
|
return /* @__PURE__ */ jsxs("div", { className: "nebula-ds rounded-s-[20px] relative inline-flex items-center self-stretch py-2 ps-4 pe-2 transition-[color,box-shadow] outline-none has-disabled:pointer-events-none has-disabled:opacity-50", children: [
|
|
3504
3399
|
/* @__PURE__ */ jsxs("div", { className: "nebula-ds inline-flex items-center gap-1", "aria-hidden": "true", children: [
|
|
3505
3400
|
/* @__PURE__ */ jsx(FlagComponent, { country: value, countryName: value, "aria-hidden": "true" }),
|
|
3506
|
-
/* @__PURE__ */ jsx("span", { className: "nebula-ds text-inputText-text-filled focus:text-inputText-text-focus", children: /* @__PURE__ */ jsx(
|
|
3401
|
+
/* @__PURE__ */ jsx("span", { className: "nebula-ds text-inputText-text-filled focus:text-inputText-text-focus", children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16, "aria-hidden": "true" }) })
|
|
3507
3402
|
] }),
|
|
3508
3403
|
/* @__PURE__ */ jsxs(
|
|
3509
3404
|
"select",
|
|
@@ -3527,7 +3422,7 @@ var CountrySelect = ({
|
|
|
3527
3422
|
};
|
|
3528
3423
|
var FlagComponent = ({ country, countryName }) => {
|
|
3529
3424
|
const Flag = flags[country];
|
|
3530
|
-
return /* @__PURE__ */ jsx("span", { className: "nebula-ds w-5 overflow-hidden rounded-sm", children: Flag ? /* @__PURE__ */ jsx(Flag, { title: countryName }) : /* @__PURE__ */ jsx(
|
|
3425
|
+
return /* @__PURE__ */ jsx("span", { className: "nebula-ds w-5 overflow-hidden rounded-sm", children: Flag ? /* @__PURE__ */ jsx(Flag, { title: countryName }) : /* @__PURE__ */ jsx(PhoneIcon, { size: 16, "aria-hidden": "true" }) });
|
|
3531
3426
|
};
|
|
3532
3427
|
var PhoneInput = React8__default.forwardRef(({ className, ...props }, ref) => {
|
|
3533
3428
|
return /* @__PURE__ */ jsxs("div", { className: "nebula-ds flex items-center justify-center rounded-e-[20px] w-full", children: [
|
|
@@ -3635,6 +3530,1315 @@ var Skeleton = React8__default.forwardRef(
|
|
|
3635
3530
|
}
|
|
3636
3531
|
);
|
|
3637
3532
|
Skeleton.displayName = "Skeleton";
|
|
3533
|
+
var MONTHS = [
|
|
3534
|
+
"01/01",
|
|
3535
|
+
"02/01",
|
|
3536
|
+
"03/01",
|
|
3537
|
+
"04/01",
|
|
3538
|
+
"05/01",
|
|
3539
|
+
"06/01",
|
|
3540
|
+
"07/01",
|
|
3541
|
+
"08/01",
|
|
3542
|
+
"09/01",
|
|
3543
|
+
"10/01",
|
|
3544
|
+
"11/01",
|
|
3545
|
+
"12/01"
|
|
3546
|
+
];
|
|
3547
|
+
var localeByi18nKey = {
|
|
3548
|
+
es,
|
|
3549
|
+
"en-US": enUS,
|
|
3550
|
+
"pt-BR": ptBR
|
|
3551
|
+
};
|
|
3552
|
+
var Calendar = ({
|
|
3553
|
+
numberOfMonths = 1,
|
|
3554
|
+
hideNavigation = false,
|
|
3555
|
+
month,
|
|
3556
|
+
onNextClick,
|
|
3557
|
+
onPrevClick,
|
|
3558
|
+
components: calendarComponents,
|
|
3559
|
+
...props
|
|
3560
|
+
}) => {
|
|
3561
|
+
const { locale } = useNebulaI18n();
|
|
3562
|
+
const [selectedMonth, setSelectedMonth] = useState(/* @__PURE__ */ new Date());
|
|
3563
|
+
const [showMonthGridSelection, setShowMonthGridSelection] = useState(false);
|
|
3564
|
+
const isRange = props.mode === "range";
|
|
3565
|
+
const currentMonth = useMemo(
|
|
3566
|
+
() => month ?? selectedMonth,
|
|
3567
|
+
[month, selectedMonth]
|
|
3568
|
+
);
|
|
3569
|
+
const handleSelectMonthByOption = useCallback(
|
|
3570
|
+
(monthOption) => {
|
|
3571
|
+
setShowMonthGridSelection(false);
|
|
3572
|
+
const calendarDate = currentMonth;
|
|
3573
|
+
currentMonth.setMonth(monthOption.getMonth());
|
|
3574
|
+
if (typeof month !== "undefined") {
|
|
3575
|
+
onNextClick?.(calendarDate);
|
|
3576
|
+
} else {
|
|
3577
|
+
setSelectedMonth(calendarDate);
|
|
3578
|
+
}
|
|
3579
|
+
},
|
|
3580
|
+
[currentMonth, month, onNextClick]
|
|
3581
|
+
);
|
|
3582
|
+
const components2 = useMemo(() => {
|
|
3583
|
+
return {
|
|
3584
|
+
Day(props2) {
|
|
3585
|
+
const {
|
|
3586
|
+
selected,
|
|
3587
|
+
range_end: rangeEnd,
|
|
3588
|
+
range_start: rangeStart
|
|
3589
|
+
} = props2.modifiers;
|
|
3590
|
+
const isSaturday = props2.day.date.getDay() === 0;
|
|
3591
|
+
const isSunday = props2.day.date.getDay() === 6;
|
|
3592
|
+
return /* @__PURE__ */ jsx(
|
|
3593
|
+
"td",
|
|
3594
|
+
{
|
|
3595
|
+
...props2,
|
|
3596
|
+
className: cn(props2.className, "!w-9 !h-9 !p-0", {
|
|
3597
|
+
"rounded-r-full": isSunday && selected || rangeEnd,
|
|
3598
|
+
"rounded-l-full": isSaturday && selected || rangeStart,
|
|
3599
|
+
"!bg-calendar-rowSelected-background [&>button]:!border-none": selected && isRange
|
|
3600
|
+
})
|
|
3601
|
+
}
|
|
3602
|
+
);
|
|
3603
|
+
},
|
|
3604
|
+
DayButton(props2) {
|
|
3605
|
+
const {
|
|
3606
|
+
outside,
|
|
3607
|
+
today,
|
|
3608
|
+
selected,
|
|
3609
|
+
disabled,
|
|
3610
|
+
range_middle: rangeMiddle,
|
|
3611
|
+
range_end: rangeEnd,
|
|
3612
|
+
range_start: rangeStart
|
|
3613
|
+
} = props2.modifiers;
|
|
3614
|
+
return /* @__PURE__ */ jsx(
|
|
3615
|
+
"button",
|
|
3616
|
+
{
|
|
3617
|
+
...props2,
|
|
3618
|
+
tabIndex: 0,
|
|
3619
|
+
className: cn(
|
|
3620
|
+
props2.className,
|
|
3621
|
+
"!w-9 !h-9 hover:bg-button-ghost-background-hover hover:rounded-full",
|
|
3622
|
+
{
|
|
3623
|
+
"!text-calendar-day-color": !outside,
|
|
3624
|
+
"!text-calendar-outsideDay-color !opacity-1": outside,
|
|
3625
|
+
"!bg-calendar-daySelected-background !border-calendar-daySelected-background !text-calendar-daySelected-color rounded-full": (selected || rangeEnd || rangeStart) && !rangeMiddle,
|
|
3626
|
+
"!text-neutral-200 dark:!text-neutral-900 pointer-events-none cursor-not-allowed": disabled
|
|
3627
|
+
}
|
|
3628
|
+
),
|
|
3629
|
+
children: /* @__PURE__ */ jsxs(
|
|
3630
|
+
"div",
|
|
3631
|
+
{
|
|
3632
|
+
className: cn({
|
|
3633
|
+
"flex flex-col relative items-center text-inherit": today
|
|
3634
|
+
}),
|
|
3635
|
+
children: [
|
|
3636
|
+
/* @__PURE__ */ jsx(
|
|
3637
|
+
Paragraph,
|
|
3638
|
+
{
|
|
3639
|
+
size: "md",
|
|
3640
|
+
className: "!font-medium !text-inherit text-center",
|
|
3641
|
+
children: props2.children
|
|
3642
|
+
}
|
|
3643
|
+
),
|
|
3644
|
+
today && /* @__PURE__ */ jsx("div", { className: "nebula-ds !bg-calendar-today-dotColor w-1 h-1 rounded-full absolute -bottom-[2px]" })
|
|
3645
|
+
]
|
|
3646
|
+
}
|
|
3647
|
+
)
|
|
3648
|
+
}
|
|
3649
|
+
);
|
|
3650
|
+
},
|
|
3651
|
+
MonthCaption({ calendarMonth, displayIndex, ...rest }) {
|
|
3652
|
+
const handleNextMonth = () => {
|
|
3653
|
+
const newMonth = addMonths(
|
|
3654
|
+
currentMonth,
|
|
3655
|
+
props.pagedNavigation || numberOfMonths === 1 ? 1 : 0
|
|
3656
|
+
);
|
|
3657
|
+
if (typeof month !== "undefined") {
|
|
3658
|
+
onNextClick?.(newMonth);
|
|
3659
|
+
return;
|
|
3660
|
+
}
|
|
3661
|
+
setSelectedMonth(newMonth);
|
|
3662
|
+
};
|
|
3663
|
+
const handlePreviousMonth = () => {
|
|
3664
|
+
const newMonth = addMonths(
|
|
3665
|
+
currentMonth,
|
|
3666
|
+
props.pagedNavigation ? -2 : -1
|
|
3667
|
+
);
|
|
3668
|
+
if (typeof month !== "undefined") {
|
|
3669
|
+
onPrevClick?.(newMonth);
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
setSelectedMonth(newMonth);
|
|
3673
|
+
};
|
|
3674
|
+
const handleToggleShowMonthGridSelection = () => {
|
|
3675
|
+
setShowMonthGridSelection((s) => !s);
|
|
3676
|
+
};
|
|
3677
|
+
return /* @__PURE__ */ jsxs(
|
|
3678
|
+
"div",
|
|
3679
|
+
{
|
|
3680
|
+
className: cn("flex justify-between items-center !h-9 mb-3", {
|
|
3681
|
+
"ps-3": numberOfMonths === 1,
|
|
3682
|
+
"mb-0": showMonthGridSelection
|
|
3683
|
+
}),
|
|
3684
|
+
children: [
|
|
3685
|
+
!hideNavigation && numberOfMonths > 1 && /* @__PURE__ */ jsx(
|
|
3686
|
+
Button,
|
|
3687
|
+
{
|
|
3688
|
+
icon: true,
|
|
3689
|
+
size: "sm",
|
|
3690
|
+
variant: "ghost",
|
|
3691
|
+
onClick: handlePreviousMonth,
|
|
3692
|
+
className: cn({
|
|
3693
|
+
"pointer-events-none invisible": displayIndex === 1
|
|
3694
|
+
}),
|
|
3695
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "nebula-ds !w-[unset] !h-[unset]" })
|
|
3696
|
+
}
|
|
3697
|
+
),
|
|
3698
|
+
/* @__PURE__ */ jsx(
|
|
3699
|
+
"div",
|
|
3700
|
+
{
|
|
3701
|
+
...rest,
|
|
3702
|
+
className: cn(
|
|
3703
|
+
rest.className,
|
|
3704
|
+
"!h-auto select-none ",
|
|
3705
|
+
numberOfMonths > 1 && "pointer-events-none"
|
|
3706
|
+
),
|
|
3707
|
+
role: "button",
|
|
3708
|
+
onClick: handleToggleShowMonthGridSelection,
|
|
3709
|
+
children: /* @__PURE__ */ jsxs(Space, { size: "xs", className: "nebula-ds items-center", children: [
|
|
3710
|
+
/* @__PURE__ */ jsx("span", { className: "nebula-ds !text-calendar-month-label !text-sm !font-semibold", children: formatDate(calendarMonth.date, "LLL yyyy", {
|
|
3711
|
+
locale: localeByi18nKey[locale ?? "en-US"]
|
|
3712
|
+
}).replace(/^./, (char) => char.toUpperCase()) }),
|
|
3713
|
+
numberOfMonths === 1 && /* @__PURE__ */ jsx(ChevronDownIcon, { className: "nebula-ds !text-calendar-month-selectionChevron" })
|
|
3714
|
+
] })
|
|
3715
|
+
}
|
|
3716
|
+
),
|
|
3717
|
+
!hideNavigation && numberOfMonths === 1 && !showMonthGridSelection && /* @__PURE__ */ jsxs("div", { className: "nebula-ds flex gap-x-1", children: [
|
|
3718
|
+
/* @__PURE__ */ jsx(
|
|
3719
|
+
Button,
|
|
3720
|
+
{
|
|
3721
|
+
icon: true,
|
|
3722
|
+
size: "sm",
|
|
3723
|
+
variant: "ghost",
|
|
3724
|
+
onClick: handlePreviousMonth,
|
|
3725
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "nebula-ds !w-[unset] !h-[unset] !text-calendar-month-navigator" })
|
|
3726
|
+
}
|
|
3727
|
+
),
|
|
3728
|
+
/* @__PURE__ */ jsx(
|
|
3729
|
+
Button,
|
|
3730
|
+
{
|
|
3731
|
+
icon: true,
|
|
3732
|
+
size: "sm",
|
|
3733
|
+
variant: "ghost",
|
|
3734
|
+
onClick: handleNextMonth,
|
|
3735
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "nebula-ds !w-[unset] !h-[unset] !text-calendar-month-navigator" })
|
|
3736
|
+
}
|
|
3737
|
+
)
|
|
3738
|
+
] }),
|
|
3739
|
+
!hideNavigation && numberOfMonths > 1 && /* @__PURE__ */ jsx(
|
|
3740
|
+
Button,
|
|
3741
|
+
{
|
|
3742
|
+
icon: true,
|
|
3743
|
+
size: "sm",
|
|
3744
|
+
variant: "ghost",
|
|
3745
|
+
onClick: handleNextMonth,
|
|
3746
|
+
className: cn({
|
|
3747
|
+
"pointer-events-none invisible": displayIndex !== numberOfMonths - 1
|
|
3748
|
+
}),
|
|
3749
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "nebula-ds !w-[unset] !h-[unset]" })
|
|
3750
|
+
}
|
|
3751
|
+
)
|
|
3752
|
+
]
|
|
3753
|
+
}
|
|
3754
|
+
);
|
|
3755
|
+
},
|
|
3756
|
+
MonthGrid(props2) {
|
|
3757
|
+
if (!showMonthGridSelection) {
|
|
3758
|
+
return /* @__PURE__ */ jsx("table", { ...props2 });
|
|
3759
|
+
}
|
|
3760
|
+
return /* @__PURE__ */ jsx(
|
|
3761
|
+
Box,
|
|
3762
|
+
{
|
|
3763
|
+
className: "nebula-ds z-40 !p-0 flex gap-2 flex-col justify-between w-full",
|
|
3764
|
+
border: false,
|
|
3765
|
+
children: /* @__PURE__ */ jsx("div", { className: "nebula-ds z-40 grid grid-cols-2 gap-1 bg-inherit pt-2", children: MONTHS.map((monthOption) => {
|
|
3766
|
+
const monthOptionAsDate = new Date(monthOption);
|
|
3767
|
+
const isSelectedMonth = month ? month.getMonth() === monthOptionAsDate.getMonth() : monthOptionAsDate.getMonth() === currentMonth.getMonth();
|
|
3768
|
+
const monthLabel = formatDate(monthOptionAsDate, "LLLL", {
|
|
3769
|
+
locale: localeByi18nKey[locale ?? "en-US"]
|
|
3770
|
+
});
|
|
3771
|
+
return /* @__PURE__ */ jsx(
|
|
3772
|
+
Button,
|
|
3773
|
+
{
|
|
3774
|
+
variant: isSelectedMonth ? "primary" : "secondary",
|
|
3775
|
+
type: "button",
|
|
3776
|
+
className: cn("rounded-lg", {
|
|
3777
|
+
"border-neutral-200 dark:border-neutral-800": !isSelectedMonth
|
|
3778
|
+
}),
|
|
3779
|
+
size: "md",
|
|
3780
|
+
onClick: () => handleSelectMonthByOption(monthOptionAsDate),
|
|
3781
|
+
children: monthLabel
|
|
3782
|
+
},
|
|
3783
|
+
monthLabel
|
|
3784
|
+
);
|
|
3785
|
+
}) })
|
|
3786
|
+
}
|
|
3787
|
+
);
|
|
3788
|
+
},
|
|
3789
|
+
Months(props2) {
|
|
3790
|
+
return /* @__PURE__ */ jsx("div", { ...props2, className: cn(props2.className, "gap-2 flex p-2") });
|
|
3791
|
+
},
|
|
3792
|
+
Month(props2) {
|
|
3793
|
+
return /* @__PURE__ */ jsx(
|
|
3794
|
+
"div",
|
|
3795
|
+
{
|
|
3796
|
+
...props2,
|
|
3797
|
+
className: cn(
|
|
3798
|
+
props2.className,
|
|
3799
|
+
"[&:not(:last-child)]:pr-2 [&:not(:last-child)]:border-neutral-200 [&:not(:last-child)]:border-r dark:[&:not(:last-child)]:border-neutral-800"
|
|
3800
|
+
)
|
|
3801
|
+
}
|
|
3802
|
+
);
|
|
3803
|
+
},
|
|
3804
|
+
Week(props2) {
|
|
3805
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3806
|
+
/* @__PURE__ */ jsx("tr", { ...props2, className: cn(props2.className) }),
|
|
3807
|
+
/* @__PURE__ */ jsx("tr", { className: "nebula-ds h-1 last:h-0" })
|
|
3808
|
+
] });
|
|
3809
|
+
},
|
|
3810
|
+
Weekdays(props2) {
|
|
3811
|
+
return /* @__PURE__ */ jsx("tr", { ...props2 });
|
|
3812
|
+
},
|
|
3813
|
+
Weekday(props2) {
|
|
3814
|
+
return /* @__PURE__ */ jsx(
|
|
3815
|
+
"th",
|
|
3816
|
+
{
|
|
3817
|
+
...props2,
|
|
3818
|
+
className: cn(
|
|
3819
|
+
props2.className,
|
|
3820
|
+
"font-medium text-xs !text-calendar-weekDay-color"
|
|
3821
|
+
),
|
|
3822
|
+
children: String(props2.children)?.toUpperCase()?.[0]
|
|
3823
|
+
}
|
|
3824
|
+
);
|
|
3825
|
+
},
|
|
3826
|
+
Footer(props2) {
|
|
3827
|
+
if (showMonthGridSelection) return void 0;
|
|
3828
|
+
return /* @__PURE__ */ jsx(
|
|
3829
|
+
"div",
|
|
3830
|
+
{
|
|
3831
|
+
...props2,
|
|
3832
|
+
className: cn(props2.className, "p-3 border-t border-t-box-border")
|
|
3833
|
+
}
|
|
3834
|
+
);
|
|
3835
|
+
},
|
|
3836
|
+
...calendarComponents
|
|
3837
|
+
};
|
|
3838
|
+
}, [
|
|
3839
|
+
calendarComponents,
|
|
3840
|
+
isRange,
|
|
3841
|
+
currentMonth,
|
|
3842
|
+
handleSelectMonthByOption,
|
|
3843
|
+
hideNavigation,
|
|
3844
|
+
locale,
|
|
3845
|
+
month,
|
|
3846
|
+
numberOfMonths,
|
|
3847
|
+
onNextClick,
|
|
3848
|
+
onPrevClick,
|
|
3849
|
+
props.pagedNavigation,
|
|
3850
|
+
showMonthGridSelection
|
|
3851
|
+
]);
|
|
3852
|
+
return /* @__PURE__ */ jsx(
|
|
3853
|
+
Box,
|
|
3854
|
+
{
|
|
3855
|
+
border: true,
|
|
3856
|
+
className: cn("p-0 w-fit", numberOfMonths === 1 && "w-[270px]"),
|
|
3857
|
+
shadow: "md",
|
|
3858
|
+
children: /* @__PURE__ */ jsx(
|
|
3859
|
+
DayPicker,
|
|
3860
|
+
{
|
|
3861
|
+
showOutsideDays: true,
|
|
3862
|
+
mode: "single",
|
|
3863
|
+
animate: false,
|
|
3864
|
+
...props,
|
|
3865
|
+
month: currentMonth,
|
|
3866
|
+
hideNavigation: true,
|
|
3867
|
+
numberOfMonths: Math.min(Math.max(numberOfMonths, 1), 2),
|
|
3868
|
+
components: components2,
|
|
3869
|
+
locale: localeByi18nKey[locale ?? "en-US"],
|
|
3870
|
+
footer: showMonthGridSelection ? void 0 : props.footer
|
|
3871
|
+
}
|
|
3872
|
+
)
|
|
3873
|
+
}
|
|
3874
|
+
);
|
|
3875
|
+
};
|
|
3876
|
+
|
|
3877
|
+
// src/utils/valid-date-format.ts
|
|
3878
|
+
function dateFormatIsValid(dateStr, locale) {
|
|
3879
|
+
const regexBR = /^(?:(?:31\/(0[13578]|1[02]))\/(?:\d{4})|(?:29|30)\/(0[13-9]|1[0-2])\/(?:\d{4})|29\/02\/(?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)|(?:0[1-9]|1\d|2[0-8])\/(0[1-9]|1[0-2])\/(?:\d{4}))$/;
|
|
3880
|
+
const regexUS = /^(?:(?:(0[13578]|1[02])\/31)\/(?:\d{4})|(?:(0[13-9]|1[0-2])\/(29|30))\/(?:\d{4})|(?:02\/29)\/(?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)|(?:(0[1-9]|1[0-2])\/(0[1-9]|1\d|2[0-8]))\/(?:\d{4}))$/;
|
|
3881
|
+
const regex = locale === "en-US" ? regexUS : regexBR;
|
|
3882
|
+
return regex.test(dateStr);
|
|
3883
|
+
}
|
|
3884
|
+
function timeFormatIsValid(timeStr) {
|
|
3885
|
+
const regex = /^(?:[01]\d|2[0-3]):[0-5]\d$/;
|
|
3886
|
+
return regex.test(timeStr);
|
|
3887
|
+
}
|
|
3888
|
+
var dateIsAvailable = (inputDate, disabledDates) => {
|
|
3889
|
+
if (!disabledDates || !inputDate) return true;
|
|
3890
|
+
const dateIsDisabled = (d, matcher) => {
|
|
3891
|
+
if (Array.isArray(matcher)) {
|
|
3892
|
+
return matcher.some((date) => isSameDay(date, d));
|
|
3893
|
+
}
|
|
3894
|
+
if (typeof matcher === "boolean") return matcher;
|
|
3895
|
+
if (typeof matcher === "function") {
|
|
3896
|
+
return matcher(d);
|
|
3897
|
+
}
|
|
3898
|
+
if ("from" in matcher) {
|
|
3899
|
+
const { from, to } = matcher;
|
|
3900
|
+
if (!from) return false;
|
|
3901
|
+
if (from && to) {
|
|
3902
|
+
return isBefore(d, to) && isAfter(d, from) || isSameDay(d, from) || isSameDay(d, to);
|
|
3903
|
+
}
|
|
3904
|
+
return isSameDay(d, from);
|
|
3905
|
+
}
|
|
3906
|
+
if ("before" in matcher && !("after" in matcher)) {
|
|
3907
|
+
const { before } = matcher;
|
|
3908
|
+
return isBefore(d, before) && !isSameDay(d, before);
|
|
3909
|
+
}
|
|
3910
|
+
if ("after" in matcher && !("before" in matcher)) {
|
|
3911
|
+
const { after } = matcher;
|
|
3912
|
+
return isAfter(d, after) && !isSameDay(d, after);
|
|
3913
|
+
}
|
|
3914
|
+
if ("after" in matcher && "before" in matcher) {
|
|
3915
|
+
const { after, before } = matcher;
|
|
3916
|
+
return isAfter(d, after) && !isSameDay(d, after) || isBefore(d, before) && !isSameDay(d, before);
|
|
3917
|
+
}
|
|
3918
|
+
if ("dayOfWeek" in matcher) {
|
|
3919
|
+
const { dayOfWeek } = matcher;
|
|
3920
|
+
if (Array.isArray(dayOfWeek)) {
|
|
3921
|
+
return dayOfWeek.includes(d.getDay());
|
|
3922
|
+
}
|
|
3923
|
+
return dayOfWeek === d.getDay();
|
|
3924
|
+
}
|
|
3925
|
+
return isSameDay(d, matcher);
|
|
3926
|
+
};
|
|
3927
|
+
if (Array.isArray(disabledDates)) {
|
|
3928
|
+
return disabledDates.every((matcher) => {
|
|
3929
|
+
return dateIsDisabled(inputDate, matcher) === false;
|
|
3930
|
+
});
|
|
3931
|
+
}
|
|
3932
|
+
return !dateIsDisabled(inputDate, disabledDates);
|
|
3933
|
+
};
|
|
3934
|
+
var InputDatePickerSingle = ({
|
|
3935
|
+
portal,
|
|
3936
|
+
placeholder,
|
|
3937
|
+
className,
|
|
3938
|
+
value,
|
|
3939
|
+
onChange,
|
|
3940
|
+
numberOfMonths = 1,
|
|
3941
|
+
onClean,
|
|
3942
|
+
disabledDates,
|
|
3943
|
+
...rest
|
|
3944
|
+
}) => {
|
|
3945
|
+
const [popoverIsOpen, setPopoverIsOpen] = useState(false);
|
|
3946
|
+
const [innerDate, setInnerDate] = useState(
|
|
3947
|
+
value ? new Date(value) : void 0
|
|
3948
|
+
);
|
|
3949
|
+
const { locale } = useNebulaI18n();
|
|
3950
|
+
const [month, setMonth] = useState(/* @__PURE__ */ new Date());
|
|
3951
|
+
const handleClearValue = () => {
|
|
3952
|
+
setInnerDate(void 0);
|
|
3953
|
+
setMonth(/* @__PURE__ */ new Date());
|
|
3954
|
+
};
|
|
3955
|
+
const handleInnerInputChange = (text) => {
|
|
3956
|
+
const dateSlice = text.substring(0, 10).trim();
|
|
3957
|
+
if (!text) {
|
|
3958
|
+
onChange?.(text);
|
|
3959
|
+
handleClearValue();
|
|
3960
|
+
return;
|
|
3961
|
+
}
|
|
3962
|
+
const [day, month2, year] = [
|
|
3963
|
+
locale !== "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
3964
|
+
locale === "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
3965
|
+
dateSlice.substring(6)
|
|
3966
|
+
];
|
|
3967
|
+
const date = new Date(Number(year), Number(month2) - 1, Number(day));
|
|
3968
|
+
if ([day, month2, year].some((value2) => !value2) || !dateFormatIsValid(dateSlice, locale) || !isValid(new Date(date)) || !dateIsAvailable(date, disabledDates)) {
|
|
3969
|
+
onChange?.(text);
|
|
3970
|
+
handleClearValue();
|
|
3971
|
+
return;
|
|
3972
|
+
}
|
|
3973
|
+
onChange?.(text, date);
|
|
3974
|
+
setInnerDate(date);
|
|
3975
|
+
};
|
|
3976
|
+
const handleKeyDown = (e) => {
|
|
3977
|
+
if ((e.altKey || e.ctrlKey || e.metaKey) && e.key !== "z") return;
|
|
3978
|
+
const allowedKeys = [
|
|
3979
|
+
"Backspace",
|
|
3980
|
+
"Delete",
|
|
3981
|
+
"Tab",
|
|
3982
|
+
"ArrowLeft",
|
|
3983
|
+
"ArrowRight",
|
|
3984
|
+
"Home",
|
|
3985
|
+
"End",
|
|
3986
|
+
"/"
|
|
3987
|
+
];
|
|
3988
|
+
if (!allowedKeys.includes(e.key) && !/^[0-9]$/.test(e.key)) {
|
|
3989
|
+
e.preventDefault();
|
|
3990
|
+
}
|
|
3991
|
+
};
|
|
3992
|
+
const handleCalendarSelect = (date) => {
|
|
3993
|
+
const dateToStr = Intl.DateTimeFormat(locale ?? "en-US", {
|
|
3994
|
+
month: "2-digit",
|
|
3995
|
+
year: "numeric",
|
|
3996
|
+
day: "2-digit"
|
|
3997
|
+
}).format(date);
|
|
3998
|
+
setInnerDate(date);
|
|
3999
|
+
onChange?.(dateToStr, date);
|
|
4000
|
+
};
|
|
4001
|
+
const normalizedCalendarDate = useMemo(() => {
|
|
4002
|
+
return isValid(innerDate) ? innerDate : void 0;
|
|
4003
|
+
}, [innerDate]);
|
|
4004
|
+
useEffect(() => {
|
|
4005
|
+
if (innerDate) setMonth(innerDate);
|
|
4006
|
+
}, [innerDate]);
|
|
4007
|
+
return /* @__PURE__ */ jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
|
|
4008
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsx(
|
|
4009
|
+
"div",
|
|
4010
|
+
{
|
|
4011
|
+
onClick: (e) => e.preventDefault(),
|
|
4012
|
+
onFocus: (e) => e.preventDefault(),
|
|
4013
|
+
children: /* @__PURE__ */ jsx(
|
|
4014
|
+
InputText,
|
|
4015
|
+
{
|
|
4016
|
+
placeholder,
|
|
4017
|
+
value,
|
|
4018
|
+
className,
|
|
4019
|
+
onChange: (e) => handleInnerInputChange(e.target.value),
|
|
4020
|
+
onKeyDown: handleKeyDown,
|
|
4021
|
+
icon: /* @__PURE__ */ jsx(
|
|
4022
|
+
CalendarIcon,
|
|
4023
|
+
{
|
|
4024
|
+
tabIndex: 0,
|
|
4025
|
+
role: "button",
|
|
4026
|
+
onClick: () => setPopoverIsOpen((s) => !s),
|
|
4027
|
+
onKeyUp: (e) => {
|
|
4028
|
+
if (e.key === "Enter") {
|
|
4029
|
+
setPopoverIsOpen((s) => !s);
|
|
4030
|
+
}
|
|
4031
|
+
},
|
|
4032
|
+
className: "nebula-ds cursor-pointer"
|
|
4033
|
+
}
|
|
4034
|
+
),
|
|
4035
|
+
iconPlacement: "end",
|
|
4036
|
+
onKeyUp: (e) => {
|
|
4037
|
+
if (e.key === "ArrowDown") {
|
|
4038
|
+
setPopoverIsOpen(true);
|
|
4039
|
+
}
|
|
4040
|
+
},
|
|
4041
|
+
maxLength: 10,
|
|
4042
|
+
onClean: onClean ? () => {
|
|
4043
|
+
onClean();
|
|
4044
|
+
handleClearValue();
|
|
4045
|
+
} : void 0,
|
|
4046
|
+
...rest
|
|
4047
|
+
}
|
|
4048
|
+
)
|
|
4049
|
+
}
|
|
4050
|
+
) }),
|
|
4051
|
+
/* @__PURE__ */ jsx(
|
|
4052
|
+
PopoverContent,
|
|
4053
|
+
{
|
|
4054
|
+
portal,
|
|
4055
|
+
side: "bottom",
|
|
4056
|
+
className: "nebula-ds p-0 border-none bg-transparent shadow-none",
|
|
4057
|
+
align: "start",
|
|
4058
|
+
children: /* @__PURE__ */ jsx(
|
|
4059
|
+
Calendar,
|
|
4060
|
+
{
|
|
4061
|
+
required: false,
|
|
4062
|
+
mode: "single",
|
|
4063
|
+
numberOfMonths,
|
|
4064
|
+
selected: normalizedCalendarDate,
|
|
4065
|
+
onSelect: handleCalendarSelect,
|
|
4066
|
+
month,
|
|
4067
|
+
onPrevClick: setMonth,
|
|
4068
|
+
onNextClick: setMonth,
|
|
4069
|
+
disabled: disabledDates
|
|
4070
|
+
}
|
|
4071
|
+
)
|
|
4072
|
+
}
|
|
4073
|
+
)
|
|
4074
|
+
] });
|
|
4075
|
+
};
|
|
4076
|
+
var InputTime = forwardRef(
|
|
4077
|
+
({ value = "", onChange, placeholder = "--:--", ...rest }, ref) => {
|
|
4078
|
+
const [displayValue, setDisplayValue] = useState(value);
|
|
4079
|
+
const handleKeyDown = (e) => {
|
|
4080
|
+
const currentValue = e.currentTarget.value;
|
|
4081
|
+
if ((e.altKey || e.ctrlKey || e.metaKey) && e.key !== "z") return;
|
|
4082
|
+
const allowedKeys = [
|
|
4083
|
+
"Backspace",
|
|
4084
|
+
"Delete",
|
|
4085
|
+
"Tab",
|
|
4086
|
+
"ArrowLeft",
|
|
4087
|
+
"ArrowRight",
|
|
4088
|
+
"Home",
|
|
4089
|
+
"End",
|
|
4090
|
+
":"
|
|
4091
|
+
];
|
|
4092
|
+
if (!allowedKeys.includes(e.key) && !/^[0-9]$/.test(e.key)) {
|
|
4093
|
+
e.preventDefault();
|
|
4094
|
+
}
|
|
4095
|
+
if (currentValue.indexOf(":") > -1 && e.key === ":" || e.key === ":" && currentValue.length < 2) {
|
|
4096
|
+
e.preventDefault();
|
|
4097
|
+
}
|
|
4098
|
+
};
|
|
4099
|
+
const handleInput = (value2) => {
|
|
4100
|
+
if (value2.startsWith(":")) return;
|
|
4101
|
+
let clean = value2.replace(/\D/g, "");
|
|
4102
|
+
if (clean.length === 2) {
|
|
4103
|
+
clean = String(
|
|
4104
|
+
Math.min(Math.max(parseInt(clean || "0", 10), 0), 23)
|
|
4105
|
+
).padStart(2, "0");
|
|
4106
|
+
}
|
|
4107
|
+
if (clean.length === 4) {
|
|
4108
|
+
let h = parseInt(clean.slice(0, 2) || "0", 10);
|
|
4109
|
+
let m = parseInt(clean.slice(2, 4) || "0", 10);
|
|
4110
|
+
h = Math.min(Math.max(h, 0), 23);
|
|
4111
|
+
m = Math.min(Math.max(m, 0), 59);
|
|
4112
|
+
const value24h = `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}`;
|
|
4113
|
+
setDisplayValue(value24h);
|
|
4114
|
+
onChange?.(value24h);
|
|
4115
|
+
} else {
|
|
4116
|
+
setDisplayValue(value2);
|
|
4117
|
+
onChange?.(value2);
|
|
4118
|
+
}
|
|
4119
|
+
};
|
|
4120
|
+
useEffect(() => {
|
|
4121
|
+
if (!value) {
|
|
4122
|
+
setDisplayValue("");
|
|
4123
|
+
}
|
|
4124
|
+
}, [value]);
|
|
4125
|
+
return /* @__PURE__ */ jsx(
|
|
4126
|
+
InputText,
|
|
4127
|
+
{
|
|
4128
|
+
ref,
|
|
4129
|
+
type: "text",
|
|
4130
|
+
value: displayValue,
|
|
4131
|
+
placeholder,
|
|
4132
|
+
...rest,
|
|
4133
|
+
onChange: (e) => handleInput(e.target.value),
|
|
4134
|
+
onKeyDown: handleKeyDown,
|
|
4135
|
+
maxLength: 5,
|
|
4136
|
+
icon: /* @__PURE__ */ jsx(ClockIcon, {})
|
|
4137
|
+
}
|
|
4138
|
+
);
|
|
4139
|
+
}
|
|
4140
|
+
);
|
|
4141
|
+
InputTime.displayName = "InputTime";
|
|
4142
|
+
var InputDateTimePickerSingle = ({
|
|
4143
|
+
portal,
|
|
4144
|
+
placeholder,
|
|
4145
|
+
className,
|
|
4146
|
+
value,
|
|
4147
|
+
onChange,
|
|
4148
|
+
numberOfMonths = 1,
|
|
4149
|
+
onClean,
|
|
4150
|
+
disabledDates,
|
|
4151
|
+
...rest
|
|
4152
|
+
}) => {
|
|
4153
|
+
const [popoverIsOpen, setPopoverIsOpen] = useState(false);
|
|
4154
|
+
const [innerTimeValue, setInnerTimeValue] = useState();
|
|
4155
|
+
const [innerDate, setInnerDate] = useState(
|
|
4156
|
+
value ? new Date(value) : void 0
|
|
4157
|
+
);
|
|
4158
|
+
const { locale, messages: messages17 } = useNebulaI18n();
|
|
4159
|
+
const [month, setMonth] = useState(/* @__PURE__ */ new Date());
|
|
4160
|
+
const inputTimeRef = useRef(null);
|
|
4161
|
+
const handleClearValue = () => {
|
|
4162
|
+
setInnerTimeValue("");
|
|
4163
|
+
setInnerDate(void 0);
|
|
4164
|
+
setMonth(/* @__PURE__ */ new Date());
|
|
4165
|
+
};
|
|
4166
|
+
const handleInnerInputChange = (text) => {
|
|
4167
|
+
const dateSlice = text.substring(0, 11).trim();
|
|
4168
|
+
let hourSlice = text.substring(11).trim();
|
|
4169
|
+
if (!text) {
|
|
4170
|
+
onChange?.(text);
|
|
4171
|
+
handleClearValue();
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4174
|
+
const [day, month2, year] = [
|
|
4175
|
+
locale !== "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
4176
|
+
locale === "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
4177
|
+
dateSlice.substring(6)
|
|
4178
|
+
];
|
|
4179
|
+
const date = new Date(Number(year), Number(month2) - 1, Number(day));
|
|
4180
|
+
if ([day, month2, year].some((value2) => !value2) || !dateFormatIsValid(dateSlice, locale) || !isValid(new Date(date)) || !dateIsAvailable(date, disabledDates)) {
|
|
4181
|
+
onChange?.(text);
|
|
4182
|
+
handleClearValue();
|
|
4183
|
+
return;
|
|
4184
|
+
}
|
|
4185
|
+
if (!timeFormatIsValid(hourSlice)) {
|
|
4186
|
+
hourSlice = "";
|
|
4187
|
+
setInnerTimeValue("");
|
|
4188
|
+
} else {
|
|
4189
|
+
setInnerTimeValue(hourSlice);
|
|
4190
|
+
}
|
|
4191
|
+
onChange?.(text, date, hourSlice);
|
|
4192
|
+
setInnerDate(date);
|
|
4193
|
+
};
|
|
4194
|
+
const handleOnChangeTime = (newTime) => {
|
|
4195
|
+
const [date = ""] = value?.split(" ") ?? [];
|
|
4196
|
+
setInnerTimeValue(newTime);
|
|
4197
|
+
if (date && !dateFormatIsValid(date, locale)) {
|
|
4198
|
+
handleClearValue();
|
|
4199
|
+
}
|
|
4200
|
+
onChange?.(date + " " + newTime, innerDate, newTime);
|
|
4201
|
+
};
|
|
4202
|
+
const handleKeyDown = (e) => {
|
|
4203
|
+
if ((e.altKey || e.ctrlKey || e.metaKey) && e.key !== "z") return;
|
|
4204
|
+
const allowedKeys = [
|
|
4205
|
+
"Backspace",
|
|
4206
|
+
"Delete",
|
|
4207
|
+
"Tab",
|
|
4208
|
+
"ArrowLeft",
|
|
4209
|
+
"ArrowRight",
|
|
4210
|
+
"Home",
|
|
4211
|
+
"End",
|
|
4212
|
+
":",
|
|
4213
|
+
"/",
|
|
4214
|
+
" "
|
|
4215
|
+
];
|
|
4216
|
+
if (!allowedKeys.includes(e.key) && !/^[0-9]$/.test(e.key)) {
|
|
4217
|
+
e.preventDefault();
|
|
4218
|
+
}
|
|
4219
|
+
};
|
|
4220
|
+
const handleCalendarSelect = (date) => {
|
|
4221
|
+
const dateToStr = Intl.DateTimeFormat(locale ?? "en-US", {
|
|
4222
|
+
month: "2-digit",
|
|
4223
|
+
year: "numeric",
|
|
4224
|
+
day: "2-digit"
|
|
4225
|
+
}).format(date);
|
|
4226
|
+
setInnerDate(date);
|
|
4227
|
+
onChange?.(
|
|
4228
|
+
[dateToStr, innerTimeValue].filter(Boolean).join(" "),
|
|
4229
|
+
date,
|
|
4230
|
+
innerTimeValue
|
|
4231
|
+
);
|
|
4232
|
+
if (!innerTimeValue) {
|
|
4233
|
+
setTimeout(() => inputTimeRef.current?.focus(), 100);
|
|
4234
|
+
}
|
|
4235
|
+
};
|
|
4236
|
+
const normalizedCalendarDate = useMemo(() => {
|
|
4237
|
+
return isValid(innerDate) ? innerDate : void 0;
|
|
4238
|
+
}, [innerDate]);
|
|
4239
|
+
useEffect(() => {
|
|
4240
|
+
if (innerDate) setMonth(innerDate);
|
|
4241
|
+
}, [innerDate]);
|
|
4242
|
+
return /* @__PURE__ */ jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
|
|
4243
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsx(
|
|
4244
|
+
"div",
|
|
4245
|
+
{
|
|
4246
|
+
onClick: (e) => e.preventDefault(),
|
|
4247
|
+
onFocus: (e) => e.preventDefault(),
|
|
4248
|
+
children: /* @__PURE__ */ jsx(
|
|
4249
|
+
InputText,
|
|
4250
|
+
{
|
|
4251
|
+
placeholder,
|
|
4252
|
+
value,
|
|
4253
|
+
className,
|
|
4254
|
+
onChange: (e) => handleInnerInputChange(e.target.value),
|
|
4255
|
+
onKeyDown: handleKeyDown,
|
|
4256
|
+
icon: /* @__PURE__ */ jsx(
|
|
4257
|
+
CalendarIcon,
|
|
4258
|
+
{
|
|
4259
|
+
tabIndex: 0,
|
|
4260
|
+
role: "button",
|
|
4261
|
+
onClick: () => setPopoverIsOpen((s) => !s),
|
|
4262
|
+
onKeyUp: (e) => {
|
|
4263
|
+
if (e.key === "Enter") {
|
|
4264
|
+
setPopoverIsOpen((s) => !s);
|
|
4265
|
+
}
|
|
4266
|
+
},
|
|
4267
|
+
className: "nebula-ds cursor-pointer"
|
|
4268
|
+
}
|
|
4269
|
+
),
|
|
4270
|
+
iconPlacement: "end",
|
|
4271
|
+
onKeyUp: (e) => {
|
|
4272
|
+
if (e.key === "ArrowDown") {
|
|
4273
|
+
setPopoverIsOpen(true);
|
|
4274
|
+
}
|
|
4275
|
+
},
|
|
4276
|
+
maxLength: 16,
|
|
4277
|
+
onClean: onClean ? () => {
|
|
4278
|
+
onClean();
|
|
4279
|
+
handleClearValue();
|
|
4280
|
+
} : void 0,
|
|
4281
|
+
...rest
|
|
4282
|
+
}
|
|
4283
|
+
)
|
|
4284
|
+
}
|
|
4285
|
+
) }),
|
|
4286
|
+
/* @__PURE__ */ jsx(
|
|
4287
|
+
PopoverContent,
|
|
4288
|
+
{
|
|
4289
|
+
portal,
|
|
4290
|
+
side: "bottom",
|
|
4291
|
+
className: "nebula-ds p-0 border-none bg-transparent shadow-none",
|
|
4292
|
+
align: "start",
|
|
4293
|
+
children: /* @__PURE__ */ jsx(
|
|
4294
|
+
Calendar,
|
|
4295
|
+
{
|
|
4296
|
+
required: false,
|
|
4297
|
+
mode: "single",
|
|
4298
|
+
numberOfMonths,
|
|
4299
|
+
selected: normalizedCalendarDate,
|
|
4300
|
+
onSelect: handleCalendarSelect,
|
|
4301
|
+
month,
|
|
4302
|
+
onPrevClick: setMonth,
|
|
4303
|
+
onNextClick: setMonth,
|
|
4304
|
+
disabled: disabledDates,
|
|
4305
|
+
footer: /* @__PURE__ */ jsxs(Space, { className: "nebula-ds items-center", children: [
|
|
4306
|
+
/* @__PURE__ */ jsxs(Label, { children: [
|
|
4307
|
+
messages17.timePicker.label,
|
|
4308
|
+
":"
|
|
4309
|
+
] }),
|
|
4310
|
+
/* @__PURE__ */ jsx(
|
|
4311
|
+
InputTime,
|
|
4312
|
+
{
|
|
4313
|
+
placeholder: "00:00",
|
|
4314
|
+
value: innerTimeValue,
|
|
4315
|
+
onChange: handleOnChangeTime,
|
|
4316
|
+
ref: inputTimeRef,
|
|
4317
|
+
className: "nebula-ds max-w-[188px]"
|
|
4318
|
+
}
|
|
4319
|
+
)
|
|
4320
|
+
] })
|
|
4321
|
+
}
|
|
4322
|
+
)
|
|
4323
|
+
}
|
|
4324
|
+
)
|
|
4325
|
+
] });
|
|
4326
|
+
};
|
|
4327
|
+
var FileUploadError = /* @__PURE__ */ ((FileUploadError2) => {
|
|
4328
|
+
FileUploadError2["MAX_FILES_EXCEEDED"] = "MAX_FILES_EXCEEDED";
|
|
4329
|
+
FileUploadError2["MAXIMUM_FILE_SIZE_EXCEEDED"] = "MAXIMUM_FILE_SIZE_EXCEEDED";
|
|
4330
|
+
FileUploadError2["INVALID_FORMAT"] = "INVALID_FORMAT";
|
|
4331
|
+
return FileUploadError2;
|
|
4332
|
+
})(FileUploadError || {});
|
|
4333
|
+
var useFileUpload = (options = {}) => {
|
|
4334
|
+
const {
|
|
4335
|
+
maxFiles = Infinity,
|
|
4336
|
+
maxSize = Infinity,
|
|
4337
|
+
accept = "*",
|
|
4338
|
+
multiple = false,
|
|
4339
|
+
initialFiles = [],
|
|
4340
|
+
onFilesChange,
|
|
4341
|
+
onFilesAdded
|
|
4342
|
+
} = options;
|
|
4343
|
+
const [state, setState] = useState({
|
|
4344
|
+
files: initialFiles.map((file) => ({
|
|
4345
|
+
file,
|
|
4346
|
+
id: file.id,
|
|
4347
|
+
preview: file.url
|
|
4348
|
+
})),
|
|
4349
|
+
isDragging: false,
|
|
4350
|
+
errors: []
|
|
4351
|
+
});
|
|
4352
|
+
const inputRef = useRef(null);
|
|
4353
|
+
const validateFile = useCallback(
|
|
4354
|
+
(file) => {
|
|
4355
|
+
if (file instanceof File) {
|
|
4356
|
+
if (file.size > maxSize) {
|
|
4357
|
+
return {
|
|
4358
|
+
file,
|
|
4359
|
+
error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */
|
|
4360
|
+
};
|
|
4361
|
+
}
|
|
4362
|
+
} else {
|
|
4363
|
+
if (file.size > maxSize) {
|
|
4364
|
+
return { error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */, file };
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
if (accept !== "*") {
|
|
4368
|
+
const acceptedTypes = accept.split(",").map((type) => type.trim());
|
|
4369
|
+
const fileType = file instanceof File ? file.type || "" : file.type;
|
|
4370
|
+
const fileExtension = `.${file instanceof File ? file.name.split(".").pop() : file.name.split(".").pop()}`;
|
|
4371
|
+
const isAccepted = acceptedTypes.some((type) => {
|
|
4372
|
+
if (type.startsWith(".")) {
|
|
4373
|
+
return fileExtension.toLowerCase() === type.toLowerCase();
|
|
4374
|
+
}
|
|
4375
|
+
if (type.endsWith("/*")) {
|
|
4376
|
+
const baseType = type.split("/")[0];
|
|
4377
|
+
return fileType.startsWith(`${baseType}/`);
|
|
4378
|
+
}
|
|
4379
|
+
return fileType === type;
|
|
4380
|
+
});
|
|
4381
|
+
if (!isAccepted) {
|
|
4382
|
+
return {
|
|
4383
|
+
file,
|
|
4384
|
+
error: "INVALID_FORMAT" /* INVALID_FORMAT */
|
|
4385
|
+
};
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
return null;
|
|
4389
|
+
},
|
|
4390
|
+
[accept, maxSize]
|
|
4391
|
+
);
|
|
4392
|
+
const createPreview = useCallback(
|
|
4393
|
+
(file) => {
|
|
4394
|
+
if (file instanceof File) {
|
|
4395
|
+
return URL.createObjectURL(file);
|
|
4396
|
+
}
|
|
4397
|
+
return file.url;
|
|
4398
|
+
},
|
|
4399
|
+
[]
|
|
4400
|
+
);
|
|
4401
|
+
const generateUniqueId = useCallback((file) => {
|
|
4402
|
+
if (file instanceof File) {
|
|
4403
|
+
return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
4404
|
+
}
|
|
4405
|
+
return file.id;
|
|
4406
|
+
}, []);
|
|
4407
|
+
const clearFiles = useCallback(() => {
|
|
4408
|
+
setState((prev) => {
|
|
4409
|
+
prev.files.forEach((file) => {
|
|
4410
|
+
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) {
|
|
4411
|
+
URL.revokeObjectURL(file.preview);
|
|
4412
|
+
}
|
|
4413
|
+
});
|
|
4414
|
+
if (inputRef.current) {
|
|
4415
|
+
inputRef.current.value = "";
|
|
4416
|
+
}
|
|
4417
|
+
const newState = {
|
|
4418
|
+
...prev,
|
|
4419
|
+
files: [],
|
|
4420
|
+
errors: []
|
|
4421
|
+
};
|
|
4422
|
+
onFilesChange?.(newState.files);
|
|
4423
|
+
return newState;
|
|
4424
|
+
});
|
|
4425
|
+
}, [onFilesChange]);
|
|
4426
|
+
const addFiles = useCallback(
|
|
4427
|
+
(newFiles) => {
|
|
4428
|
+
if (!newFiles || newFiles.length === 0) return;
|
|
4429
|
+
const newFilesArray = Array.from(newFiles);
|
|
4430
|
+
const errors = [];
|
|
4431
|
+
setState((prev) => ({ ...prev, errors: [] }));
|
|
4432
|
+
if (!multiple) {
|
|
4433
|
+
clearFiles();
|
|
4434
|
+
}
|
|
4435
|
+
if (multiple && maxFiles !== Infinity && state.files.length + newFilesArray.length > maxFiles) {
|
|
4436
|
+
errors.push({ error: "MAX_FILES_EXCEEDED" /* MAX_FILES_EXCEEDED */ });
|
|
4437
|
+
setState((prev) => ({ ...prev, errors }));
|
|
4438
|
+
return;
|
|
4439
|
+
}
|
|
4440
|
+
const validFiles = [];
|
|
4441
|
+
newFilesArray.forEach((file) => {
|
|
4442
|
+
if (multiple) {
|
|
4443
|
+
const isDuplicate = state.files.some(
|
|
4444
|
+
(existingFile) => existingFile.file.name === file.name && existingFile.file.size === file.size
|
|
4445
|
+
);
|
|
4446
|
+
if (isDuplicate) {
|
|
4447
|
+
return;
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
if (file.size > maxSize) {
|
|
4451
|
+
errors.push({
|
|
4452
|
+
error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */,
|
|
4453
|
+
file
|
|
4454
|
+
});
|
|
4455
|
+
return;
|
|
4456
|
+
}
|
|
4457
|
+
const error2 = validateFile(file);
|
|
4458
|
+
if (error2) {
|
|
4459
|
+
errors.push(error2);
|
|
4460
|
+
} else {
|
|
4461
|
+
validFiles.push({
|
|
4462
|
+
file,
|
|
4463
|
+
id: generateUniqueId(file),
|
|
4464
|
+
preview: createPreview(file)
|
|
4465
|
+
});
|
|
4466
|
+
}
|
|
4467
|
+
});
|
|
4468
|
+
if (validFiles.length > 0) {
|
|
4469
|
+
onFilesAdded?.(validFiles);
|
|
4470
|
+
setState((prev) => {
|
|
4471
|
+
const newFiles2 = !multiple ? validFiles : [...prev.files, ...validFiles];
|
|
4472
|
+
onFilesChange?.(newFiles2);
|
|
4473
|
+
return {
|
|
4474
|
+
...prev,
|
|
4475
|
+
files: newFiles2,
|
|
4476
|
+
errors
|
|
4477
|
+
};
|
|
4478
|
+
});
|
|
4479
|
+
} else if (errors.length > 0) {
|
|
4480
|
+
setState((prev) => ({
|
|
4481
|
+
...prev,
|
|
4482
|
+
errors
|
|
4483
|
+
}));
|
|
4484
|
+
}
|
|
4485
|
+
if (inputRef.current) {
|
|
4486
|
+
inputRef.current.value = "";
|
|
4487
|
+
}
|
|
4488
|
+
},
|
|
4489
|
+
[
|
|
4490
|
+
state.files,
|
|
4491
|
+
maxFiles,
|
|
4492
|
+
multiple,
|
|
4493
|
+
maxSize,
|
|
4494
|
+
validateFile,
|
|
4495
|
+
createPreview,
|
|
4496
|
+
generateUniqueId,
|
|
4497
|
+
clearFiles,
|
|
4498
|
+
onFilesChange,
|
|
4499
|
+
onFilesAdded
|
|
4500
|
+
]
|
|
4501
|
+
);
|
|
4502
|
+
const removeFile = useCallback(
|
|
4503
|
+
(id) => {
|
|
4504
|
+
setState((prev) => {
|
|
4505
|
+
const fileToRemove = prev.files.find((file) => file.id === id);
|
|
4506
|
+
if (fileToRemove && fileToRemove.preview && fileToRemove.file instanceof File && fileToRemove.file.type.startsWith("image/")) {
|
|
4507
|
+
URL.revokeObjectURL(fileToRemove.preview);
|
|
4508
|
+
}
|
|
4509
|
+
const newFiles = prev.files.filter((file) => file.id !== id);
|
|
4510
|
+
onFilesChange?.(newFiles);
|
|
4511
|
+
return {
|
|
4512
|
+
...prev,
|
|
4513
|
+
files: newFiles,
|
|
4514
|
+
errors: []
|
|
4515
|
+
};
|
|
4516
|
+
});
|
|
4517
|
+
},
|
|
4518
|
+
[onFilesChange]
|
|
4519
|
+
);
|
|
4520
|
+
const clearErrors = useCallback(() => {
|
|
4521
|
+
setState((prev) => ({
|
|
4522
|
+
...prev,
|
|
4523
|
+
errors: []
|
|
4524
|
+
}));
|
|
4525
|
+
}, []);
|
|
4526
|
+
const handleDragEnter = useCallback((e) => {
|
|
4527
|
+
e.preventDefault();
|
|
4528
|
+
e.stopPropagation();
|
|
4529
|
+
setState((prev) => ({ ...prev, isDragging: true }));
|
|
4530
|
+
}, []);
|
|
4531
|
+
const handleDragLeave = useCallback((e) => {
|
|
4532
|
+
e.preventDefault();
|
|
4533
|
+
e.stopPropagation();
|
|
4534
|
+
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
4535
|
+
return;
|
|
4536
|
+
}
|
|
4537
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
4538
|
+
}, []);
|
|
4539
|
+
const handleDragOver = useCallback((e) => {
|
|
4540
|
+
e.preventDefault();
|
|
4541
|
+
e.stopPropagation();
|
|
4542
|
+
}, []);
|
|
4543
|
+
const handleDrop = useCallback(
|
|
4544
|
+
(e) => {
|
|
4545
|
+
e.preventDefault();
|
|
4546
|
+
e.stopPropagation();
|
|
4547
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
4548
|
+
if (inputRef.current?.disabled) {
|
|
4549
|
+
return;
|
|
4550
|
+
}
|
|
4551
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
4552
|
+
if (!multiple) {
|
|
4553
|
+
const file = e.dataTransfer.files[0];
|
|
4554
|
+
if (file) {
|
|
4555
|
+
addFiles([file]);
|
|
4556
|
+
}
|
|
4557
|
+
} else {
|
|
4558
|
+
addFiles(e.dataTransfer.files);
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
},
|
|
4562
|
+
[addFiles, multiple]
|
|
4563
|
+
);
|
|
4564
|
+
const handleFileChange = useCallback(
|
|
4565
|
+
(e) => {
|
|
4566
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
4567
|
+
addFiles(e.target.files);
|
|
4568
|
+
}
|
|
4569
|
+
},
|
|
4570
|
+
[addFiles]
|
|
4571
|
+
);
|
|
4572
|
+
const openFileDialog = useCallback(() => {
|
|
4573
|
+
if (inputRef.current) {
|
|
4574
|
+
inputRef.current.click();
|
|
4575
|
+
}
|
|
4576
|
+
}, []);
|
|
4577
|
+
const getInputProps = useCallback(
|
|
4578
|
+
(props = {}) => {
|
|
4579
|
+
return {
|
|
4580
|
+
...props,
|
|
4581
|
+
type: "file",
|
|
4582
|
+
onChange: handleFileChange,
|
|
4583
|
+
accept: props.accept || accept,
|
|
4584
|
+
multiple: props.multiple !== void 0 ? props.multiple : multiple,
|
|
4585
|
+
ref: inputRef
|
|
4586
|
+
};
|
|
4587
|
+
},
|
|
4588
|
+
[accept, multiple, handleFileChange]
|
|
4589
|
+
);
|
|
4590
|
+
return [
|
|
4591
|
+
state,
|
|
4592
|
+
{
|
|
4593
|
+
addFiles,
|
|
4594
|
+
removeFile,
|
|
4595
|
+
clearFiles,
|
|
4596
|
+
clearErrors,
|
|
4597
|
+
handleDragEnter,
|
|
4598
|
+
handleDragLeave,
|
|
4599
|
+
handleDragOver,
|
|
4600
|
+
handleDrop,
|
|
4601
|
+
handleFileChange,
|
|
4602
|
+
openFileDialog,
|
|
4603
|
+
getInputProps
|
|
4604
|
+
}
|
|
4605
|
+
];
|
|
4606
|
+
};
|
|
4607
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
4608
|
+
if (bytes === 0) return "0 Bytes";
|
|
4609
|
+
const k = 1024;
|
|
4610
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
4611
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
4612
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
4613
|
+
return Number.parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + (sizes?.[i] || "");
|
|
4614
|
+
};
|
|
4615
|
+
var filePreviewByMimetype = (mimetype) => {
|
|
4616
|
+
if (mimetype.match("text") || mimetype.match("application")) {
|
|
4617
|
+
return /* @__PURE__ */ jsx(FileTextIcon, {});
|
|
4618
|
+
}
|
|
4619
|
+
if (mimetype.match("audio")) {
|
|
4620
|
+
return /* @__PURE__ */ jsx(FileAudioIcon, {});
|
|
4621
|
+
}
|
|
4622
|
+
if (mimetype.match("video")) {
|
|
4623
|
+
return /* @__PURE__ */ jsx(FileVideoIcon, {});
|
|
4624
|
+
}
|
|
4625
|
+
return null;
|
|
4626
|
+
};
|
|
4627
|
+
function FileUpload({
|
|
4628
|
+
maxSizeMB = 2,
|
|
4629
|
+
subtitle,
|
|
4630
|
+
title,
|
|
4631
|
+
imagePreview,
|
|
4632
|
+
showPreview = true,
|
|
4633
|
+
onError,
|
|
4634
|
+
maxFiles = Infinity,
|
|
4635
|
+
...rest
|
|
4636
|
+
}) {
|
|
4637
|
+
const { fileUpload } = useNebulaI18n().messages;
|
|
4638
|
+
const maxSize = maxSizeMB * 1024 * 1024;
|
|
4639
|
+
const [
|
|
4640
|
+
{ files, isDragging, errors },
|
|
4641
|
+
{
|
|
4642
|
+
handleDragEnter,
|
|
4643
|
+
handleDragLeave,
|
|
4644
|
+
handleDragOver,
|
|
4645
|
+
handleDrop,
|
|
4646
|
+
openFileDialog,
|
|
4647
|
+
removeFile,
|
|
4648
|
+
getInputProps,
|
|
4649
|
+
clearFiles
|
|
4650
|
+
}
|
|
4651
|
+
] = useFileUpload({
|
|
4652
|
+
multiple: false,
|
|
4653
|
+
maxSize: maxSize > 0 ? maxSize : void 0,
|
|
4654
|
+
accept: "*",
|
|
4655
|
+
...rest,
|
|
4656
|
+
maxFiles
|
|
4657
|
+
});
|
|
4658
|
+
useEffect(() => {
|
|
4659
|
+
onError?.(errors);
|
|
4660
|
+
}, [errors, onError]);
|
|
4661
|
+
const disabled = useMemo(() => {
|
|
4662
|
+
if (rest.disabled) return true;
|
|
4663
|
+
if (rest.multiple) {
|
|
4664
|
+
if (!Number.isFinite(maxFiles)) return false;
|
|
4665
|
+
return files.length === maxFiles;
|
|
4666
|
+
}
|
|
4667
|
+
return files.length;
|
|
4668
|
+
}, [rest.disabled, rest.multiple, files.length, maxFiles]);
|
|
4669
|
+
return /* @__PURE__ */ jsxs("div", { className: "nebula-ds flex flex-col gap-2 w-full", children: [
|
|
4670
|
+
/* @__PURE__ */ jsx("div", { className: "nebula-ds relative w-full", children: /* @__PURE__ */ jsxs(
|
|
4671
|
+
"div",
|
|
4672
|
+
{
|
|
4673
|
+
role: "button",
|
|
4674
|
+
onClick: openFileDialog,
|
|
4675
|
+
onDragEnter: handleDragEnter,
|
|
4676
|
+
onDragLeave: handleDragLeave,
|
|
4677
|
+
onDragOver: handleDragOver,
|
|
4678
|
+
onDrop: handleDrop,
|
|
4679
|
+
"data-dragging": isDragging || void 0,
|
|
4680
|
+
className: cn(
|
|
4681
|
+
"bg-fileUpload-background hover:bg-fileUpload-backgroundHover transition-colors",
|
|
4682
|
+
"border border-dashed border-fileUpload-border rounded-2xl",
|
|
4683
|
+
"py-14",
|
|
4684
|
+
disabled && "pointer-events-none cursor-not-allowed"
|
|
4685
|
+
),
|
|
4686
|
+
children: [
|
|
4687
|
+
/* @__PURE__ */ jsx(
|
|
4688
|
+
"input",
|
|
4689
|
+
{
|
|
4690
|
+
...getInputProps(),
|
|
4691
|
+
className: "nebula-ds sr-only",
|
|
4692
|
+
"aria-label": "Upload file"
|
|
4693
|
+
}
|
|
4694
|
+
),
|
|
4695
|
+
/* @__PURE__ */ jsxs(
|
|
4696
|
+
"div",
|
|
4697
|
+
{
|
|
4698
|
+
className: cn(
|
|
4699
|
+
"flex flex-col items-center justify-center px-4 py-3 text-center w-full",
|
|
4700
|
+
disabled && "opacity-60"
|
|
4701
|
+
),
|
|
4702
|
+
children: [
|
|
4703
|
+
/* @__PURE__ */ jsx(
|
|
4704
|
+
"div",
|
|
4705
|
+
{
|
|
4706
|
+
className: "nebula-ds mb-2 flex size-12 shrink-0 items-center justify-center rounded-full border border-fileUpload-border",
|
|
4707
|
+
"aria-hidden": "true",
|
|
4708
|
+
children: /* @__PURE__ */ jsx(ImageUpIcon, { className: "nebula-ds size-4 opacity-60 text-fileUpload-icon" })
|
|
4709
|
+
}
|
|
4710
|
+
),
|
|
4711
|
+
/* @__PURE__ */ jsx(Heading, { level: "5", className: "nebula-ds mb-1", children: title }),
|
|
4712
|
+
/* @__PURE__ */ jsx(Paragraph, { size: "sm", children: subtitle })
|
|
4713
|
+
]
|
|
4714
|
+
}
|
|
4715
|
+
)
|
|
4716
|
+
]
|
|
4717
|
+
}
|
|
4718
|
+
) }),
|
|
4719
|
+
files.length > 0 && showPreview && /* @__PURE__ */ jsx("div", { className: "nebula-ds space-y-2", children: files.map((file, idx) => /* @__PURE__ */ jsxs(
|
|
4720
|
+
"div",
|
|
4721
|
+
{
|
|
4722
|
+
className: "nebula-ds bg-fileUpload-backgroundFile flex items-center justify-between gap-2 rounded-xl border border-fileUpload-borderFile p-2",
|
|
4723
|
+
children: [
|
|
4724
|
+
/* @__PURE__ */ jsxs("div", { className: "nebula-ds flex items-center gap-3 overflow-hidden", children: [
|
|
4725
|
+
/* @__PURE__ */ jsx("div", { className: "nebula-ds bg-[inherit] aspect-square shrink-0 rounded border border-fileUpload-borderFile size-10 [&>svg]:size-4 [&>svg]:text-fileUpload-icon flex items-center justify-center", children: imagePreview?.(file) || filePreviewByMimetype(file.file.type) || /* @__PURE__ */ jsx(
|
|
4726
|
+
"img",
|
|
4727
|
+
{
|
|
4728
|
+
src: file.preview,
|
|
4729
|
+
alt: file.file.name,
|
|
4730
|
+
className: "nebula-ds rounded-[inherit] object-cover h-full w-full"
|
|
4731
|
+
}
|
|
4732
|
+
) }),
|
|
4733
|
+
/* @__PURE__ */ jsxs("div", { className: "nebula-ds flex min-w-0 flex-col gap-1", children: [
|
|
4734
|
+
/* @__PURE__ */ jsx(Heading, { level: "5", className: "nebula-ds text-xs", children: file.file.name }),
|
|
4735
|
+
/* @__PURE__ */ jsx(Paragraph, { size: "sm", children: formatBytes(file.file.size) })
|
|
4736
|
+
] })
|
|
4737
|
+
] }),
|
|
4738
|
+
/* @__PURE__ */ jsx(
|
|
4739
|
+
Button,
|
|
4740
|
+
{
|
|
4741
|
+
icon: true,
|
|
4742
|
+
variant: "ghost",
|
|
4743
|
+
onClick: () => removeFile(file.id),
|
|
4744
|
+
"aria-label": "Remove file",
|
|
4745
|
+
"data-testid": `file-upload-remove-file-${idx}`,
|
|
4746
|
+
children: /* @__PURE__ */ jsx(XIcon, { "aria-hidden": "true" })
|
|
4747
|
+
}
|
|
4748
|
+
)
|
|
4749
|
+
]
|
|
4750
|
+
},
|
|
4751
|
+
file.id
|
|
4752
|
+
)) }),
|
|
4753
|
+
files.length > 1 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
4754
|
+
Button,
|
|
4755
|
+
{
|
|
4756
|
+
size: "md",
|
|
4757
|
+
variant: "secondary",
|
|
4758
|
+
onClick: clearFiles,
|
|
4759
|
+
"data-testid": "file-upload-remove-all-files",
|
|
4760
|
+
children: fileUpload.deleteAll
|
|
4761
|
+
}
|
|
4762
|
+
) })
|
|
4763
|
+
] });
|
|
4764
|
+
}
|
|
4765
|
+
var TextArea = React8.forwardRef(
|
|
4766
|
+
({
|
|
4767
|
+
className,
|
|
4768
|
+
isError = false,
|
|
4769
|
+
disabled,
|
|
4770
|
+
resize = true,
|
|
4771
|
+
showCount = false,
|
|
4772
|
+
autoResize = true,
|
|
4773
|
+
maxLength,
|
|
4774
|
+
asInput,
|
|
4775
|
+
...props
|
|
4776
|
+
}, ref) => {
|
|
4777
|
+
const innerRef = React8.useRef(
|
|
4778
|
+
null
|
|
4779
|
+
);
|
|
4780
|
+
const [count, setCount] = React8.useState(String(props.value ?? "").length);
|
|
4781
|
+
const countParts = [count, maxLength].filter(
|
|
4782
|
+
(part) => typeof part === "number"
|
|
4783
|
+
);
|
|
4784
|
+
React8.useEffect(() => {
|
|
4785
|
+
const textarea = innerRef.current;
|
|
4786
|
+
if (!textarea || !autoResize) return;
|
|
4787
|
+
const adjustHeight = () => {
|
|
4788
|
+
textarea.style.height = "auto";
|
|
4789
|
+
textarea.style.height = asInput && !textarea.value || !textarea.value.match("\n") ? "22px" : `${textarea.scrollHeight}px`;
|
|
4790
|
+
};
|
|
4791
|
+
adjustHeight();
|
|
4792
|
+
textarea.addEventListener("input", adjustHeight);
|
|
4793
|
+
return () => {
|
|
4794
|
+
textarea.removeEventListener("input", adjustHeight);
|
|
4795
|
+
};
|
|
4796
|
+
}, [asInput, autoResize, props.value]);
|
|
4797
|
+
React8.useImperativeHandle(ref, () => innerRef.current);
|
|
4798
|
+
return /* @__PURE__ */ jsxs("div", { className: "nebula-ds relative", children: [
|
|
4799
|
+
/* @__PURE__ */ jsx(
|
|
4800
|
+
"div",
|
|
4801
|
+
{
|
|
4802
|
+
className: cn(
|
|
4803
|
+
"w-full pl-0 pr-2 py-2 overflow-hidden flex box-border",
|
|
4804
|
+
"w-full outline-none rounded-textarea text-sm font-medium",
|
|
4805
|
+
"bg-inputText-background-default",
|
|
4806
|
+
"border border-inputText-border-default focus-within:ring-[3px] focus-within:ring-inputText-border-focus focus-within:border-inputText-border-focus",
|
|
4807
|
+
"text-inputText-text-filled focus-within:text-inputText-text-focus ",
|
|
4808
|
+
"disabled:cursor-not-allowed",
|
|
4809
|
+
"[&>textarea]:bg-transparent [&>textarea]:w-full [&>textarea]:py-0 [&>textarea]:pr-2 [&>textarea]:pl-4 [&>textarea]:flex-1 [&>textarea]:min-h-[62px] [&>textarea]:box-border",
|
|
4810
|
+
"[&>textarea]:focus:ring-0 [&>textarea]:focus:border-none [&>textarea]:border-none [&>textarea]:outline-none [&>textarea]:ring-0",
|
|
4811
|
+
"[&>textarea]:bg-inputText-background-default disabled:[&>textarea]:bg-inputText-background-disabled",
|
|
4812
|
+
"[&>textarea]:placeholder:text-inputText-text-default disabled:[&>textarea]:text-inputText-text-disabled",
|
|
4813
|
+
{
|
|
4814
|
+
"bg-inputText-background-disabled text-inputText-text-disabled [&>textarea]:ps-4 [&>textarea]:pr-2": disabled,
|
|
4815
|
+
"border-inputText-border-danger focus-within:border-inputText-border-danger focus-within:ring-button-danger-border-focus": isError,
|
|
4816
|
+
"[&>textarea]:resize-none": !resize,
|
|
4817
|
+
"[&>textarea]:min-h-[22px] !rounded-input": asInput
|
|
4818
|
+
},
|
|
4819
|
+
className
|
|
4820
|
+
),
|
|
4821
|
+
children: /* @__PURE__ */ jsx(
|
|
4822
|
+
"textarea",
|
|
4823
|
+
{
|
|
4824
|
+
ref: innerRef,
|
|
4825
|
+
...props,
|
|
4826
|
+
disabled,
|
|
4827
|
+
onChange: (e) => {
|
|
4828
|
+
if (showCount) {
|
|
4829
|
+
setCount(e.target.value.length);
|
|
4830
|
+
}
|
|
4831
|
+
props.onChange?.(e);
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
)
|
|
4835
|
+
}
|
|
4836
|
+
),
|
|
4837
|
+
!!showCount && /* @__PURE__ */ jsx("div", { className: "nebula-ds absolute right-0 top-[100%] pt-1", children: /* @__PURE__ */ jsx(Paragraph, { size: "sm", children: countParts.join("/") }) })
|
|
4838
|
+
] });
|
|
4839
|
+
}
|
|
4840
|
+
);
|
|
4841
|
+
TextArea.displayName = "TextArea";
|
|
3638
4842
|
|
|
3639
4843
|
// src/tailwind.ts
|
|
3640
4844
|
function content({ base = "./" } = {}) {
|
|
@@ -3645,35 +4849,5 @@ var tailwind = {
|
|
|
3645
4849
|
content
|
|
3646
4850
|
// plugin: () => require("tailwindcss")("node_modules/@nebulareact/dist/tailwind.config.js"),
|
|
3647
4851
|
};
|
|
3648
|
-
/*! Bundled license information:
|
|
3649
|
-
|
|
3650
|
-
lucide-react/dist/esm/shared/src/utils.js:
|
|
3651
|
-
lucide-react/dist/esm/defaultAttributes.js:
|
|
3652
|
-
lucide-react/dist/esm/Icon.js:
|
|
3653
|
-
lucide-react/dist/esm/createLucideIcon.js:
|
|
3654
|
-
lucide-react/dist/esm/icons/check.js:
|
|
3655
|
-
lucide-react/dist/esm/icons/chevron-down.js:
|
|
3656
|
-
lucide-react/dist/esm/icons/chevron-left.js:
|
|
3657
|
-
lucide-react/dist/esm/icons/chevron-right.js:
|
|
3658
|
-
lucide-react/dist/esm/icons/chevrons-left.js:
|
|
3659
|
-
lucide-react/dist/esm/icons/chevrons-right.js:
|
|
3660
|
-
lucide-react/dist/esm/icons/circle-check-big.js:
|
|
3661
|
-
lucide-react/dist/esm/icons/circle-x.js:
|
|
3662
|
-
lucide-react/dist/esm/icons/circle.js:
|
|
3663
|
-
lucide-react/dist/esm/icons/ellipsis.js:
|
|
3664
|
-
lucide-react/dist/esm/icons/eye-off.js:
|
|
3665
|
-
lucide-react/dist/esm/icons/eye.js:
|
|
3666
|
-
lucide-react/dist/esm/icons/info.js:
|
|
3667
|
-
lucide-react/dist/esm/icons/minus.js:
|
|
3668
|
-
lucide-react/dist/esm/icons/phone.js:
|
|
3669
|
-
lucide-react/dist/esm/icons/x.js:
|
|
3670
|
-
lucide-react/dist/esm/lucide-react.js:
|
|
3671
|
-
(**
|
|
3672
|
-
* @license lucide-react v0.476.0 - ISC
|
|
3673
|
-
*
|
|
3674
|
-
* This source code is licensed under the ISC license.
|
|
3675
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
3676
|
-
*)
|
|
3677
|
-
*/
|
|
3678
4852
|
|
|
3679
|
-
export { Accordion, AccordionContent, AccordionDescription, AccordionItem, AccordionTitle, AccordionTrigger, ActionBar, ActionBarButton, ActionBarClose, ActionBarContent, ActionBarDivider, ActionBarPortal, ActionBarTrigger, Alert, AlertButton, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AlertTitle, StyledAsync as Async, StyledAsyncCreatable as AsyncCreatable, Badge, Box, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Caption, Checkbox, StyledCreatable as Creatable, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Heading, InputPhone, InputText, Label, Link, NebulaI18nProvider, Pagination, Paragraph, Popover, PopoverContent, PopoverTrigger, StyledSelect as Select, Separator2 as Separator, Skeleton, Space, SpaceDirectionEnum, SpaceSizeEnum, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Toaster, Tooltip, alertVariants, badgeSizeEnum, badgeVariantEnum, buttonSizeEnum, buttonVariantEnum, buttonVariantsConfig, getNebulaLanguage,
|
|
4853
|
+
export { Accordion, AccordionContent, AccordionDescription, AccordionItem, AccordionTitle, AccordionTrigger, ActionBar, ActionBarButton, ActionBarClose, ActionBarContent, ActionBarDivider, ActionBarPortal, ActionBarTrigger, Alert, AlertButton, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AlertTitle, StyledAsync as Async, StyledAsyncCreatable as AsyncCreatable, Badge, Box, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Caption, Checkbox, StyledCreatable as Creatable, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FileUpload, FileUploadError, Heading, InputDatePickerSingle, InputDateTimePickerSingle, InputPhone, InputText, InputTime, Label, Link, NebulaI18nProvider, Pagination, Paragraph, Popover, PopoverContent, PopoverTrigger, StyledSelect as Select, Separator2 as Separator, Skeleton, Space, SpaceDirectionEnum, SpaceSizeEnum, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TextArea, Toaster, Tooltip, alertVariants, badgeSizeEnum, badgeVariantEnum, buttonSizeEnum, buttonVariantEnum, buttonVariantsConfig, dateIsAvailable, formatBytes, getNebulaLanguage, localeByi18nKey, messages16 as messages, separatorVariants, setNebulaLanguage, tagVariantsEnum, tailwind, toast, useNebulaI18n };
|