@linzjs/step-ag-grid 22.1.1 → 22.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/src/components/clickInputWhenContainingCellClicked.d.ts +1 -1
- package/dist/src/components/gridPopoverEdit/GridButton.d.ts +12 -0
- package/dist/src/components/gridPopoverEdit/index.d.ts +1 -0
- package/dist/step-ag-grid.cjs.js +44 -13
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +44 -14
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/clickInputWhenContainingCellClicked.tsx +11 -14
- package/src/components/gridPopoverEdit/GridButton.tsx +63 -0
- package/src/components/gridPopoverEdit/index.ts +1 -0
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +21 -1
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +1 -1
|
@@ -3,4 +3,4 @@ import { CellClickedEvent } from "ag-grid-community";
|
|
|
3
3
|
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
4
4
|
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
5
5
|
*/
|
|
6
|
-
export declare const clickInputWhenContainingCellClicked: (
|
|
6
|
+
export declare const clickInputWhenContainingCellClicked: (params: CellClickedEvent) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ICellEditorParams } from "ag-grid-community";
|
|
2
|
+
import { ColDefT } from "../GridCell";
|
|
3
|
+
import { GenericCellColDef } from "../gridRender";
|
|
4
|
+
import { GridBaseRow } from "../Grid";
|
|
5
|
+
export interface GridButtonProps<TData> {
|
|
6
|
+
visible?: (cellEditorParams: ICellEditorParams) => boolean;
|
|
7
|
+
onClick?: (props: {
|
|
8
|
+
selectedRows: TData[];
|
|
9
|
+
selectedRowIds: (string | number)[];
|
|
10
|
+
}) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const GridButton: <TData extends GridBaseRow>(colDef: GenericCellColDef<TData, boolean>, editor: GridButtonProps<TData>) => ColDefT<TData>;
|
package/dist/step-ag-grid.cjs.js
CHANGED
|
@@ -2339,9 +2339,13 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
|
|
|
2339
2339
|
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
2340
2340
|
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
2341
2341
|
*/
|
|
2342
|
-
const clickInputWhenContainingCellClicked = (
|
|
2342
|
+
const clickInputWhenContainingCellClicked = (params) => {
|
|
2343
|
+
const { data, event, colDef } = params;
|
|
2343
2344
|
if (!data || !event)
|
|
2344
2345
|
return;
|
|
2346
|
+
if (fnOrVar(colDef.editable, params) === false) {
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2345
2349
|
const element = event.target;
|
|
2346
2350
|
// Already handled
|
|
2347
2351
|
if (["BUTTON", "INPUT"].includes(element?.tagName) && element.closest(".ag-cell-inline-editing"))
|
|
@@ -2352,25 +2356,16 @@ const clickInputWhenContainingCellClicked = ({ data, event, colDef }) => {
|
|
|
2352
2356
|
const colId = colDef.colId;
|
|
2353
2357
|
if (!colId)
|
|
2354
2358
|
return;
|
|
2355
|
-
const clickInput = (
|
|
2359
|
+
const clickInput = () => {
|
|
2356
2360
|
const cell = row.querySelector(`[col-id='${colId}']`);
|
|
2357
2361
|
if (!cell)
|
|
2358
2362
|
return;
|
|
2359
2363
|
const input = cell.querySelector("input, button");
|
|
2360
|
-
if (!input)
|
|
2364
|
+
if (!input)
|
|
2361
2365
|
return;
|
|
2362
|
-
}
|
|
2363
|
-
// When clicking on a cell that is not editing, the cell changes to editing and the input/button ref becomes invalid
|
|
2364
|
-
// So wait until the cell is in edit mode before sending the click
|
|
2365
|
-
if (!input.ownerDocument.contains(input)) {
|
|
2366
|
-
if (cnt !== 0) {
|
|
2367
|
-
setTimeout(() => clickInput(cnt - 1));
|
|
2368
|
-
}
|
|
2369
|
-
return;
|
|
2370
|
-
}
|
|
2371
2366
|
input?.dispatchEvent(event);
|
|
2372
2367
|
};
|
|
2373
|
-
setTimeout(
|
|
2368
|
+
setTimeout(clickInput, 20);
|
|
2374
2369
|
};
|
|
2375
2370
|
|
|
2376
2371
|
/**
|
|
@@ -4435,6 +4430,41 @@ const GridFormTextInput = (props) => {
|
|
|
4435
4430
|
return popoverWrapper(jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "row" }, className: "FormTest subComponent", children: jsxRuntime.jsx(TextInputFormatted, { value: value, onChange: (e) => setValue(e.target.value), error: invalid(), formatted: props.units, style: { width: props.width ?? 240 }, placeholder: props.placeholder ?? "Type here", helpText: helpText }) }));
|
|
4436
4431
|
};
|
|
4437
4432
|
|
|
4433
|
+
const ButtonCellRenderer = (props) => {
|
|
4434
|
+
const { data, node, column, colDef, api } = props;
|
|
4435
|
+
const inputRef = React.useRef(null);
|
|
4436
|
+
React.useEffect(() => {
|
|
4437
|
+
const checkFocus = (event) => {
|
|
4438
|
+
if (event.rowIndex === node.rowIndex && event.column === column) {
|
|
4439
|
+
inputRef.current?.focus();
|
|
4440
|
+
}
|
|
4441
|
+
};
|
|
4442
|
+
api.addEventListener("cellFocused", checkFocus);
|
|
4443
|
+
return () => {
|
|
4444
|
+
api.removeEventListener("cellFocused", checkFocus);
|
|
4445
|
+
};
|
|
4446
|
+
}, [api, column, node.rowIndex]);
|
|
4447
|
+
return (jsxRuntime.jsx(lui.LuiButton, { ref: inputRef, className: "lui-button-icon-only", size: "sm", level: "text", onClick: () => {
|
|
4448
|
+
const selectedRows = [data];
|
|
4449
|
+
const selectedRowIds = selectedRows.map((r) => r.id);
|
|
4450
|
+
colDef?.cellEditorParams.onClick?.({ selectedRows, selectedRowIds });
|
|
4451
|
+
}, style: { display: colDef?.cellEditorParams?.visible?.(props) !== false ? "" : "none" }, children: jsxRuntime.jsx(lui.LuiIcon, { name: "ic_redo", alt: "revert", size: "md" }) }));
|
|
4452
|
+
};
|
|
4453
|
+
const GridButton = (colDef, editor) => {
|
|
4454
|
+
return GridCell({
|
|
4455
|
+
minWidth: 72,
|
|
4456
|
+
maxWidth: 72,
|
|
4457
|
+
resizable: false,
|
|
4458
|
+
headerClass: "GridHeaderAlignCenter",
|
|
4459
|
+
cellClass: "GridCellAlignCenter",
|
|
4460
|
+
cellRenderer: ButtonCellRenderer,
|
|
4461
|
+
cellEditorParams: {
|
|
4462
|
+
...editor,
|
|
4463
|
+
},
|
|
4464
|
+
...colDef,
|
|
4465
|
+
});
|
|
4466
|
+
};
|
|
4467
|
+
|
|
4438
4468
|
const BooleanCellRenderer = (props) => {
|
|
4439
4469
|
const { onValueChange, value, api, node, column, colDef, data } = props;
|
|
4440
4470
|
const inputRef = React.useRef(null);
|
|
@@ -5345,6 +5375,7 @@ exports.FocusableItem = FocusableItem;
|
|
|
5345
5375
|
exports.FormError = FormError;
|
|
5346
5376
|
exports.GenericCellEditorComponentWrapper = GenericCellEditorComponentWrapper;
|
|
5347
5377
|
exports.Grid = Grid;
|
|
5378
|
+
exports.GridButton = GridButton;
|
|
5348
5379
|
exports.GridCell = GridCell;
|
|
5349
5380
|
exports.GridCellFiller = GridCellFiller;
|
|
5350
5381
|
exports.GridCellFillerColId = GridCellFillerColId;
|