react-better-html 1.1.115 → 1.1.116
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 +61 -7
- package/dist/index.d.ts +61 -7
- package/dist/index.js +472 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +477 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
Tabs: () => Tabs_default,
|
|
53
53
|
Text: () => Text_default,
|
|
54
54
|
ToggleInput: () => ToggleInput_default,
|
|
55
|
+
Tooltip: () => Tooltip_default,
|
|
55
56
|
colorThemeControls: () => colorThemeControls,
|
|
56
57
|
countries: () => countries,
|
|
57
58
|
darkenColor: () => darkenColor,
|
|
@@ -6943,6 +6944,14 @@ var TableStyledComponent = import_styled_components11.default.table.withConfig({
|
|
|
6943
6944
|
cursor: pointer;
|
|
6944
6945
|
}
|
|
6945
6946
|
|
|
6947
|
+
&.isExpandRow {
|
|
6948
|
+
height: 0px;
|
|
6949
|
+
|
|
6950
|
+
td {
|
|
6951
|
+
border-top: none;
|
|
6952
|
+
}
|
|
6953
|
+
}
|
|
6954
|
+
|
|
6946
6955
|
${(props) => props.isStriped ? import_styled_components11.css`
|
|
6947
6956
|
&:nth-child(even) {
|
|
6948
6957
|
background-color: ${props.theme.colors.backgroundSecondary};
|
|
@@ -7020,6 +7029,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7020
7029
|
const { colorTheme } = useBetterHtmlContextInternal();
|
|
7021
7030
|
const filterModalRef = (0, import_react23.useRef)(null);
|
|
7022
7031
|
const [checkedItems, setCheckedItems] = (0, import_react23.useState)([]);
|
|
7032
|
+
const [expandedRows, setExpandedRows] = (0, import_react23.useState)([]);
|
|
7023
7033
|
const [currentPage, setCurrentPage] = (0, import_react23.useState)(1);
|
|
7024
7034
|
const [filterData, setFilterData] = (0, import_react23.useState)({});
|
|
7025
7035
|
const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = (0, import_react23.useState)();
|
|
@@ -7052,30 +7062,35 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7052
7062
|
filterModalRef.current?.close();
|
|
7053
7063
|
}
|
|
7054
7064
|
});
|
|
7065
|
+
const expandRow = (0, import_react23.useMemo)(() => columns.find((column) => column.type === "expand"), [columns]);
|
|
7055
7066
|
const renderCellContent = (0, import_react23.useCallback)(
|
|
7056
|
-
(column, item,
|
|
7067
|
+
(column, item, itemIndex) => {
|
|
7057
7068
|
switch (column.type) {
|
|
7058
7069
|
case "text": {
|
|
7059
7070
|
const value = column.keyName ? item[column.keyName] : void 0;
|
|
7060
|
-
|
|
7071
|
+
const textProps = (typeof column.getTextProps === "function" ? column.getTextProps?.(item, itemIndex) : column.getTextProps) ?? {};
|
|
7072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default, { ...textProps, children: column.format?.(item, itemIndex) ?? String(value ?? "") });
|
|
7061
7073
|
}
|
|
7062
7074
|
case "element": {
|
|
7063
|
-
return column.render?.(item,
|
|
7075
|
+
return column.render?.(item, itemIndex) ?? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, {});
|
|
7064
7076
|
}
|
|
7065
7077
|
case "image": {
|
|
7066
|
-
const
|
|
7067
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Image_default, {
|
|
7078
|
+
const imageProps = (typeof column.getImageProps === "function" ? column.getImageProps?.(item, itemIndex) : column.getImageProps) ?? {};
|
|
7079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Image_default, { width: "100%", borderRadius: theme2.styles.borderRadius / 2, ...imageProps });
|
|
7068
7080
|
}
|
|
7069
7081
|
case "checkbox": {
|
|
7070
|
-
const { onChange, ...toggleInputProps } = column.
|
|
7071
|
-
const checkedValue = checkedItems[
|
|
7082
|
+
const { onChange, ...toggleInputProps } = (typeof column.getToggleInputProps === "function" ? column.getToggleInputProps?.(item, itemIndex) : column.getToggleInputProps) ?? {};
|
|
7083
|
+
const checkedValue = checkedItems[itemIndex];
|
|
7072
7084
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7073
7085
|
ToggleInput_default.checkbox,
|
|
7074
7086
|
{
|
|
7075
7087
|
checked: checkedValue,
|
|
7088
|
+
value: item,
|
|
7076
7089
|
onChange: (checked, value) => {
|
|
7077
7090
|
setCheckedItems(
|
|
7078
|
-
(oldValue) => oldValue.map(
|
|
7091
|
+
(oldValue) => oldValue.map(
|
|
7092
|
+
(isChecked, internalIndex) => internalIndex === itemIndex ? checked : isChecked
|
|
7093
|
+
)
|
|
7079
7094
|
);
|
|
7080
7095
|
onChange?.(checked, value);
|
|
7081
7096
|
},
|
|
@@ -7083,18 +7098,37 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7083
7098
|
}
|
|
7084
7099
|
);
|
|
7085
7100
|
}
|
|
7101
|
+
case "expand": {
|
|
7102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7103
|
+
Icon_default,
|
|
7104
|
+
{
|
|
7105
|
+
name: "chevronDown",
|
|
7106
|
+
transform: `rotate(${expandedRows[itemIndex] ? 180 : 0}deg)`,
|
|
7107
|
+
transition: theme2.styles.transition
|
|
7108
|
+
}
|
|
7109
|
+
);
|
|
7110
|
+
}
|
|
7086
7111
|
default: {
|
|
7087
7112
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, {});
|
|
7088
7113
|
}
|
|
7089
7114
|
}
|
|
7090
7115
|
},
|
|
7091
|
-
[theme2, checkedItems]
|
|
7116
|
+
[theme2, checkedItems, expandedRows]
|
|
7092
7117
|
);
|
|
7093
7118
|
const onClickRowElement = (0, import_react23.useCallback)(
|
|
7094
7119
|
(item, index) => {
|
|
7095
|
-
|
|
7120
|
+
if (expandRow) {
|
|
7121
|
+
setExpandedRows((oldValue) => {
|
|
7122
|
+
if (oldValue[index] === void 0) {
|
|
7123
|
+
const newValue = expandRow.onlyOneExpanded ? [] : [...oldValue];
|
|
7124
|
+
newValue[index] = true;
|
|
7125
|
+
return newValue;
|
|
7126
|
+
}
|
|
7127
|
+
return oldValue.map((isExpanded, internalIndex) => internalIndex === index ? !isExpanded : isExpanded);
|
|
7128
|
+
});
|
|
7129
|
+
} else onClickRow?.(item, index);
|
|
7096
7130
|
},
|
|
7097
|
-
[onClickRow]
|
|
7131
|
+
[onClickRow, expandRow]
|
|
7098
7132
|
);
|
|
7099
7133
|
const onClickAllCheckboxesElement = (0, import_react23.useCallback)(
|
|
7100
7134
|
(checked) => {
|
|
@@ -7219,6 +7253,14 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7219
7253
|
},
|
|
7220
7254
|
[openedFilterColumn]
|
|
7221
7255
|
);
|
|
7256
|
+
const renderExpandedRow = (0, import_react23.useCallback)(
|
|
7257
|
+
(...props2) => {
|
|
7258
|
+
const expandColumn = columns.find((column) => column.type === "expand");
|
|
7259
|
+
if (!expandColumn) return;
|
|
7260
|
+
return expandColumn.render?.(...props2);
|
|
7261
|
+
},
|
|
7262
|
+
[columns]
|
|
7263
|
+
);
|
|
7222
7264
|
const dataAfterFilter = (0, import_react23.useMemo)(
|
|
7223
7265
|
() => data.filter(
|
|
7224
7266
|
(item) => Object.entries(filterData).every(([columnIndex, filter]) => {
|
|
@@ -7336,7 +7378,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7336
7378
|
TableStyledComponent,
|
|
7337
7379
|
{
|
|
7338
7380
|
isStriped,
|
|
7339
|
-
withHover: onClickRow !== void 0,
|
|
7381
|
+
withHover: onClickRow !== void 0 || expandRow !== void 0,
|
|
7340
7382
|
withStickyHeader,
|
|
7341
7383
|
colorTheme,
|
|
7342
7384
|
theme: theme2,
|
|
@@ -7344,7 +7386,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7344
7386
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { className: "isHeader", children: columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7345
7387
|
ThStyledComponent,
|
|
7346
7388
|
{
|
|
7347
|
-
width: column.width ?? (column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : void 0),
|
|
7389
|
+
width: column.width ?? (column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.type === "expand" ? 16 : void 0),
|
|
7348
7390
|
minWidth: column.minWidth,
|
|
7349
7391
|
maxWidth: column.maxWidth,
|
|
7350
7392
|
textAlign: column.align,
|
|
@@ -7378,15 +7420,24 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7378
7420
|
},
|
|
7379
7421
|
column.type + column.label + index
|
|
7380
7422
|
)) }) }),
|
|
7381
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime21.
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7423
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react23.Fragment, { children: [
|
|
7424
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7425
|
+
"tr",
|
|
7426
|
+
{
|
|
7427
|
+
className: onClickRow || expandRow ? "isClickable" : void 0,
|
|
7428
|
+
onClick: () => onClickRowElement(item, rowIndex),
|
|
7429
|
+
children: columns.map((column, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7430
|
+
TdStyledComponent,
|
|
7431
|
+
{
|
|
7432
|
+
textAlign: column.align,
|
|
7433
|
+
children: renderCellContent(column, item, rowIndex)
|
|
7434
|
+
},
|
|
7435
|
+
column.type + column.label + colIndex
|
|
7436
|
+
))
|
|
7437
|
+
}
|
|
7438
|
+
),
|
|
7439
|
+
expandedRows[rowIndex] && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { className: "withoutHover isExpandRow", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { colSpan: columns.length, children: renderExpandedRow(item, rowIndex) }) })
|
|
7440
|
+
] }, JSON.stringify(item) + rowIndex)) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default.unknown, { children: noDataItemsMessage }) }) }) }),
|
|
7390
7441
|
pageSize !== void 0 && pageCountInternal > 1 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tfoot", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { className: "isFooter", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
7391
7442
|
Div_default.column,
|
|
7392
7443
|
{
|
|
@@ -7598,20 +7649,367 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7598
7649
|
var Table2 = (0, import_react23.memo)(TableComponent);
|
|
7599
7650
|
var Table_default = Table2;
|
|
7600
7651
|
|
|
7601
|
-
// src/components/
|
|
7652
|
+
// src/components/Tooltip.tsx
|
|
7602
7653
|
var import_react24 = require("react");
|
|
7654
|
+
var import_styled_components12 = __toESM(require("styled-components"));
|
|
7603
7655
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
7656
|
+
var tooltipContainerStyle = (props) => ({
|
|
7657
|
+
top: import_styled_components12.css`
|
|
7658
|
+
bottom: calc(100% + ${props.gap}px + ${props.arrowSize}px);
|
|
7659
|
+
${props.align === "center" ? "left: 50%;" : props.align === "left" ? "left: 0;" : "right: 0;"}
|
|
7660
|
+
`,
|
|
7661
|
+
bottom: import_styled_components12.css`
|
|
7662
|
+
top: calc(100% + ${props.gap}px + ${props.arrowSize}px);
|
|
7663
|
+
${props.align === "center" ? "left: 50%;" : props.align === "left" ? "left: 0;" : "right: 0;"};
|
|
7664
|
+
`,
|
|
7665
|
+
left: import_styled_components12.css`
|
|
7666
|
+
${props.align === "center" ? "top: 50%;" : props.align === "top" ? "top: 0;" : "bottom: 0;"};
|
|
7667
|
+
right: calc(100% + ${props.gap}px + ${props.arrowSize}px);
|
|
7668
|
+
`,
|
|
7669
|
+
right: import_styled_components12.css`
|
|
7670
|
+
${props.align === "center" ? "top: 50%;" : props.align === "top" ? "top: 0;" : "bottom: 0;"};
|
|
7671
|
+
left: calc(100% + ${props.gap}px + ${props.arrowSize}px);
|
|
7672
|
+
`
|
|
7673
|
+
});
|
|
7674
|
+
var tooltipPositionStyle = (props) => ({
|
|
7675
|
+
top: {
|
|
7676
|
+
opened: import_styled_components12.css`
|
|
7677
|
+
transform: translateX(${props.align === "center" ? "-50%" : "0"});
|
|
7678
|
+
`,
|
|
7679
|
+
closed: import_styled_components12.css`
|
|
7680
|
+
transform: translateX(${props.align === "center" ? "-50%" : "0"}) translateY(${props.theme.styles.gap}px);
|
|
7681
|
+
`
|
|
7682
|
+
},
|
|
7683
|
+
bottom: {
|
|
7684
|
+
opened: import_styled_components12.css`
|
|
7685
|
+
transform: translateX(${props.align === "center" ? "-50%" : "0"});
|
|
7686
|
+
`,
|
|
7687
|
+
closed: import_styled_components12.css`
|
|
7688
|
+
transform: translateX(${props.align === "center" ? "-50%" : "0"}) translateY(-${props.theme.styles.gap}px);
|
|
7689
|
+
`
|
|
7690
|
+
},
|
|
7691
|
+
left: {
|
|
7692
|
+
opened: import_styled_components12.css`
|
|
7693
|
+
transform: translateY(${props.align === "center" ? "-50%" : "0"});
|
|
7694
|
+
`,
|
|
7695
|
+
closed: import_styled_components12.css`
|
|
7696
|
+
transform: translateX(${props.theme.styles.gap}px) translateY(${props.align === "center" ? "-50%" : "0"});
|
|
7697
|
+
`
|
|
7698
|
+
},
|
|
7699
|
+
right: {
|
|
7700
|
+
opened: import_styled_components12.css`
|
|
7701
|
+
transform: translateY(${props.align === "center" ? "-50%" : "0"});
|
|
7702
|
+
`,
|
|
7703
|
+
closed: import_styled_components12.css`
|
|
7704
|
+
transform: translateX(-${props.theme.styles.gap}px) translateY(${props.align === "center" ? "-50%" : "0"});
|
|
7705
|
+
`
|
|
7706
|
+
}
|
|
7707
|
+
});
|
|
7708
|
+
var TooltipContainer = import_styled_components12.default.div.withConfig({
|
|
7709
|
+
shouldForwardProp: (prop) => !["theme", "position", "align", "withArrow", "arrowSize", "isOpen", "gap"].includes(prop)
|
|
7710
|
+
})`
|
|
7711
|
+
position: absolute;
|
|
7712
|
+
opacity: ${(props) => props.isOpen ? 1 : 0};
|
|
7713
|
+
pointer-events: ${(props) => props.isOpen ? "auto" : "none"};
|
|
7714
|
+
transition: ${(props) => props.theme.styles.transition};
|
|
7715
|
+
z-index: 1000;
|
|
7716
|
+
|
|
7717
|
+
${(props) => tooltipContainerStyle(props)[props.position]}
|
|
7718
|
+
|
|
7719
|
+
${(props) => props.isOpen ? tooltipPositionStyle(props)[props.position].opened : tooltipPositionStyle(props)[props.position].closed}
|
|
7720
|
+
`;
|
|
7721
|
+
var arrowStyle = (props, borderWidth) => ({
|
|
7722
|
+
top: {
|
|
7723
|
+
borderTopColor: props.color,
|
|
7724
|
+
borderBottom: 0,
|
|
7725
|
+
top: borderWidth ? -props.size : void 0,
|
|
7726
|
+
left: borderWidth ? -props.size + borderWidth * 2 : props.align === "center" ? "50%" : props.align === "left" ? props.sideSpace : void 0,
|
|
7727
|
+
right: !borderWidth && props.align === "right" ? props.sideSpace : void 0,
|
|
7728
|
+
bottom: -props.size + 1,
|
|
7729
|
+
transform: !borderWidth && props.align === "center" ? "translateX(-50%)" : void 0
|
|
7730
|
+
},
|
|
7731
|
+
bottom: {
|
|
7732
|
+
borderBottomColor: props.color,
|
|
7733
|
+
borderTop: 0,
|
|
7734
|
+
top: borderWidth ? borderWidth * 2 : -props.size + 1,
|
|
7735
|
+
left: borderWidth ? -props.size + borderWidth * 2 : props.align === "center" ? "50%" : props.align === "left" ? props.sideSpace : void 0,
|
|
7736
|
+
right: !borderWidth && props.align === "right" ? props.sideSpace : void 0,
|
|
7737
|
+
transform: !borderWidth && props.align === "center" ? "translateX(-50%);" : void 0
|
|
7738
|
+
},
|
|
7739
|
+
left: {
|
|
7740
|
+
borderLeftColor: props.color,
|
|
7741
|
+
borderRight: 0,
|
|
7742
|
+
top: borderWidth ? -props.size + borderWidth * 2 : props.align === "center" ? "50%" : props.align === "top" ? props.sideSpace : void 0,
|
|
7743
|
+
bottom: !borderWidth && props.align === "bottom" ? props.sideSpace : void 0,
|
|
7744
|
+
left: borderWidth ? -props.size : void 0,
|
|
7745
|
+
right: -props.size + 1,
|
|
7746
|
+
transform: !borderWidth && props.align === "center" ? "translateY(-50%)" : void 0
|
|
7747
|
+
},
|
|
7748
|
+
right: {
|
|
7749
|
+
borderRightColor: props.color,
|
|
7750
|
+
borderLeft: 0,
|
|
7751
|
+
top: borderWidth ? -props.size + borderWidth * 2 : props.align === "center" ? "50%" : props.align === "top" ? props.sideSpace : void 0,
|
|
7752
|
+
bottom: !borderWidth && props.align === "bottom" ? props.sideSpace : void 0,
|
|
7753
|
+
left: borderWidth ? borderWidth * 2 : -props.size + 1,
|
|
7754
|
+
transform: !borderWidth && props.align === "center" ? "translateY(-50%);" : void 0
|
|
7755
|
+
}
|
|
7756
|
+
});
|
|
7757
|
+
var Arrow = (0, import_react24.memo)(function Arrow2(props) {
|
|
7758
|
+
const theme2 = useTheme();
|
|
7759
|
+
const { position, size } = props;
|
|
7760
|
+
const outerProps = (0, import_react24.useMemo)(
|
|
7761
|
+
() => ({
|
|
7762
|
+
...props,
|
|
7763
|
+
color: theme2.colors.border
|
|
7764
|
+
}),
|
|
7765
|
+
[props, theme2]
|
|
7766
|
+
);
|
|
7767
|
+
const borderWidth = 1;
|
|
7768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7769
|
+
Div_default,
|
|
7770
|
+
{
|
|
7771
|
+
position: "absolute",
|
|
7772
|
+
width: 0,
|
|
7773
|
+
height: 0,
|
|
7774
|
+
border: `${size}px solid transparent`,
|
|
7775
|
+
...arrowStyle(outerProps)[position],
|
|
7776
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7777
|
+
Div_default,
|
|
7778
|
+
{
|
|
7779
|
+
position: "absolute",
|
|
7780
|
+
width: 0,
|
|
7781
|
+
height: 0,
|
|
7782
|
+
border: `${size - borderWidth * 2}px solid transparent`,
|
|
7783
|
+
...arrowStyle(props, borderWidth)[position]
|
|
7784
|
+
}
|
|
7785
|
+
)
|
|
7786
|
+
}
|
|
7787
|
+
);
|
|
7788
|
+
});
|
|
7789
|
+
var TooltipComponent = (0, import_react24.forwardRef)(function Tooltip({
|
|
7790
|
+
position = "bottom",
|
|
7791
|
+
trigger = "hover",
|
|
7792
|
+
align = "center",
|
|
7793
|
+
content,
|
|
7794
|
+
contentWidth,
|
|
7795
|
+
contentMinWidth,
|
|
7796
|
+
withArrow,
|
|
7797
|
+
isSmall,
|
|
7798
|
+
backgroundColor,
|
|
7799
|
+
asContextMenu,
|
|
7800
|
+
onOpen,
|
|
7801
|
+
onClose,
|
|
7802
|
+
children,
|
|
7803
|
+
...props
|
|
7804
|
+
}, ref) {
|
|
7805
|
+
const theme2 = useTheme();
|
|
7806
|
+
const triggerHolderRef = (0, import_react24.useRef)(null);
|
|
7807
|
+
const contentRef = (0, import_react24.useRef)(null);
|
|
7808
|
+
const tooltipContainerRef = (0, import_react24.useRef)(null);
|
|
7809
|
+
const closeTimerRef = (0, import_react24.useRef)(void 0);
|
|
7810
|
+
const [isOpen, setIsOpen] = (0, import_react24.useState)(false);
|
|
7811
|
+
const [isOpenLate, setIsOpenLate] = (0, import_react24.useState)(false);
|
|
7812
|
+
const arrowSize = withArrow ? theme2.styles.gap : 0;
|
|
7813
|
+
const gap = theme2.styles.gap / 2;
|
|
7814
|
+
const outsideScreenGap = theme2.styles.gap / 2;
|
|
7815
|
+
const totalGap = arrowSize + gap;
|
|
7816
|
+
const openTooltip = (0, import_react24.useCallback)(() => {
|
|
7817
|
+
if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
|
|
7818
|
+
setIsOpen(true);
|
|
7819
|
+
setIsOpenLate(true);
|
|
7820
|
+
setTimeout(() => {
|
|
7821
|
+
if (!tooltipContainerRef.current) return;
|
|
7822
|
+
if (!contentRef.current) return;
|
|
7823
|
+
const clientRects = tooltipContainerRef.current.getBoundingClientRect();
|
|
7824
|
+
if (clientRects) {
|
|
7825
|
+
const { width, height, x, y } = clientRects;
|
|
7826
|
+
const topOutside = y < 0;
|
|
7827
|
+
const bottomOutside = y + height > window.innerHeight;
|
|
7828
|
+
const leftOutside = x < 0;
|
|
7829
|
+
const rightOutside = x + width > window.innerWidth;
|
|
7830
|
+
if (topOutside) contentRef.current.style.transform = `translateY(${y * -1 + outsideScreenGap}px)`;
|
|
7831
|
+
if (bottomOutside)
|
|
7832
|
+
contentRef.current.style.transform = `translateY(${window.innerHeight - (y + height) - totalGap}px)`;
|
|
7833
|
+
if (leftOutside) contentRef.current.style.transform = `translateX(${x * -1 + outsideScreenGap}px)`;
|
|
7834
|
+
if (rightOutside)
|
|
7835
|
+
contentRef.current.style.transform = `translateX(${window.innerWidth - (x + width) - totalGap}px)`;
|
|
7836
|
+
}
|
|
7837
|
+
}, 1);
|
|
7838
|
+
onOpen?.();
|
|
7839
|
+
}, [onOpen, outsideScreenGap, totalGap]);
|
|
7840
|
+
const closeTooltip = (0, import_react24.useCallback)(() => {
|
|
7841
|
+
setIsOpen(false);
|
|
7842
|
+
closeTimerRef.current = setTimeout(() => setIsOpenLate(false), 300);
|
|
7843
|
+
onClose?.();
|
|
7844
|
+
}, [onClose]);
|
|
7845
|
+
const onMouseEnter = (0, import_react24.useCallback)(() => {
|
|
7846
|
+
if (trigger === "hover") openTooltip();
|
|
7847
|
+
}, [trigger, openTooltip]);
|
|
7848
|
+
const onMouseLeave = (0, import_react24.useCallback)(() => {
|
|
7849
|
+
if (trigger === "hover") closeTooltip();
|
|
7850
|
+
}, [trigger, closeTooltip]);
|
|
7851
|
+
const onClickHolder = (0, import_react24.useCallback)(
|
|
7852
|
+
(event) => {
|
|
7853
|
+
if (trigger === "click") {
|
|
7854
|
+
if (!isOpen) openTooltip();
|
|
7855
|
+
else if (triggerHolderRef.current?.contains(event.target)) closeTooltip();
|
|
7856
|
+
}
|
|
7857
|
+
},
|
|
7858
|
+
[trigger, openTooltip, isOpen, closeTooltip]
|
|
7859
|
+
);
|
|
7860
|
+
const onClickOutside = (0, import_react24.useCallback)(
|
|
7861
|
+
(event) => {
|
|
7862
|
+
if (!isOpen) return;
|
|
7863
|
+
if (trigger !== "click") return;
|
|
7864
|
+
if (!contentRef.current?.contains(event.target) && !triggerHolderRef.current?.contains(event.target)) {
|
|
7865
|
+
closeTooltip();
|
|
7866
|
+
}
|
|
7867
|
+
},
|
|
7868
|
+
[trigger, isOpen, closeTooltip]
|
|
7869
|
+
);
|
|
7870
|
+
(0, import_react24.useEffect)(() => {
|
|
7871
|
+
if (trigger === "click") {
|
|
7872
|
+
document.addEventListener("mousedown", onClickOutside);
|
|
7873
|
+
return () => {
|
|
7874
|
+
document.removeEventListener("mousedown", onClickOutside);
|
|
7875
|
+
};
|
|
7876
|
+
}
|
|
7877
|
+
}, [trigger, onClickOutside]);
|
|
7878
|
+
(0, import_react24.useImperativeHandle)(
|
|
7879
|
+
ref,
|
|
7880
|
+
() => {
|
|
7881
|
+
return {
|
|
7882
|
+
isOpen,
|
|
7883
|
+
open: openTooltip,
|
|
7884
|
+
close: closeTooltip
|
|
7885
|
+
};
|
|
7886
|
+
},
|
|
7887
|
+
[isOpen, openTooltip, closeTooltip]
|
|
7888
|
+
);
|
|
7889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default, { position: "relative", onClick: onClickHolder, onMouseEnter, onMouseLeave, children: [
|
|
7890
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default, { width: "100%", ref: triggerHolderRef, children }),
|
|
7891
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7892
|
+
TooltipContainer,
|
|
7893
|
+
{
|
|
7894
|
+
theme: theme2,
|
|
7895
|
+
position,
|
|
7896
|
+
align,
|
|
7897
|
+
withArrow,
|
|
7898
|
+
arrowSize,
|
|
7899
|
+
gap,
|
|
7900
|
+
isOpen,
|
|
7901
|
+
role: "tooltip",
|
|
7902
|
+
ref: tooltipContainerRef,
|
|
7903
|
+
children: (isOpen || isOpenLate) && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default, { position: "relative", ref: contentRef, children: [
|
|
7904
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7905
|
+
Div_default.box,
|
|
7906
|
+
{
|
|
7907
|
+
position: "relative",
|
|
7908
|
+
width: contentWidth,
|
|
7909
|
+
minWidth: contentMinWidth,
|
|
7910
|
+
backgroundColor: backgroundColor ?? theme2.colors.backgroundContent,
|
|
7911
|
+
boxShadow: "0px 10px 20px #00000020",
|
|
7912
|
+
paddingBlock: isSmall ? theme2.styles.gap / 2 : theme2.styles.gap,
|
|
7913
|
+
paddingInline: asContextMenu ? 0 : isSmall ? theme2.styles.space / 2 : theme2.styles.space,
|
|
7914
|
+
overflow: asContextMenu ? "hidden" : void 0,
|
|
7915
|
+
...props,
|
|
7916
|
+
children: content
|
|
7917
|
+
}
|
|
7918
|
+
),
|
|
7919
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7920
|
+
Div_default,
|
|
7921
|
+
{
|
|
7922
|
+
position: "absolute",
|
|
7923
|
+
width: position === "left" || position === "right" ? totalGap : "100%",
|
|
7924
|
+
height: position === "top" || position === "bottom" ? totalGap : "100%",
|
|
7925
|
+
top: position === "top" ? "100%" : position === "bottom" ? void 0 : 0,
|
|
7926
|
+
bottom: position === "bottom" ? "100%" : position === "top" ? void 0 : 0,
|
|
7927
|
+
left: position === "left" ? "100%" : position === "right" ? void 0 : 0,
|
|
7928
|
+
right: position === "right" ? "100%" : position === "left" ? void 0 : 0
|
|
7929
|
+
}
|
|
7930
|
+
),
|
|
7931
|
+
withArrow && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7932
|
+
Arrow,
|
|
7933
|
+
{
|
|
7934
|
+
position,
|
|
7935
|
+
align,
|
|
7936
|
+
sideSpace: theme2.styles.borderRadius,
|
|
7937
|
+
size: arrowSize,
|
|
7938
|
+
color: backgroundColor ?? theme2.colors.backgroundContent,
|
|
7939
|
+
isOpen
|
|
7940
|
+
}
|
|
7941
|
+
)
|
|
7942
|
+
] })
|
|
7943
|
+
}
|
|
7944
|
+
)
|
|
7945
|
+
] });
|
|
7946
|
+
});
|
|
7947
|
+
TooltipComponent.item = (0, import_react24.forwardRef)(function Item({ icon, text, description, isActive, onClick, onClickWithValue, value }, ref) {
|
|
7948
|
+
const theme2 = useTheme();
|
|
7949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
7950
|
+
Div_default.row,
|
|
7951
|
+
{
|
|
7952
|
+
alignItems: "center",
|
|
7953
|
+
gap: theme2.styles.space,
|
|
7954
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
7955
|
+
filterHover: "brightness(0.9)",
|
|
7956
|
+
paddingBlock: theme2.styles.gap,
|
|
7957
|
+
paddingInline: theme2.styles.space,
|
|
7958
|
+
cursor: "pointer",
|
|
7959
|
+
value,
|
|
7960
|
+
onClick,
|
|
7961
|
+
onClickWithValue,
|
|
7962
|
+
ref,
|
|
7963
|
+
children: [
|
|
7964
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Icon_default, { name: icon, color: !isActive ? theme2.colors.textSecondary : void 0 }),
|
|
7965
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default.column, { flex: 1, gap: theme2.styles.gap / 2, children: [
|
|
7966
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Text_default, { fontWeight: isActive ? 700 : void 0, children: text }),
|
|
7967
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Text_default, { fontSize: 14, color: theme2.colors.textSecondary, children: description })
|
|
7968
|
+
] })
|
|
7969
|
+
]
|
|
7970
|
+
}
|
|
7971
|
+
);
|
|
7972
|
+
});
|
|
7973
|
+
TooltipComponent.divider = (0, import_react24.forwardRef)(function DividerComponent(props, ref) {
|
|
7974
|
+
const theme2 = useTheme();
|
|
7975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Divider_default.horizontal, { marginBlock: theme2.styles.gap, ...props, ref });
|
|
7976
|
+
});
|
|
7977
|
+
TooltipComponent.sectionTitle = (0, import_react24.forwardRef)(function SectionTitle({ text, ...props }, ref) {
|
|
7978
|
+
const theme2 = useTheme();
|
|
7979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7980
|
+
Text_default,
|
|
7981
|
+
{
|
|
7982
|
+
fontSize: 12,
|
|
7983
|
+
fontWeight: 700,
|
|
7984
|
+
textTransform: "uppercase",
|
|
7985
|
+
marginBlock: theme2.styles.gap / 2,
|
|
7986
|
+
marginInline: theme2.styles.space,
|
|
7987
|
+
...props,
|
|
7988
|
+
ref,
|
|
7989
|
+
children: text
|
|
7990
|
+
}
|
|
7991
|
+
);
|
|
7992
|
+
});
|
|
7993
|
+
var Tooltip2 = (0, import_react24.memo)(TooltipComponent);
|
|
7994
|
+
Tooltip2.item = TooltipComponent.item;
|
|
7995
|
+
Tooltip2.divider = TooltipComponent.divider;
|
|
7996
|
+
Tooltip2.sectionTitle = TooltipComponent.sectionTitle;
|
|
7997
|
+
var Tooltip_default = Tooltip2;
|
|
7998
|
+
|
|
7999
|
+
// src/components/Tabs.tsx
|
|
8000
|
+
var import_react25 = require("react");
|
|
8001
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
7604
8002
|
var tabBottomLineWidth = 2;
|
|
7605
8003
|
var tabDotSize = 6;
|
|
7606
8004
|
var defaultTabName = "tab";
|
|
7607
|
-
var TabsComponent = (0,
|
|
8005
|
+
var TabsComponent = (0, import_react25.forwardRef)(function Tabs({ tabs, name, accentColor, style = "default", onChange, children, ...props }, ref) {
|
|
7608
8006
|
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
7609
8007
|
const theme2 = useTheme();
|
|
7610
8008
|
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
7611
8009
|
const { colorTheme, componentsState } = useBetterHtmlContextInternal();
|
|
7612
|
-
const firstRenderPassedRef = (0,
|
|
7613
|
-
const tabsRef = (0,
|
|
7614
|
-
const [selectedTab, setSelectedTab] = (0,
|
|
8010
|
+
const firstRenderPassedRef = (0, import_react25.useRef)(false);
|
|
8011
|
+
const tabsRef = (0, import_react25.useRef)({});
|
|
8012
|
+
const [selectedTab, setSelectedTab] = (0, import_react25.useState)(() => {
|
|
7615
8013
|
const selectedTabValue = tabs[0] ?? "";
|
|
7616
8014
|
if (urlQuery) {
|
|
7617
8015
|
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
@@ -7620,9 +8018,9 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7620
8018
|
}
|
|
7621
8019
|
return selectedTabValue;
|
|
7622
8020
|
});
|
|
7623
|
-
const [rerenderState, setRerenderState] = (0,
|
|
8021
|
+
const [rerenderState, setRerenderState] = (0, import_react25.useState)(0);
|
|
7624
8022
|
const tabsGap = style === "box" ? theme2.styles.gap / 2 : 0;
|
|
7625
|
-
const onClickTab = (0,
|
|
8023
|
+
const onClickTab = (0, import_react25.useCallback)(
|
|
7626
8024
|
(tab) => {
|
|
7627
8025
|
setSelectedTab(tab);
|
|
7628
8026
|
onChange?.(tab);
|
|
@@ -7634,11 +8032,11 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7634
8032
|
},
|
|
7635
8033
|
[onChange, name, urlQuery]
|
|
7636
8034
|
);
|
|
7637
|
-
const width = (0,
|
|
8035
|
+
const width = (0, import_react25.useMemo)(
|
|
7638
8036
|
() => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
|
|
7639
8037
|
[rerenderState, selectedTab]
|
|
7640
8038
|
);
|
|
7641
|
-
const leftSpacing = (0,
|
|
8039
|
+
const leftSpacing = (0, import_react25.useMemo)(() => {
|
|
7642
8040
|
const selectedTabIndex = tabs.findIndex((tab) => tab === selectedTab);
|
|
7643
8041
|
let spacing = 0;
|
|
7644
8042
|
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
@@ -7646,7 +8044,7 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7646
8044
|
});
|
|
7647
8045
|
return spacing;
|
|
7648
8046
|
}, [selectedTab, tabs, tabsGap]);
|
|
7649
|
-
(0,
|
|
8047
|
+
(0, import_react25.useEffect)(() => {
|
|
7650
8048
|
const timeout = setTimeout(() => {
|
|
7651
8049
|
setRerenderState(Math.random());
|
|
7652
8050
|
firstRenderPassedRef.current = true;
|
|
@@ -7655,7 +8053,7 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7655
8053
|
clearTimeout(timeout);
|
|
7656
8054
|
};
|
|
7657
8055
|
}, []);
|
|
7658
|
-
(0,
|
|
8056
|
+
(0, import_react25.useEffect)(() => {
|
|
7659
8057
|
componentsState.tabs.setTabGroups((oldValue) => {
|
|
7660
8058
|
const thisTabGroup = oldValue.find((item) => item.name === (name ?? defaultTabName));
|
|
7661
8059
|
if (thisTabGroup) {
|
|
@@ -7676,20 +8074,20 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7676
8074
|
}
|
|
7677
8075
|
});
|
|
7678
8076
|
}, [selectedTab, name]);
|
|
7679
|
-
(0,
|
|
8077
|
+
(0, import_react25.useEffect)(() => {
|
|
7680
8078
|
tabsRef.current[selectedTab]?.scrollIntoView({
|
|
7681
8079
|
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
7682
8080
|
block: "nearest"
|
|
7683
8081
|
});
|
|
7684
8082
|
}, [selectedTab]);
|
|
7685
|
-
(0,
|
|
8083
|
+
(0, import_react25.useEffect)(() => {
|
|
7686
8084
|
return () => {
|
|
7687
8085
|
componentsState.tabs.setTabGroups(
|
|
7688
8086
|
(oldValue) => oldValue.filter((item) => item.name !== (name ?? defaultTabName))
|
|
7689
8087
|
);
|
|
7690
8088
|
};
|
|
7691
8089
|
}, []);
|
|
7692
|
-
(0,
|
|
8090
|
+
(0, import_react25.useImperativeHandle)(
|
|
7693
8091
|
ref,
|
|
7694
8092
|
() => {
|
|
7695
8093
|
return {
|
|
@@ -7699,11 +8097,11 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7699
8097
|
},
|
|
7700
8098
|
[selectedTab, onClickTab]
|
|
7701
8099
|
);
|
|
7702
|
-
return /* @__PURE__ */ (0,
|
|
7703
|
-
/* @__PURE__ */ (0,
|
|
7704
|
-
/* @__PURE__ */ (0,
|
|
8100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
8101
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
8102
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
7705
8103
|
const selected = tab === selectedTab;
|
|
7706
|
-
return /* @__PURE__ */ (0,
|
|
8104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
7707
8105
|
Div_default,
|
|
7708
8106
|
{
|
|
7709
8107
|
position: "relative",
|
|
@@ -7724,7 +8122,7 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7724
8122
|
tabsRef.current[tab] = ref2;
|
|
7725
8123
|
},
|
|
7726
8124
|
children: [
|
|
7727
|
-
componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ (0,
|
|
8125
|
+
componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
7728
8126
|
Div_default,
|
|
7729
8127
|
{
|
|
7730
8128
|
position: "absolute",
|
|
@@ -7737,7 +8135,7 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7737
8135
|
transition: theme2.styles.transition
|
|
7738
8136
|
}
|
|
7739
8137
|
),
|
|
7740
|
-
/* @__PURE__ */ (0,
|
|
8138
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
7741
8139
|
Text_default,
|
|
7742
8140
|
{
|
|
7743
8141
|
fontWeight: 700,
|
|
@@ -7752,7 +8150,7 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7752
8150
|
tab
|
|
7753
8151
|
);
|
|
7754
8152
|
}) }),
|
|
7755
|
-
style !== "box" && /* @__PURE__ */ (0,
|
|
8153
|
+
style !== "box" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
7756
8154
|
Div_default,
|
|
7757
8155
|
{
|
|
7758
8156
|
position: "absolute",
|
|
@@ -7765,16 +8163,16 @@ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, a
|
|
|
7765
8163
|
}
|
|
7766
8164
|
)
|
|
7767
8165
|
] }),
|
|
7768
|
-
children && /* @__PURE__ */ (0,
|
|
8166
|
+
children && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Div_default, { width: "100%", children })
|
|
7769
8167
|
] });
|
|
7770
8168
|
});
|
|
7771
8169
|
TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isInitialTab, children }) {
|
|
7772
8170
|
const { componentsState } = useBetterHtmlContextInternal();
|
|
7773
|
-
const thisTabGroupData = (0,
|
|
8171
|
+
const thisTabGroupData = (0, import_react25.useMemo)(
|
|
7774
8172
|
() => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
|
|
7775
8173
|
[componentsState.tabs, tabsGroupName]
|
|
7776
8174
|
);
|
|
7777
|
-
(0,
|
|
8175
|
+
(0, import_react25.useEffect)(() => {
|
|
7778
8176
|
if (tabWithDot) {
|
|
7779
8177
|
componentsState.tabs.setTabsWithDots?.((oldValue) => oldValue.includes(tab) ? oldValue : [...oldValue, tab]);
|
|
7780
8178
|
} else {
|
|
@@ -7783,18 +8181,18 @@ TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isIni
|
|
|
7783
8181
|
);
|
|
7784
8182
|
}
|
|
7785
8183
|
}, [tabWithDot]);
|
|
7786
|
-
return (thisTabGroupData ? thisTabGroupData.selectedTab === tab : isInitialTab) ? /* @__PURE__ */ (0,
|
|
8184
|
+
return (thisTabGroupData ? thisTabGroupData.selectedTab === tab : isInitialTab) ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Div_default, { width: "100%", children }) : void 0;
|
|
7787
8185
|
};
|
|
7788
|
-
var Tabs2 = (0,
|
|
8186
|
+
var Tabs2 = (0, import_react25.memo)(TabsComponent);
|
|
7789
8187
|
Tabs2.content = TabsComponent.content;
|
|
7790
8188
|
var Tabs_default = Tabs2;
|
|
7791
8189
|
|
|
7792
8190
|
// src/components/Foldable.tsx
|
|
7793
|
-
var
|
|
7794
|
-
var
|
|
8191
|
+
var import_react26 = require("react");
|
|
8192
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
7795
8193
|
var animationDurationClose = 0.15;
|
|
7796
8194
|
var animationDurationOpen = animationDurationClose * 2;
|
|
7797
|
-
var FoldableComponent = (0,
|
|
8195
|
+
var FoldableComponent = (0, import_react26.forwardRef)(function Foldable({
|
|
7798
8196
|
isOpen: controlledIsOpen,
|
|
7799
8197
|
defaultOpen = false,
|
|
7800
8198
|
title,
|
|
@@ -7809,27 +8207,27 @@ var FoldableComponent = (0, import_react25.forwardRef)(function Foldable({
|
|
|
7809
8207
|
...props
|
|
7810
8208
|
}, ref) {
|
|
7811
8209
|
const theme2 = useTheme();
|
|
7812
|
-
const bodyRef = (0,
|
|
8210
|
+
const bodyRef = (0, import_react26.useRef)(null);
|
|
7813
8211
|
const [internalIsOpen, setInternalIsOpen] = useBooleanState(defaultOpen);
|
|
7814
|
-
const [bodyVirtualHeight, setBodyVirtualHeight] = (0,
|
|
8212
|
+
const [bodyVirtualHeight, setBodyVirtualHeight] = (0, import_react26.useState)(500);
|
|
7815
8213
|
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
7816
|
-
const open = (0,
|
|
8214
|
+
const open = (0, import_react26.useCallback)(() => {
|
|
7817
8215
|
if (controlledIsOpen === void 0) setInternalIsOpen.setTrue();
|
|
7818
8216
|
onOpenChange?.(true);
|
|
7819
8217
|
}, [controlledIsOpen, onOpenChange]);
|
|
7820
|
-
const close = (0,
|
|
8218
|
+
const close = (0, import_react26.useCallback)(() => {
|
|
7821
8219
|
if (controlledIsOpen === void 0) setInternalIsOpen.setFalse();
|
|
7822
8220
|
onOpenChange?.(false);
|
|
7823
8221
|
}, [controlledIsOpen, onOpenChange]);
|
|
7824
|
-
const toggleOpen = (0,
|
|
8222
|
+
const toggleOpen = (0, import_react26.useCallback)(() => {
|
|
7825
8223
|
if (controlledIsOpen === void 0) setInternalIsOpen.toggle();
|
|
7826
8224
|
onOpenChange?.(!isOpen);
|
|
7827
8225
|
}, [controlledIsOpen, isOpen, onOpenChange]);
|
|
7828
|
-
(0,
|
|
8226
|
+
(0, import_react26.useEffect)(() => {
|
|
7829
8227
|
if (!bodyRef.current) return;
|
|
7830
8228
|
setBodyVirtualHeight(Math.min(500, bodyRef.current.scrollHeight * 2));
|
|
7831
8229
|
}, [isOpen]);
|
|
7832
|
-
(0,
|
|
8230
|
+
(0, import_react26.useImperativeHandle)(
|
|
7833
8231
|
ref,
|
|
7834
8232
|
() => {
|
|
7835
8233
|
return {
|
|
@@ -7841,8 +8239,8 @@ var FoldableComponent = (0, import_react25.forwardRef)(function Foldable({
|
|
|
7841
8239
|
},
|
|
7842
8240
|
[open, close, toggleOpen, isOpen]
|
|
7843
8241
|
);
|
|
7844
|
-
return /* @__PURE__ */ (0,
|
|
7845
|
-
renderHeader ? renderHeader(isOpen, toggleOpen) : /* @__PURE__ */ (0,
|
|
8242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Div_default.column, { width: "100%", ...props, children: [
|
|
8243
|
+
renderHeader ? renderHeader(isOpen, toggleOpen) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
7846
8244
|
Div_default.row,
|
|
7847
8245
|
{
|
|
7848
8246
|
width: "100%",
|
|
@@ -7854,15 +8252,15 @@ var FoldableComponent = (0, import_react25.forwardRef)(function Foldable({
|
|
|
7854
8252
|
onClick: toggleOpen,
|
|
7855
8253
|
userSelect: "none",
|
|
7856
8254
|
children: [
|
|
7857
|
-
/* @__PURE__ */ (0,
|
|
7858
|
-
icon && /* @__PURE__ */ (0,
|
|
7859
|
-
image && /* @__PURE__ */ (0,
|
|
7860
|
-
/* @__PURE__ */ (0,
|
|
7861
|
-
title && /* @__PURE__ */ (0,
|
|
7862
|
-
description && /* @__PURE__ */ (0,
|
|
8255
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Div_default.row, { flex: 1, alignItems: "center", gap: theme2.styles.space, children: [
|
|
8256
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Icon_default, { name: icon, size: 20, flexShrink: 0 }),
|
|
8257
|
+
image && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Image_default.profileImage, { name: image, size: 24, flexShrink: 0 }),
|
|
8258
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Div_default.column, { gap: theme2.styles.gap / 2, children: [
|
|
8259
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text_default, { as: "h3", fontWeight: 700, lineHeight: "20px", children: title }),
|
|
8260
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text_default, { color: theme2.colors.textSecondary, children: description })
|
|
7863
8261
|
] })
|
|
7864
8262
|
] }),
|
|
7865
|
-
/* @__PURE__ */ (0,
|
|
8263
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7866
8264
|
Icon_default,
|
|
7867
8265
|
{
|
|
7868
8266
|
name: "chevronDown",
|
|
@@ -7873,8 +8271,8 @@ var FoldableComponent = (0, import_react25.forwardRef)(function Foldable({
|
|
|
7873
8271
|
]
|
|
7874
8272
|
}
|
|
7875
8273
|
),
|
|
7876
|
-
/* @__PURE__ */ (0,
|
|
7877
|
-
/* @__PURE__ */ (0,
|
|
8274
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Div_default, { height: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0, transition: theme2.styles.transition, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Divider_default.horizontal, {}) }),
|
|
8275
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7878
8276
|
Div_default,
|
|
7879
8277
|
{
|
|
7880
8278
|
maxHeight: isOpen ? bodyVirtualHeight : 0,
|
|
@@ -7883,14 +8281,14 @@ var FoldableComponent = (0, import_react25.forwardRef)(function Foldable({
|
|
|
7883
8281
|
overflow: !isOpen ? "hidden" : void 0,
|
|
7884
8282
|
pointerEvents: !isOpen ? "none" : void 0,
|
|
7885
8283
|
ref: bodyRef,
|
|
7886
|
-
children: /* @__PURE__ */ (0,
|
|
8284
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Div_default, { paddingBlock: theme2.styles.gap, paddingInline: headerPaddingInline, children })
|
|
7887
8285
|
}
|
|
7888
8286
|
)
|
|
7889
8287
|
] });
|
|
7890
8288
|
});
|
|
7891
|
-
FoldableComponent.box = (0,
|
|
8289
|
+
FoldableComponent.box = (0, import_react26.forwardRef)(function Box3({ ...props }, ref) {
|
|
7892
8290
|
const theme2 = useTheme();
|
|
7893
|
-
return /* @__PURE__ */ (0,
|
|
8291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7894
8292
|
FoldableComponent,
|
|
7895
8293
|
{
|
|
7896
8294
|
backgroundColor: theme2.colors.backgroundContent,
|
|
@@ -7903,7 +8301,7 @@ FoldableComponent.box = (0, import_react25.forwardRef)(function Box3({ ...props
|
|
|
7903
8301
|
}
|
|
7904
8302
|
);
|
|
7905
8303
|
});
|
|
7906
|
-
var Foldable2 = (0,
|
|
8304
|
+
var Foldable2 = (0, import_react26.memo)(FoldableComponent);
|
|
7907
8305
|
Foldable2.box = FoldableComponent.box;
|
|
7908
8306
|
var Foldable_default = Foldable2;
|
|
7909
8307
|
|
|
@@ -7943,6 +8341,7 @@ var reactRouterDomPlugin = {
|
|
|
7943
8341
|
Tabs,
|
|
7944
8342
|
Text,
|
|
7945
8343
|
ToggleInput,
|
|
8344
|
+
Tooltip,
|
|
7946
8345
|
colorThemeControls,
|
|
7947
8346
|
countries,
|
|
7948
8347
|
darkenColor,
|