@bolttech/form-engine 3.0.0-beta.57 → 3.0.0-beta.58

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.
Files changed (2) hide show
  1. package/index.esm.js +12 -4
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -2872,7 +2872,7 @@ const AsFormFieldBuilder = props => {
2872
2872
  * Also has the logic to remove it once this element is removed
2873
2873
  */
2874
2874
  useEffect(() => {
2875
- var _a, _b;
2875
+ var _a, _b, _c, _d;
2876
2876
  if (!((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) {
2877
2877
  context.addFormWithIndex(props.formIndex);
2878
2878
  }
@@ -2888,12 +2888,20 @@ const AsFormFieldBuilder = props => {
2888
2888
  const field = formInstance === null || formInstance === void 0 ? void 0 : formInstance.getField({
2889
2889
  key: props.name
2890
2890
  });
2891
+ /* This line is only for scenario that we have value by the component props */
2891
2892
  if (((_b = props.mapper.events) === null || _b === void 0 ? void 0 : _b.setValue) && props.props) {
2892
2893
  field === null || field === void 0 ? void 0 : field.emitValue({
2893
2894
  value: props.props[props.mapper.events.setValue],
2894
2895
  event: 'ON_FIELD_MOUNT'
2895
2896
  });
2896
2897
  }
2898
+ /* This line is only for scenario that we have value by the instanced form (initialValues) */
2899
+ if ((_c = formInstance === null || formInstance === void 0 ? void 0 : formInstance.initialValues) === null || _c === void 0 ? void 0 : _c[props.nameToSubmit || props.name]) {
2900
+ field === null || field === void 0 ? void 0 : field.emitValue({
2901
+ value: (_d = formInstance.initialValues) === null || _d === void 0 ? void 0 : _d[props.nameToSubmit || props.name],
2902
+ event: 'ON_FIELD_MOUNT'
2903
+ });
2904
+ }
2897
2905
  if (typeof (props === null || props === void 0 ? void 0 : props.visibility) !== 'undefined' && field) {
2898
2906
  field.visibility = props.visibility;
2899
2907
  }
@@ -2956,12 +2964,12 @@ const AsFormFieldBuilder = props => {
2956
2964
  * allows to control field value as a controlled component
2957
2965
  */
2958
2966
  useEffect(() => {
2959
- var _a, _b;
2967
+ var _a, _b, _c, _d;
2960
2968
  if (!mounted) return;
2961
2969
  const field = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.fields.get(props.name);
2962
- if (((_b = props.mapper.events) === null || _b === void 0 ? void 0 : _b.setValue) && props.props && field) {
2970
+ if (((_b = props.mapper.events) === null || _b === void 0 ? void 0 : _b.setValue) && ((_c = props.props) === null || _c === void 0 ? void 0 : _c[props.mapper.events.setValue]) && field) {
2963
2971
  field === null || field === void 0 ? void 0 : field.emitValue({
2964
- value: props.props[props.mapper.events.setValue],
2972
+ value: (_d = props.props) === null || _d === void 0 ? void 0 : _d[props.mapper.events.setValue],
2965
2973
  event: 'ON_FIELD_CHANGE'
2966
2974
  });
2967
2975
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine",
3
- "version": "3.0.0-beta.57",
3
+ "version": "3.0.0-beta.58",
4
4
  "description": "A react adapter for bolttech form engine",
5
5
  "module": "./index.esm.js",
6
6
  "type": "module",