@linzjs/step-ag-grid 17.0.6 → 17.1.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.
@@ -67,4 +67,4 @@ export interface GridProps {
67
67
  /**
68
68
  * Wrapper for AgGrid to add commonly used functionality.
69
69
  */
70
- export declare const Grid: ({ "data-testid": dataTestId, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, ...params }: GridProps) => ReactElement;
70
+ export declare const Grid: ({ "data-testid": dataTestId, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, rowHeight, ...params }: GridProps) => ReactElement;
@@ -2341,7 +2341,7 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
2341
2341
  /**
2342
2342
  * Wrapper for AgGrid to add commonly used functionality.
2343
2343
  */
2344
- const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, ...params }) => {
2344
+ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, rowHeight = theme === "ag-theme-step-default" ? 40 : theme === "ag-theme-step-compact" ? 36 : undefined, ...params }) => {
2345
2345
  const { gridReady, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnCellEditingComplete, getColDef, } = React.useContext(GridContext);
2346
2346
  const { checkUpdating, updatedDep, updatingCols } = React.useContext(GridUpdatingContext);
2347
2347
  const { prePopupOps } = React.useContext(GridContext);
@@ -2755,7 +2755,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2755
2755
  const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
2756
2756
  // This is setting a ref in the GridContext so won't be triggering an update loop
2757
2757
  setOnCellEditingComplete(params.onCellEditingComplete);
2758
- return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && autoSized && "Grid-ready"), children: [gridContextMenu.component, jsxRuntime.jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsxRuntime.jsx(agGridReact.AgGridReact, { rowHeight: params.rowHeight, animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: (params) => `${params.data.id}`, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: () => {
2758
+ return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && autoSized && "Grid-ready"), children: [gridContextMenu.component, jsxRuntime.jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsxRuntime.jsx(agGridReact.AgGridReact, { rowHeight: rowHeight, animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: (params) => `${params.data.id}`, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: () => {
2759
2759
  setInitialContentSize();
2760
2760
  }, onRowDataUpdated: onRowDataChanged, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: { minWidth: 48, ...lodashEs.omit(params.defaultColDef, ["editable"]) }, columnDefs: columnDefsAdjusted, rowData: params.rowData, noRowsOverlayComponent: (event) => {
2761
2761
  let rowCount = 0;
@@ -3780,6 +3780,7 @@ const GridFormMultiSelect = (props) => {
3780
3780
  const { selectedRows, data } = useGridPopoverContext();
3781
3781
  const subComponentIsValidRef = React.useRef({});
3782
3782
  const optionsInitialising = React.useRef(false);
3783
+ const firstInputSubComponent = React.useRef(null);
3783
3784
  const [filter, setFilter] = React.useState("");
3784
3785
  const [initialValues, setInitialValues] = React.useState("");
3785
3786
  const [options, setOptions] = React.useState();
@@ -3855,7 +3856,12 @@ const GridFormMultiSelect = (props) => {
3855
3856
  return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, { loading: !options, className: "GridFormMultiSelect-container", children: options && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsx(FilterInput, { ...{ headerGroups, options, setOptions, filter, setFilter, triggerSave }, filterHelpText: props.filterHelpText, onSelectFilter: props.onSelectFilter, filterPlaceholder: props.filterPlaceholder })), headerGroups &&
3856
3857
  (lodashEs.isEmpty(headerGroups) || !lodashEs.toPairs(headerGroups).some(([_, options]) => !lodashEs.isEmpty(options))) && (jsxRuntime.jsx(MenuItem, { className: "GridMultiSelect-noOptions", disabled: true, children: props.noOptionsMessage ?? "No Options" }, "noOptions")), headerGroups && !lodashEs.isEmpty(headerGroups) && (jsxRuntime.jsx("div", { className: "GridFormMultiSelect-options", children: headers.map((header, index) => {
3857
3858
  const subOptions = headerGroups[`${header.filter}`];
3858
- return (!lodashEs.isEmpty(subOptions) && (jsxRuntime.jsxs(React.Fragment, { children: [header.header && jsxRuntime.jsx(MenuHeader, { children: header.header }), subOptions.map((item, index) => item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, `div_${index}`)) : (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(MenuRadioItem, { item: item, options: options, setOptions: setOptions }), item.checked && item.subComponent && (jsxRuntime.jsx(MenuSubComponent, { ...{ item, options, setOptions, data, triggerSave }, subComponentIsValid: subComponentIsValidRef.current }))] }, `val_${item.value}`)))] }, `group_${index}`)));
3859
+ return (!lodashEs.isEmpty(subOptions) && (jsxRuntime.jsxs(React.Fragment, { children: [header.header && jsxRuntime.jsx(MenuHeader, { children: header.header }), subOptions.map((item, index) => item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, `div_${index}`)) : (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(MenuRadioItem, { item: item, options: options, setOptions: setOptions, onChecked: () => {
3860
+ // Default to focus on first input in subComponent
3861
+ lodashEs.defer(() => {
3862
+ firstInputSubComponent.current?.focus();
3863
+ });
3864
+ } }), item.checked && item.subComponent && (jsxRuntime.jsx(MenuSubComponent, { ...{ item, options, setOptions, data, triggerSave }, ref: firstInputSubComponent, subComponentIsValid: subComponentIsValidRef.current }))] }, `val_${item.value}`)))] }, `group_${index}`)));
3859
3865
  }) }))] })) }));
