react-better-html 1.1.211 → 1.1.212
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +111 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1668,7 +1668,7 @@ var TextStyledComponent = styled2.p.withConfig({
|
|
|
1668
1668
|
${(props) => props.hoverStyle}
|
|
1669
1669
|
}
|
|
1670
1670
|
`;
|
|
1671
|
-
var TextComponent = forwardRef2(function Text({ children, ...props }, ref) {
|
|
1671
|
+
var TextComponent = forwardRef2(function Text({ htmlContentTranslate, children, ...props }, ref) {
|
|
1672
1672
|
const theme2 = useTheme();
|
|
1673
1673
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
1674
1674
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
@@ -1678,6 +1678,7 @@ var TextComponent = forwardRef2(function Text({ children, ...props }, ref) {
|
|
|
1678
1678
|
TextStyledComponent,
|
|
1679
1679
|
{
|
|
1680
1680
|
as: props.as,
|
|
1681
|
+
translate: htmlContentTranslate,
|
|
1681
1682
|
...styledComponentStyles,
|
|
1682
1683
|
...dataProps,
|
|
1683
1684
|
...ariaProps,
|
|
@@ -2948,7 +2949,7 @@ function useForm(options) {
|
|
|
2948
2949
|
errorText: errors[field]
|
|
2949
2950
|
};
|
|
2950
2951
|
},
|
|
2951
|
-
[values, setFieldValue, inputTypes, errors]
|
|
2952
|
+
[values, setFieldValue, inputTypes, errors, requiredFields]
|
|
2952
2953
|
);
|
|
2953
2954
|
const getTextAreaProps = useCallback4(
|
|
2954
2955
|
(field) => {
|
|
@@ -2966,7 +2967,7 @@ function useForm(options) {
|
|
|
2966
2967
|
errorText: errors[field]
|
|
2967
2968
|
};
|
|
2968
2969
|
},
|
|
2969
|
-
[values, setFieldValue, inputTypes, errors]
|
|
2970
|
+
[values, setFieldValue, inputTypes, errors, requiredFields]
|
|
2970
2971
|
);
|
|
2971
2972
|
const getDropdownFieldProps = useCallback4(
|
|
2972
2973
|
(field) => {
|
|
@@ -2984,7 +2985,7 @@ function useForm(options) {
|
|
|
2984
2985
|
errorText: errors[field]
|
|
2985
2986
|
};
|
|
2986
2987
|
},
|
|
2987
|
-
[values, errors, setFieldValue]
|
|
2988
|
+
[values, errors, setFieldValue, requiredFields]
|
|
2988
2989
|
);
|
|
2989
2990
|
const getCheckboxProps = useCallback4(
|
|
2990
2991
|
(field) => {
|
|
@@ -3002,7 +3003,7 @@ function useForm(options) {
|
|
|
3002
3003
|
errorText: errors[field]
|
|
3003
3004
|
};
|
|
3004
3005
|
},
|
|
3005
|
-
[values, errors, setFieldValue]
|
|
3006
|
+
[values, errors, setFieldValue, requiredFields]
|
|
3006
3007
|
);
|
|
3007
3008
|
const getRadioButtonProps = useCallback4(
|
|
3008
3009
|
(field, value) => {
|
|
@@ -3021,7 +3022,7 @@ function useForm(options) {
|
|
|
3021
3022
|
errorText: errors[field]
|
|
3022
3023
|
};
|
|
3023
3024
|
},
|
|
3024
|
-
[values, errors, setFieldValue]
|
|
3025
|
+
[values, errors, setFieldValue, requiredFields]
|
|
3025
3026
|
);
|
|
3026
3027
|
const getSwitchProps = useCallback4(
|
|
3027
3028
|
(field) => {
|
|
@@ -3039,7 +3040,7 @@ function useForm(options) {
|
|
|
3039
3040
|
errorText: errors[field]
|
|
3040
3041
|
};
|
|
3041
3042
|
},
|
|
3042
|
-
[values, errors, setFieldValue]
|
|
3043
|
+
[values, errors, setFieldValue, requiredFields]
|
|
3043
3044
|
);
|
|
3044
3045
|
const focusField = useCallback4((field) => {
|
|
3045
3046
|
inputFieldRefs.current[field]?.focus();
|
|
@@ -3947,6 +3948,94 @@ var desaturateColor = (hexColor, amount) => {
|
|
|
3947
3948
|
return `#${rHex}${gHex}${bHex}`;
|
|
3948
3949
|
};
|
|
3949
3950
|
|
|
3951
|
+
// src/utils/variableFunctions.ts
|
|
3952
|
+
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
3953
|
+
if (value === void 0) {
|
|
3954
|
+
throw new Error(
|
|
3955
|
+
`\`${functionsName}()\` must be used within a \`<BetterHtmlProvider>\`. Make sure to add one at the root of your component tree.`
|
|
3956
|
+
);
|
|
3957
|
+
}
|
|
3958
|
+
return value !== void 0;
|
|
3959
|
+
};
|
|
3960
|
+
var loaderControls = {
|
|
3961
|
+
startLoading: (loaderName) => {
|
|
3962
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.startLoading")) return;
|
|
3963
|
+
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
3964
|
+
...oldValue,
|
|
3965
|
+
[loaderName.toString()]: true
|
|
3966
|
+
}));
|
|
3967
|
+
},
|
|
3968
|
+
stopLoading: (loaderName) => {
|
|
3969
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.stopLoading")) return;
|
|
3970
|
+
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
3971
|
+
...oldValue,
|
|
3972
|
+
[loaderName.toString()]: false
|
|
3973
|
+
}));
|
|
3974
|
+
}
|
|
3975
|
+
};
|
|
3976
|
+
var alertControls = {
|
|
3977
|
+
createAlert: (alert) => {
|
|
3978
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.createAlert"))
|
|
3979
|
+
return void 0;
|
|
3980
|
+
const readyAlert = {
|
|
3981
|
+
id: crypto.randomUUID(),
|
|
3982
|
+
...alert
|
|
3983
|
+
};
|
|
3984
|
+
externalBetterHtmlContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
3985
|
+
return readyAlert;
|
|
3986
|
+
},
|
|
3987
|
+
removeAlert: (alertId) => {
|
|
3988
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.removeAlert")) return;
|
|
3989
|
+
externalBetterHtmlContextValue.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
3990
|
+
}
|
|
3991
|
+
};
|
|
3992
|
+
var sideMenuControls = {
|
|
3993
|
+
expand: () => {
|
|
3994
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.expand")) return;
|
|
3995
|
+
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setFalse();
|
|
3996
|
+
},
|
|
3997
|
+
collapse: () => {
|
|
3998
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.collapse")) return;
|
|
3999
|
+
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setTrue();
|
|
4000
|
+
},
|
|
4001
|
+
toggleExpanded: () => {
|
|
4002
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleExpanded")) return;
|
|
4003
|
+
externalBetterHtmlContextValue.setSideMenuIsCollapsed.toggle();
|
|
4004
|
+
},
|
|
4005
|
+
open: () => {
|
|
4006
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.open")) return;
|
|
4007
|
+
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setTrue();
|
|
4008
|
+
},
|
|
4009
|
+
close: () => {
|
|
4010
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.close")) return;
|
|
4011
|
+
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setFalse();
|
|
4012
|
+
},
|
|
4013
|
+
toggleOpened: () => {
|
|
4014
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleOpened")) return;
|
|
4015
|
+
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.toggle();
|
|
4016
|
+
}
|
|
4017
|
+
};
|
|
4018
|
+
var colorThemeControls = {
|
|
4019
|
+
toggleTheme: (theme2) => {
|
|
4020
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "colorThemeControls.toggleTheme")) return;
|
|
4021
|
+
const currentColorTheme = externalBetterHtmlContextValue.colorTheme;
|
|
4022
|
+
const newColorTheme = theme2 ?? (currentColorTheme === "dark" ? "light" : "dark");
|
|
4023
|
+
setTimeout(() => {
|
|
4024
|
+
window.document.body.parentElement?.setAttribute("data-theme", newColorTheme);
|
|
4025
|
+
localStorage.setItem("theme", newColorTheme);
|
|
4026
|
+
}, 0.01 * 1e3);
|
|
4027
|
+
}
|
|
4028
|
+
};
|
|
4029
|
+
var filterHover = () => {
|
|
4030
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "filterHover")) return void 0;
|
|
4031
|
+
return {
|
|
4032
|
+
z05: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.95)",
|
|
4033
|
+
z1: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.3)" : "brightness(0.9)",
|
|
4034
|
+
z2: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.6)" : "brightness(0.8)",
|
|
4035
|
+
z3: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.9)" : "brightness(0.7)"
|
|
4036
|
+
};
|
|
4037
|
+
};
|
|
4038
|
+
|
|
3950
4039
|
// src/components/Chip.tsx
|
|
3951
4040
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
3952
4041
|
var ChipComponent = forwardRef9(function Chip({
|
|
@@ -3976,6 +4065,7 @@ var ChipComponent = forwardRef9(function Chip({
|
|
|
3976
4065
|
borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / 1.3,
|
|
3977
4066
|
paddingBlock: theme2.styles.gap / 2,
|
|
3978
4067
|
paddingInline: theme2.styles.space / 1.5,
|
|
4068
|
+
filterHover: onClick || onClickWithValue ? filterHover().z1 : void 0,
|
|
3979
4069
|
onClick: onClickElement,
|
|
3980
4070
|
cursor: onClick || onClickWithValue ? "pointer" : void 0,
|
|
3981
4071
|
...props,
|
|
@@ -5492,96 +5582,6 @@ var countries = [
|
|
|
5492
5582
|
|
|
5493
5583
|
// src/utils/functions.ts
|
|
5494
5584
|
import CryptoJS from "crypto-js";
|
|
5495
|
-
|
|
5496
|
-
// src/utils/variableFunctions.ts
|
|
5497
|
-
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
5498
|
-
if (value === void 0) {
|
|
5499
|
-
throw new Error(
|
|
5500
|
-
`\`${functionsName}()\` must be used within a \`<BetterHtmlProvider>\`. Make sure to add one at the root of your component tree.`
|
|
5501
|
-
);
|
|
5502
|
-
}
|
|
5503
|
-
return value !== void 0;
|
|
5504
|
-
};
|
|
5505
|
-
var loaderControls = {
|
|
5506
|
-
startLoading: (loaderName) => {
|
|
5507
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.startLoading")) return;
|
|
5508
|
-
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
5509
|
-
...oldValue,
|
|
5510
|
-
[loaderName.toString()]: true
|
|
5511
|
-
}));
|
|
5512
|
-
},
|
|
5513
|
-
stopLoading: (loaderName) => {
|
|
5514
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.stopLoading")) return;
|
|
5515
|
-
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
5516
|
-
...oldValue,
|
|
5517
|
-
[loaderName.toString()]: false
|
|
5518
|
-
}));
|
|
5519
|
-
}
|
|
5520
|
-
};
|
|
5521
|
-
var alertControls = {
|
|
5522
|
-
createAlert: (alert) => {
|
|
5523
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.createAlert"))
|
|
5524
|
-
return void 0;
|
|
5525
|
-
const readyAlert = {
|
|
5526
|
-
id: crypto.randomUUID(),
|
|
5527
|
-
...alert
|
|
5528
|
-
};
|
|
5529
|
-
externalBetterHtmlContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
5530
|
-
return readyAlert;
|
|
5531
|
-
},
|
|
5532
|
-
removeAlert: (alertId) => {
|
|
5533
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.removeAlert")) return;
|
|
5534
|
-
externalBetterHtmlContextValue.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
5535
|
-
}
|
|
5536
|
-
};
|
|
5537
|
-
var sideMenuControls = {
|
|
5538
|
-
expand: () => {
|
|
5539
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.expand")) return;
|
|
5540
|
-
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setFalse();
|
|
5541
|
-
},
|
|
5542
|
-
collapse: () => {
|
|
5543
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.collapse")) return;
|
|
5544
|
-
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setTrue();
|
|
5545
|
-
},
|
|
5546
|
-
toggleExpanded: () => {
|
|
5547
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleExpanded")) return;
|
|
5548
|
-
externalBetterHtmlContextValue.setSideMenuIsCollapsed.toggle();
|
|
5549
|
-
},
|
|
5550
|
-
open: () => {
|
|
5551
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.open")) return;
|
|
5552
|
-
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setTrue();
|
|
5553
|
-
},
|
|
5554
|
-
close: () => {
|
|
5555
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.close")) return;
|
|
5556
|
-
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setFalse();
|
|
5557
|
-
},
|
|
5558
|
-
toggleOpened: () => {
|
|
5559
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleOpened")) return;
|
|
5560
|
-
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.toggle();
|
|
5561
|
-
}
|
|
5562
|
-
};
|
|
5563
|
-
var colorThemeControls = {
|
|
5564
|
-
toggleTheme: (theme2) => {
|
|
5565
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "colorThemeControls.toggleTheme")) return;
|
|
5566
|
-
const currentColorTheme = externalBetterHtmlContextValue.colorTheme;
|
|
5567
|
-
const newColorTheme = theme2 ?? (currentColorTheme === "dark" ? "light" : "dark");
|
|
5568
|
-
setTimeout(() => {
|
|
5569
|
-
window.document.body.parentElement?.setAttribute("data-theme", newColorTheme);
|
|
5570
|
-
localStorage.setItem("theme", newColorTheme);
|
|
5571
|
-
}, 0.01 * 1e3);
|
|
5572
|
-
}
|
|
5573
|
-
};
|
|
5574
|
-
var filterHover = () => {
|
|
5575
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "filterHover")) return void 0;
|
|
5576
|
-
return {
|
|
5577
|
-
z05: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.95)",
|
|
5578
|
-
z1: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.3)" : "brightness(0.9)",
|
|
5579
|
-
z2: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.6)" : "brightness(0.8)",
|
|
5580
|
-
z3: externalBetterHtmlContextValue.colorTheme === "dark" ? "brightness(1.9)" : "brightness(0.7)"
|
|
5581
|
-
};
|
|
5582
|
-
};
|
|
5583
|
-
|
|
5584
|
-
// src/utils/functions.ts
|
|
5585
5585
|
var generateRandomString = (stringLength, options) => {
|
|
5586
5586
|
const capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
5587
5587
|
const lowers = "abcdefghijklmnopqrstuvwxyz";
|
|
@@ -5779,7 +5779,8 @@ var DropdownComponent = forwardRef10(function Dropdown({
|
|
|
5779
5779
|
if (event.key === "Enter" || !withSearch && event.key === " ") {
|
|
5780
5780
|
event.preventDefault();
|
|
5781
5781
|
if (!disabled) {
|
|
5782
|
-
setIsOpen.
|
|
5782
|
+
if (withMultiselect) setIsOpen.setTrue();
|
|
5783
|
+
else setIsOpen.toggle();
|
|
5783
5784
|
if (isOpen && filteredOptions.length > 0 && focusedOptionIndex !== void 0) {
|
|
5784
5785
|
const option = filteredOptions[focusedOptionIndex];
|
|
5785
5786
|
if (!option.disabled) {
|
|
@@ -5787,10 +5788,12 @@ var DropdownComponent = forwardRef10(function Dropdown({
|
|
|
5787
5788
|
const newValue = withMultiselect ? Array.isArray(internalValue) ? internalValue?.includes(clickedValue) ? internalValue.filter((value2) => value2 !== clickedValue) : [...internalValue, clickedValue] : [clickedValue] : clickedValue;
|
|
5788
5789
|
if (controlledValue === void 0) setInternalValue(newValue);
|
|
5789
5790
|
onChange?.(newValue);
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5791
|
+
if (!withMultiselect) {
|
|
5792
|
+
setIsOpen.setFalse();
|
|
5793
|
+
inputRef.current?.blur();
|
|
5794
|
+
setSearchQuery("");
|
|
5795
|
+
setFocusedOptionIndex(void 0);
|
|
5796
|
+
}
|
|
5794
5797
|
}
|
|
5795
5798
|
}
|
|
5796
5799
|
}
|
|
@@ -5834,10 +5837,12 @@ var DropdownComponent = forwardRef10(function Dropdown({
|
|
|
5834
5837
|
const newValue = withMultiselect ? Array.isArray(internalValue) ? internalValue?.includes(clickedValue) ? internalValue.filter((value2) => value2 !== clickedValue) : [...internalValue, clickedValue] : [clickedValue] : clickedValue;
|
|
5835
5838
|
if (controlledValue === void 0) setInternalValue(newValue);
|
|
5836
5839
|
onChange?.(newValue);
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5840
|
+
if (!withMultiselect) {
|
|
5841
|
+
setIsOpen.setFalse();
|
|
5842
|
+
inputRef.current?.blur();
|
|
5843
|
+
setSearchQuery("");
|
|
5844
|
+
setFocusedOptionIndex(void 0);
|
|
5845
|
+
}
|
|
5841
5846
|
}
|
|
5842
5847
|
},
|
|
5843
5848
|
[onChange, internalValue, controlledValue, withMultiselect]
|