@wix/form-public 0.554.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 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 { path, value, readPrehydrationValue = readText } = useFieldPropsV2();
49091
+ const props2 = useFieldPropsV2();
49092
49092
  const mountedFieldRef = React172.useRef({
49093
- path,
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
@@ -60100,6 +60099,19 @@ MultilineAddress.PostalCode = PostalCode;
60100
60099
  MultilineAddress.StreetName = StreetName;
60101
60100
  MultilineAddress.StreetNumber = StreetNumber;
60102
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
60103
60115
  var NumberInput = ({ children }) => {
60104
60116
  const { id: id6, value, onChange, disabled, required, readOnly, onBlur, onFocus, FieldLayout, hasError, validation } = useFieldPropsV2();
60105
60117
  const { labelId } = useFieldAttributes();
@@ -60162,6 +60174,7 @@ var Input12 = ({ className }) => {
60162
60174
  preventScroll: true
60163
60175
  });
60164
60176
  }, id6);
60177
+ useKeepPrehydrationValue(ref, readNumber);
60165
60178
  return /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.Input, {
60166
60179
  ref,
60167
60180
  id: inputId,
@@ -60310,6 +60323,18 @@ PaymentInput.Input = Input13;
60310
60323
  PaymentInput.Description = Description;
60311
60324
  PaymentInput.Error = Error2;
60312
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
+
60313
60338
  // ../form-fields/dist/esm/ui/phone-input-field/phone-input/use-countries.js
60314
60339
  init_esm();
60315
60340
  function useCountries() {
@@ -60703,6 +60728,7 @@ var PhoneNumber2 = ({ className }) => {
60703
60728
  preventScroll: true
60704
60729
  });
60705
60730
  }, id6);
60731
+ useKeepPrehydrationValue(ref, readPhoneNumber);
60706
60732
  return /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.Input, {
60707
60733
  ref,
60708
60734
  id: inputId,