@linzjs/step-ag-grid 2.2.1 → 2.3.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.js +81 -32
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridSubComponentTextArea.d.ts +7 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +6 -7
- package/dist/src/components/gridForm/GridSubComponentProps.d.ts +6 -0
- package/dist/src/lui/TextInputFormatted.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +82 -33
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +5 -1
- package/src/components/GridSubComponentTextArea.tsx +42 -12
- package/src/components/gridForm/GridFormDropDown.tsx +1 -0
- package/src/components/gridForm/GridFormMultiSelect.tsx +50 -24
- package/src/components/gridForm/GridFormTextInput.tsx +6 -0
- package/src/components/gridForm/GridSubComponentProps.ts +6 -0
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +7 -14
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +6 -9
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +8 -15
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +2 -4
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +1 -8
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +5 -12
- package/src/lui/TextInputFormatted.tsx +4 -1
- package/src/stories/grid/FormTest.tsx +51 -11
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +16 -7
package/dist/index.js
CHANGED
|
@@ -2710,7 +2710,11 @@ var useGridPopoverHook = function (props) {
|
|
|
2710
2710
|
});
|
|
2711
2711
|
}); }, [props, stopEditing, propsRef]);
|
|
2712
2712
|
var popoverWrapper = react.useCallback(function (children) {
|
|
2713
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: anchorRef.current && (jsxRuntime.jsxs(ControlledMenu, __assign({ state: isOpen ? "open" : "closed", portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: "step-ag-grid-react-menu", onClose: function (event) {
|
|
2713
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: anchorRef.current && (jsxRuntime.jsxs(ControlledMenu, __assign({ state: isOpen ? "open" : "closed", portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: "step-ag-grid-react-menu", onClose: function (event) {
|
|
2714
|
+
if (event.reason === "blur")
|
|
2715
|
+
return;
|
|
2716
|
+
triggerSave(event.reason).then();
|
|
2717
|
+
}, viewScroll: "auto", dontShrinkIfDirectionIsTop: true, className: props.className, closeMenuExclusionClassName: "ReactModal__Content" }, { children: [saving && ( // This is the overlay that prevents editing when the editor is saving
|
|
2714
2718
|
jsxRuntime.jsx("div", { style: {
|
|
2715
2719
|
position: "absolute",
|
|
2716
2720
|
left: 0,
|
|
@@ -2998,27 +3002,39 @@ var GridFormDropDown = function (_props) {
|
|
|
2998
3002
|
|
|
2999
3003
|
var GridFormMultiSelect = function (props) {
|
|
3000
3004
|
var selectedRows = props.selectedRows;
|
|
3001
|
-
var
|
|
3002
|
-
var
|
|
3005
|
+
var initialiseValues = react.useMemo(function () { return props.initialSelectedValues && props.initialSelectedValues(selectedRows); }, [props, selectedRows]);
|
|
3006
|
+
var subComponentIsValid = react.useRef({});
|
|
3007
|
+
var _a = react.useState(initialiseValues && !Array.isArray(initialiseValues)
|
|
3008
|
+
? lodashEs.pickBy(initialiseValues, function (value) { return typeof value !== "boolean"; })
|
|
3009
|
+
: {}), subSelectedValues = _a[0], setSubSelectedValues = _a[1];
|
|
3010
|
+
var _b = react.useState(function () {
|
|
3011
|
+
return initialiseValues ? (Array.isArray(initialiseValues) ? initialiseValues : Object.keys(initialiseValues)) : [];
|
|
3012
|
+
}), selectedValues = _b[0], setSelectedValues = _b[1];
|
|
3013
|
+
var _c = react.useState(""), filter = _c[0], setFilter = _c[1];
|
|
3014
|
+
var _d = react.useState([]), filteredValues = _d[0], setFilteredValues = _d[1];
|
|
3003
3015
|
var optionsInitialising = react.useRef(false);
|
|
3004
|
-
var
|
|
3005
|
-
var subSelectedValues = react.useRef({});
|
|
3006
|
-
var _d = react.useState(function () {
|
|
3007
|
-
return props.initialSelectedValues ? props.initialSelectedValues(selectedRows) : [];
|
|
3008
|
-
}), selectedValues = _d[0], setSelectedValues = _d[1];
|
|
3016
|
+
var _e = react.useState(), options = _e[0], setOptions = _e[1];
|
|
3009
3017
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3010
|
-
var
|
|
3011
|
-
|
|
3012
|
-
|
|
3018
|
+
var validations, notValid, selectedOptions, selectedResults;
|
|
3019
|
+
var _a;
|
|
3020
|
+
return __generator(this, function (_b) {
|
|
3021
|
+
switch (_b.label) {
|
|
3013
3022
|
case 0:
|
|
3014
|
-
values = lodashEs.fromPairs(selectedValues.map(function (value) { var _a; return [value, (_a = subSelectedValues.current[value]) !== null && _a !== void 0 ? _a : true]; }));
|
|
3015
3023
|
if (!props.onSave) return [3 /*break*/, 2];
|
|
3016
|
-
|
|
3017
|
-
|
|
3024
|
+
validations = lodashEs.pick(subComponentIsValid.current, selectedValues);
|
|
3025
|
+
notValid = Object.values(validations).some(function (v) { return !v; });
|
|
3026
|
+
if (notValid)
|
|
3027
|
+
return [2 /*return*/, false];
|
|
3028
|
+
selectedOptions = (_a = selectedValues.map(function (row) { return (options !== null && options !== void 0 ? options : []).find(function (opt) { return opt.value == row; }); })) !== null && _a !== void 0 ? _a : [];
|
|
3029
|
+
selectedResults = selectedOptions.map(function (selectedOption) {
|
|
3030
|
+
return (__assign(__assign({}, selectedOption), { subValue: subSelectedValues["".concat(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value)] }));
|
|
3031
|
+
});
|
|
3032
|
+
return [4 /*yield*/, props.onSave(selectedRows, selectedResults)];
|
|
3033
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
3018
3034
|
case 2: return [2 /*return*/, true];
|
|
3019
3035
|
}
|
|
3020
3036
|
});
|
|
3021
|
-
}); }, [props, selectedValues]);
|
|
3037
|
+
}); }, [options, props, selectedValues, subSelectedValues]);
|
|
3022
3038
|
// Load up options list if it's async function
|
|
3023
3039
|
react.useEffect(function () {
|
|
3024
3040
|
var _a;
|
|
@@ -3071,7 +3087,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
3071
3087
|
})
|
|
3072
3088
|
.filter(function (r) { return r !== undefined; }));
|
|
3073
3089
|
}, [props.filtered, filter, options]);
|
|
3074
|
-
var
|
|
3090
|
+
var _f = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _f.popoverWrapper, triggerSave = _f.triggerSave;
|
|
3075
3091
|
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) {
|
|
3076
3092
|
var _b;
|
|
3077
3093
|
var ref = _a.ref;
|
|
@@ -3113,16 +3129,23 @@ var GridFormMultiSelect = function (props) {
|
|
|
3113
3129
|
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
|
|
3114
3130
|
return item.subComponent &&
|
|
3115
3131
|
item.subComponent({
|
|
3132
|
+
ref: ref,
|
|
3133
|
+
value: subSelectedValues["".concat(item.value)],
|
|
3116
3134
|
setValue: function (value) {
|
|
3117
|
-
subSelectedValues.
|
|
3118
|
-
|
|
3119
|
-
|
|
3135
|
+
subSelectedValues["".concat(item.value)] = value;
|
|
3136
|
+
setSubSelectedValues(__assign({}, subSelectedValues));
|
|
3137
|
+
},
|
|
3138
|
+
setValid: function (valid) {
|
|
3139
|
+
subComponentIsValid.current["".concat(item.value)] = valid;
|
|
3140
|
+
},
|
|
3141
|
+
triggerSave: triggerSave
|
|
3142
|
+
});
|
|
3120
3143
|
} }), "".concat(item.value, "_subcomponent")))] }, "".concat(index)));
|
|
3121
3144
|
}) }))] }) })));
|
|
3122
3145
|
};
|
|
3123
3146
|
|
|
3124
3147
|
var GridPopoutEditMultiSelect = function (colDef, props) {
|
|
3125
|
-
return GridCell(
|
|
3148
|
+
return GridCell(colDef, __assign(__assign({ editor: GridFormMultiSelect }, props), { editorParams: __assign({ className: "GridMultiSelect-containerMedium" }, props.editorParams) }));
|
|
3126
3149
|
};
|
|
3127
3150
|
|
|
3128
3151
|
var css_248z$3 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
|
|
@@ -3296,7 +3319,7 @@ var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#b
|
|
|
3296
3319
|
styleInject(css_248z$1);
|
|
3297
3320
|
|
|
3298
3321
|
var TextInputFormatted = function (props) {
|
|
3299
|
-
return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.warning && "hasWarning", props.className) }, { children: [jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsxRuntime.jsx("input", __assign({ type: "text", className: "LuiTextInput-input", min: "0",
|
|
3322
|
+
return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.warning && "hasWarning", props.className) }, { children: [jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsxRuntime.jsx("input", __assign({ type: "text", className: "LuiTextInput-input", min: "0", spellCheck: true, defaultValue: props.value, onChange: props.onChange }, props.inputProps)), jsxRuntime.jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), props.error && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-error" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.warning && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-warning" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "warning", name: "ic_warning", className: "LuiTextInput-warning-icon", size: "sm", status: "warning" }), props.warning] })))] })));
|
|
3300
3323
|
};
|
|
3301
3324
|
|
|
3302
3325
|
var GridFormEditBearing = function (_props) {
|
|
@@ -3378,7 +3401,7 @@ var GridPopoverEditBearingCorrection = function (colDef, props) {
|
|
|
3378
3401
|
};
|
|
3379
3402
|
|
|
3380
3403
|
var GridPopoverEditDropDown = function (colDef, props) {
|
|
3381
|
-
return GridCell(
|
|
3404
|
+
return GridCell(colDef, __assign(__assign({ editor: GridFormDropDown }, props), { editorParams: __assign({
|
|
3382
3405
|
// Defaults to medium size container
|
|
3383
3406
|
className: "GridPopoverEditDropDown-containerMedium" }, props.editorParams) }));
|
|
3384
3407
|
};
|
|
@@ -3406,7 +3429,7 @@ var GridFormMessage = function (_props) {
|
|
|
3406
3429
|
};
|
|
3407
3430
|
|
|
3408
3431
|
var GridPopoverMessage = function (colDef, props) {
|
|
3409
|
-
return GridCell(__assign(__assign({
|
|
3432
|
+
return GridCell(__assign(__assign({}, colDef), { cellRendererParams: __assign({ singleClickEdit: true }, colDef.cellRendererParams) }), __assign({ editor: GridFormMessage }, props));
|
|
3410
3433
|
};
|
|
3411
3434
|
|
|
3412
3435
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
@@ -3527,9 +3550,7 @@ var GridFormTextArea = function (_props) {
|
|
|
3527
3550
|
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, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), inputProps: { placeholder: props.placeholder } }) })));
|
|
3528
3551
|
};
|
|
3529
3552
|
|
|
3530
|
-
var GridPopoverTextArea = function (colDef, params) {
|
|
3531
|
-
return GridCell(__assign({ maxWidth: 260 }, colDef), __assign({ editor: GridFormTextArea }, params));
|
|
3532
|
-
};
|
|
3553
|
+
var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
|
|
3533
3554
|
|
|
3534
3555
|
var GridFormTextInput = function (_props) {
|
|
3535
3556
|
var _a;
|
|
@@ -3574,7 +3595,12 @@ var GridFormTextInput = function (_props) {
|
|
|
3574
3595
|
});
|
|
3575
3596
|
}); }, [invalid, value, initValue, props]);
|
|
3576
3597
|
var _c = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _c.popoverWrapper, triggerSave = _c.triggerSave;
|
|
3577
|
-
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_a = props.width) !== null && _a !== void 0 ? _a : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units,
|
|
3598
|
+
return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_a = props.width) !== null && _a !== void 0 ? _a : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, onMouseEnter: function (e) {
|
|
3599
|
+
if (document.activeElement != e.currentTarget) {
|
|
3600
|
+
e.currentTarget.focus();
|
|
3601
|
+
e.currentTarget.selectionStart = e.currentTarget.value.length;
|
|
3602
|
+
}
|
|
3603
|
+
}, inputProps: {
|
|
3578
3604
|
style: { width: "100%" },
|
|
3579
3605
|
placeholder: props.placeholder,
|
|
3580
3606
|
onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -3584,15 +3610,38 @@ var GridFormTextInput = function (_props) {
|
|
|
3584
3610
|
};
|
|
3585
3611
|
|
|
3586
3612
|
var GridPopoverTextInput = function (colDef, params) {
|
|
3587
|
-
return GridCell(
|
|
3613
|
+
return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
|
|
3588
3614
|
};
|
|
3589
3615
|
|
|
3590
3616
|
var GridSubComponentTextArea = function (props) {
|
|
3591
|
-
var
|
|
3617
|
+
var value = props.value, setValue = props.setValue, setValid = props.setValid, triggerSave = props.triggerSave;
|
|
3618
|
+
var validate = react.useCallback(function (value) {
|
|
3619
|
+
if (props.required && value.length === 0) {
|
|
3620
|
+
return "Some text is required";
|
|
3621
|
+
}
|
|
3622
|
+
if (props.maxlength && value.length > props.maxlength) {
|
|
3623
|
+
return "Text must be no longer than ".concat(props.maxlength, " characters");
|
|
3624
|
+
}
|
|
3625
|
+
if (props.validate) {
|
|
3626
|
+
return props.validate(value);
|
|
3627
|
+
}
|
|
3628
|
+
return null;
|
|
3629
|
+
}, [props]);
|
|
3592
3630
|
react.useEffect(function () {
|
|
3593
|
-
|
|
3594
|
-
}, [
|
|
3595
|
-
return (jsxRuntime.jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsxRuntime.jsx(
|
|
3631
|
+
setValid(validate(value) == null);
|
|
3632
|
+
}, [setValid, validate, value]);
|
|
3633
|
+
return (jsxRuntime.jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsxRuntime.jsx(TextInputFormatted, { className: "free-text-input", value: value, onMouseEnter: function (e) {
|
|
3634
|
+
if (document.activeElement != e.currentTarget) {
|
|
3635
|
+
e.currentTarget.focus();
|
|
3636
|
+
e.currentTarget.selectionStart = e.currentTarget.value.length;
|
|
3637
|
+
}
|
|
3638
|
+
}, onChange: function (e) { return setValue(e.target.value); }, error: validate(value), inputProps: {
|
|
3639
|
+
autoFocus: true,
|
|
3640
|
+
placeholder: props.placeholder,
|
|
3641
|
+
onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3642
|
+
return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
|
|
3643
|
+
}); }); }
|
|
3644
|
+
} }) })));
|
|
3596
3645
|
};
|
|
3597
3646
|
|
|
3598
3647
|
var css_248z = ".ActionButton{align-items:center;display:flex}.ActionButton .LuiIcon{margin:0 4px!important}.ActionButton-minimalArea{position:relative}.ActionButton-minimalAreaDisplay{position:absolute}.ActionButton-minimalAreaExpand{visibility:hidden}.ActionButton-inProgress{background-color:#e2f3f7!important;color:#007198!important;cursor:progress}.ActionButton-inProgress svg *{fill:#0000!important}";
|