@linzjs/step-ag-grid 29.3.6 → 29.5.0

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,4 +1,4 @@
1
- import { ColDef, GridOptions, RowClickedEvent, RowDoubleClickedEvent } from 'ag-grid-community';
1
+ import { ColDef, ColGroupDef, GridOptions, RowClickedEvent, RowDoubleClickedEvent } from 'ag-grid-community';
2
2
  import { ReactElement } from 'react';
3
3
  import { GridContextMenuComponent } from './gridHook';
4
4
  export interface GridBaseRow {
@@ -22,7 +22,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
22
22
  externalSelectedItems?: any[];
23
23
  setExternalSelectedItems?: (items: any[]) => void;
24
24
  defaultColDef?: GridOptions['defaultColDef'];
25
- columnDefs: ColDef<TData>[];
25
+ columnDefs: ColDef<TData>[] | ColGroupDef<TData>[];
26
26
  rowData: GridOptions['rowData'];
27
27
  selectColumnPinned?: ColDef['pinned'];
28
28
  noRowsOverlayText?: string;
@@ -41,6 +41,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
41
41
  onRowDragEnd?: (props: GridOnRowDragEndProps<TData>) => Promise<void> | void;
42
42
  alwaysShowVerticalScroll?: boolean;
43
43
  suppressColumnVirtualization?: GridOptions['suppressColumnVirtualisation'];
44
+ suppressReadOnlyStyle?: boolean;
44
45
  /**
45
46
  * When the grid is rendered using sizeColumns=="auto" this is called initially with the required container size to fit all content.
46
47
  * This allows you set the size of the panel to fit perfectly.
@@ -92,4 +93,4 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
92
93
  /**
93
94
  * Wrapper for AgGrid to add commonly used functionality.
94
95
  */
95
- export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, onCellFocused: paramsOnCellFocused, maxInitialWidth, ...params }: GridProps<TData>) => ReactElement;
96
+ export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, onCellFocused: paramsOnCellFocused, maxInitialWidth, suppressReadOnlyStyle, ...params }: GridProps<TData>) => ReactElement;
@@ -35,6 +35,7 @@ export interface GridFormDropDownProps<TData extends GridBaseRow, TOptionValue>
35
35
  onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<TData, TOptionValue>) => Promise<void> | void;
36
36
  onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<TData, TOptionValue>) => Promise<void> | void;
37
37
  options: FinalSelectOption<TOptionValue>[] | ((selectedRows: TData[], filter?: string) => MaybePromise<FinalSelectOption<TOptionValue>[] | undefined>) | undefined;
38
+ topComponent?: () => ReactElement;
38
39
  }
39
40
  export declare const GridFormDropDown: <TData extends GridBaseRow, TOptionValue>(props: GridFormDropDownProps<TData, TOptionValue>) => import("react/jsx-runtime").JSX.Element;
40
41
  export {};
@@ -2762,7 +2762,7 @@ agGridCommunity.ModuleRegistry.registerModules([agGridCommunity.AllCommunityModu
2762
2762
  /**
2763
2763
  * Wrapper for AgGrid to add commonly used functionality.
2764
2764
  */
2765
- const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection = 'multiple', suppressColumnVirtualization = true, theme = 'ag-theme-step-default', sizeColumns = 'auto', selectColumnPinned = 'left', contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40, selectable, onCellFocused: paramsOnCellFocused, maxInitialWidth, ...params }) => {
2765
+ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection = 'multiple', suppressColumnVirtualization = true, theme = 'ag-theme-step-default', sizeColumns = 'auto', selectColumnPinned = 'left', contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40, selectable, onCellFocused: paramsOnCellFocused, maxInitialWidth, suppressReadOnlyStyle = false, ...params }) => {
2766
2766
  const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing: propStartCellEditing, } = useGridContext();
2767
2767
  // CellEditingStop event happens too much for one edit
2768
2768
  const startedEditRef = React.useRef(false);
@@ -2968,11 +2968,14 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2968
2968
  * Synchronise externally selected items to grid on externalSelectedItems change
2969
2969
  */
2970
2970
  React.useEffect(synchroniseExternallySelectedItemsToGrid, [synchroniseExternallySelectedItemsToGrid]);
