@linzjs/step-ag-grid 2.3.1 → 2.4.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 +38 -13
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridSubComponentTextArea.d.ts +4 -4
- 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 +8 -0
- package/dist/step-ag-grid.esm.js +38 -13
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridSubComponentTextArea.tsx +22 -10
- package/src/components/gridForm/GridFormMultiSelect.tsx +19 -15
- package/src/components/gridForm/GridFormTextArea.tsx +3 -3
- package/src/components/gridForm/GridFormTextInput.tsx +3 -3
- package/src/contexts/GridSubComponentContext.ts +21 -0
- package/src/stories/components/ActionButton.stories.tsx +1 -1
- package/src/stories/grid/FormTest.tsx +5 -6
- package/src/stories/grid/GridPopoutBearing.stories.tsx +1 -1
- package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +1 -1
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +1 -1
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +3 -3
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +2 -2
- package/src/stories/grid/GridReadOnly.stories.tsx +1 -1
- package/dist/src/components/gridForm/GridSubComponentProps.d.ts +0 -6
- package/src/components/gridForm/GridSubComponentProps.ts +0 -6
package/dist/index.js
CHANGED
|
@@ -3000,6 +3000,22 @@ var GridFormDropDown = function (_props) {
|
|
|
3000
3000
|
})] }) }))] }));
|
|
3001
3001
|
};
|
|
3002
3002
|
|
|
3003
|
+
var GridSubComponentContext = react.createContext({
|
|
3004
|
+
value: "GridSubComponentContext value no context",
|
|
3005
|
+
setValue: function () {
|
|
3006
|
+
console.error("GridSubComponentContext setValue no context");
|
|
3007
|
+
},
|
|
3008
|
+
setValid: function () {
|
|
3009
|
+
console.error("GridSubComponentContext setValid no context");
|
|
3010
|
+
},
|
|
3011
|
+
triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3012
|
+
return __generator(this, function (_a) {
|
|
3013
|
+
console.error("GridSubComponentContext triggerSave no context");
|
|
3014
|
+
return [2 /*return*/];
|
|
3015
|
+
});
|
|
3016
|
+
}); }
|
|
3017
|
+
});
|
|
3018
|
+
|
|
3003
3019
|
var GridFormMultiSelect = function (props) {
|
|
3004
3020
|
var selectedRows = props.selectedRows;
|
|
3005
3021
|
var initialiseValues = react.useMemo(function () { return props.initialSelectedValues && props.initialSelectedValues(selectedRows); }, [props, selectedRows]);
|
|
@@ -3126,10 +3142,8 @@ var GridFormMultiSelect = function (props) {
|
|
|
3126
3142
|
}
|
|
3127
3143
|
}, onChange: function () {
|
|
3128
3144
|
/*Do nothing, change handled by menuItem*/
|
|
3129
|
-
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (
|
|
3130
|
-
return item.subComponent &&
|
|
3131
|
-
item.subComponent({
|
|
3132
|
-
ref: ref,
|
|
3145
|
+
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
|
|
3146
|
+
return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3133
3147
|
value: subSelectedValues["".concat(item.value)],
|
|
3134
3148
|
setValue: function (value) {
|
|
3135
3149
|
subSelectedValues["".concat(item.value)] = value;
|
|
@@ -3139,7 +3153,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
3139
3153
|
subComponentIsValid.current["".concat(item.value)] = valid;
|
|
3140
3154
|
},
|
|
3141
3155
|
triggerSave: triggerSave
|
|
3142
|
-
});
|
|
3156
|
+
} }, { children: jsxRuntime.jsx(item.subComponent, {}) })));
|
|
3143
3157
|
} }), "".concat(item.value, "_subcomponent")))] }, "".concat(index)));
|
|
3144
3158
|
}) }))] }) })));
|
|
3145
3159
|
};
|
|
@@ -3515,8 +3529,8 @@ var GridFormTextArea = function (_props) {
|
|
|
3515
3529
|
if (props.required && value.length == 0) {
|
|
3516
3530
|
return "Some text is required";
|
|
3517
3531
|
}
|
|
3518
|
-
if (props.
|
|
3519
|
-
return "Text must be no longer than ".concat(props.
|
|
3532
|
+
if (props.maxLength && value.length > props.maxLength) {
|
|
3533
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3520
3534
|
}
|
|
3521
3535
|
if (props.validate) {
|
|
3522
3536
|
return props.validate(value);
|
|
@@ -3562,8 +3576,8 @@ var GridFormTextInput = function (_props) {
|
|
|
3562
3576
|
if (props.required && trimmedValue.length == 0) {
|
|
3563
3577
|
return "Some text is required";
|
|
3564
3578
|
}
|
|
3565
|
-
if (props.
|
|
3566
|
-
return "Text must be no longer than ".concat(props.
|
|
3579
|
+
if (props.maxLength && trimmedValue.length > props.maxLength) {
|
|
3580
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3567
3581
|
}
|
|
3568
3582
|
if (props.validate) {
|
|
3569
3583
|
return props.validate(trimmedValue, props.data);
|
|
@@ -3614,13 +3628,24 @@ var GridPopoverTextInput = function (colDef, params) {
|
|
|
3614
3628
|
};
|
|
3615
3629
|
|
|
3616
3630
|
var GridSubComponentTextArea = function (props) {
|
|
3617
|
-
var value =
|
|
3631
|
+
var _a = react.useContext(GridSubComponentContext), value = _a.value, setValue = _a.setValue, setValid = _a.setValid, triggerSave = _a.triggerSave;
|
|
3632
|
+
// If is not initialised yet as it's just been created then set the default value
|
|
3633
|
+
react.useEffect(function () {
|
|
3634
|
+
if (value == null)
|
|
3635
|
+
setValue(props.defaultValue);
|
|
3636
|
+
}, [props.defaultValue, setValue, value]);
|
|
3618
3637
|
var validate = react.useCallback(function (value) {
|
|
3638
|
+
if (value == null)
|
|
3639
|
+
return null;
|
|
3640
|
+
// This can happen because subcomponent is invoked without type safety
|
|
3641
|
+
if (typeof value !== "string") {
|
|
3642
|
+
console.error("Value is not a string", value);
|
|
3643
|
+
}
|
|
3619
3644
|
if (props.required && value.length === 0) {
|
|
3620
3645
|
return "Some text is required";
|
|
3621
3646
|
}
|
|
3622
|
-
if (props.
|
|
3623
|
-
return "Text must be no longer than ".concat(props.
|
|
3647
|
+
if (props.maxLength && value.length > props.maxLength) {
|
|
3648
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3624
3649
|
}
|
|
3625
3650
|
if (props.validate) {
|
|
3626
3651
|
return props.validate(value);
|
|
@@ -3628,7 +3653,7 @@ var GridSubComponentTextArea = function (props) {
|
|
|
3628
3653
|
return null;
|
|
3629
3654
|
}, [props]);
|
|
3630
3655
|
react.useEffect(function () {
|
|
3631
|
-
setValid(validate(value) == null);
|
|
3656
|
+
setValid(value != null && validate(value) == null);
|
|
3632
3657
|
}, [setValid, validate, value]);
|
|
3633
3658
|
return (jsxRuntime.jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsxRuntime.jsx(TextInputFormatted, { className: "free-text-input", value: value, onMouseEnter: function (e) {
|
|
3634
3659
|
if (document.activeElement != e.currentTarget) {
|