beautiful-grid 1.0.4 → 1.0.6
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 +47 -4
- package/cjs/BGrid.js +167 -39
- package/cjs/components/Table.js +71 -57
- package/cjs/components/TableHeadColumn.js +4 -1
- package/cjs/components/toolbox/TableHeadToolbox.js +8 -3
- package/cjs/components/toolbox/ToolboxColumnVisibilitySection.js +131 -0
- package/cjs/components/toolbox/index.js +1 -0
- package/cjs/store/createAppStore.js +2 -0
- package/cjs/utils/columnVisibility.js +114 -0
- package/cjs/utils/coordinate.js +7 -7
- package/cjs/utils/getVisibleScrollableRowRange.js +5 -4
- package/cjs/utils/index.js +1 -0
- package/esm/BGrid.js +168 -50
- package/esm/components/Table.js +23 -4
- package/esm/components/TableHeadColumn.js +4 -1
- package/esm/components/toolbox/TableHeadToolbox.js +8 -3
- package/esm/components/toolbox/ToolboxColumnVisibilitySection.js +68 -0
- package/esm/components/toolbox/index.js +1 -0
- package/esm/store/createAppStore.js +2 -0
- package/esm/utils/columnVisibility.js +89 -0
- package/esm/utils/coordinate.js +1 -1
- package/esm/utils/getVisibleScrollableRowRange.js +5 -4
- package/esm/utils/index.js +1 -0
- package/package.json +1 -1
- package/style.css +87 -0
- package/types/BGrid.d.ts +1 -1
- package/types/components/Table.d.ts +2 -1
- package/types/components/toolbox/ToolboxColumnVisibilitySection.d.ts +11 -0
- package/types/components/toolbox/index.d.ts +1 -0
- package/types/store/createAppStore.d.ts +1 -1
- package/types/types.d.ts +38 -0
- package/types/utils/columnVisibility.d.ts +21 -0
- package/types/utils/coordinate.d.ts +1 -0
- package/types/utils/getVisibleScrollableRowRange.d.ts +2 -1
- package/types/utils/index.d.ts +1 -0
package/cjs/components/Table.js
CHANGED
|
@@ -163,12 +163,13 @@ var LazyGridOptionalSurfaces = React.lazy(function () {
|
|
|
163
163
|
}); });
|
|
164
164
|
});
|
|
165
165
|
function Table(props) {
|
|
166
|
+
var _a;
|
|
166
167
|
var _this = this;
|
|
167
|
-
var
|
|
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;
|
|
168
169
|
var cellSelectionOptions = props.cellSelectionOptions, onChangeData = props.onChangeData, sourceIndexByVisibleIndex = props.sourceIndexByVisibleIndex;
|
|
169
|
-
var cellSelectionEnabled = (
|
|
170
|
+
var cellSelectionEnabled = (_b = cellSelectionOptions === null || cellSelectionOptions === void 0 ? void 0 : cellSelectionOptions.enabled) !== null && _b !== void 0 ? _b : true;
|
|
170
171
|
// [Selector Group 1] Layout & Dimensions - 레이아웃 차원
|
|
171
|
-
var
|
|
172
|
+
var _7 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
172
173
|
width: s.width,
|
|
173
174
|
height: s.height,
|
|
174
175
|
containerBorderWidth: s.containerBorderWidth,
|
|
@@ -176,30 +177,30 @@ function Table(props) {
|
|
|
176
177
|
style: s.style,
|
|
177
178
|
itemHeight: s.itemHeight,
|
|
178
179
|
itemPadding: s.itemPadding,
|
|
179
|
-
}); })), width =
|
|
180
|
+
}); })), width = _7.width, height = _7.height, containerBorderWidth = _7.containerBorderWidth, className = _7.className, style = _7.style, itemHeight = _7.itemHeight, itemPadding = _7.itemPadding;
|
|
180
181
|
// [Selector Group 2] Header, Footer, Summary - 헤더/푸터/요약
|
|
181
|
-
var
|
|
182
|
+
var _8 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
182
183
|
headerHeight: s.headerHeight,
|
|
183
184
|
footerHeight: s.footerHeight,
|
|
184
185
|
bottomBarHeight: s.bottomBarHeight,
|
|
185
186
|
summaryHeight: s.summaryHeight,
|
|
186
|
-
}); })), headerHeight =
|
|
187
|
+
}); })), headerHeight = _8.headerHeight, footerHeight = _8.footerHeight, bottomBarHeight = _8.bottomBarHeight, summaryHeight = _8.summaryHeight;
|
|
187
188
|
// [Selector Group 3] Scroll State - 스크롤 상태
|
|
188
|
-
var
|
|
189
|
+
var _9 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
189
190
|
scrollLeft: s.scrollLeft,
|
|
190
191
|
scrollTop: s.scrollTop,
|
|
191
|
-
}); })), scrollLeft =
|
|
192
|
+
}); })), scrollLeft = _9.scrollLeft, scrollTop = _9.scrollTop;
|
|
192
193
|
// [Selector Group 4] Content, Columns, Data - 컨텐츠 관련
|
|
193
|
-
var
|
|
194
|
+
var _10 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
194
195
|
contentBodyHeight: s.contentBodyHeight,
|
|
195
196
|
columns: s.columns,
|
|
196
197
|
data: s.data,
|
|
197
198
|
frozenColumnsWidth: s.frozenColumnsWidth,
|
|
198
199
|
frozenRowCount: s.frozenRowCount,
|
|
199
200
|
frozenRowsHeight: s.frozenRowsHeight,
|
|
200
|
-
}); })), contentBodyHeight =
|
|
201
|
+
}); })), contentBodyHeight = _10.contentBodyHeight, columns = _10.columns, data = _10.data, frozenColumnsWidth = _10.frozenColumnsWidth, frozenRowCount = _10.frozenRowCount, frozenRowsHeight = _10.frozenRowsHeight;
|
|
201
202
|
// [Selector Group 4-1] Cell selection & navigation - 셀 선택 및 내비게이션
|
|
202
|
-
var
|
|
203
|
+
var _11 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
203
204
|
cellSelectionRange: s.cellSelectionRange,
|
|
204
205
|
cellSelectionRanges: s.cellSelectionRanges,
|
|
205
206
|
activeCell: s.activeCell,
|
|
@@ -208,9 +209,9 @@ function Table(props) {
|
|
|
208
209
|
editItemIndex: s.editItemIndex,
|
|
209
210
|
editable: s.editable,
|
|
210
211
|
handleClick: s.handleClick,
|
|
211
|
-
}); })), cellSelectionRange =
|
|
212
|
+
}); })), cellSelectionRange = _11.cellSelectionRange, cellSelectionRanges = _11.cellSelectionRanges, activeCell = _11.activeCell, activeCellHost = _11.activeCellHost, cellNavigationOptions = _11.cellNavigationOptions, editItemIndex = _11.editItemIndex, editable = _11.editable, handleClick = _11.handleClick;
|
|
212
213
|
// [Selector Group 5] State - 상태
|
|
213
|
-
var
|
|
214
|
+
var _12 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
214
215
|
rowChecked: s.rowChecked,
|
|
215
216
|
page: s.page,
|
|
216
217
|
loading: s.loading,
|
|
@@ -220,8 +221,8 @@ function Table(props) {
|
|
|
220
221
|
scrollbar: s.scrollbar,
|
|
221
222
|
status: s.status,
|
|
222
223
|
pagination: s.pagination,
|
|
223
|
-
}); })), rowChecked =
|
|
224
|
-
var
|
|
224
|
+
}); })), rowChecked = _12.rowChecked, page = _12.page, loading = _12.loading, spinning = _12.spinning, showLineNumber = _12.showLineNumber, summary = _12.summary, scrollbar = _12.scrollbar, status = _12.status, pagination = _12.pagination;
|
|
225
|
+
var _13 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
225
226
|
searchOpen: s.searchOpen,
|
|
226
227
|
searchOptions: s.searchOptions,
|
|
227
228
|
contextMenuOptions: s.contextMenuOptions,
|
|
@@ -230,9 +231,9 @@ function Table(props) {
|
|
|
230
231
|
storeSourceIndexByVisibleIndex: s.sourceIndexByVisibleIndex,
|
|
231
232
|
storeRowKey: s.rowKey,
|
|
232
233
|
cellInteractionSession: s.cellInteractionSession,
|
|
233
|
-
}); })), searchOpen =
|
|
234
|
+
}); })), searchOpen = _13.searchOpen, searchOptions = _13.searchOptions, contextMenuOptions = _13.contextMenuOptions, activeSearchMatchIndex = _13.activeSearchMatchIndex, searchMatches = _13.searchMatches, storeSourceIndexByVisibleIndex = _13.storeSourceIndexByVisibleIndex, storeRowKey = _13.storeRowKey, cellInteractionSession = _13.cellInteractionSession;
|
|
234
235
|
// [Selector Group 6] State Setters - 차원 설정자
|
|
235
|
-
var
|
|
236
|
+
var _14 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
236
237
|
setHeight: s.setHeight,
|
|
237
238
|
setWidth: s.setWidth,
|
|
238
239
|
setContentBodyHeight: s.setContentBodyHeight,
|
|
@@ -245,9 +246,9 @@ function Table(props) {
|
|
|
245
246
|
setItemPadding: s.setItemPadding,
|
|
246
247
|
setLoading: s.setLoading,
|
|
247
248
|
setSpinning: s.setSpinning,
|
|
248
|
-
}); })), setHeight =
|
|
249
|
+
}); })), setHeight = _14.setHeight, setWidth = _14.setWidth, setContentBodyHeight = _14.setContentBodyHeight, setDisplayItemCount = _14.setDisplayItemCount, setHeaderHeight = _14.setHeaderHeight, setFooterHeight = _14.setFooterHeight, setBottomBarHeight = _14.setBottomBarHeight, setSummaryHeight = _14.setSummaryHeight, setItemHeight = _14.setItemHeight, setItemPadding = _14.setItemPadding, setLoading = _14.setLoading, setSpinning = _14.setSpinning;
|
|
249
250
|
// [Selector Group 7] Data & Column Setters - 데이터/열 설정자
|
|
250
|
-
var
|
|
251
|
+
var _15 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
251
252
|
setData: s.setData,
|
|
252
253
|
setSourceData: s.setSourceData,
|
|
253
254
|
setProcessedData: s.setProcessedData,
|
|
@@ -258,9 +259,9 @@ function Table(props) {
|
|
|
258
259
|
setFrozenColumnIndex: s.setFrozenColumnIndex,
|
|
259
260
|
setFrozenRowCount: s.setFrozenRowCount,
|
|
260
261
|
setFrozenRowsHeight: s.setFrozenRowsHeight,
|
|
261
|
-
}); })), setData =
|
|
262
|
+
}); })), setData = _15.setData, setSourceData = _15.setSourceData, setProcessedData = _15.setProcessedData, setColumns = _15.setColumns, setColumnsGroup = _15.setColumnsGroup, setColumnGroups = _15.setColumnGroups, setFrozenColumnsWidth = _15.setFrozenColumnsWidth, setFrozenColumnIndex = _15.setFrozenColumnIndex, setFrozenRowCount = _15.setFrozenRowCount, setFrozenRowsHeight = _15.setFrozenRowsHeight;
|
|
262
263
|
// [Selector Group 8] Row & Sort Setters - 행/정렬 설정자
|
|
263
|
-
var
|
|
264
|
+
var _16 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
264
265
|
setRowChecked: s.setRowChecked,
|
|
265
266
|
setCheckedIndexesMap: s.setCheckedIndexesMap,
|
|
266
267
|
setSort: s.setSort,
|
|
@@ -268,6 +269,7 @@ function Table(props) {
|
|
|
268
269
|
setDataQuery: s.setDataQuery,
|
|
269
270
|
setDataControl: s.setDataControl,
|
|
270
271
|
setIcons: s.setIcons,
|
|
272
|
+
setColumnVisibilityState: s.setColumnVisibilityState,
|
|
271
273
|
setActiveToolbox: s.setActiveToolbox,
|
|
272
274
|
setRowKey: s.setRowKey,
|
|
273
275
|
setFocusedRowKey: s.setSelectedRowKey,
|
|
@@ -277,9 +279,9 @@ function Table(props) {
|
|
|
277
279
|
requestSearchOpen: s.requestSearchOpen,
|
|
278
280
|
openContextMenu: s.openContextMenu,
|
|
279
281
|
commitCheckboxCell: s.commitCheckboxCell,
|
|
280
|
-
}); })), setRowChecked =
|
|
282
|
+
}); })), setRowChecked = _16.setRowChecked, setCheckedIndexesMap = _16.setCheckedIndexesMap, setSort = _16.setSort, setSortParams = _16.setSortParams, setDataQuery = _16.setDataQuery, setDataControl = _16.setDataControl, setIcons = _16.setIcons, setColumnVisibilityState = _16.setColumnVisibilityState, setActiveToolbox = _16.setActiveToolbox, setRowKey = _16.setRowKey, setFocusedRowKey = _16.setFocusedRowKey, setEditItem = _16.setEditItem, setSearchOptions = _16.setSearchOptions, setContextMenuOptions = _16.setContextMenuOptions, requestSearchOpen = _16.requestSearchOpen, openContextMenu = _16.openContextMenu, commitCheckboxCell = _16.commitCheckboxCell;
|
|
281
283
|
// [Selector Group 9] Pagination & Display Setters - 페이지/표시 설정자
|
|
282
|
-
var
|
|
284
|
+
var _17 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
283
285
|
setPage: s.setPage,
|
|
284
286
|
setDisplayPaginationLength: s.setDisplayPaginationLength,
|
|
285
287
|
setShowLineNumber: s.setShowLineNumber,
|
|
@@ -295,9 +297,9 @@ function Table(props) {
|
|
|
295
297
|
setScrollbar: s.setScrollbar,
|
|
296
298
|
setStatus: s.setStatus,
|
|
297
299
|
setPagination: s.setPagination,
|
|
298
|
-
}); })), setPage =
|
|
300
|
+
}); })), setPage = _17.setPage, setDisplayPaginationLength = _17.setDisplayPaginationLength, setShowLineNumber = _17.setShowLineNumber, setMsg = _17.setMsg, setRowClassName = _17.setRowClassName, setCellMergeOptions = _17.setCellMergeOptions, setVariant = _17.setVariant, setSummary = _17.setSummary, setColumnSortable = _17.setColumnSortable, setReorder = _17.setReorder, setClassName = _17.setClassName, setStyle = _17.setStyle, setScrollbar = _17.setScrollbar, setStatus = _17.setStatus, setPagination = _17.setPagination;
|
|
299
301
|
// [Selector Group 10] Edit & Event Setters - 편집/이벤트 설정자
|
|
300
|
-
var
|
|
302
|
+
var _18 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
301
303
|
setEditable: s.setEditable,
|
|
302
304
|
setEditTrigger: s.setEditTrigger,
|
|
303
305
|
setOnClick: s.setOnClick,
|
|
@@ -306,8 +308,8 @@ function Table(props) {
|
|
|
306
308
|
setOnLoadMore: s.setOnLoadMore,
|
|
307
309
|
setScroll: s.setScroll,
|
|
308
310
|
setInitialized: s.setInitialized,
|
|
309
|
-
}); })), setEditable =
|
|
310
|
-
var
|
|
311
|
+
}); })), setEditable = _18.setEditable, setEditTrigger = _18.setEditTrigger, setOnClick = _18.setOnClick, setOnChangeColumns = _18.setOnChangeColumns, setOnChangeData = _18.setOnChangeData, setOnLoadMore = _18.setOnLoadMore, setScroll = _18.setScroll, setInitialized = _18.setInitialized;
|
|
312
|
+
var _19 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
311
313
|
setCellSelectionRanges: s.setCellSelectionRanges,
|
|
312
314
|
setCellSelecting: s.setCellSelecting,
|
|
313
315
|
clearCellSelection: s.clearCellSelection,
|
|
@@ -315,9 +317,10 @@ function Table(props) {
|
|
|
315
317
|
moveActiveCell: s.moveActiveCell,
|
|
316
318
|
setCellNavigationOptions: s.setCellNavigationOptions,
|
|
317
319
|
syncActiveCellToBounds: s.syncActiveCellToBounds,
|
|
318
|
-
}); })), setCellSelectionRanges =
|
|
320
|
+
}); })), setCellSelectionRanges = _19.setCellSelectionRanges, setCellSelecting = _19.setCellSelecting, clearCellSelection = _19.clearCellSelection, setActiveCell = _19.setActiveCell, moveActiveCell = _19.moveActiveCell, setCellNavigationOptions = _19.setCellNavigationOptions, syncActiveCellToBounds = _19.syncActiveCellToBounds;
|
|
319
321
|
var trHeight = itemHeight + itemPadding * 2;
|
|
320
322
|
var scrollableBodyHeight = Math.max(contentBodyHeight - frozenRowsHeight, 0);
|
|
323
|
+
var scrollOverscanRows = Math.max(KEYBOARD_NAVIGATION_ROW_WINDOW_SIZE, Math.ceil(scrollableBodyHeight / Math.max(trHeight, 1)));
|
|
321
324
|
var mainViewportWidth = Math.max(width - (frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0), 0);
|
|
322
325
|
var logicalBodyContentHeight = data.length * trHeight;
|
|
323
326
|
var virtualScrollWindowMetrics = React.useMemo(function () {
|
|
@@ -327,7 +330,7 @@ function Table(props) {
|
|
|
327
330
|
enabled: scrollbar.variant !== 'native',
|
|
328
331
|
});
|
|
329
332
|
}, [contentBodyHeight, logicalBodyContentHeight, scrollbar.variant]);
|
|
330
|
-
var
|
|
333
|
+
var _20 = __read(React.useState(0), 2), virtualScrollBase = _20[0], setVirtualScrollBase = _20[1];
|
|
331
334
|
var virtualScrollBaseRef = (0, react_1.useRef)(0);
|
|
332
335
|
var containerRef = (0, react_1.useRef)(null);
|
|
333
336
|
var searchPopoverRef = (0, react_1.useRef)(null);
|
|
@@ -337,7 +340,8 @@ function Table(props) {
|
|
|
337
340
|
var logicalVerticalScrollState = React.useMemo(function () { return ({
|
|
338
341
|
scrollTop: scrollTop,
|
|
339
342
|
scrollHeight: virtualScrollWindowMetrics.logicalContentHeight,
|
|
340
|
-
|
|
343
|
+
maxScrollTop: virtualScrollWindowMetrics.logicalMaxScroll,
|
|
344
|
+
}); }, [scrollTop, virtualScrollWindowMetrics.logicalContentHeight, virtualScrollWindowMetrics.logicalMaxScroll]);
|
|
341
345
|
var hasMultiCellSelection = React.useMemo(function () {
|
|
342
346
|
return cellSelectionRanges.length > 1 ||
|
|
343
347
|
cellSelectionRanges.some(function (range) {
|
|
@@ -440,16 +444,18 @@ function Table(props) {
|
|
|
440
444
|
}, offsetTop: !topQuadrant && virtualScrollWindowMetrics.enabled ? virtualScrollBase : 0 }));
|
|
441
445
|
};
|
|
442
446
|
var visibleScrollableRows = React.useMemo(function () {
|
|
443
|
-
var _a;
|
|
447
|
+
var _a, _b, _c;
|
|
444
448
|
return (0, utils_1.getVisibleScrollableRowRange)({
|
|
445
449
|
scrollTop: scrollTop,
|
|
446
450
|
viewportHeight: scrollableBodyHeight,
|
|
447
451
|
rowHeight: trHeight,
|
|
448
452
|
frozenRowCount: frozenRowCount,
|
|
449
453
|
totalRowCount: data.length,
|
|
450
|
-
|
|
454
|
+
overscan: ((_a = props.reorder) === null || _a === void 0 ? void 0 : _a.enabled) ? 1 : scrollOverscanRows,
|
|
455
|
+
leadingOverscan: ((_b = props.reorder) === null || _b === void 0 ? void 0 : _b.enabled) ? 0 : scrollOverscanRows,
|
|
456
|
+
windowSize: ((_c = props.reorder) === null || _c === void 0 ? void 0 : _c.enabled) ? 1 : KEYBOARD_NAVIGATION_ROW_WINDOW_SIZE,
|
|
451
457
|
});
|
|
452
|
-
}, [data.length, frozenRowCount, (
|
|
458
|
+
}, [data.length, frozenRowCount, (_c = props.reorder) === null || _c === void 0 ? void 0 : _c.enabled, scrollOverscanRows, scrollTop, scrollableBodyHeight, trHeight]);
|
|
453
459
|
var frozenRowRange = React.useMemo(function () { return ({ startRowIndex: 0, endRowIndex: frozenRowCount }); }, [frozenRowCount]);
|
|
454
460
|
var scrollableRowRange = React.useMemo(function () { return ({
|
|
455
461
|
startRowIndex: visibleScrollableRows.startRowIndex,
|
|
@@ -619,7 +625,7 @@ function Table(props) {
|
|
|
619
625
|
var latestCommittedScrollRef = (0, react_1.useRef)({ top: scrollTop, left: scrollLeft });
|
|
620
626
|
var scrollPropsRef = (0, react_1.useRef)({ top: props.scrollTop, left: props.scrollLeft });
|
|
621
627
|
var syncedDataPropRef = (0, react_1.useRef)(props.data);
|
|
622
|
-
var
|
|
628
|
+
var _21 = __read(React.useState(null), 2), rowScrollRequest = _21[0], setRowScrollRequest = _21[1];
|
|
623
629
|
React.useImperativeHandle(props.ref, function () { return ({
|
|
624
630
|
scrollToRow: function (rowIndex, options) {
|
|
625
631
|
var _a;
|
|
@@ -636,7 +642,7 @@ function Table(props) {
|
|
|
636
642
|
var selectionMetricsRef = (0, react_1.useRef)({
|
|
637
643
|
columns: columns,
|
|
638
644
|
dataLength: data.length,
|
|
639
|
-
frozenColumnIndex: (
|
|
645
|
+
frozenColumnIndex: (_d = props.frozenColumnIndex) !== null && _d !== void 0 ? _d : 0,
|
|
640
646
|
frozenRowCount: frozenRowCount,
|
|
641
647
|
frozenColumnsWidth: frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0,
|
|
642
648
|
frozenRowsHeight: frozenRowsHeight,
|
|
@@ -1498,7 +1504,7 @@ function Table(props) {
|
|
|
1498
1504
|
setFrozenColumnIndex((_d = props.frozenColumnIndex) !== null && _d !== void 0 ? _d : 0);
|
|
1499
1505
|
}, [
|
|
1500
1506
|
props.frozenColumnIndex,
|
|
1501
|
-
(
|
|
1507
|
+
(_e = props.reorder) === null || _e === void 0 ? void 0 : _e.enabled,
|
|
1502
1508
|
showLineNumber,
|
|
1503
1509
|
rowChecked,
|
|
1504
1510
|
itemHeight,
|
|
@@ -1514,7 +1520,7 @@ function Table(props) {
|
|
|
1514
1520
|
var nextFrozenRowCount = Math.min(Math.max(Math.floor((_c = props.frozenRowCount) !== null && _c !== void 0 ? _c : 0), 0), rowCount);
|
|
1515
1521
|
setFrozenRowCount(nextFrozenRowCount);
|
|
1516
1522
|
setFrozenRowsHeight(nextFrozenRowCount * trHeight);
|
|
1517
|
-
}, [data.length, (
|
|
1523
|
+
}, [data.length, (_f = props.data) === null || _f === void 0 ? void 0 : _f.length, props.frozenRowCount, setFrozenRowCount, setFrozenRowsHeight, trHeight]);
|
|
1518
1524
|
// [Group 5] Data & columns
|
|
1519
1525
|
(0, react_1.useEffect)(function () {
|
|
1520
1526
|
if (props.data !== undefined &&
|
|
@@ -1563,6 +1569,7 @@ function Table(props) {
|
|
|
1563
1569
|
setSortParams(props.sortParams);
|
|
1564
1570
|
setDataControl(props.dataControl);
|
|
1565
1571
|
setIcons(props.icons);
|
|
1572
|
+
setColumnVisibilityState(props.columnVisibilityState);
|
|
1566
1573
|
setSearchOptions(props.searchOptions);
|
|
1567
1574
|
setContextMenuOptions(props.contextMenuOptions);
|
|
1568
1575
|
}, [
|
|
@@ -1571,6 +1578,7 @@ function Table(props) {
|
|
|
1571
1578
|
props.sortParams,
|
|
1572
1579
|
props.dataControl,
|
|
1573
1580
|
props.icons,
|
|
1581
|
+
props.columnVisibilityState,
|
|
1574
1582
|
props.searchOptions,
|
|
1575
1583
|
props.contextMenuOptions,
|
|
1576
1584
|
setRowChecked,
|
|
@@ -1578,6 +1586,7 @@ function Table(props) {
|
|
|
1578
1586
|
setSortParams,
|
|
1579
1587
|
setDataControl,
|
|
1580
1588
|
setIcons,
|
|
1589
|
+
setColumnVisibilityState,
|
|
1581
1590
|
setSearchOptions,
|
|
1582
1591
|
setContextMenuOptions,
|
|
1583
1592
|
]);
|
|
@@ -1605,23 +1614,23 @@ function Table(props) {
|
|
|
1605
1614
|
}
|
|
1606
1615
|
}, [
|
|
1607
1616
|
props.page,
|
|
1608
|
-
(
|
|
1609
|
-
(
|
|
1610
|
-
(
|
|
1611
|
-
(
|
|
1612
|
-
(
|
|
1613
|
-
(
|
|
1614
|
-
(
|
|
1617
|
+
(_g = props.page) === null || _g === void 0 ? void 0 : _g.currentPage,
|
|
1618
|
+
(_h = props.page) === null || _h === void 0 ? void 0 : _h.loading,
|
|
1619
|
+
(_j = props.page) === null || _j === void 0 ? void 0 : _j.pageSize,
|
|
1620
|
+
(_k = props.page) === null || _k === void 0 ? void 0 : _k.totalPages,
|
|
1621
|
+
(_l = props.page) === null || _l === void 0 ? void 0 : _l.totalElements,
|
|
1622
|
+
(_m = props.page) === null || _m === void 0 ? void 0 : _m.onChange,
|
|
1623
|
+
(_o = props.page) === null || _o === void 0 ? void 0 : _o.displayPaginationLength,
|
|
1615
1624
|
setPage,
|
|
1616
1625
|
setDisplayPaginationLength,
|
|
1617
1626
|
]);
|
|
1618
|
-
var previousPageRef = (0, react_1.useRef)((
|
|
1627
|
+
var previousPageRef = (0, react_1.useRef)((_p = props.page) === null || _p === void 0 ? void 0 : _p.currentPage);
|
|
1619
1628
|
(0, react_1.useEffect)(function () {
|
|
1620
1629
|
var _a, _b;
|
|
1621
1630
|
if (previousPageRef.current !== ((_a = props.page) === null || _a === void 0 ? void 0 : _a.currentPage))
|
|
1622
1631
|
resetScrollPosition('top');
|
|
1623
1632
|
previousPageRef.current = (_b = props.page) === null || _b === void 0 ? void 0 : _b.currentPage;
|
|
1624
|
-
}, [resetScrollPosition, (
|
|
1633
|
+
}, [resetScrollPosition, (_q = props.page) === null || _q === void 0 ? void 0 : _q.currentPage]);
|
|
1625
1634
|
// [Group 8] Row key & selection
|
|
1626
1635
|
(0, react_1.useEffect)(function () {
|
|
1627
1636
|
setRowKey(props.rowKey);
|
|
@@ -1693,10 +1702,10 @@ function Table(props) {
|
|
|
1693
1702
|
}, [
|
|
1694
1703
|
columns.length,
|
|
1695
1704
|
data.length,
|
|
1696
|
-
(
|
|
1697
|
-
(
|
|
1698
|
-
(
|
|
1699
|
-
(
|
|
1705
|
+
(_s = (_r = props.cellNavigationOptions) === null || _r === void 0 ? void 0 : _r.activeCell) === null || _s === void 0 ? void 0 : _s.columnIndex,
|
|
1706
|
+
(_u = (_t = props.cellNavigationOptions) === null || _t === void 0 ? void 0 : _t.activeCell) === null || _u === void 0 ? void 0 : _u.rowIndex,
|
|
1707
|
+
(_w = (_v = props.cellNavigationOptions) === null || _v === void 0 ? void 0 : _v.defaultActiveCell) === null || _w === void 0 ? void 0 : _w.columnIndex,
|
|
1708
|
+
(_y = (_x = props.cellNavigationOptions) === null || _x === void 0 ? void 0 : _x.defaultActiveCell) === null || _y === void 0 ? void 0 : _y.rowIndex,
|
|
1700
1709
|
syncActiveCellToBounds,
|
|
1701
1710
|
]);
|
|
1702
1711
|
// setInitialized + DOM event bindings
|
|
@@ -1818,8 +1827,8 @@ function Table(props) {
|
|
|
1818
1827
|
endCellSelectionDrag();
|
|
1819
1828
|
clearCellSelection();
|
|
1820
1829
|
}, [cellSelectionEnabled, clearCellSelection, endCellSelectionDrag]);
|
|
1821
|
-
var clearCellSelectionOnEscape = (
|
|
1822
|
-
var clearCellSelectionOnOutsideClick = (
|
|
1830
|
+
var clearCellSelectionOnEscape = (_0 = (_z = props.cellSelectionOptions) === null || _z === void 0 ? void 0 : _z.clearOnEscape) !== null && _0 !== void 0 ? _0 : true;
|
|
1831
|
+
var clearCellSelectionOnOutsideClick = (_2 = (_1 = props.cellSelectionOptions) === null || _1 === void 0 ? void 0 : _1.clearOnOutsideClick) !== null && _2 !== void 0 ? _2 : true;
|
|
1823
1832
|
var keyboardRuntimeRef = (0, react_1.useRef)({
|
|
1824
1833
|
activeCell: activeCell,
|
|
1825
1834
|
cellInteractionSession: cellInteractionSession,
|
|
@@ -1837,7 +1846,7 @@ function Table(props) {
|
|
|
1837
1846
|
editable: editable,
|
|
1838
1847
|
editItemIndex: editItemIndex,
|
|
1839
1848
|
endCellSelectionDrag: endCellSelectionDrag,
|
|
1840
|
-
frozenColumnIndex: (
|
|
1849
|
+
frozenColumnIndex: (_3 = props.frozenColumnIndex) !== null && _3 !== void 0 ? _3 : 0,
|
|
1841
1850
|
frozenRowCount: frozenRowCount,
|
|
1842
1851
|
height: height,
|
|
1843
1852
|
handleClick: handleClick,
|
|
@@ -1870,7 +1879,7 @@ function Table(props) {
|
|
|
1870
1879
|
editable: editable,
|
|
1871
1880
|
editItemIndex: editItemIndex,
|
|
1872
1881
|
endCellSelectionDrag: endCellSelectionDrag,
|
|
1873
|
-
frozenColumnIndex: (
|
|
1882
|
+
frozenColumnIndex: (_4 = props.frozenColumnIndex) !== null && _4 !== void 0 ? _4 : 0,
|
|
1874
1883
|
frozenRowCount: frozenRowCount,
|
|
1875
1884
|
height: height,
|
|
1876
1885
|
handleClick: handleClick,
|
|
@@ -2252,14 +2261,14 @@ function Table(props) {
|
|
|
2252
2261
|
};
|
|
2253
2262
|
}, []);
|
|
2254
2263
|
return (React.createElement(EditorPortalRoot_1.EditorPortalContext.Provider, { value: editorPortalContext },
|
|
2255
|
-
React.createElement(Container, { ref: containerRef, role: 'grid', style: __assign(__assign({}, style), { width: width, height: height, borderWidth: "".concat(containerBorderWidth, "px") }), className: className, tabIndex: 0, onFocus: function (event) {
|
|
2264
|
+
React.createElement(Container, { ref: containerRef, role: 'grid', style: __assign(__assign({}, style), (_a = { width: width, height: height, borderWidth: "".concat(containerBorderWidth, "px") }, _a['--bgrid-virtual-row-height'] = "".concat(trHeight, "px"), _a)), className: className, tabIndex: 0, onFocus: function (event) {
|
|
2256
2265
|
if (event.target !== event.currentTarget)
|
|
2257
2266
|
return;
|
|
2258
2267
|
var gateway = event.currentTarget.querySelector('[data-bgrid-text-editor-gateway="true"]');
|
|
2259
2268
|
if (gateway instanceof HTMLInputElement) {
|
|
2260
2269
|
gateway.focus({ preventScroll: true });
|
|
2261
2270
|
}
|
|
2262
|
-
}, "data-scroll-variant": scrollbar.variant, "data-vertical-scrollbar": scrollbar.variant !== 'native' && scrollbar.vertical.visible ? 'visible' : 'hidden', "data-bgrid-cell-selection-enabled": cellSelectionEnabled ? 'true' : 'false', "data-bgrid-frozen-columns": ((
|
|
2271
|
+
}, "data-scroll-variant": scrollbar.variant, "data-vertical-scrollbar": scrollbar.variant !== 'native' && scrollbar.vertical.visible ? 'visible' : 'hidden', "data-bgrid-cell-selection-enabled": cellSelectionEnabled ? 'true' : 'false', "data-bgrid-frozen-columns": ((_5 = props.frozenColumnIndex) !== null && _5 !== void 0 ? _5 : 0) > 0 ? 'true' : 'false' },
|
|
2263
2272
|
scrollbar.variant !== 'native' && scrollbar.vertical.visible && (React.createElement("div", { className: 'bgrid-vertical-scrollbar-gutter', "aria-hidden": 'true' })),
|
|
2264
2273
|
scrollbar.variant !== 'native' && scrollbar.vertical.visible && (React.createElement("div", { className: 'bgrid-vertical-scrollbar-area', style: {
|
|
2265
2274
|
top: 0,
|
|
@@ -2288,6 +2297,11 @@ function Table(props) {
|
|
|
2288
2297
|
React.createElement(TableSummaryFronzen_1.TableSummaryFrozen, { position: 'top' }))),
|
|
2289
2298
|
React.createElement(Summary, { style: { left: frozenColumnsWidth }, role: 'rfdg-summary' },
|
|
2290
2299
|
React.createElement(TableSummary_1.TableSummary, { position: 'top' })))),
|
|
2300
|
+
React.createElement("div", { className: 'bgrid-virtual-row-backdrop', "aria-hidden": 'true', style: {
|
|
2301
|
+
top: stickyTopHeight,
|
|
2302
|
+
height: contentBodyHeight,
|
|
2303
|
+
marginBottom: -contentBodyHeight,
|
|
2304
|
+
} }),
|
|
2291
2305
|
React.createElement("div", { className: 'bgrid-body-scroll-content', style: { height: virtualScrollWindowMetrics.physicalContentHeight } },
|
|
2292
2306
|
frozenRowCount > 0 && (React.createElement("div", { className: 'bgrid-frozen-rows-layer', style: { height: frozenRowsHeight, top: stickyTopHeight }, "data-bgrid-row-band": 'frozen' },
|
|
2293
2307
|
(frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0) > 0 && (React.createElement("div", { className: 'bgrid-frozen-rows-left bgrid-frozen-column-boundary', style: { width: frozenColumnsWidth }, role: 'rfdg-frozen-rows-left' },
|
|
@@ -2318,7 +2332,7 @@ function Table(props) {
|
|
|
2318
2332
|
React.createElement(Summary, { style: { left: frozenColumnsWidth }, role: 'rfdg-summary' },
|
|
2319
2333
|
React.createElement(TableSummary_1.TableSummary, { position: 'bottom' })))))),
|
|
2320
2334
|
React.createElement(BodyViewport, { ref: bodyContainerRef, style: { top: stickyTopHeight, height: contentBodyHeight }, "data-last": !page ? 'true' : undefined },
|
|
2321
|
-
((
|
|
2335
|
+
((_6 = rowReorderController.preview) === null || _6 === void 0 ? void 0 : _6.visible) && (React.createElement("div", { className: 'bgrid-row-reorder-preview', "data-bgrid-row-reorder-phase": rowReorderController.preview.phase, "aria-hidden": 'true' }, rowReorderController.preview.text)),
|
|
2322
2336
|
React.createElement(Loading_1.default, { active: !!spinning, size: 'small' })),
|
|
2323
2337
|
React.createElement("div", { className: 'bgrid-visually-hidden', role: 'status', "aria-live": 'polite', "aria-atomic": 'true' }, rowReorderController.announcement),
|
|
2324
2338
|
React.createElement(CellTextEditorGateway_1.CellTextEditorGateway, { containerRef: containerRef }),
|
|
@@ -57,12 +57,15 @@ function TableHeadColumn(_a) {
|
|
|
57
57
|
var activeToolboxColumnId = (0, store_1.useAppStore)(function (s) { return s.activeToolboxColumnId; });
|
|
58
58
|
var setActiveToolbox = (0, store_1.useAppStore)(function (s) { return s.setActiveToolbox; });
|
|
59
59
|
var globalIcons = (0, store_1.useAppStore)(function (s) { return s.icons; });
|
|
60
|
+
var columnVisibilityState = (0, store_1.useAppStore)(function (s) { return s.columnVisibilityState; });
|
|
60
61
|
var columnId = (_b = column.columnId) !== null && _b !== void 0 ? _b : (0, utils_1.getColumnId)(column);
|
|
61
62
|
var buttonRef = (0, react_1.useRef)(null);
|
|
62
63
|
var reactId = React.useId().replace(/:/g, '');
|
|
63
64
|
var triggerId = "bgrid-toolbox-btn-".concat(reactId);
|
|
64
65
|
var dialogId = "bgrid-toolbox-dialog-".concat(reactId);
|
|
65
|
-
var
|
|
66
|
+
var visibilityItem = columnVisibilityState === null || columnVisibilityState === void 0 ? void 0 : columnVisibilityState.items.find(function (item) { return item.columnId === columnId; });
|
|
67
|
+
var isVisibilityMenuEnabled = !!columnVisibilityState && (!!(visibilityItem === null || visibilityItem === void 0 ? void 0 : visibilityItem.hideable) || columnVisibilityState.items.some(function (item) { return item.hidden; }));
|
|
68
|
+
var isToolboxEnabled = !!column.toolbox || isVisibilityMenuEnabled;
|
|
66
69
|
var isToolboxOpen = activeToolboxColumnId === columnId;
|
|
67
70
|
var columnIcons = typeof column.toolbox === 'object' ? column.toolbox.icons : undefined;
|
|
68
71
|
var hasCheckboxHeader = ((_c = column.editor) === null || _c === void 0 ? void 0 : _c.type) === 'checkbox' && !!column.editor.header;
|
|
@@ -75,11 +75,13 @@ exports.TableHeadToolbox = TableHeadToolbox;
|
|
|
75
75
|
var React = __importStar(require("react"));
|
|
76
76
|
var react_1 = require("react");
|
|
77
77
|
var react_dom_1 = require("react-dom");
|
|
78
|
+
var store_1 = require("../../store");
|
|
78
79
|
var ToolboxSortSection_1 = require("./ToolboxSortSection");
|
|
79
80
|
var ToolboxValueFilterSection_1 = require("./ToolboxValueFilterSection");
|
|
80
81
|
var ToolboxTextFilterSection_1 = require("./ToolboxTextFilterSection");
|
|
81
82
|
var ToolboxNumberFilterSection_1 = require("./ToolboxNumberFilterSection");
|
|
82
83
|
var ToolboxCustomSection_1 = require("./ToolboxCustomSection");
|
|
84
|
+
var ToolboxColumnVisibilitySection_1 = require("./ToolboxColumnVisibilitySection");
|
|
83
85
|
var EditorPortalRoot_1 = require("../EditorPortalRoot");
|
|
84
86
|
function readToolboxTheme(anchorEl) {
|
|
85
87
|
var e_1, _a;
|
|
@@ -155,6 +157,7 @@ function TableHeadToolbox(_a) {
|
|
|
155
157
|
var popoverRef = (0, react_1.useRef)(null);
|
|
156
158
|
var floatingPortal = React.useContext(EditorPortalRoot_1.EditorPortalContext);
|
|
157
159
|
var _d = __read((0, react_1.useState)({ top: -9999, left: -9999 }), 2), position = _d[0], setPosition = _d[1];
|
|
160
|
+
var _e = __read((0, react_1.useState)('menu'), 2), visibilityMode = _e[0], setVisibilityMode = _e[1];
|
|
158
161
|
var toolboxThemeStyle = React.useMemo(function () { return readToolboxTheme(anchorEl); }, [anchorEl]);
|
|
159
162
|
var toolboxConfig = typeof column.toolbox === 'object' ? column.toolbox : undefined;
|
|
160
163
|
var showSort = column.sortDisable !== true &&
|
|
@@ -162,6 +165,7 @@ function TableHeadToolbox(_a) {
|
|
|
162
165
|
var filterType = typeof column.filter === 'object' && ((_b = column.filter) === null || _b === void 0 ? void 0 : _b.type) ? column.filter.type : 'values';
|
|
163
166
|
var showFilter = column.filter !== false &&
|
|
164
167
|
(column.toolbox === true || (toolboxConfig === null || toolboxConfig === void 0 ? void 0 : toolboxConfig.filter) === true);
|
|
168
|
+
var showColumnVisibility = !!(0, store_1.useAppStore)(function (s) { return s.columnVisibilityState; });
|
|
165
169
|
// Position calculation with boundary adjustments
|
|
166
170
|
var updatePosition = React.useCallback(function () {
|
|
167
171
|
if (!anchorEl || !anchorEl.isConnected || !popoverRef.current) {
|
|
@@ -299,10 +303,11 @@ function TableHeadToolbox(_a) {
|
|
|
299
303
|
if (typeof document === 'undefined')
|
|
300
304
|
return null;
|
|
301
305
|
return (0, react_dom_1.createPortal)(React.createElement("div", { ref: popoverRef, id: dialogId, role: "dialog", "aria-modal": "true", "aria-labelledby": triggerId, className: "bgrid-toolbox-popover", style: __assign(__assign({}, toolboxThemeStyle), { top: "".concat(position.top, "px"), left: "".concat(position.left, "px") }), onClick: function (e) { return e.stopPropagation(); } },
|
|
302
|
-
showSort && React.createElement(ToolboxSortSection_1.ToolboxSortSection, { column: column, columnId: columnId }),
|
|
303
|
-
showFilter && (React.createElement(React.Fragment, null,
|
|
306
|
+
visibilityMode === 'menu' && showSort && React.createElement(ToolboxSortSection_1.ToolboxSortSection, { column: column, columnId: columnId }),
|
|
307
|
+
visibilityMode === 'menu' && showFilter && (React.createElement(React.Fragment, null,
|
|
304
308
|
filterType === 'values' && (React.createElement(ToolboxValueFilterSection_1.ToolboxValueFilterSection, { column: column, columnId: columnId })),
|
|
305
309
|
filterType === 'text' && (React.createElement(ToolboxTextFilterSection_1.ToolboxTextFilterSection, { column: column, columnId: columnId })),
|
|
306
310
|
filterType === 'number' && (React.createElement(ToolboxNumberFilterSection_1.ToolboxNumberFilterSection, { column: column, columnId: columnId })))),
|
|
307
|
-
toolboxConfig && (React.createElement(ToolboxCustomSection_1.ToolboxCustomSection, { column: column, columnId: columnId, columnIndex: columnIndex, config: toolboxConfig, close: onClose }))
|
|
311
|
+
visibilityMode === 'menu' && toolboxConfig && (React.createElement(ToolboxCustomSection_1.ToolboxCustomSection, { column: column, columnId: columnId, columnIndex: columnIndex, config: toolboxConfig, close: onClose })),
|
|
312
|
+
showColumnVisibility && (React.createElement(ToolboxColumnVisibilitySection_1.ToolboxColumnVisibilitySection, { column: column, columnId: columnId, mode: visibilityMode, onModeChange: setVisibilityMode, close: onClose }))), (_c = floatingPortal === null || floatingPortal === void 0 ? void 0 : floatingPortal.portalRef.current) !== null && _c !== void 0 ? _c : document.body);
|
|
308
313
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
36
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
37
|
+
if (!m) return o;
|
|
38
|
+
var i = m.call(o), r, ar = [], e;
|
|
39
|
+
try {
|
|
40
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
41
|
+
}
|
|
42
|
+
catch (error) { e = { error: error }; }
|
|
43
|
+
finally {
|
|
44
|
+
try {
|
|
45
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
46
|
+
}
|
|
47
|
+
finally { if (e) throw e.error; }
|
|
48
|
+
}
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
52
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
53
|
+
if (ar || !(i in from)) {
|
|
54
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
55
|
+
ar[i] = from[i];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.ToolboxColumnVisibilitySection = ToolboxColumnVisibilitySection;
|
|
62
|
+
var React = __importStar(require("react"));
|
|
63
|
+
var store_1 = require("../../store");
|
|
64
|
+
function accessibleLabel(label, fallback) {
|
|
65
|
+
return typeof label === 'string' || typeof label === 'number' ? String(label) : fallback;
|
|
66
|
+
}
|
|
67
|
+
function ToolboxColumnVisibilitySection(_a) {
|
|
68
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
69
|
+
var column = _a.column, columnId = _a.columnId, mode = _a.mode, onModeChange = _a.onModeChange, close = _a.close;
|
|
70
|
+
var visibility = (0, store_1.useAppStore)(function (s) { return s.columnVisibilityState; });
|
|
71
|
+
var globalIcons = (0, store_1.useAppStore)(function (s) { return s.icons; });
|
|
72
|
+
var columnIcons = typeof column.toolbox === 'object' ? column.toolbox.icons : undefined;
|
|
73
|
+
var hiddenItems = (_b = visibility === null || visibility === void 0 ? void 0 : visibility.items.filter(function (item) { return item.hidden; })) !== null && _b !== void 0 ? _b : [];
|
|
74
|
+
React.useEffect(function () {
|
|
75
|
+
if (mode === 'hidden' && hiddenItems.length === 0)
|
|
76
|
+
onModeChange('menu');
|
|
77
|
+
}, [hiddenItems.length, mode, onModeChange]);
|
|
78
|
+
if (!visibility)
|
|
79
|
+
return null;
|
|
80
|
+
var visibleCount = visibility.items.length - hiddenItems.length;
|
|
81
|
+
var currentItem = visibility.items.find(function (item) { return item.columnId === columnId; });
|
|
82
|
+
var canHideCurrent = !!(currentItem === null || currentItem === void 0 ? void 0 : currentItem.hideable) && visibleCount > 1;
|
|
83
|
+
var hideIcon = (_d = (_c = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.hideColumn) !== null && _c !== void 0 ? _c : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.hideColumn) !== null && _d !== void 0 ? _d : (React.createElement("svg", { className: 'bgrid-toolbox-icon', viewBox: '0 0 16 16', width: '14', height: '14', fill: 'none', stroke: 'currentColor', strokeWidth: '1.4' },
|
|
84
|
+
React.createElement("path", { d: 'M2 2l12 12' }),
|
|
85
|
+
React.createElement("path", { d: 'M6.2 4.1A6.8 6.8 0 0 1 8 3.8c3.4 0 5.6 3.2 5.6 3.2a9 9 0 0 1-1.8 2.1M9.5 9.4A2.1 2.1 0 0 1 6.6 6.5M4.2 5.1A9.4 9.4 0 0 0 2.4 7S4.6 10.2 8 10.2c.5 0 1-.1 1.4-.2' })));
|
|
86
|
+
var showIcon = (_f = (_e = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.showColumn) !== null && _e !== void 0 ? _e : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.showColumn) !== null && _f !== void 0 ? _f : (React.createElement("svg", { className: 'bgrid-toolbox-icon', viewBox: '0 0 16 16', width: '14', height: '14', fill: 'none', stroke: 'currentColor', strokeWidth: '1.4' },
|
|
87
|
+
React.createElement("path", { d: 'M2.2 8s2.2-3.4 5.8-3.4S13.8 8 13.8 8s-2.2 3.4-5.8 3.4S2.2 8 2.2 8z' }),
|
|
88
|
+
React.createElement("circle", { cx: '8', cy: '8', r: '1.7' })));
|
|
89
|
+
var columnsIcon = (_h = (_g = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.columns) !== null && _g !== void 0 ? _g : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.columns) !== null && _h !== void 0 ? _h : (React.createElement("svg", { className: 'bgrid-toolbox-icon', viewBox: '0 0 16 16', width: '14', height: '14', fill: 'none', stroke: 'currentColor', strokeWidth: '1.4' },
|
|
90
|
+
React.createElement("rect", { x: '2.2', y: '2.5', width: '11.6', height: '11', rx: '1' }),
|
|
91
|
+
React.createElement("path", { d: 'M6 2.5v11M10 2.5v11' })));
|
|
92
|
+
if (mode === 'hidden') {
|
|
93
|
+
return (React.createElement("div", { className: 'bgrid-toolbox-section bgrid-toolbox-visibility-section' },
|
|
94
|
+
React.createElement("div", { className: 'bgrid-toolbox-visibility-header' },
|
|
95
|
+
React.createElement("button", { type: 'button', className: 'bgrid-toolbox-icon-button', "aria-label": '\uCEEC\uB7FC \uBA54\uB274\uB85C \uB3CC\uC544\uAC00\uAE30', onClick: function () { return onModeChange('menu'); } },
|
|
96
|
+
React.createElement("span", { "aria-hidden": 'true' }, "\u2039")),
|
|
97
|
+
React.createElement("span", { className: 'bgrid-toolbox-visibility-title' }, "\uC228\uAE34 \uCEEC\uB7FC")),
|
|
98
|
+
React.createElement("div", { className: 'bgrid-toolbox-hidden-list' }, hiddenItems.map(function (item) {
|
|
99
|
+
var label = accessibleLabel(item.column.label, item.columnId);
|
|
100
|
+
return (React.createElement("button", { key: item.columnId, type: 'button', className: 'bgrid-toolbox-menu-item', "aria-label": "".concat(label, " \uCEEC\uB7FC \uD45C\uC2DC"), onClick: function () {
|
|
101
|
+
visibility.onChange(visibility.hiddenColumnIds.filter(function (id) { return id !== item.columnId; }), { type: 'show', columnId: item.columnId, column: item.column });
|
|
102
|
+
} },
|
|
103
|
+
React.createElement("span", { className: 'bgrid-toolbox-icon-wrapper' }, showIcon),
|
|
104
|
+
React.createElement("span", { className: 'bgrid-toolbox-menu-label' }, item.column.label)));
|
|
105
|
+
})),
|
|
106
|
+
React.createElement("button", { type: 'button', className: 'bgrid-toolbox-menu-item bgrid-toolbox-show-all', onClick: function () {
|
|
107
|
+
visibility.onChange([], { type: 'showAll' });
|
|
108
|
+
close();
|
|
109
|
+
} },
|
|
110
|
+
React.createElement("span", { className: 'bgrid-toolbox-icon-wrapper' }, columnsIcon),
|
|
111
|
+
React.createElement("span", null, "\uBAA8\uB450 \uD45C\uC2DC"))));
|
|
112
|
+
}
|
|
113
|
+
return (React.createElement("div", { className: 'bgrid-toolbox-section bgrid-toolbox-visibility-section' },
|
|
114
|
+
React.createElement("div", { className: 'bgrid-toolbox-section-title' }, "\uCEEC\uB7FC"),
|
|
115
|
+
React.createElement("div", { className: 'bgrid-toolbox-menu-list' },
|
|
116
|
+
React.createElement("button", { type: 'button', className: 'bgrid-toolbox-menu-item', disabled: !canHideCurrent, "aria-label": "".concat(accessibleLabel(column.label, columnId), " \uCEEC\uB7FC \uC228\uAE30\uAE30"), title: !canHideCurrent && visibleCount <= 1 ? '최소 한 개의 컬럼은 표시해야 합니다.' : undefined, onClick: function () {
|
|
117
|
+
if (!canHideCurrent)
|
|
118
|
+
return;
|
|
119
|
+
visibility.onChange(__spreadArray(__spreadArray([], __read(visibility.hiddenColumnIds), false), [columnId], false), { type: 'hide', columnId: columnId, column: currentItem === null || currentItem === void 0 ? void 0 : currentItem.column });
|
|
120
|
+
close();
|
|
121
|
+
} },
|
|
122
|
+
React.createElement("span", { className: 'bgrid-toolbox-icon-wrapper' }, hideIcon),
|
|
123
|
+
React.createElement("span", null, "\uC774 \uCEEC\uB7FC \uC228\uAE30\uAE30")),
|
|
124
|
+
hiddenItems.length > 0 && (React.createElement("button", { type: 'button', className: 'bgrid-toolbox-menu-item', "aria-label": "\uC228\uAE34 \uCEEC\uB7FC ".concat(hiddenItems.length, "\uAC1C \uAD00\uB9AC"), onClick: function () { return onModeChange('hidden'); } },
|
|
125
|
+
React.createElement("span", { className: 'bgrid-toolbox-icon-wrapper' }, columnsIcon),
|
|
126
|
+
React.createElement("span", { className: 'bgrid-toolbox-menu-label' },
|
|
127
|
+
"\uC228\uAE34 \uCEEC\uB7FC ",
|
|
128
|
+
hiddenItems.length,
|
|
129
|
+
"\uAC1C"),
|
|
130
|
+
React.createElement("span", { className: 'bgrid-toolbox-menu-chevron', "aria-hidden": 'true' }, "\u203A"))))));
|
|
131
|
+
}
|
|
@@ -20,3 +20,4 @@ __exportStar(require("./ToolboxValueFilterSection"), exports);
|
|
|
20
20
|
__exportStar(require("./ToolboxTextFilterSection"), exports);
|
|
21
21
|
__exportStar(require("./ToolboxNumberFilterSection"), exports);
|
|
22
22
|
__exportStar(require("./ToolboxCustomSection"), exports);
|
|
23
|
+
__exportStar(require("./ToolboxColumnVisibilitySection"), exports);
|
|
@@ -262,6 +262,7 @@ function AppStoreProvider(_a) {
|
|
|
262
262
|
dataControl: initialState === null || initialState === void 0 ? void 0 : initialState.dataControl,
|
|
263
263
|
filterDrafts: (_16 = initialState === null || initialState === void 0 ? void 0 : initialState.filterDrafts) !== null && _16 !== void 0 ? _16 : {},
|
|
264
264
|
activeToolboxColumnId: (_17 = initialState === null || initialState === void 0 ? void 0 : initialState.activeToolboxColumnId) !== null && _17 !== void 0 ? _17 : null,
|
|
265
|
+
columnVisibilityState: initialState === null || initialState === void 0 ? void 0 : initialState.columnVisibilityState,
|
|
265
266
|
searchOptions: initialState === null || initialState === void 0 ? void 0 : initialState.searchOptions,
|
|
266
267
|
contextMenuOptions: initialState === null || initialState === void 0 ? void 0 : initialState.contextMenuOptions,
|
|
267
268
|
searchOpen: (_22 = (_20 = (_19 = (_18 = initialState === null || initialState === void 0 ? void 0 : initialState.searchOptions) === null || _18 === void 0 ? void 0 : _18.open) !== null && _19 !== void 0 ? _19 : initialState === null || initialState === void 0 ? void 0 : initialState.searchOpen) !== null && _20 !== void 0 ? _20 : (_21 = initialState === null || initialState === void 0 ? void 0 : initialState.searchOptions) === null || _21 === void 0 ? void 0 : _21.defaultOpen) !== null && _22 !== void 0 ? _22 : false,
|
|
@@ -499,6 +500,7 @@ function AppStoreProvider(_a) {
|
|
|
499
500
|
}, (_a = {}, _a[columnId] = appliedFilter ? __assign({}, appliedFilter) : undefined, _a)) }));
|
|
500
501
|
});
|
|
501
502
|
},
|
|
503
|
+
setColumnVisibilityState: function (columnVisibilityState) { return set({ columnVisibilityState: columnVisibilityState }); },
|
|
502
504
|
setSearchOptions: function (options) {
|
|
503
505
|
return set(function (state) {
|
|
504
506
|
var _a, _b;
|