@linzjs/step-ag-grid 2.2.2 → 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 +76 -31
- 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 +77 -32
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -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/GridPopoutEditMultiSelect.stories.tsx +16 -7
package/dist/index.js
CHANGED
|
@@ -3002,27 +3002,39 @@ var GridFormDropDown = function (_props) {
|
|
|
3002
3002
|
|
|
3003
3003
|
var GridFormMultiSelect = function (props) {
|
|
3004
3004
|
var selectedRows = props.selectedRows;
|
|
3005
|
-
var
|
|
3006
|
-
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];
|
|
3007
3015
|
var optionsInitialising = react.useRef(false);
|
|
3008
|
-
var
|
|
3009
|
-
var subSelectedValues = react.useRef({});
|
|
3010
|
-
var _d = react.useState(function () {
|
|
3011
|
-
return props.initialSelectedValues ? props.initialSelectedValues(selectedRows) : [];
|
|
3012
|
-
}), selectedValues = _d[0], setSelectedValues = _d[1];
|
|
3016
|
+
var _e = react.useState(), options = _e[0], setOptions = _e[1];
|
|
3013
3017
|
var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3014
|
-
var
|
|
3015
|
-
|
|
3016
|
-
|
|
3018
|
+
var validations, notValid, selectedOptions, selectedResults;
|
|
3019
|
+
var _a;
|
|
3020
|
+
return __generator(this, function (_b) {
|
|
3021
|
+
switch (_b.label) {
|
|
3017
3022
|
case 0:
|
|
3018
|
-
values = lodashEs.fromPairs(selectedValues.map(function (value) { var _a; return [value, (_a = subSelectedValues.current[value]) !== null && _a !== void 0 ? _a : true]; }));
|
|
3019
3023
|
if (!props.onSave) return [3 /*break*/, 2];
|
|
3020
|
-
|
|
3021
|
-
|
|
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()];
|
|
3022
3034
|
case 2: return [2 /*return*/, true];
|
|
3023
3035
|
}
|
|
3024
3036
|
});
|
|
3025
|
-
}); }, [props, selectedValues]);
|
|
3037
|
+
}); }, [options, props, selectedValues, subSelectedValues]);
|
|
3026
3038
|
// Load up options list if it's async function
|
|
3027
3039
|
react.useEffect(function () {
|
|
3028
3040
|
var _a;
|
|
@@ -3075,7 +3087,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
3075
3087
|
})
|
|
3076
3088
|
.filter(function (r) { return r !== undefined; }));
|
|
3077
3089
|
}, [props.filtered, filter, options]);
|
|
3078
|
-
var
|
|
3090
|
+
var _f = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _f.popoverWrapper, triggerSave = _f.triggerSave;
|
|
3079
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) {
|
|
3080
3092
|
var _b;
|
|
3081
3093
|
var ref = _a.ref;
|
|
@@ -3117,16 +3129,23 @@ var GridFormMultiSelect = function (props) {
|
|
|
3117
3129
|
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
|
|
3118
3130
|
return item.subComponent &&
|
|
3119
3131
|
item.subComponent({
|
|
3132
|
+
ref: ref,
|
|
3133
|
+
value: subSelectedValues["".concat(item.value)],
|
|
3120
3134
|
setValue: function (value) {
|
|
3121
|
-
subSelectedValues.
|
|
3122
|
-
|
|
3123
|
-
|
|
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
|
+
});
|
|
3124
3143
|
} }), "".concat(item.value, "_subcomponent")))] }, "".concat(index)));
|
|
3125
3144
|
}) }))] }) })));
|
|
3126
3145
|
};
|
|
3127
3146
|
|
|
3128
3147
|
var GridPopoutEditMultiSelect = function (colDef, props) {
|
|
3129
|
-
return GridCell(
|
|
3148
|
+
return GridCell(colDef, __assign(__assign({ editor: GridFormMultiSelect }, props), { editorParams: __assign({ className: "GridMultiSelect-containerMedium" }, props.editorParams) }));
|
|
3130
3149
|
};
|
|
3131
3150
|
|
|
3132
3151
|
var css_248z$3 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
|
|
@@ -3300,7 +3319,7 @@ var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#b
|
|
|
3300
3319
|
styleInject(css_248z$1);
|
|
3301
3320
|
|
|
3302
3321
|
var TextInputFormatted = function (props) {
|
|
3303
|
-
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] })))] })));
|
|
3304
3323
|
};
|
|
3305
3324
|
|
|
3306
3325
|
var GridFormEditBearing = function (_props) {
|
|
@@ -3382,7 +3401,7 @@ var GridPopoverEditBearingCorrection = function (colDef, props) {
|
|
|
3382
3401
|
};
|
|
3383
3402
|
|
|
3384
3403
|
var GridPopoverEditDropDown = function (colDef, props) {
|
|
3385
|
-
return GridCell(
|
|
3404
|
+
return GridCell(colDef, __assign(__assign({ editor: GridFormDropDown }, props), { editorParams: __assign({
|
|
3386
3405
|
// Defaults to medium size container
|
|
3387
3406
|
className: "GridPopoverEditDropDown-containerMedium" }, props.editorParams) }));
|
|
3388
3407
|
};
|
|
@@ -3410,7 +3429,7 @@ var GridFormMessage = function (_props) {
|
|
|
3410
3429
|
};
|
|
3411
3430
|
|
|
3412
3431
|
var GridPopoverMessage = function (colDef, props) {
|
|
3413
|
-
return GridCell(__assign(__assign({
|
|
3432
|
+
return GridCell(__assign(__assign({}, colDef), { cellRendererParams: __assign({ singleClickEdit: true }, colDef.cellRendererParams) }), __assign({ editor: GridFormMessage }, props));
|
|
3414
3433
|
};
|
|
3415
3434
|
|
|
3416
3435
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
@@ -3531,9 +3550,7 @@ var GridFormTextArea = function (_props) {
|
|
|
3531
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 } }) })));
|
|
3532
3551
|
};
|
|
3533
3552
|
|
|
3534
|
-
var GridPopoverTextArea = function (colDef, params) {
|
|
3535
|
-
return GridCell(__assign({ maxWidth: 260 }, colDef), __assign({ editor: GridFormTextArea }, params));
|
|
3536
|
-
};
|
|
3553
|
+
var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
|
|
3537
3554
|
|
|
3538
3555
|
var GridFormTextInput = function (_props) {
|
|
3539
3556
|
var _a;
|
|
@@ -3578,7 +3595,12 @@ var GridFormTextInput = function (_props) {
|
|
|
3578
3595
|
});
|
|
3579
3596
|
}); }, [invalid, value, initValue, props]);
|
|
3580
3597
|
var _c = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _c.popoverWrapper, triggerSave = _c.triggerSave;
|
|
3581
|
-
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: {
|
|
3582
3604
|
style: { width: "100%" },
|
|
3583
3605
|
placeholder: props.placeholder,
|
|
3584
3606
|
onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -3588,15 +3610,38 @@ var GridFormTextInput = function (_props) {
|
|
|
3588
3610
|
};
|
|
3589
3611
|
|
|
3590
3612
|
var GridPopoverTextInput = function (colDef, params) {
|
|
3591
|
-
return GridCell(
|
|
3613
|
+
return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
|
|
3592
3614
|
};
|
|
3593
3615
|
|
|
3594
3616
|
var GridSubComponentTextArea = function (props) {
|
|
3595
|
-
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]);
|
|
3596
3630
|
react.useEffect(function () {
|
|
3597
|
-
|
|
3598
|
-
}, [
|
|
3599
|
-
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
|
+
} }) })));
|
|
3600
3645
|
};
|
|
3601
3646
|
|
|
3602
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}";
|