@bolttech/form-engine 3.0.0-beta.56 → 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 +14 -7
  2. package/package.json +2 -2
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
  }
@@ -2929,15 +2937,14 @@ const AsFormFieldBuilder = props => {
2929
2937
  * allows to control field selected value on each event
2930
2938
  */
2931
2939
  useEffect(() => {
2932
- var _a, _b;
2940
+ var _a;
2933
2941
  if (!props.onSelected) return;
2934
- (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.fields.get(props.name);
2935
2942
  const callback = payload => {
2936
2943
  if (props.onSelected) {
2937
2944
  props.onSelected(payload);
2938
2945
  }
2939
2946
  };
2940
- const sub = (_b = context.formGroupInstance.forms.get(props.formIndex)) === null || _b === void 0 ? void 0 : _b.subscribeFieldEvent({
2947
+ const sub = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.subscribeFieldEvent({
2941
2948
  callback
2942
2949
  });
2943
2950
  return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
@@ -2957,12 +2964,12 @@ const AsFormFieldBuilder = props => {
2957
2964
  * allows to control field value as a controlled component
2958
2965
  */
2959
2966
  useEffect(() => {
2960
- var _a, _b;
2967
+ var _a, _b, _c, _d;
2961
2968
  if (!mounted) return;
2962
2969
  const field = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.fields.get(props.name);
2963
- 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) {
2964
2971
  field === null || field === void 0 ? void 0 : field.emitValue({
2965
- value: props.props[props.mapper.events.setValue],
2972
+ value: (_d = props.props) === null || _d === void 0 ? void 0 : _d[props.mapper.events.setValue],
2966
2973
  event: 'ON_FIELD_CHANGE'
2967
2974
  });
2968
2975
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine",
3
- "version": "3.0.0-beta.56",
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",
7
7
  "main": "./index.esm.js",
8
8
  "dependencies": {
9
- "@bolttech/form-engine-core": "0.0.1-beta.41",
9
+ "@bolttech/form-engine-core": "0.0.1-beta.42",
10
10
  "react": "18.2.0",
11
11
  "rxjs": "7.8.1"
12
12
  },