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.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
Div: () => Div_default,
|
|
38
38
|
Divider: () => Divider_default,
|
|
39
39
|
Dropdown: () => Dropdown_default,
|
|
40
|
+
Foldable: () => Foldable_default,
|
|
40
41
|
Form: () => Form_default,
|
|
41
42
|
FormRow: () => FormRow_default,
|
|
42
43
|
Icon: () => Icon_default,
|
|
@@ -48,6 +49,7 @@ __export(index_exports, {
|
|
|
48
49
|
PageHeader: () => PageHeader_default,
|
|
49
50
|
PageHolder: () => PageHolder_default,
|
|
50
51
|
Table: () => Table_default,
|
|
52
|
+
Tabs: () => Tabs_default,
|
|
51
53
|
Text: () => Text_default,
|
|
52
54
|
ToggleInput: () => ToggleInput_default,
|
|
53
55
|
formatPhoneNumber: () => formatPhoneNumber,
|
|
@@ -1544,6 +1546,10 @@ var appConfig = {
|
|
|
1544
1546
|
// src/components/BetterHtmlProvider.tsx
|
|
1545
1547
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1546
1548
|
var GlobalStyle = import_styled_components.createGlobalStyle`
|
|
1549
|
+
html {
|
|
1550
|
+
background-color: ${(props) => props.backgroundColor};
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1547
1553
|
body {
|
|
1548
1554
|
font-family: ${(props) => props.fontFamily};
|
|
1549
1555
|
color: ${(props) => props.color};
|
|
@@ -1574,9 +1580,17 @@ var useBetterHtmlContext = () => {
|
|
|
1574
1580
|
throw new Error(
|
|
1575
1581
|
"`useBetterHtmlContext()` must be used within a `<BetterHtmlProvider>`. Make sure to add one at the root of your component tree."
|
|
1576
1582
|
);
|
|
1577
|
-
const { setLoaders, plugins, ...rest } = context;
|
|
1583
|
+
const { setLoaders, plugins, componentsState, ...rest } = context;
|
|
1578
1584
|
return rest;
|
|
1579
1585
|
};
|
|
1586
|
+
var useBetterHtmlContextInternal = () => {
|
|
1587
|
+
const context = (0, import_react.useContext)(betterHtmlContext);
|
|
1588
|
+
if (context === void 0)
|
|
1589
|
+
throw new Error(
|
|
1590
|
+
"`useBetterHtmlContextInternal()` must be used within a `<BetterHtmlProvider>`. Make sure to add one at the root of your component tree."
|
|
1591
|
+
);
|
|
1592
|
+
return context;
|
|
1593
|
+
};
|
|
1580
1594
|
var useTheme = () => {
|
|
1581
1595
|
const context = (0, import_react.useContext)(betterHtmlContext);
|
|
1582
1596
|
if (context === void 0)
|
|
@@ -1643,11 +1657,13 @@ function BetterHtmlProviderContent({ children }) {
|
|
|
1643
1657
|
] });
|
|
1644
1658
|
}
|
|
1645
1659
|
function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
|
|
1646
|
-
const [loaders, setLoaders] = (0, import_react.useState)(value?.loaders ?? {});
|
|
1647
|
-
const [plugins] = (0, import_react.useState)(pluginsToUse ?? []);
|
|
1648
1660
|
const [colorTheme, setColorTheme] = (0, import_react.useState)(
|
|
1649
1661
|
localStorage.getItem("theme") === "dark" ? "dark" : value?.colorTheme ?? "light"
|
|
1650
1662
|
);
|
|
1663
|
+
const [loaders, setLoaders] = (0, import_react.useState)(value?.loaders ?? {});
|
|
1664
|
+
const [plugins] = (0, import_react.useState)(pluginsToUse ?? []);
|
|
1665
|
+
const [tabGroups, setTabGroups] = (0, import_react.useState)([]);
|
|
1666
|
+
const [tabsWithDots, setTabsWithDots] = (0, import_react.useState)([]);
|
|
1651
1667
|
const readyValue = (0, import_react.useMemo)(
|
|
1652
1668
|
() => ({
|
|
1653
1669
|
app: {
|
|
@@ -1684,9 +1700,17 @@ function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
|
|
|
1684
1700
|
components: {
|
|
1685
1701
|
...value?.components
|
|
1686
1702
|
},
|
|
1687
|
-
plugins
|
|
1703
|
+
plugins,
|
|
1704
|
+
componentsState: {
|
|
1705
|
+
tabs: {
|
|
1706
|
+
tabGroups,
|
|
1707
|
+
setTabGroups,
|
|
1708
|
+
tabsWithDots,
|
|
1709
|
+
setTabsWithDots
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1688
1712
|
}),
|
|
1689
|
-
[value, colorTheme, loaders, plugins]
|
|
1713
|
+
[value, colorTheme, loaders, plugins, tabGroups, tabsWithDots]
|
|
1690
1714
|
);
|
|
1691
1715
|
(0, import_react.useEffect)(() => {
|
|
1692
1716
|
plugins.forEach((plugin) => {
|
|
@@ -2387,7 +2411,7 @@ var IconElement = import_styled_components5.default.svg.withConfig({
|
|
|
2387
2411
|
`;
|
|
2388
2412
|
var Icon = (0, import_react6.forwardRef)(function Icon2({ name, size = 16, ...props }, ref) {
|
|
2389
2413
|
const theme2 = useTheme();
|
|
2390
|
-
const { icons: icons2 } =
|
|
2414
|
+
const { icons: icons2 } = useBetterHtmlContextInternal();
|
|
2391
2415
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
2392
2416
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2393
2417
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
@@ -2446,7 +2470,7 @@ var ImageElement = import_styled_components6.default.img.withConfig({
|
|
|
2446
2470
|
`;
|
|
2447
2471
|
var Image = (0, import_react8.forwardRef)(function Image2({ name, src, ...props }, ref) {
|
|
2448
2472
|
const theme2 = useTheme();
|
|
2449
|
-
const { assets: assets2 } =
|
|
2473
|
+
const { assets: assets2 } = useBetterHtmlContextInternal();
|
|
2450
2474
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
2451
2475
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
2452
2476
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
@@ -2483,7 +2507,7 @@ var import_react9 = require("react");
|
|
|
2483
2507
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
2484
2508
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2485
2509
|
var ButtonElement = import_styled_components7.default.button.withConfig({
|
|
2486
|
-
shouldForwardProp: (prop) => !["theme", "normalStyle", "hoverStyle", "isSmall", "withText", "isLoading"].includes(prop)
|
|
2510
|
+
shouldForwardProp: (prop) => !["theme", "colorTheme", "normalStyle", "hoverStyle", "isSmall", "withText", "isLoading"].includes(prop)
|
|
2487
2511
|
})`
|
|
2488
2512
|
display: block;
|
|
2489
2513
|
position: relative;
|
|
@@ -2505,15 +2529,11 @@ var ButtonElement = import_styled_components7.default.button.withConfig({
|
|
|
2505
2529
|
${(props) => props.disabled ? import_styled_components7.css`
|
|
2506
2530
|
opacity: 0.6;
|
|
2507
2531
|
cursor: not-allowed;
|
|
2508
|
-
|
|
2509
|
-
&.secondary:disabled {
|
|
2510
|
-
filter: brightness(0.9);
|
|
2511
|
-
}
|
|
2512
2532
|
` : !props.isLoading ? import_styled_components7.css`
|
|
2513
2533
|
cursor: pointer;
|
|
2514
2534
|
|
|
2515
2535
|
&:not(.secondary):hover {
|
|
2516
|
-
filter: brightness(0.9);
|
|
2536
|
+
filter: ${props.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.9)"};
|
|
2517
2537
|
}
|
|
2518
2538
|
|
|
2519
2539
|
&.secondary:hover {
|
|
@@ -2562,7 +2582,7 @@ var ButtonComponent = function Button({
|
|
|
2562
2582
|
}) {
|
|
2563
2583
|
const theme2 = useTheme();
|
|
2564
2584
|
const isLoadingHook = useLoader(loaderName);
|
|
2565
|
-
const betterHtmlContext2 =
|
|
2585
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2566
2586
|
const isLoadingElement = isLoading ?? isLoadingHook;
|
|
2567
2587
|
const styledComponentStyles = useStyledComponentStyles(
|
|
2568
2588
|
{
|
|
@@ -2603,6 +2623,7 @@ var ButtonComponent = function Button({
|
|
|
2603
2623
|
{
|
|
2604
2624
|
as: href ? "a" : "button",
|
|
2605
2625
|
theme: theme2,
|
|
2626
|
+
colorTheme: betterHtmlContext2.colorTheme,
|
|
2606
2627
|
isSmall,
|
|
2607
2628
|
withText: text !== void 0,
|
|
2608
2629
|
isLoading: isLoadingElement,
|
|
@@ -2664,7 +2685,7 @@ var ButtonComponent = function Button({
|
|
|
2664
2685
|
};
|
|
2665
2686
|
ButtonComponent.secondary = function Secondary({ className, ...props }) {
|
|
2666
2687
|
const theme2 = useTheme();
|
|
2667
|
-
const betterHtmlContext2 =
|
|
2688
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2668
2689
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2669
2690
|
ButtonComponent,
|
|
2670
2691
|
{
|
|
@@ -2677,7 +2698,7 @@ ButtonComponent.secondary = function Secondary({ className, ...props }) {
|
|
|
2677
2698
|
};
|
|
2678
2699
|
ButtonComponent.destructive = function Destructive(props) {
|
|
2679
2700
|
const theme2 = useTheme();
|
|
2680
|
-
const betterHtmlContext2 =
|
|
2701
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2681
2702
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2682
2703
|
ButtonComponent,
|
|
2683
2704
|
{
|
|
@@ -2690,7 +2711,7 @@ ButtonComponent.destructive = function Destructive(props) {
|
|
|
2690
2711
|
};
|
|
2691
2712
|
ButtonComponent.icon = function Icon3({ size = 16, backgroundButtonColor, ...props }) {
|
|
2692
2713
|
const theme2 = useTheme();
|
|
2693
|
-
const betterHtmlContext2 =
|
|
2714
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2694
2715
|
const buttonSize = size + theme2.styles.space;
|
|
2695
2716
|
const backgroundButtonColorReady = backgroundButtonColor ?? theme2.colors.textPrimary;
|
|
2696
2717
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -2714,7 +2735,7 @@ ButtonComponent.icon = function Icon3({ size = 16, backgroundButtonColor, ...pro
|
|
|
2714
2735
|
);
|
|
2715
2736
|
};
|
|
2716
2737
|
ButtonComponent.upload = function Upload({ accept, multiple, onUpload, ...props }) {
|
|
2717
|
-
const betterHtmlContext2 =
|
|
2738
|
+
const betterHtmlContext2 = useBetterHtmlContextInternal();
|
|
2718
2739
|
const onClickElement = (0, import_react9.useCallback)(() => {
|
|
2719
2740
|
const input = document.createElement("input");
|
|
2720
2741
|
input.setAttribute("type", "file");
|
|
@@ -2836,7 +2857,7 @@ var ModalComponent = (0, import_react11.forwardRef)(function Modal({
|
|
|
2836
2857
|
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
2837
2858
|
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
2838
2859
|
const theme2 = useTheme();
|
|
2839
|
-
const { app, colorTheme } =
|
|
2860
|
+
const { app, colorTheme } = useBetterHtmlContextInternal();
|
|
2840
2861
|
const dialogRef = (0, import_react11.useRef)(null);
|
|
2841
2862
|
const [isOpened, setIsOpened] = (0, import_react11.useState)(false);
|
|
2842
2863
|
const [isOpenedLate, setIsOpenedLate] = (0, import_react11.useState)(false);
|
|
@@ -2844,13 +2865,14 @@ var ModalComponent = (0, import_react11.forwardRef)(function Modal({
|
|
|
2844
2865
|
dialogRef.current?.showModal();
|
|
2845
2866
|
setIsOpened(true);
|
|
2846
2867
|
setIsOpenedLate(true);
|
|
2847
|
-
if (urlQuery && name)
|
|
2868
|
+
if (urlQuery && name) {
|
|
2848
2869
|
urlQuery.setQuery(
|
|
2849
2870
|
{
|
|
2850
2871
|
[`${name}-modal`]: "opened"
|
|
2851
2872
|
},
|
|
2852
2873
|
false
|
|
2853
2874
|
);
|
|
2875
|
+
}
|
|
2854
2876
|
onOpen?.();
|
|
2855
2877
|
}, [onOpen, urlQuery, name]);
|
|
2856
2878
|
const onClickClose = (0, import_react11.useCallback)(() => {
|
|
@@ -3046,7 +3068,7 @@ var import_react12 = require("react");
|
|
|
3046
3068
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3047
3069
|
function PageHolder({ noMaxContentWidth, children }) {
|
|
3048
3070
|
const theme2 = useTheme();
|
|
3049
|
-
const { app } =
|
|
3071
|
+
const { app } = useBetterHtmlContextInternal();
|
|
3050
3072
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3051
3073
|
Div_default,
|
|
3052
3074
|
{
|
|
@@ -3077,7 +3099,7 @@ function PageHeader({
|
|
|
3077
3099
|
marginBottom
|
|
3078
3100
|
}) {
|
|
3079
3101
|
const theme2 = useTheme();
|
|
3080
|
-
const { app } =
|
|
3102
|
+
const { app } = useBetterHtmlContextInternal();
|
|
3081
3103
|
const mediaQuery = useMediaQuery();
|
|
3082
3104
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Div_default.row, { alignItems: "center", gap: theme2.styles.space, marginBottom: marginBottom ?? theme2.styles.space * 2, children: [
|
|
3083
3105
|
imageUrl && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Image_default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }),
|
|
@@ -4881,7 +4903,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
4881
4903
|
const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
|
|
4882
4904
|
const withClearButton = isOpen && selectedOption;
|
|
4883
4905
|
const readyPlaceholder = placeholder ? placeholder : `Select an ${label?.toLowerCase() ?? "option"}`;
|
|
4884
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Div_default.row, { position: "relative", width: "100%", children: [
|
|
4906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Div_default.row, { position: "relative", width: "100%", ref: inputFieldHolderRef, children: [
|
|
4885
4907
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4886
4908
|
InputField_default,
|
|
4887
4909
|
{
|
|
@@ -4901,7 +4923,6 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
4901
4923
|
onFocus: setIsFocused.setTrue,
|
|
4902
4924
|
onBlur: setIsFocused.setFalse,
|
|
4903
4925
|
onKeyDown: onKeyDownInputField,
|
|
4904
|
-
holderRef: inputFieldHolderRef,
|
|
4905
4926
|
onChangeValue: withSearch ? onChangeValue : void 0,
|
|
4906
4927
|
insideInputFieldComponent: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4907
4928
|
Div_default,
|
|
@@ -5976,6 +5997,8 @@ var InputElement2 = import_styled_components10.default.input.withConfig({
|
|
|
5976
5997
|
${(props) => props.normalStyle}
|
|
5977
5998
|
|
|
5978
5999
|
&:hover {
|
|
6000
|
+
border-color: ${(props) => props.theme.colors.primary};
|
|
6001
|
+
|
|
5979
6002
|
${(props) => props.hoverStyle}
|
|
5980
6003
|
}
|
|
5981
6004
|
`;
|
|
@@ -6461,7 +6484,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
6461
6484
|
onClickAllCheckboxes,
|
|
6462
6485
|
...props
|
|
6463
6486
|
}, ref) {
|
|
6464
|
-
const { colorTheme } =
|
|
6487
|
+
const { colorTheme } = useBetterHtmlContextInternal();
|
|
6465
6488
|
const theme2 = useTheme();
|
|
6466
6489
|
const [checkedItems, setCheckedItems] = (0, import_react23.useState)([]);
|
|
6467
6490
|
const renderCellContent = (0, import_react23.useCallback)(
|
|
@@ -6571,6 +6594,302 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
6571
6594
|
var Table2 = (0, import_react23.memo)(TableComponent);
|
|
6572
6595
|
var Table_default = Table2;
|
|
6573
6596
|
|
|
6597
|
+
// src/components/Tabs.tsx
|
|
6598
|
+
var import_react24 = require("react");
|
|
6599
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
6600
|
+
var tabBottomLineWidth = 2;
|
|
6601
|
+
var tabDotSize = 6;
|
|
6602
|
+
var defaultTabName = "tab";
|
|
6603
|
+
var TabsComponent = function Tabs({
|
|
6604
|
+
tabs,
|
|
6605
|
+
name,
|
|
6606
|
+
accentColor,
|
|
6607
|
+
style = "default",
|
|
6608
|
+
children,
|
|
6609
|
+
...props
|
|
6610
|
+
}) {
|
|
6611
|
+
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
6612
|
+
const theme2 = useTheme();
|
|
6613
|
+
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
6614
|
+
const { colorTheme, componentsState } = useBetterHtmlContextInternal();
|
|
6615
|
+
const firstRenderPassedRef = (0, import_react24.useRef)(false);
|
|
6616
|
+
const tabsRef = (0, import_react24.useRef)({});
|
|
6617
|
+
const [selectedTab, setSelectedTab] = (0, import_react24.useState)(() => {
|
|
6618
|
+
const selectedTabValue = tabs[0] ?? "";
|
|
6619
|
+
if (urlQuery) {
|
|
6620
|
+
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
6621
|
+
if (!tabQueryValue) return selectedTabValue;
|
|
6622
|
+
if (tabs.includes(tabQueryValue)) return tabQueryValue;
|
|
6623
|
+
}
|
|
6624
|
+
return selectedTabValue;
|
|
6625
|
+
});
|
|
6626
|
+
const [rerenderState, setRerenderState] = (0, import_react24.useState)(0);
|
|
6627
|
+
const tabsGap = style === "box" ? theme2.styles.gap / 2 : 0;
|
|
6628
|
+
const onClickTab = (0, import_react24.useCallback)(
|
|
6629
|
+
(tab) => {
|
|
6630
|
+
setSelectedTab(tab);
|
|
6631
|
+
if (urlQuery) {
|
|
6632
|
+
urlQuery.setQuery({
|
|
6633
|
+
[name ?? defaultTabName]: tab
|
|
6634
|
+
});
|
|
6635
|
+
}
|
|
6636
|
+
},
|
|
6637
|
+
[name, urlQuery]
|
|
6638
|
+
);
|
|
6639
|
+
const width = (0, import_react24.useMemo)(
|
|
6640
|
+
() => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
|
|
6641
|
+
[rerenderState, selectedTab]
|
|
6642
|
+
);
|
|
6643
|
+
const leftSpacing = (0, import_react24.useMemo)(() => {
|
|
6644
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab === selectedTab);
|
|
6645
|
+
let spacing = 0;
|
|
6646
|
+
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
6647
|
+
if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
6648
|
+
});
|
|
6649
|
+
return spacing;
|
|
6650
|
+
}, [selectedTab, tabs, tabsGap]);
|
|
6651
|
+
(0, import_react24.useEffect)(() => {
|
|
6652
|
+
const timeout = setTimeout(() => {
|
|
6653
|
+
setRerenderState(Math.random());
|
|
6654
|
+
firstRenderPassedRef.current = true;
|
|
6655
|
+
}, 0.01 * 1e3);
|
|
6656
|
+
return () => {
|
|
6657
|
+
clearTimeout(timeout);
|
|
6658
|
+
};
|
|
6659
|
+
}, []);
|
|
6660
|
+
(0, import_react24.useEffect)(() => {
|
|
6661
|
+
componentsState.tabs.setTabGroups((oldValue) => {
|
|
6662
|
+
const thisTabGroup = oldValue.find((item) => item.name === (name ?? defaultTabName));
|
|
6663
|
+
if (thisTabGroup) {
|
|
6664
|
+
return oldValue.map(
|
|
6665
|
+
(item) => item.name === (name ?? defaultTabName) ? {
|
|
6666
|
+
...item,
|
|
6667
|
+
selectedTab
|
|
6668
|
+
} : item
|
|
6669
|
+
);
|
|
6670
|
+
} else {
|
|
6671
|
+
return [
|
|
6672
|
+
...oldValue,
|
|
6673
|
+
{
|
|
6674
|
+
name: name ?? defaultTabName,
|
|
6675
|
+
selectedTab
|
|
6676
|
+
}
|
|
6677
|
+
];
|
|
6678
|
+
}
|
|
6679
|
+
});
|
|
6680
|
+
}, [selectedTab, name]);
|
|
6681
|
+
(0, import_react24.useEffect)(() => {
|
|
6682
|
+
tabsRef.current[selectedTab]?.scrollIntoView({
|
|
6683
|
+
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
6684
|
+
block: "nearest"
|
|
6685
|
+
});
|
|
6686
|
+
}, [selectedTab]);
|
|
6687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
6688
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
6689
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
6690
|
+
const selected = tab === selectedTab;
|
|
6691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
6692
|
+
Div_default,
|
|
6693
|
+
{
|
|
6694
|
+
position: "relative",
|
|
6695
|
+
width: "fit-content",
|
|
6696
|
+
backgroundColor: style === "box" ? selected ? theme2.colors.primary : theme2.colors.backgroundContent : theme2.colors.backgroundBase,
|
|
6697
|
+
borderRadius: style === "box" ? theme2.styles.borderRadius : void 0,
|
|
6698
|
+
borderTopLeftRadius: style === "borderRadiusTop" ? theme2.styles.borderRadius : void 0,
|
|
6699
|
+
borderTopRightRadius: style === "borderRadiusTop" ? theme2.styles.borderRadius : void 0,
|
|
6700
|
+
border: style === "box" ? `1px solid ${selected ? "transparent" : theme2.colors.border}` : void 0,
|
|
6701
|
+
filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
|
|
6702
|
+
paddingInline: theme2.styles.space,
|
|
6703
|
+
paddingBlock: theme2.styles.gap,
|
|
6704
|
+
value: tab,
|
|
6705
|
+
cursor: "pointer",
|
|
6706
|
+
isTabAccessed: true,
|
|
6707
|
+
onClickWithValue: onClickTab,
|
|
6708
|
+
ref: (ref) => {
|
|
6709
|
+
tabsRef.current[tab] = ref;
|
|
6710
|
+
},
|
|
6711
|
+
children: [
|
|
6712
|
+
componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
6713
|
+
Div_default,
|
|
6714
|
+
{
|
|
6715
|
+
position: "absolute",
|
|
6716
|
+
top: (theme2.styles.space - tabDotSize) / 2,
|
|
6717
|
+
right: (theme2.styles.space - tabDotSize) / 2,
|
|
6718
|
+
width: tabDotSize,
|
|
6719
|
+
height: tabDotSize,
|
|
6720
|
+
backgroundColor: style === "box" && selected ? theme2.colors.base : theme2.colors.primary,
|
|
6721
|
+
borderRadius: 999,
|
|
6722
|
+
transition: theme2.styles.transition
|
|
6723
|
+
}
|
|
6724
|
+
),
|
|
6725
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
6726
|
+
Text_default,
|
|
6727
|
+
{
|
|
6728
|
+
fontWeight: 700,
|
|
6729
|
+
color: !selected ? theme2.colors.textSecondary : style === "box" ? theme2.colors.base : void 0,
|
|
6730
|
+
transition: theme2.styles.transition,
|
|
6731
|
+
whiteSpace: "nowrap",
|
|
6732
|
+
children: tab
|
|
6733
|
+
}
|
|
6734
|
+
)
|
|
6735
|
+
]
|
|
6736
|
+
},
|
|
6737
|
+
tab
|
|
6738
|
+
);
|
|
6739
|
+
}) }),
|
|
6740
|
+
style !== "box" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
6741
|
+
Div_default,
|
|
6742
|
+
{
|
|
6743
|
+
position: "absolute",
|
|
6744
|
+
width,
|
|
6745
|
+
height: tabBottomLineWidth,
|
|
6746
|
+
bottom: 0,
|
|
6747
|
+
left: leftSpacing,
|
|
6748
|
+
backgroundColor: accentColor ?? theme2.colors.primary,
|
|
6749
|
+
transition: firstRenderPassedRef.current ? theme2.styles.transition : "none"
|
|
6750
|
+
}
|
|
6751
|
+
)
|
|
6752
|
+
] }),
|
|
6753
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default, { width: "100%", children })
|
|
6754
|
+
] });
|
|
6755
|
+
};
|
|
6756
|
+
TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, children }) {
|
|
6757
|
+
const { componentsState } = useBetterHtmlContextInternal();
|
|
6758
|
+
const thisTabGroupData = (0, import_react24.useMemo)(
|
|
6759
|
+
() => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
|
|
6760
|
+
[componentsState.tabs, tabsGroupName]
|
|
6761
|
+
);
|
|
6762
|
+
(0, import_react24.useEffect)(() => {
|
|
6763
|
+
if (tabWithDot) {
|
|
6764
|
+
componentsState.tabs.setTabsWithDots?.((oldValue) => oldValue.includes(tab) ? oldValue : [...oldValue, tab]);
|
|
6765
|
+
} else {
|
|
6766
|
+
componentsState.tabs.setTabsWithDots?.(
|
|
6767
|
+
(oldValue) => oldValue.includes(tab) ? oldValue.filter((tab2) => tab2 !== tab2) : oldValue
|
|
6768
|
+
);
|
|
6769
|
+
}
|
|
6770
|
+
}, [tabWithDot]);
|
|
6771
|
+
return thisTabGroupData?.selectedTab === tab ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default, { width: "100%", children }) : void 0;
|
|
6772
|
+
};
|
|
6773
|
+
var Tabs2 = (0, import_react24.memo)(TabsComponent);
|
|
6774
|
+
Tabs2.content = TabsComponent.content;
|
|
6775
|
+
var Tabs_default = Tabs2;
|
|
6776
|
+
|
|
6777
|
+
// src/components/Foldable.tsx
|
|
6778
|
+
var import_react25 = require("react");
|
|
6779
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6780
|
+
var animationDurationClose = 0.15;
|
|
6781
|
+
var animationDurationOpen = animationDurationClose * 2;
|
|
6782
|
+
var FoldableComponent = (0, import_react25.forwardRef)(function Foldable({
|
|
6783
|
+
isOpen: controlledIsOpen,
|
|
6784
|
+
defaultOpen = false,
|
|
6785
|
+
title,
|
|
6786
|
+
description,
|
|
6787
|
+
icon,
|
|
6788
|
+
image,
|
|
6789
|
+
headerPaddingInline,
|
|
6790
|
+
renderHeader,
|
|
6791
|
+
onOpenChange,
|
|
6792
|
+
children,
|
|
6793
|
+
...props
|
|
6794
|
+
}, ref) {
|
|
6795
|
+
const theme2 = useTheme();
|
|
6796
|
+
const bodyRef = (0, import_react25.useRef)(null);
|
|
6797
|
+
const [internalIsOpen, setInternalIsOpen] = useBooleanState(defaultOpen);
|
|
6798
|
+
const [bodyVirtualHeight, setBodyVirtualHeight] = (0, import_react25.useState)(500);
|
|
6799
|
+
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
6800
|
+
const open = (0, import_react25.useCallback)(() => {
|
|
6801
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.setTrue();
|
|
6802
|
+
onOpenChange?.(true);
|
|
6803
|
+
}, [controlledIsOpen, onOpenChange]);
|
|
6804
|
+
const close = (0, import_react25.useCallback)(() => {
|
|
6805
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.setFalse();
|
|
6806
|
+
onOpenChange?.(false);
|
|
6807
|
+
}, [controlledIsOpen, onOpenChange]);
|
|
6808
|
+
const toggleOpen = (0, import_react25.useCallback)(() => {
|
|
6809
|
+
if (controlledIsOpen === void 0) setInternalIsOpen.toggle();
|
|
6810
|
+
onOpenChange?.(!isOpen);
|
|
6811
|
+
}, [controlledIsOpen, isOpen, onOpenChange]);
|
|
6812
|
+
(0, import_react25.useEffect)(() => {
|
|
6813
|
+
if (!bodyRef.current) return;
|
|
6814
|
+
setBodyVirtualHeight(Math.min(500, bodyRef.current.scrollHeight * 2));
|
|
6815
|
+
}, [isOpen]);
|
|
6816
|
+
(0, import_react25.useImperativeHandle)(
|
|
6817
|
+
ref,
|
|
6818
|
+
() => {
|
|
6819
|
+
return {
|
|
6820
|
+
open,
|
|
6821
|
+
close,
|
|
6822
|
+
toggle: toggleOpen,
|
|
6823
|
+
isOpen
|
|
6824
|
+
};
|
|
6825
|
+
},
|
|
6826
|
+
[open, close, toggleOpen, isOpen]
|
|
6827
|
+
);
|
|
6828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Div_default.column, { width: "100%", ...props, children: [
|
|
6829
|
+
renderHeader ? renderHeader(isOpen, toggleOpen) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
6830
|
+
Div_default.row,
|
|
6831
|
+
{
|
|
6832
|
+
width: "100%",
|
|
6833
|
+
alignItems: "center",
|
|
6834
|
+
gap: theme2.styles.gap,
|
|
6835
|
+
paddingBlock: theme2.styles.gap,
|
|
6836
|
+
paddingInline: headerPaddingInline,
|
|
6837
|
+
cursor: "pointer",
|
|
6838
|
+
onClick: toggleOpen,
|
|
6839
|
+
userSelect: "none",
|
|
6840
|
+
children: [
|
|
6841
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Div_default.row, { flex: 1, alignItems: "center", gap: theme2.styles.space, children: [
|
|
6842
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Icon_default, { name: icon, size: 20, flexShrink: 0 }),
|
|
6843
|
+
image && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Image_default.profileImage, { name: image, size: 24, flexShrink: 0 }),
|
|
6844
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Div_default.column, { gap: theme2.styles.gap / 2, children: [
|
|
6845
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default, { as: "h3", fontWeight: 700, children: title }),
|
|
6846
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default, { color: theme2.colors.textSecondary, children: description })
|
|
6847
|
+
] })
|
|
6848
|
+
] }),
|
|
6849
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6850
|
+
Icon_default,
|
|
6851
|
+
{
|
|
6852
|
+
name: "chevronDown",
|
|
6853
|
+
transform: `rotate(${isOpen ? 180 : 0}deg)`,
|
|
6854
|
+
transition: theme2.styles.transition
|
|
6855
|
+
}
|
|
6856
|
+
)
|
|
6857
|
+
]
|
|
6858
|
+
}
|
|
6859
|
+
),
|
|
6860
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Div_default, { height: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0, transition: theme2.styles.transition, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Divider_default.horizontal, {}) }),
|
|
6861
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6862
|
+
Div_default,
|
|
6863
|
+
{
|
|
6864
|
+
maxHeight: isOpen ? bodyVirtualHeight : 0,
|
|
6865
|
+
opacity: !isOpen ? 0 : void 0,
|
|
6866
|
+
transition: `max-height ${isOpen ? animationDurationOpen : animationDurationClose}s ease, opacity ${theme2.styles.transition}`,
|
|
6867
|
+
overflow: !isOpen ? "hidden" : void 0,
|
|
6868
|
+
pointerEvents: !isOpen ? "none" : void 0,
|
|
6869
|
+
ref: bodyRef,
|
|
6870
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Div_default, { paddingBlock: theme2.styles.gap, paddingInline: headerPaddingInline, children })
|
|
6871
|
+
}
|
|
6872
|
+
)
|
|
6873
|
+
] });
|
|
6874
|
+
});
|
|
6875
|
+
FoldableComponent.box = (0, import_react25.forwardRef)(function Box3({ ...props }, ref) {
|
|
6876
|
+
const theme2 = useTheme();
|
|
6877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6878
|
+
FoldableComponent,
|
|
6879
|
+
{
|
|
6880
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
6881
|
+
border: `1px solid ${theme2.colors.border}`,
|
|
6882
|
+
borderRadius: theme2.styles.borderRadius,
|
|
6883
|
+
headerPaddingInline: theme2.styles.space,
|
|
6884
|
+
...props,
|
|
6885
|
+
ref
|
|
6886
|
+
}
|
|
6887
|
+
);
|
|
6888
|
+
});
|
|
6889
|
+
var Foldable2 = (0, import_react25.memo)(FoldableComponent);
|
|
6890
|
+
Foldable2.box = FoldableComponent.box;
|
|
6891
|
+
var Foldable_default = Foldable2;
|
|
6892
|
+
|
|
6574
6893
|
// src/utils/variableFunctions.ts
|
|
6575
6894
|
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
6576
6895
|
if (value === void 0) {
|
|
@@ -6618,6 +6937,7 @@ var reactRouterDomPlugin = {
|
|
|
6618
6937
|
Div,
|
|
6619
6938
|
Divider,
|
|
6620
6939
|
Dropdown,
|
|
6940
|
+
Foldable,
|
|
6621
6941
|
Form,
|
|
6622
6942
|
FormRow,
|
|
6623
6943
|
Icon,
|
|
@@ -6629,6 +6949,7 @@ var reactRouterDomPlugin = {
|
|
|
6629
6949
|
PageHeader,
|
|
6630
6950
|
PageHolder,
|
|
6631
6951
|
Table,
|
|
6952
|
+
Tabs,
|
|
6632
6953
|
Text,
|
|
6633
6954
|
ToggleInput,
|
|
6634
6955
|
formatPhoneNumber,
|