react-better-html 1.1.260 → 1.1.262
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 +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +25 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5940,6 +5940,7 @@ var FormComponent = forwardRef13(function Form({
|
|
|
5940
5940
|
renderActionButtons,
|
|
5941
5941
|
onClickCancel,
|
|
5942
5942
|
onSubmit,
|
|
5943
|
+
id,
|
|
5943
5944
|
children,
|
|
5944
5945
|
...props
|
|
5945
5946
|
}, ref) {
|
|
@@ -5952,7 +5953,7 @@ var FormComponent = forwardRef13(function Form({
|
|
|
5952
5953
|
}, [form]);
|
|
5953
5954
|
const SubmitButtonTag = isDestructive ? Button_default.destructive : Button_default;
|
|
5954
5955
|
const submitButtonIsDisabledFinal = submitButtonIsDisabled || submitButtonIsDisabledInternal;
|
|
5955
|
-
return /* @__PURE__ */ jsx19(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ jsxs16("form", { name, onSubmit: onSubmit ?? form?.onSubmit, ref, children: [
|
|
5956
|
+
return /* @__PURE__ */ jsx19(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ jsxs16("form", { name, onSubmit: onSubmit ?? form?.onSubmit, id, ref, children: [
|
|
5956
5957
|
gap !== void 0 || withDividers ? /* @__PURE__ */ jsx19(Div_default.column, { gap: gap ?? (withDividers ? theme2.styles.space : theme2.styles.gap), children: withDividers ? Children.toArray(children).map((child, index) => /* @__PURE__ */ jsxs16(Fragment5, { children: [
|
|
5957
5958
|
child,
|
|
5958
5959
|
index < Children.toArray(children).length - 1 && /* @__PURE__ */ jsx19(
|
|
@@ -7463,41 +7464,41 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7463
7464
|
const firstRenderPassedRef = useRef8(false);
|
|
7464
7465
|
const tabsRef = useRef8({});
|
|
7465
7466
|
const tabsGap = gap ?? (style === "box" ? theme2.styles.gap / 2 : 0);
|
|
7466
|
-
const [
|
|
7467
|
-
const
|
|
7467
|
+
const [selectedTabId, setSelectedTabId] = useState13(() => {
|
|
7468
|
+
const selectedTabId2 = tabs[0];
|
|
7468
7469
|
if (urlQuery) {
|
|
7469
7470
|
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
7470
|
-
if (!tabQueryValue) return
|
|
7471
|
+
if (!tabQueryValue) return selectedTabId2.id;
|
|
7471
7472
|
const queryTab = tabs.find((tab) => tab.id === tabQueryValue);
|
|
7472
|
-
if (queryTab) return queryTab;
|
|
7473
|
+
if (queryTab) return queryTab.id;
|
|
7473
7474
|
}
|
|
7474
|
-
return
|
|
7475
|
+
return selectedTabId2.id;
|
|
7475
7476
|
});
|
|
7476
7477
|
const [rerenderState, setRerenderState] = useState13(0);
|
|
7477
7478
|
const onClickTab = useCallback16(
|
|
7478
|
-
(
|
|
7479
|
-
|
|
7480
|
-
onChange?.(
|
|
7479
|
+
(tabId) => {
|
|
7480
|
+
setSelectedTabId(tabId);
|
|
7481
|
+
onChange?.(tabId);
|
|
7481
7482
|
if (urlQuery) {
|
|
7482
7483
|
urlQuery.setQuery({
|
|
7483
|
-
[name ?? defaultTabName]:
|
|
7484
|
+
[name ?? defaultTabName]: tabId
|
|
7484
7485
|
});
|
|
7485
7486
|
}
|
|
7486
7487
|
},
|
|
7487
7488
|
[onChange, name, urlQuery]
|
|
7488
7489
|
);
|
|
7489
7490
|
const width = useMemo11(
|
|
7490
|
-
() => tabsRef.current[
|
|
7491
|
-
[rerenderState,
|
|
7491
|
+
() => tabsRef.current[selectedTabId]?.getBoundingClientRect().width ?? 0,
|
|
7492
|
+
[rerenderState, selectedTabId]
|
|
7492
7493
|
);
|
|
7493
7494
|
const leftSpacing = useMemo11(() => {
|
|
7494
|
-
const selectedTabIndex = tabs.findIndex((tab) => tab.id ===
|
|
7495
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTabId);
|
|
7495
7496
|
let spacing = 0;
|
|
7496
7497
|
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
7497
7498
|
if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
7498
7499
|
});
|
|
7499
7500
|
return spacing;
|
|
7500
|
-
}, [
|
|
7501
|
+
}, [selectedTabId, tabs, tabsGap]);
|
|
7501
7502
|
useEffect14(() => {
|
|
7502
7503
|
const timeout = setTimeout(() => {
|
|
7503
7504
|
setRerenderState(Math.random());
|
|
@@ -7514,7 +7515,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7514
7515
|
return oldValue.map(
|
|
7515
7516
|
(item) => item.name === (name ?? defaultTabName) ? {
|
|
7516
7517
|
...item,
|
|
7517
|
-
selectedTab:
|
|
7518
|
+
selectedTab: selectedTabId
|
|
7518
7519
|
} : item
|
|
7519
7520
|
);
|
|
7520
7521
|
} else {
|
|
@@ -7522,18 +7523,18 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7522
7523
|
...oldValue,
|
|
7523
7524
|
{
|
|
7524
7525
|
name: name ?? defaultTabName,
|
|
7525
|
-
selectedTab:
|
|
7526
|
+
selectedTab: selectedTabId
|
|
7526
7527
|
}
|
|
7527
7528
|
];
|
|
7528
7529
|
}
|
|
7529
7530
|
});
|
|
7530
|
-
}, [
|
|
7531
|
+
}, [selectedTabId, name]);
|
|
7531
7532
|
useEffect14(() => {
|
|
7532
|
-
tabsRef.current[
|
|
7533
|
+
tabsRef.current[selectedTabId]?.scrollIntoView({
|
|
7533
7534
|
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
7534
7535
|
block: "nearest"
|
|
7535
7536
|
});
|
|
7536
|
-
}, [
|
|
7537
|
+
}, [selectedTabId]);
|
|
7537
7538
|
useEffect14(() => {
|
|
7538
7539
|
return () => {
|
|
7539
7540
|
componentsState.tabs.setTabGroups(
|
|
@@ -7542,18 +7543,18 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7542
7543
|
};
|
|
7543
7544
|
}, []);
|
|
7544
7545
|
useEffect14(() => {
|
|
7545
|
-
onChange?.(
|
|
7546
|
+
onChange?.(selectedTabId);
|
|
7546
7547
|
}, []);
|
|
7547
7548
|
useImperativeHandle4(ref, () => {
|
|
7548
7549
|
return {
|
|
7549
|
-
selectedTab:
|
|
7550
|
+
selectedTab: selectedTabId,
|
|
7550
7551
|
selectTab: onClickTab
|
|
7551
7552
|
};
|
|
7552
|
-
}, [
|
|
7553
|
+
}, [selectedTabId, onClickTab]);
|
|
7553
7554
|
return /* @__PURE__ */ jsxs22(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
7554
7555
|
/* @__PURE__ */ jsxs22(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
7555
7556
|
/* @__PURE__ */ jsx25(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
7556
|
-
const selected = tab.id ===
|
|
7557
|
+
const selected = tab.id === selectedTabId;
|
|
7557
7558
|
return /* @__PURE__ */ jsxs22(
|
|
7558
7559
|
Div_default,
|
|
7559
7560
|
{
|
|
@@ -7568,7 +7569,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7568
7569
|
filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
|
|
7569
7570
|
paddingInline: theme2.styles.space,
|
|
7570
7571
|
paddingBlock: theme2.styles.gap,
|
|
7571
|
-
value: tab,
|
|
7572
|
+
value: tab.id,
|
|
7572
7573
|
cursor: "pointer",
|
|
7573
7574
|
isTabAccessed: true,
|
|
7574
7575
|
onClickWithValue: onClickTab,
|