beautiful-grid 1.0.12 → 1.0.14
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/cjs/BGrid.js +17 -6
- package/cjs/components/Table.js +44 -3
- package/cjs/components/TableSummary.js +25 -34
- package/cjs/components/TableSummaryFronzen.js +36 -34
- package/cjs/store/createAppStore.js +2 -0
- package/cjs/utils/columnVisibility.js +17 -14
- package/cjs/utils/exportCsv.js +129 -0
- package/cjs/utils/exportData.js +230 -0
- package/cjs/utils/exportExcel.js +317 -0
- package/cjs/utils/index.js +4 -0
- package/cjs/utils/summary.js +55 -0
- package/esm/BGrid.js +16 -7
- package/esm/components/Table.js +43 -5
- package/esm/components/TableSummary.js +26 -29
- package/esm/components/TableSummaryFronzen.js +26 -29
- package/esm/store/createAppStore.js +2 -0
- package/esm/utils/columnVisibility.js +21 -18
- package/esm/utils/exportCsv.js +97 -0
- package/esm/utils/exportData.js +154 -0
- package/esm/utils/exportExcel.js +246 -0
- package/esm/utils/index.js +4 -0
- package/esm/utils/summary.js +35 -0
- package/package.json +1 -1
- package/style.css +8 -3
- package/types/BGrid.d.ts +1 -1
- package/types/components/Table.d.ts +3 -1
- package/types/store/createAppStore.d.ts +1 -1
- package/types/types.d.ts +91 -6
- package/types/utils/exportCsv.d.ts +5 -0
- package/types/utils/exportData.d.ts +16 -0
- package/types/utils/exportExcel.d.ts +5 -0
- package/types/utils/index.d.ts +4 -0
- package/types/utils/summary.d.ts +13 -0
package/cjs/BGrid.js
CHANGED
|
@@ -93,7 +93,7 @@ function computeModelColumns(columns, frozenColumnIndex, duplicateToolboxColumnI
|
|
|
93
93
|
}
|
|
94
94
|
function BGrid(_a) {
|
|
95
95
|
var _b, _c, _d, _e;
|
|
96
|
-
var ref = _a.ref, width = _a.width, height = _a.height, _f = _a.headerHeight, headerHeight = _f === void 0 ? 30 : _f, footerHeight = _a.footerHeight,
|
|
96
|
+
var ref = _a.ref, width = _a.width, height = _a.height, _f = _a.headerHeight, headerHeight = _f === void 0 ? 30 : _f, footerHeight = _a.footerHeight, explicitSummaryHeight = _a.summaryHeight, _g = _a.summaryRowHeight, summaryRowHeight = _g === void 0 ? utils_1.DEFAULT_SUMMARY_ROW_HEIGHT : _g, _h = _a.itemHeight, itemHeight = _h === void 0 ? 15 : _h, _j = _a.itemPadding, itemPadding = _j === void 0 ? 7 : _j, getRowHeight = _a.getRowHeight, columns = _a.columns, columnsGroup = _a.columnsGroup, columnGroups = _a.columnGroups, onChangeColumns = _a.onChangeColumns, _k = _a.frozenColumnIndex, frozenColumnIndex = _k === void 0 ? 0 : _k, _l = _a.frozenRowCount, frozenRowCount = _l === void 0 ? 0 : _l, _m = _a.data, data = _m === void 0 ? [] : _m, page = _a.page, scrollbar = _a.scrollbar, status = _a.status, pagination = _a.pagination, bottomBarHeight = _a.bottomBarHeight, _o = _a.scrollTop, scrollTop = _o === void 0 ? 0 : _o, _p = _a.scrollLeft, scrollLeft = _p === void 0 ? 0 : _p, className = _a.className, style = _a.style, rowChecked = _a.rowChecked, sort = _a.sort, onClick = _a.onClick, _q = _a.loading, loading = _q === void 0 ? false : _q, spinning = _a.spinning, disabled = _a.disabled, rowKey = _a.rowKey, selectedRowKey = _a.selectedRowKey, editable = _a.editable, onChangeData = _a.onChangeData, showLineNumber = _a.showLineNumber, msg = _a.msg, getRowClassName = _a.getRowClassName, _r = _a.editTrigger, editTrigger = _r === void 0 ? 'dblclick' : _r, cellMergeOptions = _a.cellMergeOptions, cellSelectionOptions = _a.cellSelectionOptions, cellNavigationOptions = _a.cellNavigationOptions, variant = _a.variant, summary = _a.summary, columnSortable = _a.columnSortable, reorder = _a.reorder, pivot = _a.pivot, dataControl = _a.dataControl, icons = _a.icons, columnVisibility = _a.columnVisibility, searchOptions = _a.searchOptions, contextMenuOptions = _a.contextMenuOptions, tree = _a.tree;
|
|
97
97
|
var _s = __read(React.useState(function () {
|
|
98
98
|
var _a;
|
|
99
99
|
return __spreadArray([], __read(((_a = tree === null || tree === void 0 ? void 0 : tree.defaultExpandedRowKeys) !== null && _a !== void 0 ? _a : [])), false);
|
|
@@ -608,6 +608,13 @@ function BGrid(_a) {
|
|
|
608
608
|
console.warn('[BGrid] Both bottomBarHeight and footerHeight were provided. bottomBarHeight takes precedence.');
|
|
609
609
|
}
|
|
610
610
|
}, [bottomBarHeight, footerHeight]);
|
|
611
|
+
var resolvedSummaryHeight = React.useMemo(function () {
|
|
612
|
+
return (0, utils_1.computeSummaryHeight)({
|
|
613
|
+
summary: resolvedSummary,
|
|
614
|
+
summaryHeight: explicitSummaryHeight,
|
|
615
|
+
summaryRowHeight: summaryRowHeight,
|
|
616
|
+
});
|
|
617
|
+
}, [resolvedSummary, explicitSummaryHeight, summaryRowHeight]);
|
|
611
618
|
var initialStoreState = React.useMemo(function () {
|
|
612
619
|
var _a, _b, _c;
|
|
613
620
|
var initialWidth = width !== undefined ? Math.max(width, 100) : 0;
|
|
@@ -617,7 +624,7 @@ function BGrid(_a) {
|
|
|
617
624
|
? Math.max(initialHeight -
|
|
618
625
|
headerHeight -
|
|
619
626
|
(initialShowBottomBar ? resolvedBottomBarHeight : 0) -
|
|
620
|
-
(resolvedSummary ?
|
|
627
|
+
(resolvedSummary ? resolvedSummaryHeight : 0) -
|
|
621
628
|
containerBorderWidth * 2, 0)
|
|
622
629
|
: 0;
|
|
623
630
|
var displayItemCount = contentBodyHeight > 0 ? Math.ceil(contentBodyHeight / (itemHeight + itemPadding * 2)) : 0;
|
|
@@ -638,7 +645,8 @@ function BGrid(_a) {
|
|
|
638
645
|
scrollbar: resolvedScrollbar,
|
|
639
646
|
status: resolvedStatus,
|
|
640
647
|
pagination: resolvedPagination,
|
|
641
|
-
summaryHeight:
|
|
648
|
+
summaryHeight: resolvedSummaryHeight,
|
|
649
|
+
summaryRowHeight: summaryRowHeight,
|
|
642
650
|
itemHeight: itemHeight,
|
|
643
651
|
itemPadding: itemPadding,
|
|
644
652
|
frozenColumnIndex: resolvedFrozenColumnIndex,
|
|
@@ -709,7 +717,8 @@ function BGrid(_a) {
|
|
|
709
717
|
resolvedScrollbar,
|
|
710
718
|
resolvedStatus,
|
|
711
719
|
resolvedPagination,
|
|
712
|
-
|
|
720
|
+
resolvedSummaryHeight,
|
|
721
|
+
summaryRowHeight,
|
|
713
722
|
itemHeight,
|
|
714
723
|
itemPadding,
|
|
715
724
|
rowHeightMetrics,
|
|
@@ -759,13 +768,15 @@ function BGrid(_a) {
|
|
|
759
768
|
]);
|
|
760
769
|
return (React.createElement(store_1.AppStoreProvider, { initialState: initialStoreState },
|
|
761
770
|
React.createElement(TreeContext_1.TreeContext.Provider, { value: treeContextValue },
|
|
762
|
-
React.createElement(Table_1.default, { ref: ref,
|
|
771
|
+
React.createElement(Table_1.default, { ref: ref, sourceColumns: resolvedColumns,
|
|
772
|
+
columns: computedColumns,
|
|
763
773
|
columnsGroup: visibilityProjection.columnsGroup,
|
|
764
774
|
columnGroups: visibilityProjection.columnGroups,
|
|
765
775
|
onChangeColumns: resolvedOnChangeColumns, width: width, height: height, className: className, style: style, loading: loading, disabled: resolvedDisabled, spinning: spinning, scrollLeft: scrollLeft, scrollTop: scrollTop, headerHeight: headerHeight, footerHeight: footerHeight, bottomBarHeight: resolvedBottomBarHeight,
|
|
766
776
|
scrollbar: resolvedScrollbar,
|
|
767
777
|
status: resolvedStatus,
|
|
768
|
-
pagination: resolvedPagination,
|
|
778
|
+
pagination: resolvedPagination,
|
|
779
|
+
summaryHeight: resolvedSummaryHeight, summaryRowHeight: summaryRowHeight, itemHeight: itemHeight, itemPadding: itemPadding, rowHeightMetrics: rowHeightMetrics, frozenColumnIndex: resolvedFrozenColumnIndex,
|
|
769
780
|
frozenRowCount: resolvedFrozenRowCount,
|
|
770
781
|
rowChecked: resolvedRowChecked, checkedIndexesMap: checkedIndexesMap, sort: resolvedSort, sortParams: sortParams, dataQuery: resolvedDataQuery,
|
|
771
782
|
dataControl: resolvedDataControl, icons: icons, columnVisibilityState: columnVisibilityState, searchOptions: resolvedSearchOptions,
|
package/cjs/components/Table.js
CHANGED
|
@@ -166,6 +166,7 @@ function Table(props) {
|
|
|
166
166
|
var _a;
|
|
167
167
|
var _this = this;
|
|
168
168
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
169
|
+
var store = (0, store_1.useAppStoreApi)();
|
|
169
170
|
var cellSelectionOptions = props.cellSelectionOptions, onChangeData = props.onChangeData, sourceIndexByVisibleIndex = props.sourceIndexByVisibleIndex;
|
|
170
171
|
var cellSelectionEnabled = (_b = cellSelectionOptions === null || cellSelectionOptions === void 0 ? void 0 : cellSelectionOptions.enabled) !== null && _b !== void 0 ? _b : true;
|
|
171
172
|
var rowKeyRegistryState = (0, react_1.useRef)({
|
|
@@ -199,7 +200,8 @@ function Table(props) {
|
|
|
199
200
|
footerHeight: s.footerHeight,
|
|
200
201
|
bottomBarHeight: s.bottomBarHeight,
|
|
201
202
|
summaryHeight: s.summaryHeight,
|
|
202
|
-
|
|
203
|
+
summaryRowHeight: s.summaryRowHeight,
|
|
204
|
+
}); })), headerHeight = _10.headerHeight, footerHeight = _10.footerHeight, bottomBarHeight = _10.bottomBarHeight, summaryHeight = _10.summaryHeight, summaryRowHeight = _10.summaryRowHeight;
|
|
203
205
|
// [Selector Group 3] Scroll State - 스크롤 상태
|
|
204
206
|
var _11 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
205
207
|
scrollLeft: s.scrollLeft,
|
|
@@ -258,12 +260,13 @@ function Table(props) {
|
|
|
258
260
|
setFooterHeight: s.setFooterHeight,
|
|
259
261
|
setBottomBarHeight: s.setBottomBarHeight,
|
|
260
262
|
setSummaryHeight: s.setSummaryHeight,
|
|
263
|
+
setSummaryRowHeight: s.setSummaryRowHeight,
|
|
261
264
|
setItemHeight: s.setItemHeight,
|
|
262
265
|
setItemPadding: s.setItemPadding,
|
|
263
266
|
setLoading: s.setLoading,
|
|
264
267
|
setSpinning: s.setSpinning,
|
|
265
268
|
setDisabled: s.setDisabled,
|
|
266
|
-
}); })), setHeight = _16.setHeight, setWidth = _16.setWidth, setContentBodyHeight = _16.setContentBodyHeight, setDisplayItemCount = _16.setDisplayItemCount, setHeaderHeight = _16.setHeaderHeight, setFooterHeight = _16.setFooterHeight, setBottomBarHeight = _16.setBottomBarHeight, setSummaryHeight = _16.setSummaryHeight, setItemHeight = _16.setItemHeight, setItemPadding = _16.setItemPadding, setLoading = _16.setLoading, setSpinning = _16.setSpinning, setDisabled = _16.setDisabled;
|
|
269
|
+
}); })), setHeight = _16.setHeight, setWidth = _16.setWidth, setContentBodyHeight = _16.setContentBodyHeight, setDisplayItemCount = _16.setDisplayItemCount, setHeaderHeight = _16.setHeaderHeight, setFooterHeight = _16.setFooterHeight, setBottomBarHeight = _16.setBottomBarHeight, setSummaryHeight = _16.setSummaryHeight, setSummaryRowHeight = _16.setSummaryRowHeight, setItemHeight = _16.setItemHeight, setItemPadding = _16.setItemPadding, setLoading = _16.setLoading, setSpinning = _16.setSpinning, setDisabled = _16.setDisabled;
|
|
267
270
|
// [Selector Group 7] Data & Column Setters - 데이터/열 설정자
|
|
268
271
|
var _17 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
269
272
|
setData: s.setData,
|
|
@@ -657,12 +660,46 @@ function Table(props) {
|
|
|
657
660
|
var scrollPropsRef = (0, react_1.useRef)({ top: props.scrollTop, left: props.scrollLeft });
|
|
658
661
|
var syncedDataPropRef = (0, react_1.useRef)(props.data);
|
|
659
662
|
var _23 = __read(React.useState(null), 2), rowScrollRequest = _23[0], setRowScrollRequest = _23[1];
|
|
663
|
+
var sourceColumnsRef = (0, react_1.useRef)(props.sourceColumns);
|
|
664
|
+
sourceColumnsRef.current = props.sourceColumns;
|
|
665
|
+
var getCurrentExportData = (0, react_1.useCallback)(function (options) {
|
|
666
|
+
var state = store.getState();
|
|
667
|
+
return (0, utils_1.createGridExportData)({
|
|
668
|
+
options: options,
|
|
669
|
+
columns: state.columns,
|
|
670
|
+
sourceColumns: sourceColumnsRef.current,
|
|
671
|
+
data: state.data,
|
|
672
|
+
sourceData: state.sourceData,
|
|
673
|
+
sourceIndexByVisibleIndex: state.sourceIndexByVisibleIndex,
|
|
674
|
+
visibleIndexBySourceIndex: state.visibleIndexBySourceIndex,
|
|
675
|
+
checkedIndexesMap: state.checkedIndexesMap,
|
|
676
|
+
rowKey: state.rowKey,
|
|
677
|
+
});
|
|
678
|
+
}, [store]);
|
|
660
679
|
React.useImperativeHandle(props.ref, function () { return ({
|
|
661
680
|
scrollToRow: function (rowIndex, options) {
|
|
662
681
|
var _a;
|
|
663
682
|
setRowScrollRequest({ rowIndex: rowIndex, align: (_a = options === null || options === void 0 ? void 0 : options.align) !== null && _a !== void 0 ? _a : 'nearest' });
|
|
664
683
|
},
|
|
665
|
-
|
|
684
|
+
getExportData: function (options) {
|
|
685
|
+
return getCurrentExportData(options);
|
|
686
|
+
},
|
|
687
|
+
exportCsv: function (options) {
|
|
688
|
+
var _a;
|
|
689
|
+
var exportData = getCurrentExportData(options);
|
|
690
|
+
var csv = (0, utils_1.serializeGridExportDataToCsv)(exportData, options);
|
|
691
|
+
(0, utils_1.downloadCsv)(csv, (_a = options === null || options === void 0 ? void 0 : options.fileName) !== null && _a !== void 0 ? _a : 'export.csv');
|
|
692
|
+
},
|
|
693
|
+
exportExcel: function (options) {
|
|
694
|
+
var exportData = getCurrentExportData(options);
|
|
695
|
+
void Promise.resolve().then(function () { return __importStar(require('../utils/exportExcel')); }).then(function (_a) {
|
|
696
|
+
var _b;
|
|
697
|
+
var serializeGridExportDataToExcel = _a.serializeGridExportDataToExcel, downloadExcel = _a.downloadExcel;
|
|
698
|
+
var excelBytes = serializeGridExportDataToExcel(exportData, options);
|
|
699
|
+
downloadExcel(excelBytes, (_b = options === null || options === void 0 ? void 0 : options.fileName) !== null && _b !== void 0 ? _b : 'export.xlsx');
|
|
700
|
+
});
|
|
701
|
+
},
|
|
702
|
+
}); }, [getCurrentExportData]);
|
|
666
703
|
var scrollRafRef = (0, react_1.useRef)(null);
|
|
667
704
|
var scrollIdleTimerRef = (0, react_1.useRef)(null);
|
|
668
705
|
var selectionAutoScrollRafRef = (0, react_1.useRef)(null);
|
|
@@ -1471,6 +1508,8 @@ function Table(props) {
|
|
|
1471
1508
|
setFooterHeight(props.footerHeight);
|
|
1472
1509
|
if (props.summaryHeight !== undefined)
|
|
1473
1510
|
setSummaryHeight(props.summaryHeight);
|
|
1511
|
+
if (props.summaryRowHeight !== undefined)
|
|
1512
|
+
setSummaryRowHeight(props.summaryRowHeight);
|
|
1474
1513
|
if (props.itemHeight !== undefined)
|
|
1475
1514
|
setItemHeight(props.itemHeight);
|
|
1476
1515
|
if (props.itemPadding !== undefined)
|
|
@@ -1480,12 +1519,14 @@ function Table(props) {
|
|
|
1480
1519
|
props.headerHeight,
|
|
1481
1520
|
props.footerHeight,
|
|
1482
1521
|
props.summaryHeight,
|
|
1522
|
+
props.summaryRowHeight,
|
|
1483
1523
|
props.itemHeight,
|
|
1484
1524
|
props.itemPadding,
|
|
1485
1525
|
setWidth,
|
|
1486
1526
|
setHeaderHeight,
|
|
1487
1527
|
setFooterHeight,
|
|
1488
1528
|
setSummaryHeight,
|
|
1529
|
+
setSummaryRowHeight,
|
|
1489
1530
|
setItemHeight,
|
|
1490
1531
|
setItemPadding,
|
|
1491
1532
|
]);
|
|
@@ -64,61 +64,52 @@ var react_1 = require("react");
|
|
|
64
64
|
var React = __importStar(require("react"));
|
|
65
65
|
var shallow_1 = require("zustand/react/shallow");
|
|
66
66
|
var store_1 = require("../store");
|
|
67
|
+
var utils_1 = require("../utils");
|
|
67
68
|
var TableColGroup_1 = __importDefault(require("./TableColGroup"));
|
|
68
69
|
function TableSummary(_a) {
|
|
69
70
|
var position = _a.position;
|
|
70
71
|
// [Selector Group 1] Summary Configuration - 요약 설정
|
|
71
72
|
var _b = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
72
73
|
summaryHeight: s.summaryHeight,
|
|
74
|
+
summaryRowHeight: s.summaryRowHeight,
|
|
73
75
|
summary: s.summary,
|
|
74
76
|
columns: s.columns,
|
|
75
|
-
columnsGroup: s.columnsGroup,
|
|
76
77
|
frozenColumnIndex: s.frozenColumnIndex,
|
|
77
78
|
variant: s.variant,
|
|
78
79
|
data: s.data,
|
|
79
|
-
}); })), summaryHeight = _b.summaryHeight,
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
else {
|
|
90
|
-
if (ignoreColumnCnt > 0) {
|
|
91
|
-
ignoreColumnCnt--;
|
|
92
|
-
return {};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
column: column,
|
|
97
|
-
columnIndex: columnIndex,
|
|
98
|
-
summaryColumn: summaryColumn,
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
}, [columns, frozenColumnIndex, summary]);
|
|
80
|
+
}); })), summaryHeight = _b.summaryHeight, summaryRowHeight = _b.summaryRowHeight, summary = _b.summary, columns = _b.columns, frozenColumnIndex = _b.frozenColumnIndex, variant = _b.variant, data = _b.data;
|
|
81
|
+
var summaryRows = (0, react_1.useMemo)(function () { return (0, utils_1.normalizeSummaryRows)(summary); }, [summary]);
|
|
82
|
+
var renderedRows = (0, react_1.useMemo)(function () {
|
|
83
|
+
var targetColumns = columns.slice(frozenColumnIndex);
|
|
84
|
+
return summaryRows.map(function (row, rowIndex) { return ({
|
|
85
|
+
row: row,
|
|
86
|
+
rowIndex: rowIndex,
|
|
87
|
+
cells: (0, utils_1.buildSummaryRowCells)(targetColumns, row.columns, frozenColumnIndex),
|
|
88
|
+
}); });
|
|
89
|
+
}, [summaryRows, columns, frozenColumnIndex]);
|
|
102
90
|
return (React.createElement(SummaryTable, { variant: variant, summaryHeight: summaryHeight, position: position },
|
|
103
91
|
React.createElement(TableColGroup_1.default, null),
|
|
104
|
-
React.createElement("tbody", { role: 'rfdg-summary' },
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
React.createElement("tbody", { role: 'rfdg-summary' }, renderedRows.map(function (_a) {
|
|
93
|
+
var _b, _c, _d;
|
|
94
|
+
var row = _a.row, rowIndex = _a.rowIndex, cells = _a.cells;
|
|
95
|
+
var rowHeight = (_b = row.height) !== null && _b !== void 0 ? _b : summaryRowHeight;
|
|
96
|
+
return (React.createElement("tr", { key: (_c = row.id) !== null && _c !== void 0 ? _c : rowIndex, className: ['bgrid-summary-row', (_d = row.className) !== null && _d !== void 0 ? _d : ''].filter(Boolean).join(' '), style: __assign(__assign({}, (rowHeight !== undefined ? { height: rowHeight } : {})), row.style) },
|
|
97
|
+
cells.map(function (cell, index) {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
if (!cell || !cell.column)
|
|
110
100
|
return null;
|
|
101
|
+
var column = cell.column, summaryColumn = cell.summaryColumn, columnIndex = cell.columnIndex;
|
|
111
102
|
if (!summaryColumn)
|
|
112
103
|
return React.createElement("td", { key: index });
|
|
113
|
-
return (React.createElement("td", { key: index, style: {
|
|
114
|
-
textAlign: summaryColumn.align,
|
|
115
|
-
}, colSpan: (_b = summaryColumn.colSpan) !== null && _b !== void 0 ? _b : 1 }, (_c = summaryColumn.itemRender) === null || _c === void 0 ? void 0 : _c.call(summaryColumn, {
|
|
104
|
+
return (React.createElement("td", { key: index, className: summaryColumn.className, style: __assign({ textAlign: summaryColumn.align }, summaryColumn.style), colSpan: (_a = summaryColumn.colSpan) !== null && _a !== void 0 ? _a : 1 }, (_b = summaryColumn.itemRender) === null || _b === void 0 ? void 0 : _b.call(summaryColumn, {
|
|
116
105
|
column: column,
|
|
117
106
|
columnIndex: columnIndex,
|
|
107
|
+
rowIndex: rowIndex,
|
|
118
108
|
data: data,
|
|
119
109
|
})));
|
|
120
110
|
}),
|
|
121
|
-
React.createElement("td", { "data-none": true })))
|
|
111
|
+
React.createElement("td", { "data-none": true })));
|
|
112
|
+
}))));
|
|
122
113
|
}
|
|
123
114
|
function SummaryTable(_a) {
|
|
124
115
|
var summaryHeight = _a.summaryHeight, variant = _a.variant, position = _a.position, className = _a.className, children = _a.children, rest = __rest(_a, ["summaryHeight", "variant", "position", "className", "children"]);
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -41,6 +52,7 @@ var React = __importStar(require("react"));
|
|
|
41
52
|
var react_1 = require("react");
|
|
42
53
|
var shallow_1 = require("zustand/react/shallow");
|
|
43
54
|
var store_1 = require("../store");
|
|
55
|
+
var utils_1 = require("../utils");
|
|
44
56
|
var TableColGroupFrozen_1 = __importDefault(require("./TableColGroupFrozen"));
|
|
45
57
|
var TableHead_1 = require("./TableHead");
|
|
46
58
|
var TableSummary_1 = require("./TableSummary");
|
|
@@ -49,57 +61,47 @@ function TableSummaryFrozen(_a) {
|
|
|
49
61
|
// [Selector Group 1] Summary Configuration - 요약 설정
|
|
50
62
|
var _b = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
51
63
|
summaryHeight: s.summaryHeight,
|
|
64
|
+
summaryRowHeight: s.summaryRowHeight,
|
|
52
65
|
summary: s.summary,
|
|
53
66
|
columns: s.columns,
|
|
54
|
-
columnsGroup: s.columnsGroup,
|
|
55
67
|
frozenColumnIndex: s.frozenColumnIndex,
|
|
56
68
|
variant: s.variant,
|
|
57
69
|
data: s.data,
|
|
58
70
|
showLineNumber: s.showLineNumber,
|
|
59
71
|
rowChecked: s.rowChecked,
|
|
60
|
-
}); })), summaryHeight = _b.summaryHeight,
|
|
72
|
+
}); })), summaryHeight = _b.summaryHeight, summaryRowHeight = _b.summaryRowHeight, summary = _b.summary, columns = _b.columns, frozenColumnIndex = _b.frozenColumnIndex, variant = _b.variant, data = _b.data, showLineNumber = _b.showLineNumber, rowChecked = _b.rowChecked;
|
|
61
73
|
var hasRowSelection = !!rowChecked;
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
else {
|
|
72
|
-
if (ignoreColumnCnt > 0) {
|
|
73
|
-
ignoreColumnCnt--;
|
|
74
|
-
return {};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
column: column,
|
|
79
|
-
columnIndex: columnIndex,
|
|
80
|
-
summaryColumn: summaryColumn,
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
}, [columns, frozenColumnIndex, summary]);
|
|
74
|
+
var summaryRows = (0, react_1.useMemo)(function () { return (0, utils_1.normalizeSummaryRows)(summary); }, [summary]);
|
|
75
|
+
var renderedRows = (0, react_1.useMemo)(function () {
|
|
76
|
+
var targetColumns = columns.slice(0, frozenColumnIndex);
|
|
77
|
+
return summaryRows.map(function (row, rowIndex) { return ({
|
|
78
|
+
row: row,
|
|
79
|
+
rowIndex: rowIndex,
|
|
80
|
+
cells: (0, utils_1.buildSummaryRowCells)(targetColumns, row.columns, 0),
|
|
81
|
+
}); });
|
|
82
|
+
}, [summaryRows, columns, frozenColumnIndex]);
|
|
84
83
|
return (React.createElement(TableSummary_1.SummaryTable, { variant: variant, summaryHeight: summaryHeight, position: position },
|
|
85
84
|
React.createElement(TableColGroupFrozen_1.default, null),
|
|
86
|
-
React.createElement("tbody", { role: 'rfdg-summay-frozen' },
|
|
87
|
-
|
|
85
|
+
React.createElement("tbody", { role: 'rfdg-summay-frozen' }, renderedRows.map(function (_a) {
|
|
86
|
+
var _b, _c, _d;
|
|
87
|
+
var row = _a.row, rowIndex = _a.rowIndex, cells = _a.cells;
|
|
88
|
+
var rowHeight = (_b = row.height) !== null && _b !== void 0 ? _b : summaryRowHeight;
|
|
89
|
+
return (React.createElement("tr", { key: (_c = row.id) !== null && _c !== void 0 ? _c : rowIndex, className: ['bgrid-summary-row', (_d = row.className) !== null && _d !== void 0 ? _d : ''].filter(Boolean).join(' '), style: __assign(__assign({}, (rowHeight !== undefined ? { height: rowHeight } : {})), row.style) },
|
|
88
90
|
showLineNumber && React.createElement(TableHead_1.HeadTd, { className: !hasRowSelection ? 'bordered' : '' }, "\u00A0"),
|
|
89
91
|
hasRowSelection && React.createElement("td", { className: 'bordered' }, "\u00A0"),
|
|
90
|
-
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
if (!column)
|
|
92
|
+
cells.map(function (cell, index) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
if (!cell || !cell.column)
|
|
94
95
|
return null;
|
|
96
|
+
var column = cell.column, summaryColumn = cell.summaryColumn, columnIndex = cell.columnIndex;
|
|
95
97
|
if (!summaryColumn)
|
|
96
98
|
return React.createElement("td", { key: index });
|
|
97
|
-
return (React.createElement("td", { key: index, style: {
|
|
98
|
-
textAlign: summaryColumn.align,
|
|
99
|
-
}, colSpan: (_b = summaryColumn.colSpan) !== null && _b !== void 0 ? _b : 1 }, (_c = summaryColumn.itemRender) === null || _c === void 0 ? void 0 : _c.call(summaryColumn, {
|
|
99
|
+
return (React.createElement("td", { key: index, className: summaryColumn.className, style: __assign({ textAlign: summaryColumn.align }, summaryColumn.style), colSpan: (_a = summaryColumn.colSpan) !== null && _a !== void 0 ? _a : 1 }, (_b = summaryColumn.itemRender) === null || _b === void 0 ? void 0 : _b.call(summaryColumn, {
|
|
100
100
|
column: column,
|
|
101
101
|
columnIndex: columnIndex,
|
|
102
|
+
rowIndex: rowIndex,
|
|
102
103
|
data: data,
|
|
103
104
|
})));
|
|
104
|
-
})))
|
|
105
|
+
})));
|
|
106
|
+
}))));
|
|
105
107
|
}
|
|
@@ -223,6 +223,7 @@ function AppStoreProvider(_a) {
|
|
|
223
223
|
visible: true,
|
|
224
224
|
},
|
|
225
225
|
summaryHeight: (_j = initialState === null || initialState === void 0 ? void 0 : initialState.summaryHeight) !== null && _j !== void 0 ? _j : 30,
|
|
226
|
+
summaryRowHeight: initialState === null || initialState === void 0 ? void 0 : initialState.summaryRowHeight,
|
|
226
227
|
itemHeight: (_k = initialState === null || initialState === void 0 ? void 0 : initialState.itemHeight) !== null && _k !== void 0 ? _k : 15,
|
|
227
228
|
itemPadding: (_l = initialState === null || initialState === void 0 ? void 0 : initialState.itemPadding) !== null && _l !== void 0 ? _l : 7,
|
|
228
229
|
frozenColumnIndex: (_m = initialState === null || initialState === void 0 ? void 0 : initialState.frozenColumnIndex) !== null && _m !== void 0 ? _m : 0,
|
|
@@ -917,6 +918,7 @@ function AppStoreProvider(_a) {
|
|
|
917
918
|
setHeaderHeight: function (headerHeight) { return set({ headerHeight: headerHeight }); },
|
|
918
919
|
setFooterHeight: function (footerHeight) { return set({ footerHeight: footerHeight }); },
|
|
919
920
|
setSummaryHeight: function (summaryHeight) { return set({ summaryHeight: summaryHeight }); },
|
|
921
|
+
setSummaryRowHeight: function (summaryRowHeight) { return set({ summaryRowHeight: summaryRowHeight }); },
|
|
920
922
|
setItemHeight: function (itemHeight) { return set({ itemHeight: itemHeight }); },
|
|
921
923
|
setItemPadding: function (itemPadding) { return set({ itemPadding: itemPadding }); },
|
|
922
924
|
setFrozenColumnIndex: function (frozenColumnIndex) { return set({ frozenColumnIndex: frozenColumnIndex }); },
|
|
@@ -94,21 +94,24 @@ function projectCellMergeOptions(options, visibleIndexByOriginalIndex) {
|
|
|
94
94
|
}, {});
|
|
95
95
|
return __assign(__assign({}, options), { columnsMap: columnsMap });
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function projectSummaryColumn(sc, vMap) {
|
|
98
|
+
var _a;
|
|
99
|
+
var end = sc.columnIndex + ((_a = sc.colSpan) !== null && _a !== void 0 ? _a : 1);
|
|
100
|
+
var idxs = [];
|
|
101
|
+
for (var i = sc.columnIndex; i < end; i++) {
|
|
102
|
+
var v = vMap.get(i);
|
|
103
|
+
if (v !== undefined)
|
|
104
|
+
idxs.push(v);
|
|
105
|
+
}
|
|
106
|
+
return idxs.length ? [__assign(__assign({}, sc), { columnIndex: idxs[0], colSpan: idxs.length })] : [];
|
|
107
|
+
}
|
|
108
|
+
function projectSummary(summary, vMap) {
|
|
98
109
|
if (!summary)
|
|
99
110
|
return undefined;
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (var index = summaryColumn.columnIndex; index < originalEnd; index += 1) {
|
|
105
|
-
var visibleIndex = visibleIndexByOriginalIndex.get(index);
|
|
106
|
-
if (visibleIndex !== undefined)
|
|
107
|
-
visibleIndexes.push(visibleIndex);
|
|
111
|
+
var projectCols = function (cols) { return cols.flatMap(function (c) { return projectSummaryColumn(c, vMap); }); };
|
|
112
|
+
return __assign(__assign(__assign({}, summary), (summary.columns ? { columns: projectCols(summary.columns) } : {})), (summary.rows
|
|
113
|
+
? {
|
|
114
|
+
rows: summary.rows.map(function (r) { return (Array.isArray(r) ? projectCols(r) : __assign(__assign({}, r), { columns: projectCols(r.columns) })); }),
|
|
108
115
|
}
|
|
109
|
-
|
|
110
|
-
return [];
|
|
111
|
-
return [__assign(__assign({}, summaryColumn), { columnIndex: visibleIndexes[0], colSpan: visibleIndexes.length })];
|
|
112
|
-
});
|
|
113
|
-
return __assign(__assign({}, summary), { columns: columns });
|
|
116
|
+
: {}));
|
|
114
117
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.formatCsvCellValue = formatCsvCellValue;
|
|
15
|
+
exports.escapeCsvCell = escapeCsvCell;
|
|
16
|
+
exports.serializeGridExportDataToCsv = serializeGridExportDataToCsv;
|
|
17
|
+
exports.downloadCsv = downloadCsv;
|
|
18
|
+
function formatCsvCellValue(value, preventFormulaInjection) {
|
|
19
|
+
if (preventFormulaInjection === void 0) { preventFormulaInjection = true; }
|
|
20
|
+
if (value === null || value === undefined) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
var formatted;
|
|
24
|
+
if (typeof value === 'string') {
|
|
25
|
+
formatted = value;
|
|
26
|
+
var startsWithFormula = /^[=+\-@]/.test(formatted);
|
|
27
|
+
var startsWithDangerousControl = /^[\t\r\n]/.test(formatted);
|
|
28
|
+
var hasFormulaAfterLeadingWhitespace = /^\s+[=+\-@]/.test(formatted);
|
|
29
|
+
if (preventFormulaInjection &&
|
|
30
|
+
(startsWithFormula || startsWithDangerousControl || hasFormulaAfterLeadingWhitespace)) {
|
|
31
|
+
formatted = "'".concat(formatted);
|
|
32
|
+
}
|
|
33
|
+
return formatted;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === 'number') {
|
|
36
|
+
return String(value);
|
|
37
|
+
}
|
|
38
|
+
if (typeof value === 'boolean') {
|
|
39
|
+
return value ? 'true' : 'false';
|
|
40
|
+
}
|
|
41
|
+
if (typeof value === 'bigint') {
|
|
42
|
+
return value.toString();
|
|
43
|
+
}
|
|
44
|
+
if (value instanceof Date) {
|
|
45
|
+
return isNaN(value.getTime()) ? 'Invalid Date' : value.toISOString();
|
|
46
|
+
}
|
|
47
|
+
if (typeof value === 'object') {
|
|
48
|
+
try {
|
|
49
|
+
formatted = JSON.stringify(value);
|
|
50
|
+
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
formatted = String(value);
|
|
53
|
+
}
|
|
54
|
+
return formatted;
|
|
55
|
+
}
|
|
56
|
+
return String(value);
|
|
57
|
+
}
|
|
58
|
+
function escapeCsvCell(cell, delimiter) {
|
|
59
|
+
if (delimiter === void 0) { delimiter = ','; }
|
|
60
|
+
var needsQuotes = cell.includes(delimiter) ||
|
|
61
|
+
cell.includes('"') ||
|
|
62
|
+
cell.includes('\r') ||
|
|
63
|
+
cell.includes('\n');
|
|
64
|
+
if (needsQuotes) {
|
|
65
|
+
return "\"".concat(cell.replace(/"/g, '""'), "\"");
|
|
66
|
+
}
|
|
67
|
+
return cell;
|
|
68
|
+
}
|
|
69
|
+
function serializeGridExportDataToCsv(data, options) {
|
|
70
|
+
var e_1, _a;
|
|
71
|
+
var _b, _c, _d, _e, _f;
|
|
72
|
+
var delimiter = (_b = options === null || options === void 0 ? void 0 : options.delimiter) !== null && _b !== void 0 ? _b : ',';
|
|
73
|
+
var newline = (_c = options === null || options === void 0 ? void 0 : options.newline) !== null && _c !== void 0 ? _c : '\r\n';
|
|
74
|
+
var includeHeader = (_d = options === null || options === void 0 ? void 0 : options.includeHeader) !== null && _d !== void 0 ? _d : true;
|
|
75
|
+
var bom = (_e = options === null || options === void 0 ? void 0 : options.bom) !== null && _e !== void 0 ? _e : true;
|
|
76
|
+
var preventFormulaInjection = (_f = options === null || options === void 0 ? void 0 : options.preventFormulaInjection) !== null && _f !== void 0 ? _f : true;
|
|
77
|
+
var lines = [];
|
|
78
|
+
if (includeHeader) {
|
|
79
|
+
var headerLine = data.columns
|
|
80
|
+
.map(function (col) { return escapeCsvCell(formatCsvCellValue(col.header, preventFormulaInjection), delimiter); })
|
|
81
|
+
.join(delimiter);
|
|
82
|
+
lines.push(headerLine);
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
for (var _g = __values(data.rows), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
86
|
+
var row = _h.value;
|
|
87
|
+
var rowLine = row.cells
|
|
88
|
+
.map(function (cell) { return escapeCsvCell(formatCsvCellValue(cell, preventFormulaInjection), delimiter); })
|
|
89
|
+
.join(delimiter);
|
|
90
|
+
lines.push(rowLine);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
94
|
+
finally {
|
|
95
|
+
try {
|
|
96
|
+
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
97
|
+
}
|
|
98
|
+
finally { if (e_1) throw e_1.error; }
|
|
99
|
+
}
|
|
100
|
+
var csvText = lines.join(newline);
|
|
101
|
+
return (bom ? '\uFEFF' : '') + csvText;
|
|
102
|
+
}
|
|
103
|
+
function downloadCsv(csv, fileName) {
|
|
104
|
+
if (fileName === void 0) { fileName = 'export.csv'; }
|
|
105
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
var resolvedName = (fileName || '').trim();
|
|
109
|
+
if (!resolvedName) {
|
|
110
|
+
resolvedName = 'export.csv';
|
|
111
|
+
}
|
|
112
|
+
else if (!resolvedName.toLowerCase().endsWith('.csv')) {
|
|
113
|
+
resolvedName += '.csv';
|
|
114
|
+
}
|
|
115
|
+
var blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
116
|
+
if (typeof URL !== 'undefined' && typeof URL.createObjectURL === 'function') {
|
|
117
|
+
var url = URL.createObjectURL(blob);
|
|
118
|
+
var link = document.createElement('a');
|
|
119
|
+
link.href = url;
|
|
120
|
+
link.setAttribute('download', resolvedName);
|
|
121
|
+
link.style.display = 'none';
|
|
122
|
+
document.body.appendChild(link);
|
|
123
|
+
link.click();
|
|
124
|
+
document.body.removeChild(link);
|
|
125
|
+
if (typeof URL.revokeObjectURL === 'function') {
|
|
126
|
+
URL.revokeObjectURL(url);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|