@linzjs/step-ag-grid 35.1.0 → 35.2.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/index.css +17 -0
- package/dist/src/components/Grid.d.ts +3 -1
- package/dist/src/components/GridRangeSelectContextMenu.d.ts +12 -1
- package/dist/src/components/gridFilter/GridFilterCopyButton.d.ts +9 -0
- package/dist/src/components/gridFilter/index.d.ts +1 -0
- package/dist/src/components/gridHook/copyGridCells.d.ts +19 -0
- package/dist/src/components/gridHook/copyGridCells.test.d.ts +1 -0
- package/dist/src/components/gridHook/useGridCopy.d.ts +5 -2
- package/dist/src/components/gridHook/useGridCopySettings.d.ts +2 -0
- package/dist/src/contexts/GridContext.d.ts +35 -0
- package/dist/src/contexts/GridContextProvider.copy.test.d.ts +1 -0
- package/dist/step-ag-grid.cjs +431 -231
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +432 -233
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +15 -0
- package/src/components/GridRangeSelectContextMenu.tsx +54 -51
- package/src/components/gridFilter/GridFilterCopyButton.tsx +93 -0
- package/src/components/gridFilter/index.ts +1 -0
- package/src/components/gridHook/copyGridCells.test.ts +142 -0
- package/src/components/gridHook/copyGridCells.ts +225 -0
- package/src/components/gridHook/useGridCopy.ts +88 -211
- package/src/components/gridHook/useGridCopySettings.ts +21 -6
- package/src/contexts/GridContext.tsx +44 -0
- package/src/contexts/GridContextProvider.copy.test.tsx +158 -0
- package/src/contexts/GridContextProvider.tsx +129 -2
- package/src/stories/grid/GridCopy.stories.tsx +35 -20
- package/src/stories/grid/GridCopyEditable.stories.tsx +131 -0
- package/src/stories/grid/GridCopyMultiple.stories.tsx +119 -0
- package/src/styles/GridFilterCopyButton.scss +22 -0
- package/src/styles/index.scss +1 -0
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { LuiMiniSpinner, LuiIcon, useShowLUIMessage, LuiStatusSpinner, LuiButtonGroup, LuiButton, LuiCheckboxInput, useFilterCharacters } from '@linzjs/lui';
|
|
3
3
|
import React14, { forwardRef, useContext, useRef, useState, useImperativeHandle, useLayoutEffect, useCallback, useMemo, createContext, memo, useEffect, createElement, Suspense, Component as Component$1, useReducer, cloneElement, Fragment as Fragment$1, useId } from 'react';
|
|
4
4
|
import ReactDOM, { createPortal, unstable_batchedUpdates, flushSync } from 'react-dom';
|
|
5
|
-
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, compact, xorBy, last, difference, omit, delay, sortBy, partition, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
|
|
5
|
+
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, compact, xorBy, last, difference, omit, delay, sortBy, partition, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, set, get, flatten, castArray } from 'lodash-es';
|
|
6
6
|
|
|
7
7
|
const ComponentLoadingWrapper = (props) => {
|
|
8
8
|
return props.loading ? /* @__PURE__ */ jsx(LuiMiniSpinner, { size: 22, divProps: { role: "status", ["aria-label"]: "Loading", style: { padding: 16 } } }) : /* @__PURE__ */ jsxs("div", { style: { pointerEvents: props.saving ? "none" : "inherit" }, className: props.className, children: [
|
|
@@ -62385,6 +62385,13 @@ const GridContext = createContext({
|
|
|
62385
62385
|
isExternalFilterPresent: NoContext,
|
|
62386
62386
|
doesExternalFilterPass: NoContext,
|
|
62387
62387
|
downloadCsv: NoContext,
|
|
62388
|
+
copyToClipboard: NoContext,
|
|
62389
|
+
getCopyScope: () => "all",
|
|
62390
|
+
getSelectedDataForCopy: NoContext,
|
|
62391
|
+
getCopyData: NoContext,
|
|
62392
|
+
setRangeCopy: NoContext,
|
|
62393
|
+
copyEnabled: false,
|
|
62394
|
+
setCopyEnabled: NoContext,
|
|
62388
62395
|
onBulkEditingComplete: NoContext,
|
|
62389
62396
|
setOnBulkEditingComplete: NoContext,
|
|
62390
62397
|
showNoRowsOverlay: NoContext
|
|
@@ -65030,13 +65037,21 @@ const gridCopyOptions = {
|
|
|
65030
65037
|
json: { text: "Json", icon: "ic_file_attached_outline", developer: true }
|
|
65031
65038
|
};
|
|
65032
65039
|
const CopyOptionsStorageKey = "stepAgGrid_defaultCopy";
|
|
65040
|
+
const isCopyOptionsKey = (key) => Object.keys(gridCopyOptions).includes(key);
|
|
65041
|
+
const getDefaultCopyType = () => {
|
|
65042
|
+
const defaultCopy = window.localStorage.getItem(CopyOptionsStorageKey) ?? "";
|
|
65043
|
+
return isCopyOptionsKey(defaultCopy) ? defaultCopy : "html";
|
|
65044
|
+
};
|
|
65033
65045
|
const useGridCopySettings = () => {
|
|
65034
|
-
const [copyType, _setCopyType] = useState(
|
|
65035
|
-
|
|
65036
|
-
|
|
65037
|
-
|
|
65046
|
+
const [copyType, _setCopyType] = useState(getDefaultCopyType);
|
|
65047
|
+
const listenerRef = useRef(void 0);
|
|
65048
|
+
useEffect(() => {
|
|
65049
|
+
const listener = (value) => isCopyOptionsKey(value) && _setCopyType(value);
|
|
65050
|
+
listenerRef.current = listener;
|
|
65051
|
+
return subscribeStorageKey(CopyOptionsStorageKey, listener);
|
|
65052
|
+
}, []);
|
|
65038
65053
|
const setCopyType = useCallback((key) => {
|
|
65039
|
-
window.localStorage
|
|
65054
|
+
publishStorageKey(window.localStorage, CopyOptionsStorageKey, key, listenerRef.current);
|
|
65040
65055
|
_setCopyType(key);
|
|
65041
65056
|
}, []);
|
|
65042
65057
|
return {
|
|
@@ -65045,59 +65060,231 @@ const useGridCopySettings = () => {
|
|
|
65045
65060
|
};
|
|
65046
65061
|
};
|
|
65047
65062
|
|
|
65063
|
+
const GridCopyOptionsMenuItems = ({
|
|
65064
|
+
onCopy,
|
|
65065
|
+
copyType,
|
|
65066
|
+
setCopyType,
|
|
65067
|
+
developer: showDeveloper = false,
|
|
65068
|
+
header = "Copy as"
|
|
65069
|
+
}) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65070
|
+
/* @__PURE__ */ jsx(MenuHeader, { children: header }),
|
|
65071
|
+
typedEntries(gridCopyOptions).map(([key, { icon, text, developer }]) => {
|
|
65072
|
+
return (!developer || showDeveloper) && /* @__PURE__ */ jsx(MenuItem, { onClick: () => onCopy(key), children: /* @__PURE__ */ jsxs("div", { className: "copyMenuMenuItem", children: [
|
|
65073
|
+
/* @__PURE__ */ jsx(LuiIcon, { name: icon, alt: text, size: "md" }),
|
|
65074
|
+
/* @__PURE__ */ jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65075
|
+
] }) }, key);
|
|
65076
|
+
}),
|
|
65077
|
+
/* @__PURE__ */ jsx(MenuDivider, {}),
|
|
65078
|
+
/* @__PURE__ */ jsx(MenuHeader, { children: "Set copy default" }),
|
|
65079
|
+
typedEntries(gridCopyOptions).map(([key, { text, developer }]) => {
|
|
65080
|
+
return !developer && /* @__PURE__ */ jsx(MenuItem, { onClick: () => setCopyType(key), children: /* @__PURE__ */ jsxs(
|
|
65081
|
+
"div",
|
|
65082
|
+
{
|
|
65083
|
+
className: clsx("copyMenuMenuItem", copyType === key ? "" : "copyMenuMenuItem__buttonDefault--hidden"),
|
|
65084
|
+
children: [
|
|
65085
|
+
/* @__PURE__ */ jsx(LuiIcon, { name: "ic_tick", alt: "Default", size: "sm" }),
|
|
65086
|
+
/* @__PURE__ */ jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65087
|
+
]
|
|
65088
|
+
}
|
|
65089
|
+
) }, "default_" + key);
|
|
65090
|
+
})
|
|
65091
|
+
] });
|
|
65048
65092
|
const GridRangeSelectContextMenu = ({
|
|
65049
65093
|
event,
|
|
65050
65094
|
context
|
|
65051
65095
|
}) => {
|
|
65052
65096
|
const developerContextMenu = !!event?.event?.ctrlKey && !!event?.event?.shiftKey;
|
|
65053
|
-
|
|
65054
|
-
const onClick = useCallback(
|
|
65055
|
-
(type) => {
|
|
65056
|
-
onCopy?.(type);
|
|
65057
|
-
},
|
|
65058
|
-
[onCopy]
|
|
65059
|
-
);
|
|
65060
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65061
|
-
/* @__PURE__ */ jsx(MenuHeader, { children: "Copy as" }),
|
|
65062
|
-
typedEntries(gridCopyOptions).map(([key, { icon, text, developer }]) => {
|
|
65063
|
-
return (!developer || developerContextMenu) && /* @__PURE__ */ jsx(MenuItem, { onClick: () => void onClick(key), children: /* @__PURE__ */ jsxs("div", { className: "copyMenuMenuItem", children: [
|
|
65064
|
-
/* @__PURE__ */ jsx(LuiIcon, { name: icon, alt: text, size: "md" }),
|
|
65065
|
-
/* @__PURE__ */ jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65066
|
-
] }) }, key);
|
|
65067
|
-
}),
|
|
65068
|
-
/* @__PURE__ */ jsx(MenuDivider, {}),
|
|
65069
|
-
/* @__PURE__ */ jsx(MenuHeader, { children: "Set copy default" }),
|
|
65070
|
-
typedEntries(gridCopyOptions).map(([key, { text, developer }]) => {
|
|
65071
|
-
return !developer && /* @__PURE__ */ jsx(
|
|
65072
|
-
MenuItem,
|
|
65073
|
-
{
|
|
65074
|
-
onClick: (e) => {
|
|
65075
|
-
context?.setCopyType(key);
|
|
65076
|
-
e.keepOpen = true;
|
|
65077
|
-
},
|
|
65078
|
-
children: /* @__PURE__ */ jsxs(
|
|
65079
|
-
"div",
|
|
65080
|
-
{
|
|
65081
|
-
className: clsx(
|
|
65082
|
-
"copyMenuMenuItem",
|
|
65083
|
-
context?.copyType === key ? "" : "copyMenuMenuItem__buttonDefault--hidden"
|
|
65084
|
-
),
|
|
65085
|
-
children: [
|
|
65086
|
-
/* @__PURE__ */ jsx(LuiIcon, { name: "ic_tick", alt: "CSV", size: "sm" }),
|
|
65087
|
-
/* @__PURE__ */ jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65088
|
-
]
|
|
65089
|
-
}
|
|
65090
|
-
)
|
|
65091
|
-
},
|
|
65092
|
-
"default_" + key
|
|
65093
|
-
);
|
|
65094
|
-
})
|
|
65095
|
-
] });
|
|
65097
|
+
return context ? /* @__PURE__ */ jsx(GridCopyOptionsMenuItems, { ...context, developer: developerContextMenu }) : null;
|
|
65096
65098
|
};
|
|
65097
65099
|
|
|
65098
65100
|
const agGridSelectRowColId = "ag-Grid-SelectionColumn";
|
|
65099
65101
|
|
|
65102
|
+
const isCopyableColId = (colId, getColDef) => colId !== "gridCellFiller" && getColDef(colId)?.headerComponentParams?.exportable !== false;
|
|
65103
|
+
const copyGridCells = ({
|
|
65104
|
+
type,
|
|
65105
|
+
selectedColIds,
|
|
65106
|
+
selectedNodes,
|
|
65107
|
+
selectedRowIds,
|
|
65108
|
+
getColDef,
|
|
65109
|
+
getCellValue,
|
|
65110
|
+
showToast
|
|
65111
|
+
}) => {
|
|
65112
|
+
const json = type === "json";
|
|
65113
|
+
const filteredSelectedColIds = selectedColIds.filter(
|
|
65114
|
+
(colId) => colId === agGridSelectRowColId || isCopyableColId(colId, getColDef)
|
|
65115
|
+
);
|
|
65116
|
+
const formatters = compact(
|
|
65117
|
+
filteredSelectedColIds.map((colKey) => {
|
|
65118
|
+
return (rowNode) => {
|
|
65119
|
+
if (colKey === agGridSelectRowColId) {
|
|
65120
|
+
return selectedRowIds.includes(rowNode.data.id);
|
|
65121
|
+
} else {
|
|
65122
|
+
const v = getCellValue({ rowNode, colKey });
|
|
65123
|
+
if (json && v !== void 0) {
|
|
65124
|
+
return v;
|
|
65125
|
+
}
|
|
65126
|
+
const f = getCellValue({ rowNode, colKey, useFormatter: true });
|
|
65127
|
+
return v == f ? v : f;
|
|
65128
|
+
}
|
|
65129
|
+
};
|
|
65130
|
+
})
|
|
65131
|
+
);
|
|
65132
|
+
const headers = filteredSelectedColIds.map((colId) => {
|
|
65133
|
+
if (colId === agGridSelectRowColId) return type === "json" ? "selected" : "Selected";
|
|
65134
|
+
if (json) {
|
|
65135
|
+
return colId;
|
|
65136
|
+
}
|
|
65137
|
+
return getColDef(colId)?.headerName ?? "?";
|
|
65138
|
+
});
|
|
65139
|
+
const maxCellLength = {};
|
|
65140
|
+
headers.forEach((headerName, i) => {
|
|
65141
|
+
const colId = filteredSelectedColIds[i];
|
|
65142
|
+
maxCellLength[colId] = headerName.length;
|
|
65143
|
+
});
|
|
65144
|
+
const rows = [];
|
|
65145
|
+
if (type === "csv" || type === "html") {
|
|
65146
|
+
rows.push(headers);
|
|
65147
|
+
}
|
|
65148
|
+
selectedNodes.forEach((node) => {
|
|
65149
|
+
const row = [];
|
|
65150
|
+
rows.push(row);
|
|
65151
|
+
formatters.forEach((formatter, i) => {
|
|
65152
|
+
const colId = filteredSelectedColIds[i];
|
|
65153
|
+
let value = formatter(node);
|
|
65154
|
+
if (typeof value === "string") {
|
|
65155
|
+
value = value.replaceAll("\xA0", " ");
|
|
65156
|
+
}
|
|
65157
|
+
if (!json) {
|
|
65158
|
+
if (value === "-" || value === "\u2013" || value == null) {
|
|
65159
|
+
value = "";
|
|
65160
|
+
}
|
|
65161
|
+
value = String(value);
|
|
65162
|
+
if (value === "-" || value === "\u2013") {
|
|
65163
|
+
value = "";
|
|
65164
|
+
}
|
|
65165
|
+
maxCellLength[colId] = Math.max(maxCellLength[colId], value.length);
|
|
65166
|
+
}
|
|
65167
|
+
switch (type) {
|
|
65168
|
+
case "json":
|
|
65169
|
+
value = value === "undefined" || value !== null && typeof value === "object" || typeof value === "string" ? JSON.stringify(value) : value;
|
|
65170
|
+
break;
|
|
65171
|
+
case "markdown":
|
|
65172
|
+
value = encodeMarkdownValue(value);
|
|
65173
|
+
break;
|
|
65174
|
+
case "csv":
|
|
65175
|
+
value = encodeCSVValue(value);
|
|
65176
|
+
break;
|
|
65177
|
+
}
|
|
65178
|
+
row.push(String(value));
|
|
65179
|
+
});
|
|
65180
|
+
});
|
|
65181
|
+
let result = "";
|
|
65182
|
+
let html = `<table style="
|
|
65183
|
+
font-family: 'Open Sans', system-ui, sans-serif;
|
|
65184
|
+
font-size: 10px;
|
|
65185
|
+
line-height: 10px;
|
|
65186
|
+
border: 1px solid #d1d9e0;
|
|
65187
|
+
border-collapse: collapse;
|
|
65188
|
+
">`;
|
|
65189
|
+
if (json) {
|
|
65190
|
+
result += "[\n";
|
|
65191
|
+
}
|
|
65192
|
+
rows.forEach((row, rowIndex) => {
|
|
65193
|
+
if (json) {
|
|
65194
|
+
result += " { ";
|
|
65195
|
+
}
|
|
65196
|
+
if (rowIndex == 1) {
|
|
65197
|
+
html += '<tbody style="font-weight: 400;">';
|
|
65198
|
+
}
|
|
65199
|
+
if (rowIndex == 0) {
|
|
65200
|
+
html += '<thead style="font-weight: 600;">';
|
|
65201
|
+
}
|
|
65202
|
+
if (rowIndex === 0 || (rowIndex & 1) === 1) {
|
|
65203
|
+
html += "<tr>";
|
|
65204
|
+
} else {
|
|
65205
|
+
html += '<tr style="background-color: #f6f8fa;">';
|
|
65206
|
+
}
|
|
65207
|
+
if (rowIndex === 1 && type === "html") {
|
|
65208
|
+
Object.values(maxCellLength).forEach((maxLength) => {
|
|
65209
|
+
result += "|" + "-".repeat(maxLength + 2);
|
|
65210
|
+
});
|
|
65211
|
+
result += "|\n";
|
|
65212
|
+
}
|
|
65213
|
+
row.forEach((cell, i) => {
|
|
65214
|
+
switch (type) {
|
|
65215
|
+
case "csv":
|
|
65216
|
+
if (i !== 0) {
|
|
65217
|
+
result += ", ";
|
|
65218
|
+
}
|
|
65219
|
+
result += cell;
|
|
65220
|
+
break;
|
|
65221
|
+
case "html":
|
|
65222
|
+
if (i === 0) {
|
|
65223
|
+
result += "|";
|
|
65224
|
+
}
|
|
65225
|
+
const colId = filteredSelectedColIds[i];
|
|
65226
|
+
result += " " + cell.padEnd(maxCellLength[colId], " ") + " ";
|
|
65227
|
+
result += "|";
|
|
65228
|
+
html += rowIndex === 0 ? '<th style="border: 1px solid #d1d9e0; padding:6px 13px; text-align: left;">' : '<td style="border: 1px solid #d1d9e0; padding:6px 13px;">';
|
|
65229
|
+
html += cell;
|
|
65230
|
+
html += rowIndex === 0 ? "</th>" : "</td>";
|
|
65231
|
+
break;
|
|
65232
|
+
case "json":
|
|
65233
|
+
if (i !== 0) {
|
|
65234
|
+
result += ", ";
|
|
65235
|
+
}
|
|
65236
|
+
result += JSON.stringify(headers[i]) + ": " + cell;
|
|
65237
|
+
break;
|
|
65238
|
+
}
|
|
65239
|
+
});
|
|
65240
|
+
html += "</tr>";
|
|
65241
|
+
if (rowIndex == 0) {
|
|
65242
|
+
html += "</thead>";
|
|
65243
|
+
}
|
|
65244
|
+
if (rowIndex == rows.length - 1) {
|
|
65245
|
+
html += "</tbody>";
|
|
65246
|
+
}
|
|
65247
|
+
if (json) {
|
|
65248
|
+
result += rowIndex < rows.length - 1 ? " }," : " }";
|
|
65249
|
+
}
|
|
65250
|
+
result += "\n";
|
|
65251
|
+
});
|
|
65252
|
+
if (json) {
|
|
65253
|
+
result += "]\n";
|
|
65254
|
+
}
|
|
65255
|
+
html += "</table>";
|
|
65256
|
+
showToast({
|
|
65257
|
+
message: `${gridCopyOptions[type].text} copied`,
|
|
65258
|
+
messageType: "toast",
|
|
65259
|
+
messageLevel: "info"
|
|
65260
|
+
});
|
|
65261
|
+
if (type === "html") {
|
|
65262
|
+
const clipboardItem = new ClipboardItem({
|
|
65263
|
+
"text/html": new Blob([html], { type: "text/html" }),
|
|
65264
|
+
"text/plain": new Blob([result], { type: "text/plain" })
|
|
65265
|
+
// fallback
|
|
65266
|
+
});
|
|
65267
|
+
void navigator.clipboard.write([clipboardItem]).catch((err) => console.error("Failed to copy: ", err));
|
|
65268
|
+
} else {
|
|
65269
|
+
void navigator.clipboard.writeText(result).catch((err) => console.error("Failed to copy: ", err));
|
|
65270
|
+
}
|
|
65271
|
+
};
|
|
65272
|
+
const encodeMarkdownValue = (value) => {
|
|
65273
|
+
return value.replaceAll("|", "\\|");
|
|
65274
|
+
};
|
|
65275
|
+
const encodeCSVValue = (value) => {
|
|
65276
|
+
let str = String(value);
|
|
65277
|
+
if (/[",\n]/.test(str)) {
|
|
65278
|
+
str = '"' + str.replace(/"/g, '""') + '"';
|
|
65279
|
+
}
|
|
65280
|
+
return str;
|
|
65281
|
+
};
|
|
65282
|
+
|
|
65283
|
+
let lastActiveGridElement = null;
|
|
65284
|
+
const isEditableElement = (el) => el instanceof Element && (!!el.closest("input, textarea, select") || el.isContentEditable);
|
|
65100
65285
|
const useGridCopy = ({
|
|
65286
|
+
gridDivRef,
|
|
65287
|
+
gridDocument,
|
|
65101
65288
|
ranges,
|
|
65102
65289
|
rangeStartRef,
|
|
65103
65290
|
rangeEndRef,
|
|
@@ -65105,193 +65292,41 @@ const useGridCopy = ({
|
|
|
65105
65292
|
cellContextMenu
|
|
65106
65293
|
}) => {
|
|
65107
65294
|
const showToast = useShowLUIMessage();
|
|
65108
|
-
const { getSelectedRowIds } = useGridContext();
|
|
65109
|
-
const { getColDef, getCellValue } = useGridContext();
|
|
65295
|
+
const { getColDef, getCellValue, getSelectedRowIds, setRangeCopy } = useGridContext();
|
|
65110
65296
|
const { copyType, setCopyType } = useGridCopySettings();
|
|
65297
|
+
const hasRange = useCallback(
|
|
65298
|
+
() => rangeStartRef.current !== null && rangeEndRef.current !== null && hasSelectedMoreThanOneCellRef.current,
|
|
65299
|
+
[rangeStartRef, rangeEndRef, hasSelectedMoreThanOneCellRef]
|
|
65300
|
+
);
|
|
65111
65301
|
const onCopy = useCallback(
|
|
65112
65302
|
(type = copyType) => {
|
|
65113
65303
|
const rangeStart = rangeStartRef.current;
|
|
65114
65304
|
const rangeEnd = rangeEndRef.current;
|
|
65115
|
-
if (rangeStart === null || rangeEnd === null || !
|
|
65305
|
+
if (rangeStart === null || rangeEnd === null || !hasRange()) {
|
|
65116
65306
|
return;
|
|
65117
65307
|
}
|
|
65118
65308
|
if (rangeStart.rowId === rangeEnd.rowId && rangeStart.colId === rangeEnd.colId) {
|
|
65119
65309
|
type = "html";
|
|
65120
65310
|
}
|
|
65121
|
-
const json = type === "json";
|
|
65122
65311
|
const { selectedColIds, selectedNodes } = ranges();
|
|
65123
|
-
|
|
65124
|
-
|
|
65125
|
-
|
|
65126
|
-
|
|
65127
|
-
|
|
65128
|
-
|
|
65129
|
-
|
|
65130
|
-
|
|
65131
|
-
return selectedRowIds.includes(rowNode.data.id);
|
|
65132
|
-
} else {
|
|
65133
|
-
const v = getCellValue({ rowNode, colKey });
|
|
65134
|
-
if (json && v !== void 0) {
|
|
65135
|
-
return v;
|
|
65136
|
-
}
|
|
65137
|
-
const f = getCellValue({ rowNode, colKey, useFormatter: true });
|
|
65138
|
-
return v == f ? v : f;
|
|
65139
|
-
}
|
|
65140
|
-
};
|
|
65141
|
-
})
|
|
65142
|
-
);
|
|
65143
|
-
const headers = filteredSelectedColIds.map((colId) => {
|
|
65144
|
-
if (colId === agGridSelectRowColId) return type === "json" ? "selected" : "Selected";
|
|
65145
|
-
if (json) {
|
|
65146
|
-
return colId;
|
|
65147
|
-
}
|
|
65148
|
-
return getColDef(colId)?.headerName ?? "?";
|
|
65149
|
-
});
|
|
65150
|
-
const maxCellLength = {};
|
|
65151
|
-
headers.forEach((headerName, i) => {
|
|
65152
|
-
const colId = filteredSelectedColIds[i];
|
|
65153
|
-
maxCellLength[colId] = headerName.length;
|
|
65154
|
-
});
|
|
65155
|
-
const rows = [];
|
|
65156
|
-
if (type === "csv" || type === "html") {
|
|
65157
|
-
rows.push(headers);
|
|
65158
|
-
}
|
|
65159
|
-
selectedNodes.forEach((node) => {
|
|
65160
|
-
const row = [];
|
|
65161
|
-
rows.push(row);
|
|
65162
|
-
formatters.forEach((formatter, i) => {
|
|
65163
|
-
const colId = filteredSelectedColIds[i];
|
|
65164
|
-
let value = formatter(node);
|
|
65165
|
-
if (typeof value === "string") {
|
|
65166
|
-
value = value.replaceAll("\xA0", " ");
|
|
65167
|
-
}
|
|
65168
|
-
if (!json) {
|
|
65169
|
-
if (value === "-" || value === "\u2013" || value == null) {
|
|
65170
|
-
value = "";
|
|
65171
|
-
}
|
|
65172
|
-
value = String(value);
|
|
65173
|
-
if (value === "-" || value === "\u2013") {
|
|
65174
|
-
value = "";
|
|
65175
|
-
}
|
|
65176
|
-
maxCellLength[colId] = Math.max(maxCellLength[colId], value.length);
|
|
65177
|
-
}
|
|
65178
|
-
switch (type) {
|
|
65179
|
-
case "json":
|
|
65180
|
-
value = value === "undefined" || value !== null && typeof value === "object" || typeof value === "string" ? JSON.stringify(value) : value;
|
|
65181
|
-
break;
|
|
65182
|
-
case "markdown":
|
|
65183
|
-
value = encodeMarkdownValue(value);
|
|
65184
|
-
break;
|
|
65185
|
-
case "csv":
|
|
65186
|
-
value = encodeCSVValue(value);
|
|
65187
|
-
break;
|
|
65188
|
-
}
|
|
65189
|
-
row.push(String(value));
|
|
65190
|
-
});
|
|
65191
|
-
});
|
|
65192
|
-
let result = "";
|
|
65193
|
-
let html = `<table style="
|
|
65194
|
-
font-family: 'Open Sans', system-ui, sans-serif;
|
|
65195
|
-
font-size: 10px;
|
|
65196
|
-
line-height: 10px;
|
|
65197
|
-
border: 1px solid #d1d9e0;
|
|
65198
|
-
border-collapse: collapse;
|
|
65199
|
-
">`;
|
|
65200
|
-
if (json) {
|
|
65201
|
-
result += "[\n";
|
|
65202
|
-
}
|
|
65203
|
-
rows.forEach((row, rowIndex) => {
|
|
65204
|
-
if (json) {
|
|
65205
|
-
result += " { ";
|
|
65206
|
-
}
|
|
65207
|
-
if (rowIndex == 1) {
|
|
65208
|
-
html += '<tbody style="font-weight: 400;">';
|
|
65209
|
-
}
|
|
65210
|
-
if (rowIndex == 0) {
|
|
65211
|
-
html += '<thead style="font-weight: 600;">';
|
|
65212
|
-
}
|
|
65213
|
-
if (rowIndex === 0 || (rowIndex & 1) === 1) {
|
|
65214
|
-
html += "<tr>";
|
|
65215
|
-
} else {
|
|
65216
|
-
html += '<tr style="background-color: #f6f8fa;">';
|
|
65217
|
-
}
|
|
65218
|
-
if (rowIndex === 1 && type === "html") {
|
|
65219
|
-
Object.values(maxCellLength).forEach((maxLength) => {
|
|
65220
|
-
result += "|" + "-".repeat(maxLength + 2);
|
|
65221
|
-
});
|
|
65222
|
-
result += "|\n";
|
|
65223
|
-
}
|
|
65224
|
-
row.forEach((cell, i) => {
|
|
65225
|
-
switch (type) {
|
|
65226
|
-
case "csv":
|
|
65227
|
-
if (i !== 0) {
|
|
65228
|
-
result += ", ";
|
|
65229
|
-
}
|
|
65230
|
-
result += cell;
|
|
65231
|
-
break;
|
|
65232
|
-
case "html":
|
|
65233
|
-
if (i === 0) {
|
|
65234
|
-
result += "|";
|
|
65235
|
-
}
|
|
65236
|
-
const colId = filteredSelectedColIds[i];
|
|
65237
|
-
result += " " + cell.padEnd(maxCellLength[colId], " ") + " ";
|
|
65238
|
-
result += "|";
|
|
65239
|
-
html += rowIndex === 0 ? '<th style="border: 1px solid #d1d9e0; padding:6px 13px; text-align: left;">' : '<td style="border: 1px solid #d1d9e0; padding:6px 13px;">';
|
|
65240
|
-
html += cell;
|
|
65241
|
-
html += rowIndex === 0 ? "</th>" : "</td>";
|
|
65242
|
-
break;
|
|
65243
|
-
case "json":
|
|
65244
|
-
if (i !== 0) {
|
|
65245
|
-
result += ", ";
|
|
65246
|
-
}
|
|
65247
|
-
result += JSON.stringify(headers[i]) + ": " + cell;
|
|
65248
|
-
break;
|
|
65249
|
-
}
|
|
65250
|
-
});
|
|
65251
|
-
html += "</tr>";
|
|
65252
|
-
if (rowIndex == 0) {
|
|
65253
|
-
html += "</thead>";
|
|
65254
|
-
}
|
|
65255
|
-
if (rowIndex == rows.length - 1) {
|
|
65256
|
-
html += "</tbody>";
|
|
65257
|
-
}
|
|
65258
|
-
if (json) {
|
|
65259
|
-
result += " }";
|
|
65260
|
-
}
|
|
65261
|
-
result += "\n";
|
|
65262
|
-
});
|
|
65263
|
-
if (json) {
|
|
65264
|
-
result += "]\n";
|
|
65265
|
-
}
|
|
65266
|
-
html += "</table>";
|
|
65267
|
-
showToast({
|
|
65268
|
-
message: `${gridCopyOptions[type].text} copied`,
|
|
65269
|
-
messageType: "toast",
|
|
65270
|
-
messageLevel: "info"
|
|
65312
|
+
copyGridCells({
|
|
65313
|
+
type,
|
|
65314
|
+
selectedColIds,
|
|
65315
|
+
selectedNodes,
|
|
65316
|
+
selectedRowIds: getSelectedRowIds(),
|
|
65317
|
+
getColDef,
|
|
65318
|
+
getCellValue,
|
|
65319
|
+
showToast
|
|
65271
65320
|
});
|
|
65272
|
-
if (type === "html") {
|
|
65273
|
-
const clipboardItem = new ClipboardItem({
|
|
65274
|
-
"text/html": new Blob([html], { type: "text/html" }),
|
|
65275
|
-
"text/plain": new Blob([result], { type: "text/plain" })
|
|
65276
|
-
// fallback
|
|
65277
|
-
});
|
|
65278
|
-
void navigator.clipboard.write([clipboardItem]).catch((err) => console.error("Failed to copy: ", err));
|
|
65279
|
-
} else {
|
|
65280
|
-
void navigator.clipboard.writeText(result).catch((err) => console.error("Failed to copy: ", err));
|
|
65281
|
-
}
|
|
65282
65321
|
},
|
|
65283
|
-
[
|
|
65284
|
-
getCellValue,
|
|
65285
|
-
ranges,
|
|
65286
|
-
copyType,
|
|
65287
|
-
rangeStartRef,
|
|
65288
|
-
hasSelectedMoreThanOneCellRef,
|
|
65289
|
-
rangeEndRef,
|
|
65290
|
-
showToast,
|
|
65291
|
-
getColDef,
|
|
65292
|
-
getSelectedRowIds
|
|
65293
|
-
]
|
|
65322
|
+
[getCellValue, ranges, copyType, rangeStartRef, hasRange, rangeEndRef, showToast, getColDef, getSelectedRowIds]
|
|
65294
65323
|
);
|
|
65324
|
+
const onCopyRef = useRef(onCopy);
|
|
65325
|
+
onCopyRef.current = onCopy;
|
|
65326
|
+
useEffect(() => {
|
|
65327
|
+
setRangeCopy({ hasRange, getRange: ranges, copy: (type) => onCopyRef.current(type) });
|
|
65328
|
+
return () => setRangeCopy(void 0);
|
|
65329
|
+
}, [hasRange, ranges, setRangeCopy]);
|
|
65295
65330
|
const onCopyEvent = useCallback(
|
|
65296
65331
|
(e) => {
|
|
65297
65332
|
const rangeStart = rangeStartRef.current;
|
|
@@ -65304,6 +65339,31 @@ const useGridCopy = ({
|
|
|
65304
65339
|
},
|
|
65305
65340
|
[onCopy, rangeStartRef, rangeEndRef, hasSelectedMoreThanOneCellRef]
|
|
65306
65341
|
);
|
|
65342
|
+
useEffect(() => {
|
|
65343
|
+
const gridDiv = gridDivRef.current;
|
|
65344
|
+
const doc = gridDocument ?? gridDiv?.ownerDocument;
|
|
65345
|
+
if (!gridDiv || !doc) return;
|
|
65346
|
+
const setActive = () => {
|
|
65347
|
+
lastActiveGridElement = gridDiv;
|
|
65348
|
+
};
|
|
65349
|
+
const onDocumentCopy = (e) => {
|
|
65350
|
+
if (gridDiv.contains(e.target) || // handled by onCopyEvent
|
|
65351
|
+
lastActiveGridElement !== gridDiv || !hasRange() || isEditableElement(e.target) || !doc.getSelection()?.isCollapsed) {
|
|
65352
|
+
return;
|
|
65353
|
+
}
|
|
65354
|
+
e.preventDefault();
|
|
65355
|
+
onCopyRef.current();
|
|
65356
|
+
};
|
|
65357
|
+
gridDiv.addEventListener("mousedown", setActive, true);
|
|
65358
|
+
gridDiv.addEventListener("focusin", setActive, true);
|
|
65359
|
+
doc.addEventListener("copy", onDocumentCopy);
|
|
65360
|
+
return () => {
|
|
65361
|
+
gridDiv.removeEventListener("mousedown", setActive, true);
|
|
65362
|
+
gridDiv.removeEventListener("focusin", setActive, true);
|
|
65363
|
+
doc.removeEventListener("copy", onDocumentCopy);
|
|
65364
|
+
if (lastActiveGridElement === gridDiv) lastActiveGridElement = null;
|
|
65365
|
+
};
|
|
65366
|
+
}, [gridDivRef, gridDocument, hasRange]);
|
|
65307
65367
|
const { cellContextMenu: rangeSelectContextMenu, contextMenuComponent: rangeSelectContextMenuComponent } = useGridContextMenu({
|
|
65308
65368
|
contextMenu: GridRangeSelectContextMenu,
|
|
65309
65369
|
context: { onCopy, copyType, setCopyType }
|
|
@@ -65320,16 +65380,6 @@ const useGridCopy = ({
|
|
|
65320
65380
|
rangeSelectContextMenuComponent
|
|
65321
65381
|
};
|
|
65322
65382
|
};
|
|
65323
|
-
const encodeMarkdownValue = (value) => {
|
|
65324
|
-
return value.replaceAll("|", "\\|");
|
|
65325
|
-
};
|
|
65326
|
-
const encodeCSVValue = (value) => {
|
|
65327
|
-
let str = String(value);
|
|
65328
|
-
if (/[",\n]/.test(str)) {
|
|
65329
|
-
str = '"' + str.replace(/"/g, '""') + '"';
|
|
65330
|
-
}
|
|
65331
|
-
return str;
|
|
65332
|
-
};
|
|
65333
65383
|
|
|
65334
65384
|
const useGridRangeSelection = ({
|
|
65335
65385
|
enableRangeSelection,
|
|
@@ -65751,6 +65801,7 @@ const Grid = ({
|
|
|
65751
65801
|
// ─── Selection ────────────────────────────────
|
|
65752
65802
|
autoSelectFirstRow,
|
|
65753
65803
|
enableRangeSelection = false,
|
|
65804
|
+
enableCopy = false,
|
|
65754
65805
|
externalSelectedIds,
|
|
65755
65806
|
externalSelectedItems,
|
|
65756
65807
|
selectColumnPinned = "left",
|
|
@@ -65781,6 +65832,7 @@ const Grid = ({
|
|
|
65781
65832
|
setApis,
|
|
65782
65833
|
setExternallySelectedItemsAreInSync,
|
|
65783
65834
|
setOnBulkEditingComplete,
|
|
65835
|
+
setCopyEnabled,
|
|
65784
65836
|
gridReady,
|
|
65785
65837
|
gridRenderState,
|
|
65786
65838
|
externallySelectedItemsAreInSync,
|
|
@@ -65875,6 +65927,7 @@ const Grid = ({
|
|
|
65875
65927
|
}
|
|
65876
65928
|
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
65877
65929
|
const lastOwnerDocumentRef = useRef(void 0);
|
|
65930
|
+
const [gridDocument, setGridDocument] = useState();
|
|
65878
65931
|
const wasVisibleRef = useRef(false);
|
|
65879
65932
|
useInterval(() => {
|
|
65880
65933
|
const visible = !!gridDivRef.current?.checkVisibility?.();
|
|
@@ -65892,6 +65945,7 @@ const Grid = ({
|
|
|
65892
65945
|
const currentDocument = gridDivRef.current?.ownerDocument;
|
|
65893
65946
|
if (currentDocument !== lastOwnerDocumentRef.current) {
|
|
65894
65947
|
lastOwnerDocumentRef.current = currentDocument;
|
|
65948
|
+
setGridDocument(currentDocument);
|
|
65895
65949
|
if (currentDocument) {
|
|
65896
65950
|
needsAutoSize.current = true;
|
|
65897
65951
|
}
|
|
@@ -66143,12 +66197,18 @@ const Grid = ({
|
|
|
66143
66197
|
rangeSortedNodesRef
|
|
66144
66198
|
});
|
|
66145
66199
|
const { onCopyEvent, rangeSelectInterceptContextMenu, rangeSelectContextMenuComponent } = useGridCopy({
|
|
66200
|
+
gridDivRef,
|
|
66201
|
+
gridDocument,
|
|
66146
66202
|
ranges,
|
|
66147
66203
|
rangeStartRef,
|
|
66148
66204
|
rangeEndRef,
|
|
66149
66205
|
hasSelectedMoreThanOneCellRef,
|
|
66150
66206
|
cellContextMenu
|
|
66151
66207
|
});
|
|
66208
|
+
useEffect(() => {
|
|
66209
|
+
setCopyEnabled(enableCopy);
|
|
66210
|
+
return () => setCopyEnabled(false);
|
|
66211
|
+
}, [enableCopy, setCopyEnabled]);
|
|
66152
66212
|
const userSizedColIds = useRef(/* @__PURE__ */ new Map());
|
|
66153
66213
|
const { saveColumnState: saveColumnStateToStorage } = useGridColumnStateStorage({
|
|
66154
66214
|
enabled: saveColumnState,
|
|
@@ -67181,6 +67241,72 @@ const GridFilterColumnsToggle = ({ saveState = true }) => {
|
|
|
67181
67241
|
);
|
|
67182
67242
|
};
|
|
67183
67243
|
|
|
67244
|
+
const copyScopeHeader = {
|
|
67245
|
+
range: "Copy range",
|
|
67246
|
+
selection: "Copy selection",
|
|
67247
|
+
all: "Copy all"
|
|
67248
|
+
};
|
|
67249
|
+
const copyTypeTooltipText = (copyType) => copyType === "html" ? "text / HTML" : gridCopyOptions[copyType].text;
|
|
67250
|
+
const GridFilterCopyMenuItems = ({ developer }) => {
|
|
67251
|
+
const { copyToClipboard, getCopyScope } = useGridContext();
|
|
67252
|
+
const { copyType, setCopyType } = useGridCopySettings();
|
|
67253
|
+
return /* @__PURE__ */ jsx(
|
|
67254
|
+
GridCopyOptionsMenuItems,
|
|
67255
|
+
{
|
|
67256
|
+
header: copyScopeHeader[getCopyScope()],
|
|
67257
|
+
onCopy: copyToClipboard,
|
|
67258
|
+
copyType,
|
|
67259
|
+
setCopyType,
|
|
67260
|
+
developer
|
|
67261
|
+
}
|
|
67262
|
+
);
|
|
67263
|
+
};
|
|
67264
|
+
const GridFilterCopyButton = () => {
|
|
67265
|
+
const { copyEnabled, copyToClipboard, getCopyScope } = useGridContext();
|
|
67266
|
+
const { copyType } = useGridCopySettings();
|
|
67267
|
+
const [copyScope, setCopyScope] = useState("all");
|
|
67268
|
+
const updateCopyScope = useCallback(() => setCopyScope(getCopyScope()), [getCopyScope]);
|
|
67269
|
+
const [developerMenu, setDeveloperMenu] = useState(false);
|
|
67270
|
+
if (!copyEnabled) return null;
|
|
67271
|
+
const copyTitle = `${copyScopeHeader[copyScope]} as ${copyTypeTooltipText(copyType)}`;
|
|
67272
|
+
return /* @__PURE__ */ jsxs("div", { className: "lui-split-button GridFilterCopyButton", onMouseEnter: updateCopyScope, onFocus: updateCopyScope, children: [
|
|
67273
|
+
/* @__PURE__ */ jsx(
|
|
67274
|
+
LuiButton,
|
|
67275
|
+
{
|
|
67276
|
+
type: "button",
|
|
67277
|
+
level: "secondary",
|
|
67278
|
+
className: "lui-button-icon-only lui-split-button-primary-btn GridFilterCopyButton-copy",
|
|
67279
|
+
title: copyTitle,
|
|
67280
|
+
buttonProps: { "aria-label": copyTitle },
|
|
67281
|
+
onClick: () => copyToClipboard(copyType),
|
|
67282
|
+
children: /* @__PURE__ */ jsx(LuiIcon, { name: "ic_copy", alt: copyTitle, size: "md" })
|
|
67283
|
+
}
|
|
67284
|
+
),
|
|
67285
|
+
/* @__PURE__ */ jsx(
|
|
67286
|
+
Menu,
|
|
67287
|
+
{
|
|
67288
|
+
menuButton: /* @__PURE__ */ jsx(
|
|
67289
|
+
"button",
|
|
67290
|
+
{
|
|
67291
|
+
type: "button",
|
|
67292
|
+
className: "popup-toggle-button popup-toggle-button-secondary GridFilterCopyButton-caret",
|
|
67293
|
+
title: "Copy options",
|
|
67294
|
+
"aria-label": "Copy options",
|
|
67295
|
+
onClick: (e) => setDeveloperMenu(e.ctrlKey && e.shiftKey),
|
|
67296
|
+
children: /* @__PURE__ */ jsx(LuiIcon, { name: "ic_expand_more", alt: "Copy options", size: "md" })
|
|
67297
|
+
}
|
|
67298
|
+
),
|
|
67299
|
+
menuClassName: "step-ag-grid-react-menu",
|
|
67300
|
+
className: "GridContextMenu",
|
|
67301
|
+
align: "end",
|
|
67302
|
+
portal: true,
|
|
67303
|
+
unmountOnClose: true,
|
|
67304
|
+
children: /* @__PURE__ */ jsx(GridFilterCopyMenuItems, { developer: developerMenu })
|
|
67305
|
+
}
|
|
67306
|
+
)
|
|
67307
|
+
] });
|
|
67308
|
+
};
|
|
67309
|
+
|
|
67184
67310
|
const useTimeoutHook = () => {
|
|
67185
67311
|
const timeout = useRef(void 0);
|
|
67186
67312
|
const clearTimeouts = () => {
|
|
@@ -69324,10 +69450,12 @@ const colStateFlexed = (colState) => !!colState.flex;
|
|
|
69324
69450
|
const colStateNotFlexed = (colState) => !colState.flex;
|
|
69325
69451
|
const GridContextProvider = (props) => {
|
|
69326
69452
|
const { modifyUpdating, anyUpdating } = useContext(GridUpdatingContext);
|
|
69453
|
+
const showToast = useShowLUIMessage();
|
|
69327
69454
|
const [gridApi, setGridApi] = useState();
|
|
69328
69455
|
const [gridReady, setGridReady] = useState(false);
|
|
69329
69456
|
const [quickFilter, _setQuickFilter] = useState("");
|
|
69330
69457
|
const [invisibleColumnIds, _setInvisibleColumnIds] = useState();
|
|
69458
|
+
const [copyEnabled, setCopyEnabled] = useState(false);
|
|
69331
69459
|
const testId = useRef(void 0);
|
|
69332
69460
|
const hasExternallySelectedItemsRef = useRef(false);
|
|
69333
69461
|
const enableMultilineBulkEditRef = useRef(false);
|
|
@@ -69956,6 +70084,70 @@ const GridContextProvider = (props) => {
|
|
|
69956
70084
|
},
|
|
69957
70085
|
[gridApi]
|
|
69958
70086
|
);
|
|
70087
|
+
const rangeCopyRef = useRef(void 0);
|
|
70088
|
+
const setRangeCopy = useCallback((rangeCopy) => {
|
|
70089
|
+
rangeCopyRef.current = rangeCopy;
|
|
70090
|
+
}, []);
|
|
70091
|
+
const getCopyRows = useCallback(() => {
|
|
70092
|
+
const nodes = [];
|
|
70093
|
+
if (gridApi && !gridApi.isDestroyed()) {
|
|
70094
|
+
gridApi.forEachNodeAfterFilterAndSort((node) => {
|
|
70095
|
+
if (node.data && !node.group) nodes.push(node);
|
|
70096
|
+
});
|
|
70097
|
+
}
|
|
70098
|
+
const selectedNodes = nodes.filter((node) => node.isSelected());
|
|
70099
|
+
return isEmpty(selectedNodes) ? { scope: "all", nodes } : { scope: "selection", nodes: selectedNodes };
|
|
70100
|
+
}, [gridApi]);
|
|
70101
|
+
const getDisplayedCopyColIds = useCallback(
|
|
70102
|
+
() => gridApi && !gridApi.isDestroyed() ? gridApi.getAllDisplayedColumns().map((col) => col.getColId()).filter((colId) => colId !== agGridSelectRowColId) : [],
|
|
70103
|
+
[gridApi]
|
|
70104
|
+
);
|
|
70105
|
+
const getCopyTarget = useCallback(() => {
|
|
70106
|
+
const rangeCopy = rangeCopyRef.current;
|
|
70107
|
+
const { selectedColIds, selectedNodes } = rangeCopy?.hasRange() ? rangeCopy.getRange() : { selectedColIds: getDisplayedCopyColIds(), selectedNodes: getCopyRows().nodes };
|
|
70108
|
+
return {
|
|
70109
|
+
colIds: selectedColIds.filter((colId) => colId !== agGridSelectRowColId && isCopyableColId(colId, getColDef)),
|
|
70110
|
+
nodes: selectedNodes
|
|
70111
|
+
};
|
|
70112
|
+
}, [getColDef, getCopyRows, getDisplayedCopyColIds]);
|
|
70113
|
+
const getSelectedDataForCopy = useCallback(() => {
|
|
70114
|
+
const { colIds, nodes } = getCopyTarget();
|
|
70115
|
+
const fields = compact(colIds.map((colId) => getColDef(colId)?.field));
|
|
70116
|
+
return nodes.map((node) => {
|
|
70117
|
+
const data = {};
|
|
70118
|
+
fields.forEach((field) => set(data, field, get(node.data, field)));
|
|
70119
|
+
return data;
|
|
70120
|
+
});
|
|
70121
|
+
}, [getColDef, getCopyTarget]);
|
|
70122
|
+
const getCopyData = useCallback(() => {
|
|
70123
|
+
const { colIds, nodes } = getCopyTarget();
|
|
70124
|
+
return nodes.map(
|
|
70125
|
+
(rowNode) => Object.fromEntries(colIds.map((colKey) => [colKey, gridApi?.getCellValue({ rowNode, colKey })]))
|
|
70126
|
+
);
|
|
70127
|
+
}, [getCopyTarget, gridApi]);
|
|
70128
|
+
const getCopyScope = useCallback(
|
|
70129
|
+
() => rangeCopyRef.current?.hasRange() ? "range" : getCopyRows().scope,
|
|
70130
|
+
[getCopyRows]
|
|
70131
|
+
);
|
|
70132
|
+
const copyToClipboard = useCallback(
|
|
70133
|
+
(type = getDefaultCopyType()) => {
|
|
70134
|
+
if (rangeCopyRef.current?.hasRange()) {
|
|
70135
|
+
rangeCopyRef.current.copy(type);
|
|
70136
|
+
return;
|
|
70137
|
+
}
|
|
70138
|
+
if (!gridApi || gridApi.isDestroyed()) return;
|
|
70139
|
+
copyGridCells({
|
|
70140
|
+
type,
|
|
70141
|
+
selectedColIds: getDisplayedCopyColIds(),
|
|
70142
|
+
selectedNodes: getCopyRows().nodes,
|
|
70143
|
+
selectedRowIds: getSelectedRowIds(),
|
|
70144
|
+
getColDef,
|
|
70145
|
+
getCellValue,
|
|
70146
|
+
showToast
|
|
70147
|
+
});
|
|
70148
|
+
},
|
|
70149
|
+
[getCellValue, getColDef, getCopyRows, getDisplayedCopyColIds, getSelectedRowIds, gridApi, showToast]
|
|
70150
|
+
);
|
|
69959
70151
|
return /* @__PURE__ */ jsx(
|
|
69960
70152
|
GridContext.Provider,
|
|
69961
70153
|
{
|
|
@@ -70000,6 +70192,13 @@ const GridContextProvider = (props) => {
|
|
|
70000
70192
|
isExternalFilterPresent,
|
|
70001
70193
|
doesExternalFilterPass,
|
|
70002
70194
|
downloadCsv,
|
|
70195
|
+
copyToClipboard,
|
|
70196
|
+
getCopyScope,
|
|
70197
|
+
getSelectedDataForCopy,
|
|
70198
|
+
getCopyData,
|
|
70199
|
+
setRangeCopy,
|
|
70200
|
+
copyEnabled,
|
|
70201
|
+
setCopyEnabled,
|
|
70003
70202
|
onBulkEditingComplete,
|
|
70004
70203
|
setOnBulkEditingComplete,
|
|
70005
70204
|
showNoRowsOverlay
|
|
@@ -70214,5 +70413,5 @@ const useDeferredPromise = () => {
|
|
|
70214
70413
|
};
|
|
70215
70414
|
};
|
|
70216
70415
|
|
|
70217
|
-
export { ActionButton, CancelPromise, ChromaticAllowGridAutosize, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellBearingValueFormatter, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsMultiSelect, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormInlineTextInput, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridInlineTextInput, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, agGridSelectRowColId, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, colStateFlexed, colStateId, colStateNotFlexed, compareNaturalInsensitive, convertDDToDMS, createCheckboxMultiFilterParams, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isChromatic, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, reorderRows, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textInputValidatorPropsToSummary, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
70416
|
+
export { ActionButton, CancelPromise, ChromaticAllowGridAutosize, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellBearingValueFormatter, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsMultiSelect, GridFilterColumnsToggle, GridFilterCopyButton, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormInlineTextInput, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridInlineTextInput, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, agGridSelectRowColId, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, colStateFlexed, colStateId, colStateNotFlexed, compareNaturalInsensitive, convertDDToDMS, createCheckboxMultiFilterParams, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isChromatic, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, reorderRows, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textInputValidatorPropsToSummary, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
70218
70417
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|