@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.
- package/dist/src/components/Grid.d.ts +1 -1
- package/dist/step-ag-grid.cjs.js +26 -6
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +27 -7
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +2 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +46 -14
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +1 -1
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -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';
|
|
@@ -2320,7 +2320,7 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
|
|
|
2320
2320
|
/**
|
|
2321
2321
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2322
2322
|
*/
|
|
2323
|
-
const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, ...params }) => {
|
|
2323
|
+
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 }) => {
|
|
2324
2324
|
const { gridReady, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnCellEditingComplete, getColDef, } = useContext(GridContext);
|
|
2325
2325
|
const { checkUpdating, updatedDep, updatingCols } = useContext(GridUpdatingContext);
|
|
2326
2326
|
const { prePopupOps } = useContext(GridContext);
|
|
@@ -2734,7 +2734,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
2734
2734
|
const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
|
|
2735
2735
|
// This is setting a ref in the GridContext so won't be triggering an update loop
|
|
2736
2736
|
setOnCellEditingComplete(params.onCellEditingComplete);
|
|
2737
|
-
return (jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && autoSized && "Grid-ready"), children: [gridContextMenu.component, jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsx(AgGridReact, { rowHeight:
|
|
2737
|
+
return (jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && autoSized && "Grid-ready"), children: [gridContextMenu.component, jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsx(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: () => {
|
|
2738
2738
|
setInitialContentSize();
|
|
2739
2739
|
}, onRowDataUpdated: onRowDataChanged, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: { minWidth: 48, ...omit(params.defaultColDef, ["editable"]) }, columnDefs: columnDefsAdjusted, rowData: params.rowData, noRowsOverlayComponent: (event) => {
|
|
2740
2740
|
let rowCount = 0;
|
|
@@ -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
|
|
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 = (
|
|
3943
|
+
const MenuSubComponent = React.forwardRef(MenuSubComponentFr);
|
|
3944
|
+
function MenuSubComponentFr(props, ref) {
|
|
3937
3945
|
const { data, item, options, setOptions, subComponentIsValid, triggerSave } = props;
|
|
3938
|
-
|
|
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();
|