@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.js
CHANGED
|
@@ -1150,16 +1150,23 @@ var messages4 = {
|
|
|
1150
1150
|
};
|
|
1151
1151
|
var time_picker_default = messages4;
|
|
1152
1152
|
|
|
1153
|
+
// src/i18n/messages/en/file-upload.ts
|
|
1154
|
+
var messages5 = {
|
|
1155
|
+
deleteAll: "Remove all"
|
|
1156
|
+
};
|
|
1157
|
+
var file_upload_default = messages5;
|
|
1158
|
+
|
|
1153
1159
|
// src/i18n/messages/en/index.ts
|
|
1154
1160
|
var enMessages = {
|
|
1155
1161
|
pagination: pagination_default,
|
|
1156
1162
|
inputSelect: input_select_default,
|
|
1157
1163
|
inputPhone: input_phone_default,
|
|
1158
|
-
timePicker: time_picker_default
|
|
1164
|
+
timePicker: time_picker_default,
|
|
1165
|
+
fileUpload: file_upload_default
|
|
1159
1166
|
};
|
|
1160
1167
|
|
|
1161
1168
|
// src/i18n/messages/es/pagination.ts
|
|
1162
|
-
var
|
|
1169
|
+
var messages6 = {
|
|
1163
1170
|
totalResultsLabel(pagesSize, totalResults) {
|
|
1164
1171
|
if (totalResults < pagesSize) {
|
|
1165
1172
|
pagesSize = totalResults;
|
|
@@ -1170,16 +1177,16 @@ var messages5 = {
|
|
|
1170
1177
|
return `P\xE1gina ${currentPage} de ${totalPages}`;
|
|
1171
1178
|
}
|
|
1172
1179
|
};
|
|
1173
|
-
var pagination_default2 =
|
|
1180
|
+
var pagination_default2 = messages6;
|
|
1174
1181
|
|
|
1175
1182
|
// src/i18n/messages/es/input-select.ts
|
|
1176
|
-
var
|
|
1183
|
+
var messages7 = {
|
|
1177
1184
|
noOptions: "No hay opciones disponibles"
|
|
1178
1185
|
};
|
|
1179
|
-
var input_select_default2 =
|
|
1186
|
+
var input_select_default2 = messages7;
|
|
1180
1187
|
|
|
1181
1188
|
// src/i18n/messages/es/input-phone.ts
|
|
1182
|
-
var
|
|
1189
|
+
var messages8 = {
|
|
1183
1190
|
countries: {
|
|
1184
1191
|
empty: "Seleccionar",
|
|
1185
1192
|
AF: "Afganist\xE1n",
|
|
@@ -1429,24 +1436,31 @@ var messages7 = {
|
|
|
1429
1436
|
ZW: "Zimbabue"
|
|
1430
1437
|
}
|
|
1431
1438
|
};
|
|
1432
|
-
var input_phone_default2 =
|
|
1439
|
+
var input_phone_default2 = messages8;
|
|
1433
1440
|
|
|
1434
1441
|
// src/i18n/messages/es/time-picker.ts
|
|
1435
|
-
var
|
|
1442
|
+
var messages9 = {
|
|
1436
1443
|
label: "Tiempo"
|
|
1437
1444
|
};
|
|
1438
|
-
var time_picker_default2 =
|
|
1445
|
+
var time_picker_default2 = messages9;
|
|
1446
|
+
|
|
1447
|
+
// src/i18n/messages/es/file-upload.ts
|
|
1448
|
+
var messages10 = {
|
|
1449
|
+
deleteAll: "Remover todos"
|
|
1450
|
+
};
|
|
1451
|
+
var file_upload_default2 = messages10;
|
|
1439
1452
|
|
|
1440
1453
|
// src/i18n/messages/es/index.ts
|
|
1441
1454
|
var esMessages = {
|
|
1442
1455
|
pagination: pagination_default2,
|
|
1443
1456
|
inputSelect: input_select_default2,
|
|
1444
1457
|
inputPhone: input_phone_default2,
|
|
1445
|
-
timePicker: time_picker_default2
|
|
1458
|
+
timePicker: time_picker_default2,
|
|
1459
|
+
fileUpload: file_upload_default2
|
|
1446
1460
|
};
|
|
1447
1461
|
|
|
1448
1462
|
// src/i18n/messages/pt-br/pagination.ts
|
|
1449
|
-
var
|
|
1463
|
+
var messages11 = {
|
|
1450
1464
|
totalResultsLabel(pagesSize, totalResults) {
|
|
1451
1465
|
if (totalResults < pagesSize) {
|
|
1452
1466
|
pagesSize = totalResults;
|
|
@@ -1457,16 +1471,16 @@ var messages9 = {
|
|
|
1457
1471
|
return `P\xE1gina ${currentPage} de ${totalPages}`;
|
|
1458
1472
|
}
|
|
1459
1473
|
};
|
|
1460
|
-
var pagination_default3 =
|
|
1474
|
+
var pagination_default3 = messages11;
|
|
1461
1475
|
|
|
1462
1476
|
// src/i18n/messages/pt-br/input-select.ts
|
|
1463
|
-
var
|
|
1477
|
+
var messages12 = {
|
|
1464
1478
|
noOptions: "Nenhuma op\xE7\xE3o dispon\xEDvel"
|
|
1465
1479
|
};
|
|
1466
|
-
var input_select_default3 =
|
|
1480
|
+
var input_select_default3 = messages12;
|
|
1467
1481
|
|
|
1468
1482
|
// src/i18n/messages/pt-br/input-phone.ts
|
|
1469
|
-
var
|
|
1483
|
+
var messages13 = {
|
|
1470
1484
|
countries: {
|
|
1471
1485
|
empty: "Selecione",
|
|
1472
1486
|
AF: "Afeganist\xE3o",
|
|
@@ -1716,20 +1730,27 @@ var messages11 = {
|
|
|
1716
1730
|
ZW: "Zimb\xE1bue"
|
|
1717
1731
|
}
|
|
1718
1732
|
};
|
|
1719
|
-
var input_phone_default3 =
|
|
1733
|
+
var input_phone_default3 = messages13;
|
|
1720
1734
|
|
|
1721
1735
|
// src/i18n/messages/pt-br/time-picker.ts
|
|
1722
|
-
var
|
|
1736
|
+
var messages14 = {
|
|
1723
1737
|
label: "Hor\xE1rio"
|
|
1724
1738
|
};
|
|
1725
|
-
var time_picker_default3 =
|
|
1739
|
+
var time_picker_default3 = messages14;
|
|
1740
|
+
|
|
1741
|
+
// src/i18n/messages/pt-br/file-upload.ts
|
|
1742
|
+
var messages15 = {
|
|
1743
|
+
deleteAll: "Remover todos"
|
|
1744
|
+
};
|
|
1745
|
+
var file_upload_default3 = messages15;
|
|
1726
1746
|
|
|
1727
1747
|
// src/i18n/messages/pt-br/index.ts
|
|
1728
1748
|
var ptBrMessages = {
|
|
1729
1749
|
pagination: pagination_default3,
|
|
1730
1750
|
inputSelect: input_select_default3,
|
|
1731
1751
|
inputPhone: input_phone_default3,
|
|
1732
|
-
timePicker: time_picker_default3
|
|
1752
|
+
timePicker: time_picker_default3,
|
|
1753
|
+
fileUpload: file_upload_default3
|
|
1733
1754
|
};
|
|
1734
1755
|
|
|
1735
1756
|
// src/i18n/message-storage-handler.ts
|
|
@@ -1754,7 +1775,7 @@ var setNebulaLanguage = (language) => {
|
|
|
1754
1775
|
}
|
|
1755
1776
|
localStorage.setItem(getNebulaI18nStorageKey(), language);
|
|
1756
1777
|
};
|
|
1757
|
-
var
|
|
1778
|
+
var messages16 = /* @__PURE__ */ new Map([
|
|
1758
1779
|
[null, enMessages],
|
|
1759
1780
|
[void 0, enMessages],
|
|
1760
1781
|
["en-US", enMessages],
|
|
@@ -1772,14 +1793,14 @@ var NebulaI18nProvider = ({
|
|
|
1772
1793
|
() => customI18nStorageKey ?? localStorageKey,
|
|
1773
1794
|
[customI18nStorageKey]
|
|
1774
1795
|
);
|
|
1775
|
-
const [
|
|
1776
|
-
|
|
1796
|
+
const [messages17, setMessages] = React8.useState(
|
|
1797
|
+
messages16.get(getNebulaLanguage()) ?? messages16.get("en-US")
|
|
1777
1798
|
);
|
|
1778
1799
|
const handleStorageChange = React8.useCallback(
|
|
1779
1800
|
({ detail }) => {
|
|
1780
1801
|
if (detail.key === storageKey) {
|
|
1781
1802
|
setMessages(
|
|
1782
|
-
|
|
1803
|
+
messages16.get(detail.value) ?? messages16.get("en-US")
|
|
1783
1804
|
);
|
|
1784
1805
|
}
|
|
1785
1806
|
},
|
|
@@ -1823,7 +1844,7 @@ var NebulaI18nProvider = ({
|
|
|
1823
1844
|
NebulaI18nContext.Provider,
|
|
1824
1845
|
{
|
|
1825
1846
|
value: {
|
|
1826
|
-
messages:
|
|
1847
|
+
messages: messages17,
|
|
1827
1848
|
locale: getNebulaLanguage()
|
|
1828
1849
|
},
|
|
1829
1850
|
children
|
|
@@ -1845,7 +1866,7 @@ var Pagination = ({
|
|
|
1845
1866
|
onChangePage,
|
|
1846
1867
|
...props
|
|
1847
1868
|
}) => {
|
|
1848
|
-
const { messages:
|
|
1869
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
1849
1870
|
const totalPages = React8.useMemo(() => {
|
|
1850
1871
|
return Math.ceil(total / (pageSize || 1));
|
|
1851
1872
|
}, [total, pageSize]);
|
|
@@ -1878,13 +1899,13 @@ var Pagination = ({
|
|
|
1878
1899
|
}, [totalPages, pageSize, total]);
|
|
1879
1900
|
const totalResultsLabel = React8.useMemo(() => {
|
|
1880
1901
|
if (page === totalPages) {
|
|
1881
|
-
return
|
|
1902
|
+
return messages17.pagination.totalResultsLabel(lastPageSize, total);
|
|
1882
1903
|
}
|
|
1883
|
-
return
|
|
1884
|
-
}, [
|
|
1904
|
+
return messages17.pagination.totalResultsLabel(pageSize, total);
|
|
1905
|
+
}, [messages17.pagination, pageSize, total, page, totalPages, lastPageSize]);
|
|
1885
1906
|
const currentPageLabel = React8.useMemo(
|
|
1886
|
-
() =>
|
|
1887
|
-
[
|
|
1907
|
+
() => messages17.pagination.currentPageLabel(normalizedPage, totalPages),
|
|
1908
|
+
[messages17.pagination, normalizedPage, totalPages]
|
|
1888
1909
|
);
|
|
1889
1910
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1890
1911
|
"nav",
|
|
@@ -2157,7 +2178,7 @@ var createStyledSelect = (BaseSelect, displayName) => {
|
|
|
2157
2178
|
isError = false,
|
|
2158
2179
|
...props
|
|
2159
2180
|
}) => {
|
|
2160
|
-
const { messages:
|
|
2181
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
2161
2182
|
const customClassNames = React8.useMemo(() => {
|
|
2162
2183
|
return {
|
|
2163
2184
|
control: (props2) => controlStyles(props2, isError),
|
|
@@ -2204,7 +2225,7 @@ var createStyledSelect = (BaseSelect, displayName) => {
|
|
|
2204
2225
|
isDisabled: disabled,
|
|
2205
2226
|
components: customComponents,
|
|
2206
2227
|
classNames: customClassNames,
|
|
2207
|
-
noOptionsMessage: () => /* @__PURE__ */ jsxRuntime.jsx("p", { children:
|
|
2228
|
+
noOptionsMessage: () => /* @__PURE__ */ jsxRuntime.jsx("p", { children: messages17.inputSelect.noOptions }),
|
|
2208
2229
|
...props
|
|
2209
2230
|
}
|
|
2210
2231
|
);
|
|
@@ -3207,13 +3228,13 @@ function custom(message, options) {
|
|
|
3207
3228
|
}
|
|
3208
3229
|
);
|
|
3209
3230
|
}
|
|
3210
|
-
async function promise(promise2,
|
|
3231
|
+
async function promise(promise2, messages17, options) {
|
|
3211
3232
|
const loadingToast = sonner.toast.custom(
|
|
3212
3233
|
(t) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3213
3234
|
ToastComponent,
|
|
3214
3235
|
{
|
|
3215
3236
|
type: "info",
|
|
3216
|
-
message:
|
|
3237
|
+
message: messages17.loading,
|
|
3217
3238
|
options,
|
|
3218
3239
|
t
|
|
3219
3240
|
}
|
|
@@ -3227,7 +3248,7 @@ async function promise(promise2, messages14, options) {
|
|
|
3227
3248
|
ToastComponent,
|
|
3228
3249
|
{
|
|
3229
3250
|
type: "success",
|
|
3230
|
-
message:
|
|
3251
|
+
message: messages17.success,
|
|
3231
3252
|
options,
|
|
3232
3253
|
t
|
|
3233
3254
|
}
|
|
@@ -3242,7 +3263,7 @@ async function promise(promise2, messages14, options) {
|
|
|
3242
3263
|
ToastComponent,
|
|
3243
3264
|
{
|
|
3244
3265
|
type: "error",
|
|
3245
|
-
message:
|
|
3266
|
+
message: messages17.error,
|
|
3246
3267
|
options,
|
|
3247
3268
|
t
|
|
3248
3269
|
}
|
|
@@ -3412,8 +3433,8 @@ var CountrySelect = ({
|
|
|
3412
3433
|
const handleSelect = (event) => {
|
|
3413
3434
|
onChange(event.target.value);
|
|
3414
3435
|
};
|
|
3415
|
-
const { messages:
|
|
3416
|
-
const { countries } =
|
|
3436
|
+
const { messages: messages17 } = useNebulaI18n();
|
|
3437
|
+
const { countries } = messages17.inputPhone;
|
|
3417
3438
|
return /* @__PURE__ */ jsxRuntime.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: [
|
|
3418
3439
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds inline-flex items-center gap-1", "aria-hidden": "true", children: [
|
|
3419
3440
|
/* @__PURE__ */ jsxRuntime.jsx(FlagComponent, { country: value, countryName: value, "aria-hidden": "true" }),
|
|
@@ -3625,6 +3646,7 @@ var Calendar = ({
|
|
|
3625
3646
|
outside,
|
|
3626
3647
|
today,
|
|
3627
3648
|
selected,
|
|
3649
|
+
disabled,
|
|
3628
3650
|
range_middle: rangeMiddle,
|
|
3629
3651
|
range_end: rangeEnd,
|
|
3630
3652
|
range_start: rangeStart
|
|
@@ -3634,11 +3656,16 @@ var Calendar = ({
|
|
|
3634
3656
|
{
|
|
3635
3657
|
...props2,
|
|
3636
3658
|
tabIndex: 0,
|
|
3637
|
-
className: cn(
|
|
3638
|
-
|
|
3639
|
-
"!
|
|
3640
|
-
|
|
3641
|
-
|
|
3659
|
+
className: cn(
|
|
3660
|
+
props2.className,
|
|
3661
|
+
"!w-9 !h-9 hover:bg-button-ghost-background-hover hover:rounded-full",
|
|
3662
|
+
{
|
|
3663
|
+
"!text-calendar-day-color": !outside,
|
|
3664
|
+
"!text-calendar-outsideDay-color !opacity-1": outside,
|
|
3665
|
+
"!bg-calendar-daySelected-background !border-calendar-daySelected-background !text-calendar-daySelected-color rounded-full": (selected || rangeEnd || rangeStart) && !rangeMiddle,
|
|
3666
|
+
"!text-neutral-200 dark:!text-neutral-900 pointer-events-none cursor-not-allowed": disabled
|
|
3667
|
+
}
|
|
3668
|
+
),
|
|
3642
3669
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3643
3670
|
"div",
|
|
3644
3671
|
{
|
|
@@ -3664,7 +3691,7 @@ var Calendar = ({
|
|
|
3664
3691
|
MonthCaption({ calendarMonth, displayIndex, ...rest }) {
|
|
3665
3692
|
const handleNextMonth = () => {
|
|
3666
3693
|
const newMonth = dateFns.addMonths(
|
|
3667
|
-
|
|
3694
|
+
currentMonth,
|
|
3668
3695
|
props.pagedNavigation || numberOfMonths === 1 ? 1 : 0
|
|
3669
3696
|
);
|
|
3670
3697
|
if (typeof month !== "undefined") {
|
|
@@ -3675,7 +3702,7 @@ var Calendar = ({
|
|
|
3675
3702
|
};
|
|
3676
3703
|
const handlePreviousMonth = () => {
|
|
3677
3704
|
const newMonth = dateFns.addMonths(
|
|
3678
|
-
|
|
3705
|
+
currentMonth,
|
|
3679
3706
|
props.pagedNavigation ? -2 : -1
|
|
3680
3707
|
);
|
|
3681
3708
|
if (typeof month !== "undefined") {
|
|
@@ -3690,8 +3717,9 @@ var Calendar = ({
|
|
|
3690
3717
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3691
3718
|
"div",
|
|
3692
3719
|
{
|
|
3693
|
-
className: cn("flex justify-between items-center !h-9", {
|
|
3694
|
-
"ps-3": numberOfMonths === 1
|
|
3720
|
+
className: cn("flex justify-between items-center !h-9 mb-3", {
|
|
3721
|
+
"ps-3": numberOfMonths === 1,
|
|
3722
|
+
"mb-0": showMonthGridSelection
|
|
3695
3723
|
}),
|
|
3696
3724
|
children: [
|
|
3697
3725
|
!hideNavigation && numberOfMonths > 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3874,7 +3902,7 @@ var Calendar = ({
|
|
|
3874
3902
|
mode: "single",
|
|
3875
3903
|
animate: false,
|
|
3876
3904
|
...props,
|
|
3877
|
-
month:
|
|
3905
|
+
month: currentMonth,
|
|
3878
3906
|
hideNavigation: true,
|
|
3879
3907
|
numberOfMonths: Math.min(Math.max(numberOfMonths, 1), 2),
|
|
3880
3908
|
components: components2,
|
|
@@ -3897,6 +3925,52 @@ function timeFormatIsValid(timeStr) {
|
|
|
3897
3925
|
const regex = /^(?:[01]\d|2[0-3]):[0-5]\d$/;
|
|
3898
3926
|
return regex.test(timeStr);
|
|
3899
3927
|
}
|
|
3928
|
+
var dateIsAvailable = (inputDate, disabledDates) => {
|
|
3929
|
+
if (!disabledDates || !inputDate) return true;
|
|
3930
|
+
const dateIsDisabled = (d, matcher) => {
|
|
3931
|
+
if (Array.isArray(matcher)) {
|
|
3932
|
+
return matcher.some((date) => dateFns.isSameDay(date, d));
|
|
3933
|
+
}
|
|
3934
|
+
if (typeof matcher === "boolean") return matcher;
|
|
3935
|
+
if (typeof matcher === "function") {
|
|
3936
|
+
return matcher(d);
|
|
3937
|
+
}
|
|
3938
|
+
if ("from" in matcher) {
|
|
3939
|
+
const { from, to } = matcher;
|
|
3940
|
+
if (!from) return false;
|
|
3941
|
+
if (from && to) {
|
|
3942
|
+
return dateFns.isBefore(d, to) && dateFns.isAfter(d, from) || dateFns.isSameDay(d, from) || dateFns.isSameDay(d, to);
|
|
3943
|
+
}
|
|
3944
|
+
return dateFns.isSameDay(d, from);
|
|
3945
|
+
}
|
|
3946
|
+
if ("before" in matcher && !("after" in matcher)) {
|
|
3947
|
+
const { before } = matcher;
|
|
3948
|
+
return dateFns.isBefore(d, before) && !dateFns.isSameDay(d, before);
|
|
3949
|
+
}
|
|
3950
|
+
if ("after" in matcher && !("before" in matcher)) {
|
|
3951
|
+
const { after } = matcher;
|
|
3952
|
+
return dateFns.isAfter(d, after) && !dateFns.isSameDay(d, after);
|
|
3953
|
+
}
|
|
3954
|
+
if ("after" in matcher && "before" in matcher) {
|
|
3955
|
+
const { after, before } = matcher;
|
|
3956
|
+
return dateFns.isAfter(d, after) && !dateFns.isSameDay(d, after) || dateFns.isBefore(d, before) && !dateFns.isSameDay(d, before);
|
|
3957
|
+
}
|
|
3958
|
+
if ("dayOfWeek" in matcher) {
|
|
3959
|
+
const { dayOfWeek } = matcher;
|
|
3960
|
+
if (Array.isArray(dayOfWeek)) {
|
|
3961
|
+
return dayOfWeek.includes(d.getDay());
|
|
3962
|
+
}
|
|
3963
|
+
return dayOfWeek === d.getDay();
|
|
3964
|
+
}
|
|
3965
|
+
return dateFns.isSameDay(d, matcher);
|
|
3966
|
+
};
|
|
3967
|
+
if (Array.isArray(disabledDates)) {
|
|
3968
|
+
return disabledDates.every((matcher) => {
|
|
3969
|
+
return dateIsDisabled(inputDate, matcher) === false;
|
|
3970
|
+
});
|
|
3971
|
+
}
|
|
3972
|
+
return !dateIsDisabled(inputDate, disabledDates);
|
|
3973
|
+
};
|
|
3900
3974
|
var InputDatePickerSingle = ({
|
|
3901
3975
|
portal,
|
|
3902
3976
|
placeholder,
|
|
@@ -3905,6 +3979,7 @@ var InputDatePickerSingle = ({
|
|
|
3905
3979
|
onChange,
|
|
3906
3980
|
numberOfMonths = 1,
|
|
3907
3981
|
onClean,
|
|
3982
|
+
disabledDates,
|
|
3908
3983
|
...rest
|
|
3909
3984
|
}) => {
|
|
3910
3985
|
const [popoverIsOpen, setPopoverIsOpen] = React8.useState(false);
|
|
@@ -3919,8 +3994,8 @@ var InputDatePickerSingle = ({
|
|
|
3919
3994
|
};
|
|
3920
3995
|
const handleInnerInputChange = (text) => {
|
|
3921
3996
|
const dateSlice = text.substring(0, 10).trim();
|
|
3922
|
-
onChange?.(text);
|
|
3923
3997
|
if (!text) {
|
|
3998
|
+
onChange?.(text);
|
|
3924
3999
|
handleClearValue();
|
|
3925
4000
|
return;
|
|
3926
4001
|
}
|
|
@@ -3929,15 +4004,13 @@ var InputDatePickerSingle = ({
|
|
|
3929
4004
|
locale === "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
3930
4005
|
dateSlice.substring(6)
|
|
3931
4006
|
];
|
|
3932
|
-
if ([day, month2, year].some((value2) => !value2) || !dateFormatIsValid(dateSlice, locale)) {
|
|
3933
|
-
handleClearValue();
|
|
3934
|
-
return;
|
|
3935
|
-
}
|
|
3936
4007
|
const date = new Date(Number(year), Number(month2) - 1, Number(day));
|
|
3937
|
-
if (!dateFns.isValid(new Date(date))) {
|
|
4008
|
+
if ([day, month2, year].some((value2) => !value2) || !dateFormatIsValid(dateSlice, locale) || !dateFns.isValid(new Date(date)) || !dateIsAvailable(date, disabledDates)) {
|
|
4009
|
+
onChange?.(text);
|
|
3938
4010
|
handleClearValue();
|
|
3939
4011
|
return;
|
|
3940
4012
|
}
|
|
4013
|
+
onChange?.(text, date);
|
|
3941
4014
|
setInnerDate(date);
|
|
3942
4015
|
};
|
|
3943
4016
|
const handleKeyDown = (e) => {
|
|
@@ -3963,7 +4036,7 @@ var InputDatePickerSingle = ({
|
|
|
3963
4036
|
day: "2-digit"
|
|
3964
4037
|
}).format(date);
|
|
3965
4038
|
setInnerDate(date);
|
|
3966
|
-
onChange?.(dateToStr);
|
|
4039
|
+
onChange?.(dateToStr, date);
|
|
3967
4040
|
};
|
|
3968
4041
|
const normalizedCalendarDate = React8.useMemo(() => {
|
|
3969
4042
|
return dateFns.isValid(innerDate) ? innerDate : void 0;
|
|
@@ -4032,7 +4105,8 @@ var InputDatePickerSingle = ({
|
|
|
4032
4105
|
onSelect: handleCalendarSelect,
|
|
4033
4106
|
month,
|
|
4034
4107
|
onPrevClick: setMonth,
|
|
4035
|
-
onNextClick: setMonth
|
|
4108
|
+
onNextClick: setMonth,
|
|
4109
|
+
disabled: disabledDates
|
|
4036
4110
|
}
|
|
4037
4111
|
)
|
|
4038
4112
|
}
|
|
@@ -4113,6 +4187,7 @@ var InputDateTimePickerSingle = ({
|
|
|
4113
4187
|
onChange,
|
|
4114
4188
|
numberOfMonths = 1,
|
|
4115
4189
|
onClean,
|
|
4190
|
+
disabledDates,
|
|
4116
4191
|
...rest
|
|
4117
4192
|
}) => {
|
|
4118
4193
|
const [popoverIsOpen, setPopoverIsOpen] = React8.useState(false);
|
|
@@ -4120,7 +4195,7 @@ var InputDateTimePickerSingle = ({
|
|
|
4120
4195
|
const [innerDate, setInnerDate] = React8.useState(
|
|
4121
4196
|
value ? new Date(value) : void 0
|
|
4122
4197
|
);
|
|
4123
|
-
const { locale, messages:
|
|
4198
|
+
const { locale, messages: messages17 } = useNebulaI18n();
|
|
4124
4199
|
const [month, setMonth] = React8.useState(/* @__PURE__ */ new Date());
|
|
4125
4200
|
const inputTimeRef = React8.useRef(null);
|
|
4126
4201
|
const handleClearValue = () => {
|
|
@@ -4130,9 +4205,9 @@ var InputDateTimePickerSingle = ({
|
|
|
4130
4205
|
};
|
|
4131
4206
|
const handleInnerInputChange = (text) => {
|
|
4132
4207
|
const dateSlice = text.substring(0, 11).trim();
|
|
4133
|
-
|
|
4134
|
-
onChange?.(text);
|
|
4208
|
+
let hourSlice = text.substring(11).trim();
|
|
4135
4209
|
if (!text) {
|
|
4210
|
+
onChange?.(text);
|
|
4136
4211
|
handleClearValue();
|
|
4137
4212
|
return;
|
|
4138
4213
|
}
|
|
@@ -4141,20 +4216,19 @@ var InputDateTimePickerSingle = ({
|
|
|
4141
4216
|
locale === "en-US" ? dateSlice.substring(0, 2) : dateSlice.substring(3, 5),
|
|
4142
4217
|
dateSlice.substring(6)
|
|
4143
4218
|
];
|
|
4144
|
-
|
|
4219
|
+
const date = new Date(Number(year), Number(month2) - 1, Number(day));
|
|
4220
|
+
if ([day, month2, year].some((value2) => !value2) || !dateFormatIsValid(dateSlice, locale) || !dateFns.isValid(new Date(date)) || !dateIsAvailable(date, disabledDates)) {
|
|
4221
|
+
onChange?.(text);
|
|
4145
4222
|
handleClearValue();
|
|
4146
4223
|
return;
|
|
4147
4224
|
}
|
|
4148
4225
|
if (!timeFormatIsValid(hourSlice)) {
|
|
4226
|
+
hourSlice = "";
|
|
4149
4227
|
setInnerTimeValue("");
|
|
4150
4228
|
} else {
|
|
4151
4229
|
setInnerTimeValue(hourSlice);
|
|
4152
4230
|
}
|
|
4153
|
-
|
|
4154
|
-
if (!dateFns.isValid(new Date(date))) {
|
|
4155
|
-
handleClearValue();
|
|
4156
|
-
return;
|
|
4157
|
-
}
|
|
4231
|
+
onChange?.(text, date, hourSlice);
|
|
4158
4232
|
setInnerDate(date);
|
|
4159
4233
|
};
|
|
4160
4234
|
const handleOnChangeTime = (newTime) => {
|
|
@@ -4163,7 +4237,7 @@ var InputDateTimePickerSingle = ({
|
|
|
4163
4237
|
if (date && !dateFormatIsValid(date, locale)) {
|
|
4164
4238
|
handleClearValue();
|
|
4165
4239
|
}
|
|
4166
|
-
onChange?.(date + " " + newTime);
|
|
4240
|
+
onChange?.(date + " " + newTime, innerDate, newTime);
|
|
4167
4241
|
};
|
|
4168
4242
|
const handleKeyDown = (e) => {
|
|
4169
4243
|
if ((e.altKey || e.ctrlKey || e.metaKey) && e.key !== "z") return;
|
|
@@ -4190,7 +4264,11 @@ var InputDateTimePickerSingle = ({
|
|
|
4190
4264
|
day: "2-digit"
|
|
4191
4265
|
}).format(date);
|
|
4192
4266
|
setInnerDate(date);
|
|
4193
|
-
onChange?.(
|
|
4267
|
+
onChange?.(
|
|
4268
|
+
[dateToStr, innerTimeValue].filter(Boolean).join(" "),
|
|
4269
|
+
date,
|
|
4270
|
+
innerTimeValue
|
|
4271
|
+
);
|
|
4194
4272
|
if (!innerTimeValue) {
|
|
4195
4273
|
setTimeout(() => inputTimeRef.current?.focus(), 100);
|
|
4196
4274
|
}
|
|
@@ -4263,9 +4341,10 @@ var InputDateTimePickerSingle = ({
|
|
|
4263
4341
|
month,
|
|
4264
4342
|
onPrevClick: setMonth,
|
|
4265
4343
|
onNextClick: setMonth,
|
|
4344
|
+
disabled: disabledDates,
|
|
4266
4345
|
footer: /* @__PURE__ */ jsxRuntime.jsxs(Space, { className: "nebula-ds items-center", children: [
|
|
4267
4346
|
/* @__PURE__ */ jsxRuntime.jsxs(Label, { children: [
|
|
4268
|
-
|
|
4347
|
+
messages17.timePicker.label,
|
|
4269
4348
|
":"
|
|
4270
4349
|
] }),
|
|
4271
4350
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4274,7 +4353,8 @@ var InputDateTimePickerSingle = ({
|
|
|
4274
4353
|
placeholder: "00:00",
|
|
4275
4354
|
value: innerTimeValue,
|
|
4276
4355
|
onChange: handleOnChangeTime,
|
|
4277
|
-
ref: inputTimeRef
|
|
4356
|
+
ref: inputTimeRef,
|
|
4357
|
+
className: "nebula-ds max-w-[188px]"
|
|
4278
4358
|
}
|
|
4279
4359
|
)
|
|
4280
4360
|
] })
|
|
@@ -4284,6 +4364,521 @@ var InputDateTimePickerSingle = ({
|
|
|
4284
4364
|
)
|
|
4285
4365
|
] });
|
|
4286
4366
|
};
|
|
4367
|
+
var FileUploadError = /* @__PURE__ */ ((FileUploadError2) => {
|
|
4368
|
+
FileUploadError2["MAX_FILES_EXCEEDED"] = "MAX_FILES_EXCEEDED";
|
|
4369
|
+
FileUploadError2["MAXIMUM_FILE_SIZE_EXCEEDED"] = "MAXIMUM_FILE_SIZE_EXCEEDED";
|
|
4370
|
+
FileUploadError2["INVALID_FORMAT"] = "INVALID_FORMAT";
|
|
4371
|
+
return FileUploadError2;
|
|
4372
|
+
})(FileUploadError || {});
|
|
4373
|
+
var useFileUpload = (options = {}) => {
|
|
4374
|
+
const {
|
|
4375
|
+
maxFiles = Infinity,
|
|
4376
|
+
maxSize = Infinity,
|
|
4377
|
+
accept = "*",
|
|
4378
|
+
multiple = false,
|
|
4379
|
+
initialFiles = [],
|
|
4380
|
+
onFilesChange,
|
|
4381
|
+
onFilesAdded
|
|
4382
|
+
} = options;
|
|
4383
|
+
const [state, setState] = React8.useState({
|
|
4384
|
+
files: initialFiles.map((file) => ({
|
|
4385
|
+
file,
|
|
4386
|
+
id: file.id,
|
|
4387
|
+
preview: file.url
|
|
4388
|
+
})),
|
|
4389
|
+
isDragging: false,
|
|
4390
|
+
errors: []
|
|
4391
|
+
});
|
|
4392
|
+
const inputRef = React8.useRef(null);
|
|
4393
|
+
const validateFile = React8.useCallback(
|
|
4394
|
+
(file) => {
|
|
4395
|
+
if (file instanceof File) {
|
|
4396
|
+
if (file.size > maxSize) {
|
|
4397
|
+
return {
|
|
4398
|
+
file,
|
|
4399
|
+
error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */
|
|
4400
|
+
};
|
|
4401
|
+
}
|
|
4402
|
+
} else {
|
|
4403
|
+
if (file.size > maxSize) {
|
|
4404
|
+
return { error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */, file };
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
if (accept !== "*") {
|
|
4408
|
+
const acceptedTypes = accept.split(",").map((type) => type.trim());
|
|
4409
|
+
const fileType = file instanceof File ? file.type || "" : file.type;
|
|
4410
|
+
const fileExtension = `.${file instanceof File ? file.name.split(".").pop() : file.name.split(".").pop()}`;
|
|
4411
|
+
const isAccepted = acceptedTypes.some((type) => {
|
|
4412
|
+
if (type.startsWith(".")) {
|
|
4413
|
+
return fileExtension.toLowerCase() === type.toLowerCase();
|
|
4414
|
+
}
|
|
4415
|
+
if (type.endsWith("/*")) {
|
|
4416
|
+
const baseType = type.split("/")[0];
|
|
4417
|
+
return fileType.startsWith(`${baseType}/`);
|
|
4418
|
+
}
|
|
4419
|
+
return fileType === type;
|
|
4420
|
+
});
|
|
4421
|
+
if (!isAccepted) {
|
|
4422
|
+
return {
|
|
4423
|
+
file,
|
|
4424
|
+
error: "INVALID_FORMAT" /* INVALID_FORMAT */
|
|
4425
|
+
};
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
return null;
|
|
4429
|
+
},
|
|
4430
|
+
[accept, maxSize]
|
|
4431
|
+
);
|
|
4432
|
+
const createPreview = React8.useCallback(
|
|
4433
|
+
(file) => {
|
|
4434
|
+
if (file instanceof File) {
|
|
4435
|
+
return URL.createObjectURL(file);
|
|
4436
|
+
}
|
|
4437
|
+
return file.url;
|
|
4438
|
+
},
|
|
4439
|
+
[]
|
|
4440
|
+
);
|
|
4441
|
+
const generateUniqueId = React8.useCallback((file) => {
|
|
4442
|
+
if (file instanceof File) {
|
|
4443
|
+
return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
4444
|
+
}
|
|
4445
|
+
return file.id;
|
|
4446
|
+
}, []);
|
|
4447
|
+
const clearFiles = React8.useCallback(() => {
|
|
4448
|
+
setState((prev) => {
|
|
4449
|
+
prev.files.forEach((file) => {
|
|
4450
|
+
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) {
|
|
4451
|
+
URL.revokeObjectURL(file.preview);
|
|
4452
|
+
}
|
|
4453
|
+
});
|
|
4454
|
+
if (inputRef.current) {
|
|
4455
|
+
inputRef.current.value = "";
|
|
4456
|
+
}
|
|
4457
|
+
const newState = {
|
|
4458
|
+
...prev,
|
|
4459
|
+
files: [],
|
|
4460
|
+
errors: []
|
|
4461
|
+
};
|
|
4462
|
+
onFilesChange?.(newState.files);
|
|
4463
|
+
return newState;
|
|
4464
|
+
});
|
|
4465
|
+
}, [onFilesChange]);
|
|
4466
|
+
const addFiles = React8.useCallback(
|
|
4467
|
+
(newFiles) => {
|
|
4468
|
+
if (!newFiles || newFiles.length === 0) return;
|
|
4469
|
+
const newFilesArray = Array.from(newFiles);
|
|
4470
|
+
const errors = [];
|
|
4471
|
+
setState((prev) => ({ ...prev, errors: [] }));
|
|
4472
|
+
if (!multiple) {
|
|
4473
|
+
clearFiles();
|
|
4474
|
+
}
|
|
4475
|
+
if (multiple && maxFiles !== Infinity && state.files.length + newFilesArray.length > maxFiles) {
|
|
4476
|
+
errors.push({ error: "MAX_FILES_EXCEEDED" /* MAX_FILES_EXCEEDED */ });
|
|
4477
|
+
setState((prev) => ({ ...prev, errors }));
|
|
4478
|
+
return;
|
|
4479
|
+
}
|
|
4480
|
+
const validFiles = [];
|
|
4481
|
+
newFilesArray.forEach((file) => {
|
|
4482
|
+
if (multiple) {
|
|
4483
|
+
const isDuplicate = state.files.some(
|
|
4484
|
+
(existingFile) => existingFile.file.name === file.name && existingFile.file.size === file.size
|
|
4485
|
+
);
|
|
4486
|
+
if (isDuplicate) {
|
|
4487
|
+
return;
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
if (file.size > maxSize) {
|
|
4491
|
+
errors.push({
|
|
4492
|
+
error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */,
|
|
4493
|
+
file
|
|
4494
|
+
});
|
|
4495
|
+
return;
|
|
4496
|
+
}
|
|
4497
|
+
const error2 = validateFile(file);
|
|
4498
|
+
if (error2) {
|
|
4499
|
+
errors.push(error2);
|
|
4500
|
+
} else {
|
|
4501
|
+
validFiles.push({
|
|
4502
|
+
file,
|
|
4503
|
+
id: generateUniqueId(file),
|
|
4504
|
+
preview: createPreview(file)
|
|
4505
|
+
});
|
|
4506
|
+
}
|
|
4507
|
+
});
|
|
4508
|
+
if (validFiles.length > 0) {
|
|
4509
|
+
onFilesAdded?.(validFiles);
|
|
4510
|
+
setState((prev) => {
|
|
4511
|
+
const newFiles2 = !multiple ? validFiles : [...prev.files, ...validFiles];
|
|
4512
|
+
onFilesChange?.(newFiles2);
|
|
4513
|
+
return {
|
|
4514
|
+
...prev,
|
|
4515
|
+
files: newFiles2,
|
|
4516
|
+
errors
|
|
4517
|
+
};
|
|
4518
|
+
});
|
|
4519
|
+
} else if (errors.length > 0) {
|
|
4520
|
+
setState((prev) => ({
|
|
4521
|
+
...prev,
|
|
4522
|
+
errors
|
|
4523
|
+
}));
|
|
4524
|
+
}
|
|
4525
|
+
if (inputRef.current) {
|
|
4526
|
+
inputRef.current.value = "";
|
|
4527
|
+
}
|
|
4528
|
+
},
|
|
4529
|
+
[
|
|
4530
|
+
state.files,
|
|
4531
|
+
maxFiles,
|
|
4532
|
+
multiple,
|
|
4533
|
+
maxSize,
|
|
4534
|
+
validateFile,
|
|
4535
|
+
createPreview,
|
|
4536
|
+
generateUniqueId,
|
|
4537
|
+
clearFiles,
|
|
4538
|
+
onFilesChange,
|
|
4539
|
+
onFilesAdded
|
|
4540
|
+
]
|
|
4541
|
+
);
|
|
4542
|
+
const removeFile = React8.useCallback(
|
|
4543
|
+
(id) => {
|
|
4544
|
+
setState((prev) => {
|
|
4545
|
+
const fileToRemove = prev.files.find((file) => file.id === id);
|
|
4546
|
+
if (fileToRemove && fileToRemove.preview && fileToRemove.file instanceof File && fileToRemove.file.type.startsWith("image/")) {
|
|
4547
|
+
URL.revokeObjectURL(fileToRemove.preview);
|
|
4548
|
+
}
|
|
4549
|
+
const newFiles = prev.files.filter((file) => file.id !== id);
|
|
4550
|
+
onFilesChange?.(newFiles);
|
|
4551
|
+
return {
|
|
4552
|
+
...prev,
|
|
4553
|
+
files: newFiles,
|
|
4554
|
+
errors: []
|
|
4555
|
+
};
|
|
4556
|
+
});
|
|
4557
|
+
},
|
|
4558
|
+
[onFilesChange]
|
|
4559
|
+
);
|
|
4560
|
+
const clearErrors = React8.useCallback(() => {
|
|
4561
|
+
setState((prev) => ({
|
|
4562
|
+
...prev,
|
|
4563
|
+
errors: []
|
|
4564
|
+
}));
|
|
4565
|
+
}, []);
|
|
4566
|
+
const handleDragEnter = React8.useCallback((e) => {
|
|
4567
|
+
e.preventDefault();
|
|
4568
|
+
e.stopPropagation();
|
|
4569
|
+
setState((prev) => ({ ...prev, isDragging: true }));
|
|
4570
|
+
}, []);
|
|
4571
|
+
const handleDragLeave = React8.useCallback((e) => {
|
|
4572
|
+
e.preventDefault();
|
|
4573
|
+
e.stopPropagation();
|
|
4574
|
+
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
4575
|
+
return;
|
|
4576
|
+
}
|
|
4577
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
4578
|
+
}, []);
|
|
4579
|
+
const handleDragOver = React8.useCallback((e) => {
|
|
4580
|
+
e.preventDefault();
|
|
4581
|
+
e.stopPropagation();
|
|
4582
|
+
}, []);
|
|
4583
|
+
const handleDrop = React8.useCallback(
|
|
4584
|
+
(e) => {
|
|
4585
|
+
e.preventDefault();
|
|
4586
|
+
e.stopPropagation();
|
|
4587
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
4588
|
+
if (inputRef.current?.disabled) {
|
|
4589
|
+
return;
|
|
4590
|
+
}
|
|
4591
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
4592
|
+
if (!multiple) {
|
|
4593
|
+
const file = e.dataTransfer.files[0];
|
|
4594
|
+
if (file) {
|
|
4595
|
+
addFiles([file]);
|
|
4596
|
+
}
|
|
4597
|
+
} else {
|
|
4598
|
+
addFiles(e.dataTransfer.files);
|
|
4599
|
+
}
|
|
4600
|
+
}
|
|
4601
|
+
},
|
|
4602
|
+
[addFiles, multiple]
|
|
4603
|
+
);
|
|
4604
|
+
const handleFileChange = React8.useCallback(
|
|
4605
|
+
(e) => {
|
|
4606
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
4607
|
+
addFiles(e.target.files);
|
|
4608
|
+
}
|
|
4609
|
+
},
|
|
4610
|
+
[addFiles]
|
|
4611
|
+
);
|
|
4612
|
+
const openFileDialog = React8.useCallback(() => {
|
|
4613
|
+
if (inputRef.current) {
|
|
4614
|
+
inputRef.current.click();
|
|
4615
|
+
}
|
|
4616
|
+
}, []);
|
|
4617
|
+
const getInputProps = React8.useCallback(
|
|
4618
|
+
(props = {}) => {
|
|
4619
|
+
return {
|
|
4620
|
+
...props,
|
|
4621
|
+
type: "file",
|
|
4622
|
+
onChange: handleFileChange,
|
|
4623
|
+
accept: props.accept || accept,
|
|
4624
|
+
multiple: props.multiple !== void 0 ? props.multiple : multiple,
|
|
4625
|
+
ref: inputRef
|
|
4626
|
+
};
|
|
4627
|
+
},
|
|
4628
|
+
[accept, multiple, handleFileChange]
|
|
4629
|
+
);
|
|
4630
|
+
return [
|
|
4631
|
+
state,
|
|
4632
|
+
{
|
|
4633
|
+
addFiles,
|
|
4634
|
+
removeFile,
|
|
4635
|
+
clearFiles,
|
|
4636
|
+
clearErrors,
|
|
4637
|
+
handleDragEnter,
|
|
4638
|
+
handleDragLeave,
|
|
4639
|
+
handleDragOver,
|
|
4640
|
+
handleDrop,
|
|
4641
|
+
handleFileChange,
|
|
4642
|
+
openFileDialog,
|
|
4643
|
+
getInputProps
|
|
4644
|
+
}
|
|
4645
|
+
];
|
|
4646
|
+
};
|
|
4647
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
4648
|
+
if (bytes === 0) return "0 Bytes";
|
|
4649
|
+
const k = 1024;
|
|
4650
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
4651
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
4652
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
4653
|
+
return Number.parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + (sizes?.[i] || "");
|
|
4654
|
+
};
|
|
4655
|
+
var filePreviewByMimetype = (mimetype) => {
|
|
4656
|
+
if (mimetype.match("text") || mimetype.match("application")) {
|
|
4657
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileTextIcon, {});
|
|
4658
|
+
}
|
|
4659
|
+
if (mimetype.match("audio")) {
|
|
4660
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileAudioIcon, {});
|
|
4661
|
+
}
|
|
4662
|
+
if (mimetype.match("video")) {
|
|
4663
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileVideoIcon, {});
|
|
4664
|
+
}
|
|
4665
|
+
return null;
|
|
4666
|
+
};
|
|
4667
|
+
function FileUpload({
|
|
4668
|
+
maxSizeMB = 2,
|
|
4669
|
+
subtitle,
|
|
4670
|
+
title,
|
|
4671
|
+
imagePreview,
|
|
4672
|
+
showPreview = true,
|
|
4673
|
+
onError,
|
|
4674
|
+
maxFiles = Infinity,
|
|
4675
|
+
...rest
|
|
4676
|
+
}) {
|
|
4677
|
+
const { fileUpload } = useNebulaI18n().messages;
|
|
4678
|
+
const maxSize = maxSizeMB * 1024 * 1024;
|
|
4679
|
+
const [
|
|
4680
|
+
{ files, isDragging, errors },
|
|
4681
|
+
{
|
|
4682
|
+
handleDragEnter,
|
|
4683
|
+
handleDragLeave,
|
|
4684
|
+
handleDragOver,
|
|
4685
|
+
handleDrop,
|
|
4686
|
+
openFileDialog,
|
|
4687
|
+
removeFile,
|
|
4688
|
+
getInputProps,
|
|
4689
|
+
clearFiles
|
|
4690
|
+
}
|
|
4691
|
+
] = useFileUpload({
|
|
4692
|
+
multiple: false,
|
|
4693
|
+
maxSize: maxSize > 0 ? maxSize : void 0,
|
|
4694
|
+
accept: "*",
|
|
4695
|
+
...rest,
|
|
4696
|
+
maxFiles
|
|
4697
|
+
});
|
|
4698
|
+
React8.useEffect(() => {
|
|
4699
|
+
onError?.(errors);
|
|
4700
|
+
}, [errors, onError]);
|
|
4701
|
+
const disabled = React8.useMemo(() => {
|
|
4702
|
+
if (rest.disabled) return true;
|
|
4703
|
+
if (rest.multiple) {
|
|
4704
|
+
if (!Number.isFinite(maxFiles)) return false;
|
|
4705
|
+
return files.length === maxFiles;
|
|
4706
|
+
}
|
|
4707
|
+
return files.length;
|
|
4708
|
+
}, [rest.disabled, rest.multiple, files.length, maxFiles]);
|
|
4709
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds flex flex-col gap-2 w-full", children: [
|
|
4710
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds relative w-full", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4711
|
+
"div",
|
|
4712
|
+
{
|
|
4713
|
+
role: "button",
|
|
4714
|
+
onClick: openFileDialog,
|
|
4715
|
+
onDragEnter: handleDragEnter,
|
|
4716
|
+
onDragLeave: handleDragLeave,
|
|
4717
|
+
onDragOver: handleDragOver,
|
|
4718
|
+
onDrop: handleDrop,
|
|
4719
|
+
"data-dragging": isDragging || void 0,
|
|
4720
|
+
className: cn(
|
|
4721
|
+
"bg-fileUpload-background hover:bg-fileUpload-backgroundHover transition-colors",
|
|
4722
|
+
"border border-dashed border-fileUpload-border rounded-2xl",
|
|
4723
|
+
"py-14",
|
|
4724
|
+
disabled && "pointer-events-none cursor-not-allowed"
|
|
4725
|
+
),
|
|
4726
|
+
children: [
|
|
4727
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4728
|
+
"input",
|
|
4729
|
+
{
|
|
4730
|
+
...getInputProps(),
|
|
4731
|
+
className: "nebula-ds sr-only",
|
|
4732
|
+
"aria-label": "Upload file"
|
|
4733
|
+
}
|
|
4734
|
+
),
|
|
4735
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4736
|
+
"div",
|
|
4737
|
+
{
|
|
4738
|
+
className: cn(
|
|
4739
|
+
"flex flex-col items-center justify-center px-4 py-3 text-center w-full",
|
|
4740
|
+
disabled && "opacity-60"
|
|
4741
|
+
),
|
|
4742
|
+
children: [
|
|
4743
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4744
|
+
"div",
|
|
4745
|
+
{
|
|
4746
|
+
className: "nebula-ds mb-2 flex size-12 shrink-0 items-center justify-center rounded-full border border-fileUpload-border",
|
|
4747
|
+
"aria-hidden": "true",
|
|
4748
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ImageUpIcon, { className: "nebula-ds size-4 opacity-60 text-fileUpload-icon" })
|
|
4749
|
+
}
|
|
4750
|
+
),
|
|
4751
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading, { level: "5", className: "nebula-ds mb-1", children: title }),
|
|
4752
|
+
/* @__PURE__ */ jsxRuntime.jsx(Paragraph, { size: "sm", children: subtitle })
|
|
4753
|
+
]
|
|
4754
|
+
}
|
|
4755
|
+
)
|
|
4756
|
+
]
|
|
4757
|
+
}
|
|
4758
|
+
) }),
|
|
4759
|
+
files.length > 0 && showPreview && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds space-y-2", children: files.map((file, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4760
|
+
"div",
|
|
4761
|
+
{
|
|
4762
|
+
className: "nebula-ds bg-fileUpload-backgroundFile flex items-center justify-between gap-2 rounded-xl border border-fileUpload-borderFile p-2",
|
|
4763
|
+
children: [
|
|
4764
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds flex items-center gap-3 overflow-hidden", children: [
|
|
4765
|
+
/* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(
|
|
4766
|
+
"img",
|
|
4767
|
+
{
|
|
4768
|
+
src: file.preview,
|
|
4769
|
+
alt: file.file.name,
|
|
4770
|
+
className: "nebula-ds rounded-[inherit] object-cover h-full w-full"
|
|
4771
|
+
}
|
|
4772
|
+
) }),
|
|
4773
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds flex min-w-0 flex-col gap-1", children: [
|
|
4774
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading, { level: "5", className: "nebula-ds text-xs", children: file.file.name }),
|
|
4775
|
+
/* @__PURE__ */ jsxRuntime.jsx(Paragraph, { size: "sm", children: formatBytes(file.file.size) })
|
|
4776
|
+
] })
|
|
4777
|
+
] }),
|
|
4778
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4779
|
+
Button,
|
|
4780
|
+
{
|
|
4781
|
+
icon: true,
|
|
4782
|
+
variant: "ghost",
|
|
4783
|
+
onClick: () => removeFile(file.id),
|
|
4784
|
+
"aria-label": "Remove file",
|
|
4785
|
+
"data-testid": `file-upload-remove-file-${idx}`,
|
|
4786
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { "aria-hidden": "true" })
|
|
4787
|
+
}
|
|
4788
|
+
)
|
|
4789
|
+
]
|
|
4790
|
+
},
|
|
4791
|
+
file.id
|
|
4792
|
+
)) }),
|
|
4793
|
+
files.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4794
|
+
Button,
|
|
4795
|
+
{
|
|
4796
|
+
size: "md",
|
|
4797
|
+
variant: "secondary",
|
|
4798
|
+
onClick: clearFiles,
|
|
4799
|
+
"data-testid": "file-upload-remove-all-files",
|
|
4800
|
+
children: fileUpload.deleteAll
|
|
4801
|
+
}
|
|
4802
|
+
) })
|
|
4803
|
+
] });
|
|
4804
|
+
}
|
|
4805
|
+
var TextArea = React8__namespace.forwardRef(
|
|
4806
|
+
({
|
|
4807
|
+
className,
|
|
4808
|
+
isError = false,
|
|
4809
|
+
disabled,
|
|
4810
|
+
resize = true,
|
|
4811
|
+
showCount = false,
|
|
4812
|
+
autoResize = true,
|
|
4813
|
+
maxLength,
|
|
4814
|
+
asInput,
|
|
4815
|
+
...props
|
|
4816
|
+
}, ref) => {
|
|
4817
|
+
const innerRef = React8__namespace.useRef(
|
|
4818
|
+
null
|
|
4819
|
+
);
|
|
4820
|
+
const [count, setCount] = React8__namespace.useState(String(props.value ?? "").length);
|
|
4821
|
+
const countParts = [count, maxLength].filter(
|
|
4822
|
+
(part) => typeof part === "number"
|
|
4823
|
+
);
|
|
4824
|
+
React8__namespace.useEffect(() => {
|
|
4825
|
+
const textarea = innerRef.current;
|
|
4826
|
+
if (!textarea || !autoResize) return;
|
|
4827
|
+
const adjustHeight = () => {
|
|
4828
|
+
textarea.style.height = "auto";
|
|
4829
|
+
textarea.style.height = asInput && !textarea.value || !textarea.value.match("\n") ? "22px" : `${textarea.scrollHeight}px`;
|
|
4830
|
+
};
|
|
4831
|
+
adjustHeight();
|
|
4832
|
+
textarea.addEventListener("input", adjustHeight);
|
|
4833
|
+
return () => {
|
|
4834
|
+
textarea.removeEventListener("input", adjustHeight);
|
|
4835
|
+
};
|
|
4836
|
+
}, [asInput, autoResize, props.value]);
|
|
4837
|
+
React8__namespace.useImperativeHandle(ref, () => innerRef.current);
|
|
4838
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds relative w-full", children: [
|
|
4839
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4840
|
+
"div",
|
|
4841
|
+
{
|
|
4842
|
+
className: cn(
|
|
4843
|
+
"w-full pl-0 pr-2 py-2 overflow-hidden flex box-border",
|
|
4844
|
+
"w-full outline-none rounded-textarea text-sm font-medium",
|
|
4845
|
+
"bg-inputText-background-default",
|
|
4846
|
+
"border border-inputText-border-default focus-within:ring-[3px] focus-within:ring-inputText-border-focus focus-within:border-inputText-border-focus",
|
|
4847
|
+
"text-inputText-text-filled focus-within:text-inputText-text-focus ",
|
|
4848
|
+
"disabled:cursor-not-allowed",
|
|
4849
|
+
"[&>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",
|
|
4850
|
+
"[&>textarea]:focus:ring-0 [&>textarea]:focus:border-none [&>textarea]:border-none [&>textarea]:outline-none [&>textarea]:ring-0",
|
|
4851
|
+
"[&>textarea]:bg-inputText-background-default disabled:[&>textarea]:bg-inputText-background-disabled",
|
|
4852
|
+
"[&>textarea]:placeholder:text-inputText-text-default disabled:[&>textarea]:text-inputText-text-disabled",
|
|
4853
|
+
{
|
|
4854
|
+
"bg-inputText-background-disabled text-inputText-text-disabled [&>textarea]:ps-4 [&>textarea]:pr-2": disabled,
|
|
4855
|
+
"border-inputText-border-danger focus-within:border-inputText-border-danger focus-within:ring-button-danger-border-focus": isError,
|
|
4856
|
+
"[&>textarea]:resize-none": !resize,
|
|
4857
|
+
"[&>textarea]:min-h-[22px] !rounded-input": asInput
|
|
4858
|
+
},
|
|
4859
|
+
className
|
|
4860
|
+
),
|
|
4861
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4862
|
+
"textarea",
|
|
4863
|
+
{
|
|
4864
|
+
ref: innerRef,
|
|
4865
|
+
...props,
|
|
4866
|
+
disabled,
|
|
4867
|
+
onChange: (e) => {
|
|
4868
|
+
if (showCount) {
|
|
4869
|
+
setCount(e.target.value.length);
|
|
4870
|
+
}
|
|
4871
|
+
props.onChange?.(e);
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
)
|
|
4875
|
+
}
|
|
4876
|
+
),
|
|
4877
|
+
!!showCount && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds absolute right-0 top-[100%] pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(Paragraph, { size: "sm", children: countParts.join("/") }) })
|
|
4878
|
+
] });
|
|
4879
|
+
}
|
|
4880
|
+
);
|
|
4881
|
+
TextArea.displayName = "TextArea";
|
|
4287
4882
|
|
|
4288
4883
|
// src/tailwind.ts
|
|
4289
4884
|
function content({ base = "./" } = {}) {
|
|
@@ -4371,6 +4966,8 @@ exports.DropdownMenuSub = DropdownMenuSub;
|
|
|
4371
4966
|
exports.DropdownMenuSubContent = DropdownMenuSubContent;
|
|
4372
4967
|
exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
|
|
4373
4968
|
exports.DropdownMenuTrigger = DropdownMenuTrigger;
|
|
4969
|
+
exports.FileUpload = FileUpload;
|
|
4970
|
+
exports.FileUploadError = FileUploadError;
|
|
4374
4971
|
exports.Heading = Heading;
|
|
4375
4972
|
exports.InputDatePickerSingle = InputDatePickerSingle;
|
|
4376
4973
|
exports.InputDateTimePickerSingle = InputDateTimePickerSingle;
|
|
@@ -4405,6 +5002,7 @@ exports.TabsContent = TabsContent;
|
|
|
4405
5002
|
exports.TabsList = TabsList;
|
|
4406
5003
|
exports.TabsTrigger = TabsTrigger;
|
|
4407
5004
|
exports.Tag = Tag;
|
|
5005
|
+
exports.TextArea = TextArea;
|
|
4408
5006
|
exports.Toaster = Toaster;
|
|
4409
5007
|
exports.Tooltip = Tooltip;
|
|
4410
5008
|
exports.alertVariants = alertVariants;
|
|
@@ -4413,9 +5011,11 @@ exports.badgeVariantEnum = badgeVariantEnum;
|
|
|
4413
5011
|
exports.buttonSizeEnum = buttonSizeEnum;
|
|
4414
5012
|
exports.buttonVariantEnum = buttonVariantEnum;
|
|
4415
5013
|
exports.buttonVariantsConfig = buttonVariantsConfig;
|
|
5014
|
+
exports.dateIsAvailable = dateIsAvailable;
|
|
5015
|
+
exports.formatBytes = formatBytes;
|
|
4416
5016
|
exports.getNebulaLanguage = getNebulaLanguage;
|
|
4417
5017
|
exports.localeByi18nKey = localeByi18nKey;
|
|
4418
|
-
exports.messages =
|
|
5018
|
+
exports.messages = messages16;
|
|
4419
5019
|
exports.separatorVariants = separatorVariants;
|
|
4420
5020
|
exports.setNebulaLanguage = setNebulaLanguage;
|
|
4421
5021
|
exports.tagVariantsEnum = tagVariantsEnum;
|