@linzjs/step-ag-grid 2.4.0 → 2.4.2
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.js +78 -10
- package/dist/index.js.map +1 -1
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +2 -0
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +7 -0
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/lui/ActionButton.d.ts +3 -3
- package/dist/step-ag-grid.esm.js +78 -11
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +55 -11
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +34 -0
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +3 -3
- package/src/index.ts +1 -0
- package/src/lui/ActionButton.tsx +15 -7
- package/src/stories/components/ActionButton.stories.tsx +2 -13
- package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +41 -0
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +1 -11
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +4 -5
- package/src/stories/grid/GridReadOnly.stories.tsx +1 -0
package/dist/index.js
CHANGED
|
@@ -2840,7 +2840,8 @@ var GridFormDropDown = function (_props) {
|
|
|
2840
2840
|
var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
|
|
2841
2841
|
var optionsInitialising = react.useRef(false);
|
|
2842
2842
|
var _d = react.useState(null), options = _d[0], setOptions = _d[1];
|
|
2843
|
-
var
|
|
2843
|
+
var _e = react.useState([]), subComponentValues = _e[0], setSubComponentValues = _e[1];
|
|
2844
|
+
var selectItemHandler = react.useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2844
2845
|
var field;
|
|
2845
2846
|
return __generator(this, function (_a) {
|
|
2846
2847
|
switch (_a.label) {
|
|
@@ -2854,7 +2855,7 @@ var GridFormDropDown = function (_props) {
|
|
|
2854
2855
|
hasChanged = selectedRows.some(function (row) { return row[field] !== value; });
|
|
2855
2856
|
if (!hasChanged) return [3 /*break*/, 3];
|
|
2856
2857
|
if (!props.onSelectedItem) return [3 /*break*/, 2];
|
|
2857
|
-
return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value })];
|
|
2858
|
+
return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value, subComponentValue: subComponentValue })];
|
|
2858
2859
|
case 1:
|
|
2859
2860
|
_a.sent();
|
|
2860
2861
|
return [3 /*break*/, 3];
|
|
@@ -2996,7 +2997,40 @@ var GridFormDropDown = function (_props) {
|
|
|
2996
2997
|
return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsxRuntime.jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));
|
|
2997
2998
|
} })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] }))), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && jsxRuntime.jsx(MenuItem, { children: "[Empty]" }), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
2998
2999
|
var _a;
|
|
2999
|
-
return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
|
|
3000
|
+
return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !item.subComponent ? (jsxRuntime.jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
|
|
3001
|
+
selectItemHandler(item.value);
|
|
3002
|
+
} }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(props.field, "-").concat(index))) : (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
|
|
3003
|
+
return item.subComponent &&
|
|
3004
|
+
item.subComponent({
|
|
3005
|
+
setValue: function (value) {
|
|
3006
|
+
var localSubComponentValues = __spreadArray([], subComponentValues, true);
|
|
3007
|
+
var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
|
|
3008
|
+
var optionValue = _a.optionValue;
|
|
3009
|
+
return optionValue === item.value;
|
|
3010
|
+
});
|
|
3011
|
+
if (subComponentValueIndex !== -1) {
|
|
3012
|
+
localSubComponentValues[subComponentValueIndex].subComponentValue = value;
|
|
3013
|
+
}
|
|
3014
|
+
else {
|
|
3015
|
+
localSubComponentValues.push({
|
|
3016
|
+
subComponentValue: value,
|
|
3017
|
+
optionValue: item.value
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
setSubComponentValues(localSubComponentValues);
|
|
3021
|
+
},
|
|
3022
|
+
keyDown: function (key) {
|
|
3023
|
+
var subComponentItem = subComponentValues.find(function (_a) {
|
|
3024
|
+
var optionValue = _a.optionValue;
|
|
3025
|
+
return optionValue === item.value;
|
|
3026
|
+
});
|
|
3027
|
+
if (key === "Enter" && subComponentItem) {
|
|
3028
|
+
selectItemHandler(item.value, subComponentItem.subComponentValue);
|
|
3029
|
+
ref.closeMenu();
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
}, ref);
|
|
3033
|
+
} }), "".concat(props.field, "-").concat(index, "_subcomponent"))) }));
|
|
3000
3034
|
})] }) }))] }));
|
|
3001
3035
|
};
|
|
3002
3036
|
|
|
@@ -3240,12 +3274,11 @@ var GridFormPopoutMenu = function (_props) {
|
|
|
3240
3274
|
/**
|
|
3241
3275
|
* Popout burger menu
|
|
3242
3276
|
*/
|
|
3243
|
-
var GridPopoverMenu = function (colDef,
|
|
3244
|
-
|
|
3245
|
-
return GridCell(__assign(__assign({ maxWidth: 64, editable: colDef.editable != null ? colDef.editable : true, cellRenderer: GridRenderPopoutMenuCell, cellClass: ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) === null || _a === void 0 ? void 0 : _a.multiEdit) !== false ? GenericMultiEditCellClass : undefined }, colDef), { cellRendererParams: {
|
|
3277
|
+
var GridPopoverMenu = function (colDef, custom) {
|
|
3278
|
+
return GridCell(__assign(__assign({ maxWidth: 64, editable: colDef.editable != null ? colDef.editable : true, cellRenderer: GridRenderPopoutMenuCell, cellClass: (custom === null || custom === void 0 ? void 0 : custom.multiEdit) ? GenericMultiEditCellClass : undefined }, colDef), { cellRendererParams: {
|
|
3246
3279
|
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
3247
3280
|
singleClickEdit: true
|
|
3248
|
-
} }), __assign({ editor: GridFormPopoutMenu },
|
|
3281
|
+
} }), __assign({ editor: GridFormPopoutMenu }, custom));
|
|
3249
3282
|
};
|
|
3250
3283
|
|
|
3251
3284
|
var bearingValueFormatter = function (params) {
|
|
@@ -3627,6 +3660,25 @@ var GridPopoverTextInput = function (colDef, params) {
|
|
|
3627
3660
|
return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
|
|
3628
3661
|
};
|
|
3629
3662
|
|
|
3663
|
+
var GridFormSubComponentTextInput = function (_a) {
|
|
3664
|
+
var keyDown = _a.keyDown, placeholder = _a.placeholder, setValue = _a.setValue;
|
|
3665
|
+
var placeholderText = placeholder || "Other...";
|
|
3666
|
+
var _b = react.useState(""), inputValue = _b[0], setInputValue = _b[1];
|
|
3667
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(TextInputFormatted, { value: inputValue, onChange: function (e) {
|
|
3668
|
+
var value = e.target.value;
|
|
3669
|
+
setValue(value);
|
|
3670
|
+
setInputValue(value);
|
|
3671
|
+
}, inputProps: {
|
|
3672
|
+
onKeyDown: function (k) { return keyDown(k.key); },
|
|
3673
|
+
placeholder: placeholderText,
|
|
3674
|
+
onMouseEnter: function (e) {
|
|
3675
|
+
if (document.activeElement != e.currentTarget) {
|
|
3676
|
+
e.currentTarget.focus();
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
} }) }));
|
|
3680
|
+
};
|
|
3681
|
+
|
|
3630
3682
|
var GridSubComponentTextArea = function (props) {
|
|
3631
3683
|
var _a = react.useContext(GridSubComponentContext), value = _a.value, setValue = _a.setValue, setValid = _a.setValid, triggerSave = _a.triggerSave;
|
|
3632
3684
|
// If is not initialised yet as it's just been created then set the default value
|
|
@@ -3743,15 +3795,30 @@ var minimumInProgressTimeMs = 950;
|
|
|
3743
3795
|
var ActionButton = function (_a) {
|
|
3744
3796
|
var _b;
|
|
3745
3797
|
var _c;
|
|
3746
|
-
var icon = _a.icon, name = _a.name, inProgressName = _a.inProgressName, dataTestId = _a.dataTestId,
|
|
3798
|
+
var icon = _a.icon, name = _a.name, inProgressName = _a.inProgressName, dataTestId = _a.dataTestId, className = _a.className, title = _a.title, onAction = _a.onAction, externalSetInProgress = _a.externalSetInProgress, _d = _a.size, size = _d === void 0 ? "sm" : _d;
|
|
3799
|
+
var _e = react.useState(false), inProgress = _e[0], setInProgress = _e[1];
|
|
3747
3800
|
var lastInProgress = usePrevious(inProgress !== null && inProgress !== void 0 ? inProgress : false);
|
|
3748
|
-
var
|
|
3801
|
+
var _f = useStateDeferred(inProgress), localInProgress = _f[0], setLocalInProgress = _f[1], setLocalInProgressDeferred = _f[2];
|
|
3749
3802
|
react.useEffect(function () {
|
|
3750
3803
|
if (inProgress == lastInProgress)
|
|
3751
3804
|
return;
|
|
3752
3805
|
inProgress ? setLocalInProgress(true) : setLocalInProgressDeferred(false, minimumInProgressTimeMs);
|
|
3753
3806
|
}, [inProgress, lastInProgress, setLocalInProgress, setLocalInProgressDeferred]);
|
|
3754
|
-
return (jsxRuntime.jsxs(lui.LuiButton, __assign({ "data-testid": dataTestId, type: "button", level: "tertiary", title: title !== null && title !== void 0 ? title : name, "aria-label": name, className: clsx("lui-button-icon", "ActionButton", className, localInProgress && "ActionButton-inProgress"), size: "lg", onClick:
|
|
3807
|
+
return (jsxRuntime.jsxs(lui.LuiButton, __assign({ "data-testid": dataTestId, type: "button", level: "tertiary", title: title !== null && title !== void 0 ? title : name, "aria-label": name, className: clsx("lui-button-icon", "ActionButton", className, localInProgress && "ActionButton-inProgress"), size: "lg", onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3808
|
+
return __generator(this, function (_a) {
|
|
3809
|
+
switch (_a.label) {
|
|
3810
|
+
case 0:
|
|
3811
|
+
setInProgress(true);
|
|
3812
|
+
externalSetInProgress && setInProgress(true);
|
|
3813
|
+
return [4 /*yield*/, onAction()];
|
|
3814
|
+
case 1:
|
|
3815
|
+
_a.sent();
|
|
3816
|
+
externalSetInProgress && setInProgress(false);
|
|
3817
|
+
setInProgress(false);
|
|
3818
|
+
return [2 /*return*/];
|
|
3819
|
+
}
|
|
3820
|
+
});
|
|
3821
|
+
}); }, disabled: localInProgress }, { children: [localInProgress ? (jsxRuntime.jsx(lui.LuiMiniSpinner, { size: 16, divProps: (_b = {
|
|
3755
3822
|
"data-testid": "loading-spinner",
|
|
3756
3823
|
style: { padding: 0, margin: 0, paddingRight: 8 },
|
|
3757
3824
|
role: "status"
|
|
@@ -3774,6 +3841,7 @@ exports.GridContextProvider = GridContextProvider;
|
|
|
3774
3841
|
exports.GridFormDropDown = GridFormDropDown;
|
|
3775
3842
|
exports.GridFormMultiSelect = GridFormMultiSelect;
|
|
3776
3843
|
exports.GridFormPopoutMenu = GridFormPopoutMenu;
|
|
3844
|
+
exports.GridFormSubComponentTextInput = GridFormSubComponentTextInput;
|
|
3777
3845
|
exports.GridHeaderSelect = GridHeaderSelect;
|
|
3778
3846
|
exports.GridIcon = GridIcon;
|
|
3779
3847
|
exports.GridLoadableCell = GridLoadableCell;
|