@linzjs/step-ag-grid 8.3.2 → 8.4.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/GridCell.d.ts +2 -1
- package/dist/src/components/GridCell.test.d.ts +1 -0
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +6 -2
- package/dist/step-ag-grid.esm.js +34 -4
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/components/GridCell.test.tsx +33 -0
- package/src/components/GridCell.tsx +46 -7
- package/src/components/gridForm/GridFormDropDown.tsx +1 -1
- package/src/components/gridRender/GridRenderGenericCell.tsx +6 -2
- package/src/stories/grid/GridPopoutBearing.stories.tsx +1 -0
- package/dist/src/setupTests.d.ts +0 -1
- package/src/setupTests.ts +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GridBaseRow } from "./Grid";
|
|
3
|
-
import { GenericCellColDef } from "./gridRender/GridRenderGenericCell";
|
|
3
|
+
import { GenericCellColDef, RowValueFormatterParams, RowValueGetterParams } from "./gridRender/GridRenderGenericCell";
|
|
4
4
|
import { ColDef, ICellEditorParams, ICellRendererParams } from "ag-grid-community";
|
|
5
5
|
import { SuppressKeyboardEventParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
6
6
|
export interface GenericCellEditorProps<E> {
|
|
@@ -14,6 +14,7 @@ export interface ColDefT<RowType extends GridBaseRow> extends ColDef {
|
|
|
14
14
|
editor?: (editorProps: any) => JSX.Element;
|
|
15
15
|
}
|
|
16
16
|
export declare const suppressCellKeyboardEvents: (e: SuppressKeyboardEventParams) => any;
|
|
17
|
+
export declare const generateFilterGetter: <RowType extends GridBaseRow>(field: string | undefined, filterValueGetter: string | ((params: RowValueGetterParams<RowType>) => string) | undefined, valueFormatter: string | ((params: RowValueFormatterParams<RowType>) => string) | undefined) => string | ((params: RowValueGetterParams<RowType>) => string) | undefined;
|
|
17
18
|
export declare const GridCell: <RowType extends GridBaseRow, Props extends CellEditorCommon>(props: GenericCellColDef<RowType>, custom?: {
|
|
18
19
|
multiEdit?: boolean | undefined;
|
|
19
20
|
editor?: ((editorProps: Props) => JSX.Element) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,11 +15,15 @@ export interface RowValueFormatterParams<RowType extends GridBaseRow> extends Va
|
|
|
15
15
|
export interface RowValueGetterParams<RowType extends GridBaseRow> extends ValueGetterParams {
|
|
16
16
|
data: RowType;
|
|
17
17
|
}
|
|
18
|
+
export interface RowValueGetterParams<RowType extends GridBaseRow> extends ValueGetterParams {
|
|
19
|
+
data: RowType;
|
|
20
|
+
}
|
|
18
21
|
export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<RowType> {
|
|
19
22
|
cellRenderer?: (params: RowICellRendererParams<RowType>) => any;
|
|
20
23
|
cellRendererParams?: GenericCellRendererParams<RowType>;
|
|
21
24
|
valueGetter?: string | ((params: RowValueGetterParams<RowType>) => any);
|
|
22
25
|
valueFormatter?: string | ((params: RowValueFormatterParams<RowType>) => string);
|
|
26
|
+
filterValueGetter?: string | ((params: RowValueGetterParams<RowType>) => string);
|
|
23
27
|
editable?: boolean | ((params: RowEditableCallbackParams<RowType>) => boolean);
|
|
24
28
|
}
|
|
25
29
|
export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
@@ -27,6 +31,6 @@ export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
|
27
31
|
rightHoverElement?: JSX.Element | undefined;
|
|
28
32
|
editAction?: (selectedRows: RowType[]) => void;
|
|
29
33
|
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
30
|
-
warning?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
|
|
31
|
-
info?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
|
|
34
|
+
warning?: (props: RowICellRendererParams<RowType>) => string | string[] | boolean | null | undefined;
|
|
35
|
+
info?: (props: RowICellRendererParams<RowType>) => string | string[] | boolean | null | undefined;
|
|
32
36
|
}
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2995,7 +2995,7 @@ var GridIcon = function (props) {
|
|
|
2995
2995
|
};
|
|
2996
2996
|
|
|
2997
2997
|
var GridCellRenderer = function (props) {
|
|
2998
|
-
var _a, _b, _c
|
|
2998
|
+
var _a, _b, _c;
|
|
2999
2999
|
var checkUpdating = useContext(GridUpdatingContext).checkUpdating;
|
|
3000
3000
|
var colDef = props.colDef;
|
|
3001
3001
|
var rendererParams = colDef.cellRendererParams;
|
|
@@ -3003,7 +3003,11 @@ var GridCellRenderer = function (props) {
|
|
|
3003
3003
|
var warningText = warningFn ? warningFn(props) : undefined;
|
|
3004
3004
|
var infoFn = rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.info;
|
|
3005
3005
|
var infoText = infoFn ? infoFn(props) : undefined;
|
|
3006
|
-
|
|
3006
|
+
if (Array.isArray(warningText))
|
|
3007
|
+
warningText = warningText.join("\n");
|
|
3008
|
+
if (Array.isArray(infoText))
|
|
3009
|
+
infoText = infoText.join("\n");
|
|
3010
|
+
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: [!!warningText && (jsx(GridIcon, { icon: "ic_warning_outline", title: typeof warningText === "string" ? warningText : "Warning" })), !!infoText && jsx(GridIcon, { icon: "ic_info_outline", title: typeof infoText === "string" ? infoText : "Info" }), jsx("div", __assign({ style: { display: "flex", flex: 1, overflow: "hidden" } }, { children: ((_c = 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(colDef.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 })))] }) })));
|
|
3007
3011
|
};
|
|
3008
3012
|
var suppressCellKeyboardEvents = function (e) {
|
|
3009
3013
|
var _a, _b, _c, _d;
|
|
@@ -3017,11 +3021,35 @@ var suppressCellKeyboardEvents = function (e) {
|
|
|
3017
3021
|
// as the incorrect selected rows will be returned
|
|
3018
3022
|
return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " ", "Home", "End", "PageUp", "PageDown"].includes(e.event.key);
|
|
3019
3023
|
};
|
|
3024
|
+
var generateFilterGetter = function (field, filterValueGetter, valueFormatter) {
|
|
3025
|
+
if (filterValueGetter)
|
|
3026
|
+
return filterValueGetter;
|
|
3027
|
+
// aggrid will default to valueGetter
|
|
3028
|
+
if (typeof valueFormatter !== "function" || !field)
|
|
3029
|
+
return undefined;
|
|
3030
|
+
return function (params) {
|
|
3031
|
+
var value = params.getValue(field);
|
|
3032
|
+
var formattedValue = valueFormatter(__assign(__assign({}, params), { value: value }));
|
|
3033
|
+
// Search for null values using standard dash
|
|
3034
|
+
if (formattedValue === "–")
|
|
3035
|
+
formattedValue += " -";
|
|
3036
|
+
// Search by raw value as well as formatted
|
|
3037
|
+
var gotValue = ["string", "number"].includes(typeof value) ? value : undefined;
|
|
3038
|
+
return (formattedValue + (gotValue != null && formattedValue != gotValue ? " " + gotValue : "")) //
|
|
3039
|
+
.replaceAll(/\s+/g, " ")
|
|
3040
|
+
.trim();
|
|
3041
|
+
};
|
|
3042
|
+
};
|
|
3020
3043
|
/*
|
|
3021
3044
|
* All cells should use this.
|
|
3022
3045
|
*/
|
|
3023
3046
|
var GridCell = function (props, custom) {
|
|
3024
3047
|
var _a, _b;
|
|
3048
|
+
// Generate a default filter value getter which uses the formatted value plus
|
|
3049
|
+
// the editable value if it's a string and different from the formatted value.
|
|
3050
|
+
// This is so that e.g. bearings can be searched for by DMS or raw number.
|
|
3051
|
+
var valueFormatter = props.valueFormatter;
|
|
3052
|
+
var filterValueGetter = generateFilterGetter(props.field, props.filterValueGetter, valueFormatter);
|
|
3025
3053
|
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, editable: (_a = props.editable) !== null && _a !== void 0 ? _a : false }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
|
|
3026
3054
|
cellClassRules: GridCellMultiSelectClassRules,
|
|
3027
3055
|
editable: (_b = props.editable) !== null && _b !== void 0 ? _b : true,
|
|
@@ -3029,6 +3057,8 @@ var GridCell = function (props, custom) {
|
|
|
3029
3057
|
})), { suppressKeyboardEvent: suppressCellKeyboardEvents }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
|
|
3030
3058
|
cellEditorParams: __assign(__assign({}, custom.editorParams), { multiEdit: custom.multiEdit })
|
|
3031
3059
|
})), {
|
|
3060
|
+
// If there's a valueFormatter and no filterValueGetter then create a filterValueGetter
|
|
3061
|
+
filterValueGetter: filterValueGetter,
|
|
3032
3062
|
// Default value formatter, otherwise react freaks out on objects
|
|
3033
3063
|
valueFormatter: function (params) {
|
|
3034
3064
|
if (params.value == null)
|
|
@@ -3494,7 +3524,7 @@ var GridFormDropDown = function (props) {
|
|
|
3494
3524
|
setValue: function (value) {
|
|
3495
3525
|
setSubSelectedValue(value);
|
|
3496
3526
|
if (subComponentInitialValue.current === null) {
|
|
3497
|
-
// copy the default value of the subcomponent so we can change detect on save
|
|
3527
|
+
// copy the default value of the subcomponent, so we can change detect on save
|
|
3498
3528
|
subComponentInitialValue.current = JSON.stringify(value);
|
|
3499
3529
|
}
|
|
3500
3530
|
},
|
|
@@ -24967,5 +24997,5 @@ var clickActionButton = function (text, container) { return __awaiter(void 0, vo
|
|
|
24967
24997
|
});
|
|
24968
24998
|
}); };
|
|
24969
24999
|
|
|
24970
|
-
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, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, clickActionButton, clickMenuOption, clickMultiSelectOption, closeMenu, closePopover, convertDDToDMS, countRows, deselectRow, editCell, findActionButton, findCell, findCellContains, findMenuOption, findMultiSelectOption, findOpenPopover, findParentWithClass, findRow, fnOrVar, getMultiSelectOptions, hasParentClass, isCellReadOnly, isFloat, isNotEmpty, openAndClickMenuOption, openAndFindMenuOption, queryMenuOption, queryRow, selectCell, selectRow, stringByteLengthIsInvalid, suppressCellKeyboardEvents, typeInputByLabel, typeInputByPlaceholder, typeOnlyInput, typeOtherInput, typeOtherTextArea, useDeferredPromise, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, validateMenuOptions, wait$2 as wait };
|
|
25000
|
+
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, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, clickActionButton, clickMenuOption, clickMultiSelectOption, closeMenu, closePopover, convertDDToDMS, countRows, deselectRow, editCell, findActionButton, findCell, findCellContains, findMenuOption, findMultiSelectOption, findOpenPopover, findParentWithClass, findRow, fnOrVar, generateFilterGetter, getMultiSelectOptions, hasParentClass, isCellReadOnly, isFloat, isNotEmpty, openAndClickMenuOption, openAndFindMenuOption, queryMenuOption, queryRow, selectCell, selectRow, stringByteLengthIsInvalid, suppressCellKeyboardEvents, typeInputByLabel, typeInputByPlaceholder, typeOnlyInput, typeOtherInput, typeOtherTextArea, useDeferredPromise, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, validateMenuOptions, wait$2 as wait };
|
|
24971
25001
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|