@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 +34 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -8
- 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
|
|
@@ -60090,6 +60089,19 @@ MultilineAddress.PostalCode = PostalCode;
|
|
|
60090
60089
|
MultilineAddress.StreetName = StreetName;
|
|
60091
60090
|
MultilineAddress.StreetNumber = StreetNumber;
|
|
60092
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
|
|
60093
60105
|
var NumberInput = ({ children }) => {
|
|
60094
60106
|
const { id: id6, value, onChange, disabled, required, readOnly, onBlur, onFocus, FieldLayout, hasError, validation } = useFieldPropsV2();
|
|
60095
60107
|
const { labelId } = useFieldAttributes();
|
|
@@ -60152,6 +60164,7 @@ var Input12 = ({ className }) => {
|
|
|
60152
60164
|
preventScroll: true
|
|
60153
60165
|
});
|
|
60154
60166
|
}, id6);
|
|
60167
|
+
useKeepPrehydrationValue(ref, readNumber);
|
|
60155
60168
|
return /* @__PURE__ */ React172.createElement(Input, {
|
|
60156
60169
|
ref,
|
|
60157
60170
|
id: inputId,
|
|
@@ -60300,6 +60313,18 @@ PaymentInput.Input = Input13;
|
|
|
60300
60313
|
PaymentInput.Description = Description;
|
|
60301
60314
|
PaymentInput.Error = Error2;
|
|
60302
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
|
+
|
|
60303
60328
|
// ../form-fields/dist/esm/ui/phone-input-field/phone-input/use-countries.js
|
|
60304
60329
|
init_esm();
|
|
60305
60330
|
function useCountries() {
|
|
@@ -60693,6 +60718,7 @@ var PhoneNumber2 = ({ className }) => {
|
|
|
60693
60718
|
preventScroll: true
|
|
60694
60719
|
});
|
|
60695
60720
|
}, id6);
|
|
60721
|
+
useKeepPrehydrationValue(ref, readPhoneNumber);
|
|
60696
60722
|
return /* @__PURE__ */ React172.createElement(Input, {
|
|
60697
60723
|
ref,
|
|
60698
60724
|
id: inputId,
|