@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.cjs
CHANGED
|
@@ -20509,8 +20509,6 @@ var Breakpoint = /* @__PURE__ */ (function(Breakpoint2) {
|
|
|
20509
20509
|
return Breakpoint2;
|
|
20510
20510
|
})({});
|
|
20511
20511
|
var DEFAULT_BREAKPOINT = Breakpoint.LARGE;
|
|
20512
|
-
var FieldValidationContext = /* @__PURE__ */ React32.createContext(null);
|
|
20513
|
-
var useFieldValidation = () => React32.useContext(FieldValidationContext) || {};
|
|
20514
20512
|
var FORM_STATUS = {
|
|
20515
20513
|
BUSY: "BUSY",
|
|
20516
20514
|
READY: "READY"
|
|
@@ -24453,6 +24451,10 @@ function formFieldFocus(params) {
|
|
|
24453
24451
|
function formErrorAppearedDissapeared(params) {
|
|
24454
24452
|
return { evid: 1006, src: 156, endpoint: "forms-platform-uou", params };
|
|
24455
24453
|
}
|
|
24454
|
+
var FieldValidationContext = /* @__PURE__ */ React32.createContext(null);
|
|
24455
|
+
var useFieldValidation = () => React32.useContext(FieldValidationContext) || {};
|
|
24456
|
+
|
|
24457
|
+
// ../form-fields/dist/esm/ui/form/components/form/input-field.js
|
|
24456
24458
|
var InputField = (_ref) => {
|
|
24457
24459
|
let {
|
|
24458
24460
|
field,
|
|
@@ -24774,17 +24776,25 @@ var createFormFields = (_ref) => {
|
|
|
24774
24776
|
errors,
|
|
24775
24777
|
values,
|
|
24776
24778
|
onFieldChange,
|
|
24777
|
-
FieldLayout
|
|
24779
|
+
FieldLayout,
|
|
24780
|
+
formSchema,
|
|
24781
|
+
validateFields: validateFields2
|
|
24778
24782
|
} = _ref;
|
|
24779
24783
|
return form.fields.map((formField) => {
|
|
24780
|
-
const component = /* @__PURE__ */ React32__namespace.default.createElement(
|
|
24784
|
+
const component = /* @__PURE__ */ React32__namespace.default.createElement(FormContext.Provider, {
|
|
24785
|
+
value: formSchema
|
|
24786
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(FieldValidationContext.Provider, {
|
|
24787
|
+
value: {
|
|
24788
|
+
validateFields: validateFields2
|
|
24789
|
+
}
|
|
24790
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(FormField, {
|
|
24781
24791
|
key: formField.id,
|
|
24782
24792
|
field: formField,
|
|
24783
24793
|
values,
|
|
24784
24794
|
errors,
|
|
24785
24795
|
onFieldChange,
|
|
24786
24796
|
FieldLayout
|
|
24787
|
-
});
|
|
24797
|
+
})));
|
|
24788
24798
|
return {
|
|
24789
24799
|
id: formField.id,
|
|
24790
24800
|
fieldType: formField.fieldType,
|
|
@@ -24852,9 +24862,8 @@ var Grid = (_ref) => {
|
|
|
24852
24862
|
return /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24853
24863
|
className: grid_module_default.container,
|
|
24854
24864
|
dir: isRTL ? "rtl" : ""
|
|
24855
|
-
}, reactElementsByRow.map((
|
|
24856
|
-
|
|
24857
|
-
const fieldId = (_elements$ = elements[0]) == null || (_elements$ = _elements$.props) == null || (_elements$ = _elements$.field) == null ? void 0 : _elements$.id;
|
|
24865
|
+
}, reactElementsByRow.map((rowData, index) => {
|
|
24866
|
+
const fieldId = rowData.firstFieldId;
|
|
24858
24867
|
const key = isMobile && fieldId || index;
|
|
24859
24868
|
return /* @__PURE__ */ React32__namespace.default.createElement(Focusable, {
|
|
24860
24869
|
key: fieldId,
|
|
@@ -24867,7 +24876,7 @@ var Grid = (_ref) => {
|
|
|
24867
24876
|
className: (0, import_classnames4.default)(grid_module_default.grid, grid_module_default.column, {
|
|
24868
24877
|
[grid_animations_module_default.animations]: enableAnimations
|
|
24869
24878
|
})
|
|
24870
|
-
}, elements));
|
|
24879
|
+
}, rowData.elements));
|
|
24871
24880
|
}));
|
|
24872
24881
|
};
|
|
24873
24882
|
function getReactElementsByRow(items) {
|
|
@@ -24877,9 +24886,12 @@ function getReactElementsByRow(items) {
|
|
|
24877
24886
|
key: item.id
|
|
24878
24887
|
});
|
|
24879
24888
|
if (result2[row]) {
|
|
24880
|
-
result2[row].push(element);
|
|
24889
|
+
result2[row].elements.push(element);
|
|
24881
24890
|
} else {
|
|
24882
|
-
result2[row] =
|
|
24891
|
+
result2[row] = {
|
|
24892
|
+
elements: [element],
|
|
24893
|
+
firstFieldId: item.id
|
|
24894
|
+
};
|
|
24883
24895
|
}
|
|
24884
24896
|
return result2;
|
|
24885
24897
|
}, []);
|
|
@@ -24961,7 +24973,9 @@ var FormRoot = (_ref) => {
|
|
|
24961
24973
|
form,
|
|
24962
24974
|
values,
|
|
24963
24975
|
onFieldChange,
|
|
24964
|
-
errors
|
|
24976
|
+
errors,
|
|
24977
|
+
formSchema,
|
|
24978
|
+
validateFields: validateFields2
|
|
24965
24979
|
} = _ref;
|
|
24966
24980
|
const {
|
|
24967
24981
|
isRTL
|
|
@@ -24971,7 +24985,9 @@ var FormRoot = (_ref) => {
|
|
|
24971
24985
|
values,
|
|
24972
24986
|
onFieldChange,
|
|
24973
24987
|
errors,
|
|
24974
|
-
FieldLayout: DefaultFieldLayout
|
|
24988
|
+
FieldLayout: DefaultFieldLayout,
|
|
24989
|
+
formSchema,
|
|
24990
|
+
validateFields: validateFields2
|
|
24975
24991
|
});
|
|
24976
24992
|
return /* @__PURE__ */ React32__namespace.default.createElement(Grid, {
|
|
24977
24993
|
isRTL,
|
|
@@ -26139,6 +26155,8 @@ function resolveArrayComponent(arrayComponent) {
|
|
|
26139
26155
|
switch (arrayComponent.componentType) {
|
|
26140
26156
|
case ComponentType3.CHECKBOX_GROUP:
|
|
26141
26157
|
return takeCheckboxGroupViewProperties(arrayComponent.checkboxGroupOptions);
|
|
26158
|
+
case ComponentType3.TAGS:
|
|
26159
|
+
return takeTagsViewProperties(arrayComponent.tagsOptions);
|
|
26142
26160
|
default:
|
|
26143
26161
|
throw new Error(`Unknown array component type: ${arrayComponent.componentType}`);
|
|
26144
26162
|
}
|
|
@@ -26162,6 +26180,25 @@ function takeCheckboxGroupViewProperties(checkboxGroup) {
|
|
|
26162
26180
|
}
|
|
26163
26181
|
};
|
|
26164
26182
|
}
|
|
26183
|
+
function takeTagsViewProperties(tags) {
|
|
26184
|
+
return {
|
|
26185
|
+
[HideLabelKey]: !tags.showLabel,
|
|
26186
|
+
[AddOtherKey]: tags.customOption != null,
|
|
26187
|
+
[OptionsKey]: tags.options.map((option) => makeOptionView(option)),
|
|
26188
|
+
[NumberOfColumnsKey]: numericNumberOfColumns(tags.numberOfColumns ?? NumberOfColumns3.ONE),
|
|
26189
|
+
[DefaultValueKey]: tags.options.filter((option) => option.default).map((option) => option.value),
|
|
26190
|
+
...tags.description && {
|
|
26191
|
+
[DescriptionKey]: tags.description
|
|
26192
|
+
},
|
|
26193
|
+
...tags.label && {
|
|
26194
|
+
[LabelKey]: tags.label
|
|
26195
|
+
},
|
|
26196
|
+
...tags.customOption && {
|
|
26197
|
+
[AddOtherLabelKey]: tags.customOption.label,
|
|
26198
|
+
[AddOtherPlaceholderKey]: tags.customOption.placeholder
|
|
26199
|
+
}
|
|
26200
|
+
};
|
|
26201
|
+
}
|
|
26165
26202
|
function takeProductCheckboxGroupViewProperties(checkboxGroup) {
|
|
26166
26203
|
return {
|
|
26167
26204
|
[HideLabelKey]: !checkboxGroup.showLabel,
|
|
@@ -26412,6 +26449,10 @@ function resolvePaymentComponent(paymentComponent) {
|
|
|
26412
26449
|
return takeProductCheckboxGroupViewProperties(paymentComponent.checkboxGroupOptions);
|
|
26413
26450
|
case PaymentComponentType3.DONATION_INPUT:
|
|
26414
26451
|
return takeDonationsInputViewProperties(paymentComponent.donationInputOptions);
|
|
26452
|
+
case PaymentComponentType3.FIXED_PAYMENT:
|
|
26453
|
+
return takeFixedPaymentViewProperties(paymentComponent.fixedPaymentOptions);
|
|
26454
|
+
case PaymentComponentType3.PAYMENT_INPUT:
|
|
26455
|
+
return takePaymentInputViewProperties(paymentComponent.paymentInputOptions);
|
|
26415
26456
|
default:
|
|
26416
26457
|
throw new Error(`Unknown payment component type: ${paymentComponent.componentType}`);
|
|
26417
26458
|
}
|
|
@@ -26536,6 +26577,31 @@ function takeDonationsInputViewProperties(donationInput) {
|
|
|
26536
26577
|
}
|
|
26537
26578
|
};
|
|
26538
26579
|
}
|
|
26580
|
+
function takeFixedPaymentViewProperties(fixedPayment) {
|
|
26581
|
+
return {
|
|
26582
|
+
[HideLabelKey]: !fixedPayment.showLabel,
|
|
26583
|
+
...fixedPayment.label && {
|
|
26584
|
+
[LabelKey]: fixedPayment.label
|
|
26585
|
+
},
|
|
26586
|
+
...fixedPayment.description && {
|
|
26587
|
+
[DescriptionKey]: fixedPayment.description
|
|
26588
|
+
}
|
|
26589
|
+
};
|
|
26590
|
+
}
|
|
26591
|
+
function takePaymentInputViewProperties(paymentInput) {
|
|
26592
|
+
return {
|
|
26593
|
+
[HideLabelKey]: !paymentInput.showLabel,
|
|
26594
|
+
...paymentInput.label && {
|
|
26595
|
+
[LabelKey]: paymentInput.label
|
|
26596
|
+
},
|
|
26597
|
+
...paymentInput.description && {
|
|
26598
|
+
[DescriptionKey]: paymentInput.description
|
|
26599
|
+
},
|
|
26600
|
+
...paymentInput.placeholder && {
|
|
26601
|
+
[PlaceholderKey]: paymentInput.placeholder
|
|
26602
|
+
}
|
|
26603
|
+
};
|
|
26604
|
+
}
|
|
26539
26605
|
function makeOptionView(option) {
|
|
26540
26606
|
return {
|
|
26541
26607
|
[LabelKey]: option.label,
|
|
@@ -29548,23 +29614,17 @@ var FormRoot2 = ({
|
|
|
29548
29614
|
return null;
|
|
29549
29615
|
}
|
|
29550
29616
|
return React32__namespace.default.createElement(
|
|
29551
|
-
|
|
29552
|
-
{ value:
|
|
29553
|
-
validateFields: handleFieldValidation
|
|
29554
|
-
} },
|
|
29617
|
+
FieldActionsContext.Provider,
|
|
29618
|
+
{ value: fieldActions },
|
|
29555
29619
|
React32__namespace.default.createElement(
|
|
29556
|
-
|
|
29557
|
-
{
|
|
29620
|
+
FormStatusProvider,
|
|
29621
|
+
{ onStatusChange },
|
|
29558
29622
|
React32__namespace.default.createElement(
|
|
29559
|
-
|
|
29560
|
-
{
|
|
29561
|
-
React32__namespace.default.createElement(
|
|
29562
|
-
|
|
29563
|
-
|
|
29564
|
-
React32__namespace.default.createElement(Form, { form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT }),
|
|
29565
|
-
React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29566
|
-
React32__namespace.default.createElement(SubmitStatusMessage, null)
|
|
29567
|
-
)
|
|
29623
|
+
"div",
|
|
29624
|
+
{ "data-hook": DATA_HOOKS.FORM_ROOT },
|
|
29625
|
+
React32__namespace.default.createElement(Form, { formSchema: formWithOverrides, form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT, validateFields: handleFieldValidation }),
|
|
29626
|
+
React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29627
|
+
React32__namespace.default.createElement(SubmitStatusMessage, null)
|
|
29568
29628
|
)
|
|
29569
29629
|
)
|
|
29570
29630
|
);
|