@linzjs/step-ag-grid 20.0.0 → 21.0.1
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/index.css +3 -4
- package/dist/src/components/ComponentLoadingWrapper.d.ts +9 -9
- package/dist/src/components/Grid.d.ts +80 -80
- package/dist/src/components/GridCell.d.ts +63 -27
- package/dist/src/components/GridCell.test.d.ts +1 -1
- package/dist/src/components/GridCellFiller.d.ts +5 -4
- package/dist/src/components/GridCellMultiEditor.d.ts +18 -18
- package/dist/src/components/GridCellMultiSelectClassRules.d.ts +2 -2
- package/dist/src/components/GridIcon.d.ts +9 -9
- package/dist/src/components/GridLoadableCell.d.ts +1 -1
- package/dist/src/components/GridNoRowsOverlay.d.ts +9 -9
- package/dist/src/components/GridPopoverHook.d.ts +12 -12
- package/dist/src/components/GridWrapper.d.ts +5 -5
- package/dist/src/components/PostSortRowsHook.d.ts +11 -11
- package/dist/src/components/gridFilter/GridFilterButtons.d.ts +16 -16
- package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +5 -5
- package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +2 -2
- package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +11 -11
- package/dist/src/components/gridFilter/GridFilterQuick.d.ts +5 -5
- package/dist/src/components/gridFilter/GridFilters.d.ts +2 -2
- package/dist/src/components/gridFilter/index.d.ts +7 -7
- package/dist/src/components/gridFilter/useGridFilter.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +37 -37
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +12 -12
- package/dist/src/components/gridForm/GridFormMessage.d.ts +7 -7
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +36 -36
- package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +24 -24
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +36 -36
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +12 -12
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +11 -11
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +14 -14
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +14 -14
- package/dist/src/components/gridForm/index.d.ts +10 -10
- package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +7 -7
- package/dist/src/components/gridHeader/index.d.ts +1 -1
- package/dist/src/components/gridHook/index.d.ts +1 -1
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +19 -19
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +16 -16
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +8 -8
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/index.d.ts +9 -9
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +16 -37
- package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +2 -2
- package/dist/src/components/gridRender/index.d.ts +2 -2
- package/dist/src/components/gridUtil.d.ts +3 -3
- package/dist/src/components/index.d.ts +18 -18
- package/dist/src/contexts/GridContext.d.ts +67 -67
- package/dist/src/contexts/GridContextProvider.d.ts +15 -15
- package/dist/src/contexts/GridContextProvider.test.d.ts +1 -1
- package/dist/src/contexts/GridPopoverContext.d.ts +15 -15
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +7 -7
- package/dist/src/contexts/GridSubComponentContext.d.ts +10 -10
- package/dist/src/contexts/GridUpdatingContext.d.ts +8 -8
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +3 -3
- package/dist/src/index.d.ts +17 -17
- package/dist/src/lui/ActionButton.d.ts +20 -20
- package/dist/src/lui/FormError.d.ts +7 -7
- package/dist/src/lui/TextAreaInput.d.ts +11 -11
- package/dist/src/lui/TextInputFormatted.d.ts +10 -10
- package/dist/src/lui/reactUtils.d.ts +6 -6
- package/dist/src/lui/reactUtils.test.d.ts +1 -1
- package/dist/src/lui/stateDeferredHook.d.ts +4 -4
- package/dist/src/lui/timeoutHook.d.ts +14 -14
- package/dist/src/lui/timeoutHook.test.d.ts +1 -1
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -8
- package/dist/src/react-menu3/components/FocusableItem.d.ts +9 -9
- package/dist/src/react-menu3/components/Menu.d.ts +16 -16
- package/dist/src/react-menu3/components/MenuButton.d.ts +8 -8
- package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -12
- package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -4
- package/dist/src/react-menu3/components/MenuItem.d.ts +59 -59
- package/dist/src/react-menu3/components/MenuList.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +25 -25
- package/dist/src/react-menu3/components/SubMenu.d.ts +110 -110
- package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -7
- package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -2
- package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -5
- package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -9
- package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -11
- package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -7
- package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -20
- package/dist/src/react-menu3/hooks/index.d.ts +9 -9
- package/dist/src/react-menu3/hooks/useBEM.d.ts +10 -10
- package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +3 -3
- package/dist/src/react-menu3/hooks/useItemEffect.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useItemState.d.ts +7 -7
- package/dist/src/react-menu3/hooks/useItems.d.ts +7 -7
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +23 -14
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -2
- package/dist/src/react-menu3/index.d.ts +11 -11
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +11 -11
- package/dist/src/react-menu3/positionUtils/index.d.ts +3 -3
- package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +8 -8
- package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +8 -8
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +19 -19
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +19 -19
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +13 -13
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +26 -26
- package/dist/src/react-menu3/style-utils/index.d.ts +11 -11
- package/dist/src/react-menu3/types.d.ts +401 -401
- package/dist/src/react-menu3/utils/constants.d.ts +54 -54
- package/dist/src/react-menu3/utils/index.d.ts +3 -3
- package/dist/src/react-menu3/utils/propTypes2.d.ts +56 -56
- package/dist/src/react-menu3/utils/utils.d.ts +37 -37
- package/dist/src/react-menu3/utils/withHovering.d.ts +7 -7
- package/dist/src/utils/bearing.d.ts +19 -19
- package/dist/src/utils/bearing.test.d.ts +1 -1
- package/dist/src/utils/deferredPromise.d.ts +5 -5
- package/dist/src/utils/storybookTestUtil.d.ts +3 -3
- package/dist/src/utils/testQuick.d.ts +62 -62
- package/dist/src/utils/testUtil.d.ts +46 -45
- package/dist/src/utils/textMatcher.d.ts +13 -13
- package/dist/src/utils/textMatcher.test.d.ts +1 -1
- package/dist/src/utils/textValidator.d.ts +18 -18
- package/dist/src/utils/textValidator.test.d.ts +1 -1
- package/dist/src/utils/util.d.ts +8 -8
- package/dist/src/utils/util.test.d.ts +1 -1
- package/dist/step-ag-grid.cjs.js +4651 -4651
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +4651 -4651
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/dist/vite.config.d.ts +2 -0
- package/package.json +23 -22
- package/src/components/Grid.tsx +10 -9
- package/src/components/GridCell.test.tsx +2 -3
- package/src/components/GridCell.tsx +75 -23
- package/src/components/GridCellFiller.tsx +2 -1
- package/src/components/GridCellMultiEditor.tsx +9 -9
- package/src/components/GridCellMultiSelectClassRules.tsx +4 -4
- package/src/components/GridPopoverHook.tsx +4 -4
- package/src/components/PostSortRowsHook.ts +7 -7
- package/src/components/gridFilter/GridFilterButtons.tsx +6 -6
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +2 -5
- package/src/components/gridFilter/GridFilterDownloadCsvButton.tsx +1 -1
- package/src/components/gridFilter/useGridFilter.ts +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +9 -9
- package/src/components/gridForm/GridFormEditBearing.tsx +5 -5
- package/src/components/gridForm/GridFormMessage.tsx +4 -4
- package/src/components/gridForm/GridFormMultiSelect.tsx +9 -9
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +11 -11
- package/src/components/gridForm/GridFormPopoverMenu.tsx +13 -13
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +4 -4
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +4 -4
- package/src/components/gridForm/GridFormTextArea.tsx +6 -6
- package/src/components/gridForm/GridFormTextInput.tsx +7 -7
- package/src/components/gridHeader/GridHeaderSelect.tsx +10 -8
- package/src/components/gridHook/useGridContextMenu.tsx +8 -8
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +6 -6
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +6 -6
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +16 -16
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +6 -6
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +5 -5
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +5 -5
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +5 -4
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +5 -5
- package/src/components/gridRender/GridRenderGenericCell.tsx +6 -36
- package/src/contexts/GridContext.tsx +9 -9
- package/src/contexts/GridContextProvider.test.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +32 -36
- package/src/contexts/GridPopoverContext.tsx +6 -6
- package/src/stories/grid/GridDragRow.stories.tsx +13 -7
- package/src/stories/grid/GridNonEditableRow.stories.tsx +2 -3
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +2 -2
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +1 -1
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +2 -2
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +12 -3
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +2 -2
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +2 -2
- package/src/stories/grid/GridReadOnly.stories.tsx +6 -6
- package/src/stories/grid/GridViewList.stories.tsx +5 -7
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +3 -3
- package/src/styles/Grid.scss +3 -6
- package/src/utils/testUtil.ts +49 -7
- package/src/utils/textValidator.ts +5 -5
- package/src/utils/util.ts +1 -1
|
@@ -1,49 +1,19 @@
|
|
|
1
1
|
import { ICellRendererParams } from "ag-grid-community";
|
|
2
|
-
import {
|
|
3
|
-
EditableCallbackParams,
|
|
4
|
-
SuppressKeyboardEventParams,
|
|
5
|
-
ValueFormatterParams,
|
|
6
|
-
ValueGetterParams,
|
|
7
|
-
} from "ag-grid-community/dist/lib/entities/colDef";
|
|
2
|
+
import { SuppressKeyboardEventParams } from "ag-grid-community";
|
|
8
3
|
import { ReactElement } from "react";
|
|
9
4
|
|
|
10
5
|
import { GridBaseRow } from "../Grid";
|
|
11
6
|
import { ColDefT } from "../GridCell";
|
|
12
7
|
|
|
13
|
-
export interface
|
|
14
|
-
data: RowType;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface RowEditableCallbackParams<RowType extends GridBaseRow> extends EditableCallbackParams {
|
|
18
|
-
data: RowType;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface RowValueFormatterParams<RowType extends GridBaseRow> extends ValueFormatterParams {
|
|
22
|
-
data: RowType;
|
|
23
|
-
}
|
|
24
|
-
export interface RowValueGetterParams<RowType extends GridBaseRow> extends ValueGetterParams {
|
|
25
|
-
data: RowType;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface RowValueGetterParams<RowType extends GridBaseRow> extends ValueGetterParams {
|
|
29
|
-
data: RowType;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<RowType> {
|
|
33
|
-
cellRenderer?: (params: RowICellRendererParams<RowType>) => any;
|
|
34
|
-
cellRendererParams?: GenericCellRendererParams<RowType>;
|
|
35
|
-
valueGetter?: string | ((params: RowValueGetterParams<RowType>) => any);
|
|
36
|
-
valueFormatter?: string | ((params: RowValueFormatterParams<RowType>) => string);
|
|
37
|
-
filterValueGetter?: string | ((params: RowValueGetterParams<RowType>) => string);
|
|
38
|
-
editable?: boolean | ((params: RowEditableCallbackParams<RowType>) => boolean);
|
|
8
|
+
export interface GenericCellColDef<TData extends GridBaseRow, TValue = any> extends ColDefT<TData, TValue> {
|
|
39
9
|
exportable?: boolean;
|
|
40
10
|
}
|
|
41
11
|
|
|
42
|
-
export interface GenericCellRendererParams<
|
|
12
|
+
export interface GenericCellRendererParams<TData extends GridBaseRow> {
|
|
43
13
|
singleClickEdit?: boolean;
|
|
44
14
|
rightHoverElement?: ReactElement | undefined;
|
|
45
|
-
editAction?: (selectedRows:
|
|
15
|
+
editAction?: (selectedRows: TData[]) => void;
|
|
46
16
|
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
47
|
-
warning?: (props:
|
|
48
|
-
info?: (props:
|
|
17
|
+
warning?: (props: ICellRendererParams<TData>) => string | string[] | boolean | null | undefined;
|
|
18
|
+
info?: (props: ICellRendererParams<TData>) => string | string[] | boolean | null | undefined;
|
|
49
19
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ColDef,
|
|
2
|
-
import { CsvExportParams } from "ag-grid-community
|
|
1
|
+
import { ColDef, GridApi, IRowNode } from "ag-grid-community";
|
|
2
|
+
import { CsvExportParams } from "ag-grid-community";
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
4
|
|
|
5
5
|
import { ColDefT, GridBaseRow } from "../components";
|
|
6
6
|
|
|
7
|
-
export type GridFilterExternal<
|
|
7
|
+
export type GridFilterExternal<TData extends GridBaseRow> = (data: TData, rowNode: IRowNode) => boolean;
|
|
8
8
|
|
|
9
9
|
export interface AutoSizeColumnsProps {
|
|
10
10
|
skipHeader?: boolean;
|
|
@@ -15,15 +15,15 @@ export interface AutoSizeColumnsProps {
|
|
|
15
15
|
|
|
16
16
|
export type AutoSizeColumnsResult = { width: number } | null;
|
|
17
17
|
|
|
18
|
-
export interface GridContextType<
|
|
18
|
+
export interface GridContextType<TData extends GridBaseRow> {
|
|
19
19
|
gridReady: boolean;
|
|
20
20
|
gridRenderState: () => null | "empty" | "rows-visible";
|
|
21
21
|
getColDef: (colId?: string) => ColDef | undefined;
|
|
22
22
|
getColumns: (
|
|
23
23
|
filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string),
|
|
24
|
-
) => ColDefT<
|
|
24
|
+
) => ColDefT<TData, any>[];
|
|
25
25
|
getColumnIds: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => string[];
|
|
26
|
-
setApis: (gridApi: GridApi | undefined,
|
|
26
|
+
setApis: (gridApi: GridApi | undefined, dataTestId?: string) => void;
|
|
27
27
|
prePopupOps: () => void;
|
|
28
28
|
postPopupOps: () => void;
|
|
29
29
|
setQuickFilter: (quickFilter: string) => void;
|
|
@@ -57,8 +57,8 @@ export interface GridContextType<RowType extends GridBaseRow> {
|
|
|
57
57
|
externallySelectedItemsAreInSync: boolean;
|
|
58
58
|
setExternallySelectedItemsAreInSync: (inSync: boolean) => void;
|
|
59
59
|
waitForExternallySelectedItemsToBeInSync: () => Promise<void>;
|
|
60
|
-
addExternalFilter: (filter: GridFilterExternal<
|
|
61
|
-
removeExternalFilter: (filter: GridFilterExternal<
|
|
60
|
+
addExternalFilter: (filter: GridFilterExternal<TData>) => void;
|
|
61
|
+
removeExternalFilter: (filter: GridFilterExternal<TData>) => void;
|
|
62
62
|
isExternalFilterPresent: () => boolean;
|
|
63
63
|
doesExternalFilterPass: (node: IRowNode) => boolean;
|
|
64
64
|
invisibleColumnIds: string[] | undefined;
|
|
@@ -207,4 +207,4 @@ export const GridContext = createContext<GridContextType<any>>({
|
|
|
207
207
|
},
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
export const useGridContext = <
|
|
210
|
+
export const useGridContext = <TData extends GridBaseRow>() => useContext<GridContextType<TData>>(GridContext);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { CellPosition, ColDef,
|
|
2
|
-
import {
|
|
3
|
-
import { CsvExportParams, ProcessCellForExportParams } from "ag-grid-community/dist/lib/interfaces/exportParams";
|
|
1
|
+
import { CellPosition, ColDef, GridApi, IRowNode, RowNode } from "ag-grid-community";
|
|
2
|
+
import { CsvExportParams, ProcessCellForExportParams } from "ag-grid-community";
|
|
4
3
|
import debounce from "debounce-promise";
|
|
5
4
|
import { compact, defer, delay, difference, filter, isEmpty, last, pull, remove, sortBy, sumBy } from "lodash-es";
|
|
6
5
|
import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -8,7 +7,7 @@ import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, us
|
|
|
8
7
|
import { ColDefT, GridBaseRow } from "../components";
|
|
9
8
|
import { GridCellFillerColId, isGridCellFiller } from "../components/GridCellFiller";
|
|
10
9
|
import { getColId, isFlexColumn } from "../components/gridUtil";
|
|
11
|
-
import { isNotEmpty, sanitiseFileName, wait } from "../utils/util";
|
|
10
|
+
import { fnOrVar, isNotEmpty, sanitiseFileName, wait } from "../utils/util";
|
|
12
11
|
import { AutoSizeColumnsProps, AutoSizeColumnsResult, GridContext, GridFilterExternal } from "./GridContext";
|
|
13
12
|
import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
14
13
|
|
|
@@ -17,10 +16,9 @@ import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
|
17
16
|
* Make sure you wrap AgGrid in this.
|
|
18
17
|
* Also, make sure the provider is created in a separate component, otherwise it won't be found.
|
|
19
18
|
*/
|
|
20
|
-
export const GridContextProvider = <
|
|
19
|
+
export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithChildren): ReactElement => {
|
|
21
20
|
const { modifyUpdating, checkUpdating } = useContext(GridUpdatingContext);
|
|
22
21
|
const [gridApi, setGridApi] = useState<GridApi>();
|
|
23
|
-
const [columnApi, setColumnApi] = useState<ColumnApi>();
|
|
24
22
|
const [gridReady, setGridReady] = useState(false);
|
|
25
23
|
const [quickFilter, setQuickFilter] = useState("");
|
|
26
24
|
const [invisibleColumnIds, _setInvisibleColumnIds] = useState<string[]>();
|
|
@@ -28,7 +26,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
28
26
|
const idsBeforeUpdate = useRef<number[]>([]);
|
|
29
27
|
const prePopupFocusedCell = useRef<CellPosition>();
|
|
30
28
|
const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = useState(false);
|
|
31
|
-
const externalFilters = useRef<GridFilterExternal<
|
|
29
|
+
const externalFilters = useRef<GridFilterExternal<TData>[]>([]);
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
* Make extra sure the GridCellFillerColId never gets added to invisibleColumnIds as it's dynamically determined
|
|
@@ -40,7 +38,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
40
38
|
* Set quick filter directly on grid, based on previously save quickFilter state.
|
|
41
39
|
*/
|
|
42
40
|
useEffect(() => {
|
|
43
|
-
gridApi?.
|
|
41
|
+
gridApi?.setGridOption("quickFilterText", quickFilter);
|
|
44
42
|
}, [gridApi, quickFilter]);
|
|
45
43
|
|
|
46
44
|
/**
|
|
@@ -94,11 +92,10 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
94
92
|
* Set the grid api when the grid is ready.
|
|
95
93
|
*/
|
|
96
94
|
const setApis = useCallback(
|
|
97
|
-
(gridApi: GridApi | undefined,
|
|
95
|
+
(gridApi: GridApi | undefined, dataTestId?: string) => {
|
|
98
96
|
testId.current = dataTestId;
|
|
99
97
|
setGridApi(gridApi);
|
|
100
|
-
|
|
101
|
-
gridApi?.setQuickFilter(quickFilter);
|
|
98
|
+
gridApi?.setGridOption("quickFilterText", quickFilter);
|
|
102
99
|
setGridReady(!!gridApi);
|
|
103
100
|
},
|
|
104
101
|
[quickFilter],
|
|
@@ -108,9 +105,8 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
108
105
|
* Used to check if it's OK to autosize.
|
|
109
106
|
*/
|
|
110
107
|
const gridRenderState = useCallback((): null | "empty" | "rows-visible" => {
|
|
111
|
-
|
|
112
|
-
if (!gridApi
|
|
113
|
-
if (!gridApi.getModel().isRowsToRender()) return "empty";
|
|
108
|
+
if (!gridApi) return null;
|
|
109
|
+
if (!gridApi.getDisplayedRowCount()) return "empty";
|
|
114
110
|
if (!isEmpty(gridApi.getRenderedNodes())) return "rows-visible";
|
|
115
111
|
// If there are rows to render, but there are no rendered nodes then we should wait
|
|
116
112
|
return null;
|
|
@@ -204,9 +200,9 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
204
200
|
const getColumns = useCallback(
|
|
205
201
|
(
|
|
206
202
|
filterDef: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string) = () => true,
|
|
207
|
-
): ColDefT<
|
|
208
|
-
filter(
|
|
209
|
-
[
|
|
203
|
+
): ColDefT<TData>[] =>
|
|
204
|
+
filter(gridApi?.getColumns()?.map((col) => col.getColDef()) ?? [], filterDef) as ColDefT<TData>[],
|
|
205
|
+
[gridApi],
|
|
210
206
|
);
|
|
211
207
|
|
|
212
208
|
const getColumnIds = useCallback(
|
|
@@ -407,9 +403,9 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
407
403
|
*/
|
|
408
404
|
const autoSizeColumns = useCallback(
|
|
409
405
|
({ skipHeader, colIds, userSizedColIds, includeFlex }: AutoSizeColumnsProps = {}): AutoSizeColumnsResult => {
|
|
410
|
-
if (!
|
|
406
|
+
if (!gridApi) return null;
|
|
411
407
|
const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
|
|
412
|
-
const colsToResize =
|
|
408
|
+
const colsToResize = gridApi.getColumnState().filter((colState) => {
|
|
413
409
|
const colId = colState.colId;
|
|
414
410
|
return (
|
|
415
411
|
(isEmpty(colIdsSet) || colIdsSet.has(colId)) &&
|
|
@@ -418,19 +414,19 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
418
414
|
);
|
|
419
415
|
});
|
|
420
416
|
if (!isEmpty(colsToResize)) {
|
|
421
|
-
|
|
417
|
+
gridApi.autoSizeColumns(
|
|
422
418
|
colsToResize.map((colState) => colState.colId),
|
|
423
419
|
skipHeader,
|
|
424
420
|
);
|
|
425
421
|
}
|
|
426
422
|
return {
|
|
427
423
|
width: sumBy(
|
|
428
|
-
|
|
424
|
+
gridApi.getColumnState().filter((col) => !col.hide),
|
|
429
425
|
"width",
|
|
430
426
|
),
|
|
431
427
|
};
|
|
432
428
|
},
|
|
433
|
-
[
|
|
429
|
+
[gridApi],
|
|
434
430
|
);
|
|
435
431
|
|
|
436
432
|
/**
|
|
@@ -489,7 +485,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
489
485
|
*/
|
|
490
486
|
const cancelEdit = useCallback((): void => {
|
|
491
487
|
stopEditing();
|
|
492
|
-
cellEditingCompleteCallbackRef.current
|
|
488
|
+
cellEditingCompleteCallbackRef.current?.();
|
|
493
489
|
}, [stopEditing]);
|
|
494
490
|
|
|
495
491
|
const cellEditingCompleteCallbackRef = useRef<() => void>();
|
|
@@ -583,7 +579,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
583
579
|
gridApi.refreshClientSideRowModel();
|
|
584
580
|
} else {
|
|
585
581
|
// Don't set saving if ok as the form has already closed
|
|
586
|
-
setSaving
|
|
582
|
+
setSaving?.(false);
|
|
587
583
|
}
|
|
588
584
|
|
|
589
585
|
// Only focus next cell if user hasn't already manually changed focus
|
|
@@ -639,12 +635,12 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
639
635
|
[gridApi],
|
|
640
636
|
);
|
|
641
637
|
|
|
642
|
-
const addExternalFilter = (filter: GridFilterExternal<
|
|
638
|
+
const addExternalFilter = (filter: GridFilterExternal<TData>) => {
|
|
643
639
|
externalFilters.current.push(filter);
|
|
644
640
|
onFilterChanged().then();
|
|
645
641
|
};
|
|
646
642
|
|
|
647
|
-
const removeExternalFilter = (filter: GridFilterExternal<
|
|
643
|
+
const removeExternalFilter = (filter: GridFilterExternal<TData>) => {
|
|
648
644
|
remove(externalFilters.current, (v) => v === filter);
|
|
649
645
|
onFilterChanged().then();
|
|
650
646
|
};
|
|
@@ -667,7 +663,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
667
663
|
* Apply column visibility
|
|
668
664
|
*/
|
|
669
665
|
useEffect(() => {
|
|
670
|
-
if (!
|
|
666
|
+
if (!gridApi || !invisibleColumnIds) return;
|
|
671
667
|
|
|
672
668
|
// show all columns that aren't invisible
|
|
673
669
|
const newVisibleColumns = getColumns(
|
|
@@ -679,26 +675,26 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
679
675
|
const fillerColumn = getColumns(isGridCellFiller)[0];
|
|
680
676
|
fillerColumn && newVisibleColumns.push(fillerColumn);
|
|
681
677
|
}
|
|
682
|
-
|
|
678
|
+
gridApi.setColumnsVisible(compact(newVisibleColumns.map(getColId)), true);
|
|
683
679
|
|
|
684
680
|
// Hide the filler column if there's already a flex column
|
|
685
681
|
const invisibleColumnIdsWithOptionalFiller = visibleColumnsContainsAFlex
|
|
686
682
|
? [...invisibleColumnIds, GridCellFillerColId]
|
|
687
683
|
: invisibleColumnIds;
|
|
688
|
-
|
|
689
|
-
}, [invisibleColumnIds,
|
|
684
|
+
gridApi.setColumnsVisible(invisibleColumnIdsWithOptionalFiller, false);
|
|
685
|
+
}, [invisibleColumnIds, getColumns, gridApi]);
|
|
690
686
|
|
|
691
687
|
/**
|
|
692
688
|
* Download visible columns as a CSV
|
|
693
689
|
*/
|
|
694
690
|
const downloadCsv = useCallback(
|
|
695
691
|
(csvExportParams?: CsvExportParams) => {
|
|
696
|
-
if (!gridApi
|
|
692
|
+
if (!gridApi) return;
|
|
697
693
|
|
|
698
|
-
const fileName = csvExportParams?.fileName && sanitiseFileName(csvExportParams.fileName);
|
|
694
|
+
const fileName = csvExportParams?.fileName && sanitiseFileName(fnOrVar(csvExportParams.fileName));
|
|
699
695
|
|
|
700
|
-
const columnKeys =
|
|
701
|
-
|
|
696
|
+
const columnKeys = gridApi
|
|
697
|
+
.getColumnState()
|
|
702
698
|
.filter((cs) => {
|
|
703
699
|
const colDef = gridApi.getColumnDef(cs.colId);
|
|
704
700
|
return !cs.hide && colDef && !isGridCellFiller(colDef) && colDef.headerComponentParams?.exportable !== false;
|
|
@@ -711,7 +707,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
|
|
|
711
707
|
fileName,
|
|
712
708
|
});
|
|
713
709
|
},
|
|
714
|
-
[
|
|
710
|
+
[gridApi],
|
|
715
711
|
);
|
|
716
712
|
|
|
717
713
|
return (
|
|
@@ -807,7 +803,7 @@ export const downloadCsvUseValueFormattersProcessCellCallback = (params: Process
|
|
|
807
803
|
return encodeToString(params.value);
|
|
808
804
|
}
|
|
809
805
|
|
|
810
|
-
const result = valueFormatter({ ...params, data: params.node?.data, colDef
|
|
806
|
+
const result = valueFormatter({ ...params, data: params.node?.data, colDef, node: null });
|
|
811
807
|
// type may not be string due to casting, leave the type check in
|
|
812
808
|
if (params.value != null && typeof result !== "string") {
|
|
813
809
|
console.error(`downloadCsv: valueFormatter is returning non string values, colDef:", colId: ${colDef.colId}`);
|
|
@@ -2,14 +2,14 @@ import { RefObject, createContext, useContext } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { GridBaseRow } from "../components/Grid";
|
|
4
4
|
|
|
5
|
-
export interface GridPopoverContextType<
|
|
5
|
+
export interface GridPopoverContextType<TData extends GridBaseRow> {
|
|
6
6
|
anchorRef: RefObject<Element>;
|
|
7
7
|
saving: boolean;
|
|
8
8
|
setSaving: (saving: boolean) => void;
|
|
9
|
-
field: keyof
|
|
9
|
+
field: keyof TData;
|
|
10
10
|
value: any;
|
|
11
|
-
data:
|
|
12
|
-
selectedRows:
|
|
11
|
+
data: TData;
|
|
12
|
+
selectedRows: TData[];
|
|
13
13
|
updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>, tabDirection: 1 | 0 | -1) => Promise<boolean>;
|
|
14
14
|
formatValue: (value: any) => any;
|
|
15
15
|
}
|
|
@@ -26,5 +26,5 @@ export const GridPopoverContext = createContext<GridPopoverContextType<any>>({
|
|
|
26
26
|
formatValue: () => "! No gridPopoverContextProvider !",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
export const useGridPopoverContext = <
|
|
30
|
-
useContext<GridPopoverContextType<
|
|
29
|
+
export const useGridPopoverContext = <TData extends GridBaseRow>() =>
|
|
30
|
+
useContext<GridPopoverContextType<TData>>(GridPopoverContext);
|
|
@@ -66,12 +66,12 @@ const GridDragRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
66
66
|
headerName: "Id",
|
|
67
67
|
lockVisible: true,
|
|
68
68
|
}),
|
|
69
|
-
GridCell({
|
|
69
|
+
GridCell<ITestRow, ITestRow["position"]>({
|
|
70
70
|
field: "position",
|
|
71
71
|
headerName: "Position",
|
|
72
72
|
cellRendererParams: {
|
|
73
|
-
warning: (
|
|
74
|
-
info: (
|
|
73
|
+
warning: ({ value }) => value === "Tester" && "Testers are testing",
|
|
74
|
+
info: ({ value }) => value === "Developer" && "Developers are awesome",
|
|
75
75
|
},
|
|
76
76
|
}),
|
|
77
77
|
GridCell({
|
|
@@ -91,7 +91,7 @@ const GridDragRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
91
91
|
[],
|
|
92
92
|
);
|
|
93
93
|
|
|
94
|
-
const [rowData] = useState([
|
|
94
|
+
const [rowData, setRowData] = useState([
|
|
95
95
|
{ id: 1000, position: "Tester", age: 30, height: `6'4"`, desc: "Tests application", dd: "1" },
|
|
96
96
|
{ id: 1001, position: "Developer", age: 12, height: `5'3"`, desc: "Develops application", dd: "2" },
|
|
97
97
|
{ id: 1002, position: "Manager", age: 65, height: `5'9"`, desc: "Manages", dd: "3" },
|
|
@@ -109,10 +109,16 @@ const GridDragRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
109
109
|
columnDefs={columnDefs}
|
|
110
110
|
defaultColDef={{ sortable: false }}
|
|
111
111
|
rowData={rowData}
|
|
112
|
-
onRowDragEnd={async (
|
|
113
|
-
|
|
112
|
+
onRowDragEnd={async (movedRow, targetRow, _targetIndex) => {
|
|
113
|
+
setRowData(
|
|
114
|
+
rowData.map((r) => {
|
|
115
|
+
if (r.id === movedRow.id) return targetRow;
|
|
116
|
+
if (r.id === targetRow.id) return movedRow;
|
|
117
|
+
return r;
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
114
120
|
}}
|
|
115
|
-
rowDragText={(
|
|
121
|
+
rowDragText={({ rowNode }) => `${rowNode?.data.id} - ${rowNode?.data.position}`}
|
|
116
122
|
/>
|
|
117
123
|
</GridWrapper>
|
|
118
124
|
);
|
|
@@ -3,7 +3,6 @@ import "../../styles/index.scss";
|
|
|
3
3
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
4
4
|
|
|
5
5
|
import { Meta, StoryFn } from "@storybook/react";
|
|
6
|
-
import { ColDef } from "ag-grid-community";
|
|
7
6
|
import { GridPopoverEditDropDown } from "components/gridPopoverEdit/GridPopoverEditDropDown";
|
|
8
7
|
import { GridPopoverTextArea } from "components/gridPopoverEdit/GridPopoverTextArea";
|
|
9
8
|
import { useMemo, useState } from "react";
|
|
@@ -155,9 +154,9 @@ const GridNonEditableRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
155
154
|
{ id: 1002, position: "Manager", age: 65, desc: "Manages", dd: "3" },
|
|
156
155
|
]);
|
|
157
156
|
|
|
158
|
-
const defaultColDef:
|
|
157
|
+
const defaultColDef: ColDefT<ITestRow> = useMemo(
|
|
159
158
|
() => ({
|
|
160
|
-
editable: (
|
|
159
|
+
editable: ({ data }) => data?.position !== "Manager",
|
|
161
160
|
}),
|
|
162
161
|
[],
|
|
163
162
|
);
|
|
@@ -85,8 +85,8 @@ const GridPopoutContextMenuTemplate: StoryFn<typeof Grid> = (props: GridProps) =
|
|
|
85
85
|
GridCell({
|
|
86
86
|
field: "distance",
|
|
87
87
|
headerName: "Number input",
|
|
88
|
-
valueFormatter: (
|
|
89
|
-
const v =
|
|
88
|
+
valueFormatter: ({ data }) => {
|
|
89
|
+
const v = data?.distance;
|
|
90
90
|
return v != null ? `${v}m` : "–";
|
|
91
91
|
},
|
|
92
92
|
}),
|
|
@@ -91,7 +91,7 @@ const GridPopoutEditGenericTemplate: StoryFn<typeof Grid> = (props: GridProps) =
|
|
|
91
91
|
field: "distance",
|
|
92
92
|
headerName: "Number input",
|
|
93
93
|
valueFormatter: (params) => {
|
|
94
|
-
const v = params.data
|
|
94
|
+
const v = params.data?.distance;
|
|
95
95
|
return v != null ? `${v}${params.colDef.cellEditorParams.units}` : "–";
|
|
96
96
|
},
|
|
97
97
|
},
|
|
@@ -65,8 +65,8 @@ const GridPopoverEditBearingTemplate: StoryFn<typeof Grid> = (props: GridProps)
|
|
|
65
65
|
field: "bearingCorrection",
|
|
66
66
|
headerName: "Bearing correction",
|
|
67
67
|
cellRendererParams: {
|
|
68
|
-
warning: ({ data }) => data
|
|
69
|
-
info: ({ data }) => data
|
|
68
|
+
warning: ({ data }) => data?.id == 1002 && "Testers are testing",
|
|
69
|
+
info: ({ data }) => data?.id == 1001 && "Developers are developing",
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
72
|
{
|
|
@@ -99,7 +99,7 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
99
99
|
field: "id",
|
|
100
100
|
headerName: "Id",
|
|
101
101
|
}),
|
|
102
|
-
GridPopoverEditDropDown(
|
|
102
|
+
GridPopoverEditDropDown<ITestRow, ITestRow["position2"]>(
|
|
103
103
|
{
|
|
104
104
|
field: "position2",
|
|
105
105
|
headerName: "Multi-edit",
|
|
@@ -173,7 +173,7 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
173
173
|
{
|
|
174
174
|
field: "position4",
|
|
175
175
|
headerName: "Filtered (object)",
|
|
176
|
-
valueGetter: (
|
|
176
|
+
valueGetter: ({ data }) => data?.position4?.desc,
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
multiEdit: true,
|
|
@@ -217,7 +217,7 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
217
217
|
{
|
|
218
218
|
field: "sub",
|
|
219
219
|
headerName: "Subcomponent",
|
|
220
|
-
valueGetter: (
|
|
220
|
+
valueGetter: ({ data }) => data?.sub,
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
223
|
multiEdit: true,
|
|
@@ -290,6 +290,15 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
290
290
|
code: "O2",
|
|
291
291
|
sub: "one",
|
|
292
292
|
},
|
|
293
|
+
{
|
|
294
|
+
id: 1002,
|
|
295
|
+
position: "Scrum Master",
|
|
296
|
+
position2: "2",
|
|
297
|
+
position3: "Architect",
|
|
298
|
+
position4: { code: "O2", desc: "Object Two" },
|
|
299
|
+
code: "O2",
|
|
300
|
+
sub: "one",
|
|
301
|
+
},
|
|
293
302
|
] as ITestRow[]);
|
|
294
303
|
|
|
295
304
|
return (
|
|
@@ -68,7 +68,7 @@ const GridEditMultiSelectTemplate: StoryFn<typeof Grid> = (props: GridProps) =>
|
|
|
68
68
|
field: "id",
|
|
69
69
|
headerName: "Id",
|
|
70
70
|
}),
|
|
71
|
-
GridPopoutEditMultiSelect(
|
|
71
|
+
GridPopoutEditMultiSelect<ITestRow, ITestRow["position"]>(
|
|
72
72
|
{
|
|
73
73
|
field: "position",
|
|
74
74
|
headerName: "Position",
|
|
@@ -112,7 +112,7 @@ const GridEditMultiSelectTemplate: StoryFn<typeof Grid> = (props: GridProps) =>
|
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
114
|
),
|
|
115
|
-
GridPopoutEditMultiSelect(
|
|
115
|
+
GridPopoutEditMultiSelect<ITestRow, ITestRow["position"]>(
|
|
116
116
|
{
|
|
117
117
|
field: "position",
|
|
118
118
|
headerName: "Parcel picker",
|
|
@@ -49,7 +49,7 @@ const GridEditMultiSelectGridTemplate: StoryFn<typeof Grid> = (props: GridProps)
|
|
|
49
49
|
field: "id",
|
|
50
50
|
headerName: "Id",
|
|
51
51
|
}),
|
|
52
|
-
GridPopoutEditMultiSelectGrid(
|
|
52
|
+
GridPopoutEditMultiSelectGrid<ITestRow, ITestRow["position"]>(
|
|
53
53
|
{
|
|
54
54
|
field: "position",
|
|
55
55
|
headerName: "Position",
|
|
@@ -62,7 +62,7 @@ const GridEditMultiSelectGridTemplate: StoryFn<typeof Grid> = (props: GridProps)
|
|
|
62
62
|
multiEdit: true,
|
|
63
63
|
editorParams: {
|
|
64
64
|
className: "GridMultiSelect-containerUnlimited",
|
|
65
|
-
options: (selectedRows) => {
|
|
65
|
+
options: (selectedRows: ITestRow[]) => {
|
|
66
66
|
const counts: Record<number, number> = mergeWith(
|
|
67
67
|
{},
|
|
68
68
|
...selectedRows.map((row) => countBy(row.position)),
|
|
@@ -80,23 +80,23 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
80
80
|
headerName: "Id",
|
|
81
81
|
lockVisible: true,
|
|
82
82
|
}),
|
|
83
|
-
GridCell({
|
|
83
|
+
GridCell<ITestRow, ITestRow["position"]>({
|
|
84
84
|
field: "position",
|
|
85
85
|
headerName: "Position",
|
|
86
86
|
cellRendererParams: {
|
|
87
|
-
warning: (
|
|
88
|
-
info: (
|
|
87
|
+
warning: ({ value }) => value === "Tester" && "Testers are testing",
|
|
88
|
+
info: ({ value }) => value === "Developer" && "Developers are awesome",
|
|
89
89
|
},
|
|
90
90
|
}),
|
|
91
91
|
{
|
|
92
92
|
headerName: "Metrics",
|
|
93
93
|
marryChildren: true,
|
|
94
94
|
children: [
|
|
95
|
-
GridCell({
|
|
95
|
+
GridCell<ITestRow, ITestRow["age"]>({
|
|
96
96
|
field: "age",
|
|
97
97
|
headerName: "Age",
|
|
98
98
|
}),
|
|
99
|
-
GridCell({
|
|
99
|
+
GridCell<ITestRow, ITestRow["height"]>({
|
|
100
100
|
field: "height",
|
|
101
101
|
headerName: "Height",
|
|
102
102
|
}),
|
|
@@ -134,7 +134,7 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
134
134
|
rightHoverElement: (
|
|
135
135
|
<GridIcon icon={"ic_launch_modal"} title={"Title text"} className={"GridCell-editableIcon"} />
|
|
136
136
|
),
|
|
137
|
-
editAction: (selectedRows) => {
|
|
137
|
+
editAction: (selectedRows: ITestRow[]) => {
|
|
138
138
|
alert(`Custom edit ${selectedRows.map((r) => r.id)} rowId(s) selected`);
|
|
139
139
|
},
|
|
140
140
|
shortcutKeys: {
|
|
@@ -54,24 +54,22 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
54
54
|
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
55
55
|
const columnDefs: ColDefT<ITestRow>[] = useMemo(
|
|
56
56
|
() => [
|
|
57
|
-
GridCell({
|
|
57
|
+
GridCell<ITestRow, ITestRow["id"]>({
|
|
58
58
|
field: "id",
|
|
59
59
|
headerName: "Id",
|
|
60
60
|
lockVisible: true,
|
|
61
61
|
resizable: false,
|
|
62
62
|
lockPosition: "left",
|
|
63
|
-
cellRenderer: (
|
|
64
|
-
return <a href={"#"}>{props.value}</a>;
|
|
65
|
-
},
|
|
63
|
+
cellRenderer: ({ value }) => <a href={"#"}>{value}</a>,
|
|
66
64
|
}),
|
|
67
|
-
GridCell({
|
|
65
|
+
GridCell<ITestRow, ITestRow["position"]>({
|
|
68
66
|
field: "position",
|
|
69
67
|
headerName: "Position",
|
|
70
68
|
resizable: false,
|
|
71
69
|
lockPosition: "left",
|
|
72
70
|
cellRendererParams: {
|
|
73
|
-
warning: (
|
|
74
|
-
info: (
|
|
71
|
+
warning: ({ value }) => value === "Tester" && "Testers are testing",
|
|
72
|
+
info: ({ value }) => value === "Developer" && "Developers are awesome",
|
|
75
73
|
},
|
|
76
74
|
}),
|
|
77
75
|
GridCell({
|
|
@@ -82,12 +82,12 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
|
|
|
82
82
|
field: "id",
|
|
83
83
|
headerName: "Id",
|
|
84
84
|
}),
|
|
85
|
-
GridCell({
|
|
85
|
+
GridCell<ITestRow, ITestRow["position"]>({
|
|
86
86
|
field: "position",
|
|
87
87
|
headerName: "Position",
|
|
88
88
|
cellRendererParams: {
|
|
89
|
-
warning: (
|
|
90
|
-
info: (
|
|
89
|
+
warning: ({ value }) => value === "Tester" && "Testers are testing",
|
|
90
|
+
info: ({ value }) => value === "Developer" && "Developers are awesome",
|
|
91
91
|
},
|
|
92
92
|
}),
|
|
93
93
|
GridCell({
|
package/src/styles/Grid.scss
CHANGED
|
@@ -15,13 +15,10 @@
|
|
|
15
15
|
flex: 1;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
.Grid-sortIsStale {
|
|
20
|
-
span.ag-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
span.ag-icon.ag-icon-asc::after {
|
|
19
|
+
span.ag-sort-indicator-icon::before {
|
|
20
|
+
margin-left: -6px;
|
|
21
|
+
position: absolute;
|
|
25
22
|
content: "*";
|
|
26
23
|
}
|
|
27
24
|
}
|