react-better-html 1.1.284 → 1.1.286
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +42 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -212,6 +212,10 @@ type PageHeaderProps = {
|
|
|
212
212
|
descriptionFontSize?: React.CSSProperties["fontSize"];
|
|
213
213
|
/** @default textSecondary */
|
|
214
214
|
descriptionColor?: React.CSSProperties["color"];
|
|
215
|
+
/** @default theme.styles.space */
|
|
216
|
+
imageGap?: React.CSSProperties["gap"];
|
|
217
|
+
/** @default theme.styles.gap / 2 */
|
|
218
|
+
titleGap?: React.CSSProperties["gap"];
|
|
215
219
|
textAlign?: React.CSSProperties["textAlign"];
|
|
216
220
|
rightElement?: React.ReactNode;
|
|
217
221
|
/** @default false */
|
|
@@ -1196,6 +1200,8 @@ type SideMenuPageHolderProps = PageHolderProps & {
|
|
|
1196
1200
|
type BurgerButtonProps = {
|
|
1197
1201
|
/** @default "left" */
|
|
1198
1202
|
position?: "left" | "center" | "right";
|
|
1203
|
+
/** @default theme.colors.border */
|
|
1204
|
+
color?: React.CSSProperties["color"];
|
|
1199
1205
|
onClick?: (isOpened: boolean) => void;
|
|
1200
1206
|
};
|
|
1201
1207
|
declare const SideMenu: typeof SideMenuComponent & {
|
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,10 @@ type PageHeaderProps = {
|
|
|
212
212
|
descriptionFontSize?: React.CSSProperties["fontSize"];
|
|
213
213
|
/** @default textSecondary */
|
|
214
214
|
descriptionColor?: React.CSSProperties["color"];
|
|
215
|
+
/** @default theme.styles.space */
|
|
216
|
+
imageGap?: React.CSSProperties["gap"];
|
|
217
|
+
/** @default theme.styles.gap / 2 */
|
|
218
|
+
titleGap?: React.CSSProperties["gap"];
|
|
215
219
|
textAlign?: React.CSSProperties["textAlign"];
|
|
216
220
|
rightElement?: React.ReactNode;
|
|
217
221
|
/** @default false */
|
|
@@ -1196,6 +1200,8 @@ type SideMenuPageHolderProps = PageHolderProps & {
|
|
|
1196
1200
|
type BurgerButtonProps = {
|
|
1197
1201
|
/** @default "left" */
|
|
1198
1202
|
position?: "left" | "center" | "right";
|
|
1203
|
+
/** @default theme.colors.border */
|
|
1204
|
+
color?: React.CSSProperties["color"];
|
|
1199
1205
|
onClick?: (isOpened: boolean) => void;
|
|
1200
1206
|
};
|
|
1201
1207
|
declare const SideMenu: typeof SideMenuComponent & {
|
package/dist/index.js
CHANGED
|
@@ -1687,6 +1687,8 @@ var PageHeaderComponent = (0, import_react7.forwardRef)(function PageHeader({
|
|
|
1687
1687
|
description,
|
|
1688
1688
|
descriptionFontSize,
|
|
1689
1689
|
descriptionColor,
|
|
1690
|
+
imageGap,
|
|
1691
|
+
titleGap,
|
|
1690
1692
|
textAlign,
|
|
1691
1693
|
rightElement,
|
|
1692
1694
|
lightMode,
|
|
@@ -1701,7 +1703,7 @@ var PageHeaderComponent = (0, import_react7.forwardRef)(function PageHeader({
|
|
|
1701
1703
|
Div_default.row,
|
|
1702
1704
|
{
|
|
1703
1705
|
alignItems: "center",
|
|
1704
|
-
gap: theme2.styles.space,
|
|
1706
|
+
gap: imageGap ?? theme2.styles.space,
|
|
1705
1707
|
marginBottom: marginBottom ?? theme2.styles.space * 2,
|
|
1706
1708
|
ref,
|
|
1707
1709
|
children: [
|
|
@@ -1722,7 +1724,7 @@ var PageHeaderComponent = (0, import_react7.forwardRef)(function PageHeader({
|
|
|
1722
1724
|
{
|
|
1723
1725
|
alignItems: textAlign === "center" ? "center" : textAlign === "right" ? "flex-end" : void 0,
|
|
1724
1726
|
flex: 1,
|
|
1725
|
-
gap: theme2.styles.gap / 2,
|
|
1727
|
+
gap: titleGap ?? theme2.styles.gap / 2,
|
|
1726
1728
|
children: [
|
|
1727
1729
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1728
1730
|
Div_default.row,
|
|
@@ -1869,6 +1871,7 @@ DivComponent.box = (0, import_react8.forwardRef)(function Box({
|
|
|
1869
1871
|
titleRightElement,
|
|
1870
1872
|
description,
|
|
1871
1873
|
descriptionColor,
|
|
1874
|
+
titleGap,
|
|
1872
1875
|
textAlign,
|
|
1873
1876
|
rightElement,
|
|
1874
1877
|
lightMode,
|
|
@@ -1922,6 +1925,7 @@ DivComponent.box = (0, import_react8.forwardRef)(function Box({
|
|
|
1922
1925
|
titleRightElement,
|
|
1923
1926
|
description,
|
|
1924
1927
|
descriptionColor,
|
|
1928
|
+
titleGap,
|
|
1925
1929
|
textAlign,
|
|
1926
1930
|
rightElement,
|
|
1927
1931
|
lightMode,
|
|
@@ -7449,9 +7453,9 @@ var TooltipComponent = (0, import_react29.forwardRef)(function Tooltip({
|
|
|
7449
7453
|
children
|
|
7450
7454
|
}, ref) {
|
|
7451
7455
|
const theme2 = (0, import_react_better_core26.useTheme)();
|
|
7456
|
+
const wrapperRef = (0, import_react29.useRef)(null);
|
|
7452
7457
|
const triggerHolderRef = (0, import_react29.useRef)(null);
|
|
7453
7458
|
const contentRef = (0, import_react29.useRef)(null);
|
|
7454
|
-
const tooltipContainerRef = (0, import_react29.useRef)(null);
|
|
7455
7459
|
const closeTimerRef = (0, import_react29.useRef)(void 0);
|
|
7456
7460
|
const [isOpen, setIsOpen] = (0, import_react29.useState)(false);
|
|
7457
7461
|
const [isOpenLate, setIsOpenLate] = (0, import_react29.useState)(false);
|
|
@@ -7464,26 +7468,8 @@ var TooltipComponent = (0, import_react29.forwardRef)(function Tooltip({
|
|
|
7464
7468
|
if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
|
|
7465
7469
|
setIsOpen(true);
|
|
7466
7470
|
setIsOpenLate(true);
|
|
7467
|
-
setTimeout(() => {
|
|
7468
|
-
if (!tooltipContainerRef.current) return;
|
|
7469
|
-
if (!contentRef.current) return;
|
|
7470
|
-
const clientRects = tooltipContainerRef.current.getBoundingClientRect();
|
|
7471
|
-
if (clientRects) {
|
|
7472
|
-
const { width, height, x, y } = clientRects;
|
|
7473
|
-
const topOutside = y < 0;
|
|
7474
|
-
const bottomOutside = y + height > window.innerHeight;
|
|
7475
|
-
const leftOutside = x < 0;
|
|
7476
|
-
const rightOutside = x + width > window.innerWidth;
|
|
7477
|
-
if (topOutside) contentRef.current.style.transform = `translateY(${y * -1 + outsideScreenGap}px)`;
|
|
7478
|
-
if (bottomOutside)
|
|
7479
|
-
contentRef.current.style.transform = `translateY(${window.innerHeight - (y + height) - totalGap}px)`;
|
|
7480
|
-
if (leftOutside) contentRef.current.style.transform = `translateX(${x * -1 + outsideScreenGap}px)`;
|
|
7481
|
-
if (rightOutside)
|
|
7482
|
-
contentRef.current.style.transform = `translateX(${window.innerWidth - (x + width) - totalGap}px)`;
|
|
7483
|
-
}
|
|
7484
|
-
}, 1);
|
|
7485
7471
|
onOpen?.();
|
|
7486
|
-
}, [disabled, onOpen
|
|
7472
|
+
}, [disabled, onOpen]);
|
|
7487
7473
|
const closeTooltip = (0, import_react29.useCallback)(() => {
|
|
7488
7474
|
setIsOpen(false);
|
|
7489
7475
|
closeTimerRef.current = setTimeout(() => setIsOpenLate(false), 300);
|
|
@@ -7514,6 +7500,29 @@ var TooltipComponent = (0, import_react29.forwardRef)(function Tooltip({
|
|
|
7514
7500
|
},
|
|
7515
7501
|
[trigger, isOpen, closeTooltip]
|
|
7516
7502
|
);
|
|
7503
|
+
const clampContentInsideViewport = (0, import_react29.useCallback)(() => {
|
|
7504
|
+
if (!wrapperRef.current || !contentRef.current) return;
|
|
7505
|
+
const wrapperRect = wrapperRef.current.getBoundingClientRect();
|
|
7506
|
+
const contentWidth2 = contentRef.current.offsetWidth;
|
|
7507
|
+
const contentHeight = contentRef.current.offsetHeight;
|
|
7508
|
+
let expectedLeft;
|
|
7509
|
+
let expectedTop;
|
|
7510
|
+
if (position === "top" || position === "bottom") {
|
|
7511
|
+
expectedTop = position === "top" ? wrapperRect.top - totalGap - contentHeight : wrapperRect.bottom + totalGap;
|
|
7512
|
+
expectedLeft = align === "left" ? wrapperRect.left : align === "right" ? wrapperRect.right - contentWidth2 : wrapperRect.left + wrapperRect.width / 2 - contentWidth2 / 2;
|
|
7513
|
+
} else {
|
|
7514
|
+
expectedLeft = position === "left" ? wrapperRect.left - totalGap - contentWidth2 : wrapperRect.right + totalGap;
|
|
7515
|
+
expectedTop = align === "top" ? wrapperRect.top : align === "bottom" ? wrapperRect.bottom - contentHeight : wrapperRect.top + wrapperRect.height / 2 - contentHeight / 2;
|
|
7516
|
+
}
|
|
7517
|
+
const getShift = (start, size, viewportSize) => {
|
|
7518
|
+
if (start < outsideScreenGap) return outsideScreenGap - start;
|
|
7519
|
+
if (start + size > viewportSize - outsideScreenGap) return viewportSize - outsideScreenGap - (start + size);
|
|
7520
|
+
return 0;
|
|
7521
|
+
};
|
|
7522
|
+
const shiftX = getShift(expectedLeft, contentWidth2, window.innerWidth);
|
|
7523
|
+
const shiftY = getShift(expectedTop, contentHeight, window.innerHeight);
|
|
7524
|
+
contentRef.current.style.transform = shiftX || shiftY ? `translate(${shiftX}px, ${shiftY}px)` : "";
|
|
7525
|
+
}, [position, align, totalGap, outsideScreenGap]);
|
|
7517
7526
|
(0, import_react29.useEffect)(() => {
|
|
7518
7527
|
if (trigger === "click") {
|
|
7519
7528
|
document.addEventListener("mousedown", onClickOutside);
|
|
@@ -7526,6 +7535,9 @@ var TooltipComponent = (0, import_react29.forwardRef)(function Tooltip({
|
|
|
7526
7535
|
if (!disabled) return;
|
|
7527
7536
|
closeTooltip();
|
|
7528
7537
|
}, [disabled]);
|
|
7538
|
+
(0, import_react29.useLayoutEffect)(() => {
|
|
7539
|
+
if (isOpen) clampContentInsideViewport();
|
|
7540
|
+
}, [isOpen, clampContentInsideViewport]);
|
|
7529
7541
|
(0, import_react29.useImperativeHandle)(ref, () => {
|
|
7530
7542
|
return {
|
|
7531
7543
|
isOpen,
|
|
@@ -7542,6 +7554,7 @@ var TooltipComponent = (0, import_react29.forwardRef)(function Tooltip({
|
|
|
7542
7554
|
onClick: onClickHolder,
|
|
7543
7555
|
onMouseEnter,
|
|
7544
7556
|
onMouseLeave,
|
|
7557
|
+
ref: wrapperRef,
|
|
7545
7558
|
children: [
|
|
7546
7559
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
7547
7560
|
Div_default,
|
|
@@ -7565,7 +7578,6 @@ var TooltipComponent = (0, import_react29.forwardRef)(function Tooltip({
|
|
|
7565
7578
|
gap,
|
|
7566
7579
|
isOpen,
|
|
7567
7580
|
role: "tooltip",
|
|
7568
|
-
ref: tooltipContainerRef,
|
|
7569
7581
|
children: (isOpen || isOpenLate) && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Div_default, { position: "relative", ref: contentRef, children: [
|
|
7570
7582
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
7571
7583
|
Div_default.box,
|
|
@@ -7941,6 +7953,7 @@ var FoldableComponent = (0, import_react31.forwardRef)(function Foldable({
|
|
|
7941
7953
|
description,
|
|
7942
7954
|
descriptionFontSize,
|
|
7943
7955
|
descriptionColor,
|
|
7956
|
+
titleGap,
|
|
7944
7957
|
textAlign,
|
|
7945
7958
|
rightElement,
|
|
7946
7959
|
lightMode,
|
|
@@ -8033,6 +8046,7 @@ var FoldableComponent = (0, import_react31.forwardRef)(function Foldable({
|
|
|
8033
8046
|
description,
|
|
8034
8047
|
descriptionFontSize,
|
|
8035
8048
|
descriptionColor,
|
|
8049
|
+
titleGap,
|
|
8036
8050
|
textAlign,
|
|
8037
8051
|
rightElement,
|
|
8038
8052
|
lightMode,
|
|
@@ -8639,7 +8653,7 @@ SideMenuComponent.pageHolder = function SideMenuPageHolder({
|
|
|
8639
8653
|
}
|
|
8640
8654
|
);
|
|
8641
8655
|
};
|
|
8642
|
-
SideMenuComponent.burgerButton = function BurgerButton({ position = "left", onClick }) {
|
|
8656
|
+
SideMenuComponent.burgerButton = function BurgerButton({ position = "left", color, onClick }) {
|
|
8643
8657
|
const theme2 = (0, import_react_better_core29.useTheme)();
|
|
8644
8658
|
const { sideMenuIsOpenMobile, setSideMenuIsOpenMobile } = useBetterHtmlContextInternal();
|
|
8645
8659
|
const [isHovered, setIsHovered] = (0, import_react_better_core29.useBooleanState)();
|
|
@@ -8648,6 +8662,7 @@ SideMenuComponent.burgerButton = function BurgerButton({ position = "left", onCl
|
|
|
8648
8662
|
onClick?.(!sideMenuIsOpenMobile);
|
|
8649
8663
|
}, [onClick, sideMenuIsOpenMobile]);
|
|
8650
8664
|
const width = 2;
|
|
8665
|
+
const backgroundColor = color ?? theme2.colors.border;
|
|
8651
8666
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
8652
8667
|
Div_default,
|
|
8653
8668
|
{
|
|
@@ -8669,7 +8684,7 @@ SideMenuComponent.burgerButton = function BurgerButton({ position = "left", onCl
|
|
|
8669
8684
|
top: sideMenuIsOpenMobile ? `calc(50% - ${width / 2}px)` : 0,
|
|
8670
8685
|
left: position === "left" ? 0 : position === "center" ? sideMenuIsOpenMobile ? 0 : "50%" : "auto",
|
|
8671
8686
|
right: position === "right" ? 0 : void 0,
|
|
8672
|
-
backgroundColor
|
|
8687
|
+
backgroundColor,
|
|
8673
8688
|
borderRadius: 999,
|
|
8674
8689
|
transform: sideMenuIsOpenMobile ? "rotate(45deg)" : position === "center" ? "translateX(-50%)" : void 0,
|
|
8675
8690
|
transition: theme2.styles.transition
|
|
@@ -8684,7 +8699,7 @@ SideMenuComponent.burgerButton = function BurgerButton({ position = "left", onCl
|
|
|
8684
8699
|
top: "50%",
|
|
8685
8700
|
left: position === "left" ? 0 : position === "center" ? "50%" : "auto",
|
|
8686
8701
|
right: position === "right" ? 0 : void 0,
|
|
8687
|
-
backgroundColor
|
|
8702
|
+
backgroundColor,
|
|
8688
8703
|
borderRadius: 999,
|
|
8689
8704
|
transform: `translateY(-50%)${position === "center" ? " translateX(-50%)" : ""}`,
|
|
8690
8705
|
opacity: sideMenuIsOpenMobile ? 0 : void 0,
|
|
@@ -8700,7 +8715,7 @@ SideMenuComponent.burgerButton = function BurgerButton({ position = "left", onCl
|
|
|
8700
8715
|
bottom: sideMenuIsOpenMobile ? `calc(50% - ${width / 2}px)` : 0,
|
|
8701
8716
|
left: position === "left" ? 0 : position === "center" ? sideMenuIsOpenMobile ? 0 : "50%" : "auto",
|
|
8702
8717
|
right: position === "right" ? 0 : void 0,
|
|
8703
|
-
backgroundColor
|
|
8718
|
+
backgroundColor,
|
|
8704
8719
|
borderRadius: 999,
|
|
8705
8720
|
transform: sideMenuIsOpenMobile ? "rotate(-45deg)" : position === "center" ? "translateX(-50%)" : void 0,
|
|
8706
8721
|
transition: theme2.styles.transition
|