react-better-html 1.1.247 → 1.1.249
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 +18 -8
- package/dist/index.d.ts +18 -8
- package/dist/index.js +75 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -178,6 +178,9 @@ declare const Text: typeof TextComponent & {
|
|
|
178
178
|
|
|
179
179
|
type PageHeaderProps = {
|
|
180
180
|
icon?: IconName | AnyOtherString;
|
|
181
|
+
iconColor?: React.CSSProperties["color"];
|
|
182
|
+
/** @default 20 */
|
|
183
|
+
iconSize?: number;
|
|
181
184
|
image?: AssetName | AnyOtherString;
|
|
182
185
|
imageUrl?: string;
|
|
183
186
|
imageSize?: number;
|
|
@@ -497,21 +500,25 @@ type Alert = {
|
|
|
497
500
|
onClose?: (alert: Alert) => void;
|
|
498
501
|
};
|
|
499
502
|
|
|
503
|
+
type Tab = {
|
|
504
|
+
id: string;
|
|
505
|
+
label?: string;
|
|
506
|
+
};
|
|
500
507
|
type TabGroup = {
|
|
501
508
|
name: string;
|
|
502
|
-
selectedTab:
|
|
509
|
+
selectedTab: Tab["id"];
|
|
503
510
|
};
|
|
504
511
|
type TabsProps = {
|
|
505
|
-
tabs:
|
|
512
|
+
tabs: Tab[];
|
|
506
513
|
name?: string;
|
|
507
514
|
accentColor?: Color;
|
|
508
515
|
style?: "default" | "borderRadiusTop" | "box";
|
|
509
|
-
onChange?: (tab:
|
|
516
|
+
onChange?: (tab: Tab) => void;
|
|
510
517
|
children?: React.ReactNode;
|
|
511
518
|
} & ComponentMarginProps;
|
|
512
519
|
type TabsRef = {
|
|
513
|
-
selectedTab:
|
|
514
|
-
selectTab: (tab:
|
|
520
|
+
selectedTab: Tab["id"];
|
|
521
|
+
selectTab: (tab: Tab) => void;
|
|
515
522
|
};
|
|
516
523
|
type TabsComponent = {
|
|
517
524
|
(props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
|
|
@@ -519,7 +526,7 @@ type TabsComponent = {
|
|
|
519
526
|
};
|
|
520
527
|
declare const TabsComponent: TabsComponent;
|
|
521
528
|
type TabsContentProps = {
|
|
522
|
-
|
|
529
|
+
tabId: Tab["id"];
|
|
523
530
|
tabWithDot?: boolean;
|
|
524
531
|
tabsGroupName?: string;
|
|
525
532
|
isInitialTab?: boolean;
|
|
@@ -632,8 +639,11 @@ declare const filterHover: () => Record<"z05" | "z1" | "z2" | "z3", React.CSSPro
|
|
|
632
639
|
declare function generateLocalStorage<LocalStorage extends object>(): {
|
|
633
640
|
setItem: <StorageName extends keyof LocalStorage>(name: StorageName, value: LocalStorage[StorageName]) => void;
|
|
634
641
|
getItem: <StorageName extends keyof LocalStorage>(name: StorageName) => LocalStorage[StorageName] | undefined;
|
|
642
|
+
getAllItems: () => Partial<LocalStorage>;
|
|
635
643
|
removeItem: (name: keyof LocalStorage) => void;
|
|
636
|
-
removeAllItems: (
|
|
644
|
+
removeAllItems: (config?: {
|
|
645
|
+
keepValues?: (keyof LocalStorage)[];
|
|
646
|
+
}) => void;
|
|
637
647
|
};
|
|
638
648
|
|
|
639
649
|
type LoaderProps = {
|
|
@@ -1179,4 +1189,4 @@ type LocalStoragePluginOptions = {
|
|
|
1179
1189
|
declare const defaultLocalStoragePluginOptions: Required<LocalStoragePluginOptions>;
|
|
1180
1190
|
declare const localStoragePlugin: BetterHtmlPluginConstructor<LocalStoragePluginOptions>;
|
|
1181
1191
|
|
|
1182
|
-
export { type Alert, type AlertDisplay, type AlertDuration, type AlertType, type AlertsPluginOptions, type AppConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default$1 as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, type BurgerButtonProps, Button, type ButtonProps, Chip, type ChipProps, ColorThemeSwitch, type ColorThemeSwitchProps, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, Div, type DivProps, _default$4 as Divider, Dropdown, type DropdownOption, type DropdownProps, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default as Icon, type IconProps, _default$2 as Image, type ImageProps, InputField, type InputFieldProps, _default$3 as Label, type LabelProps, Loader, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type SideMenuProps, type TabGroup, Table, type TableColumn, type TableFilterData, type TableListFilterListItem, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, _default$5 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, filterHover, generateLocalStorage, getBrowser, getFormErrorObject, isMobileDevice, localStoragePlugin, reactRouterDomPlugin, sideMenuControls, useAlertControls, useBetterHtmlContext, useForm, useMediaQuery, usePageResize, usePageScroll, useUrlQuery };
|
|
1192
|
+
export { type Alert, type AlertDisplay, type AlertDuration, type AlertType, type AlertsPluginOptions, type AppConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default$1 as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, type BurgerButtonProps, Button, type ButtonProps, Chip, type ChipProps, ColorThemeSwitch, type ColorThemeSwitchProps, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, Div, type DivProps, _default$4 as Divider, Dropdown, type DropdownOption, type DropdownProps, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default as Icon, type IconProps, _default$2 as Image, type ImageProps, InputField, type InputFieldProps, _default$3 as Label, type LabelProps, Loader, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type SideMenuProps, type Tab, type TabGroup, Table, type TableColumn, type TableFilterData, type TableListFilterListItem, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, _default$5 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, filterHover, generateLocalStorage, getBrowser, getFormErrorObject, isMobileDevice, localStoragePlugin, reactRouterDomPlugin, sideMenuControls, useAlertControls, useBetterHtmlContext, useForm, useMediaQuery, usePageResize, usePageScroll, useUrlQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -178,6 +178,9 @@ declare const Text: typeof TextComponent & {
|
|
|
178
178
|
|
|
179
179
|
type PageHeaderProps = {
|
|
180
180
|
icon?: IconName | AnyOtherString;
|
|
181
|
+
iconColor?: React.CSSProperties["color"];
|
|
182
|
+
/** @default 20 */
|
|
183
|
+
iconSize?: number;
|
|
181
184
|
image?: AssetName | AnyOtherString;
|
|
182
185
|
imageUrl?: string;
|
|
183
186
|
imageSize?: number;
|
|
@@ -497,21 +500,25 @@ type Alert = {
|
|
|
497
500
|
onClose?: (alert: Alert) => void;
|
|
498
501
|
};
|
|
499
502
|
|
|
503
|
+
type Tab = {
|
|
504
|
+
id: string;
|
|
505
|
+
label?: string;
|
|
506
|
+
};
|
|
500
507
|
type TabGroup = {
|
|
501
508
|
name: string;
|
|
502
|
-
selectedTab:
|
|
509
|
+
selectedTab: Tab["id"];
|
|
503
510
|
};
|
|
504
511
|
type TabsProps = {
|
|
505
|
-
tabs:
|
|
512
|
+
tabs: Tab[];
|
|
506
513
|
name?: string;
|
|
507
514
|
accentColor?: Color;
|
|
508
515
|
style?: "default" | "borderRadiusTop" | "box";
|
|
509
|
-
onChange?: (tab:
|
|
516
|
+
onChange?: (tab: Tab) => void;
|
|
510
517
|
children?: React.ReactNode;
|
|
511
518
|
} & ComponentMarginProps;
|
|
512
519
|
type TabsRef = {
|
|
513
|
-
selectedTab:
|
|
514
|
-
selectTab: (tab:
|
|
520
|
+
selectedTab: Tab["id"];
|
|
521
|
+
selectTab: (tab: Tab) => void;
|
|
515
522
|
};
|
|
516
523
|
type TabsComponent = {
|
|
517
524
|
(props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
|
|
@@ -519,7 +526,7 @@ type TabsComponent = {
|
|
|
519
526
|
};
|
|
520
527
|
declare const TabsComponent: TabsComponent;
|
|
521
528
|
type TabsContentProps = {
|
|
522
|
-
|
|
529
|
+
tabId: Tab["id"];
|
|
523
530
|
tabWithDot?: boolean;
|
|
524
531
|
tabsGroupName?: string;
|
|
525
532
|
isInitialTab?: boolean;
|
|
@@ -632,8 +639,11 @@ declare const filterHover: () => Record<"z05" | "z1" | "z2" | "z3", React.CSSPro
|
|
|
632
639
|
declare function generateLocalStorage<LocalStorage extends object>(): {
|
|
633
640
|
setItem: <StorageName extends keyof LocalStorage>(name: StorageName, value: LocalStorage[StorageName]) => void;
|
|
634
641
|
getItem: <StorageName extends keyof LocalStorage>(name: StorageName) => LocalStorage[StorageName] | undefined;
|
|
642
|
+
getAllItems: () => Partial<LocalStorage>;
|
|
635
643
|
removeItem: (name: keyof LocalStorage) => void;
|
|
636
|
-
removeAllItems: (
|
|
644
|
+
removeAllItems: (config?: {
|
|
645
|
+
keepValues?: (keyof LocalStorage)[];
|
|
646
|
+
}) => void;
|
|
637
647
|
};
|
|
638
648
|
|
|
639
649
|
type LoaderProps = {
|
|
@@ -1179,4 +1189,4 @@ type LocalStoragePluginOptions = {
|
|
|
1179
1189
|
declare const defaultLocalStoragePluginOptions: Required<LocalStoragePluginOptions>;
|
|
1180
1190
|
declare const localStoragePlugin: BetterHtmlPluginConstructor<LocalStoragePluginOptions>;
|
|
1181
1191
|
|
|
1182
|
-
export { type Alert, type AlertDisplay, type AlertDuration, type AlertType, type AlertsPluginOptions, type AppConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default$1 as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, type BurgerButtonProps, Button, type ButtonProps, Chip, type ChipProps, ColorThemeSwitch, type ColorThemeSwitchProps, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, Div, type DivProps, _default$4 as Divider, Dropdown, type DropdownOption, type DropdownProps, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default as Icon, type IconProps, _default$2 as Image, type ImageProps, InputField, type InputFieldProps, _default$3 as Label, type LabelProps, Loader, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type SideMenuProps, type TabGroup, Table, type TableColumn, type TableFilterData, type TableListFilterListItem, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, _default$5 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, filterHover, generateLocalStorage, getBrowser, getFormErrorObject, isMobileDevice, localStoragePlugin, reactRouterDomPlugin, sideMenuControls, useAlertControls, useBetterHtmlContext, useForm, useMediaQuery, usePageResize, usePageScroll, useUrlQuery };
|
|
1192
|
+
export { type Alert, type AlertDisplay, type AlertDuration, type AlertType, type AlertsPluginOptions, type AppConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default$1 as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, type BurgerButtonProps, Button, type ButtonProps, Chip, type ChipProps, ColorThemeSwitch, type ColorThemeSwitchProps, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, Div, type DivProps, _default$4 as Divider, Dropdown, type DropdownOption, type DropdownProps, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default as Icon, type IconProps, _default$2 as Image, type ImageProps, InputField, type InputFieldProps, _default$3 as Label, type LabelProps, Loader, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type SideMenuProps, type Tab, type TabGroup, Table, type TableColumn, type TableFilterData, type TableListFilterListItem, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, _default$5 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, filterHover, generateLocalStorage, getBrowser, getFormErrorObject, isMobileDevice, localStoragePlugin, reactRouterDomPlugin, sideMenuControls, useAlertControls, useBetterHtmlContext, useForm, useMediaQuery, usePageResize, usePageScroll, useUrlQuery };
|
package/dist/index.js
CHANGED
|
@@ -1651,6 +1651,8 @@ var Icon_default = { Icon: MemoizedIcon }.Icon;
|
|
|
1651
1651
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1652
1652
|
var PageHeaderComponent = (0, import_react7.forwardRef)(function PageHeader({
|
|
1653
1653
|
icon,
|
|
1654
|
+
iconColor,
|
|
1655
|
+
iconSize = 20,
|
|
1654
1656
|
image,
|
|
1655
1657
|
imageUrl,
|
|
1656
1658
|
imageSize = 60,
|
|
@@ -1681,7 +1683,7 @@ var PageHeaderComponent = (0, import_react7.forwardRef)(function PageHeader({
|
|
|
1681
1683
|
marginBottom: marginBottom ?? theme2.styles.space * 2,
|
|
1682
1684
|
ref,
|
|
1683
1685
|
children: [
|
|
1684
|
-
icon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon_default, { name: icon, size:
|
|
1686
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon_default, { name: icon, size: iconSize, color: iconColor, flexShrink: 0 }),
|
|
1685
1687
|
(image || imageUrl) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1686
1688
|
ImageTag,
|
|
1687
1689
|
{
|
|
@@ -3349,25 +3351,53 @@ function findClosestNumber(numbers, target) {
|
|
|
3349
3351
|
|
|
3350
3352
|
// src/utils/localStorage.ts
|
|
3351
3353
|
function generateLocalStorage() {
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3354
|
+
const setItem = (name, value) => {
|
|
3355
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.setItem"))
|
|
3356
|
+
return void 0;
|
|
3357
|
+
const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
|
|
3358
|
+
(plugin) => plugin.name === "localStorage"
|
|
3359
|
+
);
|
|
3360
|
+
if (!localStoragePlugin2) {
|
|
3361
|
+
throw new Error(
|
|
3362
|
+
"`generateLocalStorage.setItem` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
3358
3363
|
);
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3364
|
+
}
|
|
3365
|
+
const pluginConfig = localStoragePlugin2.getConfig();
|
|
3366
|
+
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
3367
|
+
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
3368
|
+
const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
|
|
3369
|
+
if (value) localStorage.setItem(readyName.toString(), readyValue);
|
|
3370
|
+
else localStorage.removeItem(readyName.toString());
|
|
3371
|
+
};
|
|
3372
|
+
const getAllItems = () => {
|
|
3373
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.getAllItems"))
|
|
3374
|
+
return void 0;
|
|
3375
|
+
const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
|
|
3376
|
+
(plugin) => plugin.name === "localStorage"
|
|
3377
|
+
);
|
|
3378
|
+
if (!localStoragePlugin2) {
|
|
3379
|
+
throw new Error(
|
|
3380
|
+
"`generateLocalStorage.getAllItems` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
3381
|
+
);
|
|
3382
|
+
}
|
|
3383
|
+
const pluginConfig = localStoragePlugin2.getConfig();
|
|
3384
|
+
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
3385
|
+
const items = {
|
|
3386
|
+
...localStorage
|
|
3387
|
+
};
|
|
3388
|
+
try {
|
|
3389
|
+
return encryptionEnabled ? Object.entries(items).reduce((previousValue, currentValue) => {
|
|
3390
|
+
const readyName = encryptString(currentValue[0]);
|
|
3391
|
+
const item = JSON.parse(decryptString(currentValue[1]));
|
|
3392
|
+
previousValue[readyName] = item;
|
|
3393
|
+
return previousValue;
|
|
3394
|
+
}, {}) : items;
|
|
3395
|
+
} catch (error) {
|
|
3396
|
+
return void 0;
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
return {
|
|
3400
|
+
setItem,
|
|
3371
3401
|
getItem: (name) => {
|
|
3372
3402
|
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.getItem"))
|
|
3373
3403
|
return void 0;
|
|
@@ -3390,6 +3420,7 @@ function generateLocalStorage() {
|
|
|
3390
3420
|
return void 0;
|
|
3391
3421
|
}
|
|
3392
3422
|
},
|
|
3423
|
+
getAllItems,
|
|
3393
3424
|
removeItem: (name) => {
|
|
3394
3425
|
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.removeItem"))
|
|
3395
3426
|
return void 0;
|
|
@@ -3406,8 +3437,14 @@ function generateLocalStorage() {
|
|
|
3406
3437
|
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
3407
3438
|
localStorage.removeItem(readyName.toString());
|
|
3408
3439
|
},
|
|
3409
|
-
removeAllItems: () => {
|
|
3440
|
+
removeAllItems: (config) => {
|
|
3441
|
+
const allItems = getAllItems();
|
|
3410
3442
|
localStorage.clear();
|
|
3443
|
+
if (config?.keepValues) {
|
|
3444
|
+
config.keepValues.forEach((key) => {
|
|
3445
|
+
setItem(key, allItems[key]);
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3411
3448
|
}
|
|
3412
3449
|
};
|
|
3413
3450
|
}
|
|
@@ -7404,23 +7441,23 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7404
7441
|
const firstRenderPassedRef = (0, import_react29.useRef)(false);
|
|
7405
7442
|
const tabsRef = (0, import_react29.useRef)({});
|
|
7406
7443
|
const [selectedTab, setSelectedTab] = (0, import_react29.useState)(() => {
|
|
7407
|
-
const
|
|
7444
|
+
const selectedTabId = tabs[0]?.id ?? "";
|
|
7408
7445
|
if (urlQuery) {
|
|
7409
7446
|
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
7410
|
-
if (!tabQueryValue) return
|
|
7411
|
-
if (tabs.
|
|
7447
|
+
if (!tabQueryValue) return selectedTabId;
|
|
7448
|
+
if (tabs.some((tab) => tab.id === tabQueryValue)) return tabQueryValue;
|
|
7412
7449
|
}
|
|
7413
|
-
return
|
|
7450
|
+
return selectedTabId;
|
|
7414
7451
|
});
|
|
7415
7452
|
const [rerenderState, setRerenderState] = (0, import_react29.useState)(0);
|
|
7416
7453
|
const tabsGap = style === "box" ? theme2.styles.gap / 2 : 0;
|
|
7417
7454
|
const onClickTab = (0, import_react29.useCallback)(
|
|
7418
7455
|
(tab) => {
|
|
7419
|
-
setSelectedTab(tab);
|
|
7456
|
+
setSelectedTab(tab.id);
|
|
7420
7457
|
onChange?.(tab);
|
|
7421
7458
|
if (urlQuery) {
|
|
7422
7459
|
urlQuery.setQuery({
|
|
7423
|
-
[name ?? defaultTabName]: tab
|
|
7460
|
+
[name ?? defaultTabName]: tab.id
|
|
7424
7461
|
});
|
|
7425
7462
|
}
|
|
7426
7463
|
},
|
|
@@ -7431,7 +7468,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7431
7468
|
[rerenderState, selectedTab]
|
|
7432
7469
|
);
|
|
7433
7470
|
const leftSpacing = (0, import_react29.useMemo)(() => {
|
|
7434
|
-
const selectedTabIndex = tabs.findIndex((tab) => tab === selectedTab);
|
|
7471
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTab);
|
|
7435
7472
|
let spacing = 0;
|
|
7436
7473
|
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
7437
7474
|
if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
@@ -7490,7 +7527,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7490
7527
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
7491
7528
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
7492
7529
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
7493
|
-
const selected = tab === selectedTab;
|
|
7530
|
+
const selected = tab.id === selectedTab;
|
|
7494
7531
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
7495
7532
|
Div_default,
|
|
7496
7533
|
{
|
|
@@ -7509,10 +7546,10 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7509
7546
|
isTabAccessed: true,
|
|
7510
7547
|
onClickWithValue: onClickTab,
|
|
7511
7548
|
ref: (ref2) => {
|
|
7512
|
-
tabsRef.current[tab] = ref2;
|
|
7549
|
+
tabsRef.current[tab.id] = ref2;
|
|
7513
7550
|
},
|
|
7514
7551
|
children: [
|
|
7515
|
-
componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
7552
|
+
componentsState.tabs.tabsWithDots.includes(tab.id) && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
7516
7553
|
Div_default,
|
|
7517
7554
|
{
|
|
7518
7555
|
position: "absolute",
|
|
@@ -7532,12 +7569,12 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7532
7569
|
color: !selected ? theme2.colors.textSecondary : style === "box" ? theme2.colors.base : void 0,
|
|
7533
7570
|
transition: theme2.styles.transition,
|
|
7534
7571
|
whiteSpace: "nowrap",
|
|
7535
|
-
children: tab
|
|
7572
|
+
children: tab.label ?? tab.id
|
|
7536
7573
|
}
|
|
7537
7574
|
)
|
|
7538
7575
|
]
|
|
7539
7576
|
},
|
|
7540
|
-
tab
|
|
7577
|
+
tab.id
|
|
7541
7578
|
);
|
|
7542
7579
|
}) }),
|
|
7543
7580
|
style !== "box" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -7556,7 +7593,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7556
7593
|
children && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default, { width: "100%", children })
|
|
7557
7594
|
] });
|
|
7558
7595
|
});
|
|
7559
|
-
TabsComponent.content = function Content({
|
|
7596
|
+
TabsComponent.content = function Content({ tabId, tabWithDot, tabsGroupName, isInitialTab, children }) {
|
|
7560
7597
|
const { componentsState } = useBetterHtmlContextInternal();
|
|
7561
7598
|
const thisTabGroupData = (0, import_react29.useMemo)(
|
|
7562
7599
|
() => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
|
|
@@ -7564,14 +7601,16 @@ TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isIni
|
|
|
7564
7601
|
);
|
|
7565
7602
|
(0, import_react29.useEffect)(() => {
|
|
7566
7603
|
if (tabWithDot) {
|
|
7567
|
-
componentsState.tabs.setTabsWithDots?.(
|
|
7604
|
+
componentsState.tabs.setTabsWithDots?.(
|
|
7605
|
+
(oldValue) => oldValue.includes(tabId) ? oldValue : [...oldValue, tabId]
|
|
7606
|
+
);
|
|
7568
7607
|
} else {
|
|
7569
7608
|
componentsState.tabs.setTabsWithDots?.(
|
|
7570
|
-
(oldValue) => oldValue.includes(
|
|
7609
|
+
(oldValue) => oldValue.includes(tabId) ? oldValue.filter((tab) => tab !== tabId) : oldValue
|
|
7571
7610
|
);
|
|
7572
7611
|
}
|
|
7573
7612
|
}, [tabWithDot]);
|
|
7574
|
-
return (thisTabGroupData ? thisTabGroupData.selectedTab ===
|
|
7613
|
+
return (thisTabGroupData ? thisTabGroupData.selectedTab === tabId : isInitialTab) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default, { width: "100%", children }) : void 0;
|
|
7575
7614
|
};
|
|
7576
7615
|
var Tabs2 = (0, import_react29.memo)(TabsComponent);
|
|
7577
7616
|
Tabs2.content = TabsComponent.content;
|