@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.js
CHANGED
|
@@ -49076,20 +49076,19 @@ var forgetPrehydrationValues = (pending, previousValues, nextValues) => {
|
|
|
49076
49076
|
// ../form-fields/dist/esm/contexts/prehydration-values-context.js
|
|
49077
49077
|
var PrehydrationValuesContext = /* @__PURE__ */ createContext(void 0);
|
|
49078
49078
|
var readText = (element) => element.value;
|
|
49079
|
-
var useKeepPrehydrationValue = (ref) => {
|
|
49079
|
+
var useKeepPrehydrationValue = (ref, read2) => {
|
|
49080
49080
|
const registry = useContext(PrehydrationValuesContext);
|
|
49081
|
-
const
|
|
49081
|
+
const props2 = useFieldPropsV2();
|
|
49082
49082
|
const mountedFieldRef = useRef({
|
|
49083
|
-
|
|
49084
|
-
value,
|
|
49083
|
+
props: props2,
|
|
49085
49084
|
registry,
|
|
49086
|
-
read: readPrehydrationValue
|
|
49085
|
+
read: read2 ?? props2.readPrehydrationValue ?? readText
|
|
49087
49086
|
});
|
|
49088
49087
|
useEffect(() => {
|
|
49089
49088
|
const field = mountedFieldRef.current;
|
|
49090
|
-
const domValue = ref.current ? field.read(ref.current) : void 0;
|
|
49091
|
-
if (field.registry && !isEmptyInputValue(domValue) && isEmptyInputValue(field.value)) {
|
|
49092
|
-
field.registry.current.set(field.path, domValue);
|
|
49089
|
+
const domValue = ref.current ? field.read(ref.current, field.props) : void 0;
|
|
49090
|
+
if (field.registry && !isEmptyInputValue(domValue) && isEmptyInputValue(field.props.value)) {
|
|
49091
|
+
field.registry.current.set(field.props.path, domValue);
|
|
49093
49092
|
}
|
|
49094
49093
|
}, [
|
|
49095
49094
|
ref
|
|
@@ -51161,7 +51160,9 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
51161
51160
|
]);
|
|
51162
51161
|
const submitForm = useCallback(async () => {
|
|
51163
51162
|
const errors = await validateAndScrollToError(values);
|
|
51164
|
-
onSubmit?.()
|
|
51163
|
+
if (onSubmit?.() === false) {
|
|
51164
|
+
return;
|
|
51165
|
+
}
|
|
51165
51166
|
reportSubmitFormBi({
|
|
51166
51167
|
status: BiFormSubmissionStatus.INIT
|
|
51167
51168
|
});
|
|
@@ -60088,6 +60089,19 @@ MultilineAddress.PostalCode = PostalCode;
|
|
|
60088
60089
|
MultilineAddress.StreetName = StreetName;
|
|
60089
60090
|
MultilineAddress.StreetNumber = StreetNumber;
|
|
60090
60091
|
MultilineAddress.Apartment = Apartment;
|
|
60092
|
+
|
|
60093
|
+
// ../form-fields/dist/esm/field-viewer/number-prehydration-reader.js
|
|
60094
|
+
var readNumber = (element, { validation }) => {
|
|
60095
|
+
const parsed = toNumericValue(element.value.trim());
|
|
60096
|
+
if (parsed === void 0) {
|
|
60097
|
+
return void 0;
|
|
60098
|
+
}
|
|
60099
|
+
const { multipleOf, minimum, maximum } = validation?.number ?? {};
|
|
60100
|
+
const rounded = Number(parsed.toFixed(getNumberOfDecimals(multipleOf || 1)));
|
|
60101
|
+
return Math.min(Math.max(rounded, minimum ?? -Infinity), maximum ?? Infinity);
|
|
60102
|
+
};
|
|
60103
|
+
|
|
60104
|
+
// ../form-fields/dist/esm/ui/number-input-field/number-input-field-headless.js
|
|
60091
60105
|
var NumberInput = ({ children }) => {
|
|
60092
60106
|
const { id: id6, value, onChange, disabled, required, readOnly, onBlur, onFocus, FieldLayout, hasError, validation } = useFieldPropsV2();
|
|
60093
60107
|
const { labelId } = useFieldAttributes();
|
|
@@ -60150,6 +60164,7 @@ var Input12 = ({ className }) => {
|
|
|
60150
60164
|
preventScroll: true
|
|
60151
60165
|
});
|
|
60152
60166
|
}, id6);
|
|
60167
|
+
useKeepPrehydrationValue(ref, readNumber);
|
|
60153
60168
|
return /* @__PURE__ */ React172.createElement(Input, {
|
|
60154
60169
|
ref,
|
|
60155
60170
|
id: inputId,
|
|
@@ -60298,6 +60313,18 @@ PaymentInput.Input = Input13;
|
|
|
60298
60313
|
PaymentInput.Description = Description;
|
|
60299
60314
|
PaymentInput.Error = Error2;
|
|
60300
60315
|
|
|
60316
|
+
// ../form-fields/dist/esm/field-viewer/phone-prehydration-reader.js
|
|
60317
|
+
var readPhoneNumber = (element, props2) => {
|
|
60318
|
+
const typed = element.value;
|
|
60319
|
+
if (!typed) {
|
|
60320
|
+
return void 0;
|
|
60321
|
+
}
|
|
60322
|
+
const { defaultCountry, validation } = props2;
|
|
60323
|
+
const allowedCountryCodes = validation?.string?.phoneOptions?.allowedCountryCodes;
|
|
60324
|
+
const country = parseCountryCodeFromPhoneNumber(typed) || defaultCountry || (allowedCountryCodes?.length === 1 ? allowedCountryCodes[0] : void 0);
|
|
60325
|
+
return normalizePhone(parseLocalPhone(typed, country)) ?? void 0;
|
|
60326
|
+
};
|
|
60327
|
+
|
|
60301
60328
|
// ../form-fields/dist/esm/ui/phone-input-field/phone-input/use-countries.js
|
|
60302
60329
|
init_esm();
|
|
60303
60330
|
function useCountries() {
|
|
@@ -60691,6 +60718,7 @@ var PhoneNumber2 = ({ className }) => {
|
|
|
60691
60718
|
preventScroll: true
|
|
60692
60719
|
});
|
|
60693
60720
|
}, id6);
|
|
60721
|
+
useKeepPrehydrationValue(ref, readPhoneNumber);
|
|
60694
60722
|
return /* @__PURE__ */ React172.createElement(Input, {
|
|
60695
60723
|
ref,
|
|
60696
60724
|
id: inputId,
|