@linzjs/step-ag-grid 35.1.0 → 35.2.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/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 +434 -233
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +435 -235
- 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/contexts/GridPopoverContextProvider.tsx +7 -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.cjs
CHANGED
|
@@ -62387,6 +62387,13 @@ const GridContext = React14.createContext({
|
|
|
62387
62387
|
isExternalFilterPresent: NoContext,
|
|
62388
62388
|
doesExternalFilterPass: NoContext,
|
|
62389
62389
|
downloadCsv: NoContext,
|
|
62390
|
+
copyToClipboard: NoContext,
|
|
62391
|
+
getCopyScope: () => "all",
|
|
62392
|
+
getSelectedDataForCopy: NoContext,
|
|
62393
|
+
getCopyData: NoContext,
|
|
62394
|
+
setRangeCopy: NoContext,
|
|
62395
|
+
copyEnabled: false,
|
|
62396
|
+
setCopyEnabled: NoContext,
|
|
62390
62397
|
onBulkEditingComplete: NoContext,
|
|
62391
62398
|
setOnBulkEditingComplete: NoContext,
|
|
62392
62399
|
showNoRowsOverlay: NoContext
|
|
@@ -65032,13 +65039,21 @@ const gridCopyOptions = {
|
|
|
65032
65039
|
json: { text: "Json", icon: "ic_file_attached_outline", developer: true }
|
|
65033
65040
|
};
|
|
65034
65041
|
const CopyOptionsStorageKey = "stepAgGrid_defaultCopy";
|
|
65042
|
+
const isCopyOptionsKey = (key) => Object.keys(gridCopyOptions).includes(key);
|
|
65043
|
+
const getDefaultCopyType = () => {
|
|
65044
|
+
const defaultCopy = window.localStorage.getItem(CopyOptionsStorageKey) ?? "";
|
|
65045
|
+
return isCopyOptionsKey(defaultCopy) ? defaultCopy : "html";
|
|
65046
|
+
};
|
|
65035
65047
|
const useGridCopySettings = () => {
|
|
65036
|
-
const [copyType, _setCopyType] = React14.useState(
|
|
65037
|
-
|
|
65038
|
-
|
|
65039
|
-
|
|
65048
|
+
const [copyType, _setCopyType] = React14.useState(getDefaultCopyType);
|
|
65049
|
+
const listenerRef = React14.useRef(void 0);
|
|
65050
|
+
React14.useEffect(() => {
|
|
65051
|
+
const listener = (value) => isCopyOptionsKey(value) && _setCopyType(value);
|
|
65052
|
+
listenerRef.current = listener;
|
|
65053
|
+
return subscribeStorageKey(CopyOptionsStorageKey, listener);
|
|
65054
|
+
}, []);
|
|
65040
65055
|
const setCopyType = React14.useCallback((key) => {
|
|
65041
|
-
window.localStorage
|
|
65056
|
+
publishStorageKey(window.localStorage, CopyOptionsStorageKey, key, listenerRef.current);
|
|
65042
65057
|
_setCopyType(key);
|
|
65043
65058
|
}, []);
|
|
65044
65059
|
return {
|
|
@@ -65047,59 +65062,231 @@ const useGridCopySettings = () => {
|
|
|
65047
65062
|
};
|
|
65048
65063
|
};
|
|
65049
65064
|
|
|
65065
|
+
const GridCopyOptionsMenuItems = ({
|
|
65066
|
+
onCopy,
|
|
65067
|
+
copyType,
|
|
65068
|
+
setCopyType,
|
|
65069
|
+
developer: showDeveloper = false,
|
|
65070
|
+
header = "Copy as"
|
|
65071
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
65072
|
+
/* @__PURE__ */ jsxRuntime.jsx(MenuHeader, { children: header }),
|
|
65073
|
+
typedEntries(gridCopyOptions).map(([key, { icon, text, developer }]) => {
|
|
65074
|
+
return (!developer || showDeveloper) && /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { onClick: () => onCopy(key), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copyMenuMenuItem", children: [
|
|
65075
|
+
/* @__PURE__ */ jsxRuntime.jsx(lui.LuiIcon, { name: icon, alt: text, size: "md" }),
|
|
65076
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65077
|
+
] }) }, key);
|
|
65078
|
+
}),
|
|
65079
|
+
/* @__PURE__ */ jsxRuntime.jsx(MenuDivider, {}),
|
|
65080
|
+
/* @__PURE__ */ jsxRuntime.jsx(MenuHeader, { children: "Set copy default" }),
|
|
65081
|
+
typedEntries(gridCopyOptions).map(([key, { text, developer }]) => {
|
|
65082
|
+
return !developer && /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { onClick: () => setCopyType(key), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
65083
|
+
"div",
|
|
65084
|
+
{
|
|
65085
|
+
className: clsx("copyMenuMenuItem", copyType === key ? "" : "copyMenuMenuItem__buttonDefault--hidden"),
|
|
65086
|
+
children: [
|
|
65087
|
+
/* @__PURE__ */ jsxRuntime.jsx(lui.LuiIcon, { name: "ic_tick", alt: "Default", size: "sm" }),
|
|
65088
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65089
|
+
]
|
|
65090
|
+
}
|
|
65091
|
+
) }, "default_" + key);
|
|
65092
|
+
})
|
|
65093
|
+
] });
|
|
65050
65094
|
const GridRangeSelectContextMenu = ({
|
|
65051
65095
|
event,
|
|
65052
65096
|
context
|
|
65053
65097
|
}) => {
|
|
65054
65098
|
const developerContextMenu = !!event?.event?.ctrlKey && !!event?.event?.shiftKey;
|
|
65055
|
-
|
|
65056
|
-
const onClick = React14.useCallback(
|
|
65057
|
-
(type) => {
|
|
65058
|
-
onCopy?.(type);
|
|
65059
|
-
},
|
|
65060
|
-
[onCopy]
|
|
65061
|
-
);
|
|
65062
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
65063
|
-
/* @__PURE__ */ jsxRuntime.jsx(MenuHeader, { children: "Copy as" }),
|
|
65064
|
-
typedEntries(gridCopyOptions).map(([key, { icon, text, developer }]) => {
|
|
65065
|
-
return (!developer || developerContextMenu) && /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { onClick: () => void onClick(key), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copyMenuMenuItem", children: [
|
|
65066
|
-
/* @__PURE__ */ jsxRuntime.jsx(lui.LuiIcon, { name: icon, alt: text, size: "md" }),
|
|
65067
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65068
|
-
] }) }, key);
|
|
65069
|
-
}),
|
|
65070
|
-
/* @__PURE__ */ jsxRuntime.jsx(MenuDivider, {}),
|
|
65071
|
-
/* @__PURE__ */ jsxRuntime.jsx(MenuHeader, { children: "Set copy default" }),
|
|
65072
|
-
typedEntries(gridCopyOptions).map(([key, { text, developer }]) => {
|
|
65073
|
-
return !developer && /* @__PURE__ */ jsxRuntime.jsx(
|
|
65074
|
-
MenuItem,
|
|
65075
|
-
{
|
|
65076
|
-
onClick: (e) => {
|
|
65077
|
-
context?.setCopyType(key);
|
|
65078
|
-
e.keepOpen = true;
|
|
65079
|
-
},
|
|
65080
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
65081
|
-
"div",
|
|
65082
|
-
{
|
|
65083
|
-
className: clsx(
|
|
65084
|
-
"copyMenuMenuItem",
|
|
65085
|
-
context?.copyType === key ? "" : "copyMenuMenuItem__buttonDefault--hidden"
|
|
65086
|
-
),
|
|
65087
|
-
children: [
|
|
65088
|
-
/* @__PURE__ */ jsxRuntime.jsx(lui.LuiIcon, { name: "ic_tick", alt: "CSV", size: "sm" }),
|
|
65089
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "copyMenuMenuItem__text", children: text })
|
|
65090
|
-
]
|
|
65091
|
-
}
|
|
65092
|
-
)
|
|
65093
|
-
},
|
|
65094
|
-
"default_" + key
|
|
65095
|
-
);
|
|
65096
|
-
})
|
|
65097
|
-
] });
|
|
65099
|
+
return context ? /* @__PURE__ */ jsxRuntime.jsx(GridCopyOptionsMenuItems, { ...context, developer: developerContextMenu }) : null;
|
|
65098
65100
|
};
|
|
65099
65101
|
|
|
65100
65102
|
const agGridSelectRowColId = "ag-Grid-SelectionColumn";
|
|
65101
65103
|
|
|
65104
|
+
const isCopyableColId = (colId, getColDef) => colId !== "gridCellFiller" && getColDef(colId)?.headerComponentParams?.exportable !== false;
|
|
65105
|
+
const copyGridCells = ({
|
|
65106
|
+
type,
|
|
65107
|
+
selectedColIds,
|
|
65108
|
+
selectedNodes,
|
|
65109
|
+
selectedRowIds,
|
|
65110
|
+
getColDef,
|
|
65111
|
+
getCellValue,
|
|
65112
|
+
showToast
|
|
65113
|
+
}) => {
|
|
65114
|
+
const json = type === "json";
|
|
65115
|
+
const filteredSelectedColIds = selectedColIds.filter(
|
|
65116
|
+
(colId) => colId === agGridSelectRowColId || isCopyableColId(colId, getColDef)
|
|
65117
|
+
);
|
|
65118
|
+
const formatters = lodashEs.compact(
|
|
65119
|
+
filteredSelectedColIds.map((colKey) => {
|
|
65120
|
+
return (rowNode) => {
|
|
65121
|
+
if (colKey === agGridSelectRowColId) {
|
|
65122
|
+
return selectedRowIds.includes(rowNode.data.id);
|
|
65123
|
+
} else {
|
|
65124
|
+
const v = getCellValue({ rowNode, colKey });
|
|
65125
|
+
if (json && v !== void 0) {
|
|
65126
|
+
return v;
|
|
65127
|
+
}
|
|
65128
|
+
const f = getCellValue({ rowNode, colKey, useFormatter: true });
|
|
65129
|
+
return v == f ? v : f;
|
|
65130
|
+
}
|
|
65131
|
+
};
|
|
65132
|
+
})
|
|
65133
|
+
);
|
|
65134
|
+
const headers = filteredSelectedColIds.map((colId) => {
|
|
65135
|
+
if (colId === agGridSelectRowColId) return type === "json" ? "selected" : "Selected";
|
|
65136
|
+
if (json) {
|
|
65137
|
+
return colId;
|
|
65138
|
+
}
|
|
65139
|
+
return getColDef(colId)?.headerName ?? "?";
|
|
65140
|
+
});
|
|
65141
|
+
const maxCellLength = {};
|
|
65142
|
+
headers.forEach((headerName, i) => {
|
|
65143
|
+
const colId = filteredSelectedColIds[i];
|
|
65144
|
+
maxCellLength[colId] = headerName.length;
|
|
65145
|
+
});
|
|
65146
|
+
const rows = [];
|
|
65147
|
+
if (type === "csv" || type === "html") {
|
|
65148
|
+
rows.push(headers);
|
|
65149
|
+
}
|
|
65150
|
+
selectedNodes.forEach((node) => {
|
|
65151
|
+
const row = [];
|
|
65152
|
+
rows.push(row);
|
|
65153
|
+
formatters.forEach((formatter, i) => {
|
|
65154
|
+
const colId = filteredSelectedColIds[i];
|
|
65155
|
+
let value = formatter(node);
|
|
65156
|
+
if (typeof value === "string") {
|
|
65157
|
+
value = value.replaceAll("\xA0", " ");
|
|
65158
|
+
}
|
|
65159
|
+
if (!json) {
|
|
65160
|
+
if (value === "-" || value === "\u2013" || value == null) {
|
|
65161
|
+
value = "";
|
|
65162
|
+
}
|
|
65163
|
+
value = String(value);
|
|
65164
|
+
if (value === "-" || value === "\u2013") {
|
|
65165
|
+
value = "";
|
|
65166
|
+
}
|
|
65167
|
+
maxCellLength[colId] = Math.max(maxCellLength[colId], value.length);
|
|
65168
|
+
}
|
|
65169
|
+
switch (type) {
|
|
65170
|
+
case "json":
|
|
65171
|
+
value = value === "undefined" || value !== null && typeof value === "object" || typeof value === "string" ? JSON.stringify(value) : value;
|
|
65172
|
+
break;
|
|
65173
|
+
case "markdown":
|
|
65174
|
+
value = encodeMarkdownValue(value);
|
|
65175
|
+
break;
|
|
65176
|
+
case "csv":
|
|
65177
|
+
value = encodeCSVValue(value);
|
|
65178
|
+
break;
|
|
65179
|
+
}
|
|
65180
|
+
row.push(String(value));
|
|
65181
|
+
});
|
|
65182
|
+
});
|
|
65183
|
+
let result = "";
|
|
65184
|
+
let html = `<table style="
|
|
65185
|
+
font-family: 'Open Sans', system-ui, sans-serif;
|
|
65186
|
+
font-size: 10px;
|
|
65187
|
+
line-height: 10px;
|
|
65188
|
+
border: 1px solid #d1d9e0;
|
|
65189
|
+
border-collapse: collapse;
|
|
65190
|
+
">`;
|
|
65191
|
+
if (json) {
|
|
65192
|
+
result += "[\n";
|
|
65193
|
+
}
|
|
65194
|
+
rows.forEach((row, rowIndex) => {
|
|
65195
|
+
if (json) {
|
|
65196
|
+
result += " { ";
|
|
65197
|
+
}
|
|
65198
|
+
if (rowIndex == 1) {
|
|
65199
|
+
html += '<tbody style="font-weight: 400;">';
|
|
65200
|
+
}
|
|
65201
|
+
if (rowIndex == 0) {
|
|
65202
|
+
html += '<thead style="font-weight: 600;">';
|
|
65203
|
+
}
|
|
65204
|
+
if (rowIndex === 0 || (rowIndex & 1) === 1) {
|
|
65205
|
+
html += "<tr>";
|
|
65206
|
+
} else {
|
|
65207
|
+
html += '<tr style="background-color: #f6f8fa;">';
|
|
65208
|
+
}
|
|
65209
|
+
if (rowIndex === 1 && type === "html") {
|
|
65210
|
+
Object.values(maxCellLength).forEach((maxLength) => {
|
|
65211
|
+
result += "|" + "-".repeat(maxLength + 2);
|
|
65212
|
+
});
|
|
65213
|
+
result += "|\n";
|
|
65214
|
+
}
|
|
65215
|
+
row.forEach((cell, i) => {
|
|
65216
|
+
switch (type) {
|
|
65217
|
+
case "csv":
|
|
65218
|
+
if (i !== 0) {
|
|
65219
|
+
result += ", ";
|
|
65220
|
+
}
|
|
65221
|
+
result += cell;
|
|
65222
|
+
break;
|
|
65223
|
+
case "html":
|
|
65224
|
+
if (i === 0) {
|
|
65225
|
+
result += "|";
|
|
65226
|
+
}
|
|
65227
|
+
const colId = filteredSelectedColIds[i];
|
|
65228
|
+
result += " " + cell.padEnd(maxCellLength[colId], " ") + " ";
|
|
65229
|
+
result += "|";
|
|
65230
|
+
html += rowIndex === 0 ? '<th style="border: 1px solid #d1d9e0; padding:6px 13px; text-align: left;">' : '<td style="border: 1px solid #d1d9e0; padding:6px 13px;">';
|
|
65231
|
+
html += cell;
|
|
65232
|
+
html += rowIndex === 0 ? "</th>" : "</td>";
|
|
65233
|
+
break;
|
|
65234
|
+
case "json":
|
|
65235
|
+
if (i !== 0) {
|
|
65236
|
+
result += ", ";
|
|
65237
|
+
}
|
|
65238
|
+
result += JSON.stringify(headers[i]) + ": " + cell;
|
|
65239
|
+
break;
|
|
65240
|
+
}
|
|
65241
|
+
});
|
|
65242
|
+
html += "</tr>";
|
|
65243
|
+
if (rowIndex == 0) {
|
|
65244
|
+
html += "</thead>";
|
|
65245
|
+
}
|
|
65246
|
+
if (rowIndex == rows.length - 1) {
|
|
65247
|
+
html += "</tbody>";
|
|
65248
|
+
}
|
|
65249
|
+
if (json) {
|
|
65250
|
+
result += rowIndex < rows.length - 1 ? " }," : " }";
|
|
65251
|
+
}
|
|
65252
|
+
result += "\n";
|
|
65253
|
+
});
|
|
65254
|
+
if (json) {
|
|
65255
|
+
result += "]\n";
|
|
65256
|
+
}
|
|
65257
|
+
html += "</table>";
|
|
65258
|
+
showToast({
|
|
65259
|
+
message: `${gridCopyOptions[type].text} copied`,
|
|
65260
|
+
messageType: "toast",
|
|
65261
|
+
messageLevel: "info"
|
|
65262
|
+
});
|
|
65263
|
+
if (type === "html") {
|
|
65264
|
+
const clipboardItem = new ClipboardItem({
|
|
65265
|
+
"text/html": new Blob([html], { type: "text/html" }),
|
|
65266
|
+
"text/plain": new Blob([result], { type: "text/plain" })
|
|
65267
|
+
// fallback
|
|
65268
|
+
});
|
|
65269
|
+
void navigator.clipboard.write([clipboardItem]).catch((err) => console.error("Failed to copy: ", err));
|
|
65270
|
+
} else {
|
|
65271
|
+
void navigator.clipboard.writeText(result).catch((err) => console.error("Failed to copy: ", err));
|
|
65272
|
+
}
|
|
65273
|
+
};
|
|
65274
|
+
const encodeMarkdownValue = (value) => {
|
|
65275
|
+
return value.replaceAll("|", "\\|");
|
|
65276
|
+
};
|
|
65277
|
+
const encodeCSVValue = (value) => {
|
|
65278
|
+
let str = String(value);
|
|
65279
|
+
if (/[",\n]/.test(str)) {
|
|
65280
|
+
str = '"' + str.replace(/"/g, '""') + '"';
|
|
65281
|
+
}
|
|
65282
|
+
return str;
|
|
65283
|
+
};
|
|
65284
|
+
|
|
65285
|
+
let lastActiveGridElement = null;
|
|
65286
|
+
const isEditableElement = (el) => el instanceof Element && (!!el.closest("input, textarea, select") || el.isContentEditable);
|
|
65102
65287
|
const useGridCopy = ({
|
|
65288
|
+
gridDivRef,
|
|
65289
|
+
gridDocument,
|
|
65103
65290
|
ranges,
|
|
65104
65291
|
rangeStartRef,
|
|
65105
65292
|
rangeEndRef,
|
|
@@ -65107,193 +65294,41 @@ const useGridCopy = ({
|
|
|
65107
65294
|
cellContextMenu
|
|
65108
65295
|
}) => {
|
|
65109
65296
|
const showToast = lui.useShowLUIMessage();
|
|
65110
|
-
const { getSelectedRowIds } = useGridContext();
|
|
65111
|
-
const { getColDef, getCellValue } = useGridContext();
|
|
65297
|
+
const { getColDef, getCellValue, getSelectedRowIds, setRangeCopy } = useGridContext();
|
|
65112
65298
|
const { copyType, setCopyType } = useGridCopySettings();
|
|
65299
|
+
const hasRange = React14.useCallback(
|
|
65300
|
+
() => rangeStartRef.current !== null && rangeEndRef.current !== null && hasSelectedMoreThanOneCellRef.current,
|
|
65301
|
+
[rangeStartRef, rangeEndRef, hasSelectedMoreThanOneCellRef]
|
|
65302
|
+
);
|
|
65113
65303
|
const onCopy = React14.useCallback(
|
|
65114
65304
|
(type = copyType) => {
|
|
65115
65305
|
const rangeStart = rangeStartRef.current;
|
|
65116
65306
|
const rangeEnd = rangeEndRef.current;
|
|
65117
|
-
if (rangeStart === null || rangeEnd === null || !
|
|
65307
|
+
if (rangeStart === null || rangeEnd === null || !hasRange()) {
|
|
65118
65308
|
return;
|
|
65119
65309
|
}
|
|
65120
65310
|
if (rangeStart.rowId === rangeEnd.rowId && rangeStart.colId === rangeEnd.colId) {
|
|
65121
65311
|
type = "html";
|
|
65122
65312
|
}
|
|
65123
|
-
const json = type === "json";
|
|
65124
65313
|
const { selectedColIds, selectedNodes } = ranges();
|
|
65125
|
-
|
|
65126
|
-
|
|
65127
|
-
|
|
65128
|
-
|
|
65129
|
-
|
|
65130
|
-
|
|
65131
|
-
|
|
65132
|
-
|
|
65133
|
-
return selectedRowIds.includes(rowNode.data.id);
|
|
65134
|
-
} else {
|
|
65135
|
-
const v = getCellValue({ rowNode, colKey });
|
|
65136
|
-
if (json && v !== void 0) {
|
|
65137
|
-
return v;
|
|
65138
|
-
}
|
|
65139
|
-
const f = getCellValue({ rowNode, colKey, useFormatter: true });
|
|
65140
|
-
return v == f ? v : f;
|
|
65141
|
-
}
|
|
65142
|
-
};
|
|
65143
|
-
})
|
|
65144
|
-
);
|
|
65145
|
-
const headers = filteredSelectedColIds.map((colId) => {
|
|
65146
|
-
if (colId === agGridSelectRowColId) return type === "json" ? "selected" : "Selected";
|
|
65147
|
-
if (json) {
|
|
65148
|
-
return colId;
|
|
65149
|
-
}
|
|
65150
|
-
return getColDef(colId)?.headerName ?? "?";
|
|
65151
|
-
});
|
|
65152
|
-
const maxCellLength = {};
|
|
65153
|
-
headers.forEach((headerName, i) => {
|
|
65154
|
-
const colId = filteredSelectedColIds[i];
|
|
65155
|
-
maxCellLength[colId] = headerName.length;
|
|
65156
|
-
});
|
|
65157
|
-
const rows = [];
|
|
65158
|
-
if (type === "csv" || type === "html") {
|
|
65159
|
-
rows.push(headers);
|
|
65160
|
-
}
|
|
65161
|
-
selectedNodes.forEach((node) => {
|
|
65162
|
-
const row = [];
|
|
65163
|
-
rows.push(row);
|
|
65164
|
-
formatters.forEach((formatter, i) => {
|
|
65165
|
-
const colId = filteredSelectedColIds[i];
|
|
65166
|
-
let value = formatter(node);
|
|
65167
|
-
if (typeof value === "string") {
|
|
65168
|
-
value = value.replaceAll("\xA0", " ");
|
|
65169
|
-
}
|
|
65170
|
-
if (!json) {
|
|
65171
|
-
if (value === "-" || value === "\u2013" || value == null) {
|
|
65172
|
-
value = "";
|
|
65173
|
-
}
|
|
65174
|
-
value = String(value);
|
|
65175
|
-
if (value === "-" || value === "\u2013") {
|
|
65176
|
-
value = "";
|
|
65177
|
-
}
|
|
65178
|
-
maxCellLength[colId] = Math.max(maxCellLength[colId], value.length);
|
|
65179
|
-
}
|
|
65180
|
-
switch (type) {
|
|
65181
|
-
case "json":
|
|
65182
|
-
value = value === "undefined" || value !== null && typeof value === "object" || typeof value === "string" ? JSON.stringify(value) : value;
|
|
65183
|
-
break;
|
|
65184
|
-
case "markdown":
|
|
65185
|
-
value = encodeMarkdownValue(value);
|
|
65186
|
-
break;
|
|
65187
|
-
case "csv":
|
|
65188
|
-
value = encodeCSVValue(value);
|
|
65189
|
-
break;
|
|
65190
|
-
}
|
|
65191
|
-
row.push(String(value));
|
|
65192
|
-
});
|
|
65193
|
-
});
|
|
65194
|
-
let result = "";
|
|
65195
|
-
let html = `<table style="
|
|
65196
|
-
font-family: 'Open Sans', system-ui, sans-serif;
|
|
65197
|
-
font-size: 10px;
|
|
65198
|
-
line-height: 10px;
|
|
65199
|
-
border: 1px solid #d1d9e0;
|
|
65200
|
-
border-collapse: collapse;
|
|
65201
|
-
">`;
|
|
65202
|
-
if (json) {
|
|
65203
|
-
result += "[\n";
|
|
65204
|
-
}
|
|
65205
|
-
rows.forEach((row, rowIndex) => {
|
|
65206
|
-
if (json) {
|
|
65207
|
-
result += " { ";
|
|
65208
|
-
}
|
|
65209
|
-
if (rowIndex == 1) {
|
|
65210
|
-
html += '<tbody style="font-weight: 400;">';
|
|
65211
|
-
}
|
|
65212
|
-
if (rowIndex == 0) {
|
|
65213
|
-
html += '<thead style="font-weight: 600;">';
|
|
65214
|
-
}
|
|
65215
|
-
if (rowIndex === 0 || (rowIndex & 1) === 1) {
|
|
65216
|
-
html += "<tr>";
|
|
65217
|
-
} else {
|
|
65218
|
-
html += '<tr style="background-color: #f6f8fa;">';
|
|
65219
|
-
}
|
|
65220
|
-
if (rowIndex === 1 && type === "html") {
|
|
65221
|
-
Object.values(maxCellLength).forEach((maxLength) => {
|
|
65222
|
-
result += "|" + "-".repeat(maxLength + 2);
|
|
65223
|
-
});
|
|
65224
|
-
result += "|\n";
|
|
65225
|
-
}
|
|
65226
|
-
row.forEach((cell, i) => {
|
|
65227
|
-
switch (type) {
|
|
65228
|
-
case "csv":
|
|
65229
|
-
if (i !== 0) {
|
|
65230
|
-
result += ", ";
|
|
65231
|
-
}
|
|
65232
|
-
result += cell;
|
|
65233
|
-
break;
|
|
65234
|
-
case "html":
|
|
65235
|
-
if (i === 0) {
|
|
65236
|
-
result += "|";
|
|
65237
|
-
}
|
|
65238
|
-
const colId = filteredSelectedColIds[i];
|
|
65239
|
-
result += " " + cell.padEnd(maxCellLength[colId], " ") + " ";
|
|
65240
|
-
result += "|";
|
|
65241
|
-
html += rowIndex === 0 ? '<th style="border: 1px solid #d1d9e0; padding:6px 13px; text-align: left;">' : '<td style="border: 1px solid #d1d9e0; padding:6px 13px;">';
|
|
65242
|
-
html += cell;
|
|
65243
|
-
html += rowIndex === 0 ? "</th>" : "</td>";
|
|
65244
|
-
break;
|
|
65245
|
-
case "json":
|
|
65246
|
-
if (i !== 0) {
|
|
65247
|
-
result += ", ";
|
|
65248
|
-
}
|
|
65249
|
-
result += JSON.stringify(headers[i]) + ": " + cell;
|
|
65250
|
-
break;
|
|
65251
|
-
}
|
|
65252
|
-
});
|
|
65253
|
-
html += "</tr>";
|
|
65254
|
-
if (rowIndex == 0) {
|
|
65255
|
-
html += "</thead>";
|
|
65256
|
-
}
|
|
65257
|
-
if (rowIndex == rows.length - 1) {
|
|
65258
|
-
html += "</tbody>";
|
|
65259
|
-
}
|
|
65260
|
-
if (json) {
|
|
65261
|
-
result += " }";
|
|
65262
|
-
}
|
|
65263
|
-
result += "\n";
|
|
65264
|
-
});
|
|
65265
|
-
if (json) {
|
|
65266
|
-
result += "]\n";
|
|
65267
|
-
}
|
|
65268
|
-
html += "</table>";
|
|
65269
|
-
showToast({
|
|
65270
|
-
message: `${gridCopyOptions[type].text} copied`,
|
|
65271
|
-
messageType: "toast",
|
|
65272
|
-
messageLevel: "info"
|
|
65314
|
+
copyGridCells({
|
|
65315
|
+
type,
|
|
65316
|
+
selectedColIds,
|
|
65317
|
+
selectedNodes,
|
|
65318
|
+
selectedRowIds: getSelectedRowIds(),
|
|
65319
|
+
getColDef,
|
|
65320
|
+
getCellValue,
|
|
65321
|
+
showToast
|
|
65273
65322
|
});
|
|
65274
|
-
if (type === "html") {
|
|
65275
|
-
const clipboardItem = new ClipboardItem({
|
|
65276
|
-
"text/html": new Blob([html], { type: "text/html" }),
|
|
65277
|
-
"text/plain": new Blob([result], { type: "text/plain" })
|
|
65278
|
-
// fallback
|
|
65279
|
-
});
|
|
65280
|
-
void navigator.clipboard.write([clipboardItem]).catch((err) => console.error("Failed to copy: ", err));
|
|
65281
|
-
} else {
|
|
65282
|
-
void navigator.clipboard.writeText(result).catch((err) => console.error("Failed to copy: ", err));
|
|
65283
|
-
}
|
|
65284
65323
|
},
|
|
65285
|
-
[
|
|
65286
|
-
getCellValue,
|
|
65287
|
-
ranges,
|
|
65288
|
-
copyType,
|
|
65289
|
-
rangeStartRef,
|
|
65290
|
-
hasSelectedMoreThanOneCellRef,
|
|
65291
|
-
rangeEndRef,
|
|
65292
|
-
showToast,
|
|
65293
|
-
getColDef,
|
|
65294
|
-
getSelectedRowIds
|
|
65295
|
-
]
|
|
65324
|
+
[getCellValue, ranges, copyType, rangeStartRef, hasRange, rangeEndRef, showToast, getColDef, getSelectedRowIds]
|
|
65296
65325
|
);
|
|
65326
|
+
const onCopyRef = React14.useRef(onCopy);
|
|
65327
|
+
onCopyRef.current = onCopy;
|
|
65328
|
+
React14.useEffect(() => {
|
|
65329
|
+
setRangeCopy({ hasRange, getRange: ranges, copy: (type) => onCopyRef.current(type) });
|
|
65330
|
+
return () => setRangeCopy(void 0);
|
|
65331
|
+
}, [hasRange, ranges, setRangeCopy]);
|
|
65297
65332
|
const onCopyEvent = React14.useCallback(
|
|
65298
65333
|
(e) => {
|
|
65299
65334
|
const rangeStart = rangeStartRef.current;
|
|
@@ -65306,6 +65341,31 @@ const useGridCopy = ({
|
|
|
65306
65341
|
},
|
|
65307
65342
|
[onCopy, rangeStartRef, rangeEndRef, hasSelectedMoreThanOneCellRef]
|
|
65308
65343
|
);
|
|
65344
|
+
React14.useEffect(() => {
|
|
65345
|
+
const gridDiv = gridDivRef.current;
|
|
65346
|
+
const doc = gridDocument ?? gridDiv?.ownerDocument;
|
|
65347
|
+
if (!gridDiv || !doc) return;
|
|
65348
|
+
const setActive = () => {
|
|
65349
|
+
lastActiveGridElement = gridDiv;
|
|
65350
|
+
};
|
|
65351
|
+
const onDocumentCopy = (e) => {
|
|
65352
|
+
if (gridDiv.contains(e.target) || // handled by onCopyEvent
|
|
65353
|
+
lastActiveGridElement !== gridDiv || !hasRange() || isEditableElement(e.target) || !doc.getSelection()?.isCollapsed) {
|
|
65354
|
+
return;
|
|
65355
|
+
}
|
|
65356
|
+
e.preventDefault();
|
|
65357
|
+
onCopyRef.current();
|
|
65358
|
+
};
|
|
65359
|
+
gridDiv.addEventListener("mousedown", setActive, true);
|
|
65360
|
+
gridDiv.addEventListener("focusin", setActive, true);
|
|
65361
|
+
doc.addEventListener("copy", onDocumentCopy);
|
|
65362
|
+
return () => {
|
|
65363
|
+
gridDiv.removeEventListener("mousedown", setActive, true);
|
|
65364
|
+
gridDiv.removeEventListener("focusin", setActive, true);
|
|
65365
|
+
doc.removeEventListener("copy", onDocumentCopy);
|
|
65366
|
+
if (lastActiveGridElement === gridDiv) lastActiveGridElement = null;
|
|
65367
|
+
};
|
|
65368
|
+
}, [gridDivRef, gridDocument, hasRange]);
|
|
65309
65369
|
const { cellContextMenu: rangeSelectContextMenu, contextMenuComponent: rangeSelectContextMenuComponent } = useGridContextMenu({
|
|
65310
65370
|
contextMenu: GridRangeSelectContextMenu,
|
|
65311
65371
|
context: { onCopy, copyType, setCopyType }
|
|
@@ -65322,16 +65382,6 @@ const useGridCopy = ({
|
|
|
65322
65382
|
rangeSelectContextMenuComponent
|
|
65323
65383
|
};
|
|
65324
65384
|
};
|
|
65325
|
-
const encodeMarkdownValue = (value) => {
|
|
65326
|
-
return value.replaceAll("|", "\\|");
|
|
65327
|
-
};
|
|
65328
|
-
const encodeCSVValue = (value) => {
|
|
65329
|
-
let str = String(value);
|
|
65330
|
-
if (/[",\n]/.test(str)) {
|
|
65331
|
-
str = '"' + str.replace(/"/g, '""') + '"';
|
|
65332
|
-
}
|
|
65333
|
-
return str;
|
|
65334
|
-
};
|
|
65335
65385
|
|
|
65336
65386
|
const useGridRangeSelection = ({
|
|
65337
65387
|
enableRangeSelection,
|
|
@@ -65753,6 +65803,7 @@ const Grid = ({
|
|
|
65753
65803
|
// ─── Selection ────────────────────────────────
|
|
65754
65804
|
autoSelectFirstRow,
|
|
65755
65805
|
enableRangeSelection = false,
|
|
65806
|
+
enableCopy = false,
|
|
65756
65807
|
externalSelectedIds,
|
|
65757
65808
|
externalSelectedItems,
|
|
65758
65809
|
selectColumnPinned = "left",
|
|
@@ -65783,6 +65834,7 @@ const Grid = ({
|
|
|
65783
65834
|
setApis,
|
|
65784
65835
|
setExternallySelectedItemsAreInSync,
|
|
65785
65836
|
setOnBulkEditingComplete,
|
|
65837
|
+
setCopyEnabled,
|
|
65786
65838
|
gridReady,
|
|
65787
65839
|
gridRenderState,
|
|
65788
65840
|
externallySelectedItemsAreInSync,
|
|
@@ -65877,6 +65929,7 @@ const Grid = ({
|
|
|
65877
65929
|
}
|
|
65878
65930
|
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
65879
65931
|
const lastOwnerDocumentRef = React14.useRef(void 0);
|
|
65932
|
+
const [gridDocument, setGridDocument] = React14.useState();
|
|
65880
65933
|
const wasVisibleRef = React14.useRef(false);
|
|
65881
65934
|
useInterval(() => {
|
|
65882
65935
|
const visible = !!gridDivRef.current?.checkVisibility?.();
|
|
@@ -65894,6 +65947,7 @@ const Grid = ({
|
|
|
65894
65947
|
const currentDocument = gridDivRef.current?.ownerDocument;
|
|
65895
65948
|
if (currentDocument !== lastOwnerDocumentRef.current) {
|
|
65896
65949
|
lastOwnerDocumentRef.current = currentDocument;
|
|
65950
|
+
setGridDocument(currentDocument);
|
|
65897
65951
|
if (currentDocument) {
|
|
65898
65952
|
needsAutoSize.current = true;
|
|
65899
65953
|
}
|
|
@@ -66145,12 +66199,18 @@ const Grid = ({
|
|
|
66145
66199
|
rangeSortedNodesRef
|
|
66146
66200
|
});
|
|
66147
66201
|
const { onCopyEvent, rangeSelectInterceptContextMenu, rangeSelectContextMenuComponent } = useGridCopy({
|
|
66202
|
+
gridDivRef,
|
|
66203
|
+
gridDocument,
|
|
66148
66204
|
ranges,
|
|
66149
66205
|
rangeStartRef,
|
|
66150
66206
|
rangeEndRef,
|
|
66151
66207
|
hasSelectedMoreThanOneCellRef,
|
|
66152
66208
|
cellContextMenu
|
|
66153
66209
|
});
|
|
66210
|
+
React14.useEffect(() => {
|
|
66211
|
+
setCopyEnabled(enableCopy);
|
|
66212
|
+
return () => setCopyEnabled(false);
|
|
66213
|
+
}, [enableCopy, setCopyEnabled]);
|
|
66154
66214
|
const userSizedColIds = React14.useRef(/* @__PURE__ */ new Map());
|
|
66155
66215
|
const { saveColumnState: saveColumnStateToStorage } = useGridColumnStateStorage({
|
|
66156
66216
|
enabled: saveColumnState,
|
|
@@ -66658,15 +66718,16 @@ const GridPopoverContextProvider = (props2) => {
|
|
|
66658
66718
|
);
|
|
66659
66719
|
const field = props.colDef?.field ?? "";
|
|
66660
66720
|
const colId = props.colDef?.colId ?? field ?? "";
|
|
66721
|
+
const updatingKey = props.colDef?.field ?? props.colDef?.colId ?? "";
|
|
66661
66722
|
const updateValue = React14.useCallback(
|
|
66662
66723
|
async (saveFn, tabDirection) => {
|
|
66663
66724
|
if (hasSaved.current) {
|
|
66664
66725
|
return true;
|
|
66665
66726
|
}
|
|
66666
66727
|
hasSaved.current = true;
|
|
66667
|
-
return saving ? false : await updatingCells({ selectedRows, field }, saveFn, setSaving, tabDirection);
|
|
66728
|
+
return saving ? false : await updatingCells({ selectedRows, field: updatingKey }, saveFn, setSaving, tabDirection);
|
|
66668
66729
|
},
|
|
66669
|
-
[
|
|
66730
|
+
[saving, selectedRows, updatingCells, updatingKey]
|
|
66670
66731
|
);
|
|
66671
66732
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
66672
66733
|
GridPopoverContext.Provider,
|
|
@@ -67183,6 +67244,72 @@ const GridFilterColumnsToggle = ({ saveState = true }) => {
|
|
|
67183
67244
|
);
|
|
67184
67245
|
};
|
|
67185
67246
|
|
|
67247
|
+
const copyScopeHeader = {
|
|
67248
|
+
range: "Copy range",
|
|
67249
|
+
selection: "Copy selection",
|
|
67250
|
+
all: "Copy all"
|
|
67251
|
+
};
|
|
67252
|
+
const copyTypeTooltipText = (copyType) => copyType === "html" ? "text / HTML" : gridCopyOptions[copyType].text;
|
|
67253
|
+
const GridFilterCopyMenuItems = ({ developer }) => {
|
|
67254
|
+
const { copyToClipboard, getCopyScope } = useGridContext();
|
|
67255
|
+
const { copyType, setCopyType } = useGridCopySettings();
|
|
67256
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
67257
|
+
GridCopyOptionsMenuItems,
|
|
67258
|
+
{
|
|
67259
|
+
header: copyScopeHeader[getCopyScope()],
|
|
67260
|
+
onCopy: copyToClipboard,
|
|
67261
|
+
copyType,
|
|
67262
|
+
setCopyType,
|
|
67263
|
+
developer
|
|
67264
|
+
}
|
|
67265
|
+
);
|
|
67266
|
+
};
|
|
67267
|
+
const GridFilterCopyButton = () => {
|
|
67268
|
+
const { copyEnabled, copyToClipboard, getCopyScope } = useGridContext();
|
|
67269
|
+
const { copyType } = useGridCopySettings();
|
|
67270
|
+
const [copyScope, setCopyScope] = React14.useState("all");
|
|
67271
|
+
const updateCopyScope = React14.useCallback(() => setCopyScope(getCopyScope()), [getCopyScope]);
|
|
67272
|
+
const [developerMenu, setDeveloperMenu] = React14.useState(false);
|
|
67273
|
+
if (!copyEnabled) return null;
|
|
67274
|
+
const copyTitle = `${copyScopeHeader[copyScope]} as ${copyTypeTooltipText(copyType)}`;
|
|
67275
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "lui-split-button GridFilterCopyButton", onMouseEnter: updateCopyScope, onFocus: updateCopyScope, children: [
|
|
67276
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
67277
|
+
lui.LuiButton,
|
|
67278
|
+
{
|
|
67279
|
+
type: "button",
|
|
67280
|
+
level: "secondary",
|
|
67281
|
+
className: "lui-button-icon-only lui-split-button-primary-btn GridFilterCopyButton-copy",
|
|
67282
|
+
title: copyTitle,
|
|
67283
|
+
buttonProps: { "aria-label": copyTitle },
|
|
67284
|
+
onClick: () => copyToClipboard(copyType),
|
|
67285
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lui.LuiIcon, { name: "ic_copy", alt: copyTitle, size: "md" })
|
|
67286
|
+
}
|
|
67287
|
+
),
|
|
67288
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
67289
|
+
Menu,
|
|
67290
|
+
{
|
|
67291
|
+
menuButton: /* @__PURE__ */ jsxRuntime.jsx(
|
|
67292
|
+
"button",
|
|
67293
|
+
{
|
|
67294
|
+
type: "button",
|
|
67295
|
+
className: "popup-toggle-button popup-toggle-button-secondary GridFilterCopyButton-caret",
|
|
67296
|
+
title: "Copy options",
|
|
67297
|
+
"aria-label": "Copy options",
|
|
67298
|
+
onClick: (e) => setDeveloperMenu(e.ctrlKey && e.shiftKey),
|
|
67299
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lui.LuiIcon, { name: "ic_expand_more", alt: "Copy options", size: "md" })
|
|
67300
|
+
}
|
|
67301
|
+
),
|
|
67302
|
+
menuClassName: "step-ag-grid-react-menu",
|
|
67303
|
+
className: "GridContextMenu",
|
|
67304
|
+
align: "end",
|
|
67305
|
+
portal: true,
|
|
67306
|
+
unmountOnClose: true,
|
|
67307
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(GridFilterCopyMenuItems, { developer: developerMenu })
|
|
67308
|
+
}
|
|
67309
|
+
)
|
|
67310
|
+
] });
|
|
67311
|
+
};
|
|
67312
|
+
|
|
67186
67313
|
const useTimeoutHook = () => {
|
|
67187
67314
|
const timeout = React14.useRef(void 0);
|
|
67188
67315
|
const clearTimeouts = () => {
|
|
@@ -69326,10 +69453,12 @@ const colStateFlexed = (colState) => !!colState.flex;
|
|
|
69326
69453
|
const colStateNotFlexed = (colState) => !colState.flex;
|
|
69327
69454
|
const GridContextProvider = (props) => {
|
|
69328
69455
|
const { modifyUpdating, anyUpdating } = React14.useContext(GridUpdatingContext);
|
|
69456
|
+
const showToast = lui.useShowLUIMessage();
|
|
69329
69457
|
const [gridApi, setGridApi] = React14.useState();
|
|
69330
69458
|
const [gridReady, setGridReady] = React14.useState(false);
|
|
69331
69459
|
const [quickFilter, _setQuickFilter] = React14.useState("");
|
|
69332
69460
|
const [invisibleColumnIds, _setInvisibleColumnIds] = React14.useState();
|
|
69461
|
+
const [copyEnabled, setCopyEnabled] = React14.useState(false);
|
|
69333
69462
|
const testId = React14.useRef(void 0);
|
|
69334
69463
|
const hasExternallySelectedItemsRef = React14.useRef(false);
|
|
69335
69464
|
const enableMultilineBulkEditRef = React14.useRef(false);
|
|
@@ -69958,6 +70087,70 @@ const GridContextProvider = (props) => {
|
|
|
69958
70087
|
},
|
|
69959
70088
|
[gridApi]
|
|
69960
70089
|
);
|
|
70090
|
+
const rangeCopyRef = React14.useRef(void 0);
|
|
70091
|
+
const setRangeCopy = React14.useCallback((rangeCopy) => {
|
|
70092
|
+
rangeCopyRef.current = rangeCopy;
|
|
70093
|
+
}, []);
|
|
70094
|
+
const getCopyRows = React14.useCallback(() => {
|
|
70095
|
+
const nodes = [];
|
|
70096
|
+
if (gridApi && !gridApi.isDestroyed()) {
|
|
70097
|
+
gridApi.forEachNodeAfterFilterAndSort((node) => {
|
|
70098
|
+
if (node.data && !node.group) nodes.push(node);
|
|
70099
|
+
});
|
|
70100
|
+
}
|
|
70101
|
+
const selectedNodes = nodes.filter((node) => node.isSelected());
|
|
70102
|
+
return lodashEs.isEmpty(selectedNodes) ? { scope: "all", nodes } : { scope: "selection", nodes: selectedNodes };
|
|
70103
|
+
}, [gridApi]);
|
|
70104
|
+
const getDisplayedCopyColIds = React14.useCallback(
|
|
70105
|
+
() => gridApi && !gridApi.isDestroyed() ? gridApi.getAllDisplayedColumns().map((col) => col.getColId()).filter((colId) => colId !== agGridSelectRowColId) : [],
|
|
70106
|
+
[gridApi]
|
|
70107
|
+
);
|
|
70108
|
+
const getCopyTarget = React14.useCallback(() => {
|
|
70109
|
+
const rangeCopy = rangeCopyRef.current;
|
|
70110
|
+
const { selectedColIds, selectedNodes } = rangeCopy?.hasRange() ? rangeCopy.getRange() : { selectedColIds: getDisplayedCopyColIds(), selectedNodes: getCopyRows().nodes };
|
|
70111
|
+
return {
|
|
70112
|
+
colIds: selectedColIds.filter((colId) => colId !== agGridSelectRowColId && isCopyableColId(colId, getColDef)),
|
|
70113
|
+
nodes: selectedNodes
|
|
70114
|
+
};
|
|
70115
|
+
}, [getColDef, getCopyRows, getDisplayedCopyColIds]);
|
|
70116
|
+
const getSelectedDataForCopy = React14.useCallback(() => {
|
|
70117
|
+
const { colIds, nodes } = getCopyTarget();
|
|
70118
|
+
const fields = lodashEs.compact(colIds.map((colId) => getColDef(colId)?.field));
|
|
70119
|
+
return nodes.map((node) => {
|
|
70120
|
+
const data = {};
|
|
70121
|
+
fields.forEach((field) => lodashEs.set(data, field, lodashEs.get(node.data, field)));
|
|
70122
|
+
return data;
|
|
70123
|
+
});
|
|
70124
|
+
}, [getColDef, getCopyTarget]);
|
|
70125
|
+
const getCopyData = React14.useCallback(() => {
|
|
70126
|
+
const { colIds, nodes } = getCopyTarget();
|
|
70127
|
+
return nodes.map(
|
|
70128
|
+
(rowNode) => Object.fromEntries(colIds.map((colKey) => [colKey, gridApi?.getCellValue({ rowNode, colKey })]))
|
|
70129
|
+
);
|
|
70130
|
+
}, [getCopyTarget, gridApi]);
|
|
70131
|
+
const getCopyScope = React14.useCallback(
|
|
70132
|
+
() => rangeCopyRef.current?.hasRange() ? "range" : getCopyRows().scope,
|
|
70133
|
+
[getCopyRows]
|
|
70134
|
+
);
|
|
70135
|
+
const copyToClipboard = React14.useCallback(
|
|
70136
|
+
(type = getDefaultCopyType()) => {
|
|
70137
|
+
if (rangeCopyRef.current?.hasRange()) {
|
|
70138
|
+
rangeCopyRef.current.copy(type);
|
|
70139
|
+
return;
|
|
70140
|
+
}
|
|
70141
|
+
if (!gridApi || gridApi.isDestroyed()) return;
|
|
70142
|
+
copyGridCells({
|
|
70143
|
+
type,
|
|
70144
|
+
selectedColIds: getDisplayedCopyColIds(),
|
|
70145
|
+
selectedNodes: getCopyRows().nodes,
|
|
70146
|
+
selectedRowIds: getSelectedRowIds(),
|
|
70147
|
+
getColDef,
|
|
70148
|
+
getCellValue,
|
|
70149
|
+
showToast
|
|
70150
|
+
});
|
|
70151
|
+
},
|
|
70152
|
+
[getCellValue, getColDef, getCopyRows, getDisplayedCopyColIds, getSelectedRowIds, gridApi, showToast]
|
|
70153
|
+
);
|
|
69961
70154
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
69962
70155
|
GridContext.Provider,
|
|
69963
70156
|
{
|
|
@@ -70002,6 +70195,13 @@ const GridContextProvider = (props) => {
|
|
|
70002
70195
|
isExternalFilterPresent,
|
|
70003
70196
|
doesExternalFilterPass,
|
|
70004
70197
|
downloadCsv,
|
|
70198
|
+
copyToClipboard,
|
|
70199
|
+
getCopyScope,
|
|
70200
|
+
getSelectedDataForCopy,
|
|
70201
|
+
getCopyData,
|
|
70202
|
+
setRangeCopy,
|
|
70203
|
+
copyEnabled,
|
|
70204
|
+
setCopyEnabled,
|
|
70005
70205
|
onBulkEditingComplete,
|
|
70006
70206
|
setOnBulkEditingComplete,
|
|
70007
70207
|
showNoRowsOverlay
|
|
@@ -70240,6 +70440,7 @@ exports.GridEditBoolean = GridEditBoolean;
|
|
|
70240
70440
|
exports.GridFilterButtons = GridFilterButtons;
|
|
70241
70441
|
exports.GridFilterColumnsMultiSelect = GridFilterColumnsMultiSelect;
|
|
70242
70442
|
exports.GridFilterColumnsToggle = GridFilterColumnsToggle;
|
|
70443
|
+
exports.GridFilterCopyButton = GridFilterCopyButton;
|
|
70243
70444
|
exports.GridFilterDownloadCsvButton = GridFilterDownloadCsvButton;
|
|
70244
70445
|
exports.GridFilterHeaderIconButton = GridFilterHeaderIconButton;
|
|
70245
70446
|
exports.GridFilterQuick = GridFilterQuick;
|