react-better-html 1.1.261 → 1.1.263
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 +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +39 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2057,6 +2057,9 @@ var Loader_default = Loader2;
|
|
|
2057
2057
|
|
|
2058
2058
|
// src/components/Button.tsx
|
|
2059
2059
|
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2060
|
+
var fromSubcomponentProps = {
|
|
2061
|
+
fromSubcomponent: true
|
|
2062
|
+
};
|
|
2060
2063
|
var ButtonElement = styled6.button.withConfig({
|
|
2061
2064
|
shouldForwardProp: (prop) => !["theme", "colorTheme", "style", "hoverStyle", "isSmall", "withText", "isLoading", "withNoBorder"].includes(
|
|
2062
2065
|
prop
|
|
@@ -2139,7 +2142,7 @@ var ButtonComponent = function Button(buttonProps) {
|
|
|
2139
2142
|
onClickWithValue,
|
|
2140
2143
|
...props
|
|
2141
2144
|
} = useComponentsPropsMerger(
|
|
2142
|
-
betterHtmlContextInternal.components.button?.style?.default,
|
|
2145
|
+
!buttonProps.fromSubcomponent ? betterHtmlContextInternal.components.button?.style?.default : {},
|
|
2143
2146
|
buttonProps
|
|
2144
2147
|
);
|
|
2145
2148
|
const theme2 = useTheme9();
|
|
@@ -2264,6 +2267,7 @@ ButtonComponent.secondary = function Secondary(buttonProps) {
|
|
|
2264
2267
|
{
|
|
2265
2268
|
className: `secondary${className ? ` ${className}` : ""}`,
|
|
2266
2269
|
color: theme2.colors.textPrimary,
|
|
2270
|
+
...fromSubcomponentProps,
|
|
2267
2271
|
...props
|
|
2268
2272
|
}
|
|
2269
2273
|
);
|
|
@@ -2275,7 +2279,15 @@ ButtonComponent.destructive = function Destructive(buttonProps) {
|
|
|
2275
2279
|
buttonProps
|
|
2276
2280
|
);
|
|
2277
2281
|
const theme2 = useTheme9();
|
|
2278
|
-
return /* @__PURE__ */ jsx8(
|
|
2282
|
+
return /* @__PURE__ */ jsx8(
|
|
2283
|
+
ButtonComponent,
|
|
2284
|
+
{
|
|
2285
|
+
backgroundColor: theme2.colors.error,
|
|
2286
|
+
color: theme2.colors.base,
|
|
2287
|
+
...fromSubcomponentProps,
|
|
2288
|
+
...props
|
|
2289
|
+
}
|
|
2290
|
+
);
|
|
2279
2291
|
};
|
|
2280
2292
|
ButtonComponent.icon = function Icon3({ size = 16, buttonSize, backgroundButtonColor, ...buttonProps }) {
|
|
2281
2293
|
const betterHtmlContextInternal = useBetterHtmlContextInternal();
|
|
@@ -2289,7 +2301,6 @@ ButtonComponent.icon = function Icon3({ size = 16, buttonSize, backgroundButtonC
|
|
|
2289
2301
|
return /* @__PURE__ */ jsx8(
|
|
2290
2302
|
ButtonComponent,
|
|
2291
2303
|
{
|
|
2292
|
-
...betterHtmlContextInternal.components.button?.style?.icon,
|
|
2293
2304
|
width: readyButtonSize,
|
|
2294
2305
|
height: readyButtonSize,
|
|
2295
2306
|
color: theme2.colors.textPrimary,
|
|
@@ -2302,6 +2313,7 @@ ButtonComponent.icon = function Icon3({ size = 16, buttonSize, backgroundButtonC
|
|
|
2302
2313
|
border: "none",
|
|
2303
2314
|
padding: 0,
|
|
2304
2315
|
filterHover: "none !important",
|
|
2316
|
+
...fromSubcomponentProps,
|
|
2305
2317
|
...props
|
|
2306
2318
|
}
|
|
2307
2319
|
);
|
|
@@ -2325,10 +2337,10 @@ ButtonComponent.upload = function Upload({ accept, multiple, onUpload, ...button
|
|
|
2325
2337
|
return /* @__PURE__ */ jsx8(
|
|
2326
2338
|
ButtonComponent,
|
|
2327
2339
|
{
|
|
2328
|
-
...betterHtmlContextInternal.components.button?.style?.upload,
|
|
2329
2340
|
text: "Upload",
|
|
2330
2341
|
icon: "uploadCloud",
|
|
2331
2342
|
onClick: onClickElement,
|
|
2343
|
+
...fromSubcomponentProps,
|
|
2332
2344
|
...props
|
|
2333
2345
|
}
|
|
2334
2346
|
);
|
|
@@ -7464,41 +7476,41 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7464
7476
|
const firstRenderPassedRef = useRef8(false);
|
|
7465
7477
|
const tabsRef = useRef8({});
|
|
7466
7478
|
const tabsGap = gap ?? (style === "box" ? theme2.styles.gap / 2 : 0);
|
|
7467
|
-
const [
|
|
7468
|
-
const
|
|
7479
|
+
const [selectedTabId, setSelectedTabId] = useState13(() => {
|
|
7480
|
+
const selectedTabId2 = tabs[0];
|
|
7469
7481
|
if (urlQuery) {
|
|
7470
7482
|
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
7471
|
-
if (!tabQueryValue) return
|
|
7483
|
+
if (!tabQueryValue) return selectedTabId2.id;
|
|
7472
7484
|
const queryTab = tabs.find((tab) => tab.id === tabQueryValue);
|
|
7473
|
-
if (queryTab) return queryTab;
|
|
7485
|
+
if (queryTab) return queryTab.id;
|
|
7474
7486
|
}
|
|
7475
|
-
return
|
|
7487
|
+
return selectedTabId2.id;
|
|
7476
7488
|
});
|
|
7477
7489
|
const [rerenderState, setRerenderState] = useState13(0);
|
|
7478
7490
|
const onClickTab = useCallback16(
|
|
7479
|
-
(
|
|
7480
|
-
|
|
7481
|
-
onChange?.(
|
|
7491
|
+
(tabId) => {
|
|
7492
|
+
setSelectedTabId(tabId);
|
|
7493
|
+
onChange?.(tabId);
|
|
7482
7494
|
if (urlQuery) {
|
|
7483
7495
|
urlQuery.setQuery({
|
|
7484
|
-
[name ?? defaultTabName]:
|
|
7496
|
+
[name ?? defaultTabName]: tabId
|
|
7485
7497
|
});
|
|
7486
7498
|
}
|
|
7487
7499
|
},
|
|
7488
7500
|
[onChange, name, urlQuery]
|
|
7489
7501
|
);
|
|
7490
7502
|
const width = useMemo11(
|
|
7491
|
-
() => tabsRef.current[
|
|
7492
|
-
[rerenderState,
|
|
7503
|
+
() => tabsRef.current[selectedTabId]?.getBoundingClientRect().width ?? 0,
|
|
7504
|
+
[rerenderState, selectedTabId]
|
|
7493
7505
|
);
|
|
7494
7506
|
const leftSpacing = useMemo11(() => {
|
|
7495
|
-
const selectedTabIndex = tabs.findIndex((tab) => tab.id ===
|
|
7507
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTabId);
|
|
7496
7508
|
let spacing = 0;
|
|
7497
7509
|
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
7498
7510
|
if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
7499
7511
|
});
|
|
7500
7512
|
return spacing;
|
|
7501
|
-
}, [
|
|
7513
|
+
}, [selectedTabId, tabs, tabsGap]);
|
|
7502
7514
|
useEffect14(() => {
|
|
7503
7515
|
const timeout = setTimeout(() => {
|
|
7504
7516
|
setRerenderState(Math.random());
|
|
@@ -7515,7 +7527,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7515
7527
|
return oldValue.map(
|
|
7516
7528
|
(item) => item.name === (name ?? defaultTabName) ? {
|
|
7517
7529
|
...item,
|
|
7518
|
-
selectedTab:
|
|
7530
|
+
selectedTab: selectedTabId
|
|
7519
7531
|
} : item
|
|
7520
7532
|
);
|
|
7521
7533
|
} else {
|
|
@@ -7523,18 +7535,18 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7523
7535
|
...oldValue,
|
|
7524
7536
|
{
|
|
7525
7537
|
name: name ?? defaultTabName,
|
|
7526
|
-
selectedTab:
|
|
7538
|
+
selectedTab: selectedTabId
|
|
7527
7539
|
}
|
|
7528
7540
|
];
|
|
7529
7541
|
}
|
|
7530
7542
|
});
|
|
7531
|
-
}, [
|
|
7543
|
+
}, [selectedTabId, name]);
|
|
7532
7544
|
useEffect14(() => {
|
|
7533
|
-
tabsRef.current[
|
|
7545
|
+
tabsRef.current[selectedTabId]?.scrollIntoView({
|
|
7534
7546
|
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
7535
7547
|
block: "nearest"
|
|
7536
7548
|
});
|
|
7537
|
-
}, [
|
|
7549
|
+
}, [selectedTabId]);
|
|
7538
7550
|
useEffect14(() => {
|
|
7539
7551
|
return () => {
|
|
7540
7552
|
componentsState.tabs.setTabGroups(
|
|
@@ -7543,18 +7555,18 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7543
7555
|
};
|
|
7544
7556
|
}, []);
|
|
7545
7557
|
useEffect14(() => {
|
|
7546
|
-
onChange?.(
|
|
7558
|
+
onChange?.(selectedTabId);
|
|
7547
7559
|
}, []);
|
|
7548
7560
|
useImperativeHandle4(ref, () => {
|
|
7549
7561
|
return {
|
|
7550
|
-
selectedTab:
|
|
7562
|
+
selectedTab: selectedTabId,
|
|
7551
7563
|
selectTab: onClickTab
|
|
7552
7564
|
};
|
|
7553
|
-
}, [
|
|
7565
|
+
}, [selectedTabId, onClickTab]);
|
|
7554
7566
|
return /* @__PURE__ */ jsxs22(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
7555
7567
|
/* @__PURE__ */ jsxs22(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
7556
7568
|
/* @__PURE__ */ jsx25(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
7557
|
-
const selected = tab.id ===
|
|
7569
|
+
const selected = tab.id === selectedTabId;
|
|
7558
7570
|
return /* @__PURE__ */ jsxs22(
|
|
7559
7571
|
Div_default,
|
|
7560
7572
|
{
|
|
@@ -7569,7 +7581,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7569
7581
|
filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
|
|
7570
7582
|
paddingInline: theme2.styles.space,
|
|
7571
7583
|
paddingBlock: theme2.styles.gap,
|
|
7572
|
-
value: tab,
|
|
7584
|
+
value: tab.id,
|
|
7573
7585
|
cursor: "pointer",
|
|
7574
7586
|
isTabAccessed: true,
|
|
7575
7587
|
onClickWithValue: onClickTab,
|