@linzjs/step-ag-grid 4.0.0 → 4.0.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 +29 -25
- package/dist/index.js.map +1 -1
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +3 -2
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +3 -2
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
- package/dist/src/contexts/GridSubComponentContext.d.ts +1 -0
- package/dist/src/utils/textValidator.d.ts +4 -3
- package/dist/step-ag-grid.esm.js +29 -25
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +2 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +2 -1
- package/src/components/gridForm/GridFormPopoverMenu.tsx +2 -1
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +10 -5
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +10 -5
- package/src/components/gridForm/GridFormTextArea.tsx +7 -5
- package/src/components/gridForm/GridFormTextInput.tsx +7 -5
- package/src/contexts/GridSubComponentContext.ts +2 -0
- package/src/utils/textValidator.ts +10 -4
package/dist/index.js
CHANGED
|
@@ -2246,6 +2246,7 @@ var GridPopoverContextProvider = function (_a) {
|
|
|
2246
2246
|
|
|
2247
2247
|
var GridSubComponentContext = react.createContext({
|
|
2248
2248
|
value: "GridSubComponentContext value no context",
|
|
2249
|
+
data: {},
|
|
2249
2250
|
setValue: function () {
|
|
2250
2251
|
console.error("GridSubComponentContext setValue no context");
|
|
2251
2252
|
},
|
|
@@ -3017,7 +3018,7 @@ var fieldToString = function (field) {
|
|
|
3017
3018
|
return typeof field == "symbol" ? field.toString() : "".concat(field);
|
|
3018
3019
|
};
|
|
3019
3020
|
var GridFormDropDown = function (props) {
|
|
3020
|
-
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue;
|
|
3021
|
+
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
|
|
3021
3022
|
var stopEditing = react.useContext(GridContext).stopEditing;
|
|
3022
3023
|
var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
|
|
3023
3024
|
var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
|
|
@@ -3210,6 +3211,7 @@ var GridFormDropDown = function (props) {
|
|
|
3210
3211
|
selectItemHandler(item.value).then();
|
|
3211
3212
|
}
|
|
3212
3213
|
} }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedSubComponent === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3214
|
+
data: data,
|
|
3213
3215
|
value: subSelectedValue,
|
|
3214
3216
|
setValue: function (value) {
|
|
3215
3217
|
setSubSelectedValue(value);
|
|
@@ -3228,18 +3230,18 @@ var GridFormDropDown = function (props) {
|
|
|
3228
3230
|
};
|
|
3229
3231
|
|
|
3230
3232
|
var GridFormMultiSelect = function (props) {
|
|
3231
|
-
var
|
|
3233
|
+
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, data = _a.data;
|
|
3232
3234
|
var initialiseValues = react.useMemo(function () {
|
|
3233
3235
|
var r = props.initialSelectedValues && props.initialSelectedValues(selectedRows);
|
|
3234
3236
|
// convert array of strings to object<value,null>
|
|
3235
3237
|
return Array.isArray(r) ? lodashEs.fromPairs(r.map(function (v) { return [v, null]; })) : r;
|
|
3236
3238
|
}, [props, selectedRows]);
|
|
3237
3239
|
var subComponentIsValid = react.useRef({});
|
|
3238
|
-
var
|
|
3239
|
-
var
|
|
3240
|
-
var
|
|
3240
|
+
var _b = react.useState(function () { return initialiseValues !== null && initialiseValues !== void 0 ? initialiseValues : {}; }), selectedValues = _b[0], setSelectedValues = _b[1];
|
|
3241
|
+
var _c = react.useState(""), filter = _c[0], setFilter = _c[1];
|
|
3242
|
+
var _d = react.useState([]), filteredValues = _d[0], setFilteredValues = _d[1];
|
|
3241
3243
|
var optionsInitialising = react.useRef(false);
|
|
3242
|
-
var
|
|
3244
|
+
var _e = react.useState(), options = _e[0], setOptions = _e[1];
|
|
3243
3245
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3244
3246
|
var validations, notValid, menuOptionSubValueResult;
|
|
3245
3247
|
return __generator(this, function (_a) {
|
|
@@ -3331,10 +3333,10 @@ var GridFormMultiSelect = function (props) {
|
|
|
3331
3333
|
setSelectedValues(__assign(__assign({}, selectedValues), (_a = {}, _a["".concat(item.value)] = null, _a)));
|
|
3332
3334
|
}
|
|
3333
3335
|
}, [selectedValues]);
|
|
3334
|
-
var
|
|
3336
|
+
var _f = useGridPopoverHook({
|
|
3335
3337
|
className: props.className,
|
|
3336
3338
|
save: save
|
|
3337
|
-
}), popoverWrapper =
|
|
3339
|
+
}), popoverWrapper = _f.popoverWrapper, lastInputKeyboardEventHandlers = _f.lastInputKeyboardEventHandlers, triggerSave = _f.triggerSave;
|
|
3338
3340
|
return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormMultiSelect-container" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && props.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
|
|
3339
3341
|
var _b;
|
|
3340
3342
|
var ref = _a.ref;
|
|
@@ -3354,6 +3356,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
3354
3356
|
/*Do nothing, change handled by menuItem*/
|
|
3355
3357
|
} }) })), "".concat(item.value) in selectedValues && item.subComponent && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
|
|
3356
3358
|
return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3359
|
+
data: data,
|
|
3357
3360
|
value: selectedValues["".concat(item.value)],
|
|
3358
3361
|
setValue: function (value) {
|
|
3359
3362
|
var _a;
|
|
@@ -3382,7 +3385,7 @@ var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
|
|
|
3382
3385
|
* you need a useMemo around your columnDefs
|
|
3383
3386
|
*/
|
|
3384
3387
|
var GridFormPopoverMenu = function (props) {
|
|
3385
|
-
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, updateValue = _a.updateValue;
|
|
3388
|
+
var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, updateValue = _a.updateValue, data = _a.data;
|
|
3386
3389
|
var optionsInitialising = react.useRef(false);
|
|
3387
3390
|
var _b = react.useState(), options = _b[0], setOptions = _b[1];
|
|
3388
3391
|
// Save triggers during async action processing which triggers another action(), this ref blocks that
|
|
@@ -3500,6 +3503,7 @@ var GridFormPopoverMenu = function (props) {
|
|
|
3500
3503
|
return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !filteredOptions, className: "GridFormPopupMenu" }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
3501
3504
|
return item.label === PopoutMenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) { return onMenuItemClick(e, item); }, disabled: !!item.disabled || !(filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.includes(item)), title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "" }, { children: item.label }), "".concat(item.label)), item.subComponent && subComponentSelected === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
|
|
3502
3505
|
return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3506
|
+
data: data,
|
|
3503
3507
|
value: subSelectedValue,
|
|
3504
3508
|
setValue: function (value) {
|
|
3505
3509
|
setSubSelectedValue(value);
|
|
@@ -3804,7 +3808,7 @@ var TextAreaInput = function (props) {
|
|
|
3804
3808
|
} }, { children: props.helpText })))] })));
|
|
3805
3809
|
};
|
|
3806
3810
|
|
|
3807
|
-
var TextInputValidator = function (props, value) {
|
|
3811
|
+
var TextInputValidator = function (props, value, data) {
|
|
3808
3812
|
if (value == null)
|
|
3809
3813
|
return null;
|
|
3810
3814
|
// This can happen because subcomponent is invoked without type safety
|
|
@@ -3818,17 +3822,17 @@ var TextInputValidator = function (props, value) {
|
|
|
3818
3822
|
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3819
3823
|
}
|
|
3820
3824
|
if (props.validate) {
|
|
3821
|
-
return props.validate(value);
|
|
3825
|
+
return props.validate(value, data);
|
|
3822
3826
|
}
|
|
3823
3827
|
return null;
|
|
3824
3828
|
};
|
|
3825
3829
|
|
|
3826
3830
|
var GridFormTextArea = function (props) {
|
|
3827
3831
|
var _a, _b;
|
|
3828
|
-
var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
|
|
3832
|
+
var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value, data = _c.data;
|
|
3829
3833
|
var _d = react.useState(initialVale != null ? "".concat(initialVale) : ""), value = _d[0], setValue = _d[1];
|
|
3830
3834
|
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
|
|
3831
|
-
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3835
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [props, value, data]);
|
|
3832
3836
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3833
3837
|
return __generator(this, function (_a) {
|
|
3834
3838
|
switch (_a.label) {
|
|
@@ -3852,19 +3856,19 @@ var GridFormTextArea = function (props) {
|
|
|
3852
3856
|
}
|
|
3853
3857
|
});
|
|
3854
3858
|
}); }, [invalid, initialVale, value, props, field]);
|
|
3855
|
-
var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper,
|
|
3856
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsxRuntime.jsx(TextAreaInput, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText },
|
|
3859
|
+
var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
|
|
3860
|
+
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsxRuntime.jsx(TextAreaInput, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText }, onlyInputKeyboardEventHandlers)) })));
|
|
3857
3861
|
};
|
|
3858
3862
|
|
|
3859
3863
|
var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
|
|
3860
3864
|
|
|
3861
3865
|
var GridFormTextInput = function (props) {
|
|
3862
3866
|
var _a, _b;
|
|
3863
|
-
var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
|
|
3867
|
+
var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value, data = _c.data;
|
|
3864
3868
|
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
|
|
3865
3869
|
var initValue = initialVale == null ? "" : "".concat(initialVale);
|
|
3866
3870
|
var _d = react.useState(initValue), value = _d[0], setValue = _d[1];
|
|
3867
|
-
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3871
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [data, props, value]);
|
|
3868
3872
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3869
3873
|
var trimmedValue;
|
|
3870
3874
|
return __generator(this, function (_a) {
|
|
@@ -3890,8 +3894,8 @@ var GridFormTextInput = function (props) {
|
|
|
3890
3894
|
}
|
|
3891
3895
|
});
|
|
3892
3896
|
}); }, [invalid, value, initValue, props, field]);
|
|
3893
|
-
var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper,
|
|
3894
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, style: { width: "100%" }, placeholder: props.placeholder },
|
|
3897
|
+
var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
|
|
3898
|
+
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, style: { width: "100%" }, placeholder: props.placeholder }, onlyInputKeyboardEventHandlers, { helpText: helpText })) })));
|
|
3895
3899
|
};
|
|
3896
3900
|
|
|
3897
3901
|
var GridPopoverTextInput = function (colDef, params) {
|
|
@@ -3900,14 +3904,14 @@ var GridPopoverTextInput = function (colDef, params) {
|
|
|
3900
3904
|
|
|
3901
3905
|
var GridFormSubComponentTextInput = function (props) {
|
|
3902
3906
|
var _a;
|
|
3903
|
-
var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
|
|
3907
|
+
var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave, data = _b.data;
|
|
3904
3908
|
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
|
|
3905
3909
|
// If is not initialised yet as it's just been created then set the default value
|
|
3906
3910
|
react.useEffect(function () {
|
|
3907
3911
|
if (value == null)
|
|
3908
3912
|
setValue(props.defaultValue);
|
|
3909
3913
|
}, [props.defaultValue, setValue, value]);
|
|
3910
|
-
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3914
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [data, props, value]);
|
|
3911
3915
|
react.useEffect(function () {
|
|
3912
3916
|
setValid(value != null && invalid() == null);
|
|
3913
3917
|
}, [setValid, invalid, value]);
|
|
@@ -3918,9 +3922,9 @@ var GridFormSubComponentTextInput = function (props) {
|
|
|
3918
3922
|
}
|
|
3919
3923
|
}, onKeyUp: function (e) {
|
|
3920
3924
|
if (e.key === "Tab") {
|
|
3921
|
-
!e.shiftKey && triggerSave().then();
|
|
3922
3925
|
e.preventDefault();
|
|
3923
3926
|
e.stopPropagation();
|
|
3927
|
+
!e.shiftKey && triggerSave().then();
|
|
3924
3928
|
}
|
|
3925
3929
|
else if (e.key === "Enter") {
|
|
3926
3930
|
triggerSave().then();
|
|
@@ -3934,14 +3938,14 @@ var GridFormSubComponentTextInput = function (props) {
|
|
|
3934
3938
|
|
|
3935
3939
|
var GridFormSubComponentTextArea = function (props) {
|
|
3936
3940
|
var _a;
|
|
3937
|
-
var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
|
|
3941
|
+
var _b = react.useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
|
|
3938
3942
|
var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
|
|
3939
3943
|
// If is not initialised yet as it's just been created then set the default value
|
|
3940
3944
|
react.useEffect(function () {
|
|
3941
3945
|
if (value == null)
|
|
3942
3946
|
setValue(props.defaultValue);
|
|
3943
3947
|
}, [props.defaultValue, setValue, value]);
|
|
3944
|
-
var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
|
|
3948
|
+
var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [data, props, value]);
|
|
3945
3949
|
react.useEffect(function () {
|
|
3946
3950
|
setValid(value != null && invalid() == null);
|
|
3947
3951
|
}, [setValid, invalid, value]);
|
|
@@ -3952,9 +3956,9 @@ var GridFormSubComponentTextArea = function (props) {
|
|
|
3952
3956
|
}
|
|
3953
3957
|
}, onKeyUp: function (e) {
|
|
3954
3958
|
if (e.key === "Tab") {
|
|
3955
|
-
!e.shiftKey && triggerSave().then();
|
|
3956
3959
|
e.preventDefault();
|
|
3957
3960
|
e.stopPropagation();
|
|
3961
|
+
!e.shiftKey && triggerSave().then();
|
|
3958
3962
|
}
|
|
3959
3963
|
} }) })));
|
|
3960
3964
|
};
|