@linzjs/step-ag-grid 8.0.0 → 8.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/index.css +4 -0
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -0
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +3 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
- package/dist/src/lui/ActionButton.d.ts +2 -1
- package/dist/step-ag-grid.esm.js +69 -52
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +86 -71
- package/src/components/gridForm/GridFormPopoverMenu.tsx +53 -46
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +3 -3
- package/src/lui/ActionButton.tsx +3 -1
- package/src/react-menu3/styles/index.scss +4 -0
- package/src/stories/components/ActionButton.stories.tsx +11 -0
- package/src/stories/grid/gridForm/GridFormDropDown.stories.tsx +85 -36
- package/src/stories/grid/gridForm/GridFormEditBearing.stories.tsx +1 -3
- package/src/stories/grid/gridForm/GridFormEditBearingCorrection.stories.tsx +1 -3
- package/src/stories/grid/gridForm/GridFormMessage.stories.tsx +32 -0
- package/src/stories/grid/gridForm/GridFormPopoverMenu.stories.tsx +55 -0
- package/src/stories/grid/gridForm/reactMenuTest.scss +0 -3
package/dist/index.css
CHANGED
|
@@ -25,6 +25,7 @@ export type SelectOption = null | string | FinalSelectOption;
|
|
|
25
25
|
export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
26
26
|
className?: "GridPopoverEditDropDown-containerSmall" | "GridPopoverEditDropDown-containerMedium" | "GridPopoverEditDropDown-containerLarge" | "GridPopoverEditDropDown-containerUnlimited" | string | undefined;
|
|
27
27
|
filtered?: "local" | "reload";
|
|
28
|
+
filterDefaultValue?: string;
|
|
28
29
|
filterPlaceholder?: string;
|
|
29
30
|
filterHelpText?: string;
|
|
30
31
|
noOptionsMessage?: string;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GridBaseRow } from "../Grid";
|
|
3
3
|
import { CellEditorCommon } from "../GridCell";
|
|
4
|
-
export interface
|
|
4
|
+
export interface GridFormPopoverMenuProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
5
5
|
options: (selectedRows: RowType[]) => Promise<MenuOption<RowType>[]>;
|
|
6
6
|
defaultAction?: (props: {
|
|
7
7
|
selectedRows: RowType[];
|
|
8
8
|
menuOption: SelectedMenuOptionResult<RowType>;
|
|
9
9
|
}) => Promise<void>;
|
|
10
10
|
}
|
|
11
|
-
/** Menu configuration types **/
|
|
12
11
|
export declare const PopoutMenuSeparator: Readonly<{
|
|
13
|
-
|
|
12
|
+
label: "__isMenuSeparator__";
|
|
14
13
|
}>;
|
|
15
14
|
interface MenuSeparatorType {
|
|
16
15
|
__isMenuSeparator__: boolean;
|
|
@@ -32,5 +31,5 @@ export interface MenuOption<RowType extends GridBaseRow> {
|
|
|
32
31
|
* NOTE: If the popout menu doesn't appear on single click when also selecting row it's because
|
|
33
32
|
* you need a useMemo around your columnDefs
|
|
34
33
|
*/
|
|
35
|
-
export declare const GridFormPopoverMenu: <RowType extends GridBaseRow>(props:
|
|
34
|
+
export declare const GridFormPopoverMenu: <RowType extends GridBaseRow>(props: GridFormPopoverMenuProps<RowType>) => JSX.Element;
|
|
36
35
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GridBaseRow } from "../Grid";
|
|
2
2
|
import { ColDefT, GenericCellEditorProps } from "../GridCell";
|
|
3
|
-
import {
|
|
3
|
+
import { GridFormPopoverMenuProps } from "../gridForm/GridFormPopoverMenu";
|
|
4
4
|
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
5
5
|
/**
|
|
6
6
|
* Popout burger menu
|
|
7
7
|
*/
|
|
8
|
-
export declare const GridPopoverMenu: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, custom: GenericCellEditorProps<
|
|
8
|
+
export declare const GridPopoverMenu: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, custom: GenericCellEditorProps<GridFormPopoverMenuProps<RowType>>) => ColDefT<RowType>;
|
|
@@ -15,5 +15,6 @@ export interface ActionButtonProps {
|
|
|
15
15
|
onClick: () => Promise<void> | void;
|
|
16
16
|
level?: LuiButtonProps["level"];
|
|
17
17
|
style?: CSSProperties;
|
|
18
|
+
disabled?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare const ActionButton: ({ icon, name, inProgressName, dataTestId, style, className, title, onClick, size, iconPosition, level, "aria-label": ariaLabel, }: ActionButtonProps) => JSX.Element;
|
|
20
|
+
export declare const ActionButton: ({ icon, name, inProgressName, disabled, dataTestId, style, className, title, onClick, size, iconPosition, level, "aria-label": ariaLabel, }: ActionButtonProps) => JSX.Element;
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -3278,17 +3278,17 @@ var fieldToString = function (field) {
|
|
|
3278
3278
|
return typeof field == "symbol" ? field.toString() : "".concat(field);
|
|
3279
3279
|
};
|
|
3280
3280
|
var GridFormDropDown = function (props) {
|
|
3281
|
-
var _a;
|
|
3282
|
-
var
|
|
3281
|
+
var _a, _b;
|
|
3282
|
+
var _c = useGridPopoverContext(), selectedRows = _c.selectedRows, field = _c.field, data = _c.data;
|
|
3283
3283
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
3284
|
-
var
|
|
3285
|
-
var
|
|
3286
|
-
var
|
|
3284
|
+
var _d = useState((_a = props.filterDefaultValue) !== null && _a !== void 0 ? _a : ""), filter = _d[0], setFilter = _d[1];
|
|
3285
|
+
var _e = useState(), filteredValues = _e[0], setFilteredValues = _e[1];
|
|
3286
|
+
var _f = useState(null), options = _f[0], setOptions = _f[1];
|
|
3287
3287
|
var subComponentIsValid = useRef(false);
|
|
3288
3288
|
var subComponentInitialValue = useRef(null);
|
|
3289
|
-
var
|
|
3289
|
+
var _g = useState(null), subSelectedValue = _g[0], setSubSelectedValue = _g[1];
|
|
3290
3290
|
// Note: null is assumed to be the filter
|
|
3291
|
-
var
|
|
3291
|
+
var _h = useState(null), selectedItem = _h[0], setSelectedItem = _h[1];
|
|
3292
3292
|
var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3293
3293
|
var hasChanged;
|
|
3294
3294
|
return __generator(this, function (_a) {
|
|
@@ -3367,7 +3367,7 @@ var GridFormDropDown = function (props) {
|
|
|
3367
3367
|
.filter(function (r) { return r !== undefined; }));
|
|
3368
3368
|
}
|
|
3369
3369
|
}, [props.filtered, filter, options]);
|
|
3370
|
-
var
|
|
3370
|
+
var reSearchOnFilterChange = useMemo(function () {
|
|
3371
3371
|
return dist$1(function () {
|
|
3372
3372
|
setOptions(null);
|
|
3373
3373
|
}, 500);
|
|
@@ -3377,9 +3377,9 @@ var GridFormDropDown = function (props) {
|
|
|
3377
3377
|
useEffect(function () {
|
|
3378
3378
|
if (previousFilter.current != filter && props.filtered == "reload") {
|
|
3379
3379
|
previousFilter.current = filter;
|
|
3380
|
-
|
|
3380
|
+
reSearchOnFilterChange().then();
|
|
3381
3381
|
}
|
|
3382
|
-
}, [filter, props,
|
|
3382
|
+
}, [filter, props, reSearchOnFilterChange]);
|
|
3383
3383
|
/**
|
|
3384
3384
|
* Saves are wrapped in updateValue and triggered by blur events
|
|
3385
3385
|
*/
|
|
@@ -3419,6 +3419,8 @@ var GridFormDropDown = function (props) {
|
|
|
3419
3419
|
invalid: function () { return !!(selectedItem && !subComponentIsValid.current); },
|
|
3420
3420
|
save: save
|
|
3421
3421
|
}).popoverWrapper;
|
|
3422
|
+
var lastHeader = null;
|
|
3423
|
+
var showHeader = null;
|
|
3422
3424
|
return popoverWrapper(jsxs(Fragment$1, { children: [props.filtered && (jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsx(FocusableItem, __assign({ className: "filter-item", onFocus: function () {
|
|
3423
3425
|
setSelectedItem(null);
|
|
3424
3426
|
setSubSelectedValue(null);
|
|
@@ -3428,44 +3430,58 @@ var GridFormDropDown = function (props) {
|
|
|
3428
3430
|
var ref = _a.ref;
|
|
3429
3431
|
return (jsxs("div", __assign({ style: { display: "flex", flexDirection: "column", width: "100%" } }, { children: [jsx("input", { className: "LuiTextInput-input", ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, "data-allowtabtosave": true, "data-disableenterautosave": !props.onSelectFilter &&
|
|
3430
3432
|
!(filteredValues && filteredValues.length === 1 && !filteredValues[0].subComponent), onChange: function (e) { return setFilter(e.target.value); } }), props.filterHelpText && isNotEmpty(filter) && (jsx(FormError, { error: null, helpText: props.filterHelpText }))] })));
|
|
3431
|
-
} })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && (isEmpty(options) || (filteredValues && isEmpty(filteredValues))) && (jsx(MenuItem, __assign({ className: "GridPopoverEditDropDown-noOptions" }, { children: (
|
|
3433
|
+
} })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && (isEmpty(options) || (filteredValues && isEmpty(filteredValues))) && (jsx(MenuItem, __assign({ className: "GridPopoverEditDropDown-noOptions" }, { children: (_b = props.noOptionsMessage) !== null && _b !== void 0 ? _b : "No Options" }), "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3432
3434
|
var _a;
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3435
|
+
showHeader = null;
|
|
3436
|
+
if (item.value === MenuSeparatorString) {
|
|
3437
|
+
return jsx(MenuDivider, {}, "$$divider_".concat(index));
|
|
3438
|
+
}
|
|
3439
|
+
else if (item.value === MenuHeaderString) {
|
|
3440
|
+
lastHeader = jsx(MenuHeader, { children: item.label }, "$$header_".concat(index));
|
|
3441
|
+
return jsx(Fragment$1, {});
|
|
3442
|
+
}
|
|
3443
|
+
else {
|
|
3444
|
+
if (lastHeader) {
|
|
3445
|
+
showHeader = lastHeader;
|
|
3446
|
+
lastHeader = null;
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
return ((!filteredValues || filteredValues.includes(item)) && (jsxs(Fragment$1, { children: [showHeader, jsxs("div", { children: [jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onFocus: function () {
|
|
3450
|
+
setSelectedItem(item);
|
|
3451
|
+
if (item.subComponent) {
|
|
3452
|
+
setSelectedItem(item);
|
|
3453
|
+
subComponentIsValid.current = true;
|
|
3454
|
+
subComponentInitialValue.current = null;
|
|
3455
|
+
}
|
|
3456
|
+
else {
|
|
3457
|
+
setSubSelectedValue(null);
|
|
3458
|
+
subComponentIsValid.current = true;
|
|
3459
|
+
}
|
|
3460
|
+
}, onClick: function (e) {
|
|
3461
|
+
if (item.subComponent) {
|
|
3462
|
+
e.keepOpen = true;
|
|
3457
3463
|
}
|
|
3458
|
-
},
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3464
|
+
} }, { children: [(_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), item.subComponent ? "..." : ""] }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedItem === item && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3465
|
+
context: { options: options },
|
|
3466
|
+
data: data,
|
|
3467
|
+
value: subSelectedValue,
|
|
3468
|
+
setValue: function (value) {
|
|
3469
|
+
setSubSelectedValue(value);
|
|
3470
|
+
if (subComponentInitialValue.current === null) {
|
|
3471
|
+
// copy the default value of the subcomponent so we can change detect on save
|
|
3472
|
+
subComponentInitialValue.current = JSON.stringify(value);
|
|
3473
|
+
}
|
|
3474
|
+
},
|
|
3475
|
+
setValid: function (valid) {
|
|
3476
|
+
subComponentIsValid.current = valid;
|
|
3477
|
+
},
|
|
3478
|
+
triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3479
|
+
return __generator(this, function (_a) {
|
|
3480
|
+
ref.closeMenu();
|
|
3481
|
+
return [2 /*return*/];
|
|
3482
|
+
});
|
|
3483
|
+
}); }
|
|
3484
|
+
} }, { children: item.subComponent && (jsx("div", __assign({ className: "subComponent" }, { children: jsx(item.subComponent, {}, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")) }))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index))] })));
|
|
3469
3485
|
})] }) }))] }));
|
|
3470
3486
|
};
|
|
3471
3487
|
|
|
@@ -3848,7 +3864,8 @@ var GridPopoutEditMultiSelect = function (colDef, props) {
|
|
|
3848
3864
|
};
|
|
3849
3865
|
|
|
3850
3866
|
/** Menu configuration types **/
|
|
3851
|
-
var
|
|
3867
|
+
var __isMenuSeparator__ = "__isMenuSeparator__";
|
|
3868
|
+
var PopoutMenuSeparator = Object.freeze({ label: __isMenuSeparator__ });
|
|
3852
3869
|
/**
|
|
3853
3870
|
* NOTE: If the popout menu doesn't appear on single click when also selecting row it's because
|
|
3854
3871
|
* you need a useMemo around your columnDefs
|
|
@@ -3969,8 +3986,8 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3969
3986
|
invalid: function () { return subComponentSelected && !subComponentIsValid.current; },
|
|
3970
3987
|
save: save
|
|
3971
3988
|
}), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
|
|
3972
|
-
return popoverWrapper(jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormPopupMenu" }, { children: jsx(Fragment$1, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3973
|
-
return item.label ===
|
|
3989
|
+
return popoverWrapper(jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormPopupMenu" }, { children: jsx(Fragment$1, { children: (options === null || options === void 0 ? void 0 : options.length) === 0 ? (jsx(MenuItem, __assign({ className: "GridPopoverMenu-noOptions", disabled: true }, { children: "No actions" }), "GridPopoverMenu-empty")) : (options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3990
|
+
return item.label === "__isMenuSeparator__" ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxs(Fragment, { children: [jsx(MenuItem, __assign({ onClick: function (e) { return onMenuItemClick(e, item); }, disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "" }, { children: item.label }), "".concat(item.label)), item.subComponent && subComponentSelected === item && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
|
|
3974
3991
|
return item.subComponent && (jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3975
3992
|
context: {},
|
|
3976
3993
|
data: data,
|
|
@@ -3984,7 +4001,7 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3984
4001
|
triggerSave: triggerSave
|
|
3985
4002
|
} }, { children: jsx("div", __assign({ className: "subComponent" }, { children: jsx(item.subComponent, {}) })) })));
|
|
3986
4003
|
} }), "".concat(item.label, "_subcomponent")))] }, "".concat(item.label))));
|
|
3987
|
-
}) }) })));
|
|
4004
|
+
})) }) })));
|
|
3988
4005
|
};
|
|
3989
4006
|
|
|
3990
4007
|
/**
|
|
@@ -4519,7 +4536,7 @@ var useStateDeferred = function (initialValue) {
|
|
|
4519
4536
|
var minimumInProgressTimeMs = 950;
|
|
4520
4537
|
var ActionButton = function (_a) {
|
|
4521
4538
|
var _b, _c, _d;
|
|
4522
|
-
var icon = _a.icon, name = _a.name, inProgressName = _a.inProgressName, dataTestId = _a.dataTestId, style = _a.style, className = _a.className, title = _a.title, onClick = _a.onClick, _e = _a.size, size = _e === void 0 ? "sm" : _e, _f = _a.iconPosition, iconPosition = _f === void 0 ? "left" : _f, _g = _a.level, level = _g === void 0 ? "tertiary" : _g, ariaLabel = _a["aria-label"];
|
|
4539
|
+
var icon = _a.icon, name = _a.name, inProgressName = _a.inProgressName, disabled = _a.disabled, dataTestId = _a.dataTestId, style = _a.style, className = _a.className, title = _a.title, onClick = _a.onClick, _e = _a.size, size = _e === void 0 ? "sm" : _e, _f = _a.iconPosition, iconPosition = _f === void 0 ? "left" : _f, _g = _a.level, level = _g === void 0 ? "tertiary" : _g, ariaLabel = _a["aria-label"];
|
|
4523
4540
|
var _h = useState(false), inProgress = _h[0], setInProgress = _h[1];
|
|
4524
4541
|
var lastInProgress = usePrevious(inProgress !== null && inProgress !== void 0 ? inProgress : false);
|
|
4525
4542
|
var _j = useStateDeferred(inProgress), localInProgress = _j[0], setLocalInProgress = _j[1], setLocalInProgressDeferred = _j[2];
|
|
@@ -4549,7 +4566,7 @@ var ActionButton = function (_a) {
|
|
|
4549
4566
|
case 3: return [2 /*return*/];
|
|
4550
4567
|
}
|
|
4551
4568
|
});
|
|
4552
|
-
}); }, disabled: localInProgress }, { children: [iconPosition === "right" && buttonText, localInProgress ? (jsx(LuiMiniSpinner, { size: 16, divProps: {
|
|
4569
|
+
}); }, disabled: localInProgress || disabled }, { children: [iconPosition === "right" && buttonText, localInProgress ? (jsx(LuiMiniSpinner, { size: 16, divProps: {
|
|
4553
4570
|
"data-testid": "loading-spinner",
|
|
4554
4571
|
style: {
|
|
4555
4572
|
margin: 0,
|