@linzjs/step-ag-grid 17.0.7 → 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.
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
2
  import { LuiMiniSpinner, LuiIcon, LuiButton, LuiCheckboxInput, LuiButtonGroup } from '@linzjs/lui';
3
3
  import { AgGridReact } from 'ag-grid-react';
4
4
  import { negate, isEmpty, findIndex, defer as defer$1, debounce as debounce$1, xorBy, last, difference, omit, sortBy, delay, partition, pick, groupBy, fromPairs, toPairs, isEqual, compact, filter, sumBy, pull, remove, castArray, flatten } from 'lodash-es';
5
- import { createContext, useContext, useRef, useEffect, useCallback, useState, useMemo, useLayoutEffect, memo, forwardRef, useReducer, cloneElement, useImperativeHandle, Fragment } from 'react';
5
+ import React, { createContext, useContext, useRef, useEffect, useCallback, useState, useMemo, useLayoutEffect, memo, forwardRef, useReducer, cloneElement, useImperativeHandle, Fragment } from 'react';
6
6
  import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
7
7
  import * as testUtils from 'react-dom/test-utils';
8
8
  import 'react-dom/client';
@@ -3759,6 +3759,7 @@ const GridFormMultiSelect = (props) => {
3759
3759
  const { selectedRows, data } = useGridPopoverContext();
3760
3760
  const subComponentIsValidRef = useRef({});
3761
3761
  const optionsInitialising = useRef(false);
3762
+ const firstInputSubComponent = useRef(null);
3762
3763
  const [filter, setFilter] = useState("");
3763
3764
  const [initialValues, setInitialValues] = useState("");
3764
3765
  const [options, setOptions] = useState();
@@ -3834,7 +3835,12 @@ const GridFormMultiSelect = (props) => {
3834
3835
  return popoverWrapper(jsx(ComponentLoadingWrapper, { loading: !options, className: "GridFormMultiSelect-container", children: options && (jsxs(Fragment$1, { children: [props.filtered && (jsx(FilterInput, { ...{ headerGroups, options, setOptions, filter, setFilter, triggerSave }, filterHelpText: props.filterHelpText, onSelectFilter: props.onSelectFilter, filterPlaceholder: props.filterPlaceholder })), headerGroups &&
3835
3836
  (isEmpty(headerGroups) || !toPairs(headerGroups).some(([_, options]) => !isEmpty(options))) && (jsx(MenuItem, { className: "GridMultiSelect-noOptions", disabled: true, children: props.noOptionsMessage ?? "No Options" }, "noOptions")), headerGroups && !isEmpty(headerGroups) && (jsx("div", { className: "GridFormMultiSelect-options", children: headers.map((header, index) => {
3836
3837
  const subOptions = headerGroups[`${header.filter}`];
3837
- return (!isEmpty(subOptions) && (jsxs(Fragment, { children: [header.header && jsx(MenuHeader, { children: header.header }), subOptions.map((item, index) => item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, `div_${index}`)) : (jsxs(Fragment, { children: [jsx(MenuRadioItem, { item: item, options: options, setOptions: setOptions }), item.checked && item.subComponent && (jsx(MenuSubComponent, { ...{ item, options, setOptions, data, triggerSave }, subComponentIsValid: subComponentIsValidRef.current }))] }, `val_${item.value}`)))] }, `group_${index}`)));
3838
+ return (!isEmpty(subOptions) && (jsxs(Fragment, { children: [header.header && jsx(MenuHeader, { children: header.header }), subOptions.map((item, index) => item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, `div_${index}`)) : (jsxs(Fragment, { children: [jsx(MenuRadioItem, { item: item, options: options, setOptions: setOptions, onChecked: () => {
3839
+ // Default to focus on first input in subComponent
3840
+ defer$1(() => {
3841
+ firstInputSubComponent.current?.focus();
3842
+ });
3843
+ } }), item.checked && item.subComponent && (jsx(MenuSubComponent, { ...{ item, options, setOptions, data, triggerSave }, ref: firstInputSubComponent, subComponentIsValid: subComponentIsValidRef.current }))] }, `val_${item.value}`)))] }, `group_${index}`)));
3838
3844
  }) }))] })) }));
3839
3845
  };
3840
3846
  const FilterInput = (props) => {
@@ -3923,6 +3929,7 @@ const MenuRadioItem = (props) => {
3923
3929
  e.keepOpen = true;
3924
3930
  toggleValue(item);
3925
3931
  }
3932
+ item.checked && props.onChecked && props.onChecked();
3926
3933
  }, children: jsx(LuiCheckboxInput, { isChecked: item.checked ?? false, value: `${item.value}`, label: jsxs(Fragment$1, { children: [item.warning && jsx(GridIcon, { icon: "ic_warning_outline", title: item.warning }), item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)] }), inputProps: {
3927
3934
  onClick: (e) => {
3928
3935
  // Click is handled by MenuItem onClick
@@ -3933,9 +3940,22 @@ const MenuRadioItem = (props) => {
3933
3940
  /*Do nothing, change handled by menuItem*/
3934
3941
  } }) }));
3935
3942
  };
3936
- const MenuSubComponent = (props) => {
3943
+ const MenuSubComponent = React.forwardRef(MenuSubComponentFr);
3944
+ function MenuSubComponentFr(props, ref) {
3937
3945
  const { data, item, options, setOptions, subComponentIsValid, triggerSave } = props;
3938
- return (jsx(FocusableItem, { className: "LuiDeprecatedForms", children: () => (jsx(GridSubComponentContext.Provider, { value: {
3946
+ const focusableRef = React.useRef(null);
3947
+ useEffect(() => {
3948
+ if (focusableRef.current) {
3949
+ const firstInputElement = focusableRef.current.querySelectorAll("input")[0] ?? null;
3950
+ if (typeof ref === "function") {
3951
+ ref(firstInputElement);
3952
+ }
3953
+ else if (ref) {
3954
+ ref.current = firstInputElement;
3955
+ }
3956
+ }
3957
+ }, [ref]);
3958
+ return (jsx(FocusableItem, { className: "LuiDeprecatedForms", ref: focusableRef, children: () => (jsx(GridSubComponentContext.Provider, { value: {
3939
3959
  context: { options },
3940
3960
  data,
3941
3961
  value: item.subValue,
@@ -3948,7 +3968,7 @@ const MenuSubComponent = (props) => {
3948
3968
  },
3949
3969
  triggerSave,
3950
3970
  }, children: jsx("div", { className: "subComponent", children: item.subComponent && jsx(item.subComponent, {}) }) })) }, `${item.value}_subcomponent`));
3951
- };
3971
+ }
3952
3972
 
3953
3973
  const GridFormMultiSelectGrid = (props) => {
3954
3974
  const { selectedRows } = useGridPopoverContext();