react-better-html 1.1.228 → 1.1.230
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 +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +143 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1403,7 +1403,7 @@ var Image = forwardRef3(function Image2({ name, src, ...props }, ref) {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
);
|
|
1405
1405
|
});
|
|
1406
|
-
Image.profileImage = forwardRef3(function ProfileImage({ size = 40, letters, backgroundColor, ...props }, ref) {
|
|
1406
|
+
Image.profileImage = forwardRef3(function ProfileImage({ size = 40, letters, letterColor, backgroundColor, ...props }, ref) {
|
|
1407
1407
|
const theme2 = useTheme4();
|
|
1408
1408
|
return letters ? /* @__PURE__ */ jsx3(
|
|
1409
1409
|
Div_default.row,
|
|
@@ -1417,7 +1417,7 @@ Image.profileImage = forwardRef3(function ProfileImage({ size = 40, letters, bac
|
|
|
1417
1417
|
...props,
|
|
1418
1418
|
width: size,
|
|
1419
1419
|
height: size,
|
|
1420
|
-
children: /* @__PURE__ */ jsx3(Text_default, { fontSize: size / 2.5, fontWeight: 700, children: letters.toUpperCase().slice(0, 2) })
|
|
1420
|
+
children: /* @__PURE__ */ jsx3(Text_default, { fontSize: size / 2.5, fontWeight: 700, color: letterColor ?? theme2.colors.textPrimary, children: letters.toUpperCase().slice(0, 2) })
|
|
1421
1421
|
}
|
|
1422
1422
|
) : /* @__PURE__ */ jsx3(
|
|
1423
1423
|
Image,
|
|
@@ -2665,25 +2665,31 @@ function Alert2({ alert }) {
|
|
|
2665
2665
|
if (intervalRef.current) clearInterval(intervalRef.current);
|
|
2666
2666
|
if (defaultAlertDisplay === "prominent") return;
|
|
2667
2667
|
setIsRemoved(true);
|
|
2668
|
-
setTimeout(
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2668
|
+
setTimeout(
|
|
2669
|
+
() => {
|
|
2670
|
+
alertControls2.removeAlert(alert.id);
|
|
2671
|
+
if (!calledOnCloseRef.current) {
|
|
2672
|
+
alert.onClose?.(alert);
|
|
2673
|
+
calledOnCloseRef.current = true;
|
|
2674
|
+
}
|
|
2675
|
+
},
|
|
2676
|
+
0.2 * 1e3 - 10
|
|
2677
|
+
);
|
|
2675
2678
|
}
|
|
2676
2679
|
}, updateInterval);
|
|
2677
2680
|
}, [alert, progress, defaultAlertDisplay]);
|
|
2678
2681
|
const onClickCloseAlert = useCallback5(() => {
|
|
2679
2682
|
setIsRemoved(true);
|
|
2680
|
-
setTimeout(
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2683
|
+
setTimeout(
|
|
2684
|
+
() => {
|
|
2685
|
+
alertControls2.removeAlert(alert.id);
|
|
2686
|
+
if (!calledOnCloseRef.current) {
|
|
2687
|
+
alert.onClose?.(alert);
|
|
2688
|
+
calledOnCloseRef.current = true;
|
|
2689
|
+
}
|
|
2690
|
+
},
|
|
2691
|
+
0.2 * 1e3 - 10
|
|
2692
|
+
);
|
|
2687
2693
|
}, [alert]);
|
|
2688
2694
|
const onMouseEnter = useCallback5(() => {
|
|
2689
2695
|
setIsPaused(true);
|
|
@@ -2700,13 +2706,16 @@ function Alert2({ alert }) {
|
|
|
2700
2706
|
const onClickAlertModalDone = useCallback5(() => {
|
|
2701
2707
|
setIsRemoved(true);
|
|
2702
2708
|
modalRef.current?.close();
|
|
2703
|
-
setTimeout(
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2709
|
+
setTimeout(
|
|
2710
|
+
() => {
|
|
2711
|
+
alertControls2.removeAlert(alert.id);
|
|
2712
|
+
if (!calledOnCloseRef.current) {
|
|
2713
|
+
alert.onClose?.(alert);
|
|
2714
|
+
calledOnCloseRef.current = true;
|
|
2715
|
+
}
|
|
2716
|
+
},
|
|
2717
|
+
0.2 * 1e3 - 10
|
|
2718
|
+
);
|
|
2710
2719
|
}, [alert]);
|
|
2711
2720
|
const alertData = useMemo2(
|
|
2712
2721
|
() => ({
|
|
@@ -2800,7 +2809,7 @@ function Alert2({ alert }) {
|
|
|
2800
2809
|
),
|
|
2801
2810
|
/* @__PURE__ */ jsxs7(Div_default.column, { flex: 1, gap: theme2.styles.gap / 2, children: [
|
|
2802
2811
|
/* @__PURE__ */ jsx10(Text_default, { fontSize: 18, fontWeight: 700, children: alertTitle }),
|
|
2803
|
-
/* @__PURE__ */ jsx10(Text_default, { color: theme2.colors.textSecondary, children: alert.message })
|
|
2812
|
+
alert.message && /* @__PURE__ */ jsx10(Text_default, { color: theme2.colors.textSecondary, children: alert.message })
|
|
2804
2813
|
] }),
|
|
2805
2814
|
pluginConfig.withCloseButton && /* @__PURE__ */ jsx10(Button_default.icon, { icon: "XMark", alignSelf: "flex-start", onClick: onClickCloseAlert })
|
|
2806
2815
|
] }),
|
|
@@ -3179,6 +3188,18 @@ var decryptString = (text) => {
|
|
|
3179
3188
|
});
|
|
3180
3189
|
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
3181
3190
|
};
|
|
3191
|
+
function findClosestNumber(numbers, target) {
|
|
3192
|
+
let closest = numbers[0];
|
|
3193
|
+
let minDistance = Math.abs(target - numbers[0]);
|
|
3194
|
+
for (let index = 1; index < numbers.length; index++) {
|
|
3195
|
+
const distance = Math.abs(target - numbers[index]);
|
|
3196
|
+
if (distance < minDistance || distance === minDistance && numbers[index] < closest) {
|
|
3197
|
+
closest = numbers[index];
|
|
3198
|
+
minDistance = distance;
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
return closest;
|
|
3202
|
+
}
|
|
3182
3203
|
|
|
3183
3204
|
// src/utils/localStorage.ts
|
|
3184
3205
|
function generateLocalStorage() {
|
|
@@ -4740,13 +4761,29 @@ InputFieldComponent.date = forwardRef11(function Date2({ minDate, maxDate, ...pr
|
|
|
4740
4761
|
}
|
|
4741
4762
|
);
|
|
4742
4763
|
});
|
|
4743
|
-
InputFieldComponent.dateTime = forwardRef11(function DateTime({
|
|
4764
|
+
InputFieldComponent.dateTime = forwardRef11(function DateTime({
|
|
4765
|
+
hoursToRender,
|
|
4766
|
+
minutesToRender,
|
|
4767
|
+
minDate,
|
|
4768
|
+
maxDate,
|
|
4769
|
+
defaultDateAfterTimePick,
|
|
4770
|
+
defaultTimeAfterDatePick = "00:00",
|
|
4771
|
+
...props
|
|
4772
|
+
}, ref) {
|
|
4744
4773
|
const theme2 = useTheme19();
|
|
4745
4774
|
const holderRef = useRef5(null);
|
|
4746
4775
|
const selectedHourRef = useRef5(null);
|
|
4747
4776
|
const selectedMinuteRef = useRef5(null);
|
|
4748
4777
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
4749
4778
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
4779
|
+
const readyHours = useMemo6(
|
|
4780
|
+
() => hoursToRender?.filter((hour) => hour >= 0 && hour <= 23) ?? hours,
|
|
4781
|
+
[hoursToRender]
|
|
4782
|
+
);
|
|
4783
|
+
const readyMinutes = useMemo6(
|
|
4784
|
+
() => minutesToRender?.filter((hour) => hour >= 0 && hour <= 59) ?? minutes,
|
|
4785
|
+
[minutesToRender]
|
|
4786
|
+
);
|
|
4750
4787
|
const onChange = useCallback10(
|
|
4751
4788
|
(date) => {
|
|
4752
4789
|
const newValue = date ? `${date}T${internalValue?.toString().split("T")[1] ?? defaultTimeAfterDatePick}` : "";
|
|
@@ -4755,6 +4792,32 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
|
|
|
4755
4792
|
},
|
|
4756
4793
|
[internalValue, defaultTimeAfterDatePick, inputFieldProps.onChangeValue]
|
|
4757
4794
|
);
|
|
4795
|
+
const onBlur = useCallback10(
|
|
4796
|
+
(event) => {
|
|
4797
|
+
if (hoursToRender || minutesToRender) {
|
|
4798
|
+
const value = event.target.value;
|
|
4799
|
+
const hours2 = parseInt(value.split(":")[0] || "0");
|
|
4800
|
+
const minutes2 = parseInt(value.split(":")[1] || "0");
|
|
4801
|
+
const readyHour = readyHours.includes(hours2) ? hours2 : findClosestNumber(readyHours, hours2);
|
|
4802
|
+
const readyMinute = readyMinutes.includes(minutes2) ? minutes2 : findClosestNumber(readyMinutes, minutes2);
|
|
4803
|
+
const newTime = `${readyHour.toString().padStart(2, "0")}:${readyMinute.toString().padStart(2, "0")}`;
|
|
4804
|
+
const today = defaultDateAfterTimePick ?? `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
4805
|
+
const newValue = `${(internalValue.trim() || today)?.toString().split("T")[0]}T${newTime}`;
|
|
4806
|
+
inputFieldProps.onChangeValue?.(newValue);
|
|
4807
|
+
}
|
|
4808
|
+
inputFieldProps.onBlur?.(event);
|
|
4809
|
+
},
|
|
4810
|
+
[
|
|
4811
|
+
defaultDateAfterTimePick,
|
|
4812
|
+
internalValue,
|
|
4813
|
+
hoursToRender,
|
|
4814
|
+
minutesToRender,
|
|
4815
|
+
readyHours,
|
|
4816
|
+
readyMinutes,
|
|
4817
|
+
inputFieldProps.onChangeValue,
|
|
4818
|
+
inputFieldProps.onBlur
|
|
4819
|
+
]
|
|
4820
|
+
);
|
|
4758
4821
|
const onClickHour = useCallback10(
|
|
4759
4822
|
(hour) => {
|
|
4760
4823
|
const newTime = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
@@ -4823,7 +4886,7 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
|
|
|
4823
4886
|
height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
|
|
4824
4887
|
overflowY: "auto",
|
|
4825
4888
|
tabIndex: -1,
|
|
4826
|
-
children:
|
|
4889
|
+
children: readyHours.map((hour) => {
|
|
4827
4890
|
const isSelected = hour.toString() === valueHour;
|
|
4828
4891
|
return /* @__PURE__ */ jsx17(
|
|
4829
4892
|
Div_default.row,
|
|
@@ -4857,7 +4920,7 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
|
|
|
4857
4920
|
height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
|
|
4858
4921
|
overflowY: "auto",
|
|
4859
4922
|
tabIndex: -1,
|
|
4860
|
-
children:
|
|
4923
|
+
children: readyMinutes.map((minute) => {
|
|
4861
4924
|
const isSelected = minute.toString() === valueMinute;
|
|
4862
4925
|
return /* @__PURE__ */ jsx17(
|
|
4863
4926
|
Div_default.row,
|
|
@@ -4890,17 +4953,56 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
|
|
|
4890
4953
|
holderRef,
|
|
4891
4954
|
ref,
|
|
4892
4955
|
...props,
|
|
4893
|
-
...inputFieldProps
|
|
4956
|
+
...inputFieldProps,
|
|
4957
|
+
onBlur
|
|
4894
4958
|
}
|
|
4895
4959
|
);
|
|
4896
4960
|
});
|
|
4897
|
-
InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
|
|
4961
|
+
InputFieldComponent.time = forwardRef11(function Time({ hoursToRender, minutesToRender, minTime, maxTime, ...props }, ref) {
|
|
4898
4962
|
const theme2 = useTheme19();
|
|
4899
4963
|
const holderRef = useRef5(null);
|
|
4900
4964
|
const selectedHourRef = useRef5(null);
|
|
4901
4965
|
const selectedMinuteRef = useRef5(null);
|
|
4902
4966
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
4967
|
+
const minHours = minTime ? parseInt(minTime.split(":")[0]) : void 0;
|
|
4968
|
+
const minMinutes = minTime ? parseInt(minTime.split(":")[1]) : void 0;
|
|
4969
|
+
const maxHours = maxTime ? parseInt(maxTime.split(":")[0]) : void 0;
|
|
4970
|
+
const maxMinutes = maxTime ? parseInt(maxTime.split(":")[1]) : void 0;
|
|
4903
4971
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
4972
|
+
const readyHours = useMemo6(
|
|
4973
|
+
() => hoursToRender?.filter((hour) => hour >= 0 && hour <= 23) ?? hours,
|
|
4974
|
+
[hoursToRender]
|
|
4975
|
+
);
|
|
4976
|
+
const readyMinutes = useMemo6(
|
|
4977
|
+
() => minutesToRender?.filter((hour) => hour >= 0 && hour <= 59) ?? minutes,
|
|
4978
|
+
[minutesToRender]
|
|
4979
|
+
);
|
|
4980
|
+
const onBlur = useCallback10(
|
|
4981
|
+
(event) => {
|
|
4982
|
+
if (!!minHours || !!maxHours || !!minMinutes || !!maxMinutes || hoursToRender || minutesToRender) {
|
|
4983
|
+
const value = event.target.value;
|
|
4984
|
+
const hours2 = parseInt(value.split(":")[0] || "0");
|
|
4985
|
+
const minutes2 = parseInt(value.split(":")[1] || "0");
|
|
4986
|
+
const readyHour = readyHours.includes(hours2) ? hours2 : findClosestNumber(readyHours, hours2);
|
|
4987
|
+
const readyMinute = readyMinutes.includes(minutes2) ? minutes2 : findClosestNumber(readyMinutes, minutes2);
|
|
4988
|
+
const newValue = `${(minHours && readyHour < minHours ? minHours : maxHours && readyHour > maxHours ? maxHours : readyHour).toString().padStart(2, "0")}:${(minMinutes && readyMinute < minMinutes ? minMinutes : maxHours && readyMinute > maxHours ? maxHours : readyMinute).toString().padStart(2, "0")}`;
|
|
4989
|
+
inputFieldProps.onChangeValue?.(newValue);
|
|
4990
|
+
}
|
|
4991
|
+
inputFieldProps.onBlur?.(event);
|
|
4992
|
+
},
|
|
4993
|
+
[
|
|
4994
|
+
minHours,
|
|
4995
|
+
maxHours,
|
|
4996
|
+
minMinutes,
|
|
4997
|
+
maxMinutes,
|
|
4998
|
+
hoursToRender,
|
|
4999
|
+
minutesToRender,
|
|
5000
|
+
readyHours,
|
|
5001
|
+
readyMinutes,
|
|
5002
|
+
inputFieldProps.onChangeValue,
|
|
5003
|
+
inputFieldProps.onBlur
|
|
5004
|
+
]
|
|
5005
|
+
);
|
|
4904
5006
|
const onClickHour = useCallback10(
|
|
4905
5007
|
(hour) => {
|
|
4906
5008
|
const value = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
@@ -4953,8 +5055,9 @@ InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
|
|
|
4953
5055
|
height: "100%",
|
|
4954
5056
|
overflowY: "auto",
|
|
4955
5057
|
tabIndex: -1,
|
|
4956
|
-
children:
|
|
5058
|
+
children: readyHours.map((hour) => {
|
|
4957
5059
|
const isSelected = hour.toString() === valueHour;
|
|
5060
|
+
const isDisabled = minHours && hour < minHours || maxHours && hour > maxHours;
|
|
4958
5061
|
return /* @__PURE__ */ jsx17(
|
|
4959
5062
|
Div_default.row,
|
|
4960
5063
|
{
|
|
@@ -4963,10 +5066,11 @@ InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
|
|
|
4963
5066
|
color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
4964
5067
|
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
4965
5068
|
filterHover: "brightness(0.9)",
|
|
4966
|
-
cursor: "pointer",
|
|
5069
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
4967
5070
|
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5071
|
+
opacity: isDisabled ? 0.6 : void 0,
|
|
4968
5072
|
value: hour,
|
|
4969
|
-
onClickWithValue: onClickHour,
|
|
5073
|
+
onClickWithValue: !isDisabled ? onClickHour : void 0,
|
|
4970
5074
|
ref: isSelected ? selectedHourRef : void 0,
|
|
4971
5075
|
children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: hour.toString().padStart(2, "0") })
|
|
4972
5076
|
},
|
|
@@ -4983,8 +5087,9 @@ InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
|
|
|
4983
5087
|
height: "100%",
|
|
4984
5088
|
overflowY: "auto",
|
|
4985
5089
|
tabIndex: -1,
|
|
4986
|
-
children:
|
|
5090
|
+
children: readyMinutes.map((minute) => {
|
|
4987
5091
|
const isSelected = minute.toString() === valueMinute;
|
|
5092
|
+
const isDisabled = minMinutes && minute < minMinutes || maxMinutes && minute > maxMinutes;
|
|
4988
5093
|
return /* @__PURE__ */ jsx17(
|
|
4989
5094
|
Div_default.row,
|
|
4990
5095
|
{
|
|
@@ -4993,10 +5098,11 @@ InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
|
|
|
4993
5098
|
color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
4994
5099
|
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
4995
5100
|
filterHover: "brightness(0.9)",
|
|
4996
|
-
cursor: "pointer",
|
|
5101
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
4997
5102
|
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5103
|
+
opacity: isDisabled ? 0.6 : void 0,
|
|
4998
5104
|
value: minute,
|
|
4999
|
-
onClickWithValue: onClickMinute,
|
|
5105
|
+
onClickWithValue: !isDisabled ? onClickMinute : void 0,
|
|
5000
5106
|
ref: isSelected ? selectedMinuteRef : void 0,
|
|
5001
5107
|
children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: minute.toString().padStart(2, "0") })
|
|
5002
5108
|
},
|
|
@@ -5012,7 +5118,8 @@ InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
|
|
|
5012
5118
|
ref,
|
|
5013
5119
|
...props,
|
|
5014
5120
|
...inputFieldProps,
|
|
5015
|
-
minWidth: buttonWidth * 2 + 2
|
|
5121
|
+
minWidth: buttonWidth * 2 + 2,
|
|
5122
|
+
onBlur
|
|
5016
5123
|
}
|
|
5017
5124
|
);
|
|
5018
5125
|
});
|