@linzjs/step-ag-grid 27.0.0 → 27.2.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/GridCell.d.ts +0 -1
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +12 -10
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +1 -1
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +0 -1
- package/dist/src/contexts/GridContext.d.ts +1 -1
- package/dist/step-ag-grid.cjs +27 -22
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +27 -23
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +5 -3
- package/src/components/GridCell.tsx +0 -1
- package/src/components/gridForm/GridFormDropDown.tsx +27 -26
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +4 -4
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -4
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +1 -4
- package/src/components/gridRender/GridRenderGenericCell.tsx +0 -1
- package/src/contexts/GridContext.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +10 -1
- package/src/react-menu3/components/ControlledMenu.tsx +0 -1
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +21 -18
|
@@ -15,7 +15,6 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
|
|
|
15
15
|
valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
|
|
16
16
|
cellRenderer?: ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined) | string;
|
|
17
17
|
cellRendererParams?: {
|
|
18
|
-
singleClickEdit?: boolean;
|
|
19
18
|
rightHoverElement?: ReactElement;
|
|
20
19
|
originalCellRenderer?: any;
|
|
21
20
|
editAction?: (selectedRows: TData[]) => void;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { GridBaseRow } from '../Grid';
|
|
3
3
|
import { CellEditorCommon } from '../GridCell';
|
|
4
|
-
export interface GridPopoutEditDropDownSelectedItem<TData extends GridBaseRow,
|
|
4
|
+
export interface GridPopoutEditDropDownSelectedItem<TData extends GridBaseRow, TOption> {
|
|
5
5
|
selectedRows: TData[];
|
|
6
6
|
selectedRowIds: TData['id'][];
|
|
7
|
-
value:
|
|
7
|
+
value: TOption;
|
|
8
8
|
subComponentValue?: any;
|
|
9
9
|
}
|
|
10
|
-
interface FinalSelectOption {
|
|
11
|
-
value:
|
|
10
|
+
interface FinalSelectOption<TOptionValue> {
|
|
11
|
+
value: TOptionValue;
|
|
12
12
|
label?: ReactElement | string;
|
|
13
13
|
disabled?: boolean | string;
|
|
14
14
|
subComponent?: (props: any, ref: any) => any;
|
|
15
15
|
}
|
|
16
|
+
export declare const primitiveToSelectOption: <T>(value: T) => SelectOption<T>;
|
|
16
17
|
export declare const MenuSeparatorString = "_____MENU_SEPARATOR_____";
|
|
17
18
|
export declare const MenuSeparator: Readonly<{
|
|
18
19
|
value: "_____MENU_SEPARATOR_____";
|
|
@@ -22,17 +23,18 @@ export declare const MenuHeaderItem: (title: string) => {
|
|
|
22
23
|
label: string;
|
|
23
24
|
value: string;
|
|
24
25
|
};
|
|
25
|
-
export type SelectOption =
|
|
26
|
-
export
|
|
26
|
+
export type SelectOption<TOptionValue = any> = FinalSelectOption<TOptionValue>;
|
|
27
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
28
|
+
export interface GridFormDropDownProps<TData extends GridBaseRow, TOptionValue> extends CellEditorCommon {
|
|
27
29
|
className?: 'GridPopoverEditDropDown-containerSmall' | 'GridPopoverEditDropDown-containerMedium' | 'GridPopoverEditDropDown-containerLarge' | 'GridPopoverEditDropDown-containerUnlimited' | 'GridPopoverEditDropDown-containerAutoWidth' | string | undefined;
|
|
28
30
|
filtered?: 'local' | 'reload';
|
|
29
31
|
filterDefaultValue?: string;
|
|
30
32
|
filterPlaceholder?: string;
|
|
31
33
|
filterHelpText?: string;
|
|
32
34
|
noOptionsMessage?: string;
|
|
33
|
-
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<TData,
|
|
34
|
-
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<TData,
|
|
35
|
-
options:
|
|
35
|
+
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<TData, TOptionValue>) => Promise<void> | void;
|
|
36
|
+
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<TData, TOptionValue>) => Promise<void> | void;
|
|
37
|
+
options: FinalSelectOption<TOptionValue>[] | ((selectedRows: TData[], filter?: string) => MaybePromise<FinalSelectOption<TOptionValue>[] | undefined>) | undefined;
|
|
36
38
|
}
|
|
37
|
-
export declare const GridFormDropDown: <TData extends GridBaseRow,
|
|
39
|
+
export declare const GridFormDropDown: <TData extends GridBaseRow, TOptionValue>(props: GridFormDropDownProps<TData, TOptionValue>) => import("react/jsx-runtime").JSX.Element;
|
|
38
40
|
export {};
|
|
@@ -2,4 +2,4 @@ import { GridBaseRow } from '../Grid';
|
|
|
2
2
|
import { ColDefT, GenericCellEditorProps } from '../GridCell';
|
|
3
3
|
import { GridFormDropDownProps } from '../gridForm/GridFormDropDown';
|
|
4
4
|
import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
|
|
5
|
-
export declare const GridPopoverEditDropDown: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormDropDownProps<TData,
|
|
5
|
+
export declare const GridPopoverEditDropDown: <TData extends GridBaseRow, TValue = any, TOptionValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormDropDownProps<TData, TOptionValue>>) => ColDefT<TData, TValue>;
|
|
@@ -7,7 +7,6 @@ export interface GenericCellColDef<TData extends GridBaseRow, TValue = any> exte
|
|
|
7
7
|
exportable?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface GenericCellRendererParams<TData extends GridBaseRow> {
|
|
10
|
-
singleClickEdit?: boolean;
|
|
11
10
|
rightHoverElement?: ReactElement | undefined;
|
|
12
11
|
editAction?: (selectedRows: TData[]) => void;
|
|
13
12
|
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
@@ -17,7 +17,7 @@ export interface GridContextType<TData extends GridBaseRow> {
|
|
|
17
17
|
getColDef: (colId?: string) => ColDef | undefined;
|
|
18
18
|
getColumns: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => ColDefT<TData, any>[];
|
|
19
19
|
getColumnIds: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => string[];
|
|
20
|
-
setApis: (gridApi: GridApi | undefined, dataTestId?: string) => void;
|
|
20
|
+
setApis: (gridApi: GridApi | undefined, hasExternallySelectedItems: boolean, dataTestId?: string) => void;
|
|
21
21
|
prePopupOps: () => void;
|
|
22
22
|
postPopupOps: () => void;
|
|
23
23
|
setQuickFilter: (quickFilter: string) => void;
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2161,7 +2161,7 @@ const ControlledMenuFr = ({ 'aria-label': ariaLabel, className, containerProps,
|
|
|
2161
2161
|
block: menuContainerClass,
|
|
2162
2162
|
modifiers,
|
|
2163
2163
|
className,
|
|
2164
|
-
}), style: { ...containerProps?.style, position: 'relative' }, ref: containerRef, children: state && (jsxRuntime.jsx(SettingsContext.Provider, { value: settings, children: jsxRuntime.jsx(ItemSettingsContext.Provider, { value: itemSettings, children: jsxRuntime.jsx(EventHandlersContext.Provider, { value: eventHandlers, children: jsxRuntime.jsx(MenuList, { ...restProps, ariaLabel: ariaLabel || 'Menu', externalRef: externalRef, containerRef: containerRef, onClose: onClose
|
|
2164
|
+
}), style: { ...containerProps?.style, position: 'relative' }, ref: containerRef, children: state && (jsxRuntime.jsx(SettingsContext.Provider, { value: settings, children: jsxRuntime.jsx(ItemSettingsContext.Provider, { value: itemSettings, children: jsxRuntime.jsx(EventHandlersContext.Provider, { value: eventHandlers, children: jsxRuntime.jsx(MenuList, { ...restProps, ariaLabel: ariaLabel || 'Menu', externalRef: externalRef, containerRef: containerRef, onClose: onClose }) }) }) })) }));
|
|
2165
2165
|
if (portal === true && anchorRef?.current != null) {
|
|
2166
2166
|
if (hasParentClass('react-menu-inline-test', anchorRef.current)) {
|
|
2167
2167
|
portal = false;
|
|
@@ -2939,14 +2939,15 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2939
2939
|
};
|
|
2940
2940
|
});
|
|
2941
2941
|
}, [params.columnDefs, params.loading, params.readOnly, params.defaultColDef?.editable]);
|
|
2942
|
+
const hasExternallySelectedItems = !!params.setExternalSelectedItems;
|
|
2942
2943
|
/**
|
|
2943
2944
|
* When grid is ready set the apis to the grid context and sync selected items to grid.
|
|
2944
2945
|
*/
|
|
2945
2946
|
const onGridReady = React.useCallback((event) => {
|
|
2946
|
-
setApis(event.api, dataTestId);
|
|
2947
|
+
setApis(event.api, hasExternallySelectedItems, dataTestId);
|
|
2947
2948
|
event.api.showNoRowsOverlay();
|
|
2948
2949
|
synchroniseExternallySelectedItemsToGrid();
|
|
2949
|
-
}, [dataTestId, setApis, synchroniseExternallySelectedItemsToGrid]);
|
|
2950
|
+
}, [dataTestId, hasExternallySelectedItems, setApis, synchroniseExternallySelectedItemsToGrid]);
|
|
2950
2951
|
/**
|
|
2951
2952
|
* When the grid is being initialized the data may be empty.
|
|
2952
2953
|
* This will resize columns when we have at least one row.
|
|
@@ -2999,7 +3000,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2999
3000
|
* Handle single click edits
|
|
3000
3001
|
*/
|
|
3001
3002
|
const onCellClicked = React.useCallback((event) => {
|
|
3002
|
-
if (event.colDef
|
|
3003
|
+
if (event.colDef.singleClickEdit ?? singleClickEdit) {
|
|
3003
3004
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3004
3005
|
}
|
|
3005
3006
|
}, [singleClickEdit, startCellEditing]);
|
|
@@ -3946,6 +3947,12 @@ const useGridPopoverHook = (props) => {
|
|
|
3946
3947
|
};
|
|
3947
3948
|
};
|
|
3948
3949
|
|
|
3950
|
+
const primitiveToSelectOption = (value) => {
|
|
3951
|
+
return {
|
|
3952
|
+
value: value,
|
|
3953
|
+
label: value ? String(value) : '',
|
|
3954
|
+
};
|
|
3955
|
+
};
|
|
3949
3956
|
const MenuSeparatorString = '_____MENU_SEPARATOR_____';
|
|
3950
3957
|
const MenuSeparator = Object.freeze({ value: MenuSeparatorString });
|
|
3951
3958
|
const MenuHeaderString = '_____MENU_HEADER_____';
|
|
@@ -3994,14 +4001,7 @@ const GridFormDropDown = (props) => {
|
|
|
3994
4001
|
optionsConf = await optionsConf(selectedRows, filter);
|
|
3995
4002
|
}
|
|
3996
4003
|
if (optionsConf !== undefined) {
|
|
3997
|
-
|
|
3998
|
-
? {
|
|
3999
|
-
value: item,
|
|
4000
|
-
label: item,
|
|
4001
|
-
disabled: false,
|
|
4002
|
-
}
|
|
4003
|
-
: item);
|
|
4004
|
-
setOptions(optionsList);
|
|
4004
|
+
setOptions(optionsConf);
|
|
4005
4005
|
}
|
|
4006
4006
|
})();
|
|
4007
4007
|
}, [filter, options, props, selectedRows]);
|
|
@@ -4098,7 +4098,7 @@ const GridFormDropDown = (props) => {
|
|
|
4098
4098
|
}
|
|
4099
4099
|
}, onClick: (e) => {
|
|
4100
4100
|
e.keepOpen = !!item.subComponent;
|
|
4101
|
-
}, children: [item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`), item.subComponent ? '...' : ''] }, `${fieldToString(field)}-${index}`), item.subComponent && selectedItem === item && (jsxRuntime.jsx(FocusableItem, { className: 'LuiDeprecatedForms', children: () => (jsxRuntime.jsx(GridSubComponentContext.Provider, { value: {
|
|
4101
|
+
}, children: [item.label ?? (item.value == null ? `<${String(item.value)}>` : `${String(item.value)}`), item.subComponent ? '...' : ''] }, `${fieldToString(field)}-${index}`), item.subComponent && selectedItem === item && (jsxRuntime.jsx(FocusableItem, { className: 'LuiDeprecatedForms', children: () => (jsxRuntime.jsx(GridSubComponentContext.Provider, { value: {
|
|
4102
4102
|
context: { options },
|
|
4103
4103
|
data,
|
|
4104
4104
|
value: subSelectedValue,
|
|
@@ -4988,11 +4988,9 @@ const GridPopoverMenu = (colDef, custom) => GridCell({
|
|
|
4988
4988
|
exportable: false,
|
|
4989
4989
|
cellStyle: { flex: 1, justifyContent: 'center' },
|
|
4990
4990
|
cellRenderer: GridRenderPopoutMenuCell,
|
|
4991
|
+
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
4992
|
+
singleClickEdit: true,
|
|
4991
4993
|
...colDef,
|
|
4992
|
-
cellRendererParams: {
|
|
4993
|
-
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
4994
|
-
singleClickEdit: true,
|
|
4995
|
-
},
|
|
4996
4994
|
}, {
|
|
4997
4995
|
editor: GridFormPopoverMenu,
|
|
4998
4996
|
preventAutoEdit: true,
|
|
@@ -5002,10 +5000,7 @@ const GridPopoverMenu = (colDef, custom) => GridCell({
|
|
|
5002
5000
|
const GridPopoverMessage = (colDef, props) => GridCell({
|
|
5003
5001
|
resizable: true,
|
|
5004
5002
|
...colDef,
|
|
5005
|
-
|
|
5006
|
-
singleClickEdit: true,
|
|
5007
|
-
...colDef.cellRendererParams,
|
|
5008
|
-
},
|
|
5003
|
+
singleClickEdit: true,
|
|
5009
5004
|
}, {
|
|
5010
5005
|
editor: GridFormMessage,
|
|
5011
5006
|
...props,
|
|
@@ -5035,6 +5030,7 @@ const GridContextProvider = (props) => {
|
|
|
5035
5030
|
const [quickFilter, _setQuickFilter] = React.useState('');
|
|
5036
5031
|
const [invisibleColumnIds, _setInvisibleColumnIds] = React.useState();
|
|
5037
5032
|
const testId = React.useRef();
|
|
5033
|
+
const hasExternallySelectedItemsRef = React.useRef(false);
|
|
5038
5034
|
const idsBeforeUpdate = React.useRef([]);
|
|
5039
5035
|
const prePopupFocusedCell = React.useRef();
|
|
5040
5036
|
const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = React.useState(false);
|
|
@@ -5098,7 +5094,8 @@ const GridContextProvider = (props) => {
|
|
|
5098
5094
|
/**
|
|
5099
5095
|
* Set the grid api when the grid is ready.
|
|
5100
5096
|
*/
|
|
5101
|
-
const setApis = React.useCallback((gridApi, dataTestId) => {
|
|
5097
|
+
const setApis = React.useCallback((gridApi, hasExternallySelectedItems, dataTestId) => {
|
|
5098
|
+
hasExternallySelectedItemsRef.current = hasExternallySelectedItems;
|
|
5102
5099
|
testId.current = dataTestId;
|
|
5103
5100
|
setGridApi(gridApi);
|
|
5104
5101
|
gridApi?.setGridOption('quickFilterText', quickFilter);
|
|
@@ -5352,10 +5349,17 @@ const GridContextProvider = (props) => {
|
|
|
5352
5349
|
externallySelectedItemsAreInSyncRef.current = externallySelectedItemsAreInSync;
|
|
5353
5350
|
}, [externallySelectedItemsAreInSync]);
|
|
5354
5351
|
const waitForExternallySelectedItemsToBeInSync = React.useCallback(async () => {
|
|
5352
|
+
if (!hasExternallySelectedItemsRef.current) {
|
|
5353
|
+
externallySelectedItemsAreInSyncRef.current = true;
|
|
5354
|
+
return;
|
|
5355
|
+
}
|
|
5355
5356
|
// Wait for up to 5 seconds
|
|
5356
5357
|
for (let i = 0; i < 5000 / 200 && !externallySelectedItemsAreInSyncRef.current; i++) {
|
|
5357
5358
|
await wait(200);
|
|
5358
5359
|
}
|
|
5360
|
+
if (!externallySelectedItemsAreInSyncRef.current) {
|
|
5361
|
+
console.error('externallySelectedItems did not sync with ag-grid selection');
|
|
5362
|
+
}
|
|
5359
5363
|
}, []);
|
|
5360
5364
|
const startCellEditing = React.useCallback(async ({ rowId, colId }) => {
|
|
5361
5365
|
if (!gridApi)
|
|
@@ -5883,6 +5887,7 @@ exports.hasParentClass = hasParentClass;
|
|
|
5883
5887
|
exports.isFloat = isFloat;
|
|
5884
5888
|
exports.isGridCellFiller = isGridCellFiller;
|
|
5885
5889
|
exports.isNotEmpty = isNotEmpty;
|
|
5890
|
+
exports.primitiveToSelectOption = primitiveToSelectOption;
|
|
5886
5891
|
exports.sanitiseFileName = sanitiseFileName;
|
|
5887
5892
|
exports.stringByteLengthIsInvalid = stringByteLengthIsInvalid;
|
|
5888
5893
|
exports.suppressCellKeyboardEvents = suppressCellKeyboardEvents;
|