beautiful-grid 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +977 -0
- package/TRADEMARK.md +17 -0
- package/cjs/BGrid.js +503 -0
- package/cjs/components/CellEditorIcon.js +209 -0
- package/cjs/components/CellNavigationDomSync.js +117 -0
- package/cjs/components/CellTextEditorGateway.js +393 -0
- package/cjs/components/ColResizer.js +144 -0
- package/cjs/components/EditorPortalRoot.js +96 -0
- package/cjs/components/GridOptionalSurfaces.js +47 -0
- package/cjs/components/GripVertical.js +48 -0
- package/cjs/components/Loading.js +76 -0
- package/cjs/components/Pagination.js +93 -0
- package/cjs/components/PluginCellEditor.js +258 -0
- package/cjs/components/RowSelector.js +74 -0
- package/cjs/components/Table.js +2572 -0
- package/cjs/components/TableBody.js +446 -0
- package/cjs/components/TableBodyCell.js +112 -0
- package/cjs/components/TableBodyFrozen.js +44 -0
- package/cjs/components/TableColGroup.js +48 -0
- package/cjs/components/TableColGroupFrozen.js +57 -0
- package/cjs/components/TableFooter.js +70 -0
- package/cjs/components/TableHead.js +195 -0
- package/cjs/components/TableHeadColumn.js +124 -0
- package/cjs/components/TableHeadFrozen.js +165 -0
- package/cjs/components/TableSummary.js +133 -0
- package/cjs/components/TableSummaryFronzen.js +105 -0
- package/cjs/components/columnSortableRuntime.js +46 -0
- package/cjs/components/context-menu/GridContextMenu.js +174 -0
- package/cjs/components/context-menu/index.js +17 -0
- package/cjs/components/scrollbar/CustomScrollbar.js +58 -0
- package/cjs/components/scrollbar/ScrollbarButton.js +69 -0
- package/cjs/components/scrollbar/ScrollbarTrack.js +106 -0
- package/cjs/components/scrollbar/index.js +20 -0
- package/cjs/components/scrollbar/useScrollbarMetrics.js +103 -0
- package/cjs/components/search/GridSearchController.js +170 -0
- package/cjs/components/search/GridSearchPopover.js +163 -0
- package/cjs/components/search/index.js +18 -0
- package/cjs/components/selection/CellSelectionOverlay.js +52 -0
- package/cjs/components/selection/CellSelectionOverlayLayer.js +65 -0
- package/cjs/components/selection/index.js +18 -0
- package/cjs/components/toolbox/TableHeadToolbox.js +308 -0
- package/cjs/components/toolbox/ToolboxCustomSection.js +55 -0
- package/cjs/components/toolbox/ToolboxNumberFilterSection.js +151 -0
- package/cjs/components/toolbox/ToolboxSortSection.js +68 -0
- package/cjs/components/toolbox/ToolboxTextFilterSection.js +114 -0
- package/cjs/components/toolbox/ToolboxValueFilterSection.js +250 -0
- package/cjs/components/toolbox/index.js +22 -0
- package/cjs/components/useColumnSortable.js +70 -0
- package/cjs/editors/createDateEditorPlugin.js +88 -0
- package/cjs/editors/createSelectEditorPlugin.js +98 -0
- package/cjs/editors/defineEditorPlugin.js +17 -0
- package/cjs/editors/index.js +19 -0
- package/cjs/index.js +19 -0
- package/cjs/store/createAppStore.js +1645 -0
- package/cjs/store/index.js +17 -0
- package/cjs/types.js +14 -0
- package/cjs/utils/buildHeaderMatrix.js +265 -0
- package/cjs/utils/cellEditState.js +71 -0
- package/cjs/utils/cellEditTransaction.js +138 -0
- package/cjs/utils/cellSelectionGeometry.js +179 -0
- package/cjs/utils/common.js +154 -0
- package/cjs/utils/coordinate.js +125 -0
- package/cjs/utils/createPivotData.js +271 -0
- package/cjs/utils/delay.js +7 -0
- package/cjs/utils/filterData.js +182 -0
- package/cjs/utils/getCellSelectionAxisState.js +39 -0
- package/cjs/utils/getCellValue.js +21 -0
- package/cjs/utils/getColumnId.js +60 -0
- package/cjs/utils/getFrozenColumnsWidth.js +21 -0
- package/cjs/utils/getLineNumber.js +7 -0
- package/cjs/utils/getVisibleScrollableRowRange.js +24 -0
- package/cjs/utils/gridSearch.js +135 -0
- package/cjs/utils/index.js +39 -0
- package/cjs/utils/mergedCells.js +76 -0
- package/cjs/utils/mouseEventSubscribe.js +119 -0
- package/cjs/utils/number/index.js +19 -0
- package/cjs/utils/number/toFixed.js +6 -0
- package/cjs/utils/number/toMoney.js +13 -0
- package/cjs/utils/number/toNumber.js +12 -0
- package/cjs/utils/processDataQuery.js +126 -0
- package/cjs/utils/rowReorder.js +131 -0
- package/cjs/utils/scrollbar.js +62 -0
- package/cjs/utils/updateDataQuery.js +147 -0
- package/cjs/utils/useBodyData.js +277 -0
- package/cjs/utils/useForceUpdate.js +57 -0
- package/cjs/utils/useRowReorderController.js +666 -0
- package/esm/BGrid.js +466 -0
- package/esm/components/CellEditorIcon.js +115 -0
- package/esm/components/CellNavigationDomSync.js +80 -0
- package/esm/components/CellTextEditorGateway.js +275 -0
- package/esm/components/ColResizer.js +60 -0
- package/esm/components/EditorPortalRoot.js +57 -0
- package/esm/components/GridOptionalSurfaces.js +10 -0
- package/esm/components/GripVertical.js +11 -0
- package/esm/components/Loading.js +24 -0
- package/esm/components/Pagination.js +44 -0
- package/esm/components/PluginCellEditor.js +110 -0
- package/esm/components/RowSelector.js +38 -0
- package/esm/components/Table.js +2347 -0
- package/esm/components/TableBody.js +315 -0
- package/esm/components/TableBodyCell.js +73 -0
- package/esm/components/TableBodyFrozen.js +6 -0
- package/esm/components/TableColGroup.js +10 -0
- package/esm/components/TableColGroupFrozen.js +19 -0
- package/esm/components/TableFooter.js +30 -0
- package/esm/components/TableHead.js +114 -0
- package/esm/components/TableHeadColumn.js +86 -0
- package/esm/components/TableHeadFrozen.js +102 -0
- package/esm/components/TableSummary.js +66 -0
- package/esm/components/TableSummaryFronzen.js +62 -0
- package/esm/components/columnSortableRuntime.js +38 -0
- package/esm/components/context-menu/GridContextMenu.js +115 -0
- package/esm/components/context-menu/index.js +1 -0
- package/esm/components/scrollbar/CustomScrollbar.js +21 -0
- package/esm/components/scrollbar/ScrollbarButton.js +32 -0
- package/esm/components/scrollbar/ScrollbarTrack.js +66 -0
- package/esm/components/scrollbar/index.js +4 -0
- package/esm/components/scrollbar/useScrollbarMetrics.js +74 -0
- package/esm/components/search/GridSearchController.js +98 -0
- package/esm/components/search/GridSearchPopover.js +109 -0
- package/esm/components/search/index.js +2 -0
- package/esm/components/selection/CellSelectionOverlay.js +5 -0
- package/esm/components/selection/CellSelectionOverlayLayer.js +28 -0
- package/esm/components/selection/index.js +2 -0
- package/esm/components/toolbox/TableHeadToolbox.js +223 -0
- package/esm/components/toolbox/ToolboxCustomSection.js +18 -0
- package/esm/components/toolbox/ToolboxNumberFilterSection.js +98 -0
- package/esm/components/toolbox/ToolboxSortSection.js +31 -0
- package/esm/components/toolbox/ToolboxTextFilterSection.js +61 -0
- package/esm/components/toolbox/ToolboxValueFilterSection.js +195 -0
- package/esm/components/toolbox/index.js +6 -0
- package/esm/components/useColumnSortable.js +33 -0
- package/esm/editors/createDateEditorPlugin.js +48 -0
- package/esm/editors/createSelectEditorPlugin.js +60 -0
- package/esm/editors/defineEditorPlugin.js +6 -0
- package/esm/editors/index.js +3 -0
- package/esm/index.js +3 -0
- package/esm/store/createAppStore.js +1483 -0
- package/esm/store/index.js +1 -0
- package/esm/types.js +11 -0
- package/esm/utils/buildHeaderMatrix.js +231 -0
- package/esm/utils/cellEditState.js +32 -0
- package/esm/utils/cellEditTransaction.js +96 -0
- package/esm/utils/cellSelectionGeometry.js +166 -0
- package/esm/utils/common.js +145 -0
- package/esm/utils/coordinate.js +112 -0
- package/esm/utils/createPivotData.js +226 -0
- package/esm/utils/delay.js +1 -0
- package/esm/utils/filterData.js +176 -0
- package/esm/utils/getCellSelectionAxisState.js +34 -0
- package/esm/utils/getCellValue.js +18 -0
- package/esm/utils/getColumnId.js +52 -0
- package/esm/utils/getFrozenColumnsWidth.js +16 -0
- package/esm/utils/getLineNumber.js +3 -0
- package/esm/utils/getVisibleScrollableRowRange.js +20 -0
- package/esm/utils/gridSearch.js +127 -0
- package/esm/utils/index.js +23 -0
- package/esm/utils/mergedCells.js +70 -0
- package/esm/utils/mouseEventSubscribe.js +113 -0
- package/esm/utils/number/index.js +3 -0
- package/esm/utils/number/toFixed.js +3 -0
- package/esm/utils/number/toMoney.js +10 -0
- package/esm/utils/number/toNumber.js +9 -0
- package/esm/utils/processDataQuery.js +119 -0
- package/esm/utils/rowReorder.js +85 -0
- package/esm/utils/scrollbar.js +51 -0
- package/esm/utils/updateDataQuery.js +130 -0
- package/esm/utils/useBodyData.js +153 -0
- package/esm/utils/useForceUpdate.js +5 -0
- package/esm/utils/useRowReorderController.js +603 -0
- package/package.json +54 -0
- package/style.css +2508 -0
- package/types/BGrid.d.ts +3 -0
- package/types/components/CellEditorIcon.d.ts +13 -0
- package/types/components/CellNavigationDomSync.d.ts +17 -0
- package/types/components/CellTextEditorGateway.d.ts +20 -0
- package/types/components/ColResizer.d.ts +12 -0
- package/types/components/EditorPortalRoot.d.ts +8 -0
- package/types/components/GridOptionalSurfaces.d.ts +10 -0
- package/types/components/GripVertical.d.ts +6 -0
- package/types/components/Loading.d.ts +7 -0
- package/types/components/Pagination.d.ts +5 -0
- package/types/components/PluginCellEditor.d.ts +13 -0
- package/types/components/RowSelector.d.ts +10 -0
- package/types/components/Table.d.ts +61 -0
- package/types/components/TableBody.d.ts +39 -0
- package/types/components/TableBodyCell.d.ts +20 -0
- package/types/components/TableBodyFrozen.d.ts +15 -0
- package/types/components/TableColGroup.d.ts +3 -0
- package/types/components/TableColGroupFrozen.d.ts +5 -0
- package/types/components/TableFooter.d.ts +9 -0
- package/types/components/TableHead.d.ts +21 -0
- package/types/components/TableHeadColumn.d.ts +8 -0
- package/types/components/TableHeadFrozen.d.ts +7 -0
- package/types/components/TableSummary.d.ts +13 -0
- package/types/components/TableSummaryFronzen.d.ts +7 -0
- package/types/components/columnSortableRuntime.d.ts +12 -0
- package/types/components/context-menu/GridContextMenu.d.ts +6 -0
- package/types/components/context-menu/index.d.ts +1 -0
- package/types/components/scrollbar/CustomScrollbar.d.ts +11 -0
- package/types/components/scrollbar/ScrollbarButton.d.ts +9 -0
- package/types/components/scrollbar/ScrollbarTrack.d.ts +11 -0
- package/types/components/scrollbar/index.d.ts +4 -0
- package/types/components/scrollbar/useScrollbarMetrics.d.ts +12 -0
- package/types/components/search/GridSearchController.d.ts +1 -0
- package/types/components/search/GridSearchPopover.d.ts +6 -0
- package/types/components/search/index.d.ts +2 -0
- package/types/components/selection/CellSelectionOverlay.d.ts +17 -0
- package/types/components/selection/CellSelectionOverlayLayer.d.ts +18 -0
- package/types/components/selection/index.d.ts +2 -0
- package/types/components/toolbox/TableHeadToolbox.d.ts +13 -0
- package/types/components/toolbox/ToolboxCustomSection.d.ts +11 -0
- package/types/components/toolbox/ToolboxNumberFilterSection.d.ts +8 -0
- package/types/components/toolbox/ToolboxSortSection.d.ts +8 -0
- package/types/components/toolbox/ToolboxTextFilterSection.d.ts +8 -0
- package/types/components/toolbox/ToolboxValueFilterSection.d.ts +8 -0
- package/types/components/toolbox/index.d.ts +6 -0
- package/types/components/useColumnSortable.d.ts +13 -0
- package/types/editors/createDateEditorPlugin.d.ts +8 -0
- package/types/editors/createSelectEditorPlugin.d.ts +15 -0
- package/types/editors/defineEditorPlugin.d.ts +2 -0
- package/types/editors/index.d.ts +3 -0
- package/types/index.d.ts +3 -0
- package/types/store/createAppStore.d.ts +13 -0
- package/types/store/index.d.ts +1 -0
- package/types/types.d.ts +864 -0
- package/types/utils/buildHeaderMatrix.d.ts +32 -0
- package/types/utils/cellEditState.d.ts +12 -0
- package/types/utils/cellEditTransaction.d.ts +14 -0
- package/types/utils/cellSelectionGeometry.d.ts +34 -0
- package/types/utils/common.d.ts +3 -0
- package/types/utils/coordinate.d.ts +29 -0
- package/types/utils/createPivotData.d.ts +12 -0
- package/types/utils/delay.d.ts +1 -0
- package/types/utils/filterData.d.ts +18 -0
- package/types/utils/getCellSelectionAxisState.d.ts +12 -0
- package/types/utils/getCellValue.d.ts +2 -0
- package/types/utils/getColumnId.d.ts +19 -0
- package/types/utils/getFrozenColumnsWidth.d.ts +12 -0
- package/types/utils/getLineNumber.d.ts +6 -0
- package/types/utils/getVisibleScrollableRowRange.d.ts +20 -0
- package/types/utils/gridSearch.d.ts +18 -0
- package/types/utils/index.d.ts +23 -0
- package/types/utils/mergedCells.d.ts +14 -0
- package/types/utils/mouseEventSubscribe.d.ts +18 -0
- package/types/utils/number/index.d.ts +3 -0
- package/types/utils/number/toFixed.d.ts +1 -0
- package/types/utils/number/toMoney.d.ts +1 -0
- package/types/utils/number/toNumber.d.ts +1 -0
- package/types/utils/processDataQuery.d.ts +19 -0
- package/types/utils/rowReorder.d.ts +24 -0
- package/types/utils/scrollbar.d.ts +13 -0
- package/types/utils/updateDataQuery.d.ts +28 -0
- package/types/utils/useBodyData.d.ts +9 -0
- package/types/utils/useForceUpdate.d.ts +1 -0
- package/types/utils/useRowReorderController.d.ts +19 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
47
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
48
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
49
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
50
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
51
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
52
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
58
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
59
|
+
function step(op) {
|
|
60
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
61
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
62
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
63
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
64
|
+
switch (op[0]) {
|
|
65
|
+
case 0: case 1: t = op; break;
|
|
66
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
67
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
68
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
69
|
+
default:
|
|
70
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
71
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
72
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
73
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
74
|
+
if (t[2]) _.ops.pop();
|
|
75
|
+
_.trys.pop(); continue;
|
|
76
|
+
}
|
|
77
|
+
op = body.call(thisArg, _);
|
|
78
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
79
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
|
+
exports.CellEditorIcon = CellEditorIcon;
|
|
84
|
+
var React = __importStar(require("react"));
|
|
85
|
+
var store_1 = require("../store");
|
|
86
|
+
function CellEditorIcon(_a) {
|
|
87
|
+
var _this = this;
|
|
88
|
+
var _b, _c;
|
|
89
|
+
var hostCell = _a.hostCell, index = _a.index, columnIndex = _a.columnIndex, column = _a.column, item = _a.item, value = _a.value, editing = _a.editing;
|
|
90
|
+
var config = column.editorIcon;
|
|
91
|
+
var active = (0, store_1.useAppStore)(function (state) { var _a, _b; return ((_a = state.activeCell) === null || _a === void 0 ? void 0 : _a.rowIndex) === index && ((_b = state.activeCell) === null || _b === void 0 ? void 0 : _b.columnIndex) === columnIndex; });
|
|
92
|
+
var interactionSession = (0, store_1.useAppStore)(function (s) { return s.cellInteractionSession; });
|
|
93
|
+
var beginCellEdit = (0, store_1.useAppStore)(function (s) { return s.beginCellEdit; });
|
|
94
|
+
var beginEditorIconInteraction = (0, store_1.useAppStore)(function (s) { return s.beginEditorIconInteraction; });
|
|
95
|
+
var cancelCellInteraction = (0, store_1.useAppStore)(function (s) { return s.cancelCellInteraction; });
|
|
96
|
+
var handleGridClick = (0, store_1.useAppStore)(function (s) { return s.handleClick; });
|
|
97
|
+
var requestCellCommit = (0, store_1.useAppStore)(function (s) { return s.requestCellCommit; });
|
|
98
|
+
var isCellInteractionSessionActive = (0, store_1.useAppStore)(function (s) { return s.isCellInteractionSessionActive; });
|
|
99
|
+
var callbackSessionIdRef = React.useRef(undefined);
|
|
100
|
+
var cleanupRef = React.useRef(undefined);
|
|
101
|
+
var runCleanup = React.useCallback(function () {
|
|
102
|
+
var cleanup = cleanupRef.current;
|
|
103
|
+
cleanupRef.current = undefined;
|
|
104
|
+
if (!cleanup)
|
|
105
|
+
return;
|
|
106
|
+
try {
|
|
107
|
+
cleanup();
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
111
|
+
console.warn('[BGrid] editorIcon cleanup failed.', error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, []);
|
|
115
|
+
React.useEffect(function () {
|
|
116
|
+
var sessionId = callbackSessionIdRef.current;
|
|
117
|
+
if (sessionId === undefined || (interactionSession === null || interactionSession === void 0 ? void 0 : interactionSession.id) === sessionId)
|
|
118
|
+
return;
|
|
119
|
+
callbackSessionIdRef.current = undefined;
|
|
120
|
+
runCleanup();
|
|
121
|
+
}, [interactionSession === null || interactionSession === void 0 ? void 0 : interactionSession.id, runCleanup]);
|
|
122
|
+
React.useEffect(function () { return function () {
|
|
123
|
+
var sessionId = callbackSessionIdRef.current;
|
|
124
|
+
if (sessionId !== undefined)
|
|
125
|
+
cancelCellInteraction(sessionId);
|
|
126
|
+
runCleanup();
|
|
127
|
+
}; }, [cancelCellInteraction, runCleanup]);
|
|
128
|
+
if (!config)
|
|
129
|
+
return null;
|
|
130
|
+
var params = {
|
|
131
|
+
column: column,
|
|
132
|
+
index: index,
|
|
133
|
+
columnIndex: columnIndex,
|
|
134
|
+
item: item,
|
|
135
|
+
values: item.values,
|
|
136
|
+
value: value,
|
|
137
|
+
active: active,
|
|
138
|
+
};
|
|
139
|
+
var ariaLabel = typeof config.ariaLabel === 'function'
|
|
140
|
+
? config.ariaLabel(params)
|
|
141
|
+
: (_b = config.ariaLabel) !== null && _b !== void 0 ? _b : (typeof column.label === 'string' ? "".concat(column.label, " \uD3B8\uC9D1") : '셀 편집');
|
|
142
|
+
var isOwnIconSession = (interactionSession === null || interactionSession === void 0 ? void 0 : interactionSession.kind) === 'editorIcon' &&
|
|
143
|
+
interactionSession.cell.rowIndex === index &&
|
|
144
|
+
interactionSession.cell.columnIndex === columnIndex;
|
|
145
|
+
var hiddenWhileEditing = editing && !config.onClick;
|
|
146
|
+
var activate = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
147
|
+
var session, terminal, cancel, cleanup, error_1;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
handleGridClick(index, columnIndex);
|
|
152
|
+
if (!config.onClick) {
|
|
153
|
+
beginCellEdit(hostCell, 'preserve', 'editorIcon');
|
|
154
|
+
return [2 /*return*/];
|
|
155
|
+
}
|
|
156
|
+
session = beginEditorIconInteraction(hostCell);
|
|
157
|
+
if (!session)
|
|
158
|
+
return [2 /*return*/];
|
|
159
|
+
callbackSessionIdRef.current = session.id;
|
|
160
|
+
terminal = false;
|
|
161
|
+
cancel = function () {
|
|
162
|
+
if (terminal)
|
|
163
|
+
return;
|
|
164
|
+
terminal = true;
|
|
165
|
+
cancelCellInteraction(session.id);
|
|
166
|
+
};
|
|
167
|
+
_a.label = 1;
|
|
168
|
+
case 1:
|
|
169
|
+
_a.trys.push([1, 3, , 4]);
|
|
170
|
+
return [4 /*yield*/, config.onClick(__assign(__assign({}, params), { commit: function (changes, options) {
|
|
171
|
+
if (terminal)
|
|
172
|
+
return Promise.resolve();
|
|
173
|
+
terminal = true;
|
|
174
|
+
return requestCellCommit({
|
|
175
|
+
sessionId: session.id,
|
|
176
|
+
source: 'editorIcon',
|
|
177
|
+
changes: changes,
|
|
178
|
+
options: options,
|
|
179
|
+
});
|
|
180
|
+
}, cancel: cancel }))];
|
|
181
|
+
case 2:
|
|
182
|
+
cleanup = _a.sent();
|
|
183
|
+
if (typeof cleanup === 'function') {
|
|
184
|
+
if (isCellInteractionSessionActive(session.id))
|
|
185
|
+
cleanupRef.current = cleanup;
|
|
186
|
+
else
|
|
187
|
+
cleanup();
|
|
188
|
+
}
|
|
189
|
+
return [3 /*break*/, 4];
|
|
190
|
+
case 3:
|
|
191
|
+
error_1 = _a.sent();
|
|
192
|
+
cancel();
|
|
193
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
194
|
+
console.warn('[BGrid] editorIcon onClick failed.', error_1);
|
|
195
|
+
}
|
|
196
|
+
return [3 /*break*/, 4];
|
|
197
|
+
case 4: return [2 /*return*/];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); };
|
|
201
|
+
return (React.createElement("button", { type: 'button', className: 'bgrid-editor-icon', "data-visibility": (_c = config.visibility) !== null && _c !== void 0 ? _c : 'always', "data-active": active ? 'true' : undefined, "data-busy": isOwnIconSession ? 'true' : undefined, "aria-label": ariaLabel, "aria-busy": isOwnIconSession || undefined, tabIndex: active && hostCell.rowIndex === index ? 0 : -1, hidden: hiddenWhileEditing || isOwnIconSession, onPointerDown: function (event) {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
event.stopPropagation();
|
|
204
|
+
}, onClick: function (event) {
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
void activate();
|
|
207
|
+
} },
|
|
208
|
+
React.createElement("span", { className: 'bgrid-editor-icon-content', "aria-hidden": 'true' }, typeof config.render === 'function' ? config.render(params) : config.render)));
|
|
209
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CellNavigationDomSync = CellNavigationDomSync;
|
|
37
|
+
var React = __importStar(require("react"));
|
|
38
|
+
/**
|
|
39
|
+
* Keeps the compatibility classes/data attributes on rendered table cells and
|
|
40
|
+
* axes without making every body/header subscribe to navigation state.
|
|
41
|
+
* Selection geometry itself is rendered by the lightweight overlay layer.
|
|
42
|
+
*/
|
|
43
|
+
function CellNavigationDomSync(_a) {
|
|
44
|
+
var containerRef = _a.containerRef, activeCell = _a.activeCell, cellSelectionRanges = _a.cellSelectionRanges, hasMultiCellSelection = _a.hasMultiCellSelection, rowCount = _a.rowCount, columnCount = _a.columnCount;
|
|
45
|
+
React.useLayoutEffect(function () {
|
|
46
|
+
var container = containerRef.current;
|
|
47
|
+
if (!container)
|
|
48
|
+
return;
|
|
49
|
+
container
|
|
50
|
+
.querySelectorAll('[data-bgrid-cell-active="true"], [data-bgrid-cell-active-multi-selection="true"]')
|
|
51
|
+
.forEach(function (cell) {
|
|
52
|
+
cell.classList.remove('bgrid-cell-active', 'bgrid-cell-active-multi-selection');
|
|
53
|
+
cell.removeAttribute('data-bgrid-cell-active');
|
|
54
|
+
cell.removeAttribute('data-bgrid-cell-active-multi-selection');
|
|
55
|
+
});
|
|
56
|
+
if (activeCell) {
|
|
57
|
+
container
|
|
58
|
+
.querySelectorAll("td[data-bgrid-cell=\"true\"][data-bgrid-logical-row-index=\"".concat(activeCell.rowIndex, "\"][data-column-index=\"").concat(activeCell.columnIndex, "\"]"))
|
|
59
|
+
.forEach(function (cell) {
|
|
60
|
+
cell.classList.add('bgrid-cell-active');
|
|
61
|
+
cell.setAttribute('data-bgrid-cell-active', 'true');
|
|
62
|
+
if (hasMultiCellSelection) {
|
|
63
|
+
cell.classList.add('bgrid-cell-active-multi-selection');
|
|
64
|
+
cell.setAttribute('data-bgrid-cell-active-multi-selection', 'true');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
var coversEveryColumn = cellSelectionRanges.some(function (range) { return coversCompleteAxis(range.startColumnIndex, range.endColumnIndex, columnCount); });
|
|
69
|
+
var coversEveryRow = cellSelectionRanges.some(function (range) { return coversCompleteAxis(range.startRowIndex, range.endRowIndex, rowCount); });
|
|
70
|
+
var wholeRowSelection = coversEveryColumn && !coversEveryRow;
|
|
71
|
+
var wholeColumnSelection = coversEveryRow && !coversEveryColumn;
|
|
72
|
+
container.querySelectorAll('.bgrid-line-number-cell[data-row-index]').forEach(function (cell) {
|
|
73
|
+
var rowIndex = Number(cell.dataset.rowIndex);
|
|
74
|
+
var active = !wholeColumnSelection &&
|
|
75
|
+
Number.isFinite(rowIndex) &&
|
|
76
|
+
isRowAxisActive(rowIndex, activeCell, cellSelectionRanges);
|
|
77
|
+
cell.classList.toggle('bgrid-row-axis-active', active);
|
|
78
|
+
if (active)
|
|
79
|
+
cell.setAttribute('data-bgrid-row-axis-active', 'true');
|
|
80
|
+
else
|
|
81
|
+
cell.removeAttribute('data-bgrid-row-axis-active');
|
|
82
|
+
});
|
|
83
|
+
container.querySelectorAll('[data-header-cell-type][data-column-index]').forEach(function (cell) {
|
|
84
|
+
var columnIndex = Number(cell.dataset.columnIndex);
|
|
85
|
+
var active = cell.dataset.headerCellType === 'column' &&
|
|
86
|
+
!wholeRowSelection &&
|
|
87
|
+
Number.isFinite(columnIndex) &&
|
|
88
|
+
isColumnAxisActive(columnIndex, activeCell, cellSelectionRanges);
|
|
89
|
+
cell.classList.toggle('bgrid-column-axis-active', active);
|
|
90
|
+
if (active)
|
|
91
|
+
cell.setAttribute('data-bgrid-column-axis-active', 'true');
|
|
92
|
+
else
|
|
93
|
+
cell.removeAttribute('data-bgrid-column-axis-active');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function coversCompleteAxis(first, second, length) {
|
|
99
|
+
return length > 0 && Math.min(first, second) === 0 && Math.max(first, second) === length - 1;
|
|
100
|
+
}
|
|
101
|
+
function isRowAxisActive(rowIndex, activeCell, ranges) {
|
|
102
|
+
if ((activeCell === null || activeCell === void 0 ? void 0 : activeCell.rowIndex) === rowIndex)
|
|
103
|
+
return true;
|
|
104
|
+
return ranges.some(function (range) { return isWithin(rowIndex, range.startRowIndex, range.endRowIndex); });
|
|
105
|
+
}
|
|
106
|
+
function isColumnAxisActive(columnIndex, activeCell, ranges) {
|
|
107
|
+
if ((activeCell === null || activeCell === void 0 ? void 0 : activeCell.columnIndex) === columnIndex)
|
|
108
|
+
return true;
|
|
109
|
+
return ranges.some(function (range) {
|
|
110
|
+
var rangeStart = Math.min(range.startColumnIndex, range.endColumnIndex);
|
|
111
|
+
var rangeEnd = Math.max(range.startColumnIndex, range.endColumnIndex);
|
|
112
|
+
return columnIndex >= rangeStart && columnIndex <= rangeEnd;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function isWithin(value, first, second) {
|
|
116
|
+
return value >= Math.min(first, second) && value <= Math.max(first, second);
|
|
117
|
+
}
|