@deepnoid/ui 0.1.181 → 0.1.183
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/.turbo/turbo-build.log +145 -145
- package/dist/{chunk-GWHUQUKA.mjs → chunk-6WD32ERF.mjs} +93 -79
- package/dist/{chunk-HOQAQVDA.mjs → chunk-VRHMQMRO.mjs} +110 -31
- package/dist/chunk-WKTRWHDA.mjs +264 -0
- package/dist/components/charts/barChart.js +125 -111
- package/dist/components/charts/barChart.mjs +1 -1
- package/dist/components/charts/index.js +218 -190
- package/dist/components/charts/index.mjs +2 -2
- package/dist/components/charts/simpleBarChart.js +93 -79
- package/dist/components/charts/simpleBarChart.mjs +1 -1
- package/dist/components/table/index.js +144 -65
- package/dist/components/table/index.mjs +1 -1
- package/dist/components/table/table-body.js +140 -61
- package/dist/components/table/table-body.mjs +1 -1
- package/dist/components/table/table-head.js +108 -31
- package/dist/components/table/table-head.mjs +1 -1
- package/dist/components/table/table.js +140 -61
- package/dist/components/table/table.mjs +1 -1
- package/dist/components/toast/index.mjs +2 -2
- package/dist/components/toast/use-toast.mjs +2 -2
- package/dist/index.js +540 -433
- package/dist/index.mjs +19 -19
- package/package.json +1 -1
- package/dist/chunk-JOK735WN.mjs +0 -250
- package/dist/{chunk-ROXKJQSJ.mjs → chunk-4SDPS5R2.mjs} +3 -3
|
@@ -105,7 +105,7 @@ __export(table_body_exports, {
|
|
|
105
105
|
default: () => table_body_default
|
|
106
106
|
});
|
|
107
107
|
module.exports = __toCommonJS(table_body_exports);
|
|
108
|
-
var
|
|
108
|
+
var import_react7 = require("react");
|
|
109
109
|
|
|
110
110
|
// src/utils/clsx.ts
|
|
111
111
|
function clsx(...args) {
|
|
@@ -148,7 +148,7 @@ function toVal(mix) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// src/components/table/table.tsx
|
|
151
|
-
var
|
|
151
|
+
var import_react6 = require("react");
|
|
152
152
|
var import_tailwind_variants6 = require("tailwind-variants");
|
|
153
153
|
|
|
154
154
|
// src/utils/props.ts
|
|
@@ -171,6 +171,9 @@ var mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
|
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
173
|
|
|
174
|
+
// src/components/table/table-head.tsx
|
|
175
|
+
var import_react2 = require("react");
|
|
176
|
+
|
|
174
177
|
// src/components/checkbox/checkbox.tsx
|
|
175
178
|
var import_react = require("react");
|
|
176
179
|
|
|
@@ -629,20 +632,51 @@ var checkboxStyle = tv({
|
|
|
629
632
|
|
|
630
633
|
// src/components/table/table-head.tsx
|
|
631
634
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
632
|
-
|
|
635
|
+
function TableHeaderCell({
|
|
636
|
+
content,
|
|
637
|
+
column,
|
|
638
|
+
isCheckbox = false,
|
|
633
639
|
slots,
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
642
|
-
|
|
640
|
+
classNames
|
|
641
|
+
}) {
|
|
642
|
+
const thRef = (0, import_react2.useRef)(null);
|
|
643
|
+
const [showTitle, setShowTitle] = (0, import_react2.useState)(false);
|
|
644
|
+
const checkOverflow = (el) => {
|
|
645
|
+
if (el.scrollWidth > el.clientWidth) {
|
|
646
|
+
return true;
|
|
647
|
+
}
|
|
648
|
+
const children = Array.from(el.children);
|
|
649
|
+
for (const child of children) {
|
|
650
|
+
if (child.scrollWidth > child.clientWidth) {
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
return false;
|
|
655
|
+
};
|
|
656
|
+
const extractTextFromContent = (node) => {
|
|
657
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
658
|
+
return String(node);
|
|
659
|
+
}
|
|
660
|
+
if ((0, import_react2.isValidElement)(node)) {
|
|
661
|
+
return String(node.props.children || "");
|
|
662
|
+
}
|
|
663
|
+
return "";
|
|
664
|
+
};
|
|
665
|
+
(0, import_react2.useEffect)(() => {
|
|
666
|
+
if (thRef.current && !isCheckbox) {
|
|
667
|
+
setTimeout(() => {
|
|
668
|
+
if (thRef.current) {
|
|
669
|
+
setShowTitle(checkOverflow(thRef.current));
|
|
670
|
+
}
|
|
671
|
+
}, 0);
|
|
672
|
+
}
|
|
673
|
+
}, [content, isCheckbox]);
|
|
674
|
+
const titleText = !isCheckbox && showTitle ? extractTextFromContent(content) : void 0;
|
|
675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
643
676
|
"th",
|
|
644
677
|
{
|
|
645
|
-
|
|
678
|
+
ref: thRef,
|
|
679
|
+
className: clsx(slots.th({ class: classNames == null ? void 0 : classNames.th }), column == null ? void 0 : column.className, !isCheckbox && "truncate"),
|
|
646
680
|
style: isCheckbox ? {
|
|
647
681
|
width: "40px",
|
|
648
682
|
minWidth: "40px",
|
|
@@ -651,42 +685,66 @@ var TableHead = ({
|
|
|
651
685
|
flexGrow: 0,
|
|
652
686
|
boxSizing: "border-box"
|
|
653
687
|
} : column ? { ...getCellStyle(column), textAlign: "center" } : void 0,
|
|
688
|
+
title: titleText,
|
|
654
689
|
children: content
|
|
655
|
-
}
|
|
656
|
-
key
|
|
690
|
+
}
|
|
657
691
|
);
|
|
692
|
+
}
|
|
693
|
+
var TableHead = ({
|
|
694
|
+
slots,
|
|
695
|
+
columns,
|
|
696
|
+
color,
|
|
697
|
+
size,
|
|
698
|
+
rowCheckbox = false,
|
|
699
|
+
hasCheckedRows,
|
|
700
|
+
classNames,
|
|
701
|
+
onCheckAll
|
|
702
|
+
}) => {
|
|
658
703
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { className: slots.thead({ class: classNames == null ? void 0 : classNames.thead }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
|
|
659
|
-
columns.map((column, idx) =>
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
704
|
+
columns.map((column, idx) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
705
|
+
TableHeaderCell,
|
|
706
|
+
{
|
|
707
|
+
content: column.headerName,
|
|
708
|
+
column,
|
|
709
|
+
slots,
|
|
710
|
+
classNames
|
|
711
|
+
},
|
|
712
|
+
`${column.field}-${idx}`
|
|
713
|
+
)),
|
|
714
|
+
rowCheckbox && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
715
|
+
TableHeaderCell,
|
|
716
|
+
{
|
|
717
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-checkbox": true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
718
|
+
checkbox_default,
|
|
719
|
+
{
|
|
720
|
+
size,
|
|
721
|
+
checked: hasCheckedRows,
|
|
722
|
+
onChange: (e) => onCheckAll(e.target.checked)
|
|
723
|
+
}
|
|
724
|
+
) }),
|
|
725
|
+
isCheckbox: true,
|
|
726
|
+
slots,
|
|
727
|
+
classNames
|
|
728
|
+
},
|
|
729
|
+
"checkbox"
|
|
672
730
|
)
|
|
673
731
|
] }) });
|
|
674
732
|
};
|
|
675
733
|
var table_head_default = TableHead;
|
|
676
734
|
|
|
677
735
|
// src/components/pagination/pagination.tsx
|
|
678
|
-
var
|
|
736
|
+
var import_react5 = require("react");
|
|
679
737
|
|
|
680
738
|
// src/components/pagination/usePagination.ts
|
|
681
|
-
var
|
|
739
|
+
var import_react3 = require("react");
|
|
682
740
|
var usePagination = ({ currentPage, totalPage, groupSize, handleChangePage }) => {
|
|
683
|
-
const startPage = (0,
|
|
684
|
-
const endPage = (0,
|
|
685
|
-
const pageList = (0,
|
|
741
|
+
const startPage = (0, import_react3.useMemo)(() => Math.floor((currentPage - 1) / groupSize) * groupSize + 1, [currentPage, groupSize]);
|
|
742
|
+
const endPage = (0, import_react3.useMemo)(() => Math.min(startPage + groupSize - 1, totalPage), [startPage, groupSize, totalPage]);
|
|
743
|
+
const pageList = (0, import_react3.useMemo)(
|
|
686
744
|
() => Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i),
|
|
687
745
|
[startPage, endPage]
|
|
688
746
|
);
|
|
689
|
-
const handleClickMovePage = (0,
|
|
747
|
+
const handleClickMovePage = (0, import_react3.useCallback)(
|
|
690
748
|
(page) => (event) => {
|
|
691
749
|
event.preventDefault();
|
|
692
750
|
handleChangePage == null ? void 0 : handleChangePage(page);
|
|
@@ -703,7 +761,7 @@ var usePagination = ({ currentPage, totalPage, groupSize, handleChangePage }) =>
|
|
|
703
761
|
var usePagination_default = usePagination;
|
|
704
762
|
|
|
705
763
|
// src/components/input/input.tsx
|
|
706
|
-
var
|
|
764
|
+
var import_react4 = require("react");
|
|
707
765
|
|
|
708
766
|
// src/components/icon/template.tsx
|
|
709
767
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -5438,12 +5496,12 @@ var Icon_default = Icon;
|
|
|
5438
5496
|
|
|
5439
5497
|
// src/components/input/input.tsx
|
|
5440
5498
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
5441
|
-
var Input = (0,
|
|
5499
|
+
var Input = (0, import_react4.forwardRef)((originalProps, ref) => {
|
|
5442
5500
|
const [props, variantProps] = mapPropsVariants(originalProps, inputStyle.variantKeys);
|
|
5443
5501
|
const { classNames, label, helperMessage, errorMessage, startContent, endContent, ...inputProps } = props;
|
|
5444
|
-
const inputRef = (0,
|
|
5445
|
-
const slots = (0,
|
|
5446
|
-
const getContentProps = (0,
|
|
5502
|
+
const inputRef = (0, import_react4.useRef)(null);
|
|
5503
|
+
const slots = (0, import_react4.useMemo)(() => inputStyle({ ...variantProps }), [variantProps]);
|
|
5504
|
+
const getContentProps = (0, import_react4.useCallback)(
|
|
5447
5505
|
() => ({
|
|
5448
5506
|
className: clsx(
|
|
5449
5507
|
slots.content({ class: classNames == null ? void 0 : classNames.content }),
|
|
@@ -5454,13 +5512,13 @@ var Input = (0, import_react3.forwardRef)((originalProps, ref) => {
|
|
|
5454
5512
|
[slots, classNames, originalProps.size, inputProps.readOnly]
|
|
5455
5513
|
);
|
|
5456
5514
|
const renderStartContent = () => {
|
|
5457
|
-
if ((0,
|
|
5515
|
+
if ((0, import_react4.isValidElement)(startContent)) {
|
|
5458
5516
|
const existingProps = startContent.props;
|
|
5459
5517
|
const mergedProps = {
|
|
5460
5518
|
...getContentProps(),
|
|
5461
5519
|
className: `${getContentProps().className || ""} ${existingProps.className || ""}`.trim()
|
|
5462
5520
|
};
|
|
5463
|
-
return (0,
|
|
5521
|
+
return (0, import_react4.cloneElement)(startContent, mergedProps);
|
|
5464
5522
|
} else {
|
|
5465
5523
|
const contentProps = getContentProps();
|
|
5466
5524
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ...contentProps, children: startContent });
|
|
@@ -5479,13 +5537,13 @@ var Input = (0, import_react3.forwardRef)((originalProps, ref) => {
|
|
|
5479
5537
|
}
|
|
5480
5538
|
);
|
|
5481
5539
|
const renderContentWithIcon = () => {
|
|
5482
|
-
if ((0,
|
|
5540
|
+
if ((0, import_react4.isValidElement)(endContent)) {
|
|
5483
5541
|
const existingProps = endContent.props;
|
|
5484
5542
|
const mergedProps = {
|
|
5485
5543
|
...getContentProps(),
|
|
5486
5544
|
className: `${getContentProps().className || ""} ${existingProps.className || ""}`.trim()
|
|
5487
5545
|
};
|
|
5488
|
-
return (0,
|
|
5546
|
+
return (0, import_react4.cloneElement)(endContent, mergedProps);
|
|
5489
5547
|
} else if (errorMessage && errorMessage.length > 0) {
|
|
5490
5548
|
const iconProps = { ...getContentProps(), className: getContentProps().className };
|
|
5491
5549
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ...iconProps, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon_default, { name: "exclamation-circle", fill: true, size: originalProps.size }) });
|
|
@@ -5822,7 +5880,7 @@ var inputStyle = tv(
|
|
|
5822
5880
|
|
|
5823
5881
|
// src/components/pagination/pagination.tsx
|
|
5824
5882
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
5825
|
-
var Pagination = (0,
|
|
5883
|
+
var Pagination = (0, import_react5.forwardRef)((originalProps, ref) => {
|
|
5826
5884
|
const [props, variantProps] = mapPropsVariants(originalProps, paginationStyle.variantKeys);
|
|
5827
5885
|
const {
|
|
5828
5886
|
classNames,
|
|
@@ -5836,12 +5894,12 @@ var Pagination = (0, import_react4.forwardRef)((originalProps, ref) => {
|
|
|
5836
5894
|
variant,
|
|
5837
5895
|
size
|
|
5838
5896
|
} = { ...props, ...variantProps };
|
|
5839
|
-
const [inputPage, setInputPage] = (0,
|
|
5897
|
+
const [inputPage, setInputPage] = (0, import_react5.useState)(currentPage);
|
|
5840
5898
|
const isFirstPageDisabled = currentPage <= 1;
|
|
5841
5899
|
const isPrevPageDisabled = currentPage <= 1;
|
|
5842
5900
|
const isNextPageDisabled = currentPage >= totalPage;
|
|
5843
5901
|
const isLastPageDisabled = currentPage >= totalPage;
|
|
5844
|
-
const slots = (0,
|
|
5902
|
+
const slots = (0, import_react5.useMemo)(() => paginationStyle(variantProps), [variantProps]);
|
|
5845
5903
|
const { pageList, handleClickMovePage } = usePagination_default({
|
|
5846
5904
|
currentPage,
|
|
5847
5905
|
totalPage,
|
|
@@ -6209,7 +6267,7 @@ var scrollAreaStyle = (0, import_tailwind_variants5.tv)({
|
|
|
6209
6267
|
|
|
6210
6268
|
// src/components/table/table.tsx
|
|
6211
6269
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
6212
|
-
var Table = (0,
|
|
6270
|
+
var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
6213
6271
|
const [props, variantProps] = mapPropsVariants(originalProps, tableStyle.variantKeys);
|
|
6214
6272
|
const {
|
|
6215
6273
|
rows,
|
|
@@ -6234,8 +6292,8 @@ var Table = (0, import_react5.forwardRef)((originalProps, ref) => {
|
|
|
6234
6292
|
} = { ...props, ...variantProps };
|
|
6235
6293
|
const { page = 1, perPage = 15 } = pagination || {};
|
|
6236
6294
|
const showPagination = pagination && totalData > 0;
|
|
6237
|
-
const [checkedRowIds, setCheckedRowIds] = (0,
|
|
6238
|
-
const tableMinWidth = (0,
|
|
6295
|
+
const [checkedRowIds, setCheckedRowIds] = (0, import_react6.useState)(new Set(checkedRows == null ? void 0 : checkedRows.map((row) => row.id)));
|
|
6296
|
+
const tableMinWidth = (0, import_react6.useMemo)(() => {
|
|
6239
6297
|
const columnsWidth = columns.reduce((total, column) => {
|
|
6240
6298
|
if (column.width) return total + column.width;
|
|
6241
6299
|
if (column.minWidth) return total + column.minWidth;
|
|
@@ -6244,10 +6302,10 @@ var Table = (0, import_react5.forwardRef)((originalProps, ref) => {
|
|
|
6244
6302
|
const checkboxWidth = rowCheckbox ? 40 : 0;
|
|
6245
6303
|
return columnsWidth + checkboxWidth;
|
|
6246
6304
|
}, [columns, rowCheckbox]);
|
|
6247
|
-
(0,
|
|
6305
|
+
(0, import_react6.useEffect)(() => {
|
|
6248
6306
|
onCheckedRowsChange == null ? void 0 : onCheckedRowsChange(getCheckedRowData(checkedRowIds));
|
|
6249
6307
|
}, [checkedRowIds]);
|
|
6250
|
-
(0,
|
|
6308
|
+
(0, import_react6.useEffect)(() => {
|
|
6251
6309
|
const currentRowIds = new Set(rows.map((row) => row.id));
|
|
6252
6310
|
const ids = Array.from(checkedRowIds);
|
|
6253
6311
|
const hasValidCheckedRows = ids.every((id) => currentRowIds.has(id));
|
|
@@ -6255,7 +6313,7 @@ var Table = (0, import_react5.forwardRef)((originalProps, ref) => {
|
|
|
6255
6313
|
setCheckedRowIds(new Set(checkedRows == null ? void 0 : checkedRows.map((row) => row.id)));
|
|
6256
6314
|
}
|
|
6257
6315
|
}, [rows.map((row) => row.id).join(",")]);
|
|
6258
|
-
(0,
|
|
6316
|
+
(0, import_react6.useImperativeHandle)(
|
|
6259
6317
|
ref,
|
|
6260
6318
|
() => ({
|
|
6261
6319
|
checkedRowIds,
|
|
@@ -6282,7 +6340,7 @@ var Table = (0, import_react5.forwardRef)((originalProps, ref) => {
|
|
|
6282
6340
|
onRowClick == null ? void 0 : onRowClick(row, index, event);
|
|
6283
6341
|
};
|
|
6284
6342
|
const getCheckedRowData = (checked) => rows.filter((row) => checked.has(row.id));
|
|
6285
|
-
const slots = (0,
|
|
6343
|
+
const slots = (0, import_react6.useMemo)(
|
|
6286
6344
|
() => tableStyle({ ...variantProps, rowClickable: typeof onRowClick === "function" }),
|
|
6287
6345
|
[variantProps, onRowClick]
|
|
6288
6346
|
);
|
|
@@ -6609,25 +6667,46 @@ function TableCell({
|
|
|
6609
6667
|
slots,
|
|
6610
6668
|
classNames
|
|
6611
6669
|
}) {
|
|
6612
|
-
var _a;
|
|
6670
|
+
var _a, _b;
|
|
6613
6671
|
const value = row[column.field];
|
|
6614
6672
|
const formattedValue = ((_a = column.valueFormatter) == null ? void 0 : _a.call(column, { value, field: column.field })) || value;
|
|
6615
6673
|
const content = column.renderCell ? column.renderCell({ id: row.id, field: column.field, value, formattedValue, row }) : formattedValue;
|
|
6616
|
-
const tdRef = (0,
|
|
6617
|
-
const [showTitle, setShowTitle] = (0,
|
|
6618
|
-
const checkOverflow = (el) =>
|
|
6619
|
-
|
|
6674
|
+
const tdRef = (0, import_react7.useRef)(null);
|
|
6675
|
+
const [showTitle, setShowTitle] = (0, import_react7.useState)(false);
|
|
6676
|
+
const checkOverflow = (el) => {
|
|
6677
|
+
if (el.scrollWidth > el.clientWidth) {
|
|
6678
|
+
return true;
|
|
6679
|
+
}
|
|
6680
|
+
const children = Array.from(el.children);
|
|
6681
|
+
for (const child of children) {
|
|
6682
|
+
if (child.scrollWidth > child.clientWidth) {
|
|
6683
|
+
return true;
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6686
|
+
return false;
|
|
6687
|
+
};
|
|
6688
|
+
(0, import_react7.useEffect)(() => {
|
|
6620
6689
|
if (tdRef.current) {
|
|
6621
|
-
|
|
6690
|
+
setTimeout(() => {
|
|
6691
|
+
if (tdRef.current) {
|
|
6692
|
+
setShowTitle(checkOverflow(tdRef.current));
|
|
6693
|
+
}
|
|
6694
|
+
}, 0);
|
|
6622
6695
|
}
|
|
6623
6696
|
}, [content]);
|
|
6624
6697
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6625
6698
|
"td",
|
|
6626
6699
|
{
|
|
6627
6700
|
ref: tdRef,
|
|
6628
|
-
className: clsx(
|
|
6701
|
+
className: clsx(
|
|
6702
|
+
slots.td(),
|
|
6703
|
+
classNames == null ? void 0 : classNames.td,
|
|
6704
|
+
column.className,
|
|
6705
|
+
"truncate",
|
|
6706
|
+
"[&>*]:block [&>*]:w-full [&>*]:truncate"
|
|
6707
|
+
),
|
|
6629
6708
|
style: { ...getCellStyle(column), maxWidth: column.width || "150px" },
|
|
6630
|
-
title: showTitle ? String(content) : void 0,
|
|
6709
|
+
title: showTitle ? String(((_b = value == null ? void 0 : value.props) == null ? void 0 : _b.children) || content || "") : void 0,
|
|
6631
6710
|
children: content
|
|
6632
6711
|
},
|
|
6633
6712
|
`${row.id}-${column.field}-${colIdx}-${rowIndex}`
|
|
@@ -105,6 +105,7 @@ __export(table_head_exports, {
|
|
|
105
105
|
default: () => table_head_default
|
|
106
106
|
});
|
|
107
107
|
module.exports = __toCommonJS(table_head_exports);
|
|
108
|
+
var import_react7 = require("react");
|
|
108
109
|
|
|
109
110
|
// src/utils/clsx.ts
|
|
110
111
|
function clsx(...args) {
|
|
@@ -639,25 +640,46 @@ function TableCell({
|
|
|
639
640
|
slots,
|
|
640
641
|
classNames
|
|
641
642
|
}) {
|
|
642
|
-
var _a;
|
|
643
|
+
var _a, _b;
|
|
643
644
|
const value = row[column.field];
|
|
644
645
|
const formattedValue = ((_a = column.valueFormatter) == null ? void 0 : _a.call(column, { value, field: column.field })) || value;
|
|
645
646
|
const content = column.renderCell ? column.renderCell({ id: row.id, field: column.field, value, formattedValue, row }) : formattedValue;
|
|
646
647
|
const tdRef = (0, import_react2.useRef)(null);
|
|
647
648
|
const [showTitle, setShowTitle] = (0, import_react2.useState)(false);
|
|
648
|
-
const checkOverflow = (el) =>
|
|
649
|
+
const checkOverflow = (el) => {
|
|
650
|
+
if (el.scrollWidth > el.clientWidth) {
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
const children = Array.from(el.children);
|
|
654
|
+
for (const child of children) {
|
|
655
|
+
if (child.scrollWidth > child.clientWidth) {
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return false;
|
|
660
|
+
};
|
|
649
661
|
(0, import_react2.useEffect)(() => {
|
|
650
662
|
if (tdRef.current) {
|
|
651
|
-
|
|
663
|
+
setTimeout(() => {
|
|
664
|
+
if (tdRef.current) {
|
|
665
|
+
setShowTitle(checkOverflow(tdRef.current));
|
|
666
|
+
}
|
|
667
|
+
}, 0);
|
|
652
668
|
}
|
|
653
669
|
}, [content]);
|
|
654
670
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
655
671
|
"td",
|
|
656
672
|
{
|
|
657
673
|
ref: tdRef,
|
|
658
|
-
className: clsx(
|
|
674
|
+
className: clsx(
|
|
675
|
+
slots.td(),
|
|
676
|
+
classNames == null ? void 0 : classNames.td,
|
|
677
|
+
column.className,
|
|
678
|
+
"truncate",
|
|
679
|
+
"[&>*]:block [&>*]:w-full [&>*]:truncate"
|
|
680
|
+
),
|
|
659
681
|
style: { ...getCellStyle(column), maxWidth: column.width || "150px" },
|
|
660
|
-
title: showTitle ? String(content) : void 0,
|
|
682
|
+
title: showTitle ? String(((_b = value == null ? void 0 : value.props) == null ? void 0 : _b.children) || content || "") : void 0,
|
|
661
683
|
children: content
|
|
662
684
|
},
|
|
663
685
|
`${row.id}-${column.field}-${colIdx}-${rowIndex}`
|
|
@@ -6653,20 +6675,51 @@ var getCellStyle = (column) => {
|
|
|
6653
6675
|
|
|
6654
6676
|
// src/components/table/table-head.tsx
|
|
6655
6677
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6656
|
-
|
|
6678
|
+
function TableHeaderCell({
|
|
6679
|
+
content,
|
|
6680
|
+
column,
|
|
6681
|
+
isCheckbox = false,
|
|
6657
6682
|
slots,
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
}
|
|
6666
|
-
|
|
6683
|
+
classNames
|
|
6684
|
+
}) {
|
|
6685
|
+
const thRef = (0, import_react7.useRef)(null);
|
|
6686
|
+
const [showTitle, setShowTitle] = (0, import_react7.useState)(false);
|
|
6687
|
+
const checkOverflow = (el) => {
|
|
6688
|
+
if (el.scrollWidth > el.clientWidth) {
|
|
6689
|
+
return true;
|
|
6690
|
+
}
|
|
6691
|
+
const children = Array.from(el.children);
|
|
6692
|
+
for (const child of children) {
|
|
6693
|
+
if (child.scrollWidth > child.clientWidth) {
|
|
6694
|
+
return true;
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
return false;
|
|
6698
|
+
};
|
|
6699
|
+
const extractTextFromContent = (node) => {
|
|
6700
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
6701
|
+
return String(node);
|
|
6702
|
+
}
|
|
6703
|
+
if ((0, import_react7.isValidElement)(node)) {
|
|
6704
|
+
return String(node.props.children || "");
|
|
6705
|
+
}
|
|
6706
|
+
return "";
|
|
6707
|
+
};
|
|
6708
|
+
(0, import_react7.useEffect)(() => {
|
|
6709
|
+
if (thRef.current && !isCheckbox) {
|
|
6710
|
+
setTimeout(() => {
|
|
6711
|
+
if (thRef.current) {
|
|
6712
|
+
setShowTitle(checkOverflow(thRef.current));
|
|
6713
|
+
}
|
|
6714
|
+
}, 0);
|
|
6715
|
+
}
|
|
6716
|
+
}, [content, isCheckbox]);
|
|
6717
|
+
const titleText = !isCheckbox && showTitle ? extractTextFromContent(content) : void 0;
|
|
6718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6667
6719
|
"th",
|
|
6668
6720
|
{
|
|
6669
|
-
|
|
6721
|
+
ref: thRef,
|
|
6722
|
+
className: clsx(slots.th({ class: classNames == null ? void 0 : classNames.th }), column == null ? void 0 : column.className, !isCheckbox && "truncate"),
|
|
6670
6723
|
style: isCheckbox ? {
|
|
6671
6724
|
width: "40px",
|
|
6672
6725
|
minWidth: "40px",
|
|
@@ -6675,24 +6728,48 @@ var TableHead = ({
|
|
|
6675
6728
|
flexGrow: 0,
|
|
6676
6729
|
boxSizing: "border-box"
|
|
6677
6730
|
} : column ? { ...getCellStyle(column), textAlign: "center" } : void 0,
|
|
6731
|
+
title: titleText,
|
|
6678
6732
|
children: content
|
|
6679
|
-
}
|
|
6680
|
-
key
|
|
6733
|
+
}
|
|
6681
6734
|
);
|
|
6735
|
+
}
|
|
6736
|
+
var TableHead = ({
|
|
6737
|
+
slots,
|
|
6738
|
+
columns,
|
|
6739
|
+
color,
|
|
6740
|
+
size,
|
|
6741
|
+
rowCheckbox = false,
|
|
6742
|
+
hasCheckedRows,
|
|
6743
|
+
classNames,
|
|
6744
|
+
onCheckAll
|
|
6745
|
+
}) => {
|
|
6682
6746
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("thead", { className: slots.thead({ class: classNames == null ? void 0 : classNames.thead }), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
|
|
6683
|
-
columns.map((column, idx) =>
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6747
|
+
columns.map((column, idx) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6748
|
+
TableHeaderCell,
|
|
6749
|
+
{
|
|
6750
|
+
content: column.headerName,
|
|
6751
|
+
column,
|
|
6752
|
+
slots,
|
|
6753
|
+
classNames
|
|
6754
|
+
},
|
|
6755
|
+
`${column.field}-${idx}`
|
|
6756
|
+
)),
|
|
6757
|
+
rowCheckbox && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6758
|
+
TableHeaderCell,
|
|
6759
|
+
{
|
|
6760
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { "data-checkbox": true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6761
|
+
checkbox_default,
|
|
6762
|
+
{
|
|
6763
|
+
size,
|
|
6764
|
+
checked: hasCheckedRows,
|
|
6765
|
+
onChange: (e) => onCheckAll(e.target.checked)
|
|
6766
|
+
}
|
|
6767
|
+
) }),
|
|
6768
|
+
isCheckbox: true,
|
|
6769
|
+
slots,
|
|
6770
|
+
classNames
|
|
6771
|
+
},
|
|
6772
|
+
"checkbox"
|
|
6696
6773
|
)
|
|
6697
6774
|
] }) });
|
|
6698
6775
|
};
|