react-better-html 1.1.75 → 1.1.77
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 +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +583 -242
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +564 -223
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1335,7 +1335,7 @@ var theme = {
|
|
|
1335
1335
|
},
|
|
1336
1336
|
dark: {
|
|
1337
1337
|
textPrimary: "#f8f8f8",
|
|
1338
|
-
textSecondary: "#
|
|
1338
|
+
textSecondary: "#c8c8c8",
|
|
1339
1339
|
textLink: "#0894ff",
|
|
1340
1340
|
label: "#111111",
|
|
1341
1341
|
primary: "#9b6499",
|
|
@@ -1344,7 +1344,7 @@ var theme = {
|
|
|
1344
1344
|
success: "#28a745",
|
|
1345
1345
|
info: "#0fa0da",
|
|
1346
1346
|
warn: "#ffc107",
|
|
1347
|
-
error: "#
|
|
1347
|
+
error: "#f5384b",
|
|
1348
1348
|
base: "#f8f8f8",
|
|
1349
1349
|
backgroundBase: "#111111",
|
|
1350
1350
|
backgroundSecondary: "#222222",
|
|
@@ -1396,6 +1396,26 @@ var icons = {
|
|
|
1396
1396
|
}
|
|
1397
1397
|
]
|
|
1398
1398
|
},
|
|
1399
|
+
chevronLeft: {
|
|
1400
|
+
width: 320,
|
|
1401
|
+
height: 512,
|
|
1402
|
+
paths: [
|
|
1403
|
+
{
|
|
1404
|
+
d: "M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z",
|
|
1405
|
+
type: "fill"
|
|
1406
|
+
}
|
|
1407
|
+
]
|
|
1408
|
+
},
|
|
1409
|
+
chevronRight: {
|
|
1410
|
+
width: 320,
|
|
1411
|
+
height: 512,
|
|
1412
|
+
paths: [
|
|
1413
|
+
{
|
|
1414
|
+
d: "M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z",
|
|
1415
|
+
type: "fill"
|
|
1416
|
+
}
|
|
1417
|
+
]
|
|
1418
|
+
},
|
|
1399
1419
|
eye: {
|
|
1400
1420
|
width: 576,
|
|
1401
1421
|
height: 512,
|
|
@@ -1703,7 +1723,7 @@ function useComponentPropsWithoutStyle(props) {
|
|
|
1703
1723
|
[props]
|
|
1704
1724
|
);
|
|
1705
1725
|
}
|
|
1706
|
-
function useComponentInputFieldDateProps(props, holderRef) {
|
|
1726
|
+
function useComponentInputFieldDateProps(props, holderRef, disabled) {
|
|
1707
1727
|
const theme2 = useTheme();
|
|
1708
1728
|
const [isOpen, setIsOpen] = useBooleanState();
|
|
1709
1729
|
const [isOpenLate, setIsOpenLate] = useBooleanState();
|
|
@@ -1712,7 +1732,7 @@ function useComponentInputFieldDateProps(props, holderRef) {
|
|
|
1712
1732
|
const inputFieldProps = useMemo2(
|
|
1713
1733
|
() => ({
|
|
1714
1734
|
value: internalValue,
|
|
1715
|
-
className: `${isOpen ? "react-better-html-inputField-dateTime-opened" : ""}${isOpenLate ? " react-better-html-inputField-dateTime-opened-late" : ""}${props.className ? ` ${props.className}` : ""}`,
|
|
1735
|
+
className: `${isOpen && !disabled ? "react-better-html-inputField-dateTime-opened" : ""}${isOpenLate && !disabled ? " react-better-html-inputField-dateTime-opened-late" : ""}${props.className ? ` ${props.className}` : ""}`,
|
|
1716
1736
|
onClick: (event) => {
|
|
1717
1737
|
if (props.disabled) return;
|
|
1718
1738
|
setIsOpen.setTrue();
|
|
@@ -1731,7 +1751,7 @@ function useComponentInputFieldDateProps(props, holderRef) {
|
|
|
1731
1751
|
props.onChangeValue?.(value);
|
|
1732
1752
|
}
|
|
1733
1753
|
}),
|
|
1734
|
-
[props, internalValue, isOpen, isOpenLate]
|
|
1754
|
+
[props, internalValue, isOpen, isOpenLate, disabled]
|
|
1735
1755
|
);
|
|
1736
1756
|
const insideInputFieldComponentProps = useMemo2(
|
|
1737
1757
|
() => ({
|
|
@@ -3059,7 +3079,7 @@ Chip2.circle = ChipComponent.circle;
|
|
|
3059
3079
|
var Chip_default = Chip2;
|
|
3060
3080
|
|
|
3061
3081
|
// src/components/InputField.tsx
|
|
3062
|
-
import { forwardRef as forwardRef8, memo as
|
|
3082
|
+
import { forwardRef as forwardRef8, memo as memo16, useCallback as useCallback9, useState as useState7, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef4 } from "react";
|
|
3063
3083
|
import styled8 from "styled-components";
|
|
3064
3084
|
|
|
3065
3085
|
// src/constants/countries.ts
|
|
@@ -4543,6 +4563,68 @@ var countries = [
|
|
|
4543
4563
|
}
|
|
4544
4564
|
];
|
|
4545
4565
|
|
|
4566
|
+
// src/utils/functions.ts
|
|
4567
|
+
var generateRandomString = (stringLength, options) => {
|
|
4568
|
+
const capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
4569
|
+
const lowers = "abcdefghijklmnopqrstuvwxyz";
|
|
4570
|
+
const numbers = "0123456789";
|
|
4571
|
+
const includes = [];
|
|
4572
|
+
if (options?.includeCapitalLetters !== false) includes.push(capitals);
|
|
4573
|
+
if (options?.includeLowerLetters !== false) includes.push(lowers);
|
|
4574
|
+
if (options?.includeNumbers !== false) includes.push(numbers);
|
|
4575
|
+
const characters = includes.join("");
|
|
4576
|
+
const dashSections = Math.max(1, options?.dashSections ?? 1);
|
|
4577
|
+
const dashSectionLength = Math.floor(stringLength / dashSections);
|
|
4578
|
+
if (stringLength < dashSections) return "";
|
|
4579
|
+
let result = "";
|
|
4580
|
+
let currentSectionLength = 0;
|
|
4581
|
+
while (result.length < stringLength) {
|
|
4582
|
+
if (currentSectionLength >= dashSectionLength) {
|
|
4583
|
+
result += "-";
|
|
4584
|
+
currentSectionLength = 0;
|
|
4585
|
+
}
|
|
4586
|
+
if (result.length < stringLength) {
|
|
4587
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
4588
|
+
currentSectionLength += 1;
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
return result;
|
|
4592
|
+
};
|
|
4593
|
+
var getBrowser = () => {
|
|
4594
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
4595
|
+
if (userAgent.includes("firefox")) return "firefox";
|
|
4596
|
+
if (userAgent.includes("chrome") && !userAgent.includes("edg")) return "chrome";
|
|
4597
|
+
if (userAgent.includes("safari") && !userAgent.includes("chrome")) return "safari";
|
|
4598
|
+
if (userAgent.includes("edg")) return "edge";
|
|
4599
|
+
if (userAgent.includes("opr") || userAgent.includes("opera")) return "opera";
|
|
4600
|
+
return;
|
|
4601
|
+
};
|
|
4602
|
+
var formatPhoneNumber = (phoneNumber) => {
|
|
4603
|
+
const cleanPhoneNumber = phoneNumber.replace(/\D/g, "");
|
|
4604
|
+
const country = countries.find(
|
|
4605
|
+
(country2) => country2.phoneNumberExtension === cleanPhoneNumber.slice(0, country2.phoneNumberExtension.length)
|
|
4606
|
+
);
|
|
4607
|
+
if (!country) return phoneNumber;
|
|
4608
|
+
let phonNumberRest = cleanPhoneNumber.slice(country.phoneNumberExtension.length);
|
|
4609
|
+
if (country.phoneNumberFormat) {
|
|
4610
|
+
let formattedNumber = "";
|
|
4611
|
+
let index = 0;
|
|
4612
|
+
for (const char of country.phoneNumberFormat) {
|
|
4613
|
+
if (char === "X" && index < phonNumberRest.length) {
|
|
4614
|
+
formattedNumber += phonNumberRest[index];
|
|
4615
|
+
index++;
|
|
4616
|
+
} else {
|
|
4617
|
+
formattedNumber += char;
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
phonNumberRest = formattedNumber.replace(/X/g, "").trim();
|
|
4621
|
+
}
|
|
4622
|
+
return `+${country.phoneNumberExtension} ${phonNumberRest}`;
|
|
4623
|
+
};
|
|
4624
|
+
var getFormErrorObject = (formValues) => {
|
|
4625
|
+
return {};
|
|
4626
|
+
};
|
|
4627
|
+
|
|
4546
4628
|
// src/components/Label.tsx
|
|
4547
4629
|
import { memo as memo13 } from "react";
|
|
4548
4630
|
import { jsxs as jsxs7 } from "react/jsx-runtime";
|
|
@@ -4850,8 +4932,188 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4850
4932
|
var Dropdown2 = memo14(DropdownComponent);
|
|
4851
4933
|
var Dropdown_default = Dropdown2;
|
|
4852
4934
|
|
|
4853
|
-
// src/components/
|
|
4935
|
+
// src/components/Calendar.tsx
|
|
4936
|
+
import { useCallback as useCallback8, useMemo as useMemo4, useState as useState6, memo as memo15, useEffect as useEffect6 } from "react";
|
|
4854
4937
|
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4938
|
+
var getMonthName = (month, short = false) => {
|
|
4939
|
+
return [
|
|
4940
|
+
short ? "Jan" : "January",
|
|
4941
|
+
short ? "Feb" : "February",
|
|
4942
|
+
short ? "Mar" : "March",
|
|
4943
|
+
short ? "Apr" : "April",
|
|
4944
|
+
short ? "May" : "May",
|
|
4945
|
+
short ? "Jun" : "June",
|
|
4946
|
+
short ? "Jul" : "July",
|
|
4947
|
+
short ? "Aug" : "August",
|
|
4948
|
+
short ? "Sep" : "September",
|
|
4949
|
+
short ? "Oct" : "October",
|
|
4950
|
+
short ? "Nov" : "November",
|
|
4951
|
+
short ? "Dec" : "December"
|
|
4952
|
+
][month];
|
|
4953
|
+
};
|
|
4954
|
+
var getWeekDayName = (day, short = false) => {
|
|
4955
|
+
return [
|
|
4956
|
+
short ? "Sun" : "Sunday",
|
|
4957
|
+
short ? "Mon" : "Monday",
|
|
4958
|
+
short ? "Tue" : "Tuesday",
|
|
4959
|
+
short ? "Wed" : "Wednesday",
|
|
4960
|
+
short ? "Thu" : "Thursday",
|
|
4961
|
+
short ? "Fri" : "Friday",
|
|
4962
|
+
short ? "Sat" : "Saturday"
|
|
4963
|
+
][day];
|
|
4964
|
+
};
|
|
4965
|
+
var weekDaysIndex = [1, 2, 3, 4, 5, 6, 0];
|
|
4966
|
+
function Calendar({ value, minDate, maxDate, onChange }) {
|
|
4967
|
+
const theme2 = useTheme();
|
|
4968
|
+
const [currentDate, setCurrentDate] = useState6(value ? new Date(value) : void 0);
|
|
4969
|
+
const [currentMonth, setCurrentMonth] = useState6(currentDate?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth());
|
|
4970
|
+
const [currentYear, setCurrentYear] = useState6(currentDate?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear());
|
|
4971
|
+
const daysInMonth = useMemo4(() => new Date(currentYear, currentMonth + 1, 0).getDate(), [currentMonth, currentYear]);
|
|
4972
|
+
const onClickPreviousMonthButton = useCallback8(() => {
|
|
4973
|
+
const newMonth = currentMonth === 0 ? 11 : currentMonth - 1;
|
|
4974
|
+
const newYear = currentMonth === 0 ? currentYear - 1 : currentYear;
|
|
4975
|
+
setCurrentMonth(newMonth);
|
|
4976
|
+
setCurrentYear(newYear);
|
|
4977
|
+
}, [currentMonth, currentYear]);
|
|
4978
|
+
const onClickNextMonthButton = useCallback8(() => {
|
|
4979
|
+
const newMonth = currentMonth === 11 ? 0 : currentMonth + 1;
|
|
4980
|
+
const newYear = currentMonth === 11 ? currentYear + 1 : currentYear;
|
|
4981
|
+
setCurrentMonth(newMonth);
|
|
4982
|
+
setCurrentYear(newYear);
|
|
4983
|
+
}, [currentMonth, currentYear]);
|
|
4984
|
+
const onClickDay = useCallback8(
|
|
4985
|
+
(day) => {
|
|
4986
|
+
if (!day) return;
|
|
4987
|
+
const newDate = new Date(currentYear, currentMonth, day);
|
|
4988
|
+
setCurrentDate(newDate);
|
|
4989
|
+
onChange?.(
|
|
4990
|
+
`${newDate.getFullYear()}-${(newDate.getMonth() + 1).toString().padStart(2, "0")}-${newDate.getDate().toString().padStart(2, "0")}`
|
|
4991
|
+
);
|
|
4992
|
+
},
|
|
4993
|
+
[currentMonth, currentYear, onChange]
|
|
4994
|
+
);
|
|
4995
|
+
const onClickClear = useCallback8(() => {
|
|
4996
|
+
setCurrentDate(void 0);
|
|
4997
|
+
onChange?.(void 0);
|
|
4998
|
+
}, []);
|
|
4999
|
+
const onClickToday = useCallback8(() => {
|
|
5000
|
+
const today = /* @__PURE__ */ new Date();
|
|
5001
|
+
setCurrentDate(today);
|
|
5002
|
+
onChange?.(
|
|
5003
|
+
`${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2, "0")}-${today.getDate().toString().padStart(2, "0")}`
|
|
5004
|
+
);
|
|
5005
|
+
}, [onChange]);
|
|
5006
|
+
const firstDayOfMonth = useMemo4(() => {
|
|
5007
|
+
const day = new Date(currentYear, currentMonth, 1).getDay();
|
|
5008
|
+
return day === 0 ? 6 : day - 1;
|
|
5009
|
+
}, [currentMonth, currentYear]);
|
|
5010
|
+
const days = useMemo4(() => {
|
|
5011
|
+
const result = [];
|
|
5012
|
+
for (let index = 0; index < firstDayOfMonth; index++) {
|
|
5013
|
+
result.push(void 0);
|
|
5014
|
+
}
|
|
5015
|
+
for (let index = 1; index <= daysInMonth; index++) {
|
|
5016
|
+
result.push(index);
|
|
5017
|
+
}
|
|
5018
|
+
return result;
|
|
5019
|
+
}, [daysInMonth, firstDayOfMonth]);
|
|
5020
|
+
useEffect6(() => {
|
|
5021
|
+
if (!value) return;
|
|
5022
|
+
const date = new Date(value);
|
|
5023
|
+
setCurrentDate(date);
|
|
5024
|
+
setCurrentMonth(date.getMonth());
|
|
5025
|
+
setCurrentYear(date.getFullYear());
|
|
5026
|
+
}, [value]);
|
|
5027
|
+
return /* @__PURE__ */ jsxs9(Div_default.column, { width: "100%", maxWidth: 320, gap: theme2.styles.gap, padding: theme2.styles.space / 2, userSelect: "none", children: [
|
|
5028
|
+
/* @__PURE__ */ jsxs9(Div_default.row, { width: "100%", justifyContent: "space-between", alignItems: "center", children: [
|
|
5029
|
+
/* @__PURE__ */ jsx14(Button_default.icon, { icon: "chevronLeft", onClick: onClickPreviousMonthButton }),
|
|
5030
|
+
/* @__PURE__ */ jsxs9(Text_default, { fontWeight: 700, children: [
|
|
5031
|
+
getMonthName(currentMonth),
|
|
5032
|
+
" ",
|
|
5033
|
+
currentYear
|
|
5034
|
+
] }),
|
|
5035
|
+
/* @__PURE__ */ jsx14(Button_default.icon, { icon: "chevronRight", onClick: onClickNextMonthButton })
|
|
5036
|
+
] }),
|
|
5037
|
+
/* @__PURE__ */ jsxs9(Div_default.grid, { width: "100%", gridTemplateColumns: "repeat(7, 1fr)", gap: theme2.styles.gap / 2, children: [
|
|
5038
|
+
weekDaysIndex.map((day) => /* @__PURE__ */ jsx14(Div_default.row, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx14(Text_default, { fontSize: 14, fontWeight: 700, textAlign: "center", children: getWeekDayName(day, true) }) }, day)),
|
|
5039
|
+
days.map((day, index) => {
|
|
5040
|
+
const thisDayDate = new Date(currentYear, currentMonth, day);
|
|
5041
|
+
const isSelected = day !== void 0 && day === currentDate?.getDate() && currentMonth === currentDate.getMonth() && currentYear === currentDate.getFullYear();
|
|
5042
|
+
const isWeekend = thisDayDate.getDay() === 6 || thisDayDate.getDay() === 0;
|
|
5043
|
+
const isDisabled = minDate && thisDayDate.getTime() < minDate.getTime() || maxDate && thisDayDate.getTime() > maxDate.getTime();
|
|
5044
|
+
return /* @__PURE__ */ jsxs9(
|
|
5045
|
+
Div_default.row,
|
|
5046
|
+
{
|
|
5047
|
+
position: "relative",
|
|
5048
|
+
width: "100%",
|
|
5049
|
+
aspectRatio: "1",
|
|
5050
|
+
alignItems: "center",
|
|
5051
|
+
justifyContent: "center",
|
|
5052
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5053
|
+
filterHover: !isDisabled ? "brightness(0.9)" : void 0,
|
|
5054
|
+
borderRadius: theme2.styles.borderRadius / 2,
|
|
5055
|
+
padding: theme2.styles.space / 2,
|
|
5056
|
+
cursor: day ? !isDisabled ? "pointer" : "not-allowed" : void 0,
|
|
5057
|
+
value: day,
|
|
5058
|
+
onClickWithValue: !isDisabled ? onClickDay : void 0,
|
|
5059
|
+
children: [
|
|
5060
|
+
day && /* @__PURE__ */ jsx14(
|
|
5061
|
+
Text_default,
|
|
5062
|
+
{
|
|
5063
|
+
fontSize: 14,
|
|
5064
|
+
textAlign: "center",
|
|
5065
|
+
color: isDisabled ? theme2.colors.textSecondary + "80" : isSelected ? theme2.colors.base : isWeekend ? theme2.colors.textSecondary : void 0,
|
|
5066
|
+
children: day
|
|
5067
|
+
}
|
|
5068
|
+
),
|
|
5069
|
+
isDisabled && /* @__PURE__ */ jsx14(
|
|
5070
|
+
Div_default,
|
|
5071
|
+
{
|
|
5072
|
+
position: "absolute",
|
|
5073
|
+
width: "60%",
|
|
5074
|
+
height: 1,
|
|
5075
|
+
top: "50%",
|
|
5076
|
+
left: "50%",
|
|
5077
|
+
backgroundColor: theme2.colors.textSecondary,
|
|
5078
|
+
borderRadius: 999,
|
|
5079
|
+
transform: "translate(-50%, -50%) rotate(45deg)"
|
|
5080
|
+
}
|
|
5081
|
+
)
|
|
5082
|
+
]
|
|
5083
|
+
},
|
|
5084
|
+
index
|
|
5085
|
+
);
|
|
5086
|
+
})
|
|
5087
|
+
] }),
|
|
5088
|
+
/* @__PURE__ */ jsxs9(Div_default.row, { width: "100%", justifyContent: "space-between", alignItems: "center", children: [
|
|
5089
|
+
/* @__PURE__ */ jsx14(Div_default, { isTabAccessed: true, cursor: "pointer", onClick: onClickClear, children: /* @__PURE__ */ jsx14(
|
|
5090
|
+
Text_default,
|
|
5091
|
+
{
|
|
5092
|
+
fontSize: 14,
|
|
5093
|
+
textDecorationHover: "underline",
|
|
5094
|
+
color: theme2.colors.textSecondary,
|
|
5095
|
+
colorHover: theme2.colors.textPrimary,
|
|
5096
|
+
children: "Clear"
|
|
5097
|
+
}
|
|
5098
|
+
) }),
|
|
5099
|
+
/* @__PURE__ */ jsx14(Div_default, { isTabAccessed: true, cursor: "pointer", onClick: onClickToday, children: /* @__PURE__ */ jsx14(
|
|
5100
|
+
Text_default,
|
|
5101
|
+
{
|
|
5102
|
+
fontSize: 14,
|
|
5103
|
+
textDecorationHover: "underline",
|
|
5104
|
+
color: theme2.colors.textSecondary,
|
|
5105
|
+
colorHover: theme2.colors.textPrimary,
|
|
5106
|
+
children: "Today"
|
|
5107
|
+
}
|
|
5108
|
+
) })
|
|
5109
|
+
] })
|
|
5110
|
+
] });
|
|
5111
|
+
}
|
|
5112
|
+
var Calendar_default = memo15(Calendar);
|
|
5113
|
+
|
|
5114
|
+
// src/components/InputField.tsx
|
|
5115
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5116
|
+
var buttonWidth = 50;
|
|
4855
5117
|
var InputElement = styled8.input.withConfig({
|
|
4856
5118
|
shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "normalStyle", "hoverStyle"].includes(prop)
|
|
4857
5119
|
})`
|
|
@@ -4883,11 +5145,20 @@ var InputElement = styled8.input.withConfig({
|
|
|
4883
5145
|
cursor: not-allowed;
|
|
4884
5146
|
}
|
|
4885
5147
|
|
|
4886
|
-
&[type="date"]
|
|
4887
|
-
&[type="datetime-local"]
|
|
4888
|
-
&[type="time"]
|
|
4889
|
-
|
|
5148
|
+
&[type="date"],
|
|
5149
|
+
&[type="datetime-local"],
|
|
5150
|
+
&[type="time"] {
|
|
5151
|
+
min-height: 48px;
|
|
4890
5152
|
-webkit-appearance: none;
|
|
5153
|
+
|
|
5154
|
+
&::-webkit-calendar-picker-indicator {
|
|
5155
|
+
display: none;
|
|
5156
|
+
-webkit-appearance: none;
|
|
5157
|
+
}
|
|
5158
|
+
|
|
5159
|
+
&::-webkit-date-and-time-value {
|
|
5160
|
+
text-align: left !important;
|
|
5161
|
+
}
|
|
4891
5162
|
}
|
|
4892
5163
|
|
|
4893
5164
|
&.react-better-html-phone-number-holder {
|
|
@@ -4993,7 +5264,7 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
4993
5264
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
4994
5265
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
4995
5266
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
4996
|
-
const onChangeElement =
|
|
5267
|
+
const onChangeElement = useCallback9(
|
|
4997
5268
|
(event) => {
|
|
4998
5269
|
const newValue = event.target.value;
|
|
4999
5270
|
if (withDebounce) {
|
|
@@ -5006,14 +5277,14 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
5006
5277
|
},
|
|
5007
5278
|
[onChange, onChangeValue, withDebounce]
|
|
5008
5279
|
);
|
|
5009
|
-
|
|
5280
|
+
useEffect7(() => {
|
|
5010
5281
|
if (!withDebounce) return;
|
|
5011
5282
|
onChangeValue?.(debouncedValue);
|
|
5012
5283
|
}, [withDebounce, onChangeValue, debouncedValue]);
|
|
5013
|
-
return /* @__PURE__ */
|
|
5014
|
-
label && /* @__PURE__ */
|
|
5015
|
-
/* @__PURE__ */
|
|
5016
|
-
leftIcon && /* @__PURE__ */
|
|
5284
|
+
return /* @__PURE__ */ jsxs10(Div_default.column, { width: "100%", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, ref: holderRef, children: [
|
|
5285
|
+
label && /* @__PURE__ */ jsx15(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
|
|
5286
|
+
/* @__PURE__ */ jsxs10(Div_default, { position: "relative", width: "100%", children: [
|
|
5287
|
+
leftIcon && /* @__PURE__ */ jsx15(
|
|
5017
5288
|
Icon_default,
|
|
5018
5289
|
{
|
|
5019
5290
|
name: leftIcon,
|
|
@@ -5025,7 +5296,7 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
5025
5296
|
zIndex: props.className?.includes("react-better-html-dropdown-open-late") ? 1002 : 1
|
|
5026
5297
|
}
|
|
5027
5298
|
),
|
|
5028
|
-
/* @__PURE__ */
|
|
5299
|
+
/* @__PURE__ */ jsx15(
|
|
5029
5300
|
InputElement,
|
|
5030
5301
|
{
|
|
5031
5302
|
theme: theme2,
|
|
@@ -5041,7 +5312,7 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
5041
5312
|
ref
|
|
5042
5313
|
}
|
|
5043
5314
|
),
|
|
5044
|
-
rightIcon ? onClickRightIcon ? /* @__PURE__ */
|
|
5315
|
+
rightIcon ? onClickRightIcon ? /* @__PURE__ */ jsx15(
|
|
5045
5316
|
Button_default.icon,
|
|
5046
5317
|
{
|
|
5047
5318
|
icon: rightIcon,
|
|
@@ -5051,7 +5322,7 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
5051
5322
|
transform: "translateY(-50%)",
|
|
5052
5323
|
onClick: onClickRightIcon
|
|
5053
5324
|
}
|
|
5054
|
-
) : /* @__PURE__ */
|
|
5325
|
+
) : /* @__PURE__ */ jsx15(
|
|
5055
5326
|
Icon_default,
|
|
5056
5327
|
{
|
|
5057
5328
|
name: rightIcon,
|
|
@@ -5064,7 +5335,7 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
5064
5335
|
) : void 0,
|
|
5065
5336
|
insideInputFieldComponent
|
|
5066
5337
|
] }),
|
|
5067
|
-
(errorText || infoText) && /* @__PURE__ */
|
|
5338
|
+
(errorText || infoText) && /* @__PURE__ */ jsx15(
|
|
5068
5339
|
Text_default,
|
|
5069
5340
|
{
|
|
5070
5341
|
as: "span",
|
|
@@ -5094,17 +5365,17 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5094
5365
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5095
5366
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5096
5367
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5097
|
-
const onChangeElement =
|
|
5368
|
+
const onChangeElement = useCallback9(
|
|
5098
5369
|
(event) => {
|
|
5099
5370
|
onChange?.(event);
|
|
5100
5371
|
onChangeValue?.(event.target.value);
|
|
5101
5372
|
},
|
|
5102
5373
|
[onChange, onChangeValue]
|
|
5103
5374
|
);
|
|
5104
|
-
return /* @__PURE__ */
|
|
5105
|
-
label && /* @__PURE__ */
|
|
5106
|
-
/* @__PURE__ */
|
|
5107
|
-
leftIcon && /* @__PURE__ */
|
|
5375
|
+
return /* @__PURE__ */ jsxs10(Div_default.column, { gap: theme2.styles.gap, children: [
|
|
5376
|
+
label && /* @__PURE__ */ jsx15(Label_default, { text: label, required, isError: !!errorText }),
|
|
5377
|
+
/* @__PURE__ */ jsxs10(Div_default, { position: "relative", width: "100%", children: [
|
|
5378
|
+
leftIcon && /* @__PURE__ */ jsx15(
|
|
5108
5379
|
Icon_default,
|
|
5109
5380
|
{
|
|
5110
5381
|
name: leftIcon,
|
|
@@ -5115,7 +5386,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5115
5386
|
pointerEvents: "none"
|
|
5116
5387
|
}
|
|
5117
5388
|
),
|
|
5118
|
-
/* @__PURE__ */
|
|
5389
|
+
/* @__PURE__ */ jsx15(
|
|
5119
5390
|
TextareaElement,
|
|
5120
5391
|
{
|
|
5121
5392
|
theme: theme2,
|
|
@@ -5131,7 +5402,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5131
5402
|
ref
|
|
5132
5403
|
}
|
|
5133
5404
|
),
|
|
5134
|
-
rightIcon ? onClickRightIcon ? /* @__PURE__ */
|
|
5405
|
+
rightIcon ? onClickRightIcon ? /* @__PURE__ */ jsx15(
|
|
5135
5406
|
Button_default.icon,
|
|
5136
5407
|
{
|
|
5137
5408
|
icon: rightIcon,
|
|
@@ -5141,7 +5412,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5141
5412
|
transform: "translateY(-50%)",
|
|
5142
5413
|
onClick: onClickRightIcon
|
|
5143
5414
|
}
|
|
5144
|
-
) : /* @__PURE__ */
|
|
5415
|
+
) : /* @__PURE__ */ jsx15(
|
|
5145
5416
|
Icon_default,
|
|
5146
5417
|
{
|
|
5147
5418
|
name: rightIcon,
|
|
@@ -5153,7 +5424,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5153
5424
|
}
|
|
5154
5425
|
) : void 0
|
|
5155
5426
|
] }),
|
|
5156
|
-
(errorText || infoText) && /* @__PURE__ */
|
|
5427
|
+
(errorText || infoText) && /* @__PURE__ */ jsx15(
|
|
5157
5428
|
Text_default,
|
|
5158
5429
|
{
|
|
5159
5430
|
as: "span",
|
|
@@ -5167,7 +5438,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5167
5438
|
] });
|
|
5168
5439
|
});
|
|
5169
5440
|
InputFieldComponent.email = forwardRef8(function Email({ ...props }, ref) {
|
|
5170
|
-
return /* @__PURE__ */
|
|
5441
|
+
return /* @__PURE__ */ jsx15(
|
|
5171
5442
|
InputFieldComponent,
|
|
5172
5443
|
{
|
|
5173
5444
|
type: "email",
|
|
@@ -5182,7 +5453,7 @@ InputFieldComponent.email = forwardRef8(function Email({ ...props }, ref) {
|
|
|
5182
5453
|
});
|
|
5183
5454
|
InputFieldComponent.password = forwardRef8(function Password({ ...props }, ref) {
|
|
5184
5455
|
const [isPassword, setIsPassword] = useBooleanState(true);
|
|
5185
|
-
return /* @__PURE__ */
|
|
5456
|
+
return /* @__PURE__ */ jsx15(
|
|
5186
5457
|
InputFieldComponent,
|
|
5187
5458
|
{
|
|
5188
5459
|
type: isPassword ? "password" : "text",
|
|
@@ -5198,20 +5469,20 @@ InputFieldComponent.password = forwardRef8(function Password({ ...props }, ref)
|
|
|
5198
5469
|
);
|
|
5199
5470
|
});
|
|
5200
5471
|
InputFieldComponent.search = forwardRef8(function Search({ ...props }, ref) {
|
|
5201
|
-
return /* @__PURE__ */
|
|
5472
|
+
return /* @__PURE__ */ jsx15(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref, ...props });
|
|
5202
5473
|
});
|
|
5203
5474
|
InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
|
|
5204
5475
|
const theme2 = useTheme();
|
|
5205
|
-
const [dropdownValue, setDropdownValue] =
|
|
5206
|
-
const [inputFieldValue, setInputFieldValue] =
|
|
5207
|
-
const renderOption =
|
|
5208
|
-
(option, index, isSelected) => /* @__PURE__ */
|
|
5209
|
-
/* @__PURE__ */
|
|
5210
|
-
/* @__PURE__ */
|
|
5476
|
+
const [dropdownValue, setDropdownValue] = useState7();
|
|
5477
|
+
const [inputFieldValue, setInputFieldValue] = useState7(value?.toString() ?? "");
|
|
5478
|
+
const renderOption = useCallback9(
|
|
5479
|
+
(option, index, isSelected) => /* @__PURE__ */ jsxs10(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
|
|
5480
|
+
/* @__PURE__ */ jsx15(Image_default, { src: `https://flagcdn.com/w80/${option.data?.code.toString().toLowerCase()}.webp`, width: 20 }),
|
|
5481
|
+
/* @__PURE__ */ jsx15(Text_default, { children: option.label })
|
|
5211
5482
|
] }),
|
|
5212
5483
|
[]
|
|
5213
5484
|
);
|
|
5214
|
-
const onChangeValueElement =
|
|
5485
|
+
const onChangeValueElement = useCallback9(
|
|
5215
5486
|
(value2) => {
|
|
5216
5487
|
const readyValue = value2.replace(/\D/g, "");
|
|
5217
5488
|
setInputFieldValue(readyValue);
|
|
@@ -5219,7 +5490,7 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
|
|
|
5219
5490
|
},
|
|
5220
5491
|
[onChangeValue, dropdownValue]
|
|
5221
5492
|
);
|
|
5222
|
-
const options =
|
|
5493
|
+
const options = useMemo5(
|
|
5223
5494
|
() => countries.map((country) => ({
|
|
5224
5495
|
value: country.phoneNumberExtension,
|
|
5225
5496
|
label: `+${country.phoneNumberExtension}`,
|
|
@@ -5227,13 +5498,13 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
|
|
|
5227
5498
|
})),
|
|
5228
5499
|
[]
|
|
5229
5500
|
);
|
|
5230
|
-
const defaultValue =
|
|
5501
|
+
const defaultValue = useMemo5(() => {
|
|
5231
5502
|
const thisTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
5232
5503
|
const initialDefaultValue = options.find((option) => option.data?.timeZone === thisTimeZone)?.value ?? "";
|
|
5233
5504
|
setDropdownValue(initialDefaultValue);
|
|
5234
5505
|
return initialDefaultValue;
|
|
5235
5506
|
}, [options]);
|
|
5236
|
-
|
|
5507
|
+
useEffect7(() => {
|
|
5237
5508
|
if (value === void 0 || value === null) return;
|
|
5238
5509
|
const newValue = value.toString();
|
|
5239
5510
|
const country = countries.find(
|
|
@@ -5249,10 +5520,10 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
|
|
|
5249
5520
|
setDropdownValue(country.phoneNumberExtension);
|
|
5250
5521
|
setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
|
|
5251
5522
|
}, [value]);
|
|
5252
|
-
return /* @__PURE__ */
|
|
5253
|
-
label && /* @__PURE__ */
|
|
5254
|
-
/* @__PURE__ */
|
|
5255
|
-
/* @__PURE__ */
|
|
5523
|
+
return /* @__PURE__ */ jsxs10(Div_default.column, { width: "100%", gap: theme2.styles.gap, children: [
|
|
5524
|
+
label && /* @__PURE__ */ jsx15(Label_default, { text: label, color: labelColor, required: props.required, isError: !!props.errorText }),
|
|
5525
|
+
/* @__PURE__ */ jsxs10(Div_default.row, { children: [
|
|
5526
|
+
/* @__PURE__ */ jsx15(
|
|
5256
5527
|
Dropdown_default,
|
|
5257
5528
|
{
|
|
5258
5529
|
options,
|
|
@@ -5268,7 +5539,7 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
|
|
|
5268
5539
|
withoutClearButton: true
|
|
5269
5540
|
}
|
|
5270
5541
|
),
|
|
5271
|
-
/* @__PURE__ */
|
|
5542
|
+
/* @__PURE__ */ jsx15(
|
|
5272
5543
|
InputFieldComponent,
|
|
5273
5544
|
{
|
|
5274
5545
|
placeholder: label ?? "Phone number",
|
|
@@ -5282,31 +5553,38 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
|
|
|
5282
5553
|
] })
|
|
5283
5554
|
] });
|
|
5284
5555
|
});
|
|
5285
|
-
InputFieldComponent.date = forwardRef8(function
|
|
5556
|
+
InputFieldComponent.date = forwardRef8(function Date2({ minDate, maxDate, ...props }, ref) {
|
|
5286
5557
|
const theme2 = useTheme();
|
|
5287
5558
|
const holderRef = useRef4(null);
|
|
5288
|
-
const
|
|
5289
|
-
|
|
5559
|
+
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5560
|
+
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5561
|
+
const onChange = useCallback9(
|
|
5562
|
+
(date) => {
|
|
5563
|
+
inputFieldProps.onChangeValue?.(date ?? "");
|
|
5564
|
+
setInternalValue(date ?? "");
|
|
5565
|
+
},
|
|
5566
|
+
[inputFieldProps.onChangeValue]
|
|
5567
|
+
);
|
|
5568
|
+
return /* @__PURE__ */ jsx15(
|
|
5290
5569
|
InputFieldComponent,
|
|
5291
5570
|
{
|
|
5292
5571
|
type: "date",
|
|
5293
|
-
insideInputFieldComponent: /* @__PURE__ */
|
|
5572
|
+
insideInputFieldComponent: !isMobileIOS ? /* @__PURE__ */ jsx15(
|
|
5294
5573
|
Div_default,
|
|
5295
5574
|
{
|
|
5296
5575
|
position: "absolute",
|
|
5297
5576
|
top: "100%",
|
|
5298
5577
|
left: 0,
|
|
5299
|
-
width: "
|
|
5300
|
-
maxHeight: 300,
|
|
5578
|
+
width: "fit-content",
|
|
5301
5579
|
backgroundColor: theme2.colors.backgroundContent,
|
|
5302
5580
|
borderBottomLeftRadius: theme2.styles.borderRadius,
|
|
5303
5581
|
borderBottomRightRadius: theme2.styles.borderRadius,
|
|
5304
5582
|
boxShadow: "0px 10px 20px #00000020",
|
|
5305
|
-
|
|
5583
|
+
userSelect: "none",
|
|
5306
5584
|
...insideInputFieldComponentProps,
|
|
5307
|
-
children:
|
|
5585
|
+
children: /* @__PURE__ */ jsx15(Calendar_default, { value: internalValue, minDate, maxDate, onChange })
|
|
5308
5586
|
}
|
|
5309
|
-
),
|
|
5587
|
+
) : void 0,
|
|
5310
5588
|
holderRef,
|
|
5311
5589
|
ref,
|
|
5312
5590
|
...props,
|
|
@@ -5314,31 +5592,152 @@ InputFieldComponent.date = forwardRef8(function Date({ className, onFocus, onBlu
|
|
|
5314
5592
|
}
|
|
5315
5593
|
);
|
|
5316
5594
|
});
|
|
5317
|
-
InputFieldComponent.dateTime = forwardRef8(function DateTime({
|
|
5595
|
+
InputFieldComponent.dateTime = forwardRef8(function DateTime({ minDate, maxDate, ...props }, ref) {
|
|
5318
5596
|
const theme2 = useTheme();
|
|
5319
5597
|
const holderRef = useRef4(null);
|
|
5320
|
-
const
|
|
5321
|
-
|
|
5598
|
+
const selectedHourRef = useRef4(null);
|
|
5599
|
+
const selectedMinuteRef = useRef4(null);
|
|
5600
|
+
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5601
|
+
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5602
|
+
const onChange = useCallback9(
|
|
5603
|
+
(date) => {
|
|
5604
|
+
const newValue = date ? `${date}T${internalValue?.toString().split("T")[1] ?? "00:00"}` : "";
|
|
5605
|
+
inputFieldProps.onChangeValue?.(newValue);
|
|
5606
|
+
setInternalValue(newValue);
|
|
5607
|
+
},
|
|
5608
|
+
[internalValue, inputFieldProps.onChangeValue]
|
|
5609
|
+
);
|
|
5610
|
+
const onClickHour = useCallback9(
|
|
5611
|
+
(hour) => {
|
|
5612
|
+
const newTime = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
5613
|
+
const today = `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
5614
|
+
const newValue = `${(internalValue.trim() || today)?.toString().split("T")[0]}T${newTime}`;
|
|
5615
|
+
inputFieldProps.onChangeValue?.(newValue);
|
|
5616
|
+
setInternalValue(newValue);
|
|
5617
|
+
},
|
|
5618
|
+
[internalValue, inputFieldProps.onChangeValue]
|
|
5619
|
+
);
|
|
5620
|
+
const onClickMinute = useCallback9(
|
|
5621
|
+
(minute) => {
|
|
5622
|
+
const newTime = `${internalValue?.toString().split("T")?.[1]?.split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
5623
|
+
const today = `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
5624
|
+
const newValue = `${(internalValue.trim() || today)?.toString().split("T")[0]}T${newTime}`;
|
|
5625
|
+
console.log(newValue);
|
|
5626
|
+
inputFieldProps.onChangeValue?.(newValue);
|
|
5627
|
+
setInternalValue(newValue);
|
|
5628
|
+
},
|
|
5629
|
+
[internalValue, inputFieldProps.onChangeValue]
|
|
5630
|
+
);
|
|
5631
|
+
useEffect7(() => {
|
|
5632
|
+
if (isOpen && selectedHourRef.current)
|
|
5633
|
+
selectedHourRef.current.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
5634
|
+
if (isOpen && selectedMinuteRef.current)
|
|
5635
|
+
selectedMinuteRef.current.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
5636
|
+
}, [isOpen]);
|
|
5637
|
+
const valueHour = parseInt(internalValue?.toString().split("T")?.[1]?.split(":")?.[0]).toString();
|
|
5638
|
+
const valueMinute = parseInt(internalValue?.toString().split("T")?.[1]?.split(":")?.[1]).toString();
|
|
5639
|
+
const topSpacing = 32 + theme2.styles.space / 2 + theme2.styles.gap;
|
|
5640
|
+
return /* @__PURE__ */ jsx15(
|
|
5322
5641
|
InputFieldComponent,
|
|
5323
5642
|
{
|
|
5324
5643
|
type: "datetime-local",
|
|
5325
|
-
insideInputFieldComponent: /* @__PURE__ */
|
|
5644
|
+
insideInputFieldComponent: !isMobileIOS ? /* @__PURE__ */ jsx15(
|
|
5326
5645
|
Div_default,
|
|
5327
5646
|
{
|
|
5328
5647
|
position: "absolute",
|
|
5329
5648
|
top: "100%",
|
|
5330
5649
|
left: 0,
|
|
5331
|
-
width: "
|
|
5332
|
-
maxHeight: 300,
|
|
5650
|
+
width: "fit-content",
|
|
5333
5651
|
backgroundColor: theme2.colors.backgroundContent,
|
|
5334
5652
|
borderBottomLeftRadius: theme2.styles.borderRadius,
|
|
5335
5653
|
borderBottomRightRadius: theme2.styles.borderRadius,
|
|
5336
5654
|
boxShadow: "0px 10px 20px #00000020",
|
|
5337
|
-
|
|
5655
|
+
overflow: "hidden",
|
|
5656
|
+
userSelect: "none",
|
|
5338
5657
|
...insideInputFieldComponentProps,
|
|
5339
|
-
children:
|
|
5658
|
+
children: /* @__PURE__ */ jsxs10(Div_default.row, { gap: theme2.styles.space, children: [
|
|
5659
|
+
/* @__PURE__ */ jsx15(Calendar_default, { value: internalValue, minDate, maxDate, onChange }),
|
|
5660
|
+
/* @__PURE__ */ jsxs10(
|
|
5661
|
+
Div_default.row,
|
|
5662
|
+
{
|
|
5663
|
+
height: 276,
|
|
5664
|
+
gap: theme2.styles.gap / 2,
|
|
5665
|
+
paddingTop: topSpacing,
|
|
5666
|
+
paddingBottom: theme2.styles.space / 2,
|
|
5667
|
+
paddingRight: theme2.styles.space / 2,
|
|
5668
|
+
children: [
|
|
5669
|
+
/* @__PURE__ */ jsxs10(Div_default, { height: "100%", children: [
|
|
5670
|
+
/* @__PURE__ */ jsx15(Text_default, { fontSize: 14, fontWeight: 700, textAlign: "center", marginBottom: theme2.styles.gap / 2, children: "H" }),
|
|
5671
|
+
/* @__PURE__ */ jsx15(
|
|
5672
|
+
Div_default,
|
|
5673
|
+
{
|
|
5674
|
+
className: "react-better-html-no-scrollbar",
|
|
5675
|
+
width: buttonWidth,
|
|
5676
|
+
height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
|
|
5677
|
+
overflowY: "auto",
|
|
5678
|
+
children: hours.map((hour) => {
|
|
5679
|
+
const isSelected = hour.toString() === valueHour;
|
|
5680
|
+
return /* @__PURE__ */ jsx15(
|
|
5681
|
+
Div_default.row,
|
|
5682
|
+
{
|
|
5683
|
+
alignItems: "center",
|
|
5684
|
+
justifyContent: "center",
|
|
5685
|
+
color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
5686
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5687
|
+
borderRadius: theme2.styles.borderRadius / 2,
|
|
5688
|
+
filterHover: "brightness(0.9)",
|
|
5689
|
+
cursor: "pointer",
|
|
5690
|
+
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5691
|
+
value: hour,
|
|
5692
|
+
onClickWithValue: onClickHour,
|
|
5693
|
+
ref: isSelected ? selectedHourRef : void 0,
|
|
5694
|
+
children: /* @__PURE__ */ jsx15(Text_default, { textAlign: "center", children: hour.toString().padStart(2, "0") })
|
|
5695
|
+
},
|
|
5696
|
+
hour
|
|
5697
|
+
);
|
|
5698
|
+
})
|
|
5699
|
+
}
|
|
5700
|
+
)
|
|
5701
|
+
] }),
|
|
5702
|
+
/* @__PURE__ */ jsxs10(Div_default, { height: "100%", children: [
|
|
5703
|
+
/* @__PURE__ */ jsx15(Text_default, { fontSize: 14, fontWeight: 700, textAlign: "center", marginBottom: theme2.styles.gap / 2, children: "M" }),
|
|
5704
|
+
/* @__PURE__ */ jsx15(
|
|
5705
|
+
Div_default,
|
|
5706
|
+
{
|
|
5707
|
+
className: "react-better-html-no-scrollbar",
|
|
5708
|
+
width: buttonWidth,
|
|
5709
|
+
height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
|
|
5710
|
+
overflowY: "auto",
|
|
5711
|
+
children: minutes.map((minute) => {
|
|
5712
|
+
const isSelected = minute.toString() === valueMinute;
|
|
5713
|
+
return /* @__PURE__ */ jsx15(
|
|
5714
|
+
Div_default.row,
|
|
5715
|
+
{
|
|
5716
|
+
alignItems: "center",
|
|
5717
|
+
justifyContent: "center",
|
|
5718
|
+
color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
5719
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5720
|
+
borderRadius: theme2.styles.borderRadius / 2,
|
|
5721
|
+
filterHover: "brightness(0.9)",
|
|
5722
|
+
cursor: "pointer",
|
|
5723
|
+
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5724
|
+
value: minute,
|
|
5725
|
+
onClickWithValue: onClickMinute,
|
|
5726
|
+
ref: isSelected ? selectedMinuteRef : void 0,
|
|
5727
|
+
children: /* @__PURE__ */ jsx15(Text_default, { textAlign: "center", children: minute.toString().padStart(2, "0") })
|
|
5728
|
+
},
|
|
5729
|
+
minute
|
|
5730
|
+
);
|
|
5731
|
+
})
|
|
5732
|
+
}
|
|
5733
|
+
)
|
|
5734
|
+
] })
|
|
5735
|
+
]
|
|
5736
|
+
}
|
|
5737
|
+
)
|
|
5738
|
+
] })
|
|
5340
5739
|
}
|
|
5341
|
-
),
|
|
5740
|
+
) : void 0,
|
|
5342
5741
|
holderRef,
|
|
5343
5742
|
ref,
|
|
5344
5743
|
...props,
|
|
@@ -5351,8 +5750,9 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5351
5750
|
const holderRef = useRef4(null);
|
|
5352
5751
|
const selectedHourRef = useRef4(null);
|
|
5353
5752
|
const selectedMinuteRef = useRef4(null);
|
|
5354
|
-
const
|
|
5355
|
-
const
|
|
5753
|
+
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5754
|
+
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5755
|
+
const onClickHour = useCallback9(
|
|
5356
5756
|
(hour) => {
|
|
5357
5757
|
const value = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
5358
5758
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -5360,7 +5760,7 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5360
5760
|
},
|
|
5361
5761
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5362
5762
|
);
|
|
5363
|
-
const onClickMinute =
|
|
5763
|
+
const onClickMinute = useCallback9(
|
|
5364
5764
|
(minute) => {
|
|
5365
5765
|
const value = `${internalValue?.toString().split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
5366
5766
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -5368,7 +5768,7 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5368
5768
|
},
|
|
5369
5769
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5370
5770
|
);
|
|
5371
|
-
|
|
5771
|
+
useEffect7(() => {
|
|
5372
5772
|
if (isOpen && selectedHourRef.current)
|
|
5373
5773
|
selectedHourRef.current.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
5374
5774
|
if (isOpen && selectedMinuteRef.current)
|
|
@@ -5376,12 +5776,11 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5376
5776
|
}, [isOpen]);
|
|
5377
5777
|
const valueHour = parseInt(internalValue?.toString().split(":")?.[0]).toString();
|
|
5378
5778
|
const valueMinute = parseInt(internalValue?.toString().split(":")?.[1]).toString();
|
|
5379
|
-
|
|
5380
|
-
return /* @__PURE__ */ jsx14(
|
|
5779
|
+
return /* @__PURE__ */ jsx15(
|
|
5381
5780
|
InputFieldComponent,
|
|
5382
5781
|
{
|
|
5383
5782
|
type: "time",
|
|
5384
|
-
insideInputFieldComponent: /* @__PURE__ */
|
|
5783
|
+
insideInputFieldComponent: !isMobileIOS ? /* @__PURE__ */ jsx15(
|
|
5385
5784
|
Div_default,
|
|
5386
5785
|
{
|
|
5387
5786
|
position: "absolute",
|
|
@@ -5394,11 +5793,12 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5394
5793
|
borderBottomRightRadius: theme2.styles.borderRadius,
|
|
5395
5794
|
boxShadow: "0px 10px 20px #00000020",
|
|
5396
5795
|
overflowY: "auto",
|
|
5796
|
+
userSelect: "none",
|
|
5397
5797
|
...insideInputFieldComponentProps,
|
|
5398
|
-
children: /* @__PURE__ */
|
|
5399
|
-
/* @__PURE__ */
|
|
5798
|
+
children: /* @__PURE__ */ jsxs10(Div_default.row, { height: "100%", children: [
|
|
5799
|
+
/* @__PURE__ */ jsx15(Div_default, { className: "react-better-html-no-scrollbar", width: buttonWidth, height: "100%", overflowY: "auto", children: hours.map((hour) => {
|
|
5400
5800
|
const isSelected = hour.toString() === valueHour;
|
|
5401
|
-
return /* @__PURE__ */
|
|
5801
|
+
return /* @__PURE__ */ jsx15(
|
|
5402
5802
|
Div_default.row,
|
|
5403
5803
|
{
|
|
5404
5804
|
alignItems: "center",
|
|
@@ -5411,14 +5811,14 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5411
5811
|
value: hour,
|
|
5412
5812
|
onClickWithValue: onClickHour,
|
|
5413
5813
|
ref: isSelected ? selectedHourRef : void 0,
|
|
5414
|
-
children: /* @__PURE__ */
|
|
5814
|
+
children: /* @__PURE__ */ jsx15(Text_default, { textAlign: "center", children: hour.toString().padStart(2, "0") })
|
|
5415
5815
|
},
|
|
5416
5816
|
hour
|
|
5417
5817
|
);
|
|
5418
5818
|
}) }),
|
|
5419
|
-
/* @__PURE__ */
|
|
5819
|
+
/* @__PURE__ */ jsx15(Div_default, { className: "react-better-html-no-scrollbar", width: buttonWidth, height: "100%", overflowY: "auto", children: minutes.map((minute) => {
|
|
5420
5820
|
const isSelected = minute.toString() === valueMinute;
|
|
5421
|
-
return /* @__PURE__ */
|
|
5821
|
+
return /* @__PURE__ */ jsx15(
|
|
5422
5822
|
Div_default.row,
|
|
5423
5823
|
{
|
|
5424
5824
|
alignItems: "center",
|
|
@@ -5431,14 +5831,14 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5431
5831
|
value: minute,
|
|
5432
5832
|
onClickWithValue: onClickMinute,
|
|
5433
5833
|
ref: isSelected ? selectedMinuteRef : void 0,
|
|
5434
|
-
children: /* @__PURE__ */
|
|
5834
|
+
children: /* @__PURE__ */ jsx15(Text_default, { textAlign: "center", children: minute.toString().padStart(2, "0") })
|
|
5435
5835
|
},
|
|
5436
5836
|
minute
|
|
5437
5837
|
);
|
|
5438
5838
|
}) })
|
|
5439
5839
|
] })
|
|
5440
5840
|
}
|
|
5441
|
-
),
|
|
5841
|
+
) : void 0,
|
|
5442
5842
|
holderRef,
|
|
5443
5843
|
ref,
|
|
5444
5844
|
...props,
|
|
@@ -5447,7 +5847,7 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5447
5847
|
}
|
|
5448
5848
|
);
|
|
5449
5849
|
});
|
|
5450
|
-
var InputField2 =
|
|
5850
|
+
var InputField2 = memo16(InputFieldComponent);
|
|
5451
5851
|
InputField2.multiline = InputFieldComponent.multiline;
|
|
5452
5852
|
InputField2.email = InputFieldComponent.email;
|
|
5453
5853
|
InputField2.password = InputFieldComponent.password;
|
|
@@ -5459,9 +5859,9 @@ InputField2.time = InputFieldComponent.time;
|
|
|
5459
5859
|
var InputField_default = InputField2;
|
|
5460
5860
|
|
|
5461
5861
|
// src/components/ToggleInput.tsx
|
|
5462
|
-
import { forwardRef as forwardRef9, useCallback as
|
|
5862
|
+
import { forwardRef as forwardRef9, useCallback as useCallback10, useState as useState8 } from "react";
|
|
5463
5863
|
import styled9 from "styled-components";
|
|
5464
|
-
import { jsx as
|
|
5864
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5465
5865
|
var componentSize = 26;
|
|
5466
5866
|
var switchComponentBallGap = 3;
|
|
5467
5867
|
var switchComponentMouseDownDifference = 4;
|
|
@@ -5571,8 +5971,8 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5571
5971
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5572
5972
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5573
5973
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5574
|
-
const [internalChecked, setInternalChecked] =
|
|
5575
|
-
const onChangeElement =
|
|
5974
|
+
const [internalChecked, setInternalChecked] = useState8(false);
|
|
5975
|
+
const onChangeElement = useCallback10(
|
|
5576
5976
|
(event) => {
|
|
5577
5977
|
const newIsChecked = event.target.checked;
|
|
5578
5978
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
@@ -5581,16 +5981,16 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5581
5981
|
[onChange, controlledChecked, value]
|
|
5582
5982
|
);
|
|
5583
5983
|
const checked = controlledChecked ?? internalChecked;
|
|
5584
|
-
const onClickText =
|
|
5984
|
+
const onClickText = useCallback10(() => {
|
|
5585
5985
|
const newIsChecked = !checked;
|
|
5586
5986
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
5587
5987
|
onChange?.(newIsChecked, value);
|
|
5588
5988
|
}, [checked, controlledChecked, onChange, value]);
|
|
5589
|
-
return /* @__PURE__ */
|
|
5590
|
-
label && /* @__PURE__ */
|
|
5591
|
-
/* @__PURE__ */
|
|
5592
|
-
/* @__PURE__ */
|
|
5593
|
-
/* @__PURE__ */
|
|
5989
|
+
return /* @__PURE__ */ jsxs11(Div_default.column, { width: "100%", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
|
|
5990
|
+
label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
|
|
5991
|
+
/* @__PURE__ */ jsxs11(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
|
|
5992
|
+
/* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", alignItems: "center", children: [
|
|
5993
|
+
/* @__PURE__ */ jsx16(
|
|
5594
5994
|
InputElement2,
|
|
5595
5995
|
{
|
|
5596
5996
|
theme: theme2,
|
|
@@ -5603,7 +6003,7 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5603
6003
|
...restProps
|
|
5604
6004
|
}
|
|
5605
6005
|
),
|
|
5606
|
-
props.type === "checkbox" ? /* @__PURE__ */
|
|
6006
|
+
props.type === "checkbox" ? /* @__PURE__ */ jsx16(
|
|
5607
6007
|
Icon_default,
|
|
5608
6008
|
{
|
|
5609
6009
|
name: "check",
|
|
@@ -5617,7 +6017,7 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5617
6017
|
pointerEvents: "none",
|
|
5618
6018
|
transition: theme2.styles.transition
|
|
5619
6019
|
}
|
|
5620
|
-
) : props.type === "radio" ? /* @__PURE__ */
|
|
6020
|
+
) : props.type === "radio" ? /* @__PURE__ */ jsx16(
|
|
5621
6021
|
Div_default,
|
|
5622
6022
|
{
|
|
5623
6023
|
position: "absolute",
|
|
@@ -5633,15 +6033,15 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5633
6033
|
}
|
|
5634
6034
|
) : void 0
|
|
5635
6035
|
] }),
|
|
5636
|
-
text && /* @__PURE__ */
|
|
6036
|
+
text && /* @__PURE__ */ jsxs11(Text_default, { color, userSelect: "none", cursor: "pointer", onClick: onClickText, children: [
|
|
5637
6037
|
text,
|
|
5638
|
-
required && !label && /* @__PURE__ */
|
|
6038
|
+
required && !label && /* @__PURE__ */ jsxs11(Text_default, { as: "span", fontSize: 16, color: theme2.colors.error, children: [
|
|
5639
6039
|
" ",
|
|
5640
6040
|
"*"
|
|
5641
6041
|
] })
|
|
5642
6042
|
] })
|
|
5643
6043
|
] }),
|
|
5644
|
-
(errorText || infoText) && /* @__PURE__ */
|
|
6044
|
+
(errorText || infoText) && /* @__PURE__ */ jsx16(
|
|
5645
6045
|
Text_default,
|
|
5646
6046
|
{
|
|
5647
6047
|
as: "span",
|
|
@@ -5655,10 +6055,10 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5655
6055
|
});
|
|
5656
6056
|
var ToggleInput_default = {
|
|
5657
6057
|
checkbox: forwardRef9(function Checkbox(props, ref) {
|
|
5658
|
-
return /* @__PURE__ */
|
|
6058
|
+
return /* @__PURE__ */ jsx16(ToggleInputComponent, { type: "checkbox", ref, ...props });
|
|
5659
6059
|
}),
|
|
5660
6060
|
radiobutton: forwardRef9(function RadioButton(props, ref) {
|
|
5661
|
-
return /* @__PURE__ */
|
|
6061
|
+
return /* @__PURE__ */ jsx16(ToggleInputComponent, { type: "radio", ref, ...props });
|
|
5662
6062
|
}),
|
|
5663
6063
|
switch: forwardRef9(function Switch({
|
|
5664
6064
|
label,
|
|
@@ -5681,15 +6081,15 @@ var ToggleInput_default = {
|
|
|
5681
6081
|
const [internalChecked, setInternalChecked] = useBooleanState();
|
|
5682
6082
|
const [isMouseDown, setIsMouseDown] = useBooleanState();
|
|
5683
6083
|
const checked = controlledChecked ?? internalChecked;
|
|
5684
|
-
const onClickElement =
|
|
6084
|
+
const onClickElement = useCallback10(() => {
|
|
5685
6085
|
if (disabled) return;
|
|
5686
6086
|
const newIsChecked = !checked;
|
|
5687
6087
|
if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
|
|
5688
6088
|
onChange?.(newIsChecked, value);
|
|
5689
6089
|
}, [disabled, checked, onChange, controlledChecked, value]);
|
|
5690
|
-
return /* @__PURE__ */
|
|
5691
|
-
label && /* @__PURE__ */
|
|
5692
|
-
/* @__PURE__ */
|
|
6090
|
+
return /* @__PURE__ */ jsxs11(Div_default.column, { width: "fit-content", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
|
|
6091
|
+
label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
|
|
6092
|
+
/* @__PURE__ */ jsx16(
|
|
5693
6093
|
Div_default.row,
|
|
5694
6094
|
{
|
|
5695
6095
|
alignItems: "center",
|
|
@@ -5700,7 +6100,7 @@ var ToggleInput_default = {
|
|
|
5700
6100
|
onTouchStart: setIsMouseDown.setTrue,
|
|
5701
6101
|
onTouchEnd: setIsMouseDown.setFalse,
|
|
5702
6102
|
onTouchCancel: setIsMouseDown.setFalse,
|
|
5703
|
-
children: /* @__PURE__ */
|
|
6103
|
+
children: /* @__PURE__ */ jsx16(
|
|
5704
6104
|
SwitchElement,
|
|
5705
6105
|
{
|
|
5706
6106
|
theme: theme2,
|
|
@@ -5716,7 +6116,7 @@ var ToggleInput_default = {
|
|
|
5716
6116
|
)
|
|
5717
6117
|
}
|
|
5718
6118
|
),
|
|
5719
|
-
(errorText || infoText) && /* @__PURE__ */
|
|
6119
|
+
(errorText || infoText) && /* @__PURE__ */ jsx16(
|
|
5720
6120
|
Text_default,
|
|
5721
6121
|
{
|
|
5722
6122
|
as: "span",
|
|
@@ -5731,8 +6131,8 @@ var ToggleInput_default = {
|
|
|
5731
6131
|
};
|
|
5732
6132
|
|
|
5733
6133
|
// src/components/Form.tsx
|
|
5734
|
-
import { memo as
|
|
5735
|
-
import { jsx as
|
|
6134
|
+
import { memo as memo17, useMemo as useMemo6 } from "react";
|
|
6135
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
5736
6136
|
function Form({
|
|
5737
6137
|
form,
|
|
5738
6138
|
submitButtonText,
|
|
@@ -5749,7 +6149,7 @@ function Form({
|
|
|
5749
6149
|
...props
|
|
5750
6150
|
}) {
|
|
5751
6151
|
const theme2 = useTheme();
|
|
5752
|
-
const submitButtonIsDisabledInternal =
|
|
6152
|
+
const submitButtonIsDisabledInternal = useMemo6(() => {
|
|
5753
6153
|
if (!form || !form.requiredFields) return false;
|
|
5754
6154
|
return Object.entries(form.values).some(
|
|
5755
6155
|
([key, value]) => form.requiredFields?.includes(key) && (value === void 0 || value === null || value?.toString().trim() === "")
|
|
@@ -5757,9 +6157,9 @@ function Form({
|
|
|
5757
6157
|
}, [form]);
|
|
5758
6158
|
const SubmitButtonTag = isDestructive ? Button_default.destructive : Button_default;
|
|
5759
6159
|
const submitButtonIsDisabledFinal = submitButtonIsDisabled || submitButtonIsDisabledInternal;
|
|
5760
|
-
return /* @__PURE__ */
|
|
5761
|
-
gap !== void 0 ? /* @__PURE__ */
|
|
5762
|
-
submitButtonText && /* @__PURE__ */
|
|
6160
|
+
return /* @__PURE__ */ jsx17(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ jsxs12("form", { onSubmit: onSubmit ?? form?.onSubmit, children: [
|
|
6161
|
+
gap !== void 0 ? /* @__PURE__ */ jsx17(Div_default.column, { gap, children }) : children,
|
|
6162
|
+
submitButtonText && /* @__PURE__ */ jsxs12(
|
|
5763
6163
|
Div_default.row,
|
|
5764
6164
|
{
|
|
5765
6165
|
alignItems: "center",
|
|
@@ -5767,8 +6167,8 @@ function Form({
|
|
|
5767
6167
|
gap: theme2.styles.gap,
|
|
5768
6168
|
marginTop: theme2.styles.space,
|
|
5769
6169
|
children: [
|
|
5770
|
-
onClickCancel && /* @__PURE__ */
|
|
5771
|
-
/* @__PURE__ */
|
|
6170
|
+
onClickCancel && /* @__PURE__ */ jsx17(Button_default.secondary, { text: "Cancel", onClick: onClickCancel }),
|
|
6171
|
+
/* @__PURE__ */ jsx17(
|
|
5772
6172
|
SubmitButtonTag,
|
|
5773
6173
|
{
|
|
5774
6174
|
text: submitButtonText,
|
|
@@ -5784,19 +6184,19 @@ function Form({
|
|
|
5784
6184
|
)
|
|
5785
6185
|
] }) });
|
|
5786
6186
|
}
|
|
5787
|
-
var Form_default =
|
|
6187
|
+
var Form_default = memo17(Form);
|
|
5788
6188
|
|
|
5789
6189
|
// src/components/FormRow.tsx
|
|
5790
|
-
import { forwardRef as forwardRef10, memo as
|
|
5791
|
-
import { jsx as
|
|
6190
|
+
import { forwardRef as forwardRef10, memo as memo18 } from "react";
|
|
6191
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5792
6192
|
var FormRowComponent = forwardRef10(function FormRow({ oneItemOnly, noBreakingPoint, gap, children, ...props }, ref) {
|
|
5793
6193
|
const theme2 = useTheme();
|
|
5794
6194
|
const mediaQuery = useMediaQuery();
|
|
5795
6195
|
const breakingPoint = !noBreakingPoint ? mediaQuery.size900 : false;
|
|
5796
6196
|
const readyGap = breakingPoint || noBreakingPoint && mediaQuery.size900 ? theme2.styles.gap : theme2.styles.space * 2;
|
|
5797
|
-
return /* @__PURE__ */
|
|
6197
|
+
return /* @__PURE__ */ jsxs13(Div_default.row, { alignItems: "center", gap: gap ?? readyGap, invertFlexDirection: breakingPoint, ...props, ref, children: [
|
|
5798
6198
|
children,
|
|
5799
|
-
oneItemOnly && /* @__PURE__ */
|
|
6199
|
+
oneItemOnly && /* @__PURE__ */ jsx18(Div_default, { width: "100%" })
|
|
5800
6200
|
] });
|
|
5801
6201
|
});
|
|
5802
6202
|
FormRowComponent.withTitle = forwardRef10(function WithTitle({
|
|
@@ -5813,15 +6213,15 @@ FormRowComponent.withTitle = forwardRef10(function WithTitle({
|
|
|
5813
6213
|
}, ref) {
|
|
5814
6214
|
const theme2 = useTheme();
|
|
5815
6215
|
const mediaQuery = useMediaQuery();
|
|
5816
|
-
return /* @__PURE__ */
|
|
5817
|
-
/* @__PURE__ */
|
|
5818
|
-
icon && /* @__PURE__ */
|
|
5819
|
-
/* @__PURE__ */
|
|
5820
|
-
/* @__PURE__ */
|
|
5821
|
-
description && /* @__PURE__ */
|
|
6216
|
+
return /* @__PURE__ */ jsxs13(FormRowComponent, { ...props, ref, children: [
|
|
6217
|
+
/* @__PURE__ */ jsxs13(Div_default.row, { width: "100%", alignItems: "center", gap: theme2.styles.space, children: [
|
|
6218
|
+
icon && /* @__PURE__ */ jsx18(Icon_default, { name: icon }),
|
|
6219
|
+
/* @__PURE__ */ jsxs13(Div_default.column, { flex: 1, gap: theme2.styles.gap / 2, children: [
|
|
6220
|
+
/* @__PURE__ */ jsx18(Text_default, { as: "h3", children: title }),
|
|
6221
|
+
description && /* @__PURE__ */ jsx18(Text_default, { color: theme2.colors.textSecondary, children: description })
|
|
5822
6222
|
] })
|
|
5823
6223
|
] }),
|
|
5824
|
-
/* @__PURE__ */
|
|
6224
|
+
/* @__PURE__ */ jsxs13(
|
|
5825
6225
|
Div_default.row,
|
|
5826
6226
|
{
|
|
5827
6227
|
width: props.noBreakingPoint && mediaQuery.size900 ? void 0 : "100%",
|
|
@@ -5829,22 +6229,22 @@ FormRowComponent.withTitle = forwardRef10(function WithTitle({
|
|
|
5829
6229
|
gap: theme2.styles.gap,
|
|
5830
6230
|
children: [
|
|
5831
6231
|
children,
|
|
5832
|
-
withActions && /* @__PURE__ */
|
|
5833
|
-
onClickReset && /* @__PURE__ */
|
|
5834
|
-
/* @__PURE__ */
|
|
6232
|
+
withActions && /* @__PURE__ */ jsxs13(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
|
|
6233
|
+
onClickReset && /* @__PURE__ */ jsx18(Button_default.icon, { icon: "XMark", loaderName: resetButtonLoaderName, onClick: onClickReset }),
|
|
6234
|
+
/* @__PURE__ */ jsx18(Button_default.icon, { icon: "check", loaderName: saveButtonLoaderName, onClick: onClickSave })
|
|
5835
6235
|
] })
|
|
5836
6236
|
]
|
|
5837
6237
|
}
|
|
5838
6238
|
)
|
|
5839
6239
|
] });
|
|
5840
6240
|
});
|
|
5841
|
-
var FormRow2 =
|
|
6241
|
+
var FormRow2 = memo18(FormRowComponent);
|
|
5842
6242
|
FormRow2.withTitle = FormRowComponent.withTitle;
|
|
5843
6243
|
var FormRow_default = FormRow2;
|
|
5844
6244
|
|
|
5845
6245
|
// src/components/ColorThemeSwitch.tsx
|
|
5846
|
-
import { memo as
|
|
5847
|
-
import { jsx as
|
|
6246
|
+
import { memo as memo19, useEffect as useEffect8 } from "react";
|
|
6247
|
+
import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5848
6248
|
var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
5849
6249
|
withMoon,
|
|
5850
6250
|
className,
|
|
@@ -5855,7 +6255,7 @@ var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
|
5855
6255
|
darkMode: localStorage.getItem("theme") === "dark"
|
|
5856
6256
|
}
|
|
5857
6257
|
});
|
|
5858
|
-
|
|
6258
|
+
useEffect8(() => {
|
|
5859
6259
|
const timeout = setTimeout(() => {
|
|
5860
6260
|
window.document.body.parentElement?.setAttribute("data-theme", form.values.darkMode ? "dark" : "light");
|
|
5861
6261
|
localStorage.setItem("theme", form.values.darkMode ? "dark" : "light");
|
|
@@ -5864,7 +6264,7 @@ var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
|
5864
6264
|
clearTimeout(timeout);
|
|
5865
6265
|
};
|
|
5866
6266
|
}, [form.values.darkMode]);
|
|
5867
|
-
|
|
6267
|
+
useEffect8(() => {
|
|
5868
6268
|
const html = document.querySelector("html");
|
|
5869
6269
|
if (!html) return;
|
|
5870
6270
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -5881,7 +6281,7 @@ var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
|
5881
6281
|
observer.disconnect();
|
|
5882
6282
|
};
|
|
5883
6283
|
}, []);
|
|
5884
|
-
return /* @__PURE__ */
|
|
6284
|
+
return /* @__PURE__ */ jsx19(
|
|
5885
6285
|
ToggleInput_default.switch,
|
|
5886
6286
|
{
|
|
5887
6287
|
className: `react-better-html-color-theme-switch ${withMoon ? ` react-better-html-color-theme-switch-with-moon` : ""}${className ? ` ${className}` : ""}`,
|
|
@@ -5892,23 +6292,23 @@ var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
|
5892
6292
|
};
|
|
5893
6293
|
ColorThemeSwitchComponent.withText = function WithText({ withMoon, className, ...props }) {
|
|
5894
6294
|
const theme2 = useTheme();
|
|
5895
|
-
return /* @__PURE__ */
|
|
5896
|
-
/* @__PURE__ */
|
|
5897
|
-
/* @__PURE__ */
|
|
5898
|
-
/* @__PURE__ */
|
|
6295
|
+
return /* @__PURE__ */ jsxs14(Div_default.row, { width: "fit-content", alignItems: "center", gap: theme2.styles.gap, userSelect: "none", ...props, children: [
|
|
6296
|
+
/* @__PURE__ */ jsx19(Text_default, { children: "Light" }),
|
|
6297
|
+
/* @__PURE__ */ jsx19(ColorThemeSwitchComponent, { withMoon, className }),
|
|
6298
|
+
/* @__PURE__ */ jsx19(Text_default, { children: "Dark" })
|
|
5899
6299
|
] });
|
|
5900
6300
|
};
|
|
5901
|
-
var ColorThemeSwitch2 =
|
|
6301
|
+
var ColorThemeSwitch2 = memo19(ColorThemeSwitchComponent);
|
|
5902
6302
|
ColorThemeSwitch2.withText = ColorThemeSwitchComponent.withText;
|
|
5903
6303
|
var ColorThemeSwitch_default = ColorThemeSwitch2;
|
|
5904
6304
|
|
|
5905
6305
|
// src/components/Table.tsx
|
|
5906
|
-
import { forwardRef as forwardRef11, memo as
|
|
6306
|
+
import { forwardRef as forwardRef11, memo as memo20, useCallback as useCallback11, useMemo as useMemo7, useState as useState9 } from "react";
|
|
5907
6307
|
import styled10, { css as css2 } from "styled-components";
|
|
5908
|
-
import { Fragment as Fragment3, jsx as
|
|
6308
|
+
import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
5909
6309
|
var defaultImageWidth = 120;
|
|
5910
6310
|
var TableStyledComponent = styled10.table.withConfig({
|
|
5911
|
-
shouldForwardProp: (prop) => !["isStriped", "withHover", "withStickyHeader", "theme"].includes(prop)
|
|
6311
|
+
shouldForwardProp: (prop) => !["isStriped", "withHover", "withStickyHeader", "colorTheme", "theme"].includes(prop)
|
|
5912
6312
|
})`
|
|
5913
6313
|
width: 100%;
|
|
5914
6314
|
border-collapse: collapse;
|
|
@@ -5936,7 +6336,7 @@ var TableStyledComponent = styled10.table.withConfig({
|
|
|
5936
6336
|
transition: ${props.theme.styles.transition};
|
|
5937
6337
|
|
|
5938
6338
|
&:not(.isHeader):hover {
|
|
5939
|
-
filter: brightness(0.95);
|
|
6339
|
+
filter: brightness(${props.colorTheme === "light" ? "0.95" : "0.85"});
|
|
5940
6340
|
}
|
|
5941
6341
|
` : ""}
|
|
5942
6342
|
|
|
@@ -5947,7 +6347,7 @@ var TableStyledComponent = styled10.table.withConfig({
|
|
|
5947
6347
|
}
|
|
5948
6348
|
|
|
5949
6349
|
td {
|
|
5950
|
-
border-top: 1px solid ${(props) => props.theme.colors.border}
|
|
6350
|
+
border-top: 1px solid ${(props) => props.theme.colors.border + (props.colorTheme === "light" ? "60" : "40")};
|
|
5951
6351
|
padding: ${(props) => props.theme.styles.gap}px ${(props) => props.theme.styles.space}px;
|
|
5952
6352
|
|
|
5953
6353
|
&.noData {
|
|
@@ -5974,15 +6374,17 @@ var TableComponent = forwardRef11(function Table({
|
|
|
5974
6374
|
columns,
|
|
5975
6375
|
data,
|
|
5976
6376
|
isStriped,
|
|
6377
|
+
isLoading,
|
|
5977
6378
|
withStickyHeader,
|
|
5978
6379
|
noDataItemsMessage = "No data available",
|
|
5979
6380
|
onClickRow,
|
|
5980
6381
|
onClickAllCheckboxes,
|
|
5981
6382
|
...props
|
|
5982
6383
|
}, ref) {
|
|
6384
|
+
const { colorTheme } = useBetterHtmlContext();
|
|
5983
6385
|
const theme2 = useTheme();
|
|
5984
|
-
const [checkedItems, setCheckedItems] =
|
|
5985
|
-
const renderCellContent =
|
|
6386
|
+
const [checkedItems, setCheckedItems] = useState9([]);
|
|
6387
|
+
const renderCellContent = useCallback11(
|
|
5986
6388
|
(column, item, index) => {
|
|
5987
6389
|
switch (column.type) {
|
|
5988
6390
|
case "text": {
|
|
@@ -5990,17 +6392,17 @@ var TableComponent = forwardRef11(function Table({
|
|
|
5990
6392
|
return column.format ? column.format(item, index) : String(value ?? "");
|
|
5991
6393
|
}
|
|
5992
6394
|
case "element": {
|
|
5993
|
-
return column.render?.(item, index) ?? /* @__PURE__ */
|
|
6395
|
+
return column.render?.(item, index) ?? /* @__PURE__ */ jsx20(Fragment3, {});
|
|
5994
6396
|
}
|
|
5995
6397
|
case "image": {
|
|
5996
6398
|
const { type, keyName, ...props2 } = column;
|
|
5997
6399
|
const src = keyName ? item[keyName] : void 0;
|
|
5998
|
-
return /* @__PURE__ */
|
|
6400
|
+
return /* @__PURE__ */ jsx20(Image_default, { src, width: defaultImageWidth, borderRadius: theme2.styles.borderRadius / 2, ...props2 });
|
|
5999
6401
|
}
|
|
6000
6402
|
case "checkbox": {
|
|
6001
6403
|
const { type, onChange, ...props2 } = column;
|
|
6002
6404
|
const checkedValue = checkedItems[index];
|
|
6003
|
-
return /* @__PURE__ */
|
|
6405
|
+
return /* @__PURE__ */ jsx20(
|
|
6004
6406
|
ToggleInput_default.checkbox,
|
|
6005
6407
|
{
|
|
6006
6408
|
checked: checkedValue,
|
|
@@ -6015,29 +6417,29 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6015
6417
|
);
|
|
6016
6418
|
}
|
|
6017
6419
|
default: {
|
|
6018
|
-
return /* @__PURE__ */
|
|
6420
|
+
return /* @__PURE__ */ jsx20(Fragment3, {});
|
|
6019
6421
|
}
|
|
6020
6422
|
}
|
|
6021
6423
|
},
|
|
6022
6424
|
[theme2, checkedItems]
|
|
6023
6425
|
);
|
|
6024
|
-
const onClickRowElement =
|
|
6426
|
+
const onClickRowElement = useCallback11(
|
|
6025
6427
|
(item, index) => {
|
|
6026
6428
|
onClickRow?.(item, index);
|
|
6027
6429
|
},
|
|
6028
6430
|
[onClickRow]
|
|
6029
6431
|
);
|
|
6030
|
-
const onClickAllCheckboxesElement =
|
|
6432
|
+
const onClickAllCheckboxesElement = useCallback11(
|
|
6031
6433
|
(checked) => {
|
|
6032
6434
|
onClickAllCheckboxes?.(checked);
|
|
6033
6435
|
setCheckedItems(data.map(() => checked));
|
|
6034
6436
|
},
|
|
6035
6437
|
[onClickAllCheckboxes, data]
|
|
6036
6438
|
);
|
|
6037
|
-
const everythingIsChecked =
|
|
6439
|
+
const everythingIsChecked = useMemo7(() => {
|
|
6038
6440
|
return checkedItems.every((checked) => checked) && checkedItems.length === data.length;
|
|
6039
6441
|
}, [data, checkedItems]);
|
|
6040
|
-
return /* @__PURE__ */
|
|
6442
|
+
return /* @__PURE__ */ jsx20(
|
|
6041
6443
|
Div_default,
|
|
6042
6444
|
{
|
|
6043
6445
|
border: `1px solid ${theme2.colors.border}`,
|
|
@@ -6045,22 +6447,23 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6045
6447
|
overflow: "auto",
|
|
6046
6448
|
...props,
|
|
6047
6449
|
ref,
|
|
6048
|
-
children: /* @__PURE__ */
|
|
6450
|
+
children: /* @__PURE__ */ jsxs15(
|
|
6049
6451
|
TableStyledComponent,
|
|
6050
6452
|
{
|
|
6051
6453
|
isStriped,
|
|
6052
6454
|
withHover: onClickRow !== void 0,
|
|
6053
6455
|
withStickyHeader,
|
|
6456
|
+
colorTheme,
|
|
6054
6457
|
theme: theme2,
|
|
6055
6458
|
children: [
|
|
6056
|
-
/* @__PURE__ */
|
|
6459
|
+
/* @__PURE__ */ jsx20("thead", { children: /* @__PURE__ */ jsx20("tr", { className: "isHeader", children: columns.map((column, index) => /* @__PURE__ */ jsx20(
|
|
6057
6460
|
ThStyledComponent,
|
|
6058
6461
|
{
|
|
6059
6462
|
width: column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.width,
|
|
6060
6463
|
minWidth: column.minWidth,
|
|
6061
6464
|
maxWidth: column.maxWidth,
|
|
6062
6465
|
textAlign: column.align,
|
|
6063
|
-
children: column.label ?? (column.type === "checkbox" && onClickAllCheckboxes ? /* @__PURE__ */
|
|
6466
|
+
children: column.label ?? (column.type === "checkbox" && onClickAllCheckboxes ? /* @__PURE__ */ jsx20(
|
|
6064
6467
|
ToggleInput_default.checkbox,
|
|
6065
6468
|
{
|
|
6066
6469
|
checked: everythingIsChecked,
|
|
@@ -6070,86 +6473,24 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6070
6473
|
},
|
|
6071
6474
|
column.type + column.label + index
|
|
6072
6475
|
)) }) }),
|
|
6073
|
-
/* @__PURE__ */
|
|
6476
|
+
/* @__PURE__ */ jsx20("tbody", { children: isLoading ? /* @__PURE__ */ jsx20("tr", { children: /* @__PURE__ */ jsx20("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ jsx20(Loader_default.box, {}) }) }) : data.length > 0 ? data.map((item, rowIndex) => /* @__PURE__ */ jsx20(
|
|
6074
6477
|
"tr",
|
|
6075
6478
|
{
|
|
6076
6479
|
className: onClickRow ? "isClickable" : void 0,
|
|
6077
6480
|
onClick: () => onClickRowElement(item, rowIndex),
|
|
6078
|
-
children: columns.map((column, colIndex) => /* @__PURE__ */
|
|
6481
|
+
children: columns.map((column, colIndex) => /* @__PURE__ */ jsx20(TdStyledComponent, { textAlign: column.align, children: renderCellContent(column, item, rowIndex) }, column.type + column.label + colIndex))
|
|
6079
6482
|
},
|
|
6080
6483
|
JSON.stringify(item) + rowIndex
|
|
6081
|
-
)) : /* @__PURE__ */
|
|
6484
|
+
)) : /* @__PURE__ */ jsx20("tr", { children: /* @__PURE__ */ jsx20("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ jsx20(Text_default.unknown, { children: noDataItemsMessage }) }) }) })
|
|
6082
6485
|
]
|
|
6083
6486
|
}
|
|
6084
6487
|
)
|
|
6085
6488
|
}
|
|
6086
6489
|
);
|
|
6087
6490
|
});
|
|
6088
|
-
var Table2 =
|
|
6491
|
+
var Table2 = memo20(TableComponent);
|
|
6089
6492
|
var Table_default = Table2;
|
|
6090
6493
|
|
|
6091
|
-
// src/utils/functions.ts
|
|
6092
|
-
var generateRandomString = (stringLength, options) => {
|
|
6093
|
-
const capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
6094
|
-
const lowers = "abcdefghijklmnopqrstuvwxyz";
|
|
6095
|
-
const numbers = "0123456789";
|
|
6096
|
-
const includes = [];
|
|
6097
|
-
if (options?.includeCapitalLetters !== false) includes.push(capitals);
|
|
6098
|
-
if (options?.includeLowerLetters !== false) includes.push(lowers);
|
|
6099
|
-
if (options?.includeNumbers !== false) includes.push(numbers);
|
|
6100
|
-
const characters = includes.join("");
|
|
6101
|
-
const dashSections = Math.max(1, options?.dashSections ?? 1);
|
|
6102
|
-
const dashSectionLength = Math.floor(stringLength / dashSections);
|
|
6103
|
-
if (stringLength < dashSections) return "";
|
|
6104
|
-
let result = "";
|
|
6105
|
-
let currentSectionLength = 0;
|
|
6106
|
-
while (result.length < stringLength) {
|
|
6107
|
-
if (currentSectionLength >= dashSectionLength) {
|
|
6108
|
-
result += "-";
|
|
6109
|
-
currentSectionLength = 0;
|
|
6110
|
-
}
|
|
6111
|
-
if (result.length < stringLength) {
|
|
6112
|
-
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
6113
|
-
currentSectionLength += 1;
|
|
6114
|
-
}
|
|
6115
|
-
}
|
|
6116
|
-
return result;
|
|
6117
|
-
};
|
|
6118
|
-
var getBrowser = () => {
|
|
6119
|
-
const userAgent = navigator.userAgent.toLowerCase();
|
|
6120
|
-
if (userAgent.includes("firefox")) return "firefox";
|
|
6121
|
-
if (userAgent.includes("chrome") && !userAgent.includes("edg")) return "chrome";
|
|
6122
|
-
if (userAgent.includes("safari") && !userAgent.includes("chrome")) return "safari";
|
|
6123
|
-
if (userAgent.includes("edg")) return "edge";
|
|
6124
|
-
if (userAgent.includes("opr") || userAgent.includes("opera")) return "opera";
|
|
6125
|
-
return;
|
|
6126
|
-
};
|
|
6127
|
-
var formatPhoneNumber = (phoneNumber) => {
|
|
6128
|
-
const cleanPhoneNumber = phoneNumber.replace(/\D/g, "");
|
|
6129
|
-
const country = countries.find(
|
|
6130
|
-
(country2) => country2.phoneNumberExtension === cleanPhoneNumber.slice(0, country2.phoneNumberExtension.length)
|
|
6131
|
-
);
|
|
6132
|
-
if (!country) return phoneNumber;
|
|
6133
|
-
let phonNumberRest = cleanPhoneNumber.slice(country.phoneNumberExtension.length);
|
|
6134
|
-
if (country.phoneNumberFormat) {
|
|
6135
|
-
let formattedNumber = "";
|
|
6136
|
-
let index = 0;
|
|
6137
|
-
for (const char of country.phoneNumberFormat) {
|
|
6138
|
-
if (char === "X" && index < phonNumberRest.length) {
|
|
6139
|
-
formattedNumber += phonNumberRest[index];
|
|
6140
|
-
index++;
|
|
6141
|
-
} else {
|
|
6142
|
-
formattedNumber += char;
|
|
6143
|
-
}
|
|
6144
|
-
}
|
|
6145
|
-
phonNumberRest = formattedNumber.replace(/X/g, "").trim();
|
|
6146
|
-
}
|
|
6147
|
-
return `+${country.phoneNumberExtension} ${phonNumberRest}`;
|
|
6148
|
-
};
|
|
6149
|
-
var getFormErrorObject = (formValues) => {
|
|
6150
|
-
return {};
|
|
6151
|
-
};
|
|
6152
|
-
|
|
6153
6494
|
// src/utils/variableFunctions.ts
|
|
6154
6495
|
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
6155
6496
|
if (value === void 0) {
|