3860
3866
  };
3861
3867
  const FilterInput = (props) => {
@@ -3944,6 +3950,7 @@ const MenuRadioItem = (props) => {
3944
3950
  e.keepOpen = true;
3945
3951
  toggleValue(item);
3946
3952
  }
3953
+ item.checked && props.onChecked && props.onChecked();
3947
3954
  }, children: jsxRuntime.jsx(lui.LuiCheckboxInput, { isChecked: item.checked ?? false, value: `${item.value}`, label: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.warning && jsxRuntime.jsx(GridIcon, { icon: "ic_warning_outline", title: item.warning }), item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)] }), inputProps: {
3948
3955
  onClick: (e) => {
3949
3956
  // Click is handled by MenuItem onClick
@@ -3954,9 +3961,22 @@ const MenuRadioItem = (props) => {
3954
3961
  /*Do nothing, change handled by menuItem*/
3955
3962
  } }) }));
3956
3963
  };
3957
- const MenuSubComponent = (props) => {
3964
+ const MenuSubComponent = React.forwardRef(MenuSubComponentFr);
3965
+ function MenuSubComponentFr(props, ref) {
3958
3966
  const { data, item, options, setOptions, subComponentIsValid, triggerSave } = props;
3959
- return (jsxRuntime.jsx(FocusableItem, { className: "LuiDeprecatedForms", children: () => (jsxRuntime.jsx(GridSubComponentContext.Provider, { value: {
3967
+ const focusableRef = React.useRef(null);
3968
+ React.useEffect(() => {
3969
+ if (focusableRef.current) {
3970
+ const firstInputElement = focusableRef.current.querySelectorAll("input")[0] ?? null;
3971
+ if (typeof ref === "function") {
3972
+ ref(firstInputElement);
3973
+ }
3974
+ else if (ref) {
3975
+ ref.current = firstInputElement;
3976
+ }
3977
+ }
3978
+ }, [ref]);
3979
+ return (jsxRuntime.jsx(FocusableItem, { className: "LuiDeprecatedForms", ref: focusableRef, children: () => (jsxRuntime.jsx(GridSubComponentContext.Provider, { value: {
3960
3980
  context: { options },
3961
3981
  data,
3962
3982
  value: item.subValue,
@@ -3969,7 +3989,7 @@ const MenuSubComponent = (props) => {
3969
3989
  },
3970
3990
  triggerSave,
3971
3991
  }, children: jsxRuntime.jsx("div", { className: "subComponent", children: item.subComponent && jsxRuntime.jsx(item.subComponent, {}) }) })) }, `${item.value}_subcomponent`));
3972
- };
3992
+ }
3973
3993
 
3974
3994
  const GridFormMultiSelectGrid = (props) => {
3975
3995
  const { selectedRows } = useGridPopoverContext();