@wix/form-public 0.35.0 → 0.37.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.
@@ -1293,7 +1293,7 @@ export { PhoneInputProps as PhoneInputProps_alias_1 }
1293
1293
 
1294
1294
  export declare type PossibleValues = ValueType | {
1295
1295
  [target: string]: ValueType;
1296
- };
1296
+ } | FormValues[];
1297
1297
 
1298
1298
  export declare const ProductListMapper: PropsMapper;
1299
1299
 
@@ -1293,7 +1293,7 @@ export { PhoneInputProps as PhoneInputProps_alias_1 }
1293
1293
 
1294
1294
  export declare type PossibleValues = ValueType | {
1295
1295
  [target: string]: ValueType;
1296
- };
1296
+ } | FormValues[];
1297
1297
 
1298
1298
  export declare const ProductListMapper: PropsMapper;
1299
1299
 
package/dist/index.cjs CHANGED
@@ -20463,7 +20463,8 @@ var IDENTITY_FIELD_TYPES = {
20463
20463
  IDENTITY_PASSWORD: "IDENTITY_PASSWORD"
20464
20464
  };
20465
20465
  var EVENTS_FIELD_TYPES = {
20466
- EVENTS_RSVP: "EVENTS_RSVP"
20466
+ EVENTS_RSVP: "EVENTS_RSVP",
20467
+ EVENTS_REPEATER: "EVENTS_REPEATER"
20467
20468
  };
20468
20469
  var INPUT_FIELD_TYPES = {
20469
20470
  ...CONTACTS_FIELD_TYPES,
@@ -20509,8 +20510,6 @@ var Breakpoint = /* @__PURE__ */ (function(Breakpoint2) {
20509
20510
  return Breakpoint2;
20510
20511
  })({});
20511
20512
  var DEFAULT_BREAKPOINT = Breakpoint.LARGE;
20512
- var FieldValidationContext = /* @__PURE__ */ React32.createContext(null);
20513
- var useFieldValidation = () => React32.useContext(FieldValidationContext) || {};
20514
20513
  var FORM_STATUS = {
20515
20514
  BUSY: "BUSY",
20516
20515
  READY: "READY"
@@ -24453,6 +24452,10 @@ function formFieldFocus(params) {
24453
24452
  function formErrorAppearedDissapeared(params) {
24454
24453
  return { evid: 1006, src: 156, endpoint: "forms-platform-uou", params };
24455
24454
  }
24455
+ var FieldValidationContext = /* @__PURE__ */ React32.createContext(null);
24456
+ var useFieldValidation = () => React32.useContext(FieldValidationContext) || {};
24457
+
24458
+ // ../form-fields/dist/esm/ui/form/components/form/input-field.js
24456
24459
  var InputField = (_ref) => {
24457
24460
  let {
24458
24461
  field,
@@ -24775,11 +24778,16 @@ var createFormFields = (_ref) => {
24775
24778
  values,
24776
24779
  onFieldChange,
24777
24780
  FieldLayout,
24778
- formSchema
24781
+ formSchema,
24782
+ validateFields: validateFields2
24779
24783
  } = _ref;
24780
24784
  return form.fields.map((formField) => {
24781
24785
  const component = /* @__PURE__ */ React32__namespace.default.createElement(FormContext.Provider, {
24782
24786
  value: formSchema
24787
+ }, /* @__PURE__ */ React32__namespace.default.createElement(FieldValidationContext.Provider, {
24788
+ value: {
24789
+ validateFields: validateFields2
24790
+ }
24783
24791
  }, /* @__PURE__ */ React32__namespace.default.createElement(FormField, {
24784
24792
  key: formField.id,
24785
24793
  field: formField,
@@ -24787,7 +24795,7 @@ var createFormFields = (_ref) => {
24787
24795
  errors,
24788
24796
  onFieldChange,
24789
24797
  FieldLayout
24790
- }));
24798
+ })));
24791
24799
  return {
24792
24800
  id: formField.id,
24793
24801
  fieldType: formField.fieldType,
@@ -24967,7 +24975,8 @@ var FormRoot = (_ref) => {
24967
24975
  values,
24968
24976
  onFieldChange,
24969
24977
  errors,
24970
- formSchema
24978
+ formSchema,
24979
+ validateFields: validateFields2
24971
24980
  } = _ref;
24972
24981
  const {
24973
24982
  isRTL
@@ -24978,7 +24987,8 @@ var FormRoot = (_ref) => {
24978
24987
  onFieldChange,
24979
24988
  errors,
24980
24989
  FieldLayout: DefaultFieldLayout,
24981
- formSchema
24990
+ formSchema,
24991
+ validateFields: validateFields2
24982
24992
  });
24983
24993
  return /* @__PURE__ */ React32__namespace.default.createElement(Grid, {
24984
24994
  isRTL,
@@ -28464,7 +28474,8 @@ var ADDITIONAL_FIELD_VALIDATION = {
28464
28474
  [FIELD_TYPES.IDENTITY_PASSWORD]: null,
28465
28475
  [FIELD_TYPES.SERVICES_DROPDOWN]: null,
28466
28476
  [FIELD_TYPES.SERVICES_MULTI_CHOICE]: null,
28467
- [FIELD_TYPES.EVENTS_RSVP]: null
28477
+ [FIELD_TYPES.EVENTS_RSVP]: null,
28478
+ [FIELD_TYPES.EVENTS_REPEATER]: null
28468
28479
  };
28469
28480
 
28470
28481
  // ../form-viewer/dist/esm/services/get-field-errors.js
@@ -28853,7 +28864,8 @@ var NORMALIZED_VALUE = {
28853
28864
  [FIELD_TYPES.IDENTITY_PASSWORD]: acceptStringValue,
28854
28865
  [FIELD_TYPES.SERVICES_DROPDOWN]: acceptStringValue,
28855
28866
  [FIELD_TYPES.SERVICES_MULTI_CHOICE]: removeInvalidOptions,
28856
- [FIELD_TYPES.EVENTS_RSVP]: acceptOnlyValidOptionByValue
28867
+ [FIELD_TYPES.EVENTS_RSVP]: acceptOnlyValidOptionByValue,
28868
+ [FIELD_TYPES.EVENTS_REPEATER]: normalizeRepeater
28857
28869
  };
28858
28870
  function keepValueUnchanged({ fieldValue }) {
28859
28871
  return fieldValue;
@@ -29027,6 +29039,27 @@ function acceptOnlyValidPayments({ field, fieldValue }) {
29027
29039
  }
29028
29040
  return fieldValue;
29029
29041
  }
29042
+ function normalizeRepeater({ field, fieldValue, config }) {
29043
+ const isEmptyValue = fieldValue === EMPTY_VALUE;
29044
+ const nestedFields = field.view?.fields;
29045
+ if (isEmptyValue) {
29046
+ return fieldValue;
29047
+ }
29048
+ if (!Array.isArray(fieldValue) || !nestedFields) {
29049
+ return EMPTY_VALUE;
29050
+ }
29051
+ const nestedForm = {
29052
+ fields: nestedFields
29053
+ };
29054
+ const normalizedValues = fieldValue.map((values) => {
29055
+ if (!isObject5(values)) {
29056
+ return {};
29057
+ }
29058
+ const normalized = normalizeValues(nestedForm, values, false, config);
29059
+ return Object.fromEntries(Object.entries(normalized).filter(([_23, value]) => value !== EMPTY_VALUE));
29060
+ });
29061
+ return normalizedValues;
29062
+ }
29030
29063
 
29031
29064
  // ../form-viewer/dist/esm/components/form/use-form-values.js
29032
29065
  var useFormValues = (form, values, onChange, config) => {
@@ -29605,23 +29638,17 @@ var FormRoot2 = ({
29605
29638
  return null;
29606
29639
  }
29607
29640
  return React32__namespace.default.createElement(
29608
- FieldValidationContext.Provider,
29609
- { value: {
29610
- validateFields: handleFieldValidation
29611
- } },
29641
+ FieldActionsContext.Provider,
29642
+ { value: fieldActions },
29612
29643
  React32__namespace.default.createElement(
29613
- FieldActionsContext.Provider,
29614
- { value: fieldActions },
29644
+ FormStatusProvider,
29645
+ { onStatusChange },
29615
29646
  React32__namespace.default.createElement(
29616
- FormStatusProvider,
29617
- { onStatusChange },
29618
- React32__namespace.default.createElement(
29619
- "div",
29620
- { "data-hook": DATA_HOOKS.FORM_ROOT },
29621
- React32__namespace.default.createElement(Form, { formSchema: formWithOverrides, form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT }),
29622
- React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
29623
- React32__namespace.default.createElement(SubmitStatusMessage, null)
29624
- )
29647
+ "div",
29648
+ { "data-hook": DATA_HOOKS.FORM_ROOT },
29649
+ React32__namespace.default.createElement(Form, { formSchema: formWithOverrides, form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT, validateFields: handleFieldValidation }),
29650
+ React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
29651
+ React32__namespace.default.createElement(SubmitStatusMessage, null)
29625
29652
  )
29626
29653
  )
29627
29654
  );
@@ -30116,6 +30143,7 @@ var FIELD_TYPE_MAP = {
30116
30143
  // EVENTS_FIELD_TYPES
30117
30144
  EVENTS_RSVP: "RADIO_GROUP",
30118
30145
  EVENTS_HEADER: "TEXT",
30146
+ EVENTS_REPEATER: "TEXT",
30119
30147
  // COMMON_FIELD_TYPES + READONLY
30120
30148
  TEXT_INPUT: "TEXT_INPUT",
30121
30149
  NUMBER_INPUT: "NUMBER_INPUT",