@linzjs/step-ag-grid 7.12.0 → 7.13.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/GridTheme.scss +0 -4
- package/dist/src/components/GridCell.d.ts +3 -3
- package/dist/src/components/GridCellMultiEditor.d.ts +15 -0
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +2 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +5 -1
- package/dist/src/contexts/GridContext.d.ts +2 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/step-ag-grid.esm.js +119 -67
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/components/Grid.tsx +19 -4
- package/src/components/GridCell.tsx +21 -16
- package/src/components/GridCellMultiEditor.tsx +52 -0
- package/src/components/GridCellMultiSelectClassRules.tsx +16 -5
- package/src/components/gridForm/GridFormDropDown.tsx +34 -32
- package/src/components/gridForm/GridFormTextArea.tsx +1 -1
- package/src/components/gridRender/GridRenderGenericCell.tsx +6 -1
- package/src/contexts/GridContext.tsx +6 -0
- package/src/contexts/GridContextProvider.tsx +12 -7
- package/src/index.ts +6 -0
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +41 -3
- package/src/styles/GridTheme.scss +0 -4
- package/dist/index.js +0 -24853
- package/dist/index.js.map +0 -1
package/dist/GridTheme.scss
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { GridBaseRow } from "./Grid";
|
|
3
3
|
import { GenericCellColDef } from "./gridRender/GridRenderGenericCell";
|
|
4
4
|
import { ColDef, ICellEditorParams, ICellRendererParams } from "ag-grid-community";
|
|
5
|
+
import { SuppressKeyboardEventParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
5
6
|
export interface GenericCellEditorProps<E> {
|
|
6
7
|
multiEdit?: boolean;
|
|
7
8
|
editor?: (editorProps: E) => JSX.Element;
|
|
@@ -12,6 +13,7 @@ export interface ColDefT<RowType extends GridBaseRow> extends ColDef {
|
|
|
12
13
|
_?: RowType;
|
|
13
14
|
editor?: (editorProps: any) => JSX.Element;
|
|
14
15
|
}
|
|
16
|
+
export declare const suppressCellKeyboardEvents: (e: SuppressKeyboardEventParams) => any;
|
|
15
17
|
export declare const GridCell: <RowType extends GridBaseRow, Props extends CellEditorCommon>(props: GenericCellColDef<RowType>, custom?: {
|
|
16
18
|
multiEdit?: boolean | undefined;
|
|
17
19
|
editor?: ((editorProps: Props) => JSX.Element) | undefined;
|
|
@@ -20,6 +22,4 @@ export declare const GridCell: <RowType extends GridBaseRow, Props extends CellE
|
|
|
20
22
|
export interface CellEditorCommon {
|
|
21
23
|
className?: string | undefined;
|
|
22
24
|
}
|
|
23
|
-
export declare const GenericCellEditorComponentWrapper: (
|
|
24
|
-
editor?: ((props: any) => JSX.Element) | undefined;
|
|
25
|
-
} | undefined) => import("react").ForwardRefExoticComponent<ICellEditorParams & import("react").RefAttributes<unknown>>;
|
|
25
|
+
export declare const GenericCellEditorComponentWrapper: (editor?: ((props: any) => JSX.Element) | undefined) => import("react").ForwardRefExoticComponent<ICellEditorParams & import("react").RefAttributes<unknown>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GridBaseRow } from "./Grid";
|
|
2
|
+
import { GenericCellColDef } from "./gridRender/GridRenderGenericCell";
|
|
3
|
+
import { CellEditorSelectorResult } from "ag-grid-community/dist/lib/entities/colDef";
|
|
4
|
+
import { ColDefT } from "./GridCell";
|
|
5
|
+
import { ComponentProps } from "react";
|
|
6
|
+
import { ICellEditorParams } from "ag-grid-community/dist/lib/interfaces/iCellEditor";
|
|
7
|
+
export declare const Editor: <FN extends (param: any) => JSX.Element>(props: {
|
|
8
|
+
multiEdit: boolean;
|
|
9
|
+
editor: FN;
|
|
10
|
+
editorParams: ComponentProps<FN>;
|
|
11
|
+
}) => CellEditorSelectorResult;
|
|
12
|
+
export interface RowCellEditorParams<RowType extends GridBaseRow> extends ICellEditorParams {
|
|
13
|
+
data: RowType;
|
|
14
|
+
}
|
|
15
|
+
export declare const GridCellMultiEditor: <RowType extends GridBaseRow>(props: GenericCellColDef<RowType>, cellEditorSelector: (params: RowCellEditorParams<RowType>) => CellEditorSelectorResult) => ColDefT<RowType>;
|
|
@@ -27,10 +27,10 @@ export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow> extend
|
|
|
27
27
|
filtered?: "local" | "reload";
|
|
28
28
|
filterPlaceholder?: string;
|
|
29
29
|
filterHelpText?: string;
|
|
30
|
+
noOptionsMessage?: string;
|
|
30
31
|
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<RowType>) => Promise<void>;
|
|
31
32
|
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<RowType>) => Promise<void>;
|
|
32
|
-
options: SelectOption[] | ((selectedRows: RowType[], filter?: string) => Promise<SelectOption[]> | SelectOption[]);
|
|
33
|
-
optionsRequestCancel?: () => void;
|
|
33
|
+
options: SelectOption[] | ((selectedRows: RowType[], filter?: string) => Promise<SelectOption[] | undefined> | SelectOption[] | undefined) | undefined;
|
|
34
34
|
}
|
|
35
35
|
export declare const GridFormDropDown: <RowType extends GridBaseRow>(props: GridFormPopoutDropDownProps<RowType>) => JSX.Element;
|
|
36
36
|
export {};
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
import { ICellRendererParams } from "ag-grid-community";
|
|
3
3
|
import { GridBaseRow } from "../Grid";
|
|
4
4
|
import { ColDefT } from "../GridCell";
|
|
5
|
-
import { SuppressKeyboardEventParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
5
|
+
import { EditableCallbackParams, SuppressKeyboardEventParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
6
6
|
export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
|
|
7
7
|
data: RowType;
|
|
8
8
|
}
|
|
9
|
+
export interface RowEditableCallbackParams<RowType extends GridBaseRow> extends EditableCallbackParams {
|
|
10
|
+
data: RowType;
|
|
11
|
+
}
|
|
9
12
|
export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<RowType> {
|
|
10
13
|
cellRendererParams?: GenericCellRendererParams<RowType>;
|
|
14
|
+
editable?: boolean | ((params: RowEditableCallbackParams<RowType>) => boolean);
|
|
11
15
|
}
|
|
12
16
|
export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
13
17
|
singleClickEdit?: boolean;
|
|
@@ -14,6 +14,7 @@ export interface GridContextType {
|
|
|
14
14
|
selectRowsByIdWithFlash: (rowIds?: number[]) => void;
|
|
15
15
|
flashRows: (rowIds?: number[]) => void;
|
|
16
16
|
flashRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
|
|
17
|
+
focusByRowById: (rowId: number) => void;
|
|
17
18
|
ensureRowVisible: (id: number | string) => boolean;
|
|
18
19
|
ensureSelectedRowIsVisible: () => void;
|
|
19
20
|
sizeColumnsToFit: () => void;
|
|
@@ -23,6 +24,7 @@ export interface GridContextType {
|
|
|
23
24
|
field?: string;
|
|
24
25
|
}, fnUpdate: (selectedRows: any[]) => Promise<boolean>, setSaving?: (saving: boolean) => void, tabDirection?: 1 | 0 | -1) => Promise<boolean>;
|
|
25
26
|
redrawRows: (rowNodes?: RowNode[]) => void;
|
|
27
|
+
externallySelectedItemsAreInSync: boolean;
|
|
26
28
|
setExternallySelectedItemsAreInSync: (inSync: boolean) => void;
|
|
27
29
|
waitForExternallySelectedItemsToBeInSync: () => Promise<void>;
|
|
28
30
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./contexts/GridSubComponentContext";
|
|
|
10
10
|
export type { GridBaseRow } from "./components/Grid";
|
|
11
11
|
export { Grid } from "./components/Grid";
|
|
12
12
|
export * from "./components/GridCell";
|
|
13
|
+
export * from "./components/GridCellMultiEditor";
|
|
13
14
|
export { GridIcon } from "./components/GridIcon";
|
|
14
15
|
export { ComponentLoadingWrapper } from "./components/ComponentLoadingWrapper";
|
|
15
16
|
export { GridCellMultiSelectClassRules } from "./components/GridCellMultiSelectClassRules";
|
|
@@ -30,6 +31,10 @@ export { GridFormSubComponentTextInput } from "./components/gridForm/GridFormSub
|
|
|
30
31
|
export * from "./components/gridForm/GridFormDropDown";
|
|
31
32
|
export * from "./components/gridForm/GridFormMultiSelect";
|
|
32
33
|
export * from "./components/gridForm/GridFormPopoverMenu";
|
|
34
|
+
export * from "./components/gridForm/GridFormTextInput";
|
|
35
|
+
export * from "./components/gridForm/GridFormTextArea";
|
|
36
|
+
export * from "./components/gridForm/GridFormMessage";
|
|
37
|
+
export * from "./components/gridForm/GridFormEditBearing";
|
|
33
38
|
export { GridHeaderSelect } from "./components/gridHeader/GridHeaderSelect";
|
|
34
39
|
export { TextAreaInput } from "./lui/TextAreaInput";
|
|
35
40
|
export { TextInputFormatted } from "./lui/TextInputFormatted";
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1957,6 +1957,7 @@ var MenuRadioGroup = forwardRef(MenuRadioGroupFr);
|
|
|
1957
1957
|
|
|
1958
1958
|
var GridContext = createContext({
|
|
1959
1959
|
gridReady: false,
|
|
1960
|
+
externallySelectedItemsAreInSync: false,
|
|
1960
1961
|
setGridApi: function () {
|
|
1961
1962
|
console.error("no context provider for setGridApi");
|
|
1962
1963
|
},
|
|
@@ -1998,6 +1999,12 @@ var GridContext = createContext({
|
|
|
1998
1999
|
return [2 /*return*/];
|
|
1999
2000
|
});
|
|
2000
2001
|
}); },
|
|
2002
|
+
focusByRowById: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2003
|
+
return __generator(this, function (_a) {
|
|
2004
|
+
console.error("no context provider for focusByRowById");
|
|
2005
|
+
return [2 /*return*/];
|
|
2006
|
+
});
|
|
2007
|
+
}); },
|
|
2001
2008
|
ensureRowVisible: function () {
|
|
2002
2009
|
console.error("no context provider for ensureRowVisible");
|
|
2003
2010
|
return true;
|
|
@@ -2059,7 +2066,7 @@ var GridContextProvider = function (props) {
|
|
|
2059
2066
|
var _a = useState(), gridApi = _a[0], _setGridApi = _a[1];
|
|
2060
2067
|
var _b = useState(false), gridReady = _b[0], setGridReady = _b[1];
|
|
2061
2068
|
var idsBeforeUpdate = useRef([]);
|
|
2062
|
-
var
|
|
2069
|
+
var _c = useState(false), externallySelectedItemsAreInSync = _c[0], setExternallySelectedItemsAreInSync = _c[1];
|
|
2063
2070
|
var setGridApi = useCallback(function (gridApi) {
|
|
2064
2071
|
_setGridApi(gridApi);
|
|
2065
2072
|
setGridReady(!!gridApi);
|
|
@@ -2224,6 +2231,7 @@ var GridContextProvider = function (props) {
|
|
|
2224
2231
|
}
|
|
2225
2232
|
});
|
|
2226
2233
|
}); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
|
|
2234
|
+
var focusByRowById = useCallback(function (rowId) { return _selectRowsWithOptionalFlash([rowId], false, false); }, [_selectRowsWithOptionalFlash]);
|
|
2227
2235
|
var getSelectedRows = useCallback(function () {
|
|
2228
2236
|
return gridApiOp(function (gridApi) { return gridApi.getSelectedRows(); }, function () { return []; });
|
|
2229
2237
|
}, [gridApiOp]);
|
|
@@ -2337,9 +2345,6 @@ var GridContextProvider = function (props) {
|
|
|
2337
2345
|
gridApi.redrawRows(rowNodes ? { rowNodes: rowNodes } : undefined);
|
|
2338
2346
|
});
|
|
2339
2347
|
}, [gridApiOp]);
|
|
2340
|
-
var setExternallySelectedItemsAreInSync = useCallback(function (inSync) {
|
|
2341
|
-
externallySelectedItemsAreInSync.current = inSync;
|
|
2342
|
-
}, []);
|
|
2343
2348
|
var waitForExternallySelectedItemsToBeInSync = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2344
2349
|
var i;
|
|
2345
2350
|
return __generator(this, function (_a) {
|
|
@@ -2348,7 +2353,7 @@ var GridContextProvider = function (props) {
|
|
|
2348
2353
|
i = 0;
|
|
2349
2354
|
_a.label = 1;
|
|
2350
2355
|
case 1:
|
|
2351
|
-
if (!(i < 5000 / 200 && !externallySelectedItemsAreInSync
|
|
2356
|
+
if (!(i < 5000 / 200 && !externallySelectedItemsAreInSync)) return [3 /*break*/, 4];
|
|
2352
2357
|
return [4 /*yield*/, wait$2(200)];
|
|
2353
2358
|
case 2:
|
|
2354
2359
|
_a.sent();
|
|
@@ -2359,7 +2364,7 @@ var GridContextProvider = function (props) {
|
|
|
2359
2364
|
case 4: return [2 /*return*/];
|
|
2360
2365
|
}
|
|
2361
2366
|
});
|
|
2362
|
-
}); }, []);
|
|
2367
|
+
}); }, [externallySelectedItemsAreInSync]);
|
|
2363
2368
|
return (jsx(GridContext.Provider, __assign({ value: {
|
|
2364
2369
|
gridReady: gridReady,
|
|
2365
2370
|
setGridApi: setGridApi,
|
|
@@ -2370,6 +2375,7 @@ var GridContextProvider = function (props) {
|
|
|
2370
2375
|
selectRowsWithFlashDiff: selectRowsWithFlashDiff,
|
|
2371
2376
|
flashRows: flashRows,
|
|
2372
2377
|
flashRowsDiff: flashRowsDiff,
|
|
2378
|
+
focusByRowById: focusByRowById,
|
|
2373
2379
|
getSelectedRows: getSelectedRows,
|
|
2374
2380
|
getSelectedRowIds: getSelectedRowIds,
|
|
2375
2381
|
editingCells: editingCells,
|
|
@@ -2379,6 +2385,7 @@ var GridContextProvider = function (props) {
|
|
|
2379
2385
|
stopEditing: stopEditing,
|
|
2380
2386
|
updatingCells: updatingCells,
|
|
2381
2387
|
redrawRows: redrawRows,
|
|
2388
|
+
externallySelectedItemsAreInSync: externallySelectedItemsAreInSync,
|
|
2382
2389
|
setExternallySelectedItemsAreInSync: setExternallySelectedItemsAreInSync,
|
|
2383
2390
|
waitForExternallySelectedItemsToBeInSync: waitForExternallySelectedItemsToBeInSync
|
|
2384
2391
|
} }, { children: props.children })));
|
|
@@ -2710,7 +2717,7 @@ var GridHeaderSelect = function (_a) {
|
|
|
2710
2717
|
*/
|
|
2711
2718
|
var Grid = function (params) {
|
|
2712
2719
|
var _a, _b, _c;
|
|
2713
|
-
var _d = useContext(GridContext), gridReady = _d.gridReady, setGridApi = _d.setGridApi, setQuickFilter = _d.setQuickFilter, ensureRowVisible = _d.ensureRowVisible, selectRowsById = _d.selectRowsById, ensureSelectedRowIsVisible = _d.ensureSelectedRowIsVisible, sizeColumnsToFit = _d.sizeColumnsToFit, setExternallySelectedItemsAreInSync = _d.setExternallySelectedItemsAreInSync;
|
|
2720
|
+
var _d = useContext(GridContext), gridReady = _d.gridReady, setGridApi = _d.setGridApi, setQuickFilter = _d.setQuickFilter, ensureRowVisible = _d.ensureRowVisible, selectRowsById = _d.selectRowsById, focusByRowById = _d.focusByRowById, ensureSelectedRowIsVisible = _d.ensureSelectedRowIsVisible, sizeColumnsToFit = _d.sizeColumnsToFit, externallySelectedItemsAreInSync = _d.externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync = _d.setExternallySelectedItemsAreInSync;
|
|
2714
2721
|
var checkUpdating = useContext(GridUpdatingContext).checkUpdating;
|
|
2715
2722
|
var _e = useState(""), internalQuickFilter = _e[0], setInternalQuickFilter = _e[1];
|
|
2716
2723
|
var lastSelectedIds = useRef([]);
|
|
@@ -2721,13 +2728,27 @@ var Grid = function (params) {
|
|
|
2721
2728
|
*/
|
|
2722
2729
|
var hasSelectedFirstItem = useRef(false);
|
|
2723
2730
|
useEffect(function () {
|
|
2724
|
-
if (!gridReady ||
|
|
2731
|
+
if (!gridReady || hasSelectedFirstItem.current || !params.rowData || !externallySelectedItemsAreInSync)
|
|
2725
2732
|
return;
|
|
2726
2733
|
hasSelectedFirstItem.current = true;
|
|
2727
2734
|
if (isNotEmpty(params.rowData) && isEmpty(params.externalSelectedItems)) {
|
|
2728
|
-
|
|
2735
|
+
var firstRowId = params.rowData[0].id;
|
|
2736
|
+
if (params.autoSelectFirstRow) {
|
|
2737
|
+
selectRowsById([firstRowId]);
|
|
2738
|
+
}
|
|
2739
|
+
else {
|
|
2740
|
+
focusByRowById(firstRowId);
|
|
2741
|
+
}
|
|
2729
2742
|
}
|
|
2730
|
-
}, [
|
|
2743
|
+
}, [
|
|
2744
|
+
externallySelectedItemsAreInSync,
|
|
2745
|
+
focusByRowById,
|
|
2746
|
+
gridReady,
|
|
2747
|
+
params,
|
|
2748
|
+
params.autoSelectFirstRow,
|
|
2749
|
+
params.rowData,
|
|
2750
|
+
selectRowsById,
|
|
2751
|
+
]);
|
|
2731
2752
|
/**
|
|
2732
2753
|
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
2733
2754
|
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
@@ -2822,7 +2843,7 @@ var Grid = function (params) {
|
|
|
2822
2843
|
checkboxSelection: true,
|
|
2823
2844
|
headerComponent: GridHeaderSelect,
|
|
2824
2845
|
suppressHeaderKeyboardEvent: function (e) {
|
|
2825
|
-
if (e.event.key === "Enter" && !e.event.repeat) {
|
|
2846
|
+
if ((e.event.key === "Enter" || e.event.key === " ") && !e.event.repeat) {
|
|
2826
2847
|
var selectedNodeCount = e.api.getSelectedRows().length;
|
|
2827
2848
|
if (selectedNodeCount == 0) {
|
|
2828
2849
|
e.api.selectAllFiltered();
|
|
@@ -2915,12 +2936,18 @@ var Grid = function (params) {
|
|
|
2915
2936
|
};
|
|
2916
2937
|
|
|
2917
2938
|
var GridCellMultiSelectClassRules = {
|
|
2918
|
-
"ag-selected-for-edit": function (
|
|
2919
|
-
var
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2939
|
+
"ag-selected-for-edit": function (params) {
|
|
2940
|
+
var _a;
|
|
2941
|
+
var api = params.api, node = params.node, colDef = params.colDef;
|
|
2942
|
+
var cep = colDef.cellEditorSelector
|
|
2943
|
+
? (_a = colDef.cellEditorSelector(params)) === null || _a === void 0 ? void 0 : _a.params
|
|
2944
|
+
: colDef.cellEditorParams;
|
|
2945
|
+
return ((cep === null || cep === void 0 ? void 0 : cep.multiEdit) &&
|
|
2946
|
+
api
|
|
2947
|
+
.getSelectedNodes()
|
|
2948
|
+
.map(function (row) { return row.id; })
|
|
2949
|
+
.includes(node.id) &&
|
|
2950
|
+
api.getEditingCells().some(function (cell) { return cell.column.getColDef() === colDef; }));
|
|
2924
2951
|
}
|
|
2925
2952
|
};
|
|
2926
2953
|
|
|
@@ -2942,27 +2969,28 @@ var GridCellRenderer = function (props) {
|
|
|
2942
2969
|
var infoText = infoFn ? infoFn(props) : undefined;
|
|
2943
2970
|
return (jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_b = (_a = colDef.field) !== null && _a !== void 0 ? _a : colDef.colId) !== null && _b !== void 0 ? _b : "", props.data.id) }, { children: jsxs(Fragment$1, { children: [typeof warningText === "string" && jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsx(GridIcon, { icon: "ic_info", title: infoText }), jsx("div", __assign({ style: { display: "flex", flex: 1, overflow: "hidden" } }, { children: ((_c = colDef === null || colDef === void 0 ? void 0 : colDef.cellRendererParams) === null || _c === void 0 ? void 0 : _c.originalCellRenderer) ? (jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))) : (jsx("span", __assign({ title: props.valueFormatted }, { children: props.valueFormatted }))) })), fnOrVar((_d = props.colDef) === null || _d === void 0 ? void 0 : _d.editable, props) && (rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.rightHoverElement) && (jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.rightHoverElement })))] }) })));
|
|
2944
2971
|
};
|
|
2972
|
+
var suppressCellKeyboardEvents = function (e) {
|
|
2973
|
+
var _a, _b, _c, _d;
|
|
2974
|
+
var shortcutKeys = (_b = (_a = e.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.shortcutKeys) !== null && _b !== void 0 ? _b : {};
|
|
2975
|
+
var exec = shortcutKeys[e.event.key];
|
|
2976
|
+
if (!e.editing && !e.event.repeat && e.event.type === "keypress" && exec) {
|
|
2977
|
+
var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
|
|
2978
|
+
return editable ? (_d = exec(e)) !== null && _d !== void 0 ? _d : true : true;
|
|
2979
|
+
}
|
|
2980
|
+
// It's important that aggrid doesn't trigger edit on enter
|
|
2981
|
+
// as the incorrect selected rows will be returned
|
|
2982
|
+
return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " ", "Home", "End", "PageUp", "PageDown"].includes(e.event.key);
|
|
2983
|
+
};
|
|
2945
2984
|
/*
|
|
2946
2985
|
* All cells should use this
|
|
2947
2986
|
*/
|
|
2948
2987
|
var GridCell = function (props, custom) {
|
|
2949
2988
|
var _a;
|
|
2950
2989
|
return __assign(__assign(__assign(__assign(__assign(__assign({ colId: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
|
|
2951
|
-
cellClassRules:
|
|
2990
|
+
cellClassRules: GridCellMultiSelectClassRules,
|
|
2952
2991
|
editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
|
|
2953
|
-
cellEditor: GenericCellEditorComponentWrapper(custom)
|
|
2954
|
-
})), { suppressKeyboardEvent:
|
|
2955
|
-
var _a, _b, _c, _d;
|
|
2956
|
-
var shortcutKeys = (_b = (_a = e.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.shortcutKeys) !== null && _b !== void 0 ? _b : {};
|
|
2957
|
-
var exec = shortcutKeys[e.event.key];
|
|
2958
|
-
if (!e.editing && !e.event.repeat && e.event.type === "keypress" && exec) {
|
|
2959
|
-
var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
|
|
2960
|
-
return editable ? (_d = exec(e)) !== null && _d !== void 0 ? _d : true : true;
|
|
2961
|
-
}
|
|
2962
|
-
// It's important that aggrid doesn't trigger edit on enter
|
|
2963
|
-
// as the incorrect selected rows will be returned
|
|
2964
|
-
return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " "].includes(e.event.key);
|
|
2965
|
-
} }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
|
|
2992
|
+
cellEditor: GenericCellEditorComponentWrapper(custom === null || custom === void 0 ? void 0 : custom.editor)
|
|
2993
|
+
})), { suppressKeyboardEvent: suppressCellKeyboardEvents }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
|
|
2966
2994
|
cellEditorParams: __assign(__assign({}, custom.editorParams), { multiEdit: custom.multiEdit })
|
|
2967
2995
|
})), {
|
|
2968
2996
|
// Default value formatter, otherwise react freaks out on objects
|
|
@@ -2976,15 +3004,38 @@ var GridCell = function (props, custom) {
|
|
|
2976
3004
|
return JSON.stringify(params.value);
|
|
2977
3005
|
} }), props), { cellRenderer: GridCellRenderer, cellRendererParams: __assign({ originalCellRenderer: props.cellRenderer }, props.cellRendererParams) });
|
|
2978
3006
|
};
|
|
2979
|
-
var GenericCellEditorComponentWrapper = function (
|
|
3007
|
+
var GenericCellEditorComponentWrapper = function (editor) {
|
|
3008
|
+
var obj = { editor: editor };
|
|
2980
3009
|
return forwardRef(function GenericCellEditorComponentFr(cellEditorParams, _) {
|
|
2981
3010
|
var valueFormatted = cellEditorParams.formatValue
|
|
2982
3011
|
? cellEditorParams.formatValue(cellEditorParams.value)
|
|
2983
3012
|
: "Missing formatter";
|
|
2984
|
-
return (jsxs(GridPopoverContextProvider, __assign({ props: cellEditorParams }, { children: [jsx(cellEditorParams.colDef.cellRenderer, __assign({}, cellEditorParams, { valueFormatted: valueFormatted }, cellEditorParams.colDef.cellRendererParams)),
|
|
3013
|
+
return (jsxs(GridPopoverContextProvider, __assign({ props: cellEditorParams }, { children: [jsx(cellEditorParams.colDef.cellRenderer, __assign({}, cellEditorParams, { valueFormatted: valueFormatted }, cellEditorParams.colDef.cellRendererParams)), obj.editor && jsx(obj.editor, __assign({}, cellEditorParams))] })));
|
|
2985
3014
|
});
|
|
2986
3015
|
};
|
|
2987
3016
|
|
|
3017
|
+
var Editor = function (props) { return ({
|
|
3018
|
+
component: GenericCellEditorComponentWrapper(props.editor),
|
|
3019
|
+
params: __assign(__assign({}, props.editorParams), { multiEdit: props.multiEdit })
|
|
3020
|
+
}); };
|
|
3021
|
+
/*
|
|
3022
|
+
* All cells should use this
|
|
3023
|
+
*/
|
|
3024
|
+
var GridCellMultiEditor = function (props, cellEditorSelector) {
|
|
3025
|
+
var _a, _b;
|
|
3026
|
+
return __assign(__assign({ colId: (_a = props.colId) !== null && _a !== void 0 ? _a : props.field, field: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true, editable: (_b = props.editable) !== null && _b !== void 0 ? _b : true, cellClassRules: GridCellMultiSelectClassRules, cellEditorSelector: cellEditorSelector, suppressKeyboardEvent: suppressCellKeyboardEvents,
|
|
3027
|
+
// Default value formatter, otherwise react freaks out on objects
|
|
3028
|
+
valueFormatter: function (params) {
|
|
3029
|
+
if (params.value == null)
|
|
3030
|
+
return "–";
|
|
3031
|
+
var types = ["number", "boolean", "string"];
|
|
3032
|
+
if (types.includes(typeof params.value))
|
|
3033
|
+
return "".concat(params.value);
|
|
3034
|
+
else
|
|
3035
|
+
return JSON.stringify(params.value);
|
|
3036
|
+
} }, props), { cellRenderer: GridCellRenderer, cellRendererParams: __assign({ originalCellRenderer: props.cellRenderer }, props.cellRendererParams) });
|
|
3037
|
+
};
|
|
3038
|
+
|
|
2988
3039
|
/**
|
|
2989
3040
|
* If loading is true this returns a loading spinner, otherwise it returns its children.
|
|
2990
3041
|
*/
|
|
@@ -3213,17 +3264,17 @@ var fieldToString = function (field) {
|
|
|
3213
3264
|
return typeof field == "symbol" ? field.toString() : "".concat(field);
|
|
3214
3265
|
};
|
|
3215
3266
|
var GridFormDropDown = function (props) {
|
|
3216
|
-
var _a
|
|
3267
|
+
var _a;
|
|
3268
|
+
var _b = useGridPopoverContext(), selectedRows = _b.selectedRows, field = _b.field, data = _b.data;
|
|
3217
3269
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
3218
|
-
var
|
|
3219
|
-
var
|
|
3220
|
-
var
|
|
3221
|
-
var _d = useState(null), options = _d[0], setOptions = _d[1];
|
|
3270
|
+
var _c = useState(""), filter = _c[0], setFilter = _c[1];
|
|
3271
|
+
var _d = useState(), filteredValues = _d[0], setFilteredValues = _d[1];
|
|
3272
|
+
var _e = useState(null), options = _e[0], setOptions = _e[1];
|
|
3222
3273
|
var subComponentIsValid = useRef(false);
|
|
3223
3274
|
var subComponentInitialValue = useRef(null);
|
|
3224
|
-
var
|
|
3275
|
+
var _f = useState(null), subSelectedValue = _f[0], setSubSelectedValue = _f[1];
|
|
3225
3276
|
// Note: null is assumed to be the filter
|
|
3226
|
-
var
|
|
3277
|
+
var _g = useState(null), selectedItem = _g[0], setSelectedItem = _g[1];
|
|
3227
3278
|
var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3228
3279
|
var hasChanged;
|
|
3229
3280
|
return __generator(this, function (_a) {
|
|
@@ -3246,11 +3297,9 @@ var GridFormDropDown = function (props) {
|
|
|
3246
3297
|
}); }, [field, props, selectedRows]);
|
|
3247
3298
|
// Load up options list if it's async function
|
|
3248
3299
|
useEffect(function () {
|
|
3249
|
-
|
|
3250
|
-
if (options || optionsInitialising.current)
|
|
3300
|
+
if (options)
|
|
3251
3301
|
return;
|
|
3252
|
-
|
|
3253
|
-
var optionsConf = (_a = props.options) !== null && _a !== void 0 ? _a : [];
|
|
3302
|
+
var optionsConf = props.options;
|
|
3254
3303
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3255
3304
|
var optionsList;
|
|
3256
3305
|
return __generator(this, function (_a) {
|
|
@@ -3262,24 +3311,26 @@ var GridFormDropDown = function (props) {
|
|
|
3262
3311
|
optionsConf = _a.sent();
|
|
3263
3312
|
_a.label = 2;
|
|
3264
3313
|
case 2:
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3314
|
+
if (optionsConf !== undefined) {
|
|
3315
|
+
optionsList = optionsConf === null || optionsConf === void 0 ? void 0 : optionsConf.map(function (item) {
|
|
3316
|
+
return item == null || typeof item == "string"
|
|
3317
|
+
? {
|
|
3318
|
+
value: item,
|
|
3319
|
+
label: item,
|
|
3320
|
+
disabled: false
|
|
3321
|
+
}
|
|
3322
|
+
: item;
|
|
3323
|
+
});
|
|
3324
|
+
if (props.filtered) {
|
|
3325
|
+
// This is needed otherwise when filter input is rendered and sets autofocus
|
|
3326
|
+
// the mouse up of the double click edit triggers the cell to cancel editing
|
|
3327
|
+
setOptions(optionsList);
|
|
3328
|
+
//delay(() => setOptions(optionsList), 100);
|
|
3329
|
+
}
|
|
3330
|
+
else {
|
|
3331
|
+
setOptions(optionsList);
|
|
3332
|
+
}
|
|
3281
3333
|
}
|
|
3282
|
-
optionsInitialising.current = false;
|
|
3283
3334
|
return [2 /*return*/];
|
|
3284
3335
|
}
|
|
3285
3336
|
});
|
|
@@ -3302,15 +3353,16 @@ var GridFormDropDown = function (props) {
|
|
|
3302
3353
|
.filter(function (r) { return r !== undefined; }));
|
|
3303
3354
|
}
|
|
3304
3355
|
}, [props.filtered, filter, options]);
|
|
3305
|
-
var researchOnFilterChange =
|
|
3306
|
-
|
|
3307
|
-
|
|
3356
|
+
var researchOnFilterChange = useMemo(function () {
|
|
3357
|
+
return dist$1(function () {
|
|
3358
|
+
setOptions(null);
|
|
3359
|
+
}, 500);
|
|
3360
|
+
}, []);
|
|
3308
3361
|
var previousFilter = useRef(filter);
|
|
3309
3362
|
// Reload filtering.
|
|
3310
3363
|
useEffect(function () {
|
|
3311
3364
|
if (previousFilter.current != filter && props.filtered == "reload") {
|
|
3312
3365
|
previousFilter.current = filter;
|
|
3313
|
-
props.optionsRequestCancel && props.optionsRequestCancel();
|
|
3314
3366
|
researchOnFilterChange().then();
|
|
3315
3367
|
}
|
|
3316
3368
|
}, [filter, props, researchOnFilterChange]);
|
|
@@ -3362,7 +3414,7 @@ var GridFormDropDown = function (props) {
|
|
|
3362
3414
|
var ref = _a.ref;
|
|
3363
3415
|
return (jsxs("div", __assign({ style: { display: "flex", flexDirection: "column", width: "100%" } }, { children: [jsx("input", { className: "LuiTextInput-input", ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, "data-allowtabtosave": true, "data-disableenterautosave": !props.onSelectFilter &&
|
|
3364
3416
|
!(filteredValues && filteredValues.length === 1 && !filteredValues[0].subComponent), onChange: function (e) { return setFilter(e.target.value); } }), props.filterHelpText && isNotEmpty(filter) && (jsx(FormError, { error: null, helpText: props.filterHelpText }))] })));
|
|
3365
|
-
} })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && (isEmpty(options) || (filteredValues && isEmpty(filteredValues))) && (jsx(MenuItem, __assign({ className: "GridPopoverEditDropDown-noOptions" }, { children: "No Options" }), "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3417
|
+
} })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && (isEmpty(options) || (filteredValues && isEmpty(filteredValues))) && (jsx(MenuItem, __assign({ className: "GridPopoverEditDropDown-noOptions" }, { children: (_a = props.noOptionsMessage) !== null && _a !== void 0 ? _a : "No Options" }), "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3366
3418
|
var _a;
|
|
3367
3419
|
return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : ((!filteredValues || filteredValues.includes(item)) && (jsxs("div", { children: [jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onFocus: function () {
|
|
3368
3420
|
setSelectedItem(item);
|
|
@@ -24743,5 +24795,5 @@ var clickActionButton = function (text, container) { return __awaiter(void 0, vo
|
|
|
24743
24795
|
});
|
|
24744
24796
|
}); };
|
|
24745
24797
|
|
|
24746
|
-
export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponentWrapper, Grid, GridCell, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, clickActionButton, clickMenuOption, clickMultiSelectOption, closeMenu, convertDDToDMS, countRows, deselectRow, editCell, findActionButton, findCell, findCellContains, findMenuOption, findMultiSelectOption, findParentWithClass, findRow, fnOrVar, getMultiSelectOptions, hasParentClass, isFloat, isNotEmpty, openAndClickMenuOption, queryMenuOption, queryRow, selectCell, selectRow, stringByteLengthIsInvalid, typeOtherInput, typeOtherTextArea, useDeferredPromise, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait$2 as wait };
|
|
24798
|
+
export { ActionButton, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, GenericCellEditorComponentWrapper, Grid, GridCell, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, clickActionButton, clickMenuOption, clickMultiSelectOption, closeMenu, convertDDToDMS, countRows, deselectRow, editCell, findActionButton, findCell, findCellContains, findMenuOption, findMultiSelectOption, findParentWithClass, findRow, fnOrVar, getMultiSelectOptions, hasParentClass, isFloat, isNotEmpty, openAndClickMenuOption, queryMenuOption, queryRow, selectCell, selectRow, stringByteLengthIsInvalid, suppressCellKeyboardEvents, typeOtherInput, typeOtherTextArea, useDeferredPromise, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait$2 as wait };
|
|
24747
24799
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|