react-better-html 1.1.157 → 1.1.159
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 +27 -4
- package/dist/index.d.ts +27 -4
- package/dist/index.js +297 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1526,19 +1526,6 @@ import { memo as memo7 } from "react";
|
|
|
1526
1526
|
import { memo as memo6, useCallback as useCallback2, useEffect as useEffect3, useMemo, useRef, useState } from "react";
|
|
1527
1527
|
import styled6 from "styled-components";
|
|
1528
1528
|
|
|
1529
|
-
// src/plugins/react-router-dom.ts
|
|
1530
|
-
import { Link as RouterLink, NavLink as RouterNavLink } from "react-router-dom";
|
|
1531
|
-
var reactRouterDomPlugin = () => ({
|
|
1532
|
-
name: "react-router-dom",
|
|
1533
|
-
components: {
|
|
1534
|
-
Link: RouterLink,
|
|
1535
|
-
NavLink: RouterNavLink
|
|
1536
|
-
},
|
|
1537
|
-
initialize: () => {
|
|
1538
|
-
console.log("react-router-dom plugin initialized");
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1541
|
-
|
|
1542
1529
|
// src/plugins/alerts.ts
|
|
1543
1530
|
var defaultAlertsPluginOptions = {
|
|
1544
1531
|
position: "bottom",
|
|
@@ -1559,6 +1546,39 @@ var alertsPlugin = (options) => ({
|
|
|
1559
1546
|
})
|
|
1560
1547
|
});
|
|
1561
1548
|
|
|
1549
|
+
// src/plugins/reactRouterDom.ts
|
|
1550
|
+
import { Link as RouterLink, NavLink as RouterNavLink } from "react-router-dom";
|
|
1551
|
+
var defaultReactRouterDomPluginOptions = {};
|
|
1552
|
+
var reactRouterDomPlugin = (options) => ({
|
|
1553
|
+
name: "react-router-dom",
|
|
1554
|
+
components: {
|
|
1555
|
+
Link: RouterLink,
|
|
1556
|
+
NavLink: RouterNavLink
|
|
1557
|
+
},
|
|
1558
|
+
initialize: () => {
|
|
1559
|
+
console.log("react-router-dom plugin initialized");
|
|
1560
|
+
},
|
|
1561
|
+
getConfig: () => ({
|
|
1562
|
+
...defaultReactRouterDomPluginOptions,
|
|
1563
|
+
...options
|
|
1564
|
+
})
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
// src/plugins/localStorage.ts
|
|
1568
|
+
var defaultLocalStoragePluginOptions = {
|
|
1569
|
+
encryption: {}
|
|
1570
|
+
};
|
|
1571
|
+
var localStoragePlugin = (options) => ({
|
|
1572
|
+
name: "localStorage",
|
|
1573
|
+
initialize: () => {
|
|
1574
|
+
console.log("localStorage plugin initialized");
|
|
1575
|
+
},
|
|
1576
|
+
getConfig: () => ({
|
|
1577
|
+
...defaultLocalStoragePluginOptions,
|
|
1578
|
+
...options
|
|
1579
|
+
})
|
|
1580
|
+
});
|
|
1581
|
+
|
|
1562
1582
|
// src/components/Icon.tsx
|
|
1563
1583
|
import { forwardRef, memo, useEffect } from "react";
|
|
1564
1584
|
import styled from "styled-components";
|
|
@@ -2637,12 +2657,17 @@ function useStyledComponentStyles(props, theme2, excludeProps) {
|
|
|
2637
2657
|
haveHover = true;
|
|
2638
2658
|
const normalKey = key.slice(0, -5);
|
|
2639
2659
|
hoverStyle[normalKey] = props[key];
|
|
2660
|
+
if (normalKey === "transition") hoverStyle.WebkitTransition = hoverStyle.transition;
|
|
2640
2661
|
} else {
|
|
2641
2662
|
if (!cssProps[key.toLowerCase()]) continue;
|
|
2642
2663
|
normalStyle[key] = props[key];
|
|
2664
|
+
if (key === "transition") normalStyle.WebkitTransition = normalStyle.transition;
|
|
2643
2665
|
}
|
|
2644
2666
|
}
|
|
2645
|
-
if (haveHover)
|
|
2667
|
+
if (haveHover) {
|
|
2668
|
+
normalStyle.transition = theme2?.styles.transition ?? "";
|
|
2669
|
+
normalStyle.WebkitTransition = normalStyle.transition;
|
|
2670
|
+
}
|
|
2646
2671
|
return {
|
|
2647
2672
|
normalStyle,
|
|
2648
2673
|
hoverStyle
|
|
@@ -3848,7 +3873,7 @@ Chip2.colored = ChipComponent.colored;
|
|
|
3848
3873
|
var Chip_default = Chip2;
|
|
3849
3874
|
|
|
3850
3875
|
// src/components/InputField.tsx
|
|
3851
|
-
import { forwardRef as forwardRef11, memo as memo18, useCallback as useCallback9, useState as useState7, useEffect as useEffect8, useMemo as useMemo6, useRef as useRef5, useId } from "react";
|
|
3876
|
+
import { forwardRef as forwardRef11, memo as memo18, useCallback as useCallback9, useState as useState7, useEffect as useEffect8, useMemo as useMemo6, useRef as useRef5, useId as useId2 } from "react";
|
|
3852
3877
|
import styled10 from "styled-components";
|
|
3853
3878
|
|
|
3854
3879
|
// src/constants/countries.ts
|
|
@@ -4307,13 +4332,15 @@ var countries = [
|
|
|
4307
4332
|
name: "Finland",
|
|
4308
4333
|
code: "FI",
|
|
4309
4334
|
timeZone: "Europe/Helsinki",
|
|
4310
|
-
phoneNumberExtension: "358"
|
|
4335
|
+
phoneNumberExtension: "358",
|
|
4336
|
+
phoneNumberFormat: "XX XXX XX XX"
|
|
4311
4337
|
},
|
|
4312
4338
|
{
|
|
4313
4339
|
name: "France",
|
|
4314
4340
|
code: "FR",
|
|
4315
4341
|
timeZone: "Europe/Paris",
|
|
4316
|
-
phoneNumberExtension: "33"
|
|
4342
|
+
phoneNumberExtension: "33",
|
|
4343
|
+
phoneNumberFormat: "X XX XX XX XX"
|
|
4317
4344
|
},
|
|
4318
4345
|
{
|
|
4319
4346
|
name: "French Guiana",
|
|
@@ -4356,7 +4383,7 @@ var countries = [
|
|
|
4356
4383
|
code: "DE",
|
|
4357
4384
|
timeZone: "Europe/Berlin",
|
|
4358
4385
|
phoneNumberExtension: "49",
|
|
4359
|
-
phoneNumberFormat: "XXXX
|
|
4386
|
+
phoneNumberFormat: "XXXX XXXXXXX"
|
|
4360
4387
|
},
|
|
4361
4388
|
{
|
|
4362
4389
|
name: "Ghana",
|
|
@@ -5332,6 +5359,62 @@ var countries = [
|
|
|
5332
5359
|
}
|
|
5333
5360
|
];
|
|
5334
5361
|
|
|
5362
|
+
// src/utils/functions.ts
|
|
5363
|
+
import CryptoJS from "crypto-js";
|
|
5364
|
+
|
|
5365
|
+
// src/utils/variableFunctions.ts
|
|
5366
|
+
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
5367
|
+
if (value === void 0) {
|
|
5368
|
+
throw new Error(
|
|
5369
|
+
`\`${functionsName}()\` must be used within a \`<BetterHtmlProvider>\`. Make sure to add one at the root of your component tree.`
|
|
5370
|
+
);
|
|
5371
|
+
}
|
|
5372
|
+
return value !== void 0;
|
|
5373
|
+
};
|
|
5374
|
+
var loaderControls = {
|
|
5375
|
+
startLoading: (loaderName) => {
|
|
5376
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.startLoading")) return;
|
|
5377
|
+
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
5378
|
+
...oldValue,
|
|
5379
|
+
[loaderName.toString()]: true
|
|
5380
|
+
}));
|
|
5381
|
+
},
|
|
5382
|
+
stopLoading: (loaderName) => {
|
|
5383
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.stopLoading")) return;
|
|
5384
|
+
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
5385
|
+
...oldValue,
|
|
5386
|
+
[loaderName.toString()]: false
|
|
5387
|
+
}));
|
|
5388
|
+
}
|
|
5389
|
+
};
|
|
5390
|
+
var alertControls = {
|
|
5391
|
+
createAlert: (alert) => {
|
|
5392
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.createAlert"))
|
|
5393
|
+
return void 0;
|
|
5394
|
+
const readyAlert = {
|
|
5395
|
+
id: crypto.randomUUID(),
|
|
5396
|
+
...alert
|
|
5397
|
+
};
|
|
5398
|
+
externalBetterHtmlContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
5399
|
+
return readyAlert;
|
|
5400
|
+
},
|
|
5401
|
+
removeAlert: (alertId) => {
|
|
5402
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.removeAlert")) return;
|
|
5403
|
+
externalBetterHtmlContextValue.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
5404
|
+
}
|
|
5405
|
+
};
|
|
5406
|
+
var colorThemeControls = {
|
|
5407
|
+
toggleTheme: (theme2) => {
|
|
5408
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "colorThemeControls.toggleTheme")) return;
|
|
5409
|
+
const currentColorTheme = externalBetterHtmlContextValue.colorTheme;
|
|
5410
|
+
const newColorTheme = theme2 ?? (currentColorTheme === "dark" ? "light" : "dark");
|
|
5411
|
+
setTimeout(() => {
|
|
5412
|
+
window.document.body.parentElement?.setAttribute("data-theme", newColorTheme);
|
|
5413
|
+
localStorage.setItem("theme", newColorTheme);
|
|
5414
|
+
}, 0.01 * 1e3);
|
|
5415
|
+
}
|
|
5416
|
+
};
|
|
5417
|
+
|
|
5335
5418
|
// src/utils/functions.ts
|
|
5336
5419
|
var generateRandomString = (stringLength, options) => {
|
|
5337
5420
|
const capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
@@ -5403,6 +5486,40 @@ var eventPreventStop = (event) => {
|
|
|
5403
5486
|
event.preventDefault();
|
|
5404
5487
|
event.stopPropagation();
|
|
5405
5488
|
};
|
|
5489
|
+
var encryptString = (text) => {
|
|
5490
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "encryptString")) return void 0;
|
|
5491
|
+
const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find((plugin) => plugin.name === "localStorage");
|
|
5492
|
+
if (!localStoragePlugin2) {
|
|
5493
|
+
throw new Error(
|
|
5494
|
+
"`encryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
5495
|
+
);
|
|
5496
|
+
}
|
|
5497
|
+
const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
|
|
5498
|
+
if (!pluginConfig?.encryption?.enabled) return text;
|
|
5499
|
+
const encrypted = CryptoJS.AES.encrypt(text, CryptoJS.enc.Hex.parse(pluginConfig.encryption.secretKey), {
|
|
5500
|
+
iv: CryptoJS.enc.Hex.parse(pluginConfig.encryption.iv),
|
|
5501
|
+
mode: CryptoJS.mode.CBC,
|
|
5502
|
+
padding: CryptoJS.pad.Pkcs7
|
|
5503
|
+
}).toString();
|
|
5504
|
+
return encrypted;
|
|
5505
|
+
};
|
|
5506
|
+
var decryptString = (text) => {
|
|
5507
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "decryptString")) return void 0;
|
|
5508
|
+
const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find((plugin) => plugin.name === "localStorage");
|
|
5509
|
+
if (!localStoragePlugin2) {
|
|
5510
|
+
throw new Error(
|
|
5511
|
+
"`decryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
5512
|
+
);
|
|
5513
|
+
}
|
|
5514
|
+
const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
|
|
5515
|
+
if (!pluginConfig?.encryption?.enabled) return text;
|
|
5516
|
+
const decrypted = CryptoJS.AES.decrypt(text, CryptoJS.enc.Hex.parse(pluginConfig.encryption.secretKey), {
|
|
5517
|
+
iv: CryptoJS.enc.Hex.parse(pluginConfig.encryption.iv),
|
|
5518
|
+
mode: CryptoJS.mode.CBC,
|
|
5519
|
+
padding: CryptoJS.pad.Pkcs7
|
|
5520
|
+
});
|
|
5521
|
+
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
5522
|
+
};
|
|
5406
5523
|
|
|
5407
5524
|
// src/components/Label.tsx
|
|
5408
5525
|
import { memo as memo15 } from "react";
|
|
@@ -5773,7 +5890,7 @@ Dropdown2.countries = DropdownComponent.countries;
|
|
|
5773
5890
|
var Dropdown_default = Dropdown2;
|
|
5774
5891
|
|
|
5775
5892
|
// src/components/Calendar.tsx
|
|
5776
|
-
import { useCallback as useCallback8, useMemo as useMemo5, useState as useState6, memo as memo17, useEffect as useEffect7 } from "react";
|
|
5893
|
+
import { useCallback as useCallback8, useMemo as useMemo5, useState as useState6, memo as memo17, useEffect as useEffect7, useId } from "react";
|
|
5777
5894
|
import styled9 from "styled-components";
|
|
5778
5895
|
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5779
5896
|
var getMonthName = (month, short = false) => {
|
|
@@ -5805,8 +5922,18 @@ var getWeekDayName = (day, short = false) => {
|
|
|
5805
5922
|
};
|
|
5806
5923
|
var weekDaysIndex = [1, 2, 3, 4, 5, 6, 0];
|
|
5807
5924
|
var yearsRange = Array.from({ length: 100 + 1 + 50 }, (_, index) => index + (/* @__PURE__ */ new Date()).getFullYear() - 100);
|
|
5925
|
+
var SelectWrapperComponent = styled9.div.withConfig({
|
|
5926
|
+
shouldForwardProp: (prop) => !["theme"].includes(prop)
|
|
5927
|
+
})`
|
|
5928
|
+
&:has(select:focus) {
|
|
5929
|
+
outline: auto;
|
|
5930
|
+
outline-color: -webkit-focus-ring-color;
|
|
5931
|
+
outline-style: auto;
|
|
5932
|
+
outline-offset: 2px;
|
|
5933
|
+
}
|
|
5934
|
+
`;
|
|
5808
5935
|
var SelectComponent = styled9.select.withConfig({
|
|
5809
|
-
shouldForwardProp: (prop) => !["
|
|
5936
|
+
shouldForwardProp: (prop) => !["theme"].includes(prop)
|
|
5810
5937
|
})`
|
|
5811
5938
|
position: absolute;
|
|
5812
5939
|
top: 50%;
|
|
@@ -5816,6 +5943,7 @@ var SelectComponent = styled9.select.withConfig({
|
|
|
5816
5943
|
`;
|
|
5817
5944
|
function Calendar({ value, minDate, maxDate, onChange }) {
|
|
5818
5945
|
const theme2 = useTheme();
|
|
5946
|
+
const internalYearSelectId = useId();
|
|
5819
5947
|
const [currentDate, setCurrentDate] = useState6(value ? new Date(value) : void 0);
|
|
5820
5948
|
const [currentMonth, setCurrentMonth] = useState6(currentDate?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth());
|
|
5821
5949
|
const [currentYear, setCurrentYear] = useState6(currentDate?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear());
|
|
@@ -5883,11 +6011,20 @@ function Calendar({ value, minDate, maxDate, onChange }) {
|
|
|
5883
6011
|
/* @__PURE__ */ jsx16(Button_default.icon, { icon: "chevronLeft", onClick: onClickPreviousMonthButton }),
|
|
5884
6012
|
/* @__PURE__ */ jsxs11(Div_default.row, { alignItems: "center", gap: 4, children: [
|
|
5885
6013
|
/* @__PURE__ */ jsx16(Text_default, { fontWeight: 700, children: getMonthName(currentMonth) }),
|
|
5886
|
-
/* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", alignItems: "center", gap: 2, children: [
|
|
6014
|
+
/* @__PURE__ */ jsx16(SelectWrapperComponent, { children: /* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", alignItems: "center", gap: 2, children: [
|
|
5887
6015
|
/* @__PURE__ */ jsx16(Text_default, { fontWeight: 700, children: currentYear }),
|
|
5888
6016
|
/* @__PURE__ */ jsx16(Icon_default, { name: "chevronDown", size: 12 }),
|
|
5889
|
-
/* @__PURE__ */ jsx16(
|
|
5890
|
-
|
|
6017
|
+
/* @__PURE__ */ jsx16(
|
|
6018
|
+
SelectComponent,
|
|
6019
|
+
{
|
|
6020
|
+
theme: theme2,
|
|
6021
|
+
value: currentYear,
|
|
6022
|
+
onChange: onChangeYearSelect,
|
|
6023
|
+
id: internalYearSelectId,
|
|
6024
|
+
children: yearsRange.map((year) => /* @__PURE__ */ jsx16("option", { value: year, children: year }, year))
|
|
6025
|
+
}
|
|
6026
|
+
)
|
|
6027
|
+
] }) })
|
|
5891
6028
|
] }),
|
|
5892
6029
|
/* @__PURE__ */ jsx16(Button_default.icon, { icon: "chevronRight", onClick: onClickNextMonthButton })
|
|
5893
6030
|
] }),
|
|
@@ -6011,6 +6148,10 @@ var InputElement = styled10.input.withConfig({
|
|
|
6011
6148
|
cursor: not-allowed;
|
|
6012
6149
|
}
|
|
6013
6150
|
|
|
6151
|
+
&:read-only {
|
|
6152
|
+
caret-color: transparent;
|
|
6153
|
+
}
|
|
6154
|
+
|
|
6014
6155
|
&::-webkit-outer-spin-button,
|
|
6015
6156
|
&::-webkit-inner-spin-button {
|
|
6016
6157
|
-webkit-appearance: none;
|
|
@@ -6148,7 +6289,7 @@ var InputFieldComponent = forwardRef11(function InputField({
|
|
|
6148
6289
|
...props
|
|
6149
6290
|
}, ref) {
|
|
6150
6291
|
const theme2 = useTheme();
|
|
6151
|
-
const internalId =
|
|
6292
|
+
const internalId = useId2();
|
|
6152
6293
|
const { colorTheme } = useBetterHtmlContextInternal();
|
|
6153
6294
|
const [_, debouncedValue, setDebouncedValue] = useDebounceState(
|
|
6154
6295
|
props.value?.toString() ?? "",
|
|
@@ -6297,7 +6438,7 @@ InputFieldComponent.multiline = forwardRef11(function Multiline({
|
|
|
6297
6438
|
...props
|
|
6298
6439
|
}, ref) {
|
|
6299
6440
|
const theme2 = useTheme();
|
|
6300
|
-
const internalId =
|
|
6441
|
+
const internalId = useId2();
|
|
6301
6442
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
6302
6443
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
6303
6444
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
@@ -6452,7 +6593,7 @@ InputFieldComponent.search = forwardRef11(function Search({ value, onChangeValue
|
|
|
6452
6593
|
});
|
|
6453
6594
|
InputFieldComponent.phoneNumber = forwardRef11(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
|
|
6454
6595
|
const theme2 = useTheme();
|
|
6455
|
-
const internalId =
|
|
6596
|
+
const internalId = useId2();
|
|
6456
6597
|
const [dropdownValue, setDropdownValue] = useState7();
|
|
6457
6598
|
const [inputFieldValue, setInputFieldValue] = useState7(value?.toString() ?? "");
|
|
6458
6599
|
const renderOption = useCallback9(
|
|
@@ -6667,6 +6808,7 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
|
|
|
6667
6808
|
width: buttonWidth,
|
|
6668
6809
|
height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
|
|
6669
6810
|
overflowY: "auto",
|
|
6811
|
+
tabIndex: -1,
|
|
6670
6812
|
children: hours.map((hour) => {
|
|
6671
6813
|
const isSelected = hour.toString() === valueHour;
|
|
6672
6814
|
return /* @__PURE__ */ jsx17(
|
|
@@ -6700,6 +6842,7 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
|
|
|
6700
6842
|
width: buttonWidth,
|
|
6701
6843
|
height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
|
|
6702
6844
|
overflowY: "auto",
|
|
6845
|
+
tabIndex: -1,
|
|
6703
6846
|
children: minutes.map((minute) => {
|
|
6704
6847
|
const isSelected = minute.toString() === valueMinute;
|
|
6705
6848
|
return /* @__PURE__ */ jsx17(
|
|
@@ -6788,46 +6931,66 @@ InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
|
|
|
6788
6931
|
userSelect: "none",
|
|
6789
6932
|
...insideInputFieldComponentProps,
|
|
6790
6933
|
children: /* @__PURE__ */ jsxs12(Div_default.row, { height: "100%", children: [
|
|
6791
|
-
/* @__PURE__ */ jsx17(
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6934
|
+
/* @__PURE__ */ jsx17(
|
|
6935
|
+
Div_default,
|
|
6936
|
+
{
|
|
6937
|
+
className: "react-better-html-no-scrollbar",
|
|
6938
|
+
width: buttonWidth,
|
|
6939
|
+
height: "100%",
|
|
6940
|
+
overflowY: "auto",
|
|
6941
|
+
tabIndex: -1,
|
|
6942
|
+
children: hours.map((hour) => {
|
|
6943
|
+
const isSelected = hour.toString() === valueHour;
|
|
6944
|
+
return /* @__PURE__ */ jsx17(
|
|
6945
|
+
Div_default.row,
|
|
6946
|
+
{
|
|
6947
|
+
alignItems: "center",
|
|
6948
|
+
justifyContent: "center",
|
|
6949
|
+
color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
6950
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
6951
|
+
filterHover: "brightness(0.9)",
|
|
6952
|
+
cursor: "pointer",
|
|
6953
|
+
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
6954
|
+
value: hour,
|
|
6955
|
+
onClickWithValue: onClickHour,
|
|
6956
|
+
ref: isSelected ? selectedHourRef : void 0,
|
|
6957
|
+
children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: hour.toString().padStart(2, "0") })
|
|
6958
|
+
},
|
|
6959
|
+
hour
|
|
6960
|
+
);
|
|
6961
|
+
})
|
|
6962
|
+
}
|
|
6963
|
+
),
|
|
6964
|
+
/* @__PURE__ */ jsx17(
|
|
6965
|
+
Div_default,
|
|
6966
|
+
{
|
|
6967
|
+
className: "react-better-html-no-scrollbar",
|
|
6968
|
+
width: buttonWidth,
|
|
6969
|
+
height: "100%",
|
|
6970
|
+
overflowY: "auto",
|
|
6971
|
+
tabIndex: -1,
|
|
6972
|
+
children: minutes.map((minute) => {
|
|
6973
|
+
const isSelected = minute.toString() === valueMinute;
|
|
6974
|
+
return /* @__PURE__ */ jsx17(
|
|
6975
|
+
Div_default.row,
|
|
6976
|
+
{
|
|
6977
|
+
alignItems: "center",
|
|
6978
|
+
justifyContent: "center",
|
|
6979
|
+
color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
6980
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
6981
|
+
filterHover: "brightness(0.9)",
|
|
6982
|
+
cursor: "pointer",
|
|
6983
|
+
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
6984
|
+
value: minute,
|
|
6985
|
+
onClickWithValue: onClickMinute,
|
|
6986
|
+
ref: isSelected ? selectedMinuteRef : void 0,
|
|
6987
|
+
children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: minute.toString().padStart(2, "0") })
|
|
6988
|
+
},
|
|
6989
|
+
minute
|
|
6990
|
+
);
|
|
6991
|
+
})
|
|
6992
|
+
}
|
|
6993
|
+
)
|
|
6831
6994
|
] })
|
|
6832
6995
|
}
|
|
6833
6996
|
) : void 0,
|
|
@@ -6890,7 +7053,7 @@ InputField2.color = InputFieldComponent.color;
|
|
|
6890
7053
|
var InputField_default = InputField2;
|
|
6891
7054
|
|
|
6892
7055
|
// src/components/ToggleInput.tsx
|
|
6893
|
-
import { forwardRef as forwardRef12, useCallback as useCallback10, useId as
|
|
7056
|
+
import { forwardRef as forwardRef12, useCallback as useCallback10, useId as useId3, useState as useState8 } from "react";
|
|
6894
7057
|
import styled11 from "styled-components";
|
|
6895
7058
|
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6896
7059
|
var componentSize = 26;
|
|
@@ -7001,7 +7164,7 @@ var ToggleInputComponent = forwardRef12(function ToggleInput({
|
|
|
7001
7164
|
...props
|
|
7002
7165
|
}, ref) {
|
|
7003
7166
|
const theme2 = useTheme();
|
|
7004
|
-
const internalId =
|
|
7167
|
+
const internalId = useId3();
|
|
7005
7168
|
const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
|
|
7006
7169
|
const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
|
|
7007
7170
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
@@ -7118,7 +7281,7 @@ var ToggleInput_default = {
|
|
|
7118
7281
|
...props
|
|
7119
7282
|
}, ref) {
|
|
7120
7283
|
const theme2 = useTheme();
|
|
7121
|
-
const internalId =
|
|
7284
|
+
const internalId = useId3();
|
|
7122
7285
|
const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
|
|
7123
7286
|
const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
|
|
7124
7287
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
@@ -7321,61 +7484,6 @@ var FormRow_default = FormRow2;
|
|
|
7321
7484
|
|
|
7322
7485
|
// src/components/ColorThemeSwitch.tsx
|
|
7323
7486
|
import { memo as memo21, useEffect as useEffect9 } from "react";
|
|
7324
|
-
|
|
7325
|
-
// src/utils/variableFunctions.ts
|
|
7326
|
-
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
7327
|
-
if (value === void 0) {
|
|
7328
|
-
throw new Error(
|
|
7329
|
-
`\`${functionsName}()\` must be used within a \`<BetterHtmlProvider>\`. Make sure to add one at the root of your component tree.`
|
|
7330
|
-
);
|
|
7331
|
-
}
|
|
7332
|
-
return value !== void 0;
|
|
7333
|
-
};
|
|
7334
|
-
var loaderControls = {
|
|
7335
|
-
startLoading: (loaderName) => {
|
|
7336
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.startLoading")) return;
|
|
7337
|
-
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
7338
|
-
...oldValue,
|
|
7339
|
-
[loaderName.toString()]: true
|
|
7340
|
-
}));
|
|
7341
|
-
},
|
|
7342
|
-
stopLoading: (loaderName) => {
|
|
7343
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "loaderControls.stopLoading")) return;
|
|
7344
|
-
externalBetterHtmlContextValue.setLoaders((oldValue) => ({
|
|
7345
|
-
...oldValue,
|
|
7346
|
-
[loaderName.toString()]: false
|
|
7347
|
-
}));
|
|
7348
|
-
}
|
|
7349
|
-
};
|
|
7350
|
-
var alertControls = {
|
|
7351
|
-
createAlert: (alert) => {
|
|
7352
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.createAlert"))
|
|
7353
|
-
return void 0;
|
|
7354
|
-
const readyAlert = {
|
|
7355
|
-
id: crypto.randomUUID(),
|
|
7356
|
-
...alert
|
|
7357
|
-
};
|
|
7358
|
-
externalBetterHtmlContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
7359
|
-
return readyAlert;
|
|
7360
|
-
},
|
|
7361
|
-
removeAlert: (alertId) => {
|
|
7362
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.removeAlert")) return;
|
|
7363
|
-
externalBetterHtmlContextValue.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
7364
|
-
}
|
|
7365
|
-
};
|
|
7366
|
-
var colorThemeControls = {
|
|
7367
|
-
toggleTheme: (theme2) => {
|
|
7368
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "colorThemeControls.toggleTheme")) return;
|
|
7369
|
-
const currentColorTheme = externalBetterHtmlContextValue.colorTheme;
|
|
7370
|
-
const newColorTheme = theme2 ?? (currentColorTheme === "dark" ? "light" : "dark");
|
|
7371
|
-
setTimeout(() => {
|
|
7372
|
-
window.document.body.parentElement?.setAttribute("data-theme", newColorTheme);
|
|
7373
|
-
localStorage.setItem("theme", newColorTheme);
|
|
7374
|
-
}, 0.01 * 1e3);
|
|
7375
|
-
}
|
|
7376
|
-
};
|
|
7377
|
-
|
|
7378
|
-
// src/components/ColorThemeSwitch.tsx
|
|
7379
7487
|
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7380
7488
|
var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
7381
7489
|
withMoon,
|
|
@@ -8989,6 +9097,71 @@ FoldableComponent.box = forwardRef18(function Box3({ ...props }, ref) {
|
|
|
8989
9097
|
var Foldable2 = memo25(FoldableComponent);
|
|
8990
9098
|
Foldable2.box = FoldableComponent.box;
|
|
8991
9099
|
var Foldable_default = Foldable2;
|
|
9100
|
+
|
|
9101
|
+
// src/utils/localStorage.ts
|
|
9102
|
+
function generateLocalStorage() {
|
|
9103
|
+
return {
|
|
9104
|
+
setItem: (name, value) => {
|
|
9105
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage"))
|
|
9106
|
+
return void 0;
|
|
9107
|
+
const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
|
|
9108
|
+
(plugin) => plugin.name === "localStorage"
|
|
9109
|
+
);
|
|
9110
|
+
if (!localStoragePlugin2) {
|
|
9111
|
+
throw new Error(
|
|
9112
|
+
"`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
9113
|
+
);
|
|
9114
|
+
}
|
|
9115
|
+
const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
|
|
9116
|
+
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
9117
|
+
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
9118
|
+
const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
|
|
9119
|
+
if (value) localStorage.setItem(readyName.toString(), readyValue);
|
|
9120
|
+
else localStorage.removeItem(readyName.toString());
|
|
9121
|
+
},
|
|
9122
|
+
getItem: (name) => {
|
|
9123
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage"))
|
|
9124
|
+
return void 0;
|
|
9125
|
+
const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
|
|
9126
|
+
(plugin) => plugin.name === "localStorage"
|
|
9127
|
+
);
|
|
9128
|
+
if (!localStoragePlugin2) {
|
|
9129
|
+
throw new Error(
|
|
9130
|
+
"`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
9131
|
+
);
|
|
9132
|
+
}
|
|
9133
|
+
const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
|
|
9134
|
+
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
9135
|
+
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
9136
|
+
const item = localStorage.getItem(readyName.toString());
|
|
9137
|
+
if (item === null) return void 0;
|
|
9138
|
+
try {
|
|
9139
|
+
return encryptionEnabled ? JSON.parse(decryptString(item)) : JSON.parse(item);
|
|
9140
|
+
} catch (error) {
|
|
9141
|
+
return void 0;
|
|
9142
|
+
}
|
|
9143
|
+
},
|
|
9144
|
+
removeItem: (name) => {
|
|
9145
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage"))
|
|
9146
|
+
return void 0;
|
|
9147
|
+
const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
|
|
9148
|
+
(plugin) => plugin.name === "localStorage"
|
|
9149
|
+
);
|
|
9150
|
+
if (!localStoragePlugin2) {
|
|
9151
|
+
throw new Error(
|
|
9152
|
+
"`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
9153
|
+
);
|
|
9154
|
+
}
|
|
9155
|
+
const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
|
|
9156
|
+
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
9157
|
+
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
9158
|
+
localStorage.removeItem(readyName.toString());
|
|
9159
|
+
},
|
|
9160
|
+
removeAllItems: () => {
|
|
9161
|
+
localStorage.clear();
|
|
9162
|
+
}
|
|
9163
|
+
};
|
|
9164
|
+
}
|
|
8992
9165
|
export {
|
|
8993
9166
|
BetterHtmlProvider_default as BetterHtmlProvider,
|
|
8994
9167
|
Button_default as Button,
|
|
@@ -9019,17 +9192,21 @@ export {
|
|
|
9019
9192
|
countries,
|
|
9020
9193
|
darkenColor,
|
|
9021
9194
|
defaultAlertsPluginOptions,
|
|
9195
|
+
defaultLocalStoragePluginOptions,
|
|
9196
|
+
defaultReactRouterDomPluginOptions,
|
|
9022
9197
|
desaturateColor,
|
|
9023
9198
|
eventPreventDefault,
|
|
9024
9199
|
eventPreventStop,
|
|
9025
9200
|
eventStopPropagation,
|
|
9026
9201
|
formatPhoneNumber,
|
|
9202
|
+
generateLocalStorage,
|
|
9027
9203
|
generateRandomString,
|
|
9028
9204
|
getBrowser,
|
|
9029
9205
|
getFormErrorObject,
|
|
9030
9206
|
isMobileDevice,
|
|
9031
9207
|
lightenColor,
|
|
9032
9208
|
loaderControls,
|
|
9209
|
+
localStoragePlugin,
|
|
9033
9210
|
reactRouterDomPlugin,
|
|
9034
9211
|
saturateColor,
|
|
9035
9212
|
useAlertControls,
|