@linzjs/step-ag-grid 22.0.1 → 22.1.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 +39 -0
- package/dist/src/components/Grid.d.ts +1 -2
- package/dist/src/components/GridCell.d.ts +1 -1
- package/dist/src/components/clickInputWhenContainingCellClicked.d.ts +6 -0
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
- package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +11 -0
- package/dist/src/components/gridPopoverEdit/index.d.ts +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/step-ag-grid.cjs.js +99 -17
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +98 -18
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +31 -31
- package/src/components/Grid.tsx +18 -23
- package/src/components/GridCell.tsx +4 -2
- package/src/components/clickInputWhenContainingCellClicked.tsx +40 -0
- package/src/components/gridForm/GridFormDropDown.tsx +1 -0
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +1 -1
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +79 -0
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +8 -1
- package/src/components/gridPopoverEdit/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/contexts/GridContextProvider.tsx +1 -0
- package/src/stories/grid/FormTest.tsx +1 -0
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +74 -0
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +1 -0
- package/src/styles/Grid.scss +34 -0
- package/src/styles/GridFormDropDown.scss +5 -0
package/dist/index.css
CHANGED
|
@@ -324,6 +324,16 @@
|
|
|
324
324
|
position: static !important;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
.LabelPreferencesPanelGridCellAlignCenter .ag-wrapper {
|
|
328
|
+
margin-left: auto;
|
|
329
|
+
margin-right: auto;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.LabelPreferencesPanelGridCellAlignCenter .ag-cell-wrapper, .LabelPreferencesPanelGridCellAlignCenter .GridCell-container {
|
|
333
|
+
display: flex;
|
|
334
|
+
justify-content: center;
|
|
335
|
+
}
|
|
336
|
+
|
|
327
337
|
.Grid-container {
|
|
328
338
|
flex: 1;
|
|
329
339
|
width: 100%;
|
|
@@ -418,6 +428,30 @@
|
|
|
418
428
|
background-color: #f9f9f9;
|
|
419
429
|
}
|
|
420
430
|
|
|
431
|
+
.GridHeaderAlignCenter .ag-header-cell-text {
|
|
432
|
+
margin-left: auto;
|
|
433
|
+
margin-right: auto;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.GridCellAlignCenter .GridCell-container {
|
|
437
|
+
display: flex;
|
|
438
|
+
justify-content: center;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
.GridCellAlignCenter .ag-wrapper {
|
|
442
|
+
margin-left: auto;
|
|
443
|
+
margin-right: auto;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.GridCellAlignCenter .ag-cell-wrapper, .LabelPreferencesPanelGridCellAlignCenter .GridCell-container {
|
|
447
|
+
display: flex;
|
|
448
|
+
justify-content: center;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
div.ag-ltr div.ag-header-cell-resize {
|
|
452
|
+
right: -4px;
|
|
453
|
+
}
|
|
454
|
+
|
|
421
455
|
.GridCell-container {
|
|
422
456
|
overflow: hidden;
|
|
423
457
|
text-overflow: ellipsis;
|
|
@@ -455,6 +489,11 @@
|
|
|
455
489
|
justify-content: center;
|
|
456
490
|
}
|
|
457
491
|
|
|
492
|
+
.GridPopoverEditDropDown-containerAutoWidth .szh-menu {
|
|
493
|
+
width: auto;
|
|
494
|
+
max-width: 274px;
|
|
495
|
+
}
|
|
496
|
+
|
|
458
497
|
.GridFormEditBearing-input {
|
|
459
498
|
width: 320px;
|
|
460
499
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ColDef } from "ag-grid-community";
|
|
2
|
-
import { GridOptions } from "ag-grid-community";
|
|
1
|
+
import { ColDef, GridOptions } from "ag-grid-community";
|
|
3
2
|
import { ReactElement } from "react";
|
|
4
3
|
import { GridContextMenuComponent } from "./gridHook";
|
|
5
4
|
export interface GridBaseRow {
|
|
@@ -37,7 +37,7 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
|
|
|
37
37
|
editable?: boolean | SAEditableCallback<TData, ValueType>;
|
|
38
38
|
valueGetter?: string | SAValueGetterFunc<TData, ValueType>;
|
|
39
39
|
valueFormatter?: string | SAValueFormatterFunc<TData, ValueType>;
|
|
40
|
-
cellRenderer?: (props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
40
|
+
cellRenderer?: ((props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined) | string;
|
|
41
41
|
cellRendererParams?: {
|
|
42
42
|
singleClickEdit?: boolean;
|
|
43
43
|
rightHoverElement?: ReactElement;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CellClickedEvent } from "ag-grid-community";
|
|
2
|
+
/**
|
|
3
|
+
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
4
|
+
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
5
|
+
*/
|
|
6
|
+
export declare const clickInputWhenContainingCellClicked: ({ data, event, colDef }: CellClickedEvent) => void;
|
|
@@ -23,7 +23,7 @@ export declare const MenuHeaderItem: (title: string) => {
|
|
|
23
23
|
};
|
|
24
24
|
export type SelectOption = null | string | FinalSelectOption;
|
|
25
25
|
export interface GridFormDropDownProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
26
|
-
className?: "GridPopoverEditDropDown-containerSmall" | "GridPopoverEditDropDown-containerMedium" | "GridPopoverEditDropDown-containerLarge" | "GridPopoverEditDropDown-containerUnlimited" | string | undefined;
|
|
26
|
+
className?: "GridPopoverEditDropDown-containerSmall" | "GridPopoverEditDropDown-containerMedium" | "GridPopoverEditDropDown-containerLarge" | "GridPopoverEditDropDown-containerUnlimited" | "GridPopoverEditDropDown-containerAutoWidth" | string | undefined;
|
|
27
27
|
filtered?: "local" | "reload";
|
|
28
28
|
filterDefaultValue?: string;
|
|
29
29
|
filterPlaceholder?: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CellEditorCommon, ColDefT } from "../GridCell";
|
|
2
|
+
import { GenericCellColDef } from "../gridRender";
|
|
3
|
+
import { GridBaseRow } from "../Grid";
|
|
4
|
+
export interface GridEditBooleanEditorProps<TData> extends CellEditorCommon {
|
|
5
|
+
onClick: (props: {
|
|
6
|
+
selectedRows: TData[];
|
|
7
|
+
selectedRowIds: (string | number)[];
|
|
8
|
+
checked: boolean;
|
|
9
|
+
}) => Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
export declare const GridEditBoolean: <TData extends GridBaseRow>(colDef: GenericCellColDef<TData, boolean>, editorProps: GridEditBooleanEditorProps<TData>) => ColDefT<TData>;
|
package/dist/step-ag-grid.cjs.js
CHANGED
|
@@ -2335,6 +2335,44 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
|
|
|
2335
2335
|
};
|
|
2336
2336
|
};
|
|
2337
2337
|
|
|
2338
|
+
/**
|
|
2339
|
+
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
2340
|
+
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
2341
|
+
*/
|
|
2342
|
+
const clickInputWhenContainingCellClicked = ({ data, event, colDef }) => {
|
|
2343
|
+
if (!data || !event)
|
|
2344
|
+
return;
|
|
2345
|
+
const element = event.target;
|
|
2346
|
+
// Already handled
|
|
2347
|
+
if (["BUTTON", "INPUT"].includes(element?.tagName) && element.closest(".ag-cell-inline-editing"))
|
|
2348
|
+
return;
|
|
2349
|
+
const row = element.closest("[row-id]");
|
|
2350
|
+
if (!row)
|
|
2351
|
+
return;
|
|
2352
|
+
const colId = colDef.colId;
|
|
2353
|
+
if (!colId)
|
|
2354
|
+
return;
|
|
2355
|
+
const clickInput = (cnt) => {
|
|
2356
|
+
const cell = row.querySelector(`[col-id='${colId}']`);
|
|
2357
|
+
if (!cell)
|
|
2358
|
+
return;
|
|
2359
|
+
const input = cell.querySelector("input, button");
|
|
2360
|
+
if (!input) {
|
|
2361
|
+
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
|
+
input?.dispatchEvent(event);
|
|
2372
|
+
};
|
|
2373
|
+
setTimeout(() => clickInput(20), 10);
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2338
2376
|
/**
|
|
2339
2377
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2340
2378
|
*/
|
|
@@ -2448,16 +2486,6 @@ const Grid = ({ "data-testid": dataTestId, defaultPostSort = true, rowSelection
|
|
|
2448
2486
|
selectRowsById,
|
|
2449
2487
|
getFirstRowId,
|
|
2450
2488
|
]);
|
|
2451
|
-
/**
|
|
2452
|
-
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
2453
|
-
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
2454
|
-
*/
|
|
2455
|
-
const clickSelectorCheckboxWhenContainingCellClicked = React.useCallback(({ event }) => {
|
|
2456
|
-
if (!event)
|
|
2457
|
-
return;
|
|
2458
|
-
const input = event.target.querySelector("input");
|
|
2459
|
-
input?.dispatchEvent(event);
|
|
2460
|
-
}, []);
|
|
2461
2489
|
/**
|
|
2462
2490
|
* Ensure external selected items list is in sync with panel.
|
|
2463
2491
|
*/
|
|
@@ -2557,7 +2585,7 @@ const Grid = ({ "data-testid": dataTestId, defaultPostSort = true, rowSelection
|
|
|
2557
2585
|
}
|
|
2558
2586
|
return false;
|
|
2559
2587
|
},
|
|
2560
|
-
onCellClicked:
|
|
2588
|
+
onCellClicked: clickInputWhenContainingCellClicked,
|
|
2561
2589
|
},
|
|
2562
2590
|
...adjustColDefs,
|
|
2563
2591
|
]
|
|
@@ -2571,7 +2599,6 @@ const Grid = ({ "data-testid": dataTestId, defaultPostSort = true, rowSelection
|
|
|
2571
2599
|
params.defaultColDef?.editable,
|
|
2572
2600
|
selectColumnPinned,
|
|
2573
2601
|
rowSelection,
|
|
2574
|
-
clickSelectorCheckboxWhenContainingCellClicked,
|
|
2575
2602
|
]);
|
|
2576
2603
|
/**
|
|
2577
2604
|
* When grid is ready set the apis to the grid context and sync selected items to grid.
|
|
@@ -2673,11 +2700,16 @@ const Grid = ({ "data-testid": dataTestId, defaultPostSort = true, rowSelection
|
|
|
2673
2700
|
* Start editing on pressing Enter
|
|
2674
2701
|
*/
|
|
2675
2702
|
const onCellKeyPress = React.useCallback((e) => {
|
|
2676
|
-
|
|
2703
|
+
const kbe = e.event;
|
|
2704
|
+
if (kbe.key === "Enter") {
|
|
2677
2705
|
if (!invokeEditAction(e))
|
|
2678
2706
|
startCellEditing(e);
|
|
2679
2707
|
}
|
|
2680
|
-
|
|
2708
|
+
if (kbe.key === "Tab") {
|
|
2709
|
+
// eslint-disable-next-line
|
|
2710
|
+
prePopupOps();
|
|
2711
|
+
}
|
|
2712
|
+
}, [prePopupOps, startCellEditing]);
|
|
2681
2713
|
/**
|
|
2682
2714
|
* Once the grid has auto-sized we want to run fit to fit the grid in its container,
|
|
2683
2715
|
* but we don't want the non-flex auto-sized columns to "fit" size, so suppressSizeToFit is set to true.
|
|
@@ -2979,7 +3011,7 @@ const GridCell = (props, custom) => {
|
|
|
2979
3011
|
return JSON.stringify(params.value);
|
|
2980
3012
|
},
|
|
2981
3013
|
...props,
|
|
2982
|
-
cellRenderer: GridCellRenderer,
|
|
3014
|
+
cellRenderer: typeof props.cellRenderer === "string" ? props.cellRenderer : GridCellRenderer,
|
|
2983
3015
|
cellRendererParams: {
|
|
2984
3016
|
originalCellRenderer: props.cellRenderer,
|
|
2985
3017
|
...props.cellRendererParams,
|
|
@@ -4151,7 +4183,7 @@ const GridFormMultiSelectGrid = (props) => {
|
|
|
4151
4183
|
e.keepOpen = true;
|
|
4152
4184
|
toggleValue(o);
|
|
4153
4185
|
}
|
|
4154
|
-
}, children: jsxRuntime.jsx(lui.LuiCheckboxInput, { isChecked: !!o.checked
|
|
4186
|
+
}, children: jsxRuntime.jsx(lui.LuiCheckboxInput, { isChecked: !!o.checked, isIndeterminate: o.checked === "partial", value: `${o.value}`, label: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [o.warning && jsxRuntime.jsx(GridIcon, { icon: "ic_warning_outline", title: o.warning }, "$$icon$$"), jsxRuntime.jsx("span", { className: "GridMultiSelectGrid-Label", children: o.label ?? (o.value == null ? `<${o.value}>` : `${o.value}`) }, "$$label$$")] }), inputProps: {
|
|
4155
4187
|
onClick: (e) => {
|
|
4156
4188
|
// Click is handled by MenuItem onClick
|
|
4157
4189
|
e.preventDefault();
|
|
@@ -4403,6 +4435,52 @@ const GridFormTextInput = (props) => {
|
|
|
4403
4435
|
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 }) }));
|
|
4404
4436
|
};
|
|
4405
4437
|
|
|
4438
|
+
const BooleanCellRenderer = (props) => {
|
|
4439
|
+
const { onValueChange, value, api, node, column, colDef, data } = props;
|
|
4440
|
+
const inputRef = React.useRef(null);
|
|
4441
|
+
React.useEffect(() => {
|
|
4442
|
+
const checkFocus = (event) => {
|
|
4443
|
+
if (event.rowIndex === node.rowIndex && event.column === column) {
|
|
4444
|
+
inputRef.current?.focus();
|
|
4445
|
+
}
|
|
4446
|
+
};
|
|
4447
|
+
api.addEventListener("cellFocused", checkFocus);
|
|
4448
|
+
return () => {
|
|
4449
|
+
api.removeEventListener("cellFocused", checkFocus);
|
|
4450
|
+
};
|
|
4451
|
+
}, [api, column, node.rowIndex]);
|
|
4452
|
+
return (jsxRuntime.jsx("div", { className: clsx("ag-wrapper ag-input-wrapper ag-checkbox-input-wrapper", { "ag-checked": props.value }), children: jsxRuntime.jsx("input", { type: "checkbox", className: "ag-input-field-input ag-checkbox-input", disabled: !fnOrVar(colDef?.editable, props), ref: inputRef, checked: value, onChange: () => { }, onClick: (e) => {
|
|
4453
|
+
e.stopPropagation();
|
|
4454
|
+
// cell has to be in edit mode
|
|
4455
|
+
// if in non-edit mode clickInputWhenContainingCellClicked will click to put it in edit mode
|
|
4456
|
+
if (!onValueChange)
|
|
4457
|
+
return;
|
|
4458
|
+
const params = props?.colDef?.cellEditorParams;
|
|
4459
|
+
if (!params)
|
|
4460
|
+
return;
|
|
4461
|
+
const selectedRows = [data];
|
|
4462
|
+
const checked = !value;
|
|
4463
|
+
onValueChange(checked);
|
|
4464
|
+
params.onClick({ selectedRows, selectedRowIds: selectedRows.map((r) => r.id), checked }).then();
|
|
4465
|
+
} }) }));
|
|
4466
|
+
};
|
|
4467
|
+
const GridEditBoolean = (colDef, editorProps) => {
|
|
4468
|
+
return GridCell({
|
|
4469
|
+
minWidth: 64,
|
|
4470
|
+
maxWidth: 64,
|
|
4471
|
+
cellRenderer: BooleanCellRenderer,
|
|
4472
|
+
cellEditor: BooleanCellRenderer,
|
|
4473
|
+
cellEditorParams: editorProps,
|
|
4474
|
+
onCellClicked: clickInputWhenContainingCellClicked,
|
|
4475
|
+
singleClickEdit: true,
|
|
4476
|
+
resizable: false,
|
|
4477
|
+
editable: true,
|
|
4478
|
+
cellClass: "GridCellAlignCenter",
|
|
4479
|
+
headerClass: "GridHeaderAlignCenter",
|
|
4480
|
+
...colDef,
|
|
4481
|
+
});
|
|
4482
|
+
};
|
|
4483
|
+
|
|
4406
4484
|
const GridPopoutEditMultiSelect = (colDef, props) => GridCell(colDef, {
|
|
4407
4485
|
editor: GridFormMultiSelect,
|
|
4408
4486
|
...props,
|
|
@@ -4486,7 +4564,9 @@ const GridPopoverEditDropDown = (colDef, props) => GridCell(colDef, {
|
|
|
4486
4564
|
...props,
|
|
4487
4565
|
editorParams: {
|
|
4488
4566
|
...props.editorParams,
|
|
4489
|
-
className: clsx(
|
|
4567
|
+
className: clsx({
|
|
4568
|
+
"GridPopoverEditDropDown-containerLarge": !props.editorParams?.className?.includes("GridPopoverEditDropDown-container"),
|
|
4569
|
+
}, props.editorParams?.className),
|
|
4490
4570
|
},
|
|
4491
4571
|
});
|
|
4492
4572
|
|
|
@@ -5273,6 +5353,7 @@ exports.GridCellMultiSelectClassRules = GridCellMultiSelectClassRules;
|
|
|
5273
5353
|
exports.GridCellRenderer = GridCellRenderer;
|
|
5274
5354
|
exports.GridContext = GridContext;
|
|
5275
5355
|
exports.GridContextProvider = GridContextProvider;
|
|
5356
|
+
exports.GridEditBoolean = GridEditBoolean;
|
|
5276
5357
|
exports.GridFilterButtons = GridFilterButtons;
|
|
5277
5358
|
exports.GridFilterColumnsToggle = GridFilterColumnsToggle;
|
|
5278
5359
|
exports.GridFilterDownloadCsvButton = GridFilterDownloadCsvButton;
|
|
@@ -5333,6 +5414,7 @@ exports.bearingNumberParser = bearingNumberParser;
|
|
|
5333
5414
|
exports.bearingRangeValidator = bearingRangeValidator;
|
|
5334
5415
|
exports.bearingStringValidator = bearingStringValidator;
|
|
5335
5416
|
exports.bearingValueFormatter = bearingValueFormatter;
|
|
5417
|
+
exports.clickInputWhenContainingCellClicked = clickInputWhenContainingCellClicked;
|
|
5336
5418
|
exports.convertDDToDMS = convertDDToDMS;
|
|
5337
5419
|
exports.downloadCsvUseValueFormattersProcessCellCallback = downloadCsvUseValueFormattersProcessCellCallback;
|
|
5338
5420
|
exports.findParentWithClass = findParentWithClass;
|