@canvas-components/react-list-table 0.2.6 → 0.3.1
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/README.md +195 -14
- package/assets/examples/basic.gif +0 -0
- package/assets/examples/cached-columns.gif +0 -0
- package/assets/examples/carousel-scroll.gif +0 -0
- package/assets/examples/cell-content.gif +0 -0
- package/assets/examples/context-menu.gif +0 -0
- package/assets/examples/data-format.gif +0 -0
- package/assets/examples/draggable.gif +0 -0
- package/assets/examples/editable-cell.gif +0 -0
- package/assets/examples/ellipsis-tooltip.gif +0 -0
- package/assets/examples/empty-state.gif +0 -0
- package/assets/examples/expandable.gif +0 -0
- package/assets/examples/header-actions.gif +0 -0
- package/assets/examples/highlight-mode.gif +0 -0
- package/assets/examples/merged-cells.gif +0 -0
- package/assets/examples/million-rows.gif +0 -0
- package/assets/examples/multi-header.gif +0 -0
- package/assets/examples/pagination.gif +0 -0
- package/assets/examples/remote-query.gif +0 -0
- package/assets/examples/resize.gif +0 -0
- package/assets/examples/row-drag.gif +0 -0
- package/assets/examples/row-selection.gif +0 -0
- package/assets/examples/sized.gif +0 -0
- package/assets/examples/striped.gif +0 -0
- package/assets/examples/summary-row.gif +0 -0
- package/assets/examples/super.gif +0 -0
- package/assets/examples/theme.gif +0 -0
- package/dist/index.cjs +47 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -586,6 +586,14 @@ function DensityMenu(props) {
|
|
|
586
586
|
onClick: () => {
|
|
587
587
|
onChange("compact");
|
|
588
588
|
}
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
key: "density-auto",
|
|
592
|
+
label: "\u81EA\u9002\u5E94",
|
|
593
|
+
selected: value === "auto",
|
|
594
|
+
onClick: () => {
|
|
595
|
+
onChange("auto");
|
|
596
|
+
}
|
|
589
597
|
}
|
|
590
598
|
]
|
|
591
599
|
}
|
|
@@ -3352,7 +3360,7 @@ function resolveSortableTransform(index, sourceIndex, targetIndex, height) {
|
|
|
3352
3360
|
}
|
|
3353
3361
|
|
|
3354
3362
|
// src/features/toolbar/style.css
|
|
3355
|
-
styleInject('.react-list-table-titlebar {\n height: 44px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 0;\n box-sizing: border-box;\n background: #fff;\n}\n.react-list-table-title {\n min-width: 0;\n color: #1f2937;\n font-size: 14px;\n font-weight: 600;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.react-list-table-tools {\n display: flex;\n align-items: center;\n gap: 14px;\n color: #475569;\n}\n.react-list-table-tool-wrap {\n position: relative;\n display: inline-flex;\n}\n.react-list-table-tool {\n width: 20px;\n height: 24px;\n padding: 0;\n border: 0;\n color: inherit;\n background: transparent;\n font: 16px/24px sans-serif;\n cursor: pointer;\n}\n.react-list-table-tool:hover {\n color: #1677ff;\n}\n.react-list-table-tool-menu,\n.react-list-table-column-setting {\n position: absolute;\n z-index: 120;\n top: 28px;\n right: 0;\n min-width: 112px;\n padding: 6px;\n border: 1px solid #e5e7eb;\n border-radius: 6px;\n background: #fff;\n box-shadow: 0 8px 24px rgba(15, 23, 42, .14);\n}\n.react-list-table-tool-menu button {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 6px 10px;\n border: 0;\n border-radius: 4px;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.react-list-table-tool-menu button.active::after {\n content: "\\2713";\n margin-left: 12px;\n font-size: 12px;\n}\n.react-list-table-tool-menu button:hover,\n.react-list-table-tool-menu button.active {\n color: #1677ff;\n background: #e6f4ff;\n}\n.react-list-table-column-setting {\n width: 328px;\n max-height: 360px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.react-list-table-column-setting-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 4px 6px 8px;\n border-bottom: 1px solid #f0f0f0;\n flex: 0 0 auto;\n}\n.react-list-table-column-setting-head button {\n border: 0;\n color: #1677ff;\n background: transparent;\n cursor: pointer;\n}\n.react-list-table-column-setting-body {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n.react-list-table-column-item {\n display: flex;\n align-items: center;\n gap: 8px;\n justify-content: space-between;\n padding: 7px 6px;\n box-sizing: border-box;\n cursor: pointer;\n}\n.react-list-table-column-main,\n.react-list-table-column-actions {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n}\n.react-list-table-column-main {\n min-width: 0;\n}\n.react-list-table-column-actions {\n flex: 0 0 auto;\n}\n.react-list-table-column-actions > .canvas-react-select-wrap {\n flex: 0 0 96px;\n width: 96px;\n height: 24px;\n}\n.react-list-table-column-label {\n min-width: 64px;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.react-list-table-column-width-input {\n height: 22px;\n padding-inline: 5px;\n}\n.react-list-table-column-fixed-input {\n height: 22px;\n padding-inline: 6px;\n font-size: 12px;\n}\n.react-list-table-column-setting label.dragging {\n opacity: 0.45;\n background: #e6f4ff;\n}\n.react-list-table-column-setting [data-sortable-key].dragging {\n opacity: 0.28;\n}\n.react-list-table-column-drag {\n color: #94a3b8;\n display: inline-flex;\n font-size: 14px;\n cursor: grab;\n user-select: none;\n}\nbody.react-list-table-sorting,\nbody.react-list-table-sorting * {\n cursor: grabbing !important;\n}\n.react-list-table-sort-overlay {\n position: fixed;\n z-index: 1400;\n display: block;\n padding: 0;\n box-sizing: border-box;\n color: #334155;\n background: #fff;\n border: 1px solid #91caff;\n border-radius: 6px;\n box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);\n pointer-events: none;\n}\n.react-list-table-sort-overlay .react-list-table-column-item {\n width: 100%;\n height: 100%;\n}\n');
|
|
3363
|
+
styleInject('.react-list-table-shell {\n background: #fff;\n}\n.react-list-table-titlebar {\n height: 44px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 0;\n box-sizing: border-box;\n background: #fff;\n}\n.react-list-table-shell-fullscreen {\n width: 100% !important;\n height: 100% !important;\n}\n.react-list-table-shell-fullscreen .canvas-list-table-root {\n height: 100% !important;\n}\n.react-list-table-title {\n min-width: 0;\n color: #1f2937;\n font-size: 14px;\n font-weight: 600;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.react-list-table-tools {\n display: flex;\n align-items: center;\n gap: 14px;\n color: #475569;\n}\n.react-list-table-tool-wrap {\n position: relative;\n display: inline-flex;\n}\n.react-list-table-tool {\n width: 20px;\n height: 24px;\n padding: 0;\n border: 0;\n color: inherit;\n background: transparent;\n font: 16px/24px sans-serif;\n cursor: pointer;\n}\n.react-list-table-tool:hover {\n color: #1677ff;\n}\n.react-list-table-tool-menu,\n.react-list-table-column-setting {\n position: absolute;\n z-index: 120;\n top: 28px;\n right: 0;\n min-width: 112px;\n padding: 6px;\n border: 1px solid #e5e7eb;\n border-radius: 6px;\n background: #fff;\n box-shadow: 0 8px 24px rgba(15, 23, 42, .14);\n}\n.react-list-table-tool-menu button {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 6px 10px;\n border: 0;\n border-radius: 4px;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.react-list-table-tool-menu button.active::after {\n content: "\\2713";\n margin-left: 12px;\n font-size: 12px;\n}\n.react-list-table-tool-menu button:hover,\n.react-list-table-tool-menu button.active {\n color: #1677ff;\n background: #e6f4ff;\n}\n.react-list-table-column-setting {\n width: 328px;\n max-height: 360px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.react-list-table-column-setting-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 4px 6px 8px;\n border-bottom: 1px solid #f0f0f0;\n flex: 0 0 auto;\n}\n.react-list-table-column-setting-head button {\n border: 0;\n color: #1677ff;\n background: transparent;\n cursor: pointer;\n}\n.react-list-table-column-setting-body {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n.react-list-table-column-item {\n display: flex;\n align-items: center;\n gap: 8px;\n justify-content: space-between;\n padding: 7px 6px;\n box-sizing: border-box;\n cursor: pointer;\n}\n.react-list-table-column-main,\n.react-list-table-column-actions {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n}\n.react-list-table-column-main {\n min-width: 0;\n}\n.react-list-table-column-actions {\n flex: 0 0 auto;\n}\n.react-list-table-column-actions > .canvas-react-select-wrap {\n flex: 0 0 96px;\n width: 96px;\n height: 24px;\n}\n.react-list-table-column-label {\n min-width: 64px;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.react-list-table-column-width-input {\n height: 22px;\n padding-inline: 5px;\n}\n.react-list-table-column-fixed-input {\n height: 22px;\n padding-inline: 6px;\n font-size: 12px;\n}\n.react-list-table-column-setting label.dragging {\n opacity: 0.45;\n background: #e6f4ff;\n}\n.react-list-table-column-setting [data-sortable-key].dragging {\n opacity: 0.28;\n}\n.react-list-table-column-drag {\n color: #94a3b8;\n display: inline-flex;\n font-size: 14px;\n cursor: grab;\n user-select: none;\n}\nbody.react-list-table-sorting,\nbody.react-list-table-sorting * {\n cursor: grabbing !important;\n}\n.react-list-table-sort-overlay {\n position: fixed;\n z-index: 1400;\n display: block;\n padding: 0;\n box-sizing: border-box;\n color: #334155;\n background: #fff;\n border: 1px solid #91caff;\n border-radius: 6px;\n box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);\n pointer-events: none;\n}\n.react-list-table-sort-overlay .react-list-table-column-item {\n width: 100%;\n height: 100%;\n}\n');
|
|
3356
3364
|
function ReactTableToolbar(props) {
|
|
3357
3365
|
const { toolbar, title } = props;
|
|
3358
3366
|
const [densityOpen, setDensityOpen] = useState(false);
|
|
@@ -3376,11 +3384,14 @@ function ReactTableToolbar(props) {
|
|
|
3376
3384
|
useEffect(() => {
|
|
3377
3385
|
const handleFullscreenChange = () => {
|
|
3378
3386
|
const fullscreenNode = (typeof toolbar === "object" ? toolbar.getFullscreenNode?.() : null) ?? props.hostRef.current;
|
|
3379
|
-
|
|
3387
|
+
const nextIsFullscreen = document.fullscreenElement === fullscreenNode;
|
|
3388
|
+
setIsFullscreen(nextIsFullscreen);
|
|
3389
|
+
props.onFullscreenChange?.(nextIsFullscreen);
|
|
3380
3390
|
};
|
|
3391
|
+
handleFullscreenChange();
|
|
3381
3392
|
document.addEventListener("fullscreenchange", handleFullscreenChange);
|
|
3382
3393
|
return () => document.removeEventListener("fullscreenchange", handleFullscreenChange);
|
|
3383
|
-
}, [props.hostRef, toolbar]);
|
|
3394
|
+
}, [props.hostRef, props.onFullscreenChange, toolbar]);
|
|
3384
3395
|
if (!title && !hasToolbar) return null;
|
|
3385
3396
|
const config = typeof toolbar === "object" ? toolbar : {};
|
|
3386
3397
|
return /* @__PURE__ */ jsxs("div", { className: "react-list-table-titlebar", ref: rootRef, children: [
|
|
@@ -3712,6 +3723,12 @@ function useReactListTableState(options) {
|
|
|
3712
3723
|
}
|
|
3713
3724
|
|
|
3714
3725
|
// src/components/build-list-table-options.ts
|
|
3726
|
+
function resolveDensityLinkedHeight(densityOverride, configuredHeight) {
|
|
3727
|
+
return typeof densityOverride === "number" ? densityOverride : configuredHeight;
|
|
3728
|
+
}
|
|
3729
|
+
function resolveFullscreenTableSize(width, height, isFullscreen) {
|
|
3730
|
+
return isFullscreen ? { width: "100%", height: "100%" } : { width, height };
|
|
3731
|
+
}
|
|
3715
3732
|
function buildListTableOptions(props) {
|
|
3716
3733
|
const {
|
|
3717
3734
|
width,
|
|
@@ -3726,6 +3743,7 @@ function buildListTableOptions(props) {
|
|
|
3726
3743
|
return {
|
|
3727
3744
|
type: "list",
|
|
3728
3745
|
...restProps,
|
|
3746
|
+
rowHeight: restProps.rowHeight ?? 32,
|
|
3729
3747
|
width: scroll?.x === true ? "100%" : scroll?.x ?? width,
|
|
3730
3748
|
height: scroll?.y ?? height,
|
|
3731
3749
|
emptyText: locale?.emptyText ?? emptyText,
|
|
@@ -3776,9 +3794,8 @@ function ReactListTableInner(props, ref) {
|
|
|
3776
3794
|
toolbar
|
|
3777
3795
|
} = props;
|
|
3778
3796
|
const shellRef = useRef(null);
|
|
3779
|
-
const [
|
|
3780
|
-
|
|
3781
|
-
);
|
|
3797
|
+
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
3798
|
+
const [densityOverride, setDensityOverride] = useState(null);
|
|
3782
3799
|
const [columnVisibility, setColumnVisibility] = useState(() => /* @__PURE__ */ new Map());
|
|
3783
3800
|
const [columnOrders, setColumnOrders] = useState(
|
|
3784
3801
|
() => /* @__PURE__ */ new Map()
|
|
@@ -3794,8 +3811,14 @@ function ReactListTableInner(props, ref) {
|
|
|
3794
3811
|
[columns, columnVisibility, columnOrders, columnConfig]
|
|
3795
3812
|
);
|
|
3796
3813
|
const resolvedRowHeight = densityOverride ?? rowHeight;
|
|
3797
|
-
const resolvedHeaderRowHeight =
|
|
3798
|
-
|
|
3814
|
+
const resolvedHeaderRowHeight = resolveDensityLinkedHeight(
|
|
3815
|
+
densityOverride,
|
|
3816
|
+
headerRowHeight
|
|
3817
|
+
);
|
|
3818
|
+
const resolvedSummaryRowHeight = resolveDensityLinkedHeight(
|
|
3819
|
+
densityOverride,
|
|
3820
|
+
summaryRowHeight
|
|
3821
|
+
);
|
|
3799
3822
|
const options = useMemo(() => {
|
|
3800
3823
|
const nextOptions = buildListTableOptions({
|
|
3801
3824
|
width,
|
|
@@ -3832,8 +3855,14 @@ function ReactListTableInner(props, ref) {
|
|
|
3832
3855
|
rowDrag,
|
|
3833
3856
|
debug
|
|
3834
3857
|
});
|
|
3858
|
+
const fullscreenSize = resolveFullscreenTableSize(
|
|
3859
|
+
nextOptions.width,
|
|
3860
|
+
nextOptions.height,
|
|
3861
|
+
isFullscreen
|
|
3862
|
+
);
|
|
3835
3863
|
return {
|
|
3836
3864
|
...nextOptions,
|
|
3865
|
+
...fullscreenSize,
|
|
3837
3866
|
ui: {
|
|
3838
3867
|
...nextOptions.ui,
|
|
3839
3868
|
onDensityChange: setDensityOverride
|
|
@@ -3872,7 +3901,8 @@ function ReactListTableInner(props, ref) {
|
|
|
3872
3901
|
draggable,
|
|
3873
3902
|
tableId,
|
|
3874
3903
|
rowDrag,
|
|
3875
|
-
debug
|
|
3904
|
+
debug,
|
|
3905
|
+
isFullscreen
|
|
3876
3906
|
]);
|
|
3877
3907
|
const {
|
|
3878
3908
|
containerRef,
|
|
@@ -3915,7 +3945,11 @@ function ReactListTableInner(props, ref) {
|
|
|
3915
3945
|
"div",
|
|
3916
3946
|
{
|
|
3917
3947
|
ref: shellRef,
|
|
3918
|
-
className
|
|
3948
|
+
className: [
|
|
3949
|
+
"react-list-table-shell",
|
|
3950
|
+
isFullscreen ? "react-list-table-shell-fullscreen" : "",
|
|
3951
|
+
className
|
|
3952
|
+
].filter(Boolean).join(" "),
|
|
3919
3953
|
style: {
|
|
3920
3954
|
position: "relative",
|
|
3921
3955
|
display: "flex",
|
|
@@ -3930,8 +3964,9 @@ function ReactListTableInner(props, ref) {
|
|
|
3930
3964
|
title,
|
|
3931
3965
|
toolbar,
|
|
3932
3966
|
columns: resolvedColumns,
|
|
3933
|
-
density: resolvedRowHeight
|
|
3967
|
+
density: resolvedRowHeight ?? 32,
|
|
3934
3968
|
hostRef: shellRef,
|
|
3969
|
+
onFullscreenChange: setIsFullscreen,
|
|
3935
3970
|
onExport: (options2) => tableRef.current?.exportXlsx(options2),
|
|
3936
3971
|
onDensityChange: (density) => {
|
|
3937
3972
|
tableRef.current?.changeDensity(density);
|
|
@@ -3985,6 +4020,7 @@ function ReactListTableInner(props, ref) {
|
|
|
3985
4020
|
"div",
|
|
3986
4021
|
{
|
|
3987
4022
|
ref: containerRef,
|
|
4023
|
+
className: "react-list-table-host",
|
|
3988
4024
|
style: { flex: 1, minWidth: 0, width: "100%", minHeight: 0 },
|
|
3989
4025
|
children: /* @__PURE__ */ jsx(ReactTablePaginationView, { config: paginationConfig })
|
|
3990
4026
|
}
|