2971
- /**
2972
- * Add selectable column to colDefs. Adjust column defs to block fit for auto sized columns.
2973
- */
2974
- const columnDefs = React.useMemo(() => {
2975
- return params.columnDefs.map((colDef) => {
2971
+ const mapColDef = React.useCallback((colDef) => {
2972
+ if ('children' in colDef) {
2973
+ return {
2974
+ ...colDef,
2975
+ children: colDef.children.map(mapColDef),
2976
+ };
2977
+ }
2978
+ else {
2976
2979
  const colDefEditable = colDef.editable;
2977
2980
  const editable = combineEditables(params.loading !== true && params.readOnly !== true, params.defaultColDef?.editable, colDefEditable);
2978
2981
  return {
@@ -2980,11 +2983,17 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2980
2983
  editable,
2981
2984
  cellClassRules: {
2982
2985
  ...colDef.cellClassRules,
2983
- 'GridCell-readonly': (ccp) => !editable(ccp),
2986
+ 'GridCell-readonly': (ccp) => !suppressReadOnlyStyle && !editable(ccp),
2984
2987
  },
2985
2988
  };
2986
- });
2987
- }, [params.columnDefs, params.loading, params.readOnly, params.defaultColDef?.editable]);
2989
+ }
2990
+ }, [params.defaultColDef?.editable, params.loading, params.readOnly, suppressReadOnlyStyle]);
2991
+ /**
2992
+ * Add selectable column to colDefs. Adjust column defs to block fit for auto sized columns.
2993
+ */
2994
+ const columnDefs = React.useMemo(() => {
2995
+ return params.columnDefs.map(mapColDef);
2996
+ }, [params.columnDefs, mapColDef]);
2988
2997
  const hasExternallySelectedItems = !!params.setExternalSelectedItems;
2989
2998
  /**
2990
2999
  * When grid is ready set the apis to the grid context and sync selected items to grid.
@@ -4249,7 +4258,7 @@ const GridFormDropDown = (props) => {
4249
4258
  setSubSelectedValue(null);
4250
4259
  subComponentIsValid.current = true;
4251
4260
  }, children: ({ ref }) => (jsxRuntime.jsxs("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: [jsxRuntime.jsx("input", { className: 'LuiTextInput-input', ref: ref, type: "text", placeholder: props.filterPlaceholder ?? 'Filter...', "data-testid": 'filteredMenu-free-text-input', defaultValue: filter, "data-allowtabtosave": true, "data-disableenterautosave": !props.onSelectFilter &&
4252
- !(filteredValues && filteredValues.length === 1 && !filteredValues[0].subComponent), onChange: (e) => setFilter(e.target.value.trim()) }), props.filterHelpText && isNotEmpty(filter) && (jsxRuntime.jsx(FormError, { error: null, helpText: props.filterHelpText }))] })) }), jsxRuntime.jsx(MenuDivider, {}, `$$divider_filter`)] })), jsxRuntime.jsx(ComponentLoadingWrapper, { loading: !options, className: 'GridFormDropDown-options', children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && (lodashEs.isEmpty(options) || (filteredValues && lodashEs.isEmpty(filteredValues))) && (jsxRuntime.jsx(MenuItem, { className: 'GridPopoverEditDropDown-noOptions', disabled: true, children: props.noOptionsMessage ?? 'No Options' }, `${fieldToString(field)}-empty`)), options?.map((item, index) => {
4261
+ !(filteredValues && filteredValues.length === 1 && !filteredValues[0].subComponent), onChange: (e) => setFilter(e.target.value.trim()) }), props.filterHelpText && isNotEmpty(filter) && (jsxRuntime.jsx(FormError, { error: null, helpText: props.filterHelpText }))] })) }), jsxRuntime.jsx(MenuDivider, {}, `$$divider_filter`), props.topComponent && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(props.topComponent, {}), jsxRuntime.jsx(MenuDivider, {}, `$$divider_filter`)] }))] })), jsxRuntime.jsx(ComponentLoadingWrapper, { loading: !options, className: 'GridFormDropDown-options', children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && (lodashEs.isEmpty(options) || (filteredValues && lodashEs.isEmpty(filteredValues))) && (jsxRuntime.jsx(MenuItem, { className: 'GridPopoverEditDropDown-noOptions', disabled: true, children: props.noOptionsMessage ?? 'No Options' }, `${fieldToString(field)}-empty`)), options?.map((item, index) => {
4253
4262
  showHeader = null;
4254
4263
  if (item.value === MenuSeparatorString) {
4255
4264
  return jsxRuntime.jsx(MenuDivider, {}, `$$divider_${index}`);