beautiful-grid 1.0.6 → 1.0.7
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 +16 -16
- package/cjs/components/ColResizer.js +8 -3
- package/cjs/components/Pagination.js +8 -5
- package/cjs/components/Table.js +62 -36
- package/cjs/components/TableBody.js +10 -15
- package/cjs/components/TableHead.js +6 -8
- package/cjs/components/TableHeadColumn.js +20 -18
- package/cjs/components/TableHeadFrozen.js +7 -9
- package/cjs/store/createAppStore.js +109 -27
- package/esm/BGrid.js +17 -15
- package/esm/components/ColResizer.js +8 -3
- package/esm/components/Pagination.js +8 -5
- package/esm/components/Table.js +62 -33
- package/esm/components/TableBody.js +11 -16
- package/esm/components/TableHead.js +6 -8
- package/esm/components/TableHeadColumn.js +20 -18
- package/esm/components/TableHeadFrozen.js +7 -9
- package/esm/store/createAppStore.js +125 -29
- package/package.json +1 -1
- package/style.css +58 -28
- package/types/BGrid.d.ts +1 -1
- package/types/components/Table.d.ts +1 -0
- package/types/store/createAppStore.d.ts +1 -1
- package/types/types.d.ts +4 -0
|
@@ -58,6 +58,7 @@ function TableHeadColumn(_a) {
|
|
|
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
60
|
var columnVisibilityState = (0, store_1.useAppStore)(function (s) { return s.columnVisibilityState; });
|
|
61
|
+
var disabled = (0, store_1.useAppStore)(function (s) { return s.disabled; });
|
|
61
62
|
var columnId = (_b = column.columnId) !== null && _b !== void 0 ? _b : (0, utils_1.getColumnId)(column);
|
|
62
63
|
var buttonRef = (0, react_1.useRef)(null);
|
|
63
64
|
var reactId = React.useId().replace(/:/g, '');
|
|
@@ -65,7 +66,7 @@ function TableHeadColumn(_a) {
|
|
|
65
66
|
var dialogId = "bgrid-toolbox-dialog-".concat(reactId);
|
|
66
67
|
var visibilityItem = columnVisibilityState === null || columnVisibilityState === void 0 ? void 0 : columnVisibilityState.items.find(function (item) { return item.columnId === columnId; });
|
|
67
68
|
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;
|
|
69
|
+
var isToolboxEnabled = !disabled && (!!column.toolbox || isVisibilityMenuEnabled);
|
|
69
70
|
var isToolboxOpen = activeToolboxColumnId === columnId;
|
|
70
71
|
var columnIcons = typeof column.toolbox === 'object' ? column.toolbox.icons : undefined;
|
|
71
72
|
var hasCheckboxHeader = ((_c = column.editor) === null || _c === void 0 ? void 0 : _c.type) === 'checkbox' && !!column.editor.header;
|
|
@@ -73,7 +74,8 @@ function TableHeadColumn(_a) {
|
|
|
73
74
|
hasCheckboxHeader && React.createElement(CheckboxHeaderControl_1.CheckboxHeaderControl, { column: column, columnIndex: columnIndex }),
|
|
74
75
|
React.createElement("span", { className: 'bgrid-head-column-label-text' }, column.label)));
|
|
75
76
|
// Check sort status
|
|
76
|
-
var activeSortParam = (_d = dataQuery === null || dataQuery === void 0 ? void 0 : dataQuery.sortParams.find(function (s) { var _a; return ((_a = s.columnId) !== null && _a !== void 0 ? _a : s.key) === columnId; })) !== null && _d !== void 0 ? _d : ((sortParams === null || sortParams === void 0 ? void 0 : sortParams[columnId]) ||
|
|
77
|
+
var activeSortParam = (_d = dataQuery === null || dataQuery === void 0 ? void 0 : dataQuery.sortParams.find(function (s) { var _a; return ((_a = s.columnId) !== null && _a !== void 0 ? _a : s.key) === columnId; })) !== null && _d !== void 0 ? _d : ((sortParams === null || sortParams === void 0 ? void 0 : sortParams[columnId]) ||
|
|
78
|
+
(column.key ? sortParams === null || sortParams === void 0 ? void 0 : sortParams[Array.isArray(column.key) ? column.key.join('.') : column.key] : undefined));
|
|
77
79
|
var isAsc = (activeSortParam === null || activeSortParam === void 0 ? void 0 : activeSortParam.orderBy) === 'asc';
|
|
78
80
|
var isDesc = (activeSortParam === null || activeSortParam === void 0 ? void 0 : activeSortParam.orderBy) === 'desc';
|
|
79
81
|
var sortIndex = activeSortParam && dataQuery && dataQuery.sortParams.length > 1
|
|
@@ -94,28 +96,28 @@ function TableHeadColumn(_a) {
|
|
|
94
96
|
tooltipParts.push('필터 적용됨');
|
|
95
97
|
var tooltip = tooltipParts.length > 0 ? tooltipParts.join(', ') : '컬럼 옵션 열기';
|
|
96
98
|
// Resolve icons with hierarchy (column -> global -> default)
|
|
97
|
-
var sortAscIcon = (_f = (_e = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.sortAsc) !== null && _e !== void 0 ? _e : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.sortAsc) !== null && _f !== void 0 ? _f : (React.createElement("svg", { viewBox:
|
|
98
|
-
React.createElement("path", { d:
|
|
99
|
-
var sortDescIcon = (_h = (_g = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.sortDesc) !== null && _g !== void 0 ? _g : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.sortDesc) !== null && _h !== void 0 ? _h : (React.createElement("svg", { viewBox:
|
|
100
|
-
React.createElement("path", { d:
|
|
101
|
-
var filterIcon = (_k = (_j = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.filter) !== null && _j !== void 0 ? _j : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.filter) !== null && _k !== void 0 ? _k : (React.createElement("svg", { viewBox:
|
|
102
|
-
React.createElement("path", { d:
|
|
103
|
-
var filterBadgeIcon = (_m = (_l = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.filterBadge) !== null && _l !== void 0 ? _l : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.filterBadge) !== null && _m !== void 0 ? _m : (React.createElement("svg", { viewBox:
|
|
104
|
-
React.createElement("path", { d:
|
|
105
|
-
var dropdownIcon = (_p = (_o = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.dropdown) !== null && _o !== void 0 ? _o : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.dropdown) !== null && _p !== void 0 ? _p : (React.createElement("svg", { viewBox:
|
|
106
|
-
React.createElement("path", { d:
|
|
99
|
+
var sortAscIcon = (_f = (_e = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.sortAsc) !== null && _e !== void 0 ? _e : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.sortAsc) !== null && _f !== void 0 ? _f : (React.createElement("svg", { viewBox: '0 0 16 16', width: '10', height: '10', fill: 'currentColor' },
|
|
100
|
+
React.createElement("path", { d: 'M3 11.5L8 4l5 7.5H3z' })));
|
|
101
|
+
var sortDescIcon = (_h = (_g = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.sortDesc) !== null && _g !== void 0 ? _g : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.sortDesc) !== null && _h !== void 0 ? _h : (React.createElement("svg", { viewBox: '0 0 16 16', width: '10', height: '10', fill: 'currentColor' },
|
|
102
|
+
React.createElement("path", { d: 'M3 4.5L8 12l5-7.5H3z' })));
|
|
103
|
+
var filterIcon = (_k = (_j = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.filter) !== null && _j !== void 0 ? _j : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.filter) !== null && _k !== void 0 ? _k : (React.createElement("svg", { viewBox: '0 0 16 16', width: '12', height: '12', fill: 'currentColor', className: 'bgrid-filter-icon' },
|
|
104
|
+
React.createElement("path", { d: 'M1.5 1.5A.5.5 0 0 1 2 1h12a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.128.334L10 8.293V13.5a.5.5 0 0 1-.74.439l-2.5-1.5A.5.5 0 0 1 6.5 12V8.293L1.628 3.834A.5.5 0 0 1 1.5 3.5v-2z' })));
|
|
105
|
+
var filterBadgeIcon = (_m = (_l = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.filterBadge) !== null && _l !== void 0 ? _l : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.filterBadge) !== null && _m !== void 0 ? _m : (React.createElement("svg", { viewBox: '0 0 16 16', width: '10', height: '10', fill: 'currentColor', className: 'bgrid-filter-badge-icon' },
|
|
106
|
+
React.createElement("path", { d: 'M1.5 1.5A.5.5 0 0 1 2 1h12a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.128.334L10 8.293V13.5a.5.5 0 0 1-.74.439l-2.5-1.5A.5.5 0 0 1 6.5 12V8.293L1.628 3.834A.5.5 0 0 1 1.5 3.5v-2z' })));
|
|
107
|
+
var dropdownIcon = (_p = (_o = columnIcons === null || columnIcons === void 0 ? void 0 : columnIcons.dropdown) !== null && _o !== void 0 ? _o : globalIcons === null || globalIcons === void 0 ? void 0 : globalIcons.dropdown) !== null && _p !== void 0 ? _p : (React.createElement("svg", { viewBox: '0 0 16 16', width: '10', height: '10', fill: 'currentColor', className: 'bgrid-dropdown-arrow' },
|
|
108
|
+
React.createElement("path", { d: 'M3 6l5 5 5-5H3z' })));
|
|
107
109
|
if (isToolboxEnabled) {
|
|
108
|
-
return (React.createElement("div", { className:
|
|
109
|
-
React.createElement("span", { className:
|
|
110
|
-
React.createElement("button", { ref: buttonRef, id: triggerId, type:
|
|
110
|
+
return (React.createElement("div", { className: 'bgrid-head-cell-wrapper' },
|
|
111
|
+
React.createElement("span", { className: 'bgrid-head-column-label bgrid-column-drag-handle' }, headerLabel),
|
|
112
|
+
React.createElement("button", { ref: buttonRef, id: triggerId, type: 'button', "aria-haspopup": 'dialog', "aria-expanded": isToolboxOpen, "aria-controls": dialogId, "aria-label": "".concat(String(column.label || columnId), " \uCEEC\uB7FC \uBA54\uB274"), title: tooltip, className: "bgrid-toolbox-trigger-btn ".concat(isToolboxOpen ? 'active' : '', " ").concat(isFiltered ? 'is-filtered' : '', " ").concat(isAsc || isDesc ? 'is-sorted' : ''), onClick: function (e) {
|
|
111
113
|
e.preventDefault();
|
|
112
114
|
e.stopPropagation();
|
|
113
115
|
setActiveToolbox(isToolboxOpen ? null : columnId);
|
|
114
116
|
}, onMouseDown: function (e) { return e.stopPropagation(); }, onPointerEnter: function () { return void loadTableHeadToolbox(); }, onFocus: function () { return void loadTableHeadToolbox(); } },
|
|
115
|
-
isFiltered && (isAsc || isDesc) ? (React.createElement("span", { className:
|
|
117
|
+
isFiltered && (isAsc || isDesc) ? (React.createElement("span", { className: 'bgrid-icon-combo' },
|
|
116
118
|
isAsc ? sortAscIcon : sortDescIcon,
|
|
117
119
|
filterBadgeIcon)) : isFiltered ? (filterIcon) : isAsc ? (sortAscIcon) : isDesc ? (sortDescIcon) : (dropdownIcon),
|
|
118
|
-
sortIndex && React.createElement("span", { className:
|
|
120
|
+
sortIndex && React.createElement("span", { className: 'bgrid-sort-index-badge' }, sortIndex)),
|
|
119
121
|
isToolboxOpen && (React.createElement(React.Suspense, { fallback: null },
|
|
120
122
|
React.createElement(LazyTableHeadToolbox, { anchorEl: buttonRef.current, column: column, columnId: columnId, columnIndex: columnIndex, dialogId: dialogId, triggerId: triggerId, onClose: function () { return setActiveToolbox(null); } })))));
|
|
121
123
|
}
|
|
@@ -124,7 +126,7 @@ function TableHeadColumn(_a) {
|
|
|
124
126
|
return (React.createElement("div", { className: 'bgrid-head-column' },
|
|
125
127
|
React.createElement("span", { className: 'bgrid-head-column-label bgrid-column-drag-handle' }, headerLabel),
|
|
126
128
|
React.createElement("span", { className: 'bgrid-sorter', "data-sort": activeSortParam === null || activeSortParam === void 0 ? void 0 : activeSortParam.orderBy }),
|
|
127
|
-
activeSortParam && sortIndex &&
|
|
129
|
+
activeSortParam && sortIndex && React.createElement("div", { className: 'bgrid-sort-order' }, sortIndex)));
|
|
128
130
|
}
|
|
129
131
|
return (React.createElement("div", { className: 'bgrid-head-column' },
|
|
130
132
|
React.createElement("span", { className: 'bgrid-head-column-label bgrid-column-drag-handle' }, headerLabel)));
|
|
@@ -87,7 +87,8 @@ function TableHeadFrozen(_a) {
|
|
|
87
87
|
frozenColumnIndex: s.frozenColumnIndex,
|
|
88
88
|
columnResizing: s.columnResizing,
|
|
89
89
|
columnSortable: s.columnSortable,
|
|
90
|
-
|
|
90
|
+
disabled: s.disabled,
|
|
91
|
+
}); })), sort = _b.sort, dataControl = _b.dataControl, headerHeight = _b.headerHeight, columns = _b.columns, columnsGroup = _b.columnsGroup, columnGroups = _b.columnGroups, frozenColumnIndex = _b.frozenColumnIndex, columnResizing = _b.columnResizing, columnSortable = _b.columnSortable, disabled = _b.disabled;
|
|
91
92
|
// [Selector Group 2] Selection State - 선택 상태
|
|
92
93
|
var _c = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
93
94
|
rowChecked: s.rowChecked,
|
|
@@ -114,7 +115,7 @@ function TableHeadFrozen(_a) {
|
|
|
114
115
|
var nestedGroupsActive = columnGroups.length > 0;
|
|
115
116
|
var handleSorted = React.useCallback(function () { return setSorted(true); }, []);
|
|
116
117
|
(0, useColumnSortable_1.useColumnSortable)({
|
|
117
|
-
enabled: !!columnSortable && !sorted,
|
|
118
|
+
enabled: !disabled && !!columnSortable && !sorted,
|
|
118
119
|
tbodyRef: tbodyRef,
|
|
119
120
|
columnsTable: columnsTable,
|
|
120
121
|
nestedGroupsActive: nestedGroupsActive,
|
|
@@ -132,25 +133,22 @@ function TableHeadFrozen(_a) {
|
|
|
132
133
|
React.createElement("tbody", { role: 'rfdg-head-frozen', ref: tbodyRef }, columnsTable.map(function (row, ri) {
|
|
133
134
|
return (React.createElement("tr", { key: ri, "data-columns-tr": ri },
|
|
134
135
|
ri === 0 && showLineNumber && (React.createElement(TableHead_1.HeadTd, { className: ['rfdg-tr-line-number', !rowChecked ? 'bordered' : ''].filter(Boolean).join(' '), rowSpan: columnsTable.length, bottomBorder: true }, "\u00A0")),
|
|
135
|
-
ri === 0 && !!rowChecked && (React.createElement(TableHead_1.HeadTd, { rowSpan: columnsTable.length, className: 'bordered', bottomBorder: true }, !(rowChecked === null || rowChecked === void 0 ? void 0 : rowChecked.isRadio) && (React.createElement(RowSelector_1.default, { checked: checkedAll === true, indeterminate: checkedAll === 'indeterminate', handleChange: function (checked) {
|
|
136
|
+
ri === 0 && !!rowChecked && (React.createElement(TableHead_1.HeadTd, { rowSpan: columnsTable.length, className: 'bordered', bottomBorder: true }, !(rowChecked === null || rowChecked === void 0 ? void 0 : rowChecked.isRadio) && (React.createElement(RowSelector_1.default, { checked: checkedAll === true, indeterminate: checkedAll === 'indeterminate', disabled: !!disabled, handleChange: function (checked) {
|
|
136
137
|
setCheckedAll(checked);
|
|
137
138
|
} })))),
|
|
138
139
|
row.map(function (c) {
|
|
139
140
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
140
141
|
if (c.type === 'group') {
|
|
141
142
|
return (React.createElement(TableHead_1.HeadGroupTd, { key: c.key, "data-column-index": c.startColumnIndex, "data-group-id": c.groupId, "data-header-cell-type": 'group', "data-bgrid-axis-selectable": 'true', colSpan: c.colSpan, className: [
|
|
142
|
-
columnSortable && !nestedGroupsActive ? 'drag-item' : '',
|
|
143
|
+
!disabled && columnSortable && !nestedGroupsActive ? 'drag-item' : '',
|
|
143
144
|
(_a = c.className) !== null && _a !== void 0 ? _a : '',
|
|
144
145
|
]
|
|
145
146
|
.filter(Boolean)
|
|
146
147
|
.join(' '), style: __assign(__assign({}, c.headerStyle), { textAlign: (_d = (_b = c.headerAlign) !== null && _b !== void 0 ? _b : (_c = c.headerStyle) === null || _c === void 0 ? void 0 : _c.textAlign) !== null && _d !== void 0 ? _d : 'center' }) },
|
|
147
148
|
React.createElement("span", { className: 'bgrid-column-drag-handle' }, c.label)));
|
|
148
149
|
}
|
|
149
|
-
var sortEnabled = !((_e = c.column) === null || _e === void 0 ? void 0 : _e.sortDisable) && (!!sort || !!dataControl);
|
|
150
|
-
return (React.createElement(TableHead_1.HeadTd, { "data-column-index": c.columnIndex, "data-header-cell-type": 'column', "data-bgrid-axis-selectable": !sortEnabled ? 'true' : undefined, "data-parent-group-id": c.parentGroupId, key: c.key, rowSpan: c.rowSpan, bottomBorder: (0, TableHead_1.isHeadCellOnBottomRow)(ri, c.rowSpan, columnsTable.length), style: __assign(__assign({}, c.headerStyle), { textAlign: (_h = (_f = c.headerAlign) !== null && _f !== void 0 ? _f : (_g = c.headerStyle) === null || _g === void 0 ? void 0 : _g.textAlign) !== null && _h !== void 0 ? _h : 'center' }), className: [
|
|
151
|
-
columnSortable ? 'drag-item' : '',
|
|
152
|
-
(_j = c.className) !== null && _j !== void 0 ? _j : '',
|
|
153
|
-
]
|
|
150
|
+
var sortEnabled = !disabled && !((_e = c.column) === null || _e === void 0 ? void 0 : _e.sortDisable) && (!!sort || !!dataControl);
|
|
151
|
+
return (React.createElement(TableHead_1.HeadTd, { "data-column-index": c.columnIndex, "data-header-cell-type": 'column', "data-bgrid-axis-selectable": !sortEnabled ? 'true' : undefined, "data-parent-group-id": c.parentGroupId, key: c.key, rowSpan: c.rowSpan, bottomBorder: (0, TableHead_1.isHeadCellOnBottomRow)(ri, c.rowSpan, columnsTable.length), style: __assign(__assign({}, c.headerStyle), { textAlign: (_h = (_f = c.headerAlign) !== null && _f !== void 0 ? _f : (_g = c.headerStyle) === null || _g === void 0 ? void 0 : _g.textAlign) !== null && _h !== void 0 ? _h : 'center' }), className: [!disabled && columnSortable ? 'drag-item' : '', (_j = c.className) !== null && _j !== void 0 ? _j : '']
|
|
154
152
|
.filter(Boolean)
|
|
155
153
|
.join(' '), hasOnClick: sortEnabled, columnResizing: columnResizing, onClick: function (evt) {
|
|
156
154
|
evt.preventDefault();
|
|
@@ -244,13 +244,18 @@ function AppStoreProvider(_a) {
|
|
|
244
244
|
checkedAll: (_1 = initialState === null || initialState === void 0 ? void 0 : initialState.checkedAll) !== null && _1 !== void 0 ? _1 : false,
|
|
245
245
|
displayPaginationLength: (_2 = initialState === null || initialState === void 0 ? void 0 : initialState.displayPaginationLength) !== null && _2 !== void 0 ? _2 : 0,
|
|
246
246
|
loading: (_3 = initialState === null || initialState === void 0 ? void 0 : initialState.loading) !== null && _3 !== void 0 ? _3 : false,
|
|
247
|
+
disabled: initialState === null || initialState === void 0 ? void 0 : initialState.disabled,
|
|
247
248
|
editTrigger: (_4 = initialState === null || initialState === void 0 ? void 0 : initialState.editTrigger) !== null && _4 !== void 0 ? _4 : 'dblclick',
|
|
248
249
|
cellMergeOptions: initialState === null || initialState === void 0 ? void 0 : initialState.cellMergeOptions,
|
|
249
250
|
variant: (_5 = initialState === null || initialState === void 0 ? void 0 : initialState.variant) !== null && _5 !== void 0 ? _5 : 'default',
|
|
250
251
|
columnSortable: (_6 = initialState === null || initialState === void 0 ? void 0 : initialState.columnSortable) !== null && _6 !== void 0 ? _6 : false,
|
|
251
252
|
reordering: false,
|
|
252
|
-
activeCell: (
|
|
253
|
-
|
|
253
|
+
activeCell: (initialState === null || initialState === void 0 ? void 0 : initialState.disabled)
|
|
254
|
+
? undefined
|
|
255
|
+
: (_9 = (_7 = initialState === null || initialState === void 0 ? void 0 : initialState.activeCell) !== null && _7 !== void 0 ? _7 : (_8 = initialState === null || initialState === void 0 ? void 0 : initialState.cellNavigationOptions) === null || _8 === void 0 ? void 0 : _8.activeCell) !== null && _9 !== void 0 ? _9 : (_10 = initialState === null || initialState === void 0 ? void 0 : initialState.cellNavigationOptions) === null || _10 === void 0 ? void 0 : _10.defaultActiveCell,
|
|
256
|
+
activeCellHost: (initialState === null || initialState === void 0 ? void 0 : initialState.disabled)
|
|
257
|
+
? undefined
|
|
258
|
+
: (_14 = (_12 = (_11 = initialState === null || initialState === void 0 ? void 0 : initialState.activeCellHost) !== null && _11 !== void 0 ? _11 : initialState === null || initialState === void 0 ? void 0 : initialState.activeCell) !== null && _12 !== void 0 ? _12 : (_13 = initialState === null || initialState === void 0 ? void 0 : initialState.cellNavigationOptions) === null || _13 === void 0 ? void 0 : _13.activeCell) !== null && _14 !== void 0 ? _14 : (_15 = initialState === null || initialState === void 0 ? void 0 : initialState.cellNavigationOptions) === null || _15 === void 0 ? void 0 : _15.defaultActiveCell,
|
|
254
259
|
cellInteractionSession: initialState === null || initialState === void 0 ? void 0 : initialState.cellInteractionSession,
|
|
255
260
|
cellNavigationOptions: initialState === null || initialState === void 0 ? void 0 : initialState.cellNavigationOptions,
|
|
256
261
|
cellSelectionRanges: [],
|
|
@@ -389,6 +394,8 @@ function AppStoreProvider(_a) {
|
|
|
389
394
|
setDataControl: function (dataControl) { return set({ dataControl: dataControl }); },
|
|
390
395
|
setColumnSort: function (columnId, order) {
|
|
391
396
|
var _a, _b;
|
|
397
|
+
if (get().disabled)
|
|
398
|
+
return;
|
|
392
399
|
var dataControl = get().dataControl;
|
|
393
400
|
var columns = get().columns;
|
|
394
401
|
var col = columns.find(function (c) { var _a; return ((_a = c.columnId) !== null && _a !== void 0 ? _a : (0, utils_1.getColumnId)(c)) === columnId; });
|
|
@@ -421,13 +428,17 @@ function AppStoreProvider(_a) {
|
|
|
421
428
|
setFilterDraft: function (columnId, filter) {
|
|
422
429
|
return set(function (s) {
|
|
423
430
|
var _a;
|
|
424
|
-
return
|
|
425
|
-
|
|
426
|
-
|
|
431
|
+
return s.disabled
|
|
432
|
+
? {}
|
|
433
|
+
: {
|
|
434
|
+
filterDrafts: __assign(__assign({}, s.filterDrafts), (_a = {}, _a[columnId] = filter, _a)),
|
|
435
|
+
};
|
|
427
436
|
});
|
|
428
437
|
},
|
|
429
438
|
applyColumnFilter: function (columnId) {
|
|
430
439
|
var _a;
|
|
440
|
+
if (get().disabled)
|
|
441
|
+
return;
|
|
431
442
|
var dataControl = get().dataControl;
|
|
432
443
|
var draft = get().filterDrafts[columnId];
|
|
433
444
|
if (!dataControl)
|
|
@@ -451,6 +462,8 @@ function AppStoreProvider(_a) {
|
|
|
451
462
|
},
|
|
452
463
|
clearColumnFilter: function (columnId) {
|
|
453
464
|
var _a;
|
|
465
|
+
if (get().disabled)
|
|
466
|
+
return;
|
|
454
467
|
var dataControl = get().dataControl;
|
|
455
468
|
if (!dataControl)
|
|
456
469
|
return;
|
|
@@ -467,6 +480,8 @@ function AppStoreProvider(_a) {
|
|
|
467
480
|
},
|
|
468
481
|
setActiveToolbox: function (columnId) {
|
|
469
482
|
var _a, _b, _c, _d, _e, _f;
|
|
483
|
+
if (get().disabled && columnId !== null)
|
|
484
|
+
return;
|
|
470
485
|
if (columnId === null) {
|
|
471
486
|
set(function (s) {
|
|
472
487
|
var nextDrafts = __assign({}, s.filterDrafts);
|
|
@@ -533,6 +548,8 @@ function AppStoreProvider(_a) {
|
|
|
533
548
|
requestSearchOpen: function (open, reason) {
|
|
534
549
|
var _a, _b, _c, _d;
|
|
535
550
|
var state = get();
|
|
551
|
+
if (state.disabled && open)
|
|
552
|
+
return;
|
|
536
553
|
var options = state.searchOptions;
|
|
537
554
|
if (open && (!options || options.enabled === false))
|
|
538
555
|
return;
|
|
@@ -554,6 +571,8 @@ function AppStoreProvider(_a) {
|
|
|
554
571
|
},
|
|
555
572
|
setSearchQuery: function (query) {
|
|
556
573
|
var _a;
|
|
574
|
+
if (get().disabled)
|
|
575
|
+
return;
|
|
557
576
|
var options = get().searchOptions;
|
|
558
577
|
if ((options === null || options === void 0 ? void 0 : options.query) === undefined) {
|
|
559
578
|
set({ searchQuery: query });
|
|
@@ -563,9 +582,7 @@ function AppStoreProvider(_a) {
|
|
|
563
582
|
setSearchStatus: function (status) { return set({ searchStatus: status }); },
|
|
564
583
|
setSearchResults: function (matches) {
|
|
565
584
|
return set(function (state) {
|
|
566
|
-
var previous = state.activeSearchMatchIndex === undefined
|
|
567
|
-
? undefined
|
|
568
|
-
: state.searchMatches[state.activeSearchMatchIndex];
|
|
585
|
+
var previous = state.activeSearchMatchIndex === undefined ? undefined : state.searchMatches[state.activeSearchMatchIndex];
|
|
569
586
|
return {
|
|
570
587
|
searchMatches: matches,
|
|
571
588
|
activeSearchMatchIndex: (0, utils_1.findMatchingSearchResultIndex)(matches, previous, state.activeSearchMatchIndex),
|
|
@@ -585,12 +602,12 @@ function AppStoreProvider(_a) {
|
|
|
585
602
|
set({ activeSearchMatchIndex: nextIndex });
|
|
586
603
|
return state.searchMatches[nextIndex];
|
|
587
604
|
},
|
|
588
|
-
clearSearchResults: function () {
|
|
589
|
-
return set({ searchStatus: 'idle', searchMatches: [], activeSearchMatchIndex: undefined });
|
|
590
|
-
},
|
|
605
|
+
clearSearchResults: function () { return set({ searchStatus: 'idle', searchMatches: [], activeSearchMatchIndex: undefined }); },
|
|
591
606
|
openContextMenu: function (contextMenuState) {
|
|
592
607
|
var _a, _b, _c, _d, _e;
|
|
593
608
|
var state = get();
|
|
609
|
+
if (state.disabled)
|
|
610
|
+
return;
|
|
594
611
|
if (state.searchOpen)
|
|
595
612
|
(_b = (_a = state.searchOptions) === null || _a === void 0 ? void 0 : _a.onOpenChange) === null || _b === void 0 ? void 0 : _b.call(_a, false, 'surfaceConflict');
|
|
596
613
|
(_d = (_c = state.contextMenuOptions) === null || _c === void 0 ? void 0 : _c.onOpenChange) === null || _d === void 0 ? void 0 : _d.call(_c, true, contextMenuState.target);
|
|
@@ -631,6 +648,8 @@ function AppStoreProvider(_a) {
|
|
|
631
648
|
},
|
|
632
649
|
setCheckedIndexes: function (keys) {
|
|
633
650
|
var _a;
|
|
651
|
+
if (get().disabled)
|
|
652
|
+
return;
|
|
634
653
|
var rowKey = get().rowKey;
|
|
635
654
|
var sourceData = get().sourceData.length > 0 ? get().sourceData : get().data;
|
|
636
655
|
var data = get().data;
|
|
@@ -668,6 +687,8 @@ function AppStoreProvider(_a) {
|
|
|
668
687
|
},
|
|
669
688
|
setCheckedAll: function (checkedAll) {
|
|
670
689
|
var _a;
|
|
690
|
+
if (get().disabled)
|
|
691
|
+
return;
|
|
671
692
|
var rowKey = get().rowKey;
|
|
672
693
|
var data = get().data;
|
|
673
694
|
var sourceData = get().sourceData.length > 0 ? get().sourceData : get().data;
|
|
@@ -739,6 +760,8 @@ function AppStoreProvider(_a) {
|
|
|
739
760
|
},
|
|
740
761
|
setColumnWidth: function (columnIndex, options) {
|
|
741
762
|
var _a, _b;
|
|
763
|
+
if (get().disabled)
|
|
764
|
+
return;
|
|
742
765
|
if (get().cellInteractionSession) {
|
|
743
766
|
get().endCellEdit();
|
|
744
767
|
}
|
|
@@ -813,6 +836,8 @@ function AppStoreProvider(_a) {
|
|
|
813
836
|
},
|
|
814
837
|
toggleColumnSort: function (columnIndex) {
|
|
815
838
|
var _a, _b, _c, _d;
|
|
839
|
+
if (get().disabled)
|
|
840
|
+
return;
|
|
816
841
|
var columns = get().columns;
|
|
817
842
|
var column = columns[columnIndex];
|
|
818
843
|
if (!column)
|
|
@@ -861,6 +886,8 @@ function AppStoreProvider(_a) {
|
|
|
861
886
|
handleClick: function (index, columnIndex) {
|
|
862
887
|
var _a, _b, _c;
|
|
863
888
|
var state = get();
|
|
889
|
+
if (state.disabled)
|
|
890
|
+
return;
|
|
864
891
|
if (columnIndex < 0)
|
|
865
892
|
return;
|
|
866
893
|
var logicalCell = (0, utils_1.resolveLogicalCell)(state.data, state.cellMergeOptions, {
|
|
@@ -884,6 +911,24 @@ function AppStoreProvider(_a) {
|
|
|
884
911
|
setDisplayItemCount: function (displayItemCount) { return set({ displayItemCount: displayItemCount }); },
|
|
885
912
|
setLoading: function (loading) { return set({ loading: loading }); },
|
|
886
913
|
setSpinning: function (spinning) { return set({ spinning: spinning }); },
|
|
914
|
+
setDisabled: function (disabled) {
|
|
915
|
+
return set(function (state) {
|
|
916
|
+
var _a, _b, _c, _d, _e, _f;
|
|
917
|
+
if (!disabled)
|
|
918
|
+
return { disabled: disabled };
|
|
919
|
+
(_b = (_a = state.contextMenuOptions) === null || _a === void 0 ? void 0 : _a.onOpenChange) === null || _b === void 0 ? void 0 : _b.call(_a, false, (_c = state.contextMenuState) === null || _c === void 0 ? void 0 : _c.target);
|
|
920
|
+
if (state.searchOpen)
|
|
921
|
+
(_e = (_d = state.searchOptions) === null || _d === void 0 ? void 0 : _d.onOpenChange) === null || _e === void 0 ? void 0 : _e.call(_d, false, 'surfaceConflict');
|
|
922
|
+
return __assign({ disabled: disabled, editable: false, editItemIndex: -1, editItemColIndex: -1, activeToolboxColumnId: null, activeCell: undefined, activeCellHost: undefined, contextMenuState: undefined, cellInteractionSession: undefined, cellSelectionRange: undefined, cellSelectionRanges: [], cellSelecting: false, reorderingInfo: undefined }, (((_f = state.searchOptions) === null || _f === void 0 ? void 0 : _f.open) === undefined
|
|
923
|
+
? {
|
|
924
|
+
searchOpen: false,
|
|
925
|
+
searchStatus: 'idle',
|
|
926
|
+
searchMatches: [],
|
|
927
|
+
activeSearchMatchIndex: undefined,
|
|
928
|
+
}
|
|
929
|
+
: {}));
|
|
930
|
+
});
|
|
931
|
+
},
|
|
887
932
|
setHeaderHeight: function (headerHeight) { return set({ headerHeight: headerHeight }); },
|
|
888
933
|
setFooterHeight: function (footerHeight) { return set({ footerHeight: footerHeight }); },
|
|
889
934
|
setSummaryHeight: function (summaryHeight) { return set({ summaryHeight: summaryHeight }); },
|
|
@@ -898,16 +943,20 @@ function AppStoreProvider(_a) {
|
|
|
898
943
|
setRowKey: function (rowKey) { return set({ rowKey: rowKey }); },
|
|
899
944
|
setSelectedRowKey: function (selectedRowKey) { return set({ selectedRowKey: selectedRowKey }); },
|
|
900
945
|
setEditable: function (editable) {
|
|
901
|
-
return set(
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
946
|
+
return set(function (state) {
|
|
947
|
+
return editable && !state.disabled
|
|
948
|
+
? { editable: editable }
|
|
949
|
+
: {
|
|
950
|
+
editable: editable,
|
|
951
|
+
editItemIndex: -1,
|
|
952
|
+
editItemColIndex: -1,
|
|
953
|
+
cellInteractionSession: undefined,
|
|
954
|
+
};
|
|
955
|
+
});
|
|
909
956
|
},
|
|
910
957
|
setEditItem: function (index, columnIndex) {
|
|
958
|
+
if (get().disabled && index >= 0 && columnIndex >= 0)
|
|
959
|
+
return;
|
|
911
960
|
if (index < 0 || columnIndex < 0) {
|
|
912
961
|
get().endCellEdit();
|
|
913
962
|
return;
|
|
@@ -919,6 +968,8 @@ function AppStoreProvider(_a) {
|
|
|
919
968
|
if (mode === void 0) { mode = 'preserve'; }
|
|
920
969
|
if (activation === void 0) { activation = 'cell'; }
|
|
921
970
|
var state = get();
|
|
971
|
+
if (state.disabled)
|
|
972
|
+
return;
|
|
922
973
|
var logicalCell = (0, utils_1.resolveLogicalCell)(state.data, state.cellMergeOptions, cell);
|
|
923
974
|
var item = state.data[logicalCell.cell.rowIndex];
|
|
924
975
|
var column = state.columns[logicalCell.cell.columnIndex];
|
|
@@ -970,6 +1021,8 @@ function AppStoreProvider(_a) {
|
|
|
970
1021
|
beginEditorIconInteraction: function (cell) {
|
|
971
1022
|
var _a, _b, _c, _d, _e, _f;
|
|
972
1023
|
var state = get();
|
|
1024
|
+
if (state.disabled)
|
|
1025
|
+
return undefined;
|
|
973
1026
|
var logicalCell = (0, utils_1.resolveLogicalCell)(state.data, state.cellMergeOptions, cell);
|
|
974
1027
|
var item = state.data[logicalCell.cell.rowIndex];
|
|
975
1028
|
var column = state.columns[logicalCell.cell.columnIndex];
|
|
@@ -1048,6 +1101,8 @@ function AppStoreProvider(_a) {
|
|
|
1048
1101
|
switch (_b.label) {
|
|
1049
1102
|
case 0:
|
|
1050
1103
|
initialState = get();
|
|
1104
|
+
if (initialState.disabled)
|
|
1105
|
+
return [2 /*return*/];
|
|
1051
1106
|
session = initialState.cellInteractionSession;
|
|
1052
1107
|
if (!session || session.id !== request.sessionId || session.phase !== 'active')
|
|
1053
1108
|
return [2 /*return*/];
|
|
@@ -1243,6 +1298,8 @@ function AppStoreProvider(_a) {
|
|
|
1243
1298
|
switch (_b.label) {
|
|
1244
1299
|
case 0:
|
|
1245
1300
|
state = get();
|
|
1301
|
+
if (state.disabled)
|
|
1302
|
+
return [2 /*return*/];
|
|
1246
1303
|
column = state.columns[columnIndex];
|
|
1247
1304
|
config = ((_a = column === null || column === void 0 ? void 0 : column.editor) === null || _a === void 0 ? void 0 : _a.type) === 'checkbox' ? column.editor : undefined;
|
|
1248
1305
|
if (!column || !config || !state.editable || column.editable === false)
|
|
@@ -1301,6 +1358,8 @@ function AppStoreProvider(_a) {
|
|
|
1301
1358
|
switch (_c.label) {
|
|
1302
1359
|
case 0:
|
|
1303
1360
|
state = get();
|
|
1361
|
+
if (state.disabled)
|
|
1362
|
+
return [2 /*return*/];
|
|
1304
1363
|
column = state.columns[columnIndex];
|
|
1305
1364
|
config = ((_b = column === null || column === void 0 ? void 0 : column.editor) === null || _b === void 0 ? void 0 : _b.type) === 'checkbox' ? column.editor : undefined;
|
|
1306
1365
|
if (!column || !config || !config.header || !state.editable || column.editable === false)
|
|
@@ -1385,6 +1444,8 @@ function AppStoreProvider(_a) {
|
|
|
1385
1444
|
setColumnSortable: function (columnSortable) { return set({ columnSortable: columnSortable }); },
|
|
1386
1445
|
sortColumn: function (trLevel, oldColumn, newColumn) {
|
|
1387
1446
|
var _a, _b, _c, _d, _e, _f;
|
|
1447
|
+
if (get().disabled)
|
|
1448
|
+
return;
|
|
1388
1449
|
var nestedColumnGroups = get().columnGroups;
|
|
1389
1450
|
if (nestedColumnGroups.length > 0) {
|
|
1390
1451
|
var columns_1 = __spreadArray([], __read(get().columns), false);
|
|
@@ -1491,11 +1552,13 @@ function AppStoreProvider(_a) {
|
|
|
1491
1552
|
setReorder: function (reorder) { return set({ reorder: reorder }); },
|
|
1492
1553
|
setClassName: function (className) { return set({ className: className }); },
|
|
1493
1554
|
setStyle: function (style) { return set({ style: style }); },
|
|
1494
|
-
setReorderingInfo: function (reorderingInfo) { return set({ reorderingInfo: reorderingInfo }); },
|
|
1555
|
+
setReorderingInfo: function (reorderingInfo) { return set(function (state) { return (state.disabled && reorderingInfo ? {} : { reorderingInfo: reorderingInfo }); }); },
|
|
1495
1556
|
setActiveCell: function (activeCell, hostCell) {
|
|
1496
1557
|
var _a, _b, _c, _d, _e;
|
|
1497
1558
|
if (hostCell === void 0) { hostCell = activeCell; }
|
|
1498
1559
|
var state = get();
|
|
1560
|
+
if (state.disabled && activeCell)
|
|
1561
|
+
return;
|
|
1499
1562
|
var normalizedCell = activeCell
|
|
1500
1563
|
? (0, utils_1.resolveLogicalCell)(state.data, state.cellMergeOptions, activeCell).cell
|
|
1501
1564
|
: undefined;
|
|
@@ -1521,6 +1584,10 @@ function AppStoreProvider(_a) {
|
|
|
1521
1584
|
(_e = cellNavigationOptions === null || cellNavigationOptions === void 0 ? void 0 : cellNavigationOptions.onActiveCellChange) === null || _e === void 0 ? void 0 : _e.call(cellNavigationOptions, normalizedCell);
|
|
1522
1585
|
},
|
|
1523
1586
|
setCellNavigationOptions: function (cellNavigationOptions) {
|
|
1587
|
+
if (get().disabled) {
|
|
1588
|
+
set({ cellNavigationOptions: cellNavigationOptions, activeCell: undefined, activeCellHost: undefined });
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1524
1591
|
var updates = { cellNavigationOptions: cellNavigationOptions };
|
|
1525
1592
|
if ((cellNavigationOptions === null || cellNavigationOptions === void 0 ? void 0 : cellNavigationOptions.activeCell) !== undefined) {
|
|
1526
1593
|
updates.activeCell = cellNavigationOptions.activeCell;
|
|
@@ -1539,6 +1606,11 @@ function AppStoreProvider(_a) {
|
|
|
1539
1606
|
syncActiveCellToBounds: function () {
|
|
1540
1607
|
var _a, _b, _c, _d, _e, _f;
|
|
1541
1608
|
var state = get();
|
|
1609
|
+
if (state.disabled) {
|
|
1610
|
+
if (state.activeCell !== undefined)
|
|
1611
|
+
set({ activeCell: undefined, activeCellHost: undefined });
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1542
1614
|
var requestedCell = (_c = (_b = (_a = state.cellNavigationOptions) === null || _a === void 0 ? void 0 : _a.activeCell) !== null && _b !== void 0 ? _b : state.activeCell) !== null && _c !== void 0 ? _c : (_d = state.cellNavigationOptions) === null || _d === void 0 ? void 0 : _d.defaultActiveCell;
|
|
1543
1615
|
if (!requestedCell || state.data.length === 0 || state.columns.length === 0) {
|
|
1544
1616
|
if (state.activeCell !== undefined)
|
|
@@ -1561,6 +1633,8 @@ function AppStoreProvider(_a) {
|
|
|
1561
1633
|
moveActiveCell: function (direction, options) {
|
|
1562
1634
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1563
1635
|
var state = get();
|
|
1636
|
+
if (state.disabled)
|
|
1637
|
+
return;
|
|
1564
1638
|
var data = state.data;
|
|
1565
1639
|
var columns = state.columns;
|
|
1566
1640
|
if (!data || data.length === 0 || !columns || columns.length === 0)
|
|
@@ -1754,18 +1828,26 @@ function AppStoreProvider(_a) {
|
|
|
1754
1828
|
return newActiveCell;
|
|
1755
1829
|
},
|
|
1756
1830
|
setCellSelectionRange: function (cellSelectionRange) {
|
|
1757
|
-
return set({
|
|
1758
|
-
|
|
1759
|
-
|
|
1831
|
+
return set(function (state) {
|
|
1832
|
+
return state.disabled
|
|
1833
|
+
? {}
|
|
1834
|
+
: {
|
|
1835
|
+
cellSelectionRange: cellSelectionRange,
|
|
1836
|
+
cellSelectionRanges: cellSelectionRange ? [cellSelectionRange] : [],
|
|
1837
|
+
};
|
|
1760
1838
|
});
|
|
1761
1839
|
},
|
|
1762
1840
|
setCellSelectionRanges: function (cellSelectionRanges) {
|
|
1763
|
-
return set({
|
|
1764
|
-
|
|
1765
|
-
|
|
1841
|
+
return set(function (state) {
|
|
1842
|
+
return state.disabled
|
|
1843
|
+
? {}
|
|
1844
|
+
: {
|
|
1845
|
+
cellSelectionRange: cellSelectionRanges[cellSelectionRanges.length - 1],
|
|
1846
|
+
cellSelectionRanges: cellSelectionRanges,
|
|
1847
|
+
};
|
|
1766
1848
|
});
|
|
1767
1849
|
},
|
|
1768
|
-
setCellSelecting: function (cellSelecting) { return set({ cellSelecting: cellSelecting }); },
|
|
1850
|
+
setCellSelecting: function (cellSelecting) { return set(function (state) { return (state.disabled && cellSelecting ? {} : { cellSelecting: cellSelecting }); }); },
|
|
1769
1851
|
clearCellSelection: function () { return set({ cellSelectionRange: undefined, cellSelectionRanges: [], cellSelecting: false }); },
|
|
1770
1852
|
});
|
|
1771
1853
|
});
|
package/esm/BGrid.js
CHANGED
|
@@ -21,7 +21,7 @@ function computeModelColumns(columns, frozenColumnIndex, duplicateToolboxColumnI
|
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, summaryHeight = 30, itemHeight = 15, itemPadding = 7, columns, columnsGroup, columnGroups, onChangeColumns, frozenColumnIndex = 0, frozenRowCount = 0, data = [], page, scrollbar, status, pagination, bottomBarHeight, scrollTop = 0, scrollLeft = 0, className, style, rowChecked, sort, onClick, loading = false, spinning, rowKey, selectedRowKey, editable, onChangeData, showLineNumber, msg, getRowClassName, editTrigger = 'dblclick', cellMergeOptions, cellSelectionOptions, cellNavigationOptions, variant, summary, columnSortable, reorder, pivot, dataControl, icons, columnVisibility, searchOptions, contextMenuOptions, }) {
|
|
24
|
+
export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, summaryHeight = 30, itemHeight = 15, itemPadding = 7, columns, columnsGroup, columnGroups, onChangeColumns, frozenColumnIndex = 0, frozenRowCount = 0, data = [], page, scrollbar, status, pagination, bottomBarHeight, scrollTop = 0, scrollLeft = 0, className, style, rowChecked, sort, onClick, loading = false, spinning, disabled, rowKey, selectedRowKey, editable, onChangeData, showLineNumber, msg, getRowClassName, editTrigger = 'dblclick', cellMergeOptions, cellSelectionOptions, cellNavigationOptions, variant, summary, columnSortable, reorder, pivot, dataControl, icons, columnVisibility, searchOptions, contextMenuOptions, }) {
|
|
25
25
|
const warnedSearchControlledRef = React.useRef({
|
|
26
26
|
open: false,
|
|
27
27
|
query: false,
|
|
@@ -76,29 +76,32 @@ export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, sum
|
|
|
76
76
|
const resolvedFrozenColumnIndex = visibilityProjection.frozenColumnIndex;
|
|
77
77
|
const resolvedRowChecked = pivotEnabled ? undefined : rowChecked;
|
|
78
78
|
const resolvedSort = pivotEnabled ? undefined : sort;
|
|
79
|
-
const
|
|
79
|
+
const resolvedDisabled = !!disabled;
|
|
80
|
+
const resolvedOnClick = pivotEnabled || resolvedDisabled ? undefined : onClick;
|
|
80
81
|
const baseOnChangeColumns = pivotEnabled ? undefined : onChangeColumns;
|
|
81
82
|
const resolvedOnChangeData = pivotEnabled ? undefined : onChangeData;
|
|
82
83
|
const resolvedRowKey = pivotEnabled ? undefined : rowKey;
|
|
83
84
|
const resolvedSelectedRowKey = pivotEnabled ? undefined : selectedRowKey;
|
|
84
|
-
const resolvedEditable = pivotEnabled ? false : editable;
|
|
85
|
+
const resolvedEditable = pivotEnabled || resolvedDisabled ? false : editable;
|
|
85
86
|
const resolvedShowLineNumber = pivotEnabled ? false : showLineNumber;
|
|
86
87
|
const resolvedGetRowClassName = pivotEnabled ? undefined : getRowClassName;
|
|
87
88
|
const resolvedCellMergeOptions = visibilityProjection.cellMergeOptions;
|
|
88
|
-
const resolvedCellSelectionOptions =
|
|
89
|
+
const resolvedCellSelectionOptions = resolvedDisabled
|
|
90
|
+
? { ...cellSelectionOptions, enabled: false }
|
|
91
|
+
: cellSelectionOptions;
|
|
89
92
|
const resolvedSummary = visibilityProjection.summary;
|
|
90
93
|
const hasHiddenColumns = visibilityProjection.columns.length < resolvedColumns.length;
|
|
91
|
-
const resolvedColumnSortable = pivotEnabled || hasHiddenColumns ? false : columnSortable;
|
|
94
|
+
const resolvedColumnSortable = pivotEnabled || hasHiddenColumns || resolvedDisabled ? false : columnSortable;
|
|
92
95
|
const resolvedDataControl = pivotEnabled ? undefined : dataControl;
|
|
93
|
-
const resolvedSearchOptions = pivotEnabled ? undefined : searchOptions;
|
|
94
|
-
const resolvedContextMenuOptions = pivotEnabled ? undefined : contextMenuOptions;
|
|
96
|
+
const resolvedSearchOptions = pivotEnabled || resolvedDisabled ? undefined : searchOptions;
|
|
97
|
+
const resolvedContextMenuOptions = pivotEnabled || resolvedDisabled ? undefined : contextMenuOptions;
|
|
95
98
|
const hasActiveClientQuery = resolvedDataControl?.mode === 'client' &&
|
|
96
99
|
(resolvedDataControl.query.sortParams.length > 0 || resolvedDataControl.query.filterParams.length > 0);
|
|
97
|
-
const resolvedReorder = React.useMemo(() => pivotEnabled
|
|
100
|
+
const resolvedReorder = React.useMemo(() => pivotEnabled || resolvedDisabled
|
|
98
101
|
? undefined
|
|
99
102
|
: (hasActiveClientQuery || frozenRowCount > 0) && reorder
|
|
100
103
|
? { ...reorder, enabled: false }
|
|
101
|
-
: reorder, [frozenRowCount, hasActiveClientQuery, pivotEnabled, reorder]);
|
|
104
|
+
: reorder, [frozenRowCount, hasActiveClientQuery, pivotEnabled, reorder, resolvedDisabled]);
|
|
102
105
|
// Development warnings
|
|
103
106
|
React.useEffect(() => {
|
|
104
107
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -136,9 +139,7 @@ export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, sum
|
|
|
136
139
|
warnedSearchControlledRef.current.columnVisibility = true;
|
|
137
140
|
console.warn('[BGrid] Controlled columnVisibility.hiddenColumnIds requires onChange to respond to user actions.');
|
|
138
141
|
}
|
|
139
|
-
if (searchOptions?.open !== undefined &&
|
|
140
|
-
!searchOptions.onOpenChange &&
|
|
141
|
-
!warnedSearchControlledRef.current.open) {
|
|
142
|
+
if (searchOptions?.open !== undefined && !searchOptions.onOpenChange && !warnedSearchControlledRef.current.open) {
|
|
142
143
|
warnedSearchControlledRef.current.open = true;
|
|
143
144
|
console.warn('[BGrid] Controlled searchOptions.open requires onOpenChange to respond to user actions.');
|
|
144
145
|
}
|
|
@@ -234,9 +235,7 @@ export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, sum
|
|
|
234
235
|
if (updatedColumn)
|
|
235
236
|
nextColumns[originalIndex] = updatedColumn;
|
|
236
237
|
});
|
|
237
|
-
baseOnChangeColumns(visibleColumnIndex === null
|
|
238
|
-
? null
|
|
239
|
-
: visibilityProjection.visibleOriginalIndexes[visibleColumnIndex] ?? null, {
|
|
238
|
+
baseOnChangeColumns(visibleColumnIndex === null ? null : visibilityProjection.visibleOriginalIndexes[visibleColumnIndex] ?? null, {
|
|
240
239
|
...info,
|
|
241
240
|
columns: nextColumns,
|
|
242
241
|
columnsGroup: resolvedColumnsGroup,
|
|
@@ -448,6 +447,7 @@ export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, sum
|
|
|
448
447
|
page: resolvedPage,
|
|
449
448
|
displayPaginationLength: resolvedPage ? resolvedPage.displayPaginationLength ?? 5 : 0,
|
|
450
449
|
loading,
|
|
450
|
+
disabled: resolvedDisabled,
|
|
451
451
|
spinning,
|
|
452
452
|
scrollTop,
|
|
453
453
|
scrollLeft,
|
|
@@ -507,6 +507,7 @@ export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, sum
|
|
|
507
507
|
resolvedSearchOptions,
|
|
508
508
|
resolvedContextMenuOptions,
|
|
509
509
|
loading,
|
|
510
|
+
resolvedDisabled,
|
|
510
511
|
spinning,
|
|
511
512
|
scrollTop,
|
|
512
513
|
scrollLeft,
|
|
@@ -536,6 +537,7 @@ export function BGrid({ ref, width, height, headerHeight = 30, footerHeight, sum
|
|
|
536
537
|
className,
|
|
537
538
|
style,
|
|
538
539
|
loading,
|
|
540
|
+
disabled: resolvedDisabled,
|
|
539
541
|
spinning,
|
|
540
542
|
scrollLeft,
|
|
541
543
|
scrollTop,
|
|
@@ -5,8 +5,11 @@ function ColResizer({ container, columnIndex, hideHandle, bordered, frozenBounda
|
|
|
5
5
|
const setColumnWidth = useAppStore(s => s.setColumnWidth);
|
|
6
6
|
const setColumnResizing = useAppStore(s => s.setColumnResizing);
|
|
7
7
|
const endCellEdit = useAppStore(s => s.endCellEdit);
|
|
8
|
+
const disabled = useAppStore(s => s.disabled);
|
|
8
9
|
const columnsGroup = useAppStore(s => s.columnsGroup);
|
|
9
10
|
const onPointerDownResizerHandle = React.useCallback((evt, columnIndex) => {
|
|
11
|
+
if (disabled)
|
|
12
|
+
return;
|
|
10
13
|
evt.preventDefault();
|
|
11
14
|
evt.stopPropagation();
|
|
12
15
|
endCellEdit();
|
|
@@ -26,8 +29,10 @@ function ColResizer({ container, columnIndex, hideHandle, bordered, frozenBounda
|
|
|
26
29
|
pointerId: evt.pointerId,
|
|
27
30
|
initialClientX: evt.clientX,
|
|
28
31
|
});
|
|
29
|
-
}, [container, endCellEdit, setColumnResizing, setColumnWidth]);
|
|
32
|
+
}, [container, disabled, endCellEdit, setColumnResizing, setColumnWidth]);
|
|
30
33
|
const onMouseDoubleClick = React.useCallback(async (evt, columnIndex) => {
|
|
34
|
+
if (disabled)
|
|
35
|
+
return;
|
|
31
36
|
evt.preventDefault();
|
|
32
37
|
evt.stopPropagation();
|
|
33
38
|
endCellEdit();
|
|
@@ -51,13 +56,13 @@ function ColResizer({ container, columnIndex, hideHandle, bordered, frozenBounda
|
|
|
51
56
|
}
|
|
52
57
|
targetDiv.remove();
|
|
53
58
|
}
|
|
54
|
-
}, [container, endCellEdit, setColumnWidth]);
|
|
59
|
+
}, [container, disabled, endCellEdit, setColumnWidth]);
|
|
55
60
|
return (React.createElement("div", { className: [
|
|
56
61
|
'bgrid-col-resizer',
|
|
57
62
|
hideHandle ? '' : 'bgrid-col-resizer-handle',
|
|
58
63
|
frozenBoundary ? 'bgrid-col-resizer-frozen-boundary' : '',
|
|
59
64
|
]
|
|
60
65
|
.filter(Boolean)
|
|
61
|
-
.join(' '), "data-bgrid-frozen-boundary": frozenBoundary ? 'true' : undefined, style: !hideHandle ? { ['--bgrid-resizer-height']: bordered ? '100%' : '1em' } : undefined, onPointerDown: (evt) => onPointerDownResizerHandle(evt, columnIndex), onDoubleClick: (evt) => onMouseDoubleClick(evt, columnIndex), onClick: (evt) => evt.stopPropagation() }));
|
|
66
|
+
.join(' '), "data-bgrid-frozen-boundary": frozenBoundary ? 'true' : undefined, "data-bgrid-disabled": disabled ? 'true' : undefined, style: !hideHandle ? { ['--bgrid-resizer-height']: bordered ? '100%' : '1em' } : undefined, onPointerDown: (evt) => onPointerDownResizerHandle(evt, columnIndex), onDoubleClick: (evt) => onMouseDoubleClick(evt, columnIndex), onClick: (evt) => evt.stopPropagation() }));
|
|
62
67
|
}
|
|
63
68
|
export default ColResizer;
|