@linzjs/step-ag-grid 8.4.0 → 8.4.2

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.
@@ -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> {
@@ -2995,7 +2995,7 @@ var GridIcon = function (props) {
2995
2995
  };
2996
2996
 
2997
2997
  var GridCellRenderer = function (props) {
2998
- var _a, _b, _c, _d;
2998
+ var _a, _b, _c;
2999
2999
  var checkUpdating = useContext(GridUpdatingContext).checkUpdating;
3000
3000
  var colDef = props.colDef;
3001
3001
  var rendererParams = colDef.cellRendererParams;
@@ -3007,7 +3007,7 @@ var GridCellRenderer = function (props) {
3007
3007
  warningText = warningText.join("\n");
3008
3008
  if (Array.isArray(infoText))
3009
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 === 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 })))] }) })));
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 })))] }) })));
3011
3011
  };
3012
3012
  var suppressCellKeyboardEvents = function (e) {
3013
3013
  var _a, _b, _c, _d;
@@ -3021,21 +3021,44 @@ var suppressCellKeyboardEvents = function (e) {
3021
3021
  // as the incorrect selected rows will be returned
3022
3022
  return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " ", "Home", "End", "PageUp", "PageDown"].includes(e.event.key);
3023
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
+ };
3024
3043
  /*
3025
3044
  * All cells should use this.
3026
3045
  */
3027
3046
  var GridCell = function (props, custom) {
3028
3047
  var _a, _b;
3029
- return __assign(__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) && {
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);
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) && {
3030
3054
  cellClassRules: GridCellMultiSelectClassRules,
3031
3055
  editable: (_b = props.editable) !== null && _b !== void 0 ? _b : true,
3032
3056
  cellEditor: GenericCellEditorComponentWrapper(custom === null || custom === void 0 ? void 0 : custom.editor)
3033
3057
  })), { suppressKeyboardEvent: suppressCellKeyboardEvents }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
3034
3058
  cellEditorParams: __assign(__assign({}, custom.editorParams), { multiEdit: custom.multiEdit })
3035
- })), (props.valueFormatter &&
3036
- !props.filterValueGetter && {
3037
- filterValueGetter: props.valueFormatter
3038
3059
  })), {
3060
+ // If there's a valueFormatter and no filterValueGetter then create a filterValueGetter
3061
+ filterValueGetter: filterValueGetter,
3039
3062
  // Default value formatter, otherwise react freaks out on objects
3040
3063
  valueFormatter: function (params) {
3041
3064
  if (params.value == null)
@@ -24974,5 +24997,5 @@ var clickActionButton = function (text, container) { return __awaiter(void 0, vo
24974
24997
  });
24975
24998
  }); };
24976
24999
 
24977
- 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 };
24978
25001
  //# sourceMappingURL=step-ag-grid.esm.js.map