@ikatec/nebula-react 1.0.15 → 1.0.17
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 +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +670 -70
- package/dist/index.mjs +667 -72
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,7 +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, PhoneIcon, Info, CircleCheckBig } from 'lucide-react';
|
|
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';
|
|
11
11
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
12
12
|
import Select, { components } from 'react-select';
|
|
13
13
|
import Creatable from 'react-select/creatable';
|
|
@@ -23,7 +23,7 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
|
23
23
|
import { Toaster as Toaster$1, toast as toast$1 } from 'sonner';
|
|
24
24
|
import * as RPNInput from 'react-phone-number-input';
|
|
25
25
|
import flags from 'react-phone-number-input/flags';
|
|
26
|
-
import { formatDate, isValid, addMonths } from 'date-fns';
|
|
26
|
+
import { formatDate, isValid, addMonths, isSameDay, isBefore, isAfter } from 'date-fns';
|
|
27
27
|
import { DayPicker } from 'react-day-picker';
|
|
28
28
|
import { ptBR, enUS, es } from 'react-day-picker/locale';
|
|
29
29
|
|
|
@@ -1110,16 +1110,23 @@ var messages4 = {
|
|
|
1110
1110
|
};
|
|
1111
1111
|
var time_picker_default = messages4;
|
|
1112
1112
|
|
|
1113
|
+
// src/i18n/messages/en/file-upload.ts
|
|
1114
|
+
var messages5 = {
|
|
1115
|
+
deleteAll: "Remove all"
|
|
1116
|
+
};
|
|
1117
|
+
var file_upload_default = messages5;
|
|
1118
|
+
|
|
1113
1119
|
// src/i18n/messages/en/index.ts
|
|
1114
1120
|
var enMessages = {
|
|
1115
1121
|
pagination: pagination_default,
|
|
1116
1122
|
inputSelect: input_select_default,
|
|
1117
1123
|
inputPhone: input_phone_default,
|
|
1118
|
-
timePicker: time_picker_default
|
|
1124
|
+
timePicker: time_picker_default,
|
|
1125
|
+
fileUpload: file_upload_default
|
|
1119
1126
|
};
|
|
1120
1127
|
|
|
1121
1128
|
// src/i18n/messages/es/pagination.ts
|
|
1122
|
-
var
|
|
1129
|
+
var messages6 = {
|
|
1123
1130
|
totalResultsLabel(pagesSize, totalResults) {
|
|
1124
1131
|
if (totalResults < pagesSize) {
|
|
1125
1132
|
pagesSize = totalResults;
|
|
@@ -1130,16 +1137,16 @@ var messages5 = {
|
|
|
1130
1137
|
return `P\xE1gina ${currentPage} de ${totalPages}`;
|
|
1131
1138
|
}
|
|
1132
1139
|
};
|
|
1133
|
-
var pagination_default2 =
|
|
1140
|
+
var pagination_default2 = messages6;
|
|
1134
1141
|
|
|
1135
1142
|
// src/i18n/messages/es/input-select.ts
|
|
1136
|
-
var
|
|
1143
|
+
var messages7 = {
|
|
1137
1144
|
noOptions: "No hay opciones disponibles"
|
|
1138
1145
|
};
|
|
1139
|
-
var input_select_default2 =
|
|
1146
|
+
var input_select_default2 = messages7;
|
|
1140
1147
|
|
|
1141
1148
|
// src/i18n/messages/es/input-phone.ts
|
|
1142
|
-
var
|
|
1149
|
+
var messages8 = {
|
|
1143
1150
|
countries: {
|
|
1144
1151
|
empty: "Seleccionar",
|
|
1145
1152
|
AF: "Afganist\xE1n",
|
|
@@ -1389,24 +1396,31 @@ var messages7 = {
|
|
|
1389
1396
|
ZW: "Zimbabue"
|
|
1390
1397
|
}
|
|
1391
1398
|
};
|
|
1392
|
-
var input_phone_default2 =
|
|
1399
|
+
var input_phone_default2 = messages8;
|
|
1393
1400
|
|
|
1394
1401
|
// src/i18n/messages/es/time-picker.ts
|
|
1395
|
-
var
|
|
1402
|
+
var messages9 = {
|
|
1396
1403
|
label: "Tiempo"
|
|
1397
1404
|
};
|
|
1398
|
-
var time_picker_default2 =
|
|
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;
|
|
1399
1412
|
|
|
1400
1413
|
// src/i18n/messages/es/index.ts
|
|
1401
1414
|
var esMessages = {
|
|
1402
1415
|
pagination: pagination_default2,
|
|
1403
1416
|
inputSelect: input_select_default2,
|
|
1404
1417
|
inputPhone: input_phone_default2,
|
|
1405
|
-
timePicker: time_picker_default2
|
|
1418
|
+
timePicker: time_picker_default2,
|
|
1419
|
+
fileUpload: file_upload_default2
|
|
1406
1420
|
};
|
|
1407
1421
|
|
|
1408
1422
|
// src/i18n/messages/pt-br/pagination.ts
|
|
1409
|
-
var
|
|
1423
|
+
var messages11 = {
|
|
1410
1424
|
totalResultsLabel(pagesSize, totalResults) {
|
|
1411
1425
|
if (totalResults < pagesSize) {
|
|
1412
1426
|
pagesSize = totalResults;
|
|
@@ -1417,16 +1431,16 @@ var messages9 = {
|
|
|
1417
1431
|
return `P\xE1gina ${currentPage} de ${totalPages}`;
|
|
1418
1432
|
}
|
|
1419
1433
|
};
|
|
1420
|
-
var pagination_default3 =
|
|
1434
|
+
var pagination_default3 = messages11;
|
|
1421
1435
|
|
|
1422
1436
|
// src/i18n/messages/pt-br/input-select.ts
|
|
1423
|
-
var
|
|
1437
|
+
var messages12 = {
|
|
1424
1438
|
noOptions: "Nenhuma op\xE7\xE3o dispon\xEDvel"
|
|
1425
1439
|
};
|
|
1426
|
-
var input_select_default3 =
|
|
1440
|
+
var input_select_default3 = messages12;
|
|
1427
1441
|
|
|
1428
1442
|
// src/i18n/messages/pt-br/input-phone.ts
|
|
1429
|
-
var
|
|
1443
|
+
var messages13 = {
|
|
1430
1444
|
countries: {
|
|
1431
1445
|
empty: "Selecione",
|
|
1432
1446
|
AF: "Afeganist\xE3o",
|
|
@@ -1676,20 +1690,27 @@ var messages11 = {
|
|
|
1676
1690
|
ZW: "Zimb\xE1bue"
|
|
1677
1691
|
}
|
|
1678
1692
|
};
|
|
1679
|
-
var input_phone_default3 =
|
|
1693
|
+
var input_phone_default3 = messages13;
|
|
1680
1694
|
|
|
1681
1695
|
// src/i18n/messages/pt-br/time-picker.ts
|
|
1682
|
-
var
|
|
1696
|
+
var messages14 = {
|
|
1683
1697
|
label: "Hor\xE1rio"
|
|
1684
1698
|
};
|
|
1685
|
-
var time_picker_default3 =
|
|
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;
|
|
1686
1706
|
|
|
1687
1707
|
// src/i18n/messages/pt-br/index.ts
|
|
1688
1708
|
var ptBrMessages = {
|
|
1689
1709
|
pagination: pagination_default3,
|
|
1690
1710
|
inputSelect: input_select_default3,
|
|
1691
1711
|
inputPhone: input_phone_default3,
|
|
1692
|
-
timePicker: time_picker_default3
|
|
1712
|
+
timePicker: time_picker_default3,
|
|
1713
|
+
fileUpload: file_upload_default3
|
|
1693
1714
|
};
|
|
1694
1715
|
|
|
1695
1716
|
// src/i18n/message-storage-handler.ts
|
|
@@ -1714,7 +1735,7 @@ var setNebulaLanguage = (language) => {
|
|
|
1714
1735
|
}
|
|
1715
1736
|
localStorage.setItem(getNebulaI18nStorageKey(), language);
|
|
1716
1737
|
};
|
|
1717
|
-
var
|
|
1738
|
+
var messages16 = /* @__PURE__ */ new Map([
|
|
1718
1739
|
[null, enMessages],
|
|
1719
1740
|
[void 0, enMessages],
|
|
1720
1741
|
["en-US", enMessages],
|
|
@@ -1732,14 +1753,14 @@ var NebulaI18nProvider = ({
|
|
|
1732
1753
|
() => customI18nStorageKey ?? localStorageKey,
|
|
1733
1754
|
[customI18nStorageKey]
|
|
1734
1755
|
);
|
|
1735
|
-
const [
|
|
1736
|
-
|
|
1756
|
+
const [messages17, setMessages] = useState(
|
|
1757
|
+
messages16.get(getNebulaLanguage()) ?? messages16.get("en-US")
|
|
1737
1758
|
);
|
|
1738
1759
|
const handleStorageChange = useCallback(
|
|
1739
1760
|
({ detail }) => {
|
|
1740
1761
|
if (detail.key === storageKey) {
|
|
1741
1762
|
setMessages(
|
|
1742
|
-
|
|
1763
|
+
messages16.get(detail.value) ?? messages16.get("en-US")
|
|
1743
1764
|
);
|
|
1744
1765
|
}
|
|
1745
1766
|
},
|
|
@@ -1783,7 +1804,7 @@ var NebulaI18nProvider = ({
|
|
|
1783
1804
|
NebulaI18nContext.Provider,
|
|
1784
1805
|
{
|
|
1785
1806
|
value: {
|
|
1786
|
-
messages:
|
|
1807
|
+
messages: messages17,
|
|
1787
1808
|
locale: getNebulaLanguage()
|
|
1788
1809
|
},
|
|
1789
1810
|
children
|
|
@@ -1805,7 +1826,7 @@ var Pagination = ({
|
|
|
1805
1826
|
onChangePage,
|
|
1806
1827
|
...props
|
|
1807
1828
|
}) => {
|
|
1808
|
-
const { messages:
|
|
1829
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
1809
1830
|
const totalPages = useMemo(() => {
|
|
1810
1831
|
return Math.ceil(total / (pageSize || 1));
|
|
1811
1832
|
}, [total, pageSize]);
|
|
@@ -1838,13 +1859,13 @@ var Pagination = ({
|
|
|
1838
1859
|
}, [totalPages, pageSize, total]);
|
|
1839
1860
|
const totalResultsLabel = useMemo(() => {
|
|
1840
1861
|
if (page === totalPages) {
|
|
1841
|
-
return
|
|
1862
|
+
return messages17.pagination.totalResultsLabel(lastPageSize, total);
|
|
1842
1863
|
}
|
|
1843
|
-
return
|
|
1844
|
-
}, [
|
|
1864
|
+
return messages17.pagination.totalResultsLabel(pageSize, total);
|
|
1865
|
+
}, [messages17.pagination, pageSize, total, page, totalPages, lastPageSize]);
|
|
1845
1866
|
const currentPageLabel = useMemo(
|
|
1846
|
-
() =>
|
|
1847
|
-
[
|
|
1867
|
+
() => messages17.pagination.currentPageLabel(normalizedPage, totalPages),
|
|
1868
|
+
[messages17.pagination, normalizedPage, totalPages]
|
|
1848
1869
|
);
|
|
1849
1870
|
return /* @__PURE__ */ jsxs(
|
|
1850
1871
|
"nav",
|
|
@@ -2117,7 +2138,7 @@ var createStyledSelect = (BaseSelect, displayName) => {
|
|
|
2117
2138
|
isError = false,
|
|
2118
2139
|
...props
|
|
2119
2140
|
}) => {
|
|
2120
|
-
const { messages:
|
|
2141
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
2121
2142
|
const customClassNames = useMemo(() => {
|
|
2122
2143
|
return {
|
|
2123
2144
|
control: (props2) => controlStyles(props2, isError),
|
|
@@ -2164,7 +2185,7 @@ var createStyledSelect = (BaseSelect, displayName) => {
|
|
|
2164
2185
|
isDisabled: disabled,
|
|
2165
2186
|
components: customComponents,
|
|
2166
2187
|
classNames: customClassNames,
|
|
2167
|
-
noOptionsMessage: () => /* @__PURE__ */ jsx("p", { children:
|
|
2188
|
+
noOptionsMessage: () => /* @__PURE__ */ jsx("p", { children: messages17.inputSelect.noOptions }),
|
|
2168
2189
|
...props
|
|
2169
2190
|
}
|
|
2170
2191
|
);
|
|
@@ -3167,13 +3188,13 @@ function custom(message, options) {
|
|
|
3167
3188
|
}
|
|
3168
3189
|
);
|
|
3169
3190
|
}
|
|
3170
|
-
async function promise(promise2,
|
|
3191
|
+
async function promise(promise2, messages17, options) {
|
|
3171
3192
|
const loadingToast = toast$1.custom(
|
|
3172
3193
|
(t) => /* @__PURE__ */ jsx(
|
|
3173
3194
|
ToastComponent,
|
|
3174
3195
|
{
|
|
3175
3196
|
type: "info",
|
|
3176
|
-
message:
|
|
3197
|
+
message: messages17.loading,
|
|
3177
3198
|
options,
|
|
3178
3199
|
t
|
|
3179
3200
|
}
|
|
@@ -3187,7 +3208,7 @@ async function promise(promise2, messages14, options) {
|
|
|
3187
3208
|
ToastComponent,
|
|
3188
3209
|
{
|
|
3189
3210
|
type: "success",
|
|
3190
|
-
message:
|
|
3211
|
+
message: messages17.success,
|
|
3191
3212
|
options,
|
|
3192
3213
|
t
|
|
3193
3214
|
}
|
|
@@ -3202,7 +3223,7 @@ async function promise(promise2, messages14, options) {
|
|
|
3202
3223
|
ToastComponent,
|
|
3203
3224
|
{
|
|
3204
3225
|
type: "error",
|
|
3205
|
-
message:
|
|
3226
|
+
message: messages17.error,
|
|
3206
3227
|
options,
|
|
3207
3228
|
t
|
|
3208
3229
|
}
|
|
@@ -3372,8 +3393,8 @@ var CountrySelect = ({
|
|
|
3372
3393
|
const handleSelect = (event) => {
|
|
3373
3394
|
onChange(event.target.value);
|
|
3374
3395
|
};
|
|
3375
|
-
const { messages:
|
|
3376
|
-
const { countries } =
|
|
3396
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
3397
|
+
const { countries } = messages17.inputPhone;
|
|
3377
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: [
|
|
3378
3399
|
/* @__PURE__ */ jsxs("div", { className: "nebula-ds inline-flex items-center gap-1", "aria-hidden": "true", children: [
|
|
3379
3400
|
/* @__PURE__ */ jsx(FlagComponent, { country: value, countryName: value, "aria-hidden": "true" }),
|
|
@@ -3585,6 +3606,7 @@ var Calendar = ({
|
|
|
3585
3606
|
outside,
|
|
3586
3607
|
today,
|
|
3587
3608
|
selected,
|
|
3609
|
+
disabled,
|
|
3588
3610
|
range_middle: rangeMiddle,
|
|
3589
3611
|
range_end: rangeEnd,
|
|
3590
3612
|
range_start: rangeStart
|
|
@@ -3594,11 +3616,16 @@ var Calendar = ({
|
|
|
3594
3616
|
{
|
|
3595
3617
|
...props2,
|
|
3596
3618
|
tabIndex: 0,
|
|
3597
|
-
className: cn(
|
|
3598
|
-
|
|
3599
|
-
"!
|
|
3600
|
-
|
|
3601
|
-
|
|
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
|
+
),
|
|
3602
3629
|
children: /* @__PURE__ */ jsxs(
|
|
3603
3630
|
"div",
|
|
3604
3631
|
{
|
|
@@ -3624,7 +3651,7 @@ var Calendar = ({
|
|
|
3624
3651
|
MonthCaption({ calendarMonth, displayIndex, ...rest }) {
|
|
3625
3652
|
const handleNextMonth = () => {
|
|
3626
3653
|
const newMonth = addMonths(
|
|
3627
|
-
|
|
3654
|
+
currentMonth,
|
|
3628
3655
|
props.pagedNavigation || numberOfMonths === 1 ? 1 : 0
|
|
3629
3656
|
);
|
|
3630
3657
|
if (typeof month !== "undefined") {
|
|
@@ -3635,7 +3662,7 @@ var Calendar = ({
|
|
|
3635
3662
|
};
|
|
3636
3663
|
const handlePreviousMonth = () => {
|
|
3637
3664
|
const newMonth = addMonths(
|
|
3638
|
-
|
|
3665
|
+
currentMonth,
|
|
3639
3666
|
props.pagedNavigation ? -2 : -1
|
|
3640
3667
|
);
|
|
3641
3668
|
if (typeof month !== "undefined") {
|
|
@@ -3650,8 +3677,9 @@ var Calendar = ({
|
|
|
3650
3677
|
return /* @__PURE__ */ jsxs(
|
|
3651
3678
|
"div",
|
|
3652
3679
|
{
|
|
3653
|
-
className: cn("flex justify-between items-center !h-9", {
|
|
3654
|
-
"ps-3": numberOfMonths === 1
|
|
3680
|
+
className: cn("flex justify-between items-center !h-9 mb-3", {
|
|
3681
|
+
"ps-3": numberOfMonths === 1,
|
|
3682
|
+
"mb-0": showMonthGridSelection
|
|
3655
3683
|
}),
|
|
3656
3684
|
children: [
|
|
3657
3685
|
!hideNavigation && numberOfMonths > 1 && /* @__PURE__ */ jsx(
|
|
@@ -3834,7 +3862,7 @@ var Calendar = ({
|
|
|
3834
3862
|
mode: "single",
|
|
3835
3863
|
animate: false,
|
|
3836
3864
|
...props,
|
|
3837
|
-
month:
|
|
3865
|
+
month: currentMonth,
|
|
3838
3866
|
hideNavigation: true,
|
|
3839
3867
|
numberOfMonths: Math.min(Math.max(numberOfMonths, 1), 2),
|
|
3840
3868
|
components: components2,
|
|
@@ -3857,6 +3885,52 @@ function timeFormatIsValid(timeStr) {
|
|
|
3857
3885
|
const regex = /^(?:[01]\d|2[0-3]):[0-5]\d$/;
|
|
3858
3886
|
return regex.test(timeStr);
|
|
3859
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
|
+
};
|
|
3860
3934
|
var InputDatePickerSingle = ({
|
|
3861
3935
|
portal,
|
|
3862
3936
|
placeholder,
|
|
@@ -3865,6 +3939,7 @@ var InputDatePickerSingle = ({
|
|
|
3865
3939
|
onChange,
|
|
3866
3940
|
numberOfMonths = 1,
|
|
3867
3941
|
onClean,
|
|
3942
|
+
disabledDates,
|
|
3868
3943
|
...rest
|
|
3869
3944
|
}) => {
|
|
3870
3945
|
const [popoverIsOpen, setPopoverIsOpen] = useState(false);
|
|
@@ -3879,8 +3954,8 @@ var InputDatePickerSingle = ({
|
|
|
3879
3954
|
};
|
|
3880
3955
|
const handleInnerInputChange = (text) => {
|
|
3881
3956
|
const dateSlice = text.substring(0, 10).trim();
|
|
3882
|
-
onChange?.(text);
|
|
3883
3957
|
if (!text) {
|
|
3958
|
+
onChange?.(text);
|
|
3884
3959
|
handleClearValue();
|
|
3885
3960
|
return;
|
|
3886
3961
|
}
|
|
@@ -3889,15 +3964,13 @@ var InputDatePickerSingle = ({
|
|
|
3889
3964
|
locale === "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
3890
3965
|
dateSlice.substring(6)
|
|
3891
3966
|
];
|
|
3892
|
-
if ([day, month2, year].some((value2) => !value2) || !dateFormatIsValid(dateSlice, locale)) {
|
|
3893
|
-
handleClearValue();
|
|
3894
|
-
return;
|
|
3895
|
-
}
|
|
3896
3967
|
const date = new Date(Number(year), Number(month2) - 1, Number(day));
|
|
3897
|
-
if (!isValid(new Date(date))) {
|
|
3968
|
+
if ([day, month2, year].some((value2) => !value2) || !dateFormatIsValid(dateSlice, locale) || !isValid(new Date(date)) || !dateIsAvailable(date, disabledDates)) {
|
|
3969
|
+
onChange?.(text);
|
|
3898
3970
|
handleClearValue();
|
|
3899
3971
|
return;
|
|
3900
3972
|
}
|
|
3973
|
+
onChange?.(text, date);
|
|
3901
3974
|
setInnerDate(date);
|
|
3902
3975
|
};
|
|
3903
3976
|
const handleKeyDown = (e) => {
|
|
@@ -3923,7 +3996,7 @@ var InputDatePickerSingle = ({
|
|
|
3923
3996
|
day: "2-digit"
|
|
3924
3997
|
}).format(date);
|
|
3925
3998
|
setInnerDate(date);
|
|
3926
|
-
onChange?.(dateToStr);
|
|
3999
|
+
onChange?.(dateToStr, date);
|
|
3927
4000
|
};
|
|
3928
4001
|
const normalizedCalendarDate = useMemo(() => {
|
|
3929
4002
|
return isValid(innerDate) ? innerDate : void 0;
|
|
@@ -3992,7 +4065,8 @@ var InputDatePickerSingle = ({
|
|
|
3992
4065
|
onSelect: handleCalendarSelect,
|
|
3993
4066
|
month,
|
|
3994
4067
|
onPrevClick: setMonth,
|
|
3995
|
-
onNextClick: setMonth
|
|
4068
|
+
onNextClick: setMonth,
|
|
4069
|
+
disabled: disabledDates
|
|
3996
4070
|
}
|
|
3997
4071
|
)
|
|
3998
4072
|
}
|
|
@@ -4073,6 +4147,7 @@ var InputDateTimePickerSingle = ({
|
|
|
4073
4147
|
onChange,
|
|
4074
4148
|
numberOfMonths = 1,
|
|
4075
4149
|
onClean,
|
|
4150
|
+
disabledDates,
|
|
4076
4151
|
...rest
|
|
4077
4152
|
}) => {
|
|
4078
4153
|
const [popoverIsOpen, setPopoverIsOpen] = useState(false);
|
|
@@ -4080,7 +4155,7 @@ var InputDateTimePickerSingle = ({
|
|
|
4080
4155
|
const [innerDate, setInnerDate] = useState(
|
|
4081
4156
|
value ? new Date(value) : void 0
|
|
4082
4157
|
);
|
|
4083
|
-
const { locale, messages:
|
|
4158
|
+
const { locale, messages: messages17 } = useNebulaI18n();
|
|
4084
4159
|
const [month, setMonth] = useState(/* @__PURE__ */ new Date());
|
|
4085
4160
|
const inputTimeRef = useRef(null);
|
|
4086
4161
|
const handleClearValue = () => {
|
|
@@ -4090,9 +4165,9 @@ var InputDateTimePickerSingle = ({
|
|
|
4090
4165
|
};
|
|
4091
4166
|
const handleInnerInputChange = (text) => {
|
|
4092
4167
|
const dateSlice = text.substring(0, 11).trim();
|
|
4093
|
-
|
|
4094
|
-
onChange?.(text);
|
|
4168
|
+
let hourSlice = text.substring(11).trim();
|
|
4095
4169
|
if (!text) {
|
|
4170
|
+
onChange?.(text);
|
|
4096
4171
|
handleClearValue();
|
|
4097
4172
|
return;
|
|
4098
4173
|
}
|
|
@@ -4101,20 +4176,19 @@ var InputDateTimePickerSingle = ({
|
|
|
4101
4176
|
locale === "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
4102
4177
|
dateSlice.substring(6)
|
|
4103
4178
|
];
|
|
4104
|
-
|
|
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);
|
|
4105
4182
|
handleClearValue();
|
|
4106
4183
|
return;
|
|
4107
4184
|
}
|
|
4108
4185
|
if (!timeFormatIsValid(hourSlice)) {
|
|
4186
|
+
hourSlice = "";
|
|
4109
4187
|
setInnerTimeValue("");
|
|
4110
4188
|
} else {
|
|
4111
4189
|
setInnerTimeValue(hourSlice);
|
|
4112
4190
|
}
|
|
4113
|
-
|
|
4114
|
-
if (!isValid(new Date(date))) {
|
|
4115
|
-
handleClearValue();
|
|
4116
|
-
return;
|
|
4117
|
-
}
|
|
4191
|
+
onChange?.(text, date, hourSlice);
|
|
4118
4192
|
setInnerDate(date);
|
|
4119
4193
|
};
|
|
4120
4194
|
const handleOnChangeTime = (newTime) => {
|
|
@@ -4123,7 +4197,7 @@ var InputDateTimePickerSingle = ({
|
|
|
4123
4197
|
if (date && !dateFormatIsValid(date, locale)) {
|
|
4124
4198
|
handleClearValue();
|
|
4125
4199
|
}
|
|
4126
|
-
onChange?.(date + " " + newTime);
|
|
4200
|
+
onChange?.(date + " " + newTime, innerDate, newTime);
|
|
4127
4201
|
};
|
|
4128
4202
|
const handleKeyDown = (e) => {
|
|
4129
4203
|
if ((e.altKey || e.ctrlKey || e.metaKey) && e.key !== "z") return;
|
|
@@ -4150,7 +4224,11 @@ var InputDateTimePickerSingle = ({
|
|
|
4150
4224
|
day: "2-digit"
|
|
4151
4225
|
}).format(date);
|
|
4152
4226
|
setInnerDate(date);
|
|
4153
|
-
onChange?.(
|
|
4227
|
+
onChange?.(
|
|
4228
|
+
[dateToStr, innerTimeValue].filter(Boolean).join(" "),
|
|
4229
|
+
date,
|
|
4230
|
+
innerTimeValue
|
|
4231
|
+
);
|
|
4154
4232
|
if (!innerTimeValue) {
|
|
4155
4233
|
setTimeout(() => inputTimeRef.current?.focus(), 100);
|
|
4156
4234
|
}
|
|
@@ -4223,9 +4301,10 @@ var InputDateTimePickerSingle = ({
|
|
|
4223
4301
|
month,
|
|
4224
4302
|
onPrevClick: setMonth,
|
|
4225
4303
|
onNextClick: setMonth,
|
|
4304
|
+
disabled: disabledDates,
|
|
4226
4305
|
footer: /* @__PURE__ */ jsxs(Space, { className: "nebula-ds items-center", children: [
|
|
4227
4306
|
/* @__PURE__ */ jsxs(Label, { children: [
|
|
4228
|
-
|
|
4307
|
+
messages17.timePicker.label,
|
|
4229
4308
|
":"
|
|
4230
4309
|
] }),
|
|
4231
4310
|
/* @__PURE__ */ jsx(
|
|
@@ -4234,7 +4313,8 @@ var InputDateTimePickerSingle = ({
|
|
|
4234
4313
|
placeholder: "00:00",
|
|
4235
4314
|
value: innerTimeValue,
|
|
4236
4315
|
onChange: handleOnChangeTime,
|
|
4237
|
-
ref: inputTimeRef
|
|
4316
|
+
ref: inputTimeRef,
|
|
4317
|
+
className: "nebula-ds max-w-[188px]"
|
|
4238
4318
|
}
|
|
4239
4319
|
)
|
|
4240
4320
|
] })
|
|
@@ -4244,6 +4324,521 @@ var InputDateTimePickerSingle = ({
|
|
|
4244
4324
|
)
|
|
4245
4325
|
] });
|
|
4246
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 w-full", 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";
|
|
4247
4842
|
|
|
4248
4843
|
// src/tailwind.ts
|
|
4249
4844
|
function content({ base = "./" } = {}) {
|
|
@@ -4255,4 +4850,4 @@ var tailwind = {
|
|
|
4255
4850
|
// plugin: () => require("tailwindcss")("node_modules/@nebulareact/dist/tailwind.config.js"),
|
|
4256
4851
|
};
|
|
4257
4852
|
|
|
4258
|
-
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, 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, Toaster, Tooltip, alertVariants, badgeSizeEnum, badgeVariantEnum, buttonSizeEnum, buttonVariantEnum, buttonVariantsConfig, getNebulaLanguage, localeByi18nKey,
|
|
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 };
|