@wix/form-public 0.553.0 → 0.555.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 +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -49086,20 +49086,19 @@ var forgetPrehydrationValues = (pending, previousValues, nextValues) => {
|
|
|
49086
49086
|
// ../form-fields/dist/esm/contexts/prehydration-values-context.js
|
|
49087
49087
|
var PrehydrationValuesContext = /* @__PURE__ */ React172.createContext(void 0);
|
|
49088
49088
|
var readText = (element) => element.value;
|
|
49089
|
-
var useKeepPrehydrationValue = (ref) => {
|
|
49089
|
+
var useKeepPrehydrationValue = (ref, read2) => {
|
|
49090
49090
|
const registry = React172.useContext(PrehydrationValuesContext);
|
|
49091
|
-
const
|
|
49091
|
+
const props2 = useFieldPropsV2();
|
|
49092
49092
|
const mountedFieldRef = React172.useRef({
|
|
49093
|
-
|
|
49094
|
-
value,
|
|
49093
|
+
props: props2,
|
|
49095
49094
|
registry,
|
|
49096
|
-
read: readPrehydrationValue
|
|
49095
|
+
read: read2 ?? props2.readPrehydrationValue ?? readText
|
|
49097
49096
|
});
|
|
49098
49097
|
React172.useEffect(() => {
|
|
49099
49098
|
const field = mountedFieldRef.current;
|
|
49100
|
-
const domValue = ref.current ? field.read(ref.current) : void 0;
|
|
49101
|
-
if (field.registry && !isEmptyInputValue(domValue) && isEmptyInputValue(field.value)) {
|
|
49102
|
-
field.registry.current.set(field.path, domValue);
|
|
49099
|
+
const domValue = ref.current ? field.read(ref.current, field.props) : void 0;
|
|
49100
|
+
if (field.registry && !isEmptyInputValue(domValue) && isEmptyInputValue(field.props.value)) {
|
|
49101
|
+
field.registry.current.set(field.props.path, domValue);
|
|
49103
49102
|
}
|
|
49104
49103
|
}, [
|
|
49105
49104
|
ref
|
|
@@ -51171,7 +51170,9 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
51171
51170
|
]);
|
|
51172
51171
|
const submitForm = React172.useCallback(async () => {
|
|
51173
51172
|
const errors = await validateAndScrollToError(values);
|
|
51174
|
-
onSubmit?.()
|
|
51173
|
+
if (onSubmit?.() === false) {
|
|
51174
|
+
return;
|
|
51175
|
+
}
|
|
51175
51176
|
reportSubmitFormBi({
|
|
51176
51177
|
status: BiFormSubmissionStatus.INIT
|
|
51177
51178
|
});
|
|
@@ -60098,6 +60099,19 @@ MultilineAddress.PostalCode = PostalCode;
|
|
|
60098
60099
|
MultilineAddress.StreetName = StreetName;
|
|
60099
60100
|
MultilineAddress.StreetNumber = StreetNumber;
|
|
60100
60101
|
MultilineAddress.Apartment = Apartment;
|
|
60102
|
+
|
|
60103
|
+
// ../form-fields/dist/esm/field-viewer/number-prehydration-reader.js
|
|
60104
|
+
var readNumber = (element, { validation }) => {
|
|
60105
|
+
const parsed = toNumericValue(element.value.trim());
|
|
60106
|
+
if (parsed === void 0) {
|
|
60107
|
+
return void 0;
|
|
60108
|
+
}
|
|
60109
|
+
const { multipleOf, minimum, maximum } = validation?.number ?? {};
|
|
60110
|
+
const rounded = Number(parsed.toFixed(getNumberOfDecimals(multipleOf || 1)));
|
|
60111
|
+
return Math.min(Math.max(rounded, minimum ?? -Infinity), maximum ?? Infinity);
|
|
60112
|
+
};
|
|
60113
|
+
|
|
60114
|
+
// ../form-fields/dist/esm/ui/number-input-field/number-input-field-headless.js
|
|
60101
60115
|
var NumberInput = ({ children }) => {
|
|
60102
60116
|
const { id: id6, value, onChange, disabled, required, readOnly, onBlur, onFocus, FieldLayout, hasError, validation } = useFieldPropsV2();
|
|
60103
60117
|
const { labelId } = useFieldAttributes();
|
|
@@ -60160,6 +60174,7 @@ var Input12 = ({ className }) => {
|
|
|
60160
60174
|
preventScroll: true
|
|
60161
60175
|
});
|
|
60162
60176
|
}, id6);
|
|
60177
|
+
useKeepPrehydrationValue(ref, readNumber);
|
|
60163
60178
|
return /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.Input, {
|
|
60164
60179
|
ref,
|
|
60165
60180
|
id: inputId,
|
|
@@ -60308,6 +60323,18 @@ PaymentInput.Input = Input13;
|
|
|
60308
60323
|
PaymentInput.Description = Description;
|
|
60309
60324
|
PaymentInput.Error = Error2;
|
|
60310
60325
|
|
|
60326
|
+
// ../form-fields/dist/esm/field-viewer/phone-prehydration-reader.js
|
|
60327
|
+
var readPhoneNumber = (element, props2) => {
|
|
60328
|
+
const typed = element.value;
|
|
60329
|
+
if (!typed) {
|
|
60330
|
+
return void 0;
|
|
60331
|
+
}
|
|
60332
|
+
const { defaultCountry, validation } = props2;
|
|
60333
|
+
const allowedCountryCodes = validation?.string?.phoneOptions?.allowedCountryCodes;
|
|
60334
|
+
const country = parseCountryCodeFromPhoneNumber(typed) || defaultCountry || (allowedCountryCodes?.length === 1 ? allowedCountryCodes[0] : void 0);
|
|
60335
|
+
return normalizePhone(parseLocalPhone(typed, country)) ?? void 0;
|
|
60336
|
+
};
|
|
60337
|
+
|
|
60311
60338
|
// ../form-fields/dist/esm/ui/phone-input-field/phone-input/use-countries.js
|
|
60312
60339
|
init_esm();
|
|
60313
60340
|
function useCountries() {
|
|
@@ -60701,6 +60728,7 @@ var PhoneNumber2 = ({ className }) => {
|
|
|
60701
60728
|
preventScroll: true
|
|
60702
60729
|
});
|
|
60703
60730
|
}, id6);
|
|
60731
|
+
useKeepPrehydrationValue(ref, readPhoneNumber);
|
|
60704
60732
|
return /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.Input, {
|
|
60705
60733
|
ref,
|
|
60706
60734
|
id: inputId,
|