@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 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 (ref) {
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.maxlength && value.length > props.maxlength) {
3519
- return "Text must be no longer than ".concat(props.maxlength, " characters");
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.maxlength && trimmedValue.length > props.maxlength) {
3566
- return "Text must be no longer than ".concat(props.maxlength, " characters");
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 = props.value, setValue = props.setValue, setValid = props.setValid, triggerSave = props.triggerSave;
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.maxlength && value.length > props.maxlength) {
3623
- return "Text must be no longer than ".concat(props.maxlength, " characters");
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) {