react-better-html 1.1.79 → 1.1.80
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 +55 -2
- package/dist/index.d.ts +55 -2
- package/dist/index.js +339 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +389 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1501,9 +1501,17 @@ var useBetterHtmlContext = () => {
|
|
|
1501
1501
|
throw new Error(
|
|
1502
1502
|
"`useBetterHtmlContext()` must be used within a `<BetterHtmlProvider>`. Make sure to add one at the root of your component tree."
|
|
1503
1503
|
);
|
|
1504
|
-
const { setLoaders, plugins, ...rest } = context;
|
|
1504
|
+
const { setLoaders, plugins, tabsComponentState, ...rest } = context;
|
|
1505
1505
|
return rest;
|
|
1506
1506
|
};
|
|
1507
|
+
var useBetterHtmlContextInternal = () => {
|
|
1508
|
+
const context = useContext(betterHtmlContext);
|
|
1509
|
+
if (context === void 0)
|
|
1510
|
+
throw new Error(
|
|
1511
|
+
"`useBetterHtmlContextInternal()` must be used within a `<BetterHtmlProvider>`. Make sure to add one at the root of your component tree."
|
|
1512
|
+
);
|
|
1513
|
+
return context;
|
|
1514
|
+
};
|
|
1507
1515
|
var useTheme = () => {
|
|
1508
1516
|
const context = useContext(betterHtmlContext);
|
|
1509
1517
|
if (context === void 0)
|
|
@@ -1570,11 +1578,13 @@ function BetterHtmlProviderContent({ children }) {
|
|
|
1570
1578
|
] });
|
|
1571
1579
|
}
|
|
1572
1580
|
function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
|
|
1573
|
-
const [loaders, setLoaders] = useState(value?.loaders ?? {});
|
|
1574
|
-
const [plugins] = useState(pluginsToUse ?? []);
|
|
1575
1581
|
const [colorTheme, setColorTheme] = useState(
|
|
1576
1582
|
localStorage.getItem("theme") === "dark" ? "dark" : value?.colorTheme ?? "light"
|
|
1577
1583
|
);
|
|
1584
|
+
const [loaders, setLoaders] = useState(value?.loaders ?? {});
|
|
1585
|
+
const [plugins] = useState(pluginsToUse ?? []);
|
|
1586
|
+
const [tabGroups, setTabGroups] = useState([]);
|
|
1587
|
+
const [tabsWithDots, setTabsWithDots] = useState([]);
|
|
1578
1588
|
const readyValue = useMemo(
|
|
1579
1589
|
() => ({
|
|
1580
1590
|
app: {
|
|
@@ -1611,9 +1621,15 @@ function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
|
|
|
1611
1621
|
components: {
|
|
1612
1622
|
...value?.components
|
|
1613
1623
|
},
|
|
1614
|
-
plugins
|
|
1624
|
+
plugins,
|
|
1625
|
+
tabsComponentState: {
|
|
1626
|
+
tabGroups,
|
|
1627
|
+
setTabGroups,
|
|
1628
|
+
tabsWithDots,
|
|
1629
|
+
setTabsWithDots
|
|
1630
|
+
}
|
|
1615
1631
|
}),
|
|
1616
|
-
[value, colorTheme, loaders, plugins]
|
|
1632
|
+
[value, colorTheme, loaders, plugins, tabGroups, tabsWithDots]
|
|
1617
1633
|
);
|
|
1618
1634
|
useEffect(() => {
|
|
1619
1635
|
plugins.forEach((plugin) => {
|
|
@@ -2314,7 +2330,7 @@ var IconElement = styled4.svg.withConfig({
|
|
|
2314
2330
|
`;
|
|
2315
2331
|
var Icon = forwardRef3(function Icon2({ name, size = 16, ...props }, ref) {
|
|
2316
2332
|
const theme2 = useTheme();
|
|
2317
|
-
const { icons: icons2 } =
|
|
2333
|
+
const { icons: icons2 } = useBetterHtmlContextInternal();
|
|
2318
2334
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
2319
2335
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2320
2336
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
@@ -2373,7 +2389,7 @@ var ImageElement = styled5.img.withConfig({
|
|
|
2373
2389
|
`;
|
|
2374
2390
|
var Image = forwardRef4(function Image2({ name, src, ...props }, ref) {
|
|
2375
2391
|
const theme2 = useTheme();
|
|
2376
|
-
const { assets: assets2 } =
|
|
2392
|
+
const { assets: assets2 } = useBetterHtmlContextInternal();
|
|
2377
2393
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
2378
2394
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2379
2395
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
@@ -2406,11 +2422,11 @@ MemoizedImage.profileImage = Image.profileImage;
|
|
|
2406
2422
|
var Image_default = { Image: MemoizedImage }.Image;
|
|
2407
2423
|
|
|
2408
2424
|
// src/components/Button.tsx
|
|
2409
|
-
import { memo as memo7, useCallback as
|
|
2425
|
+
import { memo as memo7, useCallback as useCallback4 } from "react";
|
|
2410
2426
|
import styled6, { css } from "styled-components";
|
|
2411
2427
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2412
2428
|
var ButtonElement = styled6.button.withConfig({
|
|
2413
|
-
shouldForwardProp: (prop) => !["theme", "normalStyle", "hoverStyle", "isSmall", "withText", "isLoading"].includes(prop)
|
|
2429
|
+
shouldForwardProp: (prop) => !["theme", "colorTheme", "normalStyle", "hoverStyle", "isSmall", "withText", "isLoading"].includes(prop)
|
|
2414
2430
|
})`
|
|
2415
2431
|
display: block;
|
|
2416
2432
|
position: relative;
|
|
@@ -2432,15 +2448,11 @@ var ButtonElement = styled6.button.withConfig({
|
|
|
2432
2448
|
${(props) => props.disabled ? css`
|
|
2433
2449
|
opacity: 0.6;
|
|
2434
2450
|
cursor: not-allowed;
|
|
2435
|
-
|
|
2436
|
-
&.secondary:disabled {
|
|
2437
|
-
filter: brightness(0.9);
|
|
2438
|
-
}
|
|
2439
2451
|
` : !props.isLoading ? css`
|
|
2440
2452
|
cursor: pointer;
|
|
2441
2453
|
|
|
2442
2454
|
&:not(.secondary):hover {
|
|
2443
|
-
filter: brightness(0.9);
|
|
2455
|
+
filter: ${props.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.9)"};
|
|
2444
2456
|
}
|
|
2445
2457
|
|
|
2446
2458
|
&.secondary:hover {
|
|
@@ -2489,7 +2501,7 @@ var ButtonComponent = function Button({
|
|
|
2489
2501
|
}) {
|
|
2490
2502
|
const theme2 = useTheme();
|
|
2491
2503
|
const isLoadingHook = useLoader(loaderName);
|
|
2492
|
-
const betterHtmlContext2 =
|
|
2504
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2493
2505
|
const isLoadingElement = isLoading ?? isLoadingHook;
|
|
2494
2506
|
const styledComponentStyles = useStyledComponentStyles(
|
|
2495
2507
|
{
|
|
@@ -2501,7 +2513,7 @@ var ButtonComponent = function Button({
|
|
|
2501
2513
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2502
2514
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
2503
2515
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
2504
|
-
const onClickElement =
|
|
2516
|
+
const onClickElement = useCallback4(
|
|
2505
2517
|
(event) => {
|
|
2506
2518
|
onClick?.(event);
|
|
2507
2519
|
onClickWithValue?.(value);
|
|
@@ -2530,6 +2542,7 @@ var ButtonComponent = function Button({
|
|
|
2530
2542
|
{
|
|
2531
2543
|
as: href ? "a" : "button",
|
|
2532
2544
|
theme: theme2,
|
|
2545
|
+
colorTheme: betterHtmlContext2.colorTheme,
|
|
2533
2546
|
isSmall,
|
|
2534
2547
|
withText: text !== void 0,
|
|
2535
2548
|
isLoading: isLoadingElement,
|
|
@@ -2591,7 +2604,7 @@ var ButtonComponent = function Button({
|
|
|
2591
2604
|
};
|
|
2592
2605
|
ButtonComponent.secondary = function Secondary({ className, ...props }) {
|
|
2593
2606
|
const theme2 = useTheme();
|
|
2594
|
-
const betterHtmlContext2 =
|
|
2607
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2595
2608
|
return /* @__PURE__ */ jsx7(
|
|
2596
2609
|
ButtonComponent,
|
|
2597
2610
|
{
|
|
@@ -2604,7 +2617,7 @@ ButtonComponent.secondary = function Secondary({ className, ...props }) {
|
|
|
2604
2617
|
};
|
|
2605
2618
|
ButtonComponent.destructive = function Destructive(props) {
|
|
2606
2619
|
const theme2 = useTheme();
|
|
2607
|
-
const betterHtmlContext2 =
|
|
2620
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2608
2621
|
return /* @__PURE__ */ jsx7(
|
|
2609
2622
|
ButtonComponent,
|
|
2610
2623
|
{
|
|
@@ -2617,7 +2630,7 @@ ButtonComponent.destructive = function Destructive(props) {
|
|
|
2617
2630
|
};
|
|
2618
2631
|
ButtonComponent.icon = function Icon3({ size = 16, backgroundButtonColor, ...props }) {
|
|
2619
2632
|
const theme2 = useTheme();
|
|
2620
|
-
const betterHtmlContext2 =
|
|
2633
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2621
2634
|
const buttonSize = size + theme2.styles.space;
|
|
2622
2635
|
const backgroundButtonColorReady = backgroundButtonColor ?? theme2.colors.textPrimary;
|
|
2623
2636
|
return /* @__PURE__ */ jsx7(
|
|
@@ -2641,8 +2654,8 @@ ButtonComponent.icon = function Icon3({ size = 16, backgroundButtonColor, ...pro
|
|
|
2641
2654
|
);
|
|
2642
2655
|
};
|
|
2643
2656
|
ButtonComponent.upload = function Upload({ accept, multiple, onUpload, ...props }) {
|
|
2644
|
-
const betterHtmlContext2 =
|
|
2645
|
-
const onClickElement =
|
|
2657
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2658
|
+
const onClickElement = useCallback4(() => {
|
|
2646
2659
|
const input = document.createElement("input");
|
|
2647
2660
|
input.setAttribute("type", "file");
|
|
2648
2661
|
if (accept) input.setAttribute("accept", accept);
|
|
@@ -2704,7 +2717,7 @@ var Divider_default = {
|
|
|
2704
2717
|
};
|
|
2705
2718
|
|
|
2706
2719
|
// src/components/Modal.tsx
|
|
2707
|
-
import { memo as memo9, useCallback as
|
|
2720
|
+
import { memo as memo9, useCallback as useCallback5, forwardRef as forwardRef5, useImperativeHandle, useRef as useRef2, useState as useState3 } from "react";
|
|
2708
2721
|
import styled7 from "styled-components";
|
|
2709
2722
|
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2710
2723
|
var DialogStylesElement = styled7.dialog.withConfig({
|
|
@@ -2763,24 +2776,25 @@ var ModalComponent = forwardRef5(function Modal({
|
|
|
2763
2776
|
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
2764
2777
|
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
2765
2778
|
const theme2 = useTheme();
|
|
2766
|
-
const { app, colorTheme } =
|
|
2779
|
+
const { app, colorTheme } = useBetterHtmlContextInternal();
|
|
2767
2780
|
const dialogRef = useRef2(null);
|
|
2768
|
-
const [isOpened, setIsOpened] =
|
|
2769
|
-
const [isOpenedLate, setIsOpenedLate] =
|
|
2770
|
-
const onClickOpen =
|
|
2781
|
+
const [isOpened, setIsOpened] = useState3(false);
|
|
2782
|
+
const [isOpenedLate, setIsOpenedLate] = useState3(false);
|
|
2783
|
+
const onClickOpen = useCallback5(() => {
|
|
2771
2784
|
dialogRef.current?.showModal();
|
|
2772
2785
|
setIsOpened(true);
|
|
2773
2786
|
setIsOpenedLate(true);
|
|
2774
|
-
if (urlQuery && name)
|
|
2787
|
+
if (urlQuery && name) {
|
|
2775
2788
|
urlQuery.setQuery(
|
|
2776
2789
|
{
|
|
2777
2790
|
[`${name}-modal`]: "opened"
|
|
2778
2791
|
},
|
|
2779
2792
|
false
|
|
2780
2793
|
);
|
|
2794
|
+
}
|
|
2781
2795
|
onOpen?.();
|
|
2782
2796
|
}, [onOpen, urlQuery, name]);
|
|
2783
|
-
const onClickClose =
|
|
2797
|
+
const onClickClose = useCallback5(() => {
|
|
2784
2798
|
setIsOpened(false);
|
|
2785
2799
|
onClose?.();
|
|
2786
2800
|
if (urlQuery && name) urlQuery.removeQuery(`${name}-modal`, false);
|
|
@@ -2900,11 +2914,11 @@ var ModalComponent = forwardRef5(function Modal({
|
|
|
2900
2914
|
ModalComponent.confirmation = forwardRef5(function Confirmation({ continueButtonLoaderName, onContinue, onCancel, ...props }, ref) {
|
|
2901
2915
|
const theme2 = useTheme();
|
|
2902
2916
|
const modalRef = useRef2(null);
|
|
2903
|
-
const onCancelElement =
|
|
2917
|
+
const onCancelElement = useCallback5(() => {
|
|
2904
2918
|
onCancel?.();
|
|
2905
2919
|
modalRef.current?.close();
|
|
2906
2920
|
}, [onCancel]);
|
|
2907
|
-
const onContinueElement =
|
|
2921
|
+
const onContinueElement = useCallback5(() => {
|
|
2908
2922
|
onContinue?.();
|
|
2909
2923
|
modalRef.current?.close();
|
|
2910
2924
|
}, [onContinue]);
|
|
@@ -2929,11 +2943,11 @@ ModalComponent.confirmation = forwardRef5(function Confirmation({ continueButton
|
|
|
2929
2943
|
ModalComponent.destructive = forwardRef5(function Destructive2({ deleteButtonLoaderName, onDelete, onCancel, ...props }, ref) {
|
|
2930
2944
|
const theme2 = useTheme();
|
|
2931
2945
|
const modalRef = useRef2(null);
|
|
2932
|
-
const onCancelElement =
|
|
2946
|
+
const onCancelElement = useCallback5(() => {
|
|
2933
2947
|
onCancel?.();
|
|
2934
2948
|
modalRef.current?.close();
|
|
2935
2949
|
}, [onCancel]);
|
|
2936
|
-
const onDeleteElement =
|
|
2950
|
+
const onDeleteElement = useCallback5(() => {
|
|
2937
2951
|
onDelete?.();
|
|
2938
2952
|
modalRef.current?.close();
|
|
2939
2953
|
}, [onDelete]);
|
|
@@ -2973,7 +2987,7 @@ import { memo as memo10 } from "react";
|
|
|
2973
2987
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
2974
2988
|
function PageHolder({ noMaxContentWidth, children }) {
|
|
2975
2989
|
const theme2 = useTheme();
|
|
2976
|
-
const { app } =
|
|
2990
|
+
const { app } = useBetterHtmlContextInternal();
|
|
2977
2991
|
return /* @__PURE__ */ jsx10(
|
|
2978
2992
|
Div_default,
|
|
2979
2993
|
{
|
|
@@ -3004,7 +3018,7 @@ function PageHeader({
|
|
|
3004
3018
|
marginBottom
|
|
3005
3019
|
}) {
|
|
3006
3020
|
const theme2 = useTheme();
|
|
3007
|
-
const { app } =
|
|
3021
|
+
const { app } = useBetterHtmlContextInternal();
|
|
3008
3022
|
const mediaQuery = useMediaQuery();
|
|
3009
3023
|
return /* @__PURE__ */ jsxs6(Div_default.row, { alignItems: "center", gap: theme2.styles.space, marginBottom: marginBottom ?? theme2.styles.space * 2, children: [
|
|
3010
3024
|
imageUrl && /* @__PURE__ */ jsx11(Image_default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }),
|
|
@@ -3079,7 +3093,7 @@ Chip2.circle = ChipComponent.circle;
|
|
|
3079
3093
|
var Chip_default = Chip2;
|
|
3080
3094
|
|
|
3081
3095
|
// src/components/InputField.tsx
|
|
3082
|
-
import { forwardRef as forwardRef8, memo as memo16, useCallback as
|
|
3096
|
+
import { forwardRef as forwardRef8, memo as memo16, useCallback as useCallback8, useState as useState6, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef4 } from "react";
|
|
3083
3097
|
import styled8 from "styled-components";
|
|
3084
3098
|
|
|
3085
3099
|
// src/constants/countries.ts
|
|
@@ -4650,7 +4664,7 @@ function Label({ text, required, isError, color }) {
|
|
|
4650
4664
|
var Label_default = memo13(Label);
|
|
4651
4665
|
|
|
4652
4666
|
// src/components/Dropdown.tsx
|
|
4653
|
-
import { forwardRef as forwardRef7, memo as memo14, useCallback as
|
|
4667
|
+
import { forwardRef as forwardRef7, memo as memo14, useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
|
|
4654
4668
|
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4655
4669
|
var DropdownComponent = forwardRef7(function Dropdown({
|
|
4656
4670
|
label,
|
|
@@ -4682,13 +4696,13 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4682
4696
|
const [isOpen, setIsOpen] = useBooleanState();
|
|
4683
4697
|
const [isOpenLate, setIsOpenLate] = useBooleanState();
|
|
4684
4698
|
const [isFocused, setIsFocused] = useBooleanState();
|
|
4685
|
-
const [searchQuery, setSearchQuery] =
|
|
4699
|
+
const [searchQuery, setSearchQuery] = useState4("");
|
|
4686
4700
|
const [_, debouncedSearchQuery, setDebouncedSearchQuery, isLoadingDebouncedSearchQuery] = useDebounceState(
|
|
4687
4701
|
"",
|
|
4688
4702
|
debounceDelay
|
|
4689
4703
|
);
|
|
4690
|
-
const [focusedOptionIndex, setFocusedOptionIndex] =
|
|
4691
|
-
const [internalValue, setInternalValue] =
|
|
4704
|
+
const [focusedOptionIndex, setFocusedOptionIndex] = useState4();
|
|
4705
|
+
const [internalValue, setInternalValue] = useState4(defaultValue);
|
|
4692
4706
|
const value = controlledValue ?? internalValue;
|
|
4693
4707
|
const filteredOptions = useMemo3(() => {
|
|
4694
4708
|
if (!searchQuery) return options;
|
|
@@ -4697,7 +4711,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4697
4711
|
(option) => option.label.toLowerCase().includes(query) || option.searchValues?.some((value2) => value2.toLowerCase().includes(query))
|
|
4698
4712
|
);
|
|
4699
4713
|
}, [options, searchQuery]);
|
|
4700
|
-
const onKeyDownInputField =
|
|
4714
|
+
const onKeyDownInputField = useCallback6(
|
|
4701
4715
|
(event) => {
|
|
4702
4716
|
if (event.key === "Enter" || !withSearch && event.key === " ") {
|
|
4703
4717
|
event.preventDefault();
|
|
@@ -4738,7 +4752,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4738
4752
|
},
|
|
4739
4753
|
[disabled, withSearch, isOpen, filteredOptions, focusedOptionIndex, controlledValue, onChange]
|
|
4740
4754
|
);
|
|
4741
|
-
const onClickOption =
|
|
4755
|
+
const onClickOption = useCallback6(
|
|
4742
4756
|
(option) => {
|
|
4743
4757
|
if (!option.disabled) {
|
|
4744
4758
|
if (controlledValue === void 0) setInternalValue(option.value);
|
|
@@ -4751,7 +4765,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4751
4765
|
},
|
|
4752
4766
|
[onChange, controlledValue]
|
|
4753
4767
|
);
|
|
4754
|
-
const onClickClearButton =
|
|
4768
|
+
const onClickClearButton = useCallback6(
|
|
4755
4769
|
(event) => {
|
|
4756
4770
|
event.stopPropagation();
|
|
4757
4771
|
setInternalValue(void 0);
|
|
@@ -4763,7 +4777,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4763
4777
|
},
|
|
4764
4778
|
[onChange]
|
|
4765
4779
|
);
|
|
4766
|
-
const onChangeValue =
|
|
4780
|
+
const onChangeValue = useCallback6(
|
|
4767
4781
|
(newValue) => {
|
|
4768
4782
|
setSearchQuery(newValue);
|
|
4769
4783
|
if (withDebounce) setDebouncedSearchQuery(newValue);
|
|
@@ -4808,7 +4822,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4808
4822
|
const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
|
|
4809
4823
|
const withClearButton = isOpen && selectedOption;
|
|
4810
4824
|
const readyPlaceholder = placeholder ? placeholder : `Select an ${label?.toLowerCase() ?? "option"}`;
|
|
4811
|
-
return /* @__PURE__ */ jsx13(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ jsxs8(Div_default.row, { position: "relative", width: "100%", children: [
|
|
4825
|
+
return /* @__PURE__ */ jsx13(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ jsxs8(Div_default.row, { position: "relative", width: "100%", ref: inputFieldHolderRef, children: [
|
|
4812
4826
|
/* @__PURE__ */ jsx13(
|
|
4813
4827
|
InputField_default,
|
|
4814
4828
|
{
|
|
@@ -4828,7 +4842,6 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4828
4842
|
onFocus: setIsFocused.setTrue,
|
|
4829
4843
|
onBlur: setIsFocused.setFalse,
|
|
4830
4844
|
onKeyDown: onKeyDownInputField,
|
|
4831
|
-
holderRef: inputFieldHolderRef,
|
|
4832
4845
|
onChangeValue: withSearch ? onChangeValue : void 0,
|
|
4833
4846
|
insideInputFieldComponent: /* @__PURE__ */ jsx13(
|
|
4834
4847
|
Div_default,
|
|
@@ -4934,7 +4947,7 @@ var Dropdown2 = memo14(DropdownComponent);
|
|
|
4934
4947
|
var Dropdown_default = Dropdown2;
|
|
4935
4948
|
|
|
4936
4949
|
// src/components/Calendar.tsx
|
|
4937
|
-
import { useCallback as
|
|
4950
|
+
import { useCallback as useCallback7, useMemo as useMemo4, useState as useState5, memo as memo15, useEffect as useEffect6 } from "react";
|
|
4938
4951
|
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4939
4952
|
var getMonthName = (month, short = false) => {
|
|
4940
4953
|
return [
|
|
@@ -4966,23 +4979,23 @@ var getWeekDayName = (day, short = false) => {
|
|
|
4966
4979
|
var weekDaysIndex = [1, 2, 3, 4, 5, 6, 0];
|
|
4967
4980
|
function Calendar({ value, minDate, maxDate, onChange }) {
|
|
4968
4981
|
const theme2 = useTheme();
|
|
4969
|
-
const [currentDate, setCurrentDate] =
|
|
4970
|
-
const [currentMonth, setCurrentMonth] =
|
|
4971
|
-
const [currentYear, setCurrentYear] =
|
|
4982
|
+
const [currentDate, setCurrentDate] = useState5(value ? new Date(value) : void 0);
|
|
4983
|
+
const [currentMonth, setCurrentMonth] = useState5(currentDate?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth());
|
|
4984
|
+
const [currentYear, setCurrentYear] = useState5(currentDate?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear());
|
|
4972
4985
|
const daysInMonth = useMemo4(() => new Date(currentYear, currentMonth + 1, 0).getDate(), [currentMonth, currentYear]);
|
|
4973
|
-
const onClickPreviousMonthButton =
|
|
4986
|
+
const onClickPreviousMonthButton = useCallback7(() => {
|
|
4974
4987
|
const newMonth = currentMonth === 0 ? 11 : currentMonth - 1;
|
|
4975
4988
|
const newYear = currentMonth === 0 ? currentYear - 1 : currentYear;
|
|
4976
4989
|
setCurrentMonth(newMonth);
|
|
4977
4990
|
setCurrentYear(newYear);
|
|
4978
4991
|
}, [currentMonth, currentYear]);
|
|
4979
|
-
const onClickNextMonthButton =
|
|
4992
|
+
const onClickNextMonthButton = useCallback7(() => {
|
|
4980
4993
|
const newMonth = currentMonth === 11 ? 0 : currentMonth + 1;
|
|
4981
4994
|
const newYear = currentMonth === 11 ? currentYear + 1 : currentYear;
|
|
4982
4995
|
setCurrentMonth(newMonth);
|
|
4983
4996
|
setCurrentYear(newYear);
|
|
4984
4997
|
}, [currentMonth, currentYear]);
|
|
4985
|
-
const onClickDay =
|
|
4998
|
+
const onClickDay = useCallback7(
|
|
4986
4999
|
(day) => {
|
|
4987
5000
|
if (!day) return;
|
|
4988
5001
|
const newDate = new Date(currentYear, currentMonth, day);
|
|
@@ -4993,11 +5006,11 @@ function Calendar({ value, minDate, maxDate, onChange }) {
|
|
|
4993
5006
|
},
|
|
4994
5007
|
[currentMonth, currentYear, onChange]
|
|
4995
5008
|
);
|
|
4996
|
-
const onClickClear =
|
|
5009
|
+
const onClickClear = useCallback7(() => {
|
|
4997
5010
|
setCurrentDate(void 0);
|
|
4998
5011
|
onChange?.(void 0);
|
|
4999
5012
|
}, []);
|
|
5000
|
-
const onClickToday =
|
|
5013
|
+
const onClickToday = useCallback7(() => {
|
|
5001
5014
|
const today = /* @__PURE__ */ new Date();
|
|
5002
5015
|
setCurrentDate(today);
|
|
5003
5016
|
onChange?.(
|
|
@@ -5265,7 +5278,7 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
5265
5278
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5266
5279
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5267
5280
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5268
|
-
const onChangeElement =
|
|
5281
|
+
const onChangeElement = useCallback8(
|
|
5269
5282
|
(event) => {
|
|
5270
5283
|
const newValue = event.target.value;
|
|
5271
5284
|
if (withDebounce) {
|
|
@@ -5372,7 +5385,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5372
5385
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5373
5386
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5374
5387
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5375
|
-
const onChangeElement =
|
|
5388
|
+
const onChangeElement = useCallback8(
|
|
5376
5389
|
(event) => {
|
|
5377
5390
|
onChange?.(event);
|
|
5378
5391
|
onChangeValue?.(event.target.value);
|
|
@@ -5480,16 +5493,16 @@ InputFieldComponent.search = forwardRef8(function Search({ ...props }, ref) {
|
|
|
5480
5493
|
});
|
|
5481
5494
|
InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
|
|
5482
5495
|
const theme2 = useTheme();
|
|
5483
|
-
const [dropdownValue, setDropdownValue] =
|
|
5484
|
-
const [inputFieldValue, setInputFieldValue] =
|
|
5485
|
-
const renderOption =
|
|
5496
|
+
const [dropdownValue, setDropdownValue] = useState6();
|
|
5497
|
+
const [inputFieldValue, setInputFieldValue] = useState6(value?.toString() ?? "");
|
|
5498
|
+
const renderOption = useCallback8(
|
|
5486
5499
|
(option, index, isSelected) => /* @__PURE__ */ jsxs10(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
|
|
5487
5500
|
/* @__PURE__ */ jsx15(Image_default, { src: `https://flagcdn.com/w80/${option.data?.code.toString().toLowerCase()}.webp`, width: 20 }),
|
|
5488
5501
|
/* @__PURE__ */ jsx15(Text_default, { children: option.label })
|
|
5489
5502
|
] }),
|
|
5490
5503
|
[]
|
|
5491
5504
|
);
|
|
5492
|
-
const onChangeValueElement =
|
|
5505
|
+
const onChangeValueElement = useCallback8(
|
|
5493
5506
|
(value2) => {
|
|
5494
5507
|
const readyValue = value2.replace(/\D/g, "");
|
|
5495
5508
|
setInputFieldValue(readyValue);
|
|
@@ -5565,7 +5578,7 @@ InputFieldComponent.date = forwardRef8(function Date2({ minDate, maxDate, ...pro
|
|
|
5565
5578
|
const holderRef = useRef4(null);
|
|
5566
5579
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5567
5580
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5568
|
-
const onChange =
|
|
5581
|
+
const onChange = useCallback8(
|
|
5569
5582
|
(date) => {
|
|
5570
5583
|
inputFieldProps.onChangeValue?.(date ?? "");
|
|
5571
5584
|
setInternalValue(date ?? "");
|
|
@@ -5606,7 +5619,7 @@ InputFieldComponent.dateTime = forwardRef8(function DateTime({ minDate, maxDate,
|
|
|
5606
5619
|
const selectedMinuteRef = useRef4(null);
|
|
5607
5620
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5608
5621
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5609
|
-
const onChange =
|
|
5622
|
+
const onChange = useCallback8(
|
|
5610
5623
|
(date) => {
|
|
5611
5624
|
const newValue = date ? `${date}T${internalValue?.toString().split("T")[1] ?? "00:00"}` : "";
|
|
5612
5625
|
inputFieldProps.onChangeValue?.(newValue);
|
|
@@ -5614,7 +5627,7 @@ InputFieldComponent.dateTime = forwardRef8(function DateTime({ minDate, maxDate,
|
|
|
5614
5627
|
},
|
|
5615
5628
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5616
5629
|
);
|
|
5617
|
-
const onClickHour =
|
|
5630
|
+
const onClickHour = useCallback8(
|
|
5618
5631
|
(hour) => {
|
|
5619
5632
|
const newTime = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
5620
5633
|
const today = `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
@@ -5624,7 +5637,7 @@ InputFieldComponent.dateTime = forwardRef8(function DateTime({ minDate, maxDate,
|
|
|
5624
5637
|
},
|
|
5625
5638
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5626
5639
|
);
|
|
5627
|
-
const onClickMinute =
|
|
5640
|
+
const onClickMinute = useCallback8(
|
|
5628
5641
|
(minute) => {
|
|
5629
5642
|
const newTime = `${internalValue?.toString().split("T")?.[1]?.split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
5630
5643
|
const today = `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
@@ -5759,7 +5772,7 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5759
5772
|
const selectedMinuteRef = useRef4(null);
|
|
5760
5773
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5761
5774
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5762
|
-
const onClickHour =
|
|
5775
|
+
const onClickHour = useCallback8(
|
|
5763
5776
|
(hour) => {
|
|
5764
5777
|
const value = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
5765
5778
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -5767,7 +5780,7 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5767
5780
|
},
|
|
5768
5781
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5769
5782
|
);
|
|
5770
|
-
const onClickMinute =
|
|
5783
|
+
const onClickMinute = useCallback8(
|
|
5771
5784
|
(minute) => {
|
|
5772
5785
|
const value = `${internalValue?.toString().split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
5773
5786
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -5866,7 +5879,7 @@ InputField2.time = InputFieldComponent.time;
|
|
|
5866
5879
|
var InputField_default = InputField2;
|
|
5867
5880
|
|
|
5868
5881
|
// src/components/ToggleInput.tsx
|
|
5869
|
-
import { forwardRef as forwardRef9, useCallback as
|
|
5882
|
+
import { forwardRef as forwardRef9, useCallback as useCallback9, useState as useState7 } from "react";
|
|
5870
5883
|
import styled9 from "styled-components";
|
|
5871
5884
|
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5872
5885
|
var componentSize = 26;
|
|
@@ -5903,6 +5916,8 @@ var InputElement2 = styled9.input.withConfig({
|
|
|
5903
5916
|
${(props) => props.normalStyle}
|
|
5904
5917
|
|
|
5905
5918
|
&:hover {
|
|
5919
|
+
border-color: ${(props) => props.theme.colors.primary};
|
|
5920
|
+
|
|
5906
5921
|
${(props) => props.hoverStyle}
|
|
5907
5922
|
}
|
|
5908
5923
|
`;
|
|
@@ -5978,8 +5993,8 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5978
5993
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5979
5994
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5980
5995
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5981
|
-
const [internalChecked, setInternalChecked] =
|
|
5982
|
-
const onChangeElement =
|
|
5996
|
+
const [internalChecked, setInternalChecked] = useState7(false);
|
|
5997
|
+
const onChangeElement = useCallback9(
|
|
5983
5998
|
(event) => {
|
|
5984
5999
|
const newIsChecked = event.target.checked;
|
|
5985
6000
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
@@ -5988,7 +6003,7 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5988
6003
|
[onChange, controlledChecked, value]
|
|
5989
6004
|
);
|
|
5990
6005
|
const checked = controlledChecked ?? internalChecked;
|
|
5991
|
-
const onClickText =
|
|
6006
|
+
const onClickText = useCallback9(() => {
|
|
5992
6007
|
const newIsChecked = !checked;
|
|
5993
6008
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
5994
6009
|
onChange?.(newIsChecked, value);
|
|
@@ -6088,7 +6103,7 @@ var ToggleInput_default = {
|
|
|
6088
6103
|
const [internalChecked, setInternalChecked] = useBooleanState();
|
|
6089
6104
|
const [isMouseDown, setIsMouseDown] = useBooleanState();
|
|
6090
6105
|
const checked = controlledChecked ?? internalChecked;
|
|
6091
|
-
const onClickElement =
|
|
6106
|
+
const onClickElement = useCallback9(() => {
|
|
6092
6107
|
if (disabled) return;
|
|
6093
6108
|
const newIsChecked = !checked;
|
|
6094
6109
|
if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
|
|
@@ -6310,7 +6325,7 @@ ColorThemeSwitch2.withText = ColorThemeSwitchComponent.withText;
|
|
|
6310
6325
|
var ColorThemeSwitch_default = ColorThemeSwitch2;
|
|
6311
6326
|
|
|
6312
6327
|
// src/components/Table.tsx
|
|
6313
|
-
import { forwardRef as forwardRef11, memo as memo20, useCallback as
|
|
6328
|
+
import { forwardRef as forwardRef11, memo as memo20, useCallback as useCallback10, useMemo as useMemo7, useState as useState8 } from "react";
|
|
6314
6329
|
import styled10, { css as css2 } from "styled-components";
|
|
6315
6330
|
import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
6316
6331
|
var defaultImageWidth = 120;
|
|
@@ -6388,10 +6403,10 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6388
6403
|
onClickAllCheckboxes,
|
|
6389
6404
|
...props
|
|
6390
6405
|
}, ref) {
|
|
6391
|
-
const { colorTheme } =
|
|
6406
|
+
const { colorTheme } = useBetterHtmlContextInternal();
|
|
6392
6407
|
const theme2 = useTheme();
|
|
6393
|
-
const [checkedItems, setCheckedItems] =
|
|
6394
|
-
const renderCellContent =
|
|
6408
|
+
const [checkedItems, setCheckedItems] = useState8([]);
|
|
6409
|
+
const renderCellContent = useCallback10(
|
|
6395
6410
|
(column, item, index) => {
|
|
6396
6411
|
switch (column.type) {
|
|
6397
6412
|
case "text": {
|
|
@@ -6430,13 +6445,13 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6430
6445
|
},
|
|
6431
6446
|
[theme2, checkedItems]
|
|
6432
6447
|
);
|
|
6433
|
-
const onClickRowElement =
|
|
6448
|
+
const onClickRowElement = useCallback10(
|
|
6434
6449
|
(item, index) => {
|
|
6435
6450
|
onClickRow?.(item, index);
|
|
6436
6451
|
},
|
|
6437
6452
|
[onClickRow]
|
|
6438
6453
|
);
|
|
6439
|
-
const onClickAllCheckboxesElement =
|
|
6454
|
+
const onClickAllCheckboxesElement = useCallback10(
|
|
6440
6455
|
(checked) => {
|
|
6441
6456
|
onClickAllCheckboxes?.(checked);
|
|
6442
6457
|
setCheckedItems(data.map(() => checked));
|
|
@@ -6498,6 +6513,301 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6498
6513
|
var Table2 = memo20(TableComponent);
|
|
6499
6514
|
var Table_default = Table2;
|
|
6500
6515
|
|
|
6516
|
+
// src/components/Tabs.tsx
|
|
6517
|
+
import { memo as memo21, useCallback as useCallback11, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef5, useState as useState9 } from "react";
|
|
6518
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6519
|
+
var tabBottomLineWidth = 2;
|
|
6520
|
+
var tabDotSize = 6;
|
|
6521
|
+
var defaultTabName = "tab";
|
|
6522
|
+
var TabsComponent = function Tabs({
|
|
6523
|
+
tabs,
|
|
6524
|
+
name,
|
|
6525
|
+
accentColor,
|
|
6526
|
+
style = "default",
|
|
6527
|
+
children,
|
|
6528
|
+
...props
|
|
6529
|
+
}) {
|
|
6530
|
+
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
6531
|
+
const theme2 = useTheme();
|
|
6532
|
+
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
6533
|
+
const { colorTheme, tabsComponentState } = useBetterHtmlContextInternal();
|
|
6534
|
+
const tabsRef = useRef5({});
|
|
6535
|
+
const [selectedTab, setSelectedTab] = useState9(() => {
|
|
6536
|
+
const selectedTabValue = tabs[0] ?? "";
|
|
6537
|
+
if (urlQuery) {
|
|
6538
|
+
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
6539
|
+
if (!tabQueryValue) return selectedTabValue;
|
|
6540
|
+
if (tabs.includes(tabQueryValue)) return tabQueryValue;
|
|
6541
|
+
}
|
|
6542
|
+
return selectedTabValue;
|
|
6543
|
+
});
|
|
6544
|
+
const [rerenderState, setRerenderState] = useState9(0);
|
|
6545
|
+
const tabsGap = style === "box" ? theme2.styles.gap / 2 : 0;
|
|
6546
|
+
const onClickTab = useCallback11(
|
|
6547
|
+
(tab) => {
|
|
6548
|
+
setSelectedTab(tab);
|
|
6549
|
+
if (urlQuery) {
|
|
6550
|
+
urlQuery.setQuery({
|
|
6551
|
+
[name ?? defaultTabName]: tab
|
|
6552
|
+
});
|
|
6553
|
+
}
|
|
6554
|
+
},
|
|
6555
|
+
[name, urlQuery]
|
|
6556
|
+
);
|
|
6557
|
+
const width = useMemo8(
|
|
6558
|
+
() => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
|
|
6559
|
+
[rerenderState, selectedTab]
|
|
6560
|
+
);
|
|
6561
|
+
const leftSpacing = useMemo8(() => {
|
|
6562
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab === selectedTab);
|
|
6563
|
+
let totalWidth = 0;
|
|
6564
|
+
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
6565
|
+
if (index < selectedTabIndex) totalWidth += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
6566
|
+
});
|
|
6567
|
+
return totalWidth;
|
|
6568
|
+
}, [selectedTab, tabs, tabsGap]);
|
|
6569
|
+
useEffect9(() => {
|
|
6570
|
+
const timeout = setTimeout(() => setRerenderState(Math.random()), 0.01 * 1e3);
|
|
6571
|
+
return () => {
|
|
6572
|
+
clearTimeout(timeout);
|
|
6573
|
+
};
|
|
6574
|
+
}, []);
|
|
6575
|
+
useEffect9(() => {
|
|
6576
|
+
tabsComponentState.setTabGroups((oldValue) => {
|
|
6577
|
+
const thisTabGroup = oldValue.find((item) => item.name === (name ?? defaultTabName));
|
|
6578
|
+
if (thisTabGroup) {
|
|
6579
|
+
return oldValue.map(
|
|
6580
|
+
(item) => item.name === (name ?? defaultTabName) ? {
|
|
6581
|
+
...item,
|
|
6582
|
+
selectedTab
|
|
6583
|
+
} : item
|
|
6584
|
+
);
|
|
6585
|
+
} else {
|
|
6586
|
+
return [
|
|
6587
|
+
...oldValue,
|
|
6588
|
+
{
|
|
6589
|
+
name: name ?? defaultTabName,
|
|
6590
|
+
selectedTab
|
|
6591
|
+
}
|
|
6592
|
+
];
|
|
6593
|
+
}
|
|
6594
|
+
});
|
|
6595
|
+
}, [selectedTab, name]);
|
|
6596
|
+
return /* @__PURE__ */ jsxs16(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
6597
|
+
/* @__PURE__ */ jsxs16(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
6598
|
+
/* @__PURE__ */ jsx21(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
6599
|
+
const selected = tab === selectedTab;
|
|
6600
|
+
return /* @__PURE__ */ jsxs16(
|
|
6601
|
+
Div_default,
|
|
6602
|
+
{
|
|
6603
|
+
position: "relative",
|
|
6604
|
+
width: "fit-content",
|
|
6605
|
+
backgroundColor: style === "box" ? selected ? theme2.colors.primary : theme2.colors.backgroundContent : theme2.colors.backgroundBase,
|
|
6606
|
+
borderRadius: style === "box" ? theme2.styles.borderRadius : void 0,
|
|
6607
|
+
borderTopLeftRadius: style === "borderRadiusTop" ? theme2.styles.borderRadius : void 0,
|
|
6608
|
+
borderTopRightRadius: style === "borderRadiusTop" ? theme2.styles.borderRadius : void 0,
|
|
6609
|
+
border: style === "box" ? `1px solid ${selected ? "transparent" : theme2.colors.border}` : void 0,
|
|
6610
|
+
filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
|
|
6611
|
+
paddingInline: theme2.styles.space,
|
|
6612
|
+
paddingBlock: theme2.styles.gap,
|
|
6613
|
+
value: tab,
|
|
6614
|
+
cursor: "pointer",
|
|
6615
|
+
isTabAccessed: true,
|
|
6616
|
+
onClickWithValue: onClickTab,
|
|
6617
|
+
ref: (ref) => {
|
|
6618
|
+
tabsRef.current[tab] = ref;
|
|
6619
|
+
},
|
|
6620
|
+
children: [
|
|
6621
|
+
tabsComponentState.tabsWithDots.includes(tab) && /* @__PURE__ */ jsx21(
|
|
6622
|
+
Div_default,
|
|
6623
|
+
{
|
|
6624
|
+
position: "absolute",
|
|
6625
|
+
top: (theme2.styles.space - tabDotSize) / 2,
|
|
6626
|
+
right: (theme2.styles.space - tabDotSize) / 2,
|
|
6627
|
+
width: tabDotSize,
|
|
6628
|
+
height: tabDotSize,
|
|
6629
|
+
backgroundColor: style === "box" && selected ? theme2.colors.base : theme2.colors.primary,
|
|
6630
|
+
borderRadius: 999,
|
|
6631
|
+
transition: theme2.styles.transition
|
|
6632
|
+
}
|
|
6633
|
+
),
|
|
6634
|
+
/* @__PURE__ */ jsx21(
|
|
6635
|
+
Text_default,
|
|
6636
|
+
{
|
|
6637
|
+
fontWeight: 700,
|
|
6638
|
+
color: !selected ? theme2.colors.textSecondary : style === "box" ? theme2.colors.base : void 0,
|
|
6639
|
+
transition: theme2.styles.transition,
|
|
6640
|
+
whiteSpace: "nowrap",
|
|
6641
|
+
children: tab
|
|
6642
|
+
}
|
|
6643
|
+
)
|
|
6644
|
+
]
|
|
6645
|
+
},
|
|
6646
|
+
tab
|
|
6647
|
+
);
|
|
6648
|
+
}) }),
|
|
6649
|
+
style !== "box" && /* @__PURE__ */ jsx21(
|
|
6650
|
+
Div_default,
|
|
6651
|
+
{
|
|
6652
|
+
position: "absolute",
|
|
6653
|
+
width,
|
|
6654
|
+
height: tabBottomLineWidth,
|
|
6655
|
+
bottom: 0,
|
|
6656
|
+
left: leftSpacing,
|
|
6657
|
+
backgroundColor: accentColor ?? theme2.colors.primary,
|
|
6658
|
+
transition: theme2.styles.transition
|
|
6659
|
+
}
|
|
6660
|
+
)
|
|
6661
|
+
] }),
|
|
6662
|
+
/* @__PURE__ */ jsx21(Div_default, { width: "100%", children })
|
|
6663
|
+
] });
|
|
6664
|
+
};
|
|
6665
|
+
TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, children }) {
|
|
6666
|
+
const { tabsComponentState } = useBetterHtmlContextInternal();
|
|
6667
|
+
const thisTabGroupData = useMemo8(
|
|
6668
|
+
() => tabsComponentState.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
|
|
6669
|
+
[tabsComponentState, tabsGroupName]
|
|
6670
|
+
);
|
|
6671
|
+
useEffect9(() => {
|
|
6672
|
+
if (tabWithDot) {
|
|
6673
|
+
tabsComponentState.setTabsWithDots?.((oldValue) => oldValue.includes(tab) ? oldValue : [...oldValue, tab]);
|
|
6674
|
+
} else {
|
|
6675
|
+
tabsComponentState.setTabsWithDots?.(
|
|
6676
|
+
(oldValue) => oldValue.includes(tab) ? oldValue.filter((tab2) => tab2 !== tab2) : oldValue
|
|
6677
|
+
);
|
|
6678
|
+
}
|
|
6679
|
+
}, [tabWithDot]);
|
|
6680
|
+
return thisTabGroupData?.selectedTab === tab ? /* @__PURE__ */ jsx21(Div_default, { width: "100%", children }) : void 0;
|
|
6681
|
+
};
|
|
6682
|
+
var Tabs2 = memo21(TabsComponent);
|
|
6683
|
+
Tabs2.content = TabsComponent.content;
|
|
6684
|
+
var Tabs_default = Tabs2;
|
|
6685
|
+
|
|
6686
|
+
// src/components/Foldable.tsx
|
|
6687
|
+
import { forwardRef as forwardRef12, memo as memo22, useCallback as useCallback12, useEffect as useEffect10, useImperativeHandle as useImperativeHandle2, useRef as useRef6, useState as useState10 } from "react";
|
|
6688
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6689
|
+
var animationDuration = 0.2;
|
|
6690
|
+
var FoldableComponent = forwardRef12(function Foldable({
|
|
6691
|
+
isOpen: controlledIsOpen,
|
|
6692
|
+
defaultOpen = false,
|
|
6693
|
+
title,
|
|
6694
|
+
description,
|
|
6695
|
+
icon,
|
|
6696
|
+
image,
|
|
6697
|
+
headerPaddingInline,
|
|
6698
|
+
renderHeader,
|
|
6699
|
+
onOpenChange,
|
|
6700
|
+
children,
|
|
6701
|
+
...props
|
|
6702
|
+
}, ref) {
|
|
6703
|
+
const theme2 = useTheme();
|
|
6704
|
+
const bodyRef = useRef6(null);
|
|
6705
|
+
const [internalIsOpen, setInternalIsOpen] = useBooleanState(defaultOpen);
|
|
6706
|
+
const [bodyHeight, setBodyHeight] = useState10(defaultOpen ? void 0 : 0);
|
|
6707
|
+
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
6708
|
+
const open = useCallback12(() => {
|
|
6709
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.setTrue();
|
|
6710
|
+
onOpenChange?.(true);
|
|
6711
|
+
}, [controlledIsOpen, onOpenChange]);
|
|
6712
|
+
const close = useCallback12(() => {
|
|
6713
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.setFalse();
|
|
6714
|
+
onOpenChange?.(false);
|
|
6715
|
+
}, [controlledIsOpen, onOpenChange]);
|
|
6716
|
+
const toggleOpen = useCallback12(() => {
|
|
6717
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.toggle();
|
|
6718
|
+
onOpenChange?.(!isOpen);
|
|
6719
|
+
}, [controlledIsOpen, isOpen, onOpenChange]);
|
|
6720
|
+
useEffect10(() => {
|
|
6721
|
+
if (!bodyRef.current) return;
|
|
6722
|
+
if (isOpen) {
|
|
6723
|
+
const height = bodyRef.current.scrollHeight;
|
|
6724
|
+
setBodyHeight(height);
|
|
6725
|
+
const timeout = setTimeout(() => {
|
|
6726
|
+
setBodyHeight(void 0);
|
|
6727
|
+
}, animationDuration * 1e3);
|
|
6728
|
+
return () => {
|
|
6729
|
+
clearTimeout(timeout);
|
|
6730
|
+
};
|
|
6731
|
+
} else {
|
|
6732
|
+
if (bodyHeight === void 0) {
|
|
6733
|
+
const height = bodyRef.current.scrollHeight;
|
|
6734
|
+
setBodyHeight(height);
|
|
6735
|
+
bodyRef.current.offsetHeight;
|
|
6736
|
+
}
|
|
6737
|
+
const timeout = setTimeout(() => {
|
|
6738
|
+
setBodyHeight(0);
|
|
6739
|
+
}, 0.01 * 1e3);
|
|
6740
|
+
return () => {
|
|
6741
|
+
clearTimeout(timeout);
|
|
6742
|
+
};
|
|
6743
|
+
}
|
|
6744
|
+
}, [isOpen, animationDuration, bodyHeight]);
|
|
6745
|
+
useImperativeHandle2(
|
|
6746
|
+
ref,
|
|
6747
|
+
() => {
|
|
6748
|
+
return {
|
|
6749
|
+
open,
|
|
6750
|
+
close,
|
|
6751
|
+
toggle: toggleOpen,
|
|
6752
|
+
isOpen
|
|
6753
|
+
};
|
|
6754
|
+
},
|
|
6755
|
+
[open, close, toggleOpen, isOpen]
|
|
6756
|
+
);
|
|
6757
|
+
return /* @__PURE__ */ jsxs17(Div_default.column, { width: "100%", overflow: "hidden", ...props, children: [
|
|
6758
|
+
renderHeader ? renderHeader(isOpen, toggleOpen) : /* @__PURE__ */ jsxs17(
|
|
6759
|
+
Div_default.row,
|
|
6760
|
+
{
|
|
6761
|
+
width: "100%",
|
|
6762
|
+
alignItems: "center",
|
|
6763
|
+
gap: theme2.styles.gap,
|
|
6764
|
+
paddingBlock: theme2.styles.gap,
|
|
6765
|
+
paddingInline: headerPaddingInline,
|
|
6766
|
+
cursor: "pointer",
|
|
6767
|
+
onClick: toggleOpen,
|
|
6768
|
+
userSelect: "none",
|
|
6769
|
+
children: [
|
|
6770
|
+
/* @__PURE__ */ jsxs17(Div_default.row, { flex: 1, alignItems: "center", gap: theme2.styles.space, children: [
|
|
6771
|
+
icon && /* @__PURE__ */ jsx22(Icon_default, { name: icon, size: 20, flexShrink: 0 }),
|
|
6772
|
+
image && /* @__PURE__ */ jsx22(Image_default.profileImage, { name: image, size: 24, flexShrink: 0 }),
|
|
6773
|
+
/* @__PURE__ */ jsxs17(Div_default.column, { gap: theme2.styles.gap / 2, children: [
|
|
6774
|
+
title && /* @__PURE__ */ jsx22(Text_default, { as: "h3", fontWeight: 700, children: title }),
|
|
6775
|
+
description && /* @__PURE__ */ jsx22(Text_default, { color: theme2.colors.textSecondary, children: description })
|
|
6776
|
+
] })
|
|
6777
|
+
] }),
|
|
6778
|
+
/* @__PURE__ */ jsx22(
|
|
6779
|
+
Icon_default,
|
|
6780
|
+
{
|
|
6781
|
+
name: "chevronDown",
|
|
6782
|
+
transform: `rotate(${isOpen ? 180 : 0}deg)`,
|
|
6783
|
+
transition: theme2.styles.transition
|
|
6784
|
+
}
|
|
6785
|
+
)
|
|
6786
|
+
]
|
|
6787
|
+
}
|
|
6788
|
+
),
|
|
6789
|
+
/* @__PURE__ */ jsx22(Div_default, { height: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0, transition: theme2.styles.transition, children: /* @__PURE__ */ jsx22(Divider_default.horizontal, {}) }),
|
|
6790
|
+
/* @__PURE__ */ jsx22(Div_default, { height: bodyHeight, transition: `height ${animationDuration}s ease`, ref: bodyRef, children: /* @__PURE__ */ jsx22(Div_default, { paddingBlock: theme2.styles.gap, paddingInline: headerPaddingInline, children }) })
|
|
6791
|
+
] });
|
|
6792
|
+
});
|
|
6793
|
+
FoldableComponent.box = forwardRef12(function Box3({ ...props }, ref) {
|
|
6794
|
+
const theme2 = useTheme();
|
|
6795
|
+
return /* @__PURE__ */ jsx22(
|
|
6796
|
+
FoldableComponent,
|
|
6797
|
+
{
|
|
6798
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
6799
|
+
border: `1px solid ${theme2.colors.border}`,
|
|
6800
|
+
borderRadius: theme2.styles.borderRadius,
|
|
6801
|
+
headerPaddingInline: theme2.styles.space,
|
|
6802
|
+
...props,
|
|
6803
|
+
ref
|
|
6804
|
+
}
|
|
6805
|
+
);
|
|
6806
|
+
});
|
|
6807
|
+
var Foldable2 = memo22(FoldableComponent);
|
|
6808
|
+
Foldable2.box = FoldableComponent.box;
|
|
6809
|
+
var Foldable_default = Foldable2;
|
|
6810
|
+
|
|
6501
6811
|
// src/utils/variableFunctions.ts
|
|
6502
6812
|
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
6503
6813
|
if (value === void 0) {
|
|
@@ -6544,6 +6854,7 @@ export {
|
|
|
6544
6854
|
Div_default as Div,
|
|
6545
6855
|
Divider_default as Divider,
|
|
6546
6856
|
Dropdown_default as Dropdown,
|
|
6857
|
+
Foldable_default as Foldable,
|
|
6547
6858
|
Form_default as Form,
|
|
6548
6859
|
FormRow_default as FormRow,
|
|
6549
6860
|
Icon_default as Icon,
|
|
@@ -6555,6 +6866,7 @@ export {
|
|
|
6555
6866
|
PageHeader_default as PageHeader,
|
|
6556
6867
|
PageHolder_default as PageHolder,
|
|
6557
6868
|
Table_default as Table,
|
|
6869
|
+
Tabs_default as Tabs,
|
|
6558
6870
|
Text_default as Text,
|
|
6559
6871
|
ToggleInput_default as ToggleInput,
|
|
6560
6872
|
formatPhoneNumber,
|