react-better-html 1.1.79 → 1.1.81
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 +346 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +396 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1471,6 +1471,10 @@ var appConfig = {
|
|
|
1471
1471
|
// src/components/BetterHtmlProvider.tsx
|
|
1472
1472
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
1473
1473
|
var GlobalStyle = createGlobalStyle`
|
|
1474
|
+
html {
|
|
1475
|
+
background-color: ${(props) => props.backgroundColor};
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1474
1478
|
body {
|
|
1475
1479
|
font-family: ${(props) => props.fontFamily};
|
|
1476
1480
|
color: ${(props) => props.color};
|
|
@@ -1501,9 +1505,17 @@ var useBetterHtmlContext = () => {
|
|
|
1501
1505
|
throw new Error(
|
|
1502
1506
|
"`useBetterHtmlContext()` must be used within a `<BetterHtmlProvider>`. Make sure to add one at the root of your component tree."
|
|
1503
1507
|
);
|
|
1504
|
-
const { setLoaders, plugins, ...rest } = context;
|
|
1508
|
+
const { setLoaders, plugins, componentsState, ...rest } = context;
|
|
1505
1509
|
return rest;
|
|
1506
1510
|
};
|
|
1511
|
+
var useBetterHtmlContextInternal = () => {
|
|
1512
|
+
const context = useContext(betterHtmlContext);
|
|
1513
|
+
if (context === void 0)
|
|
1514
|
+
throw new Error(
|
|
1515
|
+
"`useBetterHtmlContextInternal()` must be used within a `<BetterHtmlProvider>`. Make sure to add one at the root of your component tree."
|
|
1516
|
+
);
|
|
1517
|
+
return context;
|
|
1518
|
+
};
|
|
1507
1519
|
var useTheme = () => {
|
|
1508
1520
|
const context = useContext(betterHtmlContext);
|
|
1509
1521
|
if (context === void 0)
|
|
@@ -1570,11 +1582,13 @@ function BetterHtmlProviderContent({ children }) {
|
|
|
1570
1582
|
] });
|
|
1571
1583
|
}
|
|
1572
1584
|
function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
|
|
1573
|
-
const [loaders, setLoaders] = useState(value?.loaders ?? {});
|
|
1574
|
-
const [plugins] = useState(pluginsToUse ?? []);
|
|
1575
1585
|
const [colorTheme, setColorTheme] = useState(
|
|
1576
1586
|
localStorage.getItem("theme") === "dark" ? "dark" : value?.colorTheme ?? "light"
|
|
1577
1587
|
);
|
|
1588
|
+
const [loaders, setLoaders] = useState(value?.loaders ?? {});
|
|
1589
|
+
const [plugins] = useState(pluginsToUse ?? []);
|
|
1590
|
+
const [tabGroups, setTabGroups] = useState([]);
|
|
1591
|
+
const [tabsWithDots, setTabsWithDots] = useState([]);
|
|
1578
1592
|
const readyValue = useMemo(
|
|
1579
1593
|
() => ({
|
|
1580
1594
|
app: {
|
|
@@ -1611,9 +1625,17 @@ function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
|
|
|
1611
1625
|
components: {
|
|
1612
1626
|
...value?.components
|
|
1613
1627
|
},
|
|
1614
|
-
plugins
|
|
1628
|
+
plugins,
|
|
1629
|
+
componentsState: {
|
|
1630
|
+
tabs: {
|
|
1631
|
+
tabGroups,
|
|
1632
|
+
setTabGroups,
|
|
1633
|
+
tabsWithDots,
|
|
1634
|
+
setTabsWithDots
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1615
1637
|
}),
|
|
1616
|
-
[value, colorTheme, loaders, plugins]
|
|
1638
|
+
[value, colorTheme, loaders, plugins, tabGroups, tabsWithDots]
|
|
1617
1639
|
);
|
|
1618
1640
|
useEffect(() => {
|
|
1619
1641
|
plugins.forEach((plugin) => {
|
|
@@ -2314,7 +2336,7 @@ var IconElement = styled4.svg.withConfig({
|
|
|
2314
2336
|
`;
|
|
2315
2337
|
var Icon = forwardRef3(function Icon2({ name, size = 16, ...props }, ref) {
|
|
2316
2338
|
const theme2 = useTheme();
|
|
2317
|
-
const { icons: icons2 } =
|
|
2339
|
+
const { icons: icons2 } = useBetterHtmlContextInternal();
|
|
2318
2340
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
2319
2341
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2320
2342
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
@@ -2373,7 +2395,7 @@ var ImageElement = styled5.img.withConfig({
|
|
|
2373
2395
|
`;
|
|
2374
2396
|
var Image = forwardRef4(function Image2({ name, src, ...props }, ref) {
|
|
2375
2397
|
const theme2 = useTheme();
|
|
2376
|
-
const { assets: assets2 } =
|
|
2398
|
+
const { assets: assets2 } = useBetterHtmlContextInternal();
|
|
2377
2399
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
2378
2400
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2379
2401
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
@@ -2406,11 +2428,11 @@ MemoizedImage.profileImage = Image.profileImage;
|
|
|
2406
2428
|
var Image_default = { Image: MemoizedImage }.Image;
|
|
2407
2429
|
|
|
2408
2430
|
// src/components/Button.tsx
|
|
2409
|
-
import { memo as memo7, useCallback as
|
|
2431
|
+
import { memo as memo7, useCallback as useCallback4 } from "react";
|
|
2410
2432
|
import styled6, { css } from "styled-components";
|
|
2411
2433
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2412
2434
|
var ButtonElement = styled6.button.withConfig({
|
|
2413
|
-
shouldForwardProp: (prop) => !["theme", "normalStyle", "hoverStyle", "isSmall", "withText", "isLoading"].includes(prop)
|
|
2435
|
+
shouldForwardProp: (prop) => !["theme", "colorTheme", "normalStyle", "hoverStyle", "isSmall", "withText", "isLoading"].includes(prop)
|
|
2414
2436
|
})`
|
|
2415
2437
|
display: block;
|
|
2416
2438
|
position: relative;
|
|
@@ -2432,15 +2454,11 @@ var ButtonElement = styled6.button.withConfig({
|
|
|
2432
2454
|
${(props) => props.disabled ? css`
|
|
2433
2455
|
opacity: 0.6;
|
|
2434
2456
|
cursor: not-allowed;
|
|
2435
|
-
|
|
2436
|
-
&.secondary:disabled {
|
|
2437
|
-
filter: brightness(0.9);
|
|
2438
|
-
}
|
|
2439
2457
|
` : !props.isLoading ? css`
|
|
2440
2458
|
cursor: pointer;
|
|
2441
2459
|
|
|
2442
2460
|
&:not(.secondary):hover {
|
|
2443
|
-
filter: brightness(0.9);
|
|
2461
|
+
filter: ${props.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.9)"};
|
|
2444
2462
|
}
|
|
2445
2463
|
|
|
2446
2464
|
&.secondary:hover {
|
|
@@ -2489,7 +2507,7 @@ var ButtonComponent = function Button({
|
|
|
2489
2507
|
}) {
|
|
2490
2508
|
const theme2 = useTheme();
|
|
2491
2509
|
const isLoadingHook = useLoader(loaderName);
|
|
2492
|
-
const betterHtmlContext2 =
|
|
2510
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2493
2511
|
const isLoadingElement = isLoading ?? isLoadingHook;
|
|
2494
2512
|
const styledComponentStyles = useStyledComponentStyles(
|
|
2495
2513
|
{
|
|
@@ -2501,7 +2519,7 @@ var ButtonComponent = function Button({
|
|
|
2501
2519
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2502
2520
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
2503
2521
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
2504
|
-
const onClickElement =
|
|
2522
|
+
const onClickElement = useCallback4(
|
|
2505
2523
|
(event) => {
|
|
2506
2524
|
onClick?.(event);
|
|
2507
2525
|
onClickWithValue?.(value);
|
|
@@ -2530,6 +2548,7 @@ var ButtonComponent = function Button({
|
|
|
2530
2548
|
{
|
|
2531
2549
|
as: href ? "a" : "button",
|
|
2532
2550
|
theme: theme2,
|
|
2551
|
+
colorTheme: betterHtmlContext2.colorTheme,
|
|
2533
2552
|
isSmall,
|
|
2534
2553
|
withText: text !== void 0,
|
|
2535
2554
|
isLoading: isLoadingElement,
|
|
@@ -2591,7 +2610,7 @@ var ButtonComponent = function Button({
|
|
|
2591
2610
|
};
|
|
2592
2611
|
ButtonComponent.secondary = function Secondary({ className, ...props }) {
|
|
2593
2612
|
const theme2 = useTheme();
|
|
2594
|
-
const betterHtmlContext2 =
|
|
2613
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2595
2614
|
return /* @__PURE__ */ jsx7(
|
|
2596
2615
|
ButtonComponent,
|
|
2597
2616
|
{
|
|
@@ -2604,7 +2623,7 @@ ButtonComponent.secondary = function Secondary({ className, ...props }) {
|
|
|
2604
2623
|
};
|
|
2605
2624
|
ButtonComponent.destructive = function Destructive(props) {
|
|
2606
2625
|
const theme2 = useTheme();
|
|
2607
|
-
const betterHtmlContext2 =
|
|
2626
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2608
2627
|
return /* @__PURE__ */ jsx7(
|
|
2609
2628
|
ButtonComponent,
|
|
2610
2629
|
{
|
|
@@ -2617,7 +2636,7 @@ ButtonComponent.destructive = function Destructive(props) {
|
|
|
2617
2636
|
};
|
|
2618
2637
|
ButtonComponent.icon = function Icon3({ size = 16, backgroundButtonColor, ...props }) {
|
|
2619
2638
|
const theme2 = useTheme();
|
|
2620
|
-
const betterHtmlContext2 =
|
|
2639
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2621
2640
|
const buttonSize = size + theme2.styles.space;
|
|
2622
2641
|
const backgroundButtonColorReady = backgroundButtonColor ?? theme2.colors.textPrimary;
|
|
2623
2642
|
return /* @__PURE__ */ jsx7(
|
|
@@ -2641,8 +2660,8 @@ ButtonComponent.icon = function Icon3({ size = 16, backgroundButtonColor, ...pro
|
|
|
2641
2660
|
);
|
|
2642
2661
|
};
|
|
2643
2662
|
ButtonComponent.upload = function Upload({ accept, multiple, onUpload, ...props }) {
|
|
2644
|
-
const betterHtmlContext2 =
|
|
2645
|
-
const onClickElement =
|
|
2663
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2664
|
+
const onClickElement = useCallback4(() => {
|
|
2646
2665
|
const input = document.createElement("input");
|
|
2647
2666
|
input.setAttribute("type", "file");
|
|
2648
2667
|
if (accept) input.setAttribute("accept", accept);
|
|
@@ -2704,7 +2723,7 @@ var Divider_default = {
|
|
|
2704
2723
|
};
|
|
2705
2724
|
|
|
2706
2725
|
// src/components/Modal.tsx
|
|
2707
|
-
import { memo as memo9, useCallback as
|
|
2726
|
+
import { memo as memo9, useCallback as useCallback5, forwardRef as forwardRef5, useImperativeHandle, useRef as useRef2, useState as useState3 } from "react";
|
|
2708
2727
|
import styled7 from "styled-components";
|
|
2709
2728
|
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2710
2729
|
var DialogStylesElement = styled7.dialog.withConfig({
|
|
@@ -2763,24 +2782,25 @@ var ModalComponent = forwardRef5(function Modal({
|
|
|
2763
2782
|
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
2764
2783
|
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
2765
2784
|
const theme2 = useTheme();
|
|
2766
|
-
const { app, colorTheme } =
|
|
2785
|
+
const { app, colorTheme } = useBetterHtmlContextInternal();
|
|
2767
2786
|
const dialogRef = useRef2(null);
|
|
2768
|
-
const [isOpened, setIsOpened] =
|
|
2769
|
-
const [isOpenedLate, setIsOpenedLate] =
|
|
2770
|
-
const onClickOpen =
|
|
2787
|
+
const [isOpened, setIsOpened] = useState3(false);
|
|
2788
|
+
const [isOpenedLate, setIsOpenedLate] = useState3(false);
|
|
2789
|
+
const onClickOpen = useCallback5(() => {
|
|
2771
2790
|
dialogRef.current?.showModal();
|
|
2772
2791
|
setIsOpened(true);
|
|
2773
2792
|
setIsOpenedLate(true);
|
|
2774
|
-
if (urlQuery && name)
|
|
2793
|
+
if (urlQuery && name) {
|
|
2775
2794
|
urlQuery.setQuery(
|
|
2776
2795
|
{
|
|
2777
2796
|
[`${name}-modal`]: "opened"
|
|
2778
2797
|
},
|
|
2779
2798
|
false
|
|
2780
2799
|
);
|
|
2800
|
+
}
|
|
2781
2801
|
onOpen?.();
|
|
2782
2802
|
}, [onOpen, urlQuery, name]);
|
|
2783
|
-
const onClickClose =
|
|
2803
|
+
const onClickClose = useCallback5(() => {
|
|
2784
2804
|
setIsOpened(false);
|
|
2785
2805
|
onClose?.();
|
|
2786
2806
|
if (urlQuery && name) urlQuery.removeQuery(`${name}-modal`, false);
|
|
@@ -2900,11 +2920,11 @@ var ModalComponent = forwardRef5(function Modal({
|
|
|
2900
2920
|
ModalComponent.confirmation = forwardRef5(function Confirmation({ continueButtonLoaderName, onContinue, onCancel, ...props }, ref) {
|
|
2901
2921
|
const theme2 = useTheme();
|
|
2902
2922
|
const modalRef = useRef2(null);
|
|
2903
|
-
const onCancelElement =
|
|
2923
|
+
const onCancelElement = useCallback5(() => {
|
|
2904
2924
|
onCancel?.();
|
|
2905
2925
|
modalRef.current?.close();
|
|
2906
2926
|
}, [onCancel]);
|
|
2907
|
-
const onContinueElement =
|
|
2927
|
+
const onContinueElement = useCallback5(() => {
|
|
2908
2928
|
onContinue?.();
|
|
2909
2929
|
modalRef.current?.close();
|
|
2910
2930
|
}, [onContinue]);
|
|
@@ -2929,11 +2949,11 @@ ModalComponent.confirmation = forwardRef5(function Confirmation({ continueButton
|
|
|
2929
2949
|
ModalComponent.destructive = forwardRef5(function Destructive2({ deleteButtonLoaderName, onDelete, onCancel, ...props }, ref) {
|
|
2930
2950
|
const theme2 = useTheme();
|
|
2931
2951
|
const modalRef = useRef2(null);
|
|
2932
|
-
const onCancelElement =
|
|
2952
|
+
const onCancelElement = useCallback5(() => {
|
|
2933
2953
|
onCancel?.();
|
|
2934
2954
|
modalRef.current?.close();
|
|
2935
2955
|
}, [onCancel]);
|
|
2936
|
-
const onDeleteElement =
|
|
2956
|
+
const onDeleteElement = useCallback5(() => {
|
|
2937
2957
|
onDelete?.();
|
|
2938
2958
|
modalRef.current?.close();
|
|
2939
2959
|
}, [onDelete]);
|
|
@@ -2973,7 +2993,7 @@ import { memo as memo10 } from "react";
|
|
|
2973
2993
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
2974
2994
|
function PageHolder({ noMaxContentWidth, children }) {
|
|
2975
2995
|
const theme2 = useTheme();
|
|
2976
|
-
const { app } =
|
|
2996
|
+
const { app } = useBetterHtmlContextInternal();
|
|
2977
2997
|
return /* @__PURE__ */ jsx10(
|
|
2978
2998
|
Div_default,
|
|
2979
2999
|
{
|
|
@@ -3004,7 +3024,7 @@ function PageHeader({
|
|
|
3004
3024
|
marginBottom
|
|
3005
3025
|
}) {
|
|
3006
3026
|
const theme2 = useTheme();
|
|
3007
|
-
const { app } =
|
|
3027
|
+
const { app } = useBetterHtmlContextInternal();
|
|
3008
3028
|
const mediaQuery = useMediaQuery();
|
|
3009
3029
|
return /* @__PURE__ */ jsxs6(Div_default.row, { alignItems: "center", gap: theme2.styles.space, marginBottom: marginBottom ?? theme2.styles.space * 2, children: [
|
|
3010
3030
|
imageUrl && /* @__PURE__ */ jsx11(Image_default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }),
|
|
@@ -3079,7 +3099,7 @@ Chip2.circle = ChipComponent.circle;
|
|
|
3079
3099
|
var Chip_default = Chip2;
|
|
3080
3100
|
|
|
3081
3101
|
// src/components/InputField.tsx
|
|
3082
|
-
import { forwardRef as forwardRef8, memo as memo16, useCallback as
|
|
3102
|
+
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
3103
|
import styled8 from "styled-components";
|
|
3084
3104
|
|
|
3085
3105
|
// src/constants/countries.ts
|
|
@@ -4650,7 +4670,7 @@ function Label({ text, required, isError, color }) {
|
|
|
4650
4670
|
var Label_default = memo13(Label);
|
|
4651
4671
|
|
|
4652
4672
|
// src/components/Dropdown.tsx
|
|
4653
|
-
import { forwardRef as forwardRef7, memo as memo14, useCallback as
|
|
4673
|
+
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
4674
|
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4655
4675
|
var DropdownComponent = forwardRef7(function Dropdown({
|
|
4656
4676
|
label,
|
|
@@ -4682,13 +4702,13 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4682
4702
|
const [isOpen, setIsOpen] = useBooleanState();
|
|
4683
4703
|
const [isOpenLate, setIsOpenLate] = useBooleanState();
|
|
4684
4704
|
const [isFocused, setIsFocused] = useBooleanState();
|
|
4685
|
-
const [searchQuery, setSearchQuery] =
|
|
4705
|
+
const [searchQuery, setSearchQuery] = useState4("");
|
|
4686
4706
|
const [_, debouncedSearchQuery, setDebouncedSearchQuery, isLoadingDebouncedSearchQuery] = useDebounceState(
|
|
4687
4707
|
"",
|
|
4688
4708
|
debounceDelay
|
|
4689
4709
|
);
|
|
4690
|
-
const [focusedOptionIndex, setFocusedOptionIndex] =
|
|
4691
|
-
const [internalValue, setInternalValue] =
|
|
4710
|
+
const [focusedOptionIndex, setFocusedOptionIndex] = useState4();
|
|
4711
|
+
const [internalValue, setInternalValue] = useState4(defaultValue);
|
|
4692
4712
|
const value = controlledValue ?? internalValue;
|
|
4693
4713
|
const filteredOptions = useMemo3(() => {
|
|
4694
4714
|
if (!searchQuery) return options;
|
|
@@ -4697,7 +4717,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4697
4717
|
(option) => option.label.toLowerCase().includes(query) || option.searchValues?.some((value2) => value2.toLowerCase().includes(query))
|
|
4698
4718
|
);
|
|
4699
4719
|
}, [options, searchQuery]);
|
|
4700
|
-
const onKeyDownInputField =
|
|
4720
|
+
const onKeyDownInputField = useCallback6(
|
|
4701
4721
|
(event) => {
|
|
4702
4722
|
if (event.key === "Enter" || !withSearch && event.key === " ") {
|
|
4703
4723
|
event.preventDefault();
|
|
@@ -4738,7 +4758,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4738
4758
|
},
|
|
4739
4759
|
[disabled, withSearch, isOpen, filteredOptions, focusedOptionIndex, controlledValue, onChange]
|
|
4740
4760
|
);
|
|
4741
|
-
const onClickOption =
|
|
4761
|
+
const onClickOption = useCallback6(
|
|
4742
4762
|
(option) => {
|
|
4743
4763
|
if (!option.disabled) {
|
|
4744
4764
|
if (controlledValue === void 0) setInternalValue(option.value);
|
|
@@ -4751,7 +4771,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4751
4771
|
},
|
|
4752
4772
|
[onChange, controlledValue]
|
|
4753
4773
|
);
|
|
4754
|
-
const onClickClearButton =
|
|
4774
|
+
const onClickClearButton = useCallback6(
|
|
4755
4775
|
(event) => {
|
|
4756
4776
|
event.stopPropagation();
|
|
4757
4777
|
setInternalValue(void 0);
|
|
@@ -4763,7 +4783,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4763
4783
|
},
|
|
4764
4784
|
[onChange]
|
|
4765
4785
|
);
|
|
4766
|
-
const onChangeValue =
|
|
4786
|
+
const onChangeValue = useCallback6(
|
|
4767
4787
|
(newValue) => {
|
|
4768
4788
|
setSearchQuery(newValue);
|
|
4769
4789
|
if (withDebounce) setDebouncedSearchQuery(newValue);
|
|
@@ -4808,7 +4828,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4808
4828
|
const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
|
|
4809
4829
|
const withClearButton = isOpen && selectedOption;
|
|
4810
4830
|
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: [
|
|
4831
|
+
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
4832
|
/* @__PURE__ */ jsx13(
|
|
4813
4833
|
InputField_default,
|
|
4814
4834
|
{
|
|
@@ -4828,7 +4848,6 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4828
4848
|
onFocus: setIsFocused.setTrue,
|
|
4829
4849
|
onBlur: setIsFocused.setFalse,
|
|
4830
4850
|
onKeyDown: onKeyDownInputField,
|
|
4831
|
-
holderRef: inputFieldHolderRef,
|
|
4832
4851
|
onChangeValue: withSearch ? onChangeValue : void 0,
|
|
4833
4852
|
insideInputFieldComponent: /* @__PURE__ */ jsx13(
|
|
4834
4853
|
Div_default,
|
|
@@ -4934,7 +4953,7 @@ var Dropdown2 = memo14(DropdownComponent);
|
|
|
4934
4953
|
var Dropdown_default = Dropdown2;
|
|
4935
4954
|
|
|
4936
4955
|
// src/components/Calendar.tsx
|
|
4937
|
-
import { useCallback as
|
|
4956
|
+
import { useCallback as useCallback7, useMemo as useMemo4, useState as useState5, memo as memo15, useEffect as useEffect6 } from "react";
|
|
4938
4957
|
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4939
4958
|
var getMonthName = (month, short = false) => {
|
|
4940
4959
|
return [
|
|
@@ -4966,23 +4985,23 @@ var getWeekDayName = (day, short = false) => {
|
|
|
4966
4985
|
var weekDaysIndex = [1, 2, 3, 4, 5, 6, 0];
|
|
4967
4986
|
function Calendar({ value, minDate, maxDate, onChange }) {
|
|
4968
4987
|
const theme2 = useTheme();
|
|
4969
|
-
const [currentDate, setCurrentDate] =
|
|
4970
|
-
const [currentMonth, setCurrentMonth] =
|
|
4971
|
-
const [currentYear, setCurrentYear] =
|
|
4988
|
+
const [currentDate, setCurrentDate] = useState5(value ? new Date(value) : void 0);
|
|
4989
|
+
const [currentMonth, setCurrentMonth] = useState5(currentDate?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth());
|
|
4990
|
+
const [currentYear, setCurrentYear] = useState5(currentDate?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear());
|
|
4972
4991
|
const daysInMonth = useMemo4(() => new Date(currentYear, currentMonth + 1, 0).getDate(), [currentMonth, currentYear]);
|
|
4973
|
-
const onClickPreviousMonthButton =
|
|
4992
|
+
const onClickPreviousMonthButton = useCallback7(() => {
|
|
4974
4993
|
const newMonth = currentMonth === 0 ? 11 : currentMonth - 1;
|
|
4975
4994
|
const newYear = currentMonth === 0 ? currentYear - 1 : currentYear;
|
|
4976
4995
|
setCurrentMonth(newMonth);
|
|
4977
4996
|
setCurrentYear(newYear);
|
|
4978
4997
|
}, [currentMonth, currentYear]);
|
|
4979
|
-
const onClickNextMonthButton =
|
|
4998
|
+
const onClickNextMonthButton = useCallback7(() => {
|
|
4980
4999
|
const newMonth = currentMonth === 11 ? 0 : currentMonth + 1;
|
|
4981
5000
|
const newYear = currentMonth === 11 ? currentYear + 1 : currentYear;
|
|
4982
5001
|
setCurrentMonth(newMonth);
|
|
4983
5002
|
setCurrentYear(newYear);
|
|
4984
5003
|
}, [currentMonth, currentYear]);
|
|
4985
|
-
const onClickDay =
|
|
5004
|
+
const onClickDay = useCallback7(
|
|
4986
5005
|
(day) => {
|
|
4987
5006
|
if (!day) return;
|
|
4988
5007
|
const newDate = new Date(currentYear, currentMonth, day);
|
|
@@ -4993,11 +5012,11 @@ function Calendar({ value, minDate, maxDate, onChange }) {
|
|
|
4993
5012
|
},
|
|
4994
5013
|
[currentMonth, currentYear, onChange]
|
|
4995
5014
|
);
|
|
4996
|
-
const onClickClear =
|
|
5015
|
+
const onClickClear = useCallback7(() => {
|
|
4997
5016
|
setCurrentDate(void 0);
|
|
4998
5017
|
onChange?.(void 0);
|
|
4999
5018
|
}, []);
|
|
5000
|
-
const onClickToday =
|
|
5019
|
+
const onClickToday = useCallback7(() => {
|
|
5001
5020
|
const today = /* @__PURE__ */ new Date();
|
|
5002
5021
|
setCurrentDate(today);
|
|
5003
5022
|
onChange?.(
|
|
@@ -5265,7 +5284,7 @@ var InputFieldComponent = forwardRef8(function InputField({
|
|
|
5265
5284
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5266
5285
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5267
5286
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5268
|
-
const onChangeElement =
|
|
5287
|
+
const onChangeElement = useCallback8(
|
|
5269
5288
|
(event) => {
|
|
5270
5289
|
const newValue = event.target.value;
|
|
5271
5290
|
if (withDebounce) {
|
|
@@ -5372,7 +5391,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
|
|
|
5372
5391
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5373
5392
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5374
5393
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5375
|
-
const onChangeElement =
|
|
5394
|
+
const onChangeElement = useCallback8(
|
|
5376
5395
|
(event) => {
|
|
5377
5396
|
onChange?.(event);
|
|
5378
5397
|
onChangeValue?.(event.target.value);
|
|
@@ -5480,16 +5499,16 @@ InputFieldComponent.search = forwardRef8(function Search({ ...props }, ref) {
|
|
|
5480
5499
|
});
|
|
5481
5500
|
InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
|
|
5482
5501
|
const theme2 = useTheme();
|
|
5483
|
-
const [dropdownValue, setDropdownValue] =
|
|
5484
|
-
const [inputFieldValue, setInputFieldValue] =
|
|
5485
|
-
const renderOption =
|
|
5502
|
+
const [dropdownValue, setDropdownValue] = useState6();
|
|
5503
|
+
const [inputFieldValue, setInputFieldValue] = useState6(value?.toString() ?? "");
|
|
5504
|
+
const renderOption = useCallback8(
|
|
5486
5505
|
(option, index, isSelected) => /* @__PURE__ */ jsxs10(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
|
|
5487
5506
|
/* @__PURE__ */ jsx15(Image_default, { src: `https://flagcdn.com/w80/${option.data?.code.toString().toLowerCase()}.webp`, width: 20 }),
|
|
5488
5507
|
/* @__PURE__ */ jsx15(Text_default, { children: option.label })
|
|
5489
5508
|
] }),
|
|
5490
5509
|
[]
|
|
5491
5510
|
);
|
|
5492
|
-
const onChangeValueElement =
|
|
5511
|
+
const onChangeValueElement = useCallback8(
|
|
5493
5512
|
(value2) => {
|
|
5494
5513
|
const readyValue = value2.replace(/\D/g, "");
|
|
5495
5514
|
setInputFieldValue(readyValue);
|
|
@@ -5565,7 +5584,7 @@ InputFieldComponent.date = forwardRef8(function Date2({ minDate, maxDate, ...pro
|
|
|
5565
5584
|
const holderRef = useRef4(null);
|
|
5566
5585
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5567
5586
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5568
|
-
const onChange =
|
|
5587
|
+
const onChange = useCallback8(
|
|
5569
5588
|
(date) => {
|
|
5570
5589
|
inputFieldProps.onChangeValue?.(date ?? "");
|
|
5571
5590
|
setInternalValue(date ?? "");
|
|
@@ -5606,7 +5625,7 @@ InputFieldComponent.dateTime = forwardRef8(function DateTime({ minDate, maxDate,
|
|
|
5606
5625
|
const selectedMinuteRef = useRef4(null);
|
|
5607
5626
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5608
5627
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5609
|
-
const onChange =
|
|
5628
|
+
const onChange = useCallback8(
|
|
5610
5629
|
(date) => {
|
|
5611
5630
|
const newValue = date ? `${date}T${internalValue?.toString().split("T")[1] ?? "00:00"}` : "";
|
|
5612
5631
|
inputFieldProps.onChangeValue?.(newValue);
|
|
@@ -5614,7 +5633,7 @@ InputFieldComponent.dateTime = forwardRef8(function DateTime({ minDate, maxDate,
|
|
|
5614
5633
|
},
|
|
5615
5634
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5616
5635
|
);
|
|
5617
|
-
const onClickHour =
|
|
5636
|
+
const onClickHour = useCallback8(
|
|
5618
5637
|
(hour) => {
|
|
5619
5638
|
const newTime = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
5620
5639
|
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 +5643,7 @@ InputFieldComponent.dateTime = forwardRef8(function DateTime({ minDate, maxDate,
|
|
|
5624
5643
|
},
|
|
5625
5644
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5626
5645
|
);
|
|
5627
|
-
const onClickMinute =
|
|
5646
|
+
const onClickMinute = useCallback8(
|
|
5628
5647
|
(minute) => {
|
|
5629
5648
|
const newTime = `${internalValue?.toString().split("T")?.[1]?.split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
5630
5649
|
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 +5778,7 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5759
5778
|
const selectedMinuteRef = useRef4(null);
|
|
5760
5779
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
5761
5780
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
5762
|
-
const onClickHour =
|
|
5781
|
+
const onClickHour = useCallback8(
|
|
5763
5782
|
(hour) => {
|
|
5764
5783
|
const value = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
5765
5784
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -5767,7 +5786,7 @@ InputFieldComponent.time = forwardRef8(function Time({ ...props }, ref) {
|
|
|
5767
5786
|
},
|
|
5768
5787
|
[internalValue, inputFieldProps.onChangeValue]
|
|
5769
5788
|
);
|
|
5770
|
-
const onClickMinute =
|
|
5789
|
+
const onClickMinute = useCallback8(
|
|
5771
5790
|
(minute) => {
|
|
5772
5791
|
const value = `${internalValue?.toString().split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
5773
5792
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -5866,7 +5885,7 @@ InputField2.time = InputFieldComponent.time;
|
|
|
5866
5885
|
var InputField_default = InputField2;
|
|
5867
5886
|
|
|
5868
5887
|
// src/components/ToggleInput.tsx
|
|
5869
|
-
import { forwardRef as forwardRef9, useCallback as
|
|
5888
|
+
import { forwardRef as forwardRef9, useCallback as useCallback9, useState as useState7 } from "react";
|
|
5870
5889
|
import styled9 from "styled-components";
|
|
5871
5890
|
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5872
5891
|
var componentSize = 26;
|
|
@@ -5903,6 +5922,8 @@ var InputElement2 = styled9.input.withConfig({
|
|
|
5903
5922
|
${(props) => props.normalStyle}
|
|
5904
5923
|
|
|
5905
5924
|
&:hover {
|
|
5925
|
+
border-color: ${(props) => props.theme.colors.primary};
|
|
5926
|
+
|
|
5906
5927
|
${(props) => props.hoverStyle}
|
|
5907
5928
|
}
|
|
5908
5929
|
`;
|
|
@@ -5978,8 +5999,8 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5978
5999
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
5979
6000
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
5980
6001
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
5981
|
-
const [internalChecked, setInternalChecked] =
|
|
5982
|
-
const onChangeElement =
|
|
6002
|
+
const [internalChecked, setInternalChecked] = useState7(false);
|
|
6003
|
+
const onChangeElement = useCallback9(
|
|
5983
6004
|
(event) => {
|
|
5984
6005
|
const newIsChecked = event.target.checked;
|
|
5985
6006
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
@@ -5988,7 +6009,7 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
|
|
|
5988
6009
|
[onChange, controlledChecked, value]
|
|
5989
6010
|
);
|
|
5990
6011
|
const checked = controlledChecked ?? internalChecked;
|
|
5991
|
-
const onClickText =
|
|
6012
|
+
const onClickText = useCallback9(() => {
|
|
5992
6013
|
const newIsChecked = !checked;
|
|
5993
6014
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
5994
6015
|
onChange?.(newIsChecked, value);
|
|
@@ -6088,7 +6109,7 @@ var ToggleInput_default = {
|
|
|
6088
6109
|
const [internalChecked, setInternalChecked] = useBooleanState();
|
|
6089
6110
|
const [isMouseDown, setIsMouseDown] = useBooleanState();
|
|
6090
6111
|
const checked = controlledChecked ?? internalChecked;
|
|
6091
|
-
const onClickElement =
|
|
6112
|
+
const onClickElement = useCallback9(() => {
|
|
6092
6113
|
if (disabled) return;
|
|
6093
6114
|
const newIsChecked = !checked;
|
|
6094
6115
|
if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
|
|
@@ -6310,7 +6331,7 @@ ColorThemeSwitch2.withText = ColorThemeSwitchComponent.withText;
|
|
|
6310
6331
|
var ColorThemeSwitch_default = ColorThemeSwitch2;
|
|
6311
6332
|
|
|
6312
6333
|
// src/components/Table.tsx
|
|
6313
|
-
import { forwardRef as forwardRef11, memo as memo20, useCallback as
|
|
6334
|
+
import { forwardRef as forwardRef11, memo as memo20, useCallback as useCallback10, useMemo as useMemo7, useState as useState8 } from "react";
|
|
6314
6335
|
import styled10, { css as css2 } from "styled-components";
|
|
6315
6336
|
import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
6316
6337
|
var defaultImageWidth = 120;
|
|
@@ -6388,10 +6409,10 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6388
6409
|
onClickAllCheckboxes,
|
|
6389
6410
|
...props
|
|
6390
6411
|
}, ref) {
|
|
6391
|
-
const { colorTheme } =
|
|
6412
|
+
const { colorTheme } = useBetterHtmlContextInternal();
|
|
6392
6413
|
const theme2 = useTheme();
|
|
6393
|
-
const [checkedItems, setCheckedItems] =
|
|
6394
|
-
const renderCellContent =
|
|
6414
|
+
const [checkedItems, setCheckedItems] = useState8([]);
|
|
6415
|
+
const renderCellContent = useCallback10(
|
|
6395
6416
|
(column, item, index) => {
|
|
6396
6417
|
switch (column.type) {
|
|
6397
6418
|
case "text": {
|
|
@@ -6430,13 +6451,13 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6430
6451
|
},
|
|
6431
6452
|
[theme2, checkedItems]
|
|
6432
6453
|
);
|
|
6433
|
-
const onClickRowElement =
|
|
6454
|
+
const onClickRowElement = useCallback10(
|
|
6434
6455
|
(item, index) => {
|
|
6435
6456
|
onClickRow?.(item, index);
|
|
6436
6457
|
},
|
|
6437
6458
|
[onClickRow]
|
|
6438
6459
|
);
|
|
6439
|
-
const onClickAllCheckboxesElement =
|
|
6460
|
+
const onClickAllCheckboxesElement = useCallback10(
|
|
6440
6461
|
(checked) => {
|
|
6441
6462
|
onClickAllCheckboxes?.(checked);
|
|
6442
6463
|
setCheckedItems(data.map(() => checked));
|
|
@@ -6498,6 +6519,302 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6498
6519
|
var Table2 = memo20(TableComponent);
|
|
6499
6520
|
var Table_default = Table2;
|
|
6500
6521
|
|
|
6522
|
+
// src/components/Tabs.tsx
|
|
6523
|
+
import { memo as memo21, useCallback as useCallback11, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef5, useState as useState9 } from "react";
|
|
6524
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6525
|
+
var tabBottomLineWidth = 2;
|
|
6526
|
+
var tabDotSize = 6;
|
|
6527
|
+
var defaultTabName = "tab";
|
|
6528
|
+
var TabsComponent = function Tabs({
|
|
6529
|
+
tabs,
|
|
6530
|
+
name,
|
|
6531
|
+
accentColor,
|
|
6532
|
+
style = "default",
|
|
6533
|
+
children,
|
|
6534
|
+
...props
|
|
6535
|
+
}) {
|
|
6536
|
+
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
6537
|
+
const theme2 = useTheme();
|
|
6538
|
+
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
6539
|
+
const { colorTheme, componentsState } = useBetterHtmlContextInternal();
|
|
6540
|
+
const firstRenderPassedRef = useRef5(false);
|
|
6541
|
+
const tabsRef = useRef5({});
|
|
6542
|
+
const [selectedTab, setSelectedTab] = useState9(() => {
|
|
6543
|
+
const selectedTabValue = tabs[0] ?? "";
|
|
6544
|
+
if (urlQuery) {
|
|
6545
|
+
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
6546
|
+
if (!tabQueryValue) return selectedTabValue;
|
|
6547
|
+
if (tabs.includes(tabQueryValue)) return tabQueryValue;
|
|
6548
|
+
}
|
|
6549
|
+
return selectedTabValue;
|
|
6550
|
+
});
|
|
6551
|
+
const [rerenderState, setRerenderState] = useState9(0);
|
|
6552
|
+
const tabsGap = style === "box" ? theme2.styles.gap / 2 : 0;
|
|
6553
|
+
const onClickTab = useCallback11(
|
|
6554
|
+
(tab) => {
|
|
6555
|
+
setSelectedTab(tab);
|
|
6556
|
+
if (urlQuery) {
|
|
6557
|
+
urlQuery.setQuery({
|
|
6558
|
+
[name ?? defaultTabName]: tab
|
|
6559
|
+
});
|
|
6560
|
+
}
|
|
6561
|
+
},
|
|
6562
|
+
[name, urlQuery]
|
|
6563
|
+
);
|
|
6564
|
+
const width = useMemo8(
|
|
6565
|
+
() => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
|
|
6566
|
+
[rerenderState, selectedTab]
|
|
6567
|
+
);
|
|
6568
|
+
const leftSpacing = useMemo8(() => {
|
|
6569
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab === selectedTab);
|
|
6570
|
+
let spacing = 0;
|
|
6571
|
+
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
6572
|
+
if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
6573
|
+
});
|
|
6574
|
+
return spacing;
|
|
6575
|
+
}, [selectedTab, tabs, tabsGap]);
|
|
6576
|
+
useEffect9(() => {
|
|
6577
|
+
const timeout = setTimeout(() => {
|
|
6578
|
+
setRerenderState(Math.random());
|
|
6579
|
+
firstRenderPassedRef.current = true;
|
|
6580
|
+
}, 0.01 * 1e3);
|
|
6581
|
+
return () => {
|
|
6582
|
+
clearTimeout(timeout);
|
|
6583
|
+
};
|
|
6584
|
+
}, []);
|
|
6585
|
+
useEffect9(() => {
|
|
6586
|
+
componentsState.tabs.setTabGroups((oldValue) => {
|
|
6587
|
+
const thisTabGroup = oldValue.find((item) => item.name === (name ?? defaultTabName));
|
|
6588
|
+
if (thisTabGroup) {
|
|
6589
|
+
return oldValue.map(
|
|
6590
|
+
(item) => item.name === (name ?? defaultTabName) ? {
|
|
6591
|
+
...item,
|
|
6592
|
+
selectedTab
|
|
6593
|
+
} : item
|
|
6594
|
+
);
|
|
6595
|
+
} else {
|
|
6596
|
+
return [
|
|
6597
|
+
...oldValue,
|
|
6598
|
+
{
|
|
6599
|
+
name: name ?? defaultTabName,
|
|
6600
|
+
selectedTab
|
|
6601
|
+
}
|
|
6602
|
+
];
|
|
6603
|
+
}
|
|
6604
|
+
});
|
|
6605
|
+
}, [selectedTab, name]);
|
|
6606
|
+
useEffect9(() => {
|
|
6607
|
+
tabsRef.current[selectedTab]?.scrollIntoView({
|
|
6608
|
+
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
6609
|
+
block: "nearest"
|
|
6610
|
+
});
|
|
6611
|
+
}, [selectedTab]);
|
|
6612
|
+
return /* @__PURE__ */ jsxs16(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
6613
|
+
/* @__PURE__ */ jsxs16(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
6614
|
+
/* @__PURE__ */ jsx21(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
6615
|
+
const selected = tab === selectedTab;
|
|
6616
|
+
return /* @__PURE__ */ jsxs16(
|
|
6617
|
+
Div_default,
|
|
6618
|
+
{
|
|
6619
|
+
position: "relative",
|
|
6620
|
+
width: "fit-content",
|
|
6621
|
+
backgroundColor: style === "box" ? selected ? theme2.colors.primary : theme2.colors.backgroundContent : theme2.colors.backgroundBase,
|
|
6622
|
+
borderRadius: style === "box" ? theme2.styles.borderRadius : void 0,
|
|
6623
|
+
borderTopLeftRadius: style === "borderRadiusTop" ? theme2.styles.borderRadius : void 0,
|
|
6624
|
+
borderTopRightRadius: style === "borderRadiusTop" ? theme2.styles.borderRadius : void 0,
|
|
6625
|
+
border: style === "box" ? `1px solid ${selected ? "transparent" : theme2.colors.border}` : void 0,
|
|
6626
|
+
filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
|
|
6627
|
+
paddingInline: theme2.styles.space,
|
|
6628
|
+
paddingBlock: theme2.styles.gap,
|
|
6629
|
+
value: tab,
|
|
6630
|
+
cursor: "pointer",
|
|
6631
|
+
isTabAccessed: true,
|
|
6632
|
+
onClickWithValue: onClickTab,
|
|
6633
|
+
ref: (ref) => {
|
|
6634
|
+
tabsRef.current[tab] = ref;
|
|
6635
|
+
},
|
|
6636
|
+
children: [
|
|
6637
|
+
componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ jsx21(
|
|
6638
|
+
Div_default,
|
|
6639
|
+
{
|
|
6640
|
+
position: "absolute",
|
|
6641
|
+
top: (theme2.styles.space - tabDotSize) / 2,
|
|
6642
|
+
right: (theme2.styles.space - tabDotSize) / 2,
|
|
6643
|
+
width: tabDotSize,
|
|
6644
|
+
height: tabDotSize,
|
|
6645
|
+
backgroundColor: style === "box" && selected ? theme2.colors.base : theme2.colors.primary,
|
|
6646
|
+
borderRadius: 999,
|
|
6647
|
+
transition: theme2.styles.transition
|
|
6648
|
+
}
|
|
6649
|
+
),
|
|
6650
|
+
/* @__PURE__ */ jsx21(
|
|
6651
|
+
Text_default,
|
|
6652
|
+
{
|
|
6653
|
+
fontWeight: 700,
|
|
6654
|
+
color: !selected ? theme2.colors.textSecondary : style === "box" ? theme2.colors.base : void 0,
|
|
6655
|
+
transition: theme2.styles.transition,
|
|
6656
|
+
whiteSpace: "nowrap",
|
|
6657
|
+
children: tab
|
|
6658
|
+
}
|
|
6659
|
+
)
|
|
6660
|
+
]
|
|
6661
|
+
},
|
|
6662
|
+
tab
|
|
6663
|
+
);
|
|
6664
|
+
}) }),
|
|
6665
|
+
style !== "box" && /* @__PURE__ */ jsx21(
|
|
6666
|
+
Div_default,
|
|
6667
|
+
{
|
|
6668
|
+
position: "absolute",
|
|
6669
|
+
width,
|
|
6670
|
+
height: tabBottomLineWidth,
|
|
6671
|
+
bottom: 0,
|
|
6672
|
+
left: leftSpacing,
|
|
6673
|
+
backgroundColor: accentColor ?? theme2.colors.primary,
|
|
6674
|
+
transition: firstRenderPassedRef.current ? theme2.styles.transition : "none"
|
|
6675
|
+
}
|
|
6676
|
+
)
|
|
6677
|
+
] }),
|
|
6678
|
+
/* @__PURE__ */ jsx21(Div_default, { width: "100%", children })
|
|
6679
|
+
] });
|
|
6680
|
+
};
|
|
6681
|
+
TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, children }) {
|
|
6682
|
+
const { componentsState } = useBetterHtmlContextInternal();
|
|
6683
|
+
const thisTabGroupData = useMemo8(
|
|
6684
|
+
() => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
|
|
6685
|
+
[componentsState.tabs, tabsGroupName]
|
|
6686
|
+
);
|
|
6687
|
+
useEffect9(() => {
|
|
6688
|
+
if (tabWithDot) {
|
|
6689
|
+
componentsState.tabs.setTabsWithDots?.((oldValue) => oldValue.includes(tab) ? oldValue : [...oldValue, tab]);
|
|
6690
|
+
} else {
|
|
6691
|
+
componentsState.tabs.setTabsWithDots?.(
|
|
6692
|
+
(oldValue) => oldValue.includes(tab) ? oldValue.filter((tab2) => tab2 !== tab2) : oldValue
|
|
6693
|
+
);
|
|
6694
|
+
}
|
|
6695
|
+
}, [tabWithDot]);
|
|
6696
|
+
return thisTabGroupData?.selectedTab === tab ? /* @__PURE__ */ jsx21(Div_default, { width: "100%", children }) : void 0;
|
|
6697
|
+
};
|
|
6698
|
+
var Tabs2 = memo21(TabsComponent);
|
|
6699
|
+
Tabs2.content = TabsComponent.content;
|
|
6700
|
+
var Tabs_default = Tabs2;
|
|
6701
|
+
|
|
6702
|
+
// src/components/Foldable.tsx
|
|
6703
|
+
import { forwardRef as forwardRef12, memo as memo22, useCallback as useCallback12, useEffect as useEffect10, useImperativeHandle as useImperativeHandle2, useRef as useRef6, useState as useState10 } from "react";
|
|
6704
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6705
|
+
var animationDurationClose = 0.15;
|
|
6706
|
+
var animationDurationOpen = animationDurationClose * 2;
|
|
6707
|
+
var FoldableComponent = forwardRef12(function Foldable({
|
|
6708
|
+
isOpen: controlledIsOpen,
|
|
6709
|
+
defaultOpen = false,
|
|
6710
|
+
title,
|
|
6711
|
+
description,
|
|
6712
|
+
icon,
|
|
6713
|
+
image,
|
|
6714
|
+
headerPaddingInline,
|
|
6715
|
+
renderHeader,
|
|
6716
|
+
onOpenChange,
|
|
6717
|
+
children,
|
|
6718
|
+
...props
|
|
6719
|
+
}, ref) {
|
|
6720
|
+
const theme2 = useTheme();
|
|
6721
|
+
const bodyRef = useRef6(null);
|
|
6722
|
+
const [internalIsOpen, setInternalIsOpen] = useBooleanState(defaultOpen);
|
|
6723
|
+
const [bodyVirtualHeight, setBodyVirtualHeight] = useState10(500);
|
|
6724
|
+
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
6725
|
+
const open = useCallback12(() => {
|
|
6726
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.setTrue();
|
|
6727
|
+
onOpenChange?.(true);
|
|
6728
|
+
}, [controlledIsOpen, onOpenChange]);
|
|
6729
|
+
const close = useCallback12(() => {
|
|
6730
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.setFalse();
|
|
6731
|
+
onOpenChange?.(false);
|
|
6732
|
+
}, [controlledIsOpen, onOpenChange]);
|
|
6733
|
+
const toggleOpen = useCallback12(() => {
|
|
6734
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.toggle();
|
|
6735
|
+
onOpenChange?.(!isOpen);
|
|
6736
|
+
}, [controlledIsOpen, isOpen, onOpenChange]);
|
|
6737
|
+
useEffect10(() => {
|
|
6738
|
+
if (!bodyRef.current) return;
|
|
6739
|
+
setBodyVirtualHeight(Math.min(500, bodyRef.current.scrollHeight * 2));
|
|
6740
|
+
}, [isOpen]);
|
|
6741
|
+
useImperativeHandle2(
|
|
6742
|
+
ref,
|
|
6743
|
+
() => {
|
|
6744
|
+
return {
|
|
6745
|
+
open,
|
|
6746
|
+
close,
|
|
6747
|
+
toggle: toggleOpen,
|
|
6748
|
+
isOpen
|
|
6749
|
+
};
|
|
6750
|
+
},
|
|
6751
|
+
[open, close, toggleOpen, isOpen]
|
|
6752
|
+
);
|
|
6753
|
+
return /* @__PURE__ */ jsxs17(Div_default.column, { width: "100%", ...props, children: [
|
|
6754
|
+
renderHeader ? renderHeader(isOpen, toggleOpen) : /* @__PURE__ */ jsxs17(
|
|
6755
|
+
Div_default.row,
|
|
6756
|
+
{
|
|
6757
|
+
width: "100%",
|
|
6758
|
+
alignItems: "center",
|
|
6759
|
+
gap: theme2.styles.gap,
|
|
6760
|
+
paddingBlock: theme2.styles.gap,
|
|
6761
|
+
paddingInline: headerPaddingInline,
|
|
6762
|
+
cursor: "pointer",
|
|
6763
|
+
onClick: toggleOpen,
|
|
6764
|
+
userSelect: "none",
|
|
6765
|
+
children: [
|
|
6766
|
+
/* @__PURE__ */ jsxs17(Div_default.row, { flex: 1, alignItems: "center", gap: theme2.styles.space, children: [
|
|
6767
|
+
icon && /* @__PURE__ */ jsx22(Icon_default, { name: icon, size: 20, flexShrink: 0 }),
|
|
6768
|
+
image && /* @__PURE__ */ jsx22(Image_default.profileImage, { name: image, size: 24, flexShrink: 0 }),
|
|
6769
|
+
/* @__PURE__ */ jsxs17(Div_default.column, { gap: theme2.styles.gap / 2, children: [
|
|
6770
|
+
title && /* @__PURE__ */ jsx22(Text_default, { as: "h3", fontWeight: 700, children: title }),
|
|
6771
|
+
description && /* @__PURE__ */ jsx22(Text_default, { color: theme2.colors.textSecondary, children: description })
|
|
6772
|
+
] })
|
|
6773
|
+
] }),
|
|
6774
|
+
/* @__PURE__ */ jsx22(
|
|
6775
|
+
Icon_default,
|
|
6776
|
+
{
|
|
6777
|
+
name: "chevronDown",
|
|
6778
|
+
transform: `rotate(${isOpen ? 180 : 0}deg)`,
|
|
6779
|
+
transition: theme2.styles.transition
|
|
6780
|
+
}
|
|
6781
|
+
)
|
|
6782
|
+
]
|
|
6783
|
+
}
|
|
6784
|
+
),
|
|
6785
|
+
/* @__PURE__ */ jsx22(Div_default, { height: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0, transition: theme2.styles.transition, children: /* @__PURE__ */ jsx22(Divider_default.horizontal, {}) }),
|
|
6786
|
+
/* @__PURE__ */ jsx22(
|
|
6787
|
+
Div_default,
|
|
6788
|
+
{
|
|
6789
|
+
maxHeight: isOpen ? bodyVirtualHeight : 0,
|
|
6790
|
+
opacity: !isOpen ? 0 : void 0,
|
|
6791
|
+
transition: `max-height ${isOpen ? animationDurationOpen : animationDurationClose}s ease, opacity ${theme2.styles.transition}`,
|
|
6792
|
+
overflow: !isOpen ? "hidden" : void 0,
|
|
6793
|
+
pointerEvents: !isOpen ? "none" : void 0,
|
|
6794
|
+
ref: bodyRef,
|
|
6795
|
+
children: /* @__PURE__ */ jsx22(Div_default, { paddingBlock: theme2.styles.gap, paddingInline: headerPaddingInline, children })
|
|
6796
|
+
}
|
|
6797
|
+
)
|
|
6798
|
+
] });
|
|
6799
|
+
});
|
|
6800
|
+
FoldableComponent.box = forwardRef12(function Box3({ ...props }, ref) {
|
|
6801
|
+
const theme2 = useTheme();
|
|
6802
|
+
return /* @__PURE__ */ jsx22(
|
|
6803
|
+
FoldableComponent,
|
|
6804
|
+
{
|
|
6805
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
6806
|
+
border: `1px solid ${theme2.colors.border}`,
|
|
6807
|
+
borderRadius: theme2.styles.borderRadius,
|
|
6808
|
+
headerPaddingInline: theme2.styles.space,
|
|
6809
|
+
...props,
|
|
6810
|
+
ref
|
|
6811
|
+
}
|
|
6812
|
+
);
|
|
6813
|
+
});
|
|
6814
|
+
var Foldable2 = memo22(FoldableComponent);
|
|
6815
|
+
Foldable2.box = FoldableComponent.box;
|
|
6816
|
+
var Foldable_default = Foldable2;
|
|
6817
|
+
|
|
6501
6818
|
// src/utils/variableFunctions.ts
|
|
6502
6819
|
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
6503
6820
|
if (value === void 0) {
|
|
@@ -6544,6 +6861,7 @@ export {
|
|
|
6544
6861
|
Div_default as Div,
|
|
6545
6862
|
Divider_default as Divider,
|
|
6546
6863
|
Dropdown_default as Dropdown,
|
|
6864
|
+
Foldable_default as Foldable,
|
|
6547
6865
|
Form_default as Form,
|
|
6548
6866
|
FormRow_default as FormRow,
|
|
6549
6867
|
Icon_default as Icon,
|
|
@@ -6555,6 +6873,7 @@ export {
|
|
|
6555
6873
|
PageHeader_default as PageHeader,
|
|
6556
6874
|
PageHolder_default as PageHolder,
|
|
6557
6875
|
Table_default as Table,
|
|
6876
|
+
Tabs_default as Tabs,
|
|
6558
6877
|
Text_default as Text,
|
|
6559
6878
|
ToggleInput_default as ToggleInput,
|
|
6560
6879
|
formatPhoneNumber,
|