@wix/form-public 0.34.0 → 0.36.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 +88 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -28
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -20483,8 +20483,6 @@ var Breakpoint = /* @__PURE__ */ (function(Breakpoint2) {
|
|
|
20483
20483
|
return Breakpoint2;
|
|
20484
20484
|
})({});
|
|
20485
20485
|
var DEFAULT_BREAKPOINT = Breakpoint.LARGE;
|
|
20486
|
-
var FieldValidationContext = /* @__PURE__ */ createContext(null);
|
|
20487
|
-
var useFieldValidation = () => useContext(FieldValidationContext) || {};
|
|
20488
20486
|
var FORM_STATUS = {
|
|
20489
20487
|
BUSY: "BUSY",
|
|
20490
20488
|
READY: "READY"
|
|
@@ -24427,6 +24425,10 @@ function formFieldFocus(params) {
|
|
|
24427
24425
|
function formErrorAppearedDissapeared(params) {
|
|
24428
24426
|
return { evid: 1006, src: 156, endpoint: "forms-platform-uou", params };
|
|
24429
24427
|
}
|
|
24428
|
+
var FieldValidationContext = /* @__PURE__ */ createContext(null);
|
|
24429
|
+
var useFieldValidation = () => useContext(FieldValidationContext) || {};
|
|
24430
|
+
|
|
24431
|
+
// ../form-fields/dist/esm/ui/form/components/form/input-field.js
|
|
24430
24432
|
var InputField = (_ref) => {
|
|
24431
24433
|
let {
|
|
24432
24434
|
field,
|
|
@@ -24748,17 +24750,25 @@ var createFormFields = (_ref) => {
|
|
|
24748
24750
|
errors,
|
|
24749
24751
|
values,
|
|
24750
24752
|
onFieldChange,
|
|
24751
|
-
FieldLayout
|
|
24753
|
+
FieldLayout,
|
|
24754
|
+
formSchema,
|
|
24755
|
+
validateFields: validateFields2
|
|
24752
24756
|
} = _ref;
|
|
24753
24757
|
return form.fields.map((formField) => {
|
|
24754
|
-
const component = /* @__PURE__ */ React32__default.createElement(
|
|
24758
|
+
const component = /* @__PURE__ */ React32__default.createElement(FormContext.Provider, {
|
|
24759
|
+
value: formSchema
|
|
24760
|
+
}, /* @__PURE__ */ React32__default.createElement(FieldValidationContext.Provider, {
|
|
24761
|
+
value: {
|
|
24762
|
+
validateFields: validateFields2
|
|
24763
|
+
}
|
|
24764
|
+
}, /* @__PURE__ */ React32__default.createElement(FormField, {
|
|
24755
24765
|
key: formField.id,
|
|
24756
24766
|
field: formField,
|
|
24757
24767
|
values,
|
|
24758
24768
|
errors,
|
|
24759
24769
|
onFieldChange,
|
|
24760
24770
|
FieldLayout
|
|
24761
|
-
});
|
|
24771
|
+
})));
|
|
24762
24772
|
return {
|
|
24763
24773
|
id: formField.id,
|
|
24764
24774
|
fieldType: formField.fieldType,
|
|
@@ -24826,9 +24836,8 @@ var Grid = (_ref) => {
|
|
|
24826
24836
|
return /* @__PURE__ */ React32__default.createElement("div", {
|
|
24827
24837
|
className: grid_module_default.container,
|
|
24828
24838
|
dir: isRTL ? "rtl" : ""
|
|
24829
|
-
}, reactElementsByRow.map((
|
|
24830
|
-
|
|
24831
|
-
const fieldId = (_elements$ = elements[0]) == null || (_elements$ = _elements$.props) == null || (_elements$ = _elements$.field) == null ? void 0 : _elements$.id;
|
|
24839
|
+
}, reactElementsByRow.map((rowData, index) => {
|
|
24840
|
+
const fieldId = rowData.firstFieldId;
|
|
24832
24841
|
const key = isMobile && fieldId || index;
|
|
24833
24842
|
return /* @__PURE__ */ React32__default.createElement(Focusable, {
|
|
24834
24843
|
key: fieldId,
|
|
@@ -24841,7 +24850,7 @@ var Grid = (_ref) => {
|
|
|
24841
24850
|
className: (0, import_classnames4.default)(grid_module_default.grid, grid_module_default.column, {
|
|
24842
24851
|
[grid_animations_module_default.animations]: enableAnimations
|
|
24843
24852
|
})
|
|
24844
|
-
}, elements));
|
|
24853
|
+
}, rowData.elements));
|
|
24845
24854
|
}));
|
|
24846
24855
|
};
|
|
24847
24856
|
function getReactElementsByRow(items) {
|
|
@@ -24851,9 +24860,12 @@ function getReactElementsByRow(items) {
|
|
|
24851
24860
|
key: item.id
|
|
24852
24861
|
});
|
|
24853
24862
|
if (result2[row]) {
|
|
24854
|
-
result2[row].push(element);
|
|
24863
|
+
result2[row].elements.push(element);
|
|
24855
24864
|
} else {
|
|
24856
|
-
result2[row] =
|
|
24865
|
+
result2[row] = {
|
|
24866
|
+
elements: [element],
|
|
24867
|
+
firstFieldId: item.id
|
|
24868
|
+
};
|
|
24857
24869
|
}
|
|
24858
24870
|
return result2;
|
|
24859
24871
|
}, []);
|
|
@@ -24935,7 +24947,9 @@ var FormRoot = (_ref) => {
|
|
|
24935
24947
|
form,
|
|
24936
24948
|
values,
|
|
24937
24949
|
onFieldChange,
|
|
24938
|
-
errors
|
|
24950
|
+
errors,
|
|
24951
|
+
formSchema,
|
|
24952
|
+
validateFields: validateFields2
|
|
24939
24953
|
} = _ref;
|
|
24940
24954
|
const {
|
|
24941
24955
|
isRTL
|
|
@@ -24945,7 +24959,9 @@ var FormRoot = (_ref) => {
|
|
|
24945
24959
|
values,
|
|
24946
24960
|
onFieldChange,
|
|
24947
24961
|
errors,
|
|
24948
|
-
FieldLayout: DefaultFieldLayout
|
|
24962
|
+
FieldLayout: DefaultFieldLayout,
|
|
24963
|
+
formSchema,
|
|
24964
|
+
validateFields: validateFields2
|
|
24949
24965
|
});
|
|
24950
24966
|
return /* @__PURE__ */ React32__default.createElement(Grid, {
|
|
24951
24967
|
isRTL,
|
|
@@ -26113,6 +26129,8 @@ function resolveArrayComponent(arrayComponent) {
|
|
|
26113
26129
|
switch (arrayComponent.componentType) {
|
|
26114
26130
|
case ComponentType3.CHECKBOX_GROUP:
|
|
26115
26131
|
return takeCheckboxGroupViewProperties(arrayComponent.checkboxGroupOptions);
|
|
26132
|
+
case ComponentType3.TAGS:
|
|
26133
|
+
return takeTagsViewProperties(arrayComponent.tagsOptions);
|
|
26116
26134
|
default:
|
|
26117
26135
|
throw new Error(`Unknown array component type: ${arrayComponent.componentType}`);
|
|
26118
26136
|
}
|
|
@@ -26136,6 +26154,25 @@ function takeCheckboxGroupViewProperties(checkboxGroup) {
|
|
|
26136
26154
|
}
|
|
26137
26155
|
};
|
|
26138
26156
|
}
|
|
26157
|
+
function takeTagsViewProperties(tags) {
|
|
26158
|
+
return {
|
|
26159
|
+
[HideLabelKey]: !tags.showLabel,
|
|
26160
|
+
[AddOtherKey]: tags.customOption != null,
|
|
26161
|
+
[OptionsKey]: tags.options.map((option) => makeOptionView(option)),
|
|
26162
|
+
[NumberOfColumnsKey]: numericNumberOfColumns(tags.numberOfColumns ?? NumberOfColumns3.ONE),
|
|
26163
|
+
[DefaultValueKey]: tags.options.filter((option) => option.default).map((option) => option.value),
|
|
26164
|
+
...tags.description && {
|
|
26165
|
+
[DescriptionKey]: tags.description
|
|
26166
|
+
},
|
|
26167
|
+
...tags.label && {
|
|
26168
|
+
[LabelKey]: tags.label
|
|
26169
|
+
},
|
|
26170
|
+
...tags.customOption && {
|
|
26171
|
+
[AddOtherLabelKey]: tags.customOption.label,
|
|
26172
|
+
[AddOtherPlaceholderKey]: tags.customOption.placeholder
|
|
26173
|
+
}
|
|
26174
|
+
};
|
|
26175
|
+
}
|
|
26139
26176
|
function takeProductCheckboxGroupViewProperties(checkboxGroup) {
|
|
26140
26177
|
return {
|
|
26141
26178
|
[HideLabelKey]: !checkboxGroup.showLabel,
|
|
@@ -26386,6 +26423,10 @@ function resolvePaymentComponent(paymentComponent) {
|
|
|
26386
26423
|
return takeProductCheckboxGroupViewProperties(paymentComponent.checkboxGroupOptions);
|
|
26387
26424
|
case PaymentComponentType3.DONATION_INPUT:
|
|
26388
26425
|
return takeDonationsInputViewProperties(paymentComponent.donationInputOptions);
|
|
26426
|
+
case PaymentComponentType3.FIXED_PAYMENT:
|
|
26427
|
+
return takeFixedPaymentViewProperties(paymentComponent.fixedPaymentOptions);
|
|
26428
|
+
case PaymentComponentType3.PAYMENT_INPUT:
|
|
26429
|
+
return takePaymentInputViewProperties(paymentComponent.paymentInputOptions);
|
|
26389
26430
|
default:
|
|
26390
26431
|
throw new Error(`Unknown payment component type: ${paymentComponent.componentType}`);
|
|
26391
26432
|
}
|
|
@@ -26510,6 +26551,31 @@ function takeDonationsInputViewProperties(donationInput) {
|
|
|
26510
26551
|
}
|
|
26511
26552
|
};
|
|
26512
26553
|
}
|
|
26554
|
+
function takeFixedPaymentViewProperties(fixedPayment) {
|
|
26555
|
+
return {
|
|
26556
|
+
[HideLabelKey]: !fixedPayment.showLabel,
|
|
26557
|
+
...fixedPayment.label && {
|
|
26558
|
+
[LabelKey]: fixedPayment.label
|
|
26559
|
+
},
|
|
26560
|
+
...fixedPayment.description && {
|
|
26561
|
+
[DescriptionKey]: fixedPayment.description
|
|
26562
|
+
}
|
|
26563
|
+
};
|
|
26564
|
+
}
|
|
26565
|
+
function takePaymentInputViewProperties(paymentInput) {
|
|
26566
|
+
return {
|
|
26567
|
+
[HideLabelKey]: !paymentInput.showLabel,
|
|
26568
|
+
...paymentInput.label && {
|
|
26569
|
+
[LabelKey]: paymentInput.label
|
|
26570
|
+
},
|
|
26571
|
+
...paymentInput.description && {
|
|
26572
|
+
[DescriptionKey]: paymentInput.description
|
|
26573
|
+
},
|
|
26574
|
+
...paymentInput.placeholder && {
|
|
26575
|
+
[PlaceholderKey]: paymentInput.placeholder
|
|
26576
|
+
}
|
|
26577
|
+
};
|
|
26578
|
+
}
|
|
26513
26579
|
function makeOptionView(option) {
|
|
26514
26580
|
return {
|
|
26515
26581
|
[LabelKey]: option.label,
|
|
@@ -29522,23 +29588,17 @@ var FormRoot2 = ({
|
|
|
29522
29588
|
return null;
|
|
29523
29589
|
}
|
|
29524
29590
|
return React32__default.createElement(
|
|
29525
|
-
|
|
29526
|
-
{ value:
|
|
29527
|
-
validateFields: handleFieldValidation
|
|
29528
|
-
} },
|
|
29591
|
+
FieldActionsContext.Provider,
|
|
29592
|
+
{ value: fieldActions },
|
|
29529
29593
|
React32__default.createElement(
|
|
29530
|
-
|
|
29531
|
-
{
|
|
29594
|
+
FormStatusProvider,
|
|
29595
|
+
{ onStatusChange },
|
|
29532
29596
|
React32__default.createElement(
|
|
29533
|
-
|
|
29534
|
-
{
|
|
29535
|
-
React32__default.createElement(
|
|
29536
|
-
|
|
29537
|
-
|
|
29538
|
-
React32__default.createElement(Form, { form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT }),
|
|
29539
|
-
React32__default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29540
|
-
React32__default.createElement(SubmitStatusMessage, null)
|
|
29541
|
-
)
|
|
29597
|
+
"div",
|
|
29598
|
+
{ "data-hook": DATA_HOOKS.FORM_ROOT },
|
|
29599
|
+
React32__default.createElement(Form, { formSchema: formWithOverrides, form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT, validateFields: handleFieldValidation }),
|
|
29600
|
+
React32__default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29601
|
+
React32__default.createElement(SubmitStatusMessage, null)
|
|
29542
29602
|
)
|
|
29543
29603
|
)
|
|
29544
29604
|
);
|