@wix/form-public 0.514.0 → 0.516.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 +55 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +56 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorType, ValidationMode } from '@wix/ambassador-forms-v1-validation-result/types';
|
|
2
2
|
import { DayOfWeek, InputFieldInputType, ValidationFormat, RequiredIndicator as RequiredIndicator$1, RequiredIndicatorPlacement as RequiredIndicatorPlacement$1, PriceType, InputFieldPaymentComponentType, InputFieldNumberComponentType, InputFieldStringComponentType, FieldFieldType, Format as Format$1, SubmitSuccessAction as SubmitSuccessAction$1, ContactAutofill as ContactAutofill$1, UrlTargetEnumTarget, ArrayItemsItemType, OverrideEntityType as OverrideEntityType$1 } from '@wix/ambassador-forms-v4-form-http/types';
|
|
3
|
-
import React172, { createContext, useRef, Component, createRef, Suspense, useMemo, useCallback, useState, useEffect, useContext, Children, isValidElement, cloneElement, forwardRef, useImperativeHandle, Fragment, useLayoutEffect, createElement } from 'react';
|
|
3
|
+
import React172, { createContext, useRef, Component, createRef, Suspense, useMemo, useCallback, useState, useEffect, useContext, Children, isValidElement, cloneElement, forwardRef, useImperativeHandle, Fragment, useLayoutEffect, createElement, useId } from 'react';
|
|
4
4
|
import { initReactI18next } from 'react-i18next';
|
|
5
5
|
import default2 from 'i18next';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
@@ -43121,6 +43121,7 @@ var ForcedState = /* @__PURE__ */ (function(ForcedState2) {
|
|
|
43121
43121
|
ForcedState2["INPUT_FIELDS_FOCUS"] = "INPUT_FIELDS_FOCUS";
|
|
43122
43122
|
ForcedState2["INPUT_FIELDS_ERROR"] = "INPUT_FIELDS_ERROR";
|
|
43123
43123
|
ForcedState2["SUCCESS_MESSAGE"] = "SUCCESS_MESSAGE";
|
|
43124
|
+
ForcedState2["HIDDEN_FIELDS"] = "HIDDEN_FIELDS";
|
|
43124
43125
|
return ForcedState2;
|
|
43125
43126
|
})({});
|
|
43126
43127
|
var ForcedStateContext = createContext([]);
|
|
@@ -49908,6 +49909,7 @@ var useFormValues = (form, values, onChange, userData, addressTemplates, enableA
|
|
|
49908
49909
|
};
|
|
49909
49910
|
var useFormView2 = (form, stepId, breakpoint) => {
|
|
49910
49911
|
const { isMobile: isMobile2 } = useConfig();
|
|
49912
|
+
const includeHiddenFields = useForcedState().includes(ForcedState.HIDDEN_FIELDS);
|
|
49911
49913
|
const experiments = useExperiments();
|
|
49912
49914
|
const useFieldsV2App = experiments.isExperimentEnabled(EXPERIMENTS.USE_FIELDS_V2);
|
|
49913
49915
|
const useFieldsV2Standalone = experiments.isExperimentEnabled(EXPERIMENTS.USE_FIELDS_V2_STANDALONE);
|
|
@@ -49922,7 +49924,8 @@ var useFormView2 = (form, stepId, breakpoint) => {
|
|
|
49922
49924
|
stepId: step.id,
|
|
49923
49925
|
isMobile: isMobile2,
|
|
49924
49926
|
breakpoint,
|
|
49925
|
-
useFieldsV2
|
|
49927
|
+
useFieldsV2,
|
|
49928
|
+
includeHiddenFields
|
|
49926
49929
|
});
|
|
49927
49930
|
});
|
|
49928
49931
|
}, [
|
|
@@ -49930,7 +49933,8 @@ var useFormView2 = (form, stepId, breakpoint) => {
|
|
|
49930
49933
|
stepId,
|
|
49931
49934
|
isMobile2,
|
|
49932
49935
|
breakpoint,
|
|
49933
|
-
useFieldsV2
|
|
49936
|
+
useFieldsV2,
|
|
49937
|
+
includeHiddenFields
|
|
49934
49938
|
]);
|
|
49935
49939
|
};
|
|
49936
49940
|
var useReportFieldEdit = (form) => {
|
|
@@ -59280,11 +59284,11 @@ var PhoneInput = ({ children }) => {
|
|
|
59280
59284
|
}));
|
|
59281
59285
|
};
|
|
59282
59286
|
var CountryButton = ({ children, className }) => {
|
|
59283
|
-
const {
|
|
59287
|
+
const { labelId } = useFieldAttributes();
|
|
59284
59288
|
const { hasError, disabled, readOnly } = useFieldPropsV2();
|
|
59285
59289
|
const { t } = useTranslation2();
|
|
59286
59290
|
const { selectedCountryCode, countries } = usePhoneInputContext();
|
|
59287
|
-
const buttonId =
|
|
59291
|
+
const buttonId = useId();
|
|
59288
59292
|
const selectedCountry = selectedCountryCode ? countries.find((c) => c.shortCountryCode === selectedCountryCode) : void 0;
|
|
59289
59293
|
const dialingCode = selectedCountry ? getCallingCode2(selectedCountry.longCountryCode) || "" : "";
|
|
59290
59294
|
const countryCodeLabel = t("field.phone.country-code.aria-label");
|
|
@@ -59322,9 +59326,12 @@ var CountryButtonEmptyState = ({ children, className }) => {
|
|
|
59322
59326
|
CountryButton.Flag = CountryButtonFlag;
|
|
59323
59327
|
CountryButton.EmptyState = CountryButtonEmptyState;
|
|
59324
59328
|
var CountryOptions = ({ children, className, "aria-label": ariaLabel, placement, offset, ...internal }) => {
|
|
59325
|
-
const { triggerRef, optionsRef, isForcedOpen } = internal;
|
|
59329
|
+
const { triggerRef, optionsRef, isForcedOpen, isOpen } = internal;
|
|
59326
59330
|
const { popoverContainer } = usePhoneInputContext();
|
|
59327
59331
|
const searchElement = findChildOfType(children, CountryOptions.Search);
|
|
59332
|
+
if (!isOpen) {
|
|
59333
|
+
return null;
|
|
59334
|
+
}
|
|
59328
59335
|
const content = /* @__PURE__ */ React172.createElement(CountryOptionsContent, {
|
|
59329
59336
|
isForcedOpen
|
|
59330
59337
|
}, children);
|
|
@@ -59482,24 +59489,54 @@ var PhoneNumber2 = ({ className }) => {
|
|
|
59482
59489
|
className
|
|
59483
59490
|
});
|
|
59484
59491
|
};
|
|
59492
|
+
var CountryPopover = ({ children, ...internal }) => {
|
|
59493
|
+
const pickerProps = internal;
|
|
59494
|
+
const { isForcedOpen } = pickerProps;
|
|
59495
|
+
const { disabled, readOnly, required, hasError } = useFieldPropsV2();
|
|
59496
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
59497
|
+
const { t } = useTranslation2();
|
|
59498
|
+
const { selectedCountryCode, handleCountryCodeChange } = usePhoneInputContext();
|
|
59499
|
+
const isPopoverOpen = isForcedOpen || isOpen && !disabled && !readOnly;
|
|
59500
|
+
return /* @__PURE__ */ React172.createElement(Select, {
|
|
59501
|
+
"aria-label": t("field.phone.country-code.aria-label"),
|
|
59502
|
+
value: selectedCountryCode ?? null,
|
|
59503
|
+
onChange: (key) => handleCountryCodeChange(key),
|
|
59504
|
+
isDisabled: disabled || readOnly,
|
|
59505
|
+
isInvalid: hasError,
|
|
59506
|
+
isRequired: required,
|
|
59507
|
+
placeholder: "",
|
|
59508
|
+
isOpen: isPopoverOpen,
|
|
59509
|
+
allowsEmptyCollection: true,
|
|
59510
|
+
onOpenChange: isForcedOpen ? void 0 : setIsOpen
|
|
59511
|
+
}, findChildOfType(children, PhoneInput.CountryButton), applyInternalProps(findChildOfType(children, PhoneInput.CountryOptions.Popover), {
|
|
59512
|
+
...pickerProps,
|
|
59513
|
+
isOpen: isPopoverOpen
|
|
59514
|
+
}));
|
|
59515
|
+
};
|
|
59516
|
+
var CountryDrawer = ({ children, ...internal }) => {
|
|
59517
|
+
const pickerProps = internal;
|
|
59518
|
+
return /* @__PURE__ */ React172.createElement(DialogTrigger, null, findChildOfType(children, PhoneInput.CountryButton), applyInternalProps(findChildOfType(children, PhoneInput.CountryOptions.Modal), pickerProps));
|
|
59519
|
+
};
|
|
59485
59520
|
var Control7 = ({ children, className }) => {
|
|
59486
59521
|
const controlRef = useRef(null);
|
|
59487
59522
|
const optionsRef = useRef(null);
|
|
59488
59523
|
const isFocused = useRef(false);
|
|
59489
|
-
const { id: id6, disabled,
|
|
59490
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
59524
|
+
const { id: id6, disabled, hasError, showFlag, onFocus, onBlur } = useFieldPropsV2();
|
|
59491
59525
|
const invokeBlur = useInvokeCallback(onBlur);
|
|
59492
|
-
const {
|
|
59493
|
-
const
|
|
59494
|
-
const
|
|
59495
|
-
const modalElement = findChildOfType(children, PhoneInput.CountryOptions.Modal);
|
|
59496
|
-
const countryOptionsElement = modalElement ?? findChildOfType(children, PhoneInput.CountryOptions.Popover);
|
|
59526
|
+
const { countries } = usePhoneInputContext();
|
|
59527
|
+
const drawerElement = findChildOfType(children, PhoneInput.CountryDrawer);
|
|
59528
|
+
const popoverElement = findChildOfType(children, PhoneInput.CountryPopover);
|
|
59497
59529
|
const phoneNumberElement = findChildOfType(children, PhoneInput.PhoneNumber);
|
|
59498
59530
|
const hasCountryOptions2 = countries.length > 1;
|
|
59499
|
-
const isForcedOpen = useIsForcedOpenDropdown(id6) &&
|
|
59531
|
+
const isForcedOpen = useIsForcedOpenDropdown(id6) && !!popoverElement && hasCountryOptions2;
|
|
59500
59532
|
const controlClassName = typeof className === "function" ? className({
|
|
59501
59533
|
hasCountryOptions: hasCountryOptions2
|
|
59502
59534
|
}) : className;
|
|
59535
|
+
const pickerProps = {
|
|
59536
|
+
triggerRef: controlRef,
|
|
59537
|
+
optionsRef,
|
|
59538
|
+
isForcedOpen
|
|
59539
|
+
};
|
|
59503
59540
|
const focusHandlers = {
|
|
59504
59541
|
onFocus: () => {
|
|
59505
59542
|
if (!isFocused.current) {
|
|
@@ -59526,32 +59563,19 @@ var Control7 = ({ children, className }) => {
|
|
|
59526
59563
|
longCountryCode: countries[0].longCountryCode
|
|
59527
59564
|
}), phoneNumberElement);
|
|
59528
59565
|
}
|
|
59529
|
-
const selector = /* @__PURE__ */ React172.createElement(React172.Fragment, null, countryButtonElement, applyInternalProps(countryOptionsElement, {
|
|
59530
|
-
triggerRef: controlRef,
|
|
59531
|
-
optionsRef,
|
|
59532
|
-
isForcedOpen
|
|
59533
|
-
}));
|
|
59534
59566
|
return /* @__PURE__ */ React172.createElement(Group, {
|
|
59535
59567
|
ref: controlRef,
|
|
59536
59568
|
className: controlClassName,
|
|
59537
59569
|
isDisabled: disabled,
|
|
59538
59570
|
isInvalid: hasError,
|
|
59539
59571
|
...focusHandlers
|
|
59540
|
-
},
|
|
59541
|
-
"aria-label": t("field.phone.country-code.aria-label"),
|
|
59542
|
-
value: selectedCountryCode ?? null,
|
|
59543
|
-
onChange: (key) => handleCountryCodeChange(key),
|
|
59544
|
-
isDisabled: disabled || readOnly,
|
|
59545
|
-
isInvalid: hasError,
|
|
59546
|
-
isRequired: required,
|
|
59547
|
-
placeholder: "",
|
|
59548
|
-
isOpen: isForcedOpen || isOpen && !disabled && !readOnly,
|
|
59549
|
-
onOpenChange: isForcedOpen ? void 0 : setIsOpen
|
|
59550
|
-
}, selector), phoneNumberElement);
|
|
59572
|
+
}, !isForcedOpen && applyInternalProps(drawerElement, pickerProps), applyInternalProps(popoverElement, pickerProps), phoneNumberElement);
|
|
59551
59573
|
};
|
|
59552
59574
|
PhoneInput.Label = Label;
|
|
59553
59575
|
PhoneInput.Control = Control7;
|
|
59554
59576
|
PhoneInput.CountryButton = CountryButton;
|
|
59577
|
+
PhoneInput.CountryDrawer = CountryDrawer;
|
|
59578
|
+
PhoneInput.CountryPopover = CountryPopover;
|
|
59555
59579
|
PhoneInput.CountryOptions = CountryOptions;
|
|
59556
59580
|
PhoneInput.PhoneNumber = PhoneNumber2;
|
|
59557
59581
|
PhoneInput.Description = Description;
|
|
@@ -60712,7 +60736,7 @@ var SignaturePad = class _SignaturePad extends SignatureEventTarget {
|
|
|
60712
60736
|
return svg.outerHTML;
|
|
60713
60737
|
}
|
|
60714
60738
|
};
|
|
60715
|
-
var
|
|
60739
|
+
var useId2 = typeof React172.useId === "function" ? React172.useId : () => useRef(generateUUID()).current;
|
|
60716
60740
|
|
|
60717
60741
|
// ../form-fields/dist/esm/ui/signature-field/signature-types.js
|
|
60718
60742
|
var SignatureFormat = /* @__PURE__ */ (function(SignatureFormat2) {
|
|
@@ -61622,7 +61646,7 @@ var Upload = ({ children, className, imageAlt, ...internal }) => {
|
|
|
61622
61646
|
var UploadButton = ({ children, className, ...internal }) => {
|
|
61623
61647
|
const { fileInputRef, disabled, readOnly, onBlur, onFocus } = internal;
|
|
61624
61648
|
const { inputId, ariaDescribedBy, labelId } = useFieldAttributes();
|
|
61625
|
-
const textId =
|
|
61649
|
+
const textId = useId2();
|
|
61626
61650
|
const handlePress = useCallback(() => {
|
|
61627
61651
|
fileInputRef.current?.click();
|
|
61628
61652
|
}, [
|