@uipath/apollo-react 7.11.3 → 7.12.0
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/dist/canvas/components/CanvasDiffView/CanvasDiffView.cjs +6 -6
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.js +6 -6
- package/dist/canvas/components/JsonTree/JsonTree.cjs +2 -2
- package/dist/canvas/components/JsonTree/JsonTree.js +2 -2
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.cjs +6 -6
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.js +6 -6
- package/dist/canvas/components/StageNode/tasks/TaskContent.cjs +1 -1
- package/dist/canvas/components/StageNode/tasks/TaskContent.js +1 -1
- package/dist/canvas/locales/de.cjs +1 -1
- package/dist/canvas/locales/de.d.ts.map +1 -1
- package/dist/canvas/locales/de.js +1 -1
- package/dist/canvas/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/locales/es-MX.cjs +1 -1
- package/dist/canvas/locales/es-MX.d.ts.map +1 -1
- package/dist/canvas/locales/es-MX.js +1 -1
- package/dist/canvas/locales/es.cjs +1 -1
- package/dist/canvas/locales/es.d.ts.map +1 -1
- package/dist/canvas/locales/es.js +1 -1
- package/dist/canvas/locales/fr.cjs +1 -1
- package/dist/canvas/locales/fr.d.ts.map +1 -1
- package/dist/canvas/locales/fr.js +1 -1
- package/dist/canvas/locales/ja.cjs +1 -1
- package/dist/canvas/locales/ja.d.ts.map +1 -1
- package/dist/canvas/locales/ja.js +1 -1
- package/dist/canvas/locales/ko.cjs +1 -1
- package/dist/canvas/locales/ko.d.ts.map +1 -1
- package/dist/canvas/locales/ko.js +1 -1
- package/dist/canvas/locales/pt-BR.cjs +1 -1
- package/dist/canvas/locales/pt-BR.d.ts.map +1 -1
- package/dist/canvas/locales/pt-BR.js +1 -1
- package/dist/canvas/locales/pt.cjs +1 -1
- package/dist/canvas/locales/pt.d.ts.map +1 -1
- package/dist/canvas/locales/pt.js +1 -1
- package/dist/canvas/locales/ro.cjs +1 -1
- package/dist/canvas/locales/ro.d.ts.map +1 -1
- package/dist/canvas/locales/ro.js +1 -1
- package/dist/canvas/locales/ru.cjs +1 -1
- package/dist/canvas/locales/ru.d.ts.map +1 -1
- package/dist/canvas/locales/ru.js +1 -1
- package/dist/canvas/locales/tr.cjs +1 -1
- package/dist/canvas/locales/tr.d.ts.map +1 -1
- package/dist/canvas/locales/tr.js +1 -1
- package/dist/canvas/locales/zh-CN.cjs +1 -1
- package/dist/canvas/locales/zh-CN.d.ts.map +1 -1
- package/dist/canvas/locales/zh-CN.js +1 -1
- package/dist/canvas/locales/zh-TW.cjs +1 -1
- package/dist/canvas/locales/zh-TW.d.ts.map +1 -1
- package/dist/canvas/locales/zh-TW.js +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/locales/de.cjs +1 -1
- package/dist/chat/locales/de.d.ts.map +1 -1
- package/dist/chat/locales/de.js +1 -1
- package/dist/chat/locales/en.cjs +1 -1
- package/dist/chat/locales/en.d.ts.map +1 -1
- package/dist/chat/locales/en.js +1 -1
- package/dist/chat/locales/es-MX.cjs +1 -1
- package/dist/chat/locales/es-MX.d.ts.map +1 -1
- package/dist/chat/locales/es-MX.js +1 -1
- package/dist/chat/locales/es.cjs +1 -1
- package/dist/chat/locales/es.d.ts.map +1 -1
- package/dist/chat/locales/es.js +1 -1
- package/dist/chat/locales/fr.cjs +1 -1
- package/dist/chat/locales/fr.d.ts.map +1 -1
- package/dist/chat/locales/fr.js +1 -1
- package/dist/chat/locales/ja.cjs +1 -1
- package/dist/chat/locales/ja.d.ts.map +1 -1
- package/dist/chat/locales/ja.js +1 -1
- package/dist/chat/locales/ko.cjs +1 -1
- package/dist/chat/locales/ko.d.ts.map +1 -1
- package/dist/chat/locales/ko.js +1 -1
- package/dist/chat/locales/pt-BR.cjs +1 -1
- package/dist/chat/locales/pt-BR.d.ts.map +1 -1
- package/dist/chat/locales/pt-BR.js +1 -1
- package/dist/chat/locales/pt.cjs +1 -1
- package/dist/chat/locales/pt.d.ts.map +1 -1
- package/dist/chat/locales/pt.js +1 -1
- package/dist/chat/locales/ro.cjs +1 -1
- package/dist/chat/locales/ro.d.ts.map +1 -1
- package/dist/chat/locales/ro.js +1 -1
- package/dist/chat/locales/ru.cjs +1 -1
- package/dist/chat/locales/ru.d.ts.map +1 -1
- package/dist/chat/locales/ru.js +1 -1
- package/dist/chat/locales/tr.cjs +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/locales/tr.js +1 -1
- package/dist/chat/locales/zh-CN.cjs +1 -1
- package/dist/chat/locales/zh-CN.d.ts.map +1 -1
- package/dist/chat/locales/zh-CN.js +1 -1
- package/dist/chat/locales/zh-TW.cjs +1 -1
- package/dist/chat/locales/zh-TW.d.ts.map +1 -1
- package/dist/chat/locales/zh-TW.js +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/DecisionTable.cjs +454 -0
- package/dist/decision-table/DecisionTable.d.ts +36 -0
- package/dist/decision-table/DecisionTable.d.ts.map +1 -0
- package/dist/decision-table/DecisionTable.js +410 -0
- package/dist/decision-table/GridCell.cjs +153 -0
- package/dist/decision-table/GridCell.d.ts +43 -0
- package/dist/decision-table/GridCell.d.ts.map +1 -0
- package/dist/decision-table/GridCell.js +116 -0
- package/dist/decision-table/GridMenu.cjs +135 -0
- package/dist/decision-table/GridMenu.d.ts +30 -0
- package/dist/decision-table/GridMenu.d.ts.map +1 -0
- package/dist/decision-table/GridMenu.js +101 -0
- package/dist/decision-table/MarkGlyph.cjs +51 -0
- package/dist/decision-table/MarkGlyph.d.ts +7 -0
- package/dist/decision-table/MarkGlyph.d.ts.map +1 -0
- package/dist/decision-table/MarkGlyph.js +17 -0
- package/dist/decision-table/clipboardCodec.cjs +123 -0
- package/dist/decision-table/clipboardCodec.d.ts +8 -0
- package/dist/decision-table/clipboardCodec.d.ts.map +1 -0
- package/dist/decision-table/clipboardCodec.js +80 -0
- package/dist/decision-table/clippedTitle.cjs +39 -0
- package/dist/decision-table/clippedTitle.d.ts +3 -0
- package/dist/decision-table/clippedTitle.d.ts.map +1 -0
- package/dist/decision-table/clippedTitle.js +5 -0
- package/dist/decision-table/columnSizing.cjs +92 -0
- package/dist/decision-table/columnSizing.d.ts +13 -0
- package/dist/decision-table/columnSizing.d.ts.map +1 -0
- package/dist/decision-table/columnSizing.js +52 -0
- package/dist/decision-table/constants.cjs +84 -0
- package/dist/decision-table/constants.d.ts +14 -0
- package/dist/decision-table/constants.d.ts.map +1 -0
- package/dist/decision-table/constants.js +14 -0
- package/dist/decision-table/gridClipboard.cjs +129 -0
- package/dist/decision-table/gridClipboard.d.ts +19 -0
- package/dist/decision-table/gridClipboard.d.ts.map +1 -0
- package/dist/decision-table/gridClipboard.js +89 -0
- package/dist/decision-table/gridEvents.cjs +72 -0
- package/dist/decision-table/gridEvents.d.ts +14 -0
- package/dist/decision-table/gridEvents.d.ts.map +1 -0
- package/dist/decision-table/gridEvents.js +23 -0
- package/dist/decision-table/gridStyles.cjs +196 -0
- package/dist/decision-table/gridStyles.d.ts +47 -0
- package/dist/decision-table/gridStyles.d.ts.map +1 -0
- package/dist/decision-table/gridStyles.js +54 -0
- package/dist/decision-table/gridTypes.cjs +18 -0
- package/dist/decision-table/gridTypes.d.ts +93 -0
- package/dist/decision-table/gridTypes.d.ts.map +1 -0
- package/dist/decision-table/gridTypes.js +0 -0
- package/dist/decision-table/index.cjs +271 -0
- package/dist/decision-table/index.d.ts +13 -0
- package/dist/decision-table/index.d.ts.map +1 -0
- package/dist/decision-table/index.js +12 -0
- package/dist/decision-table/marks.cjs +39 -0
- package/dist/decision-table/marks.d.ts +20 -0
- package/dist/decision-table/marks.d.ts.map +1 -0
- package/dist/decision-table/marks.js +5 -0
- package/dist/decision-table/styles/tailwind.decision-table.css +2 -0
- package/dist/decision-table/useColumnWidths.cjs +313 -0
- package/dist/decision-table/useColumnWidths.d.ts +21 -0
- package/dist/decision-table/useColumnWidths.d.ts.map +1 -0
- package/dist/decision-table/useColumnWidths.js +279 -0
- package/dist/decision-table/useDragReorder.cjs +229 -0
- package/dist/decision-table/useDragReorder.d.ts +31 -0
- package/dist/decision-table/useDragReorder.d.ts.map +1 -0
- package/dist/decision-table/useDragReorder.js +186 -0
- package/dist/decision-table/useDragSelection.cjs +75 -0
- package/dist/decision-table/useDragSelection.d.ts +18 -0
- package/dist/decision-table/useDragSelection.d.ts.map +1 -0
- package/dist/decision-table/useDragSelection.js +41 -0
- package/dist/decision-table/useGridClipboard.cjs +195 -0
- package/dist/decision-table/useGridClipboard.d.ts +13 -0
- package/dist/decision-table/useGridClipboard.d.ts.map +1 -0
- package/dist/decision-table/useGridClipboard.js +161 -0
- package/dist/decision-table/useGridLayout.cjs +248 -0
- package/dist/decision-table/useGridLayout.d.ts +50 -0
- package/dist/decision-table/useGridLayout.d.ts.map +1 -0
- package/dist/decision-table/useGridLayout.js +211 -0
- package/dist/decision-table/useGridNavigation.cjs +441 -0
- package/dist/decision-table/useGridNavigation.d.ts +67 -0
- package/dist/decision-table/useGridNavigation.d.ts.map +1 -0
- package/dist/decision-table/useGridNavigation.js +404 -0
- package/dist/decision-table/useVirtualizedAxis.cjs +256 -0
- package/dist/decision-table/useVirtualizedAxis.d.ts +34 -0
- package/dist/decision-table/useVirtualizedAxis.d.ts.map +1 -0
- package/dist/decision-table/useVirtualizedAxis.js +219 -0
- package/dist/test/setup.d.ts.map +1 -1
- package/package.json +20 -10
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
useGridClipboard: ()=>useGridClipboard
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const external_clipboardCodec_cjs_namespaceObject = require("./clipboardCodec.cjs");
|
|
31
|
+
const external_gridClipboard_cjs_namespaceObject = require("./gridClipboard.cjs");
|
|
32
|
+
const external_gridEvents_cjs_namespaceObject = require("./gridEvents.cjs");
|
|
33
|
+
const useGridClipboard = (props, extent)=>{
|
|
34
|
+
const ref = (0, external_react_namespaceObject.useRef)({
|
|
35
|
+
props,
|
|
36
|
+
extent
|
|
37
|
+
});
|
|
38
|
+
ref.current = {
|
|
39
|
+
props,
|
|
40
|
+
extent
|
|
41
|
+
};
|
|
42
|
+
const source = ()=>{
|
|
43
|
+
const { props: live, extent: size } = ref.current;
|
|
44
|
+
return live ? {
|
|
45
|
+
...live,
|
|
46
|
+
...size
|
|
47
|
+
} : null;
|
|
48
|
+
};
|
|
49
|
+
const payload = ()=>{
|
|
50
|
+
const live = source();
|
|
51
|
+
return live?.range ? {
|
|
52
|
+
matrix: (0, external_gridClipboard_cjs_namespaceObject.copyRangeMatrix)(live, live.range)
|
|
53
|
+
} : null;
|
|
54
|
+
};
|
|
55
|
+
const writeFlavors = (clipboardData, copied)=>{
|
|
56
|
+
clipboardData.setData('text/plain', (0, external_clipboardCodec_cjs_namespaceObject.toTsv)(copied.matrix));
|
|
57
|
+
clipboardData.setData('text/html', (0, external_clipboardCodec_cjs_namespaceObject.toClipboardHtml)(copied));
|
|
58
|
+
};
|
|
59
|
+
const clearSelection = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
60
|
+
const live = source();
|
|
61
|
+
if (!live?.range || live.readOnly || live.editing) return false;
|
|
62
|
+
const writes = (0, external_gridClipboard_cjs_namespaceObject.planRangeClear)(live, live.range);
|
|
63
|
+
if (0 === writes.length) return false;
|
|
64
|
+
live.onWrite(writes, 0);
|
|
65
|
+
return true;
|
|
66
|
+
}, []);
|
|
67
|
+
const applyMatrix = (matrix, grow)=>{
|
|
68
|
+
const live = source();
|
|
69
|
+
if (!live?.range || live.readOnly || live.editing || 0 === matrix.length) return;
|
|
70
|
+
const plan = (0, external_gridClipboard_cjs_namespaceObject.planRangePaste)(live, live.range, matrix, {
|
|
71
|
+
grow
|
|
72
|
+
});
|
|
73
|
+
const lastRow = plan.writes.reduce((max, write)=>Math.max(max, write.row), -1);
|
|
74
|
+
const appendRows = Math.max(0, Math.min(plan.appendRows, lastRow + 1 - live.rowCount));
|
|
75
|
+
if (plan.writes.length > 0) live.onWrite(plan.writes, appendRows);
|
|
76
|
+
if (plan.clampedRows > 0 || plan.clampedColumns > 0 || plan.skippedCells > 0) live.onPasteOutcome?.(plan);
|
|
77
|
+
};
|
|
78
|
+
const onCopy = (event)=>{
|
|
79
|
+
const live = source();
|
|
80
|
+
if (!live || live.editing || (0, external_gridEvents_cjs_namespaceObject.isFromTextField)(event.target) || !event.clipboardData) return;
|
|
81
|
+
const copied = payload();
|
|
82
|
+
if (!copied) return;
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
writeFlavors(event.clipboardData, copied);
|
|
85
|
+
};
|
|
86
|
+
const onCut = (event)=>{
|
|
87
|
+
const live = source();
|
|
88
|
+
if (!live || live.readOnly || live.editing || (0, external_gridEvents_cjs_namespaceObject.isFromTextField)(event.target) || !event.clipboardData) return;
|
|
89
|
+
const copied = payload();
|
|
90
|
+
if (!copied) return;
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
writeFlavors(event.clipboardData, copied);
|
|
93
|
+
clearSelection();
|
|
94
|
+
};
|
|
95
|
+
const onPaste = (event)=>{
|
|
96
|
+
const live = source();
|
|
97
|
+
if (!live || !live.range || live.editing || live.readOnly || (0, external_gridEvents_cjs_namespaceObject.isFromTextField)(event.target) || !event.clipboardData) return;
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
const pasted = (0, external_clipboardCodec_cjs_namespaceObject.fromClipboardHtml)(event.clipboardData.getData('text/html'));
|
|
100
|
+
applyMatrix(pasted?.matrix ?? (0, external_clipboardCodec_cjs_namespaceObject.parseTsv)(event.clipboardData.getData('text/plain')), false);
|
|
101
|
+
};
|
|
102
|
+
const menuCopy = async ()=>{
|
|
103
|
+
const live = source();
|
|
104
|
+
if (!live || live.editing) return false;
|
|
105
|
+
const copied = payload();
|
|
106
|
+
if (!copied) return false;
|
|
107
|
+
const tsv = (0, external_clipboardCodec_cjs_namespaceObject.toTsv)(copied.matrix);
|
|
108
|
+
const clipboard = navigator.clipboard;
|
|
109
|
+
const canWriteFlavors = !!clipboard?.write && "u" > typeof ClipboardItem;
|
|
110
|
+
if (!canWriteFlavors && !clipboard?.writeText) {
|
|
111
|
+
console.warn('Grid clipboard: this context exposes no Clipboard API, so a menu copy cannot run.');
|
|
112
|
+
live.onClipboardBlocked?.('copy');
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
if (canWriteFlavors) await clipboard.write([
|
|
117
|
+
new ClipboardItem({
|
|
118
|
+
'text/plain': new Blob([
|
|
119
|
+
tsv
|
|
120
|
+
], {
|
|
121
|
+
type: 'text/plain'
|
|
122
|
+
}),
|
|
123
|
+
'text/html': new Blob([
|
|
124
|
+
(0, external_clipboardCodec_cjs_namespaceObject.toClipboardHtml)(copied)
|
|
125
|
+
], {
|
|
126
|
+
type: 'text/html'
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
]);
|
|
130
|
+
else await clipboard.writeText(tsv);
|
|
131
|
+
return true;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.warn('Grid clipboard: the browser refused a clipboard write.', error);
|
|
134
|
+
live.onClipboardBlocked?.('copy');
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const menuCut = async ()=>{
|
|
139
|
+
if (source()?.readOnly) return;
|
|
140
|
+
const cutRange = source()?.range;
|
|
141
|
+
if (!await menuCopy()) return;
|
|
142
|
+
const live = source();
|
|
143
|
+
if (cutRange && live?.range && live.range.anchor.row === cutRange.anchor.row && live.range.anchor.col === cutRange.anchor.col && live.range.focus.row === cutRange.focus.row && live.range.focus.col === cutRange.focus.col) clearSelection();
|
|
144
|
+
};
|
|
145
|
+
const menuPaste = async (grow)=>{
|
|
146
|
+
const live = source();
|
|
147
|
+
if (!live || live.readOnly || live.editing) return;
|
|
148
|
+
let text;
|
|
149
|
+
try {
|
|
150
|
+
text = await navigator.clipboard.readText();
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.warn('Grid clipboard: the browser refused a clipboard read.', error);
|
|
153
|
+
live.onClipboardBlocked?.('paste');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
applyMatrix((0, external_clipboardCodec_cjs_namespaceObject.parseTsv)(text), grow);
|
|
157
|
+
};
|
|
158
|
+
const actions = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
159
|
+
const run = (operation, name)=>()=>{
|
|
160
|
+
operation().catch((error)=>console.warn(`Grid clipboard: ${name} failed.`, error));
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
copy: run(menuCopy, 'copy'),
|
|
164
|
+
cut: run(menuCut, 'cut'),
|
|
165
|
+
paste: ({ grow } = {})=>run(()=>menuPaste(true === grow), 'paste')(),
|
|
166
|
+
clear: clearSelection
|
|
167
|
+
};
|
|
168
|
+
}, [
|
|
169
|
+
clearSelection
|
|
170
|
+
]);
|
|
171
|
+
const handleKeyDown = (event)=>{
|
|
172
|
+
const live = source();
|
|
173
|
+
if (!live || 'Delete' !== event.key && 'Backspace' !== event.key) return false;
|
|
174
|
+
if (!live.range || live.readOnly || live.editing || (0, external_gridEvents_cjs_namespaceObject.isFromTextField)(event.target)) return false;
|
|
175
|
+
if (!clearSelection()) return false;
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
return true;
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
containerProps: props ? {
|
|
181
|
+
onCopy,
|
|
182
|
+
onCut,
|
|
183
|
+
onPaste
|
|
184
|
+
} : {},
|
|
185
|
+
handleKeyDown,
|
|
186
|
+
actions
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
exports.useGridClipboard = __webpack_exports__.useGridClipboard;
|
|
190
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
191
|
+
"useGridClipboard"
|
|
192
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
193
|
+
Object.defineProperty(exports, '__esModule', {
|
|
194
|
+
value: true
|
|
195
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { GridClipboardActions, GridClipboardProps } from './gridTypes';
|
|
3
|
+
interface GridClipboard {
|
|
4
|
+
containerProps: Pick<React.HTMLAttributes<HTMLElement>, 'onCopy' | 'onCut' | 'onPaste'>;
|
|
5
|
+
handleKeyDown: (event: React.KeyboardEvent) => boolean;
|
|
6
|
+
actions: GridClipboardActions;
|
|
7
|
+
}
|
|
8
|
+
export declare const useGridClipboard: (props: GridClipboardProps | undefined, extent: {
|
|
9
|
+
rowCount: number;
|
|
10
|
+
columnCount: number;
|
|
11
|
+
}) => GridClipboard;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=useGridClipboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGridClipboard.d.ts","sourceRoot":"","sources":["../../src/decision-table/useGridClipboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAM5E,UAAU,aAAa;IACrB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAExF,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,OAAO,CAAC;IACvD,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED,eAAO,MAAM,gBAAgB,GAC3B,OAAO,kBAAkB,GAAG,SAAS,EACrC,QAAQ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,KAChD,aAwOF,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
2
|
+
import { fromClipboardHtml, parseTsv, toClipboardHtml, toTsv } from "./clipboardCodec.js";
|
|
3
|
+
import { copyRangeMatrix, planRangeClear, planRangePaste } from "./gridClipboard.js";
|
|
4
|
+
import { isFromTextField } from "./gridEvents.js";
|
|
5
|
+
const useGridClipboard = (props, extent)=>{
|
|
6
|
+
const ref = useRef({
|
|
7
|
+
props,
|
|
8
|
+
extent
|
|
9
|
+
});
|
|
10
|
+
ref.current = {
|
|
11
|
+
props,
|
|
12
|
+
extent
|
|
13
|
+
};
|
|
14
|
+
const source = ()=>{
|
|
15
|
+
const { props: live, extent: size } = ref.current;
|
|
16
|
+
return live ? {
|
|
17
|
+
...live,
|
|
18
|
+
...size
|
|
19
|
+
} : null;
|
|
20
|
+
};
|
|
21
|
+
const payload = ()=>{
|
|
22
|
+
const live = source();
|
|
23
|
+
return live?.range ? {
|
|
24
|
+
matrix: copyRangeMatrix(live, live.range)
|
|
25
|
+
} : null;
|
|
26
|
+
};
|
|
27
|
+
const writeFlavors = (clipboardData, copied)=>{
|
|
28
|
+
clipboardData.setData('text/plain', toTsv(copied.matrix));
|
|
29
|
+
clipboardData.setData('text/html', toClipboardHtml(copied));
|
|
30
|
+
};
|
|
31
|
+
const clearSelection = useCallback(()=>{
|
|
32
|
+
const live = source();
|
|
33
|
+
if (!live?.range || live.readOnly || live.editing) return false;
|
|
34
|
+
const writes = planRangeClear(live, live.range);
|
|
35
|
+
if (0 === writes.length) return false;
|
|
36
|
+
live.onWrite(writes, 0);
|
|
37
|
+
return true;
|
|
38
|
+
}, []);
|
|
39
|
+
const applyMatrix = (matrix, grow)=>{
|
|
40
|
+
const live = source();
|
|
41
|
+
if (!live?.range || live.readOnly || live.editing || 0 === matrix.length) return;
|
|
42
|
+
const plan = planRangePaste(live, live.range, matrix, {
|
|
43
|
+
grow
|
|
44
|
+
});
|
|
45
|
+
const lastRow = plan.writes.reduce((max, write)=>Math.max(max, write.row), -1);
|
|
46
|
+
const appendRows = Math.max(0, Math.min(plan.appendRows, lastRow + 1 - live.rowCount));
|
|
47
|
+
if (plan.writes.length > 0) live.onWrite(plan.writes, appendRows);
|
|
48
|
+
if (plan.clampedRows > 0 || plan.clampedColumns > 0 || plan.skippedCells > 0) live.onPasteOutcome?.(plan);
|
|
49
|
+
};
|
|
50
|
+
const onCopy = (event)=>{
|
|
51
|
+
const live = source();
|
|
52
|
+
if (!live || live.editing || isFromTextField(event.target) || !event.clipboardData) return;
|
|
53
|
+
const copied = payload();
|
|
54
|
+
if (!copied) return;
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
writeFlavors(event.clipboardData, copied);
|
|
57
|
+
};
|
|
58
|
+
const onCut = (event)=>{
|
|
59
|
+
const live = source();
|
|
60
|
+
if (!live || live.readOnly || live.editing || isFromTextField(event.target) || !event.clipboardData) return;
|
|
61
|
+
const copied = payload();
|
|
62
|
+
if (!copied) return;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
writeFlavors(event.clipboardData, copied);
|
|
65
|
+
clearSelection();
|
|
66
|
+
};
|
|
67
|
+
const onPaste = (event)=>{
|
|
68
|
+
const live = source();
|
|
69
|
+
if (!live || !live.range || live.editing || live.readOnly || isFromTextField(event.target) || !event.clipboardData) return;
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
const pasted = fromClipboardHtml(event.clipboardData.getData('text/html'));
|
|
72
|
+
applyMatrix(pasted?.matrix ?? parseTsv(event.clipboardData.getData('text/plain')), false);
|
|
73
|
+
};
|
|
74
|
+
const menuCopy = async ()=>{
|
|
75
|
+
const live = source();
|
|
76
|
+
if (!live || live.editing) return false;
|
|
77
|
+
const copied = payload();
|
|
78
|
+
if (!copied) return false;
|
|
79
|
+
const tsv = toTsv(copied.matrix);
|
|
80
|
+
const clipboard = navigator.clipboard;
|
|
81
|
+
const canWriteFlavors = !!clipboard?.write && "u" > typeof ClipboardItem;
|
|
82
|
+
if (!canWriteFlavors && !clipboard?.writeText) {
|
|
83
|
+
console.warn('Grid clipboard: this context exposes no Clipboard API, so a menu copy cannot run.');
|
|
84
|
+
live.onClipboardBlocked?.('copy');
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
if (canWriteFlavors) await clipboard.write([
|
|
89
|
+
new ClipboardItem({
|
|
90
|
+
'text/plain': new Blob([
|
|
91
|
+
tsv
|
|
92
|
+
], {
|
|
93
|
+
type: 'text/plain'
|
|
94
|
+
}),
|
|
95
|
+
'text/html': new Blob([
|
|
96
|
+
toClipboardHtml(copied)
|
|
97
|
+
], {
|
|
98
|
+
type: 'text/html'
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
]);
|
|
102
|
+
else await clipboard.writeText(tsv);
|
|
103
|
+
return true;
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.warn('Grid clipboard: the browser refused a clipboard write.', error);
|
|
106
|
+
live.onClipboardBlocked?.('copy');
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const menuCut = async ()=>{
|
|
111
|
+
if (source()?.readOnly) return;
|
|
112
|
+
const cutRange = source()?.range;
|
|
113
|
+
if (!await menuCopy()) return;
|
|
114
|
+
const live = source();
|
|
115
|
+
if (cutRange && live?.range && live.range.anchor.row === cutRange.anchor.row && live.range.anchor.col === cutRange.anchor.col && live.range.focus.row === cutRange.focus.row && live.range.focus.col === cutRange.focus.col) clearSelection();
|
|
116
|
+
};
|
|
117
|
+
const menuPaste = async (grow)=>{
|
|
118
|
+
const live = source();
|
|
119
|
+
if (!live || live.readOnly || live.editing) return;
|
|
120
|
+
let text;
|
|
121
|
+
try {
|
|
122
|
+
text = await navigator.clipboard.readText();
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.warn('Grid clipboard: the browser refused a clipboard read.', error);
|
|
125
|
+
live.onClipboardBlocked?.('paste');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
applyMatrix(parseTsv(text), grow);
|
|
129
|
+
};
|
|
130
|
+
const actions = useMemo(()=>{
|
|
131
|
+
const run = (operation, name)=>()=>{
|
|
132
|
+
operation().catch((error)=>console.warn(`Grid clipboard: ${name} failed.`, error));
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
copy: run(menuCopy, 'copy'),
|
|
136
|
+
cut: run(menuCut, 'cut'),
|
|
137
|
+
paste: ({ grow } = {})=>run(()=>menuPaste(true === grow), 'paste')(),
|
|
138
|
+
clear: clearSelection
|
|
139
|
+
};
|
|
140
|
+
}, [
|
|
141
|
+
clearSelection
|
|
142
|
+
]);
|
|
143
|
+
const handleKeyDown = (event)=>{
|
|
144
|
+
const live = source();
|
|
145
|
+
if (!live || 'Delete' !== event.key && 'Backspace' !== event.key) return false;
|
|
146
|
+
if (!live.range || live.readOnly || live.editing || isFromTextField(event.target)) return false;
|
|
147
|
+
if (!clearSelection()) return false;
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
return true;
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
containerProps: props ? {
|
|
153
|
+
onCopy,
|
|
154
|
+
onCut,
|
|
155
|
+
onPaste
|
|
156
|
+
} : {},
|
|
157
|
+
handleKeyDown,
|
|
158
|
+
actions
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export { useGridClipboard };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
separatorFlexIndexes: ()=>separatorFlexIndexes,
|
|
28
|
+
useGridLayout: ()=>useGridLayout
|
|
29
|
+
});
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const external_constants_cjs_namespaceObject = require("./constants.cjs");
|
|
32
|
+
const external_useColumnWidths_cjs_namespaceObject = require("./useColumnWidths.cjs");
|
|
33
|
+
const external_useVirtualizedAxis_cjs_namespaceObject = require("./useVirtualizedAxis.cjs");
|
|
34
|
+
const separatorFlexIndexes = (columns, pinnedCount = 0)=>{
|
|
35
|
+
const indexes = new Set();
|
|
36
|
+
for(let index = Math.max(1, pinnedCount); index < columns.length; index++){
|
|
37
|
+
const group = columns[index].group;
|
|
38
|
+
if (group?.separatorBefore && group.id !== columns[index - 1].group?.id) indexes.add(index);
|
|
39
|
+
}
|
|
40
|
+
return indexes;
|
|
41
|
+
};
|
|
42
|
+
const NO_OMITTED_BORDERS = [];
|
|
43
|
+
const RIGHT_OMITTED = [
|
|
44
|
+
'right'
|
|
45
|
+
];
|
|
46
|
+
const withHostFrame = (edges, isLast)=>isLast && !edges.includes('right') ? [
|
|
47
|
+
...edges,
|
|
48
|
+
'right'
|
|
49
|
+
] : edges;
|
|
50
|
+
const resolveOmittedBorders = (columns, framedByHost)=>columns.map((column, index)=>{
|
|
51
|
+
const isLast = index === columns.length - 1;
|
|
52
|
+
const declared = column.group?.omitCellBorders;
|
|
53
|
+
if (!declared || 0 === declared.length) return framedByHost && isLast ? RIGHT_OMITTED : NO_OMITTED_BORDERS;
|
|
54
|
+
const inSameBand = (other)=>other?.group?.id !== void 0 && other.group.id === column.group?.id;
|
|
55
|
+
const opensBand = !inSameBand(columns[index - 1]);
|
|
56
|
+
const closesBand = !inSameBand(columns[index + 1]);
|
|
57
|
+
const kept = declared.filter((edge)=>!('left' === edge && opensBand) && !('right' === edge && closesBand));
|
|
58
|
+
return withHostFrame(kept.length === declared.length ? declared : kept, framedByHost && isLast);
|
|
59
|
+
});
|
|
60
|
+
const useGridLayout = ({ columns, rowCount, rowHeightPx, leadingColumnWidth, trailingColumnWidth, pinnedColumnCount = 0, initialColumnWidths, onColumnWidthsChange, containerRef, retainedRowIndex = null, retainedColumnIndex = null, framedByHost = false })=>{
|
|
61
|
+
const separatorsKey = columns.map((column)=>`${column.group?.id ?? ''}:${column.group?.separatorBefore ? '1' : ''}`).join(',');
|
|
62
|
+
const pinnedCount = Math.min(pinnedColumnCount, columns.length);
|
|
63
|
+
const separatorBefore = (0, external_react_namespaceObject.useMemo)(()=>separatorFlexIndexes(columns, pinnedCount), [
|
|
64
|
+
separatorsKey,
|
|
65
|
+
pinnedCount
|
|
66
|
+
]);
|
|
67
|
+
const omittedBorders = (0, external_react_namespaceObject.useMemo)(()=>resolveOmittedBorders(columns, framedByHost), [
|
|
68
|
+
columns,
|
|
69
|
+
framedByHost
|
|
70
|
+
]);
|
|
71
|
+
const { widths, totalWidth, setTableElement, setColElement, setSpacerElement, onResizeStart, onResizeKeyDown, onResizeReset } = (0, external_useColumnWidths_cjs_namespaceObject.useColumnWidths)({
|
|
72
|
+
columns,
|
|
73
|
+
reservedPx: leadingColumnWidth + trailingColumnWidth + separatorBefore.size * external_constants_cjs_namespaceObject.GROUP_SEPARATOR_WIDTH_PX,
|
|
74
|
+
containerRef,
|
|
75
|
+
initialWidths: initialColumnWidths,
|
|
76
|
+
onWidthsChange: onColumnWidthsChange
|
|
77
|
+
});
|
|
78
|
+
const windowedCount = columns.length - pinnedCount;
|
|
79
|
+
const headerHeightRef = (0, external_react_namespaceObject.useRef)(0);
|
|
80
|
+
const headerObserverRef = (0, external_react_namespaceObject.useRef)(null);
|
|
81
|
+
const theadRef = (0, external_react_namespaceObject.useCallback)((element)=>{
|
|
82
|
+
headerObserverRef.current?.disconnect();
|
|
83
|
+
headerObserverRef.current = null;
|
|
84
|
+
headerHeightRef.current = element?.offsetHeight ?? 0;
|
|
85
|
+
if (!element || "u" < typeof ResizeObserver) return;
|
|
86
|
+
const observer = new ResizeObserver(()=>{
|
|
87
|
+
headerHeightRef.current = element.offsetHeight;
|
|
88
|
+
});
|
|
89
|
+
observer.observe(element);
|
|
90
|
+
headerObserverRef.current = observer;
|
|
91
|
+
}, []);
|
|
92
|
+
const headerHeight = (0, external_react_namespaceObject.useCallback)(()=>headerHeightRef.current, []);
|
|
93
|
+
const widthsKey = widths.join(',');
|
|
94
|
+
const stableWidths = (0, external_react_namespaceObject.useMemo)(()=>widths, [
|
|
95
|
+
widthsKey
|
|
96
|
+
]);
|
|
97
|
+
const widthsRef = (0, external_react_namespaceObject.useRef)(stableWidths);
|
|
98
|
+
widthsRef.current = stableWidths;
|
|
99
|
+
const columnsRef = (0, external_react_namespaceObject.useRef)(columns);
|
|
100
|
+
columnsRef.current = columns;
|
|
101
|
+
const columnLeading = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
102
|
+
let leading = leadingColumnWidth;
|
|
103
|
+
for(let index = 0; index < pinnedCount && index < columnsRef.current.length; index += 1)leading += widthsRef.current[index] ?? columnsRef.current[index].defaultWidth;
|
|
104
|
+
return leading;
|
|
105
|
+
}, [
|
|
106
|
+
leadingColumnWidth,
|
|
107
|
+
pinnedCount
|
|
108
|
+
]);
|
|
109
|
+
const columnOffsets = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
110
|
+
const offsets = new Array(windowedCount + 1);
|
|
111
|
+
offsets[0] = 0;
|
|
112
|
+
for(let windowIndex = 0; windowIndex < windowedCount; windowIndex++){
|
|
113
|
+
const flexIndex = pinnedCount + windowIndex;
|
|
114
|
+
const separatorHere = separatorBefore.has(flexIndex) ? external_constants_cjs_namespaceObject.GROUP_SEPARATOR_WIDTH_PX : 0;
|
|
115
|
+
offsets[windowIndex + 1] = offsets[windowIndex] + separatorHere + (stableWidths[flexIndex] ?? columns[flexIndex].defaultWidth);
|
|
116
|
+
}
|
|
117
|
+
return offsets;
|
|
118
|
+
}, [
|
|
119
|
+
stableWidths,
|
|
120
|
+
windowedCount,
|
|
121
|
+
pinnedCount,
|
|
122
|
+
columns,
|
|
123
|
+
separatorBefore
|
|
124
|
+
]);
|
|
125
|
+
const rowWindow = (0, external_useVirtualizedAxis_cjs_namespaceObject.useVirtualizedAxis)(rowCount, rowHeightPx, retainedRowIndex, {
|
|
126
|
+
axis: 'vertical',
|
|
127
|
+
overscanItems: external_constants_cjs_namespaceObject.DEFAULT_ROW_OVERSCAN,
|
|
128
|
+
fallbackViewportPx: external_constants_cjs_namespaceObject.FALLBACK_ROW_VIEWPORT_PX,
|
|
129
|
+
leadingFixedPx: headerHeight,
|
|
130
|
+
stickyLeadingPx: headerHeight
|
|
131
|
+
});
|
|
132
|
+
const columnWindow = (0, external_useVirtualizedAxis_cjs_namespaceObject.useVirtualizedAxis)(windowedCount, external_constants_cjs_namespaceObject.COLUMN_ESTIMATE_PX, retainedColumnIndex, {
|
|
133
|
+
axis: 'horizontal',
|
|
134
|
+
overscanItems: external_constants_cjs_namespaceObject.DEFAULT_COLUMN_OVERSCAN,
|
|
135
|
+
fallbackViewportPx: external_constants_cjs_namespaceObject.FALLBACK_COLUMN_VIEWPORT_PX,
|
|
136
|
+
leadingFixedPx: columnLeading,
|
|
137
|
+
stickyLeadingPx: columnLeading,
|
|
138
|
+
stickyTrailingPx: trailingColumnWidth,
|
|
139
|
+
itemOffsetsPx: columnOffsets
|
|
140
|
+
});
|
|
141
|
+
const visibleColumns = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
142
|
+
const result = [];
|
|
143
|
+
for(let flexIndex = 0; flexIndex < pinnedCount; flexIndex++)result.push({
|
|
144
|
+
type: 'column',
|
|
145
|
+
column: columns[flexIndex],
|
|
146
|
+
flexIndex,
|
|
147
|
+
windowIndex: null,
|
|
148
|
+
omitBorders: omittedBorders[flexIndex]
|
|
149
|
+
});
|
|
150
|
+
let cursor = 0;
|
|
151
|
+
columnWindow.segments.forEach((segment, segmentIndex)=>{
|
|
152
|
+
if ('spacer' === segment.type) {
|
|
153
|
+
const nextItems = columnWindow.segments.slice(segmentIndex + 1).find((other)=>'items' === other.type);
|
|
154
|
+
const gapEnd = nextItems?.type === 'items' ? nextItems.from : windowedCount;
|
|
155
|
+
const coveredIds = [];
|
|
156
|
+
let separatorPx = 0;
|
|
157
|
+
for(let windowIndex = cursor; windowIndex < gapEnd; windowIndex++){
|
|
158
|
+
const flexIndex = pinnedCount + windowIndex;
|
|
159
|
+
coveredIds.push(columns[flexIndex].id);
|
|
160
|
+
if (separatorBefore.has(flexIndex)) separatorPx += external_constants_cjs_namespaceObject.GROUP_SEPARATOR_WIDTH_PX;
|
|
161
|
+
}
|
|
162
|
+
result.push({
|
|
163
|
+
type: 'spacer',
|
|
164
|
+
widthPx: segment.sizePx,
|
|
165
|
+
coveredIds,
|
|
166
|
+
separatorPx
|
|
167
|
+
});
|
|
168
|
+
cursor = gapEnd;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
for(let windowIndex = segment.from; windowIndex < segment.to; windowIndex++){
|
|
172
|
+
const flexIndex = pinnedCount + windowIndex;
|
|
173
|
+
if (separatorBefore.has(flexIndex)) result.push({
|
|
174
|
+
type: 'separator',
|
|
175
|
+
widthPx: external_constants_cjs_namespaceObject.GROUP_SEPARATOR_WIDTH_PX,
|
|
176
|
+
beforeColumnId: columns[flexIndex].id
|
|
177
|
+
});
|
|
178
|
+
result.push({
|
|
179
|
+
type: 'column',
|
|
180
|
+
column: columns[flexIndex],
|
|
181
|
+
flexIndex,
|
|
182
|
+
windowIndex,
|
|
183
|
+
omitBorders: omittedBorders[flexIndex]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
cursor = segment.to;
|
|
187
|
+
});
|
|
188
|
+
return result;
|
|
189
|
+
}, [
|
|
190
|
+
columnWindow.segments,
|
|
191
|
+
columns,
|
|
192
|
+
pinnedCount,
|
|
193
|
+
windowedCount,
|
|
194
|
+
separatorBefore,
|
|
195
|
+
omittedBorders
|
|
196
|
+
]);
|
|
197
|
+
const scrollRowIntoView = (0, external_react_namespaceObject.useCallback)((rowIndex)=>rowWindow.scrollItemIntoView(containerRef.current, rowIndex), [
|
|
198
|
+
rowWindow.scrollItemIntoView,
|
|
199
|
+
containerRef
|
|
200
|
+
]);
|
|
201
|
+
const scrollColumnIntoView = (0, external_react_namespaceObject.useCallback)((windowIndex)=>columnWindow.scrollItemIntoView(containerRef.current, windowIndex), [
|
|
202
|
+
columnWindow.scrollItemIntoView,
|
|
203
|
+
containerRef
|
|
204
|
+
]);
|
|
205
|
+
const { measureRef: measureRows } = rowWindow;
|
|
206
|
+
const { measureRef: measureColumns } = columnWindow;
|
|
207
|
+
const attachContainer = (0, external_react_namespaceObject.useCallback)((element)=>{
|
|
208
|
+
containerRef.current = element;
|
|
209
|
+
measureRows(element);
|
|
210
|
+
measureColumns(element);
|
|
211
|
+
}, [
|
|
212
|
+
containerRef,
|
|
213
|
+
measureRows,
|
|
214
|
+
measureColumns
|
|
215
|
+
]);
|
|
216
|
+
return {
|
|
217
|
+
widths: stableWidths,
|
|
218
|
+
totalWidth,
|
|
219
|
+
columnOffsets,
|
|
220
|
+
columnLeading,
|
|
221
|
+
headerHeight,
|
|
222
|
+
pinnedColumnCount: pinnedCount,
|
|
223
|
+
leadingColumnWidth,
|
|
224
|
+
trailingColumnWidth,
|
|
225
|
+
containerRef,
|
|
226
|
+
visibleColumns,
|
|
227
|
+
rowSegments: rowWindow.segments,
|
|
228
|
+
theadRef,
|
|
229
|
+
attachContainer,
|
|
230
|
+
setTableElement,
|
|
231
|
+
setColElement,
|
|
232
|
+
setSpacerElement,
|
|
233
|
+
scrollRowIntoView,
|
|
234
|
+
scrollColumnIntoView,
|
|
235
|
+
onResizeStart,
|
|
236
|
+
onResizeKeyDown,
|
|
237
|
+
onResizeReset
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
exports.separatorFlexIndexes = __webpack_exports__.separatorFlexIndexes;
|
|
241
|
+
exports.useGridLayout = __webpack_exports__.useGridLayout;
|
|
242
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
243
|
+
"separatorFlexIndexes",
|
|
244
|
+
"useGridLayout"
|
|
245
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
246
|
+
Object.defineProperty(exports, '__esModule', {
|
|
247
|
+
value: true
|
|
248
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { GridColumn, VisibleGridColumn } from './gridTypes';
|
|
3
|
+
interface GridLayoutOptions {
|
|
4
|
+
columns: GridColumn[];
|
|
5
|
+
rowCount: number;
|
|
6
|
+
rowHeightPx: number;
|
|
7
|
+
leadingColumnWidth: number;
|
|
8
|
+
trailingColumnWidth: number;
|
|
9
|
+
pinnedColumnCount?: number;
|
|
10
|
+
initialColumnWidths: Record<string, number> | Promise<Record<string, number>> | null;
|
|
11
|
+
onColumnWidthsChange?: (widths: Record<string, number>) => void;
|
|
12
|
+
containerRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
13
|
+
retainedRowIndex?: number | null;
|
|
14
|
+
retainedColumnIndex?: number | null;
|
|
15
|
+
framedByHost?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const separatorFlexIndexes: (columns: GridColumn[], pinnedCount?: number) => Set<number>;
|
|
18
|
+
export type GridLayout = ReturnType<typeof useGridLayout>;
|
|
19
|
+
export declare const useGridLayout: ({ columns, rowCount, rowHeightPx, leadingColumnWidth, trailingColumnWidth, pinnedColumnCount, initialColumnWidths, onColumnWidthsChange, containerRef, retainedRowIndex, retainedColumnIndex, framedByHost, }: GridLayoutOptions) => {
|
|
20
|
+
widths: number[];
|
|
21
|
+
totalWidth: number;
|
|
22
|
+
columnOffsets: number[];
|
|
23
|
+
columnLeading: () => number;
|
|
24
|
+
headerHeight: () => number;
|
|
25
|
+
pinnedColumnCount: number;
|
|
26
|
+
leadingColumnWidth: number;
|
|
27
|
+
trailingColumnWidth: number;
|
|
28
|
+
containerRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
29
|
+
visibleColumns: VisibleGridColumn[];
|
|
30
|
+
rowSegments: ({
|
|
31
|
+
type: "items";
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
} | {
|
|
35
|
+
type: "spacer";
|
|
36
|
+
sizePx: number;
|
|
37
|
+
})[];
|
|
38
|
+
theadRef: (element: HTMLTableSectionElement | null) => void;
|
|
39
|
+
attachContainer: (element: HTMLDivElement | null) => void;
|
|
40
|
+
setTableElement: (table: HTMLTableElement | null) => void;
|
|
41
|
+
setColElement: (columnId: string, element: HTMLTableColElement | null) => void;
|
|
42
|
+
setSpacerElement: (spacerId: string, coveredIds: string[], element: HTMLTableColElement | null, extraPx?: number) => void;
|
|
43
|
+
scrollRowIntoView: (rowIndex: number) => void;
|
|
44
|
+
scrollColumnIntoView: (windowIndex: number) => void;
|
|
45
|
+
onResizeStart: (columnId: string, event: React.PointerEvent) => void;
|
|
46
|
+
onResizeKeyDown: (columnId: string, event: React.KeyboardEvent) => void;
|
|
47
|
+
onResizeReset: (columnId: string) => void;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=useGridLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGridLayout.d.ts","sourceRoot":"","sources":["../../src/decision-table/useGridLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAY,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAI3E,UAAU,iBAAiB;IACzB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IAEjB,WAAW,EAAE,MAAM,CAAC;IAEpB,kBAAkB,EAAE,MAAM,CAAC;IAE3B,mBAAmB,EAAE,MAAM,CAAC;IAE5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IAErF,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAEhE,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAE5D,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAWD,eAAO,MAAM,oBAAoB,GAAI,SAAS,UAAU,EAAE,EAAE,oBAAe,KAAG,GAAG,CAAC,MAAM,CASvF,CAAC;AAwCF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAa1D,eAAO,MAAM,aAAa,GAAI,+MAa3B,iBAAiB;;;;;;;;;;;;;;;;;;;wBA2CqB,uBAAuB,GAAG,IAAI;+BAoJzD,cAAc,GAAG,IAAI;;;;kCAbpB,MAAM;wCAIH,MAAM;;;;CAwCvB,CAAC"}
|