@wix/form-public 0.34.0 → 0.35.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.cjs CHANGED
@@ -24774,17 +24774,20 @@ var createFormFields = (_ref) => {
24774
24774
  errors,
24775
24775
  values,
24776
24776
  onFieldChange,
24777
- FieldLayout
24777
+ FieldLayout,
24778
+ formSchema
24778
24779
  } = _ref;
24779
24780
  return form.fields.map((formField) => {
24780
- const component = /* @__PURE__ */ React32__namespace.default.createElement(FormField, {
24781
+ const component = /* @__PURE__ */ React32__namespace.default.createElement(FormContext.Provider, {
24782
+ value: formSchema
24783
+ }, /* @__PURE__ */ React32__namespace.default.createElement(FormField, {
24781
24784
  key: formField.id,
24782
24785
  field: formField,
24783
24786
  values,
24784
24787
  errors,
24785
24788
  onFieldChange,
24786
24789
  FieldLayout
24787
- });
24790
+ }));
24788
24791
  return {
24789
24792
  id: formField.id,
24790
24793
  fieldType: formField.fieldType,
@@ -24852,9 +24855,8 @@ var Grid = (_ref) => {
24852
24855
  return /* @__PURE__ */ React32__namespace.default.createElement("div", {
24853
24856
  className: grid_module_default.container,
24854
24857
  dir: isRTL ? "rtl" : ""
24855
- }, reactElementsByRow.map((elements, index) => {
24856
- var _elements$;
24857
- const fieldId = (_elements$ = elements[0]) == null || (_elements$ = _elements$.props) == null || (_elements$ = _elements$.field) == null ? void 0 : _elements$.id;
24858
+ }, reactElementsByRow.map((rowData, index) => {
24859
+ const fieldId = rowData.firstFieldId;
24858
24860
  const key = isMobile && fieldId || index;
24859
24861
  return /* @__PURE__ */ React32__namespace.default.createElement(Focusable, {
24860
24862
  key: fieldId,
@@ -24867,7 +24869,7 @@ var Grid = (_ref) => {
24867
24869
  className: (0, import_classnames4.default)(grid_module_default.grid, grid_module_default.column, {
24868
24870
  [grid_animations_module_default.animations]: enableAnimations
24869
24871
  })
24870
- }, elements));
24872
+ }, rowData.elements));
24871
24873
  }));
24872
24874
  };
24873
24875
  function getReactElementsByRow(items) {
@@ -24877,9 +24879,12 @@ function getReactElementsByRow(items) {
24877
24879
  key: item.id
24878
24880
  });
24879
24881
  if (result2[row]) {
24880
- result2[row].push(element);
24882
+ result2[row].elements.push(element);
24881
24883
  } else {
24882
- result2[row] = [element];
24884
+ result2[row] = {
24885
+ elements: [element],
24886
+ firstFieldId: item.id
24887
+ };
24883
24888
  }
24884
24889
  return result2;
24885
24890
  }, []);
@@ -24961,7 +24966,8 @@ var FormRoot = (_ref) => {
24961
24966
  form,
24962
24967
  values,
24963
24968
  onFieldChange,
24964
- errors
24969
+ errors,
24970
+ formSchema
24965
24971
  } = _ref;
24966
24972
  const {
24967
24973
  isRTL
@@ -24971,7 +24977,8 @@ var FormRoot = (_ref) => {
24971
24977
  values,
24972
24978
  onFieldChange,
24973
24979
  errors,
24974
- FieldLayout: DefaultFieldLayout
24980
+ FieldLayout: DefaultFieldLayout,
24981
+ formSchema
24975
24982
  });
24976
24983
  return /* @__PURE__ */ React32__namespace.default.createElement(Grid, {
24977
24984
  isRTL,
@@ -26139,6 +26146,8 @@ function resolveArrayComponent(arrayComponent) {
26139
26146
  switch (arrayComponent.componentType) {
26140
26147
  case ComponentType3.CHECKBOX_GROUP:
26141
26148
  return takeCheckboxGroupViewProperties(arrayComponent.checkboxGroupOptions);
26149
+ case ComponentType3.TAGS:
26150
+ return takeTagsViewProperties(arrayComponent.tagsOptions);
26142
26151
  default:
26143
26152
  throw new Error(`Unknown array component type: ${arrayComponent.componentType}`);
26144
26153
  }
@@ -26162,6 +26171,25 @@ function takeCheckboxGroupViewProperties(checkboxGroup) {
26162
26171
  }
26163
26172
  };
26164
26173
  }
26174
+ function takeTagsViewProperties(tags) {
26175
+ return {
26176
+ [HideLabelKey]: !tags.showLabel,
26177
+ [AddOtherKey]: tags.customOption != null,
26178
+ [OptionsKey]: tags.options.map((option) => makeOptionView(option)),
26179
+ [NumberOfColumnsKey]: numericNumberOfColumns(tags.numberOfColumns ?? NumberOfColumns3.ONE),
26180
+ [DefaultValueKey]: tags.options.filter((option) => option.default).map((option) => option.value),
26181
+ ...tags.description && {
26182
+ [DescriptionKey]: tags.description
26183
+ },
26184
+ ...tags.label && {
26185
+ [LabelKey]: tags.label
26186
+ },
26187
+ ...tags.customOption && {
26188
+ [AddOtherLabelKey]: tags.customOption.label,
26189
+ [AddOtherPlaceholderKey]: tags.customOption.placeholder
26190
+ }
26191
+ };
26192
+ }
26165
26193
  function takeProductCheckboxGroupViewProperties(checkboxGroup) {
26166
26194
  return {
26167
26195
  [HideLabelKey]: !checkboxGroup.showLabel,
@@ -26412,6 +26440,10 @@ function resolvePaymentComponent(paymentComponent) {
26412
26440
  return takeProductCheckboxGroupViewProperties(paymentComponent.checkboxGroupOptions);
26413
26441
  case PaymentComponentType3.DONATION_INPUT:
26414
26442
  return takeDonationsInputViewProperties(paymentComponent.donationInputOptions);
26443
+ case PaymentComponentType3.FIXED_PAYMENT:
26444
+ return takeFixedPaymentViewProperties(paymentComponent.fixedPaymentOptions);
26445
+ case PaymentComponentType3.PAYMENT_INPUT:
26446
+ return takePaymentInputViewProperties(paymentComponent.paymentInputOptions);
26415
26447
  default:
26416
26448
  throw new Error(`Unknown payment component type: ${paymentComponent.componentType}`);
26417
26449
  }
@@ -26536,6 +26568,31 @@ function takeDonationsInputViewProperties(donationInput) {
26536
26568
  }
26537
26569
  };
26538
26570
  }
26571
+ function takeFixedPaymentViewProperties(fixedPayment) {
26572
+ return {
26573
+ [HideLabelKey]: !fixedPayment.showLabel,
26574
+ ...fixedPayment.label && {
26575
+ [LabelKey]: fixedPayment.label
26576
+ },
26577
+ ...fixedPayment.description && {
26578
+ [DescriptionKey]: fixedPayment.description
26579
+ }
26580
+ };
26581
+ }
26582
+ function takePaymentInputViewProperties(paymentInput) {
26583
+ return {
26584
+ [HideLabelKey]: !paymentInput.showLabel,
26585
+ ...paymentInput.label && {
26586
+ [LabelKey]: paymentInput.label
26587
+ },
26588
+ ...paymentInput.description && {
26589
+ [DescriptionKey]: paymentInput.description
26590
+ },
26591
+ ...paymentInput.placeholder && {
26592
+ [PlaceholderKey]: paymentInput.placeholder
26593
+ }
26594
+ };
26595
+ }
26539
26596
  function makeOptionView(option) {
26540
26597
  return {
26541
26598
  [LabelKey]: option.label,
@@ -29561,7 +29618,7 @@ var FormRoot2 = ({
29561
29618
  React32__namespace.default.createElement(
29562
29619
  "div",
29563
29620
  { "data-hook": DATA_HOOKS.FORM_ROOT },
29564
- React32__namespace.default.createElement(Form, { form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT }),
29621
+ React32__namespace.default.createElement(Form, { formSchema: formWithOverrides, form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT }),
29565
29622
  React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
29566
29623
  React32__namespace.default.createElement(SubmitStatusMessage, null)
29567
29624
  )