@wix/form-public 0.514.0 → 0.515.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.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';
@@ -59280,11 +59280,11 @@ var PhoneInput = ({ children }) => {
59280
59280
  }));
59281
59281
  };
59282
59282
  var CountryButton = ({ children, className }) => {
59283
- const { inputId, labelId } = useFieldAttributes();
59283
+ const { labelId } = useFieldAttributes();
59284
59284
  const { hasError, disabled, readOnly } = useFieldPropsV2();
59285
59285
  const { t } = useTranslation2();
59286
59286
  const { selectedCountryCode, countries } = usePhoneInputContext();
59287
- const buttonId = `${inputId}-country`;
59287
+ const buttonId = useId();
59288
59288
  const selectedCountry = selectedCountryCode ? countries.find((c) => c.shortCountryCode === selectedCountryCode) : void 0;
59289
59289
  const dialingCode = selectedCountry ? getCallingCode2(selectedCountry.longCountryCode) || "" : "";
59290
59290
  const countryCodeLabel = t("field.phone.country-code.aria-label");
@@ -59322,9 +59322,12 @@ var CountryButtonEmptyState = ({ children, className }) => {
59322
59322
  CountryButton.Flag = CountryButtonFlag;
59323
59323
  CountryButton.EmptyState = CountryButtonEmptyState;
59324
59324
  var CountryOptions = ({ children, className, "aria-label": ariaLabel, placement, offset, ...internal }) => {
59325
- const { triggerRef, optionsRef, isForcedOpen } = internal;
59325
+ const { triggerRef, optionsRef, isForcedOpen, isOpen } = internal;
59326
59326
  const { popoverContainer } = usePhoneInputContext();
59327
59327
  const searchElement = findChildOfType(children, CountryOptions.Search);
59328
+ if (!isOpen) {
59329
+ return null;
59330
+ }
59328
59331
  const content = /* @__PURE__ */ React172.createElement(CountryOptionsContent, {
59329
59332
  isForcedOpen
59330
59333
  }, children);
@@ -59482,24 +59485,54 @@ var PhoneNumber2 = ({ className }) => {
59482
59485
  className
59483
59486
  });
59484
59487
  };
59488
+ var CountryPopover = ({ children, ...internal }) => {
59489
+ const pickerProps = internal;
59490
+ const { isForcedOpen } = pickerProps;
59491
+ const { disabled, readOnly, required, hasError } = useFieldPropsV2();
59492
+ const [isOpen, setIsOpen] = useState(false);
59493
+ const { t } = useTranslation2();
59494
+ const { selectedCountryCode, handleCountryCodeChange } = usePhoneInputContext();
59495
+ const isPopoverOpen = isForcedOpen || isOpen && !disabled && !readOnly;
59496
+ return /* @__PURE__ */ React172.createElement(Select, {
59497
+ "aria-label": t("field.phone.country-code.aria-label"),
59498
+ value: selectedCountryCode ?? null,
59499
+ onChange: (key) => handleCountryCodeChange(key),
59500
+ isDisabled: disabled || readOnly,
59501
+ isInvalid: hasError,
59502
+ isRequired: required,
59503
+ placeholder: "",
59504
+ isOpen: isPopoverOpen,
59505
+ allowsEmptyCollection: true,
59506
+ onOpenChange: isForcedOpen ? void 0 : setIsOpen
59507
+ }, findChildOfType(children, PhoneInput.CountryButton), applyInternalProps(findChildOfType(children, PhoneInput.CountryOptions.Popover), {
59508
+ ...pickerProps,
59509
+ isOpen: isPopoverOpen
59510
+ }));
59511
+ };
59512
+ var CountryDrawer = ({ children, ...internal }) => {
59513
+ const pickerProps = internal;
59514
+ return /* @__PURE__ */ React172.createElement(DialogTrigger, null, findChildOfType(children, PhoneInput.CountryButton), applyInternalProps(findChildOfType(children, PhoneInput.CountryOptions.Modal), pickerProps));
59515
+ };
59485
59516
  var Control7 = ({ children, className }) => {
59486
59517
  const controlRef = useRef(null);
59487
59518
  const optionsRef = useRef(null);
59488
59519
  const isFocused = useRef(false);
59489
- const { id: id6, disabled, readOnly, required, hasError, showFlag, onFocus, onBlur } = useFieldPropsV2();
59490
- const [isOpen, setIsOpen] = useState(false);
59520
+ const { id: id6, disabled, hasError, showFlag, onFocus, onBlur } = useFieldPropsV2();
59491
59521
  const invokeBlur = useInvokeCallback(onBlur);
59492
- const { t } = useTranslation2();
59493
- const { selectedCountryCode, handleCountryCodeChange, countries } = usePhoneInputContext();
59494
- const countryButtonElement = findChildOfType(children, PhoneInput.CountryButton);
59495
- const modalElement = findChildOfType(children, PhoneInput.CountryOptions.Modal);
59496
- const countryOptionsElement = modalElement ?? findChildOfType(children, PhoneInput.CountryOptions.Popover);
59522
+ const { countries } = usePhoneInputContext();
59523
+ const drawerElement = findChildOfType(children, PhoneInput.CountryDrawer);
59524
+ const popoverElement = findChildOfType(children, PhoneInput.CountryPopover);
59497
59525
  const phoneNumberElement = findChildOfType(children, PhoneInput.PhoneNumber);
59498
59526
  const hasCountryOptions2 = countries.length > 1;
59499
- const isForcedOpen = useIsForcedOpenDropdown(id6) && !modalElement && hasCountryOptions2;
59527
+ const isForcedOpen = useIsForcedOpenDropdown(id6) && !!popoverElement && hasCountryOptions2;
59500
59528
  const controlClassName = typeof className === "function" ? className({
59501
59529
  hasCountryOptions: hasCountryOptions2
59502
59530
  }) : className;
59531
+ const pickerProps = {
59532
+ triggerRef: controlRef,
59533
+ optionsRef,
59534
+ isForcedOpen
59535
+ };
59503
59536
  const focusHandlers = {
59504
59537
  onFocus: () => {
59505
59538
  if (!isFocused.current) {
@@ -59526,32 +59559,19 @@ var Control7 = ({ children, className }) => {
59526
59559
  longCountryCode: countries[0].longCountryCode
59527
59560
  }), phoneNumberElement);
59528
59561
  }
59529
- const selector = /* @__PURE__ */ React172.createElement(React172.Fragment, null, countryButtonElement, applyInternalProps(countryOptionsElement, {
59530
- triggerRef: controlRef,
59531
- optionsRef,
59532
- isForcedOpen
59533
- }));
59534
59562
  return /* @__PURE__ */ React172.createElement(Group, {
59535
59563
  ref: controlRef,
59536
59564
  className: controlClassName,
59537
59565
  isDisabled: disabled,
59538
59566
  isInvalid: hasError,
59539
59567
  ...focusHandlers
59540
- }, modalElement ? /* @__PURE__ */ React172.createElement(DialogTrigger, null, selector) : /* @__PURE__ */ React172.createElement(Select, {
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);
59568
+ }, !isForcedOpen && applyInternalProps(drawerElement, pickerProps), applyInternalProps(popoverElement, pickerProps), phoneNumberElement);
59551
59569
  };
59552
59570
  PhoneInput.Label = Label;
59553
59571
  PhoneInput.Control = Control7;
59554
59572
  PhoneInput.CountryButton = CountryButton;
59573
+ PhoneInput.CountryDrawer = CountryDrawer;
59574
+ PhoneInput.CountryPopover = CountryPopover;
59555
59575
  PhoneInput.CountryOptions = CountryOptions;
59556
59576
  PhoneInput.PhoneNumber = PhoneNumber2;
59557
59577
  PhoneInput.Description = Description;
@@ -60712,7 +60732,7 @@ var SignaturePad = class _SignaturePad extends SignatureEventTarget {
60712
60732
  return svg.outerHTML;
60713
60733
  }
60714
60734
  };
60715
- var useId = typeof React172.useId === "function" ? React172.useId : () => useRef(generateUUID()).current;
60735
+ var useId2 = typeof React172.useId === "function" ? React172.useId : () => useRef(generateUUID()).current;
60716
60736
 
60717
60737
  // ../form-fields/dist/esm/ui/signature-field/signature-types.js
60718
60738
  var SignatureFormat = /* @__PURE__ */ (function(SignatureFormat2) {
@@ -61622,7 +61642,7 @@ var Upload = ({ children, className, imageAlt, ...internal }) => {
61622
61642
  var UploadButton = ({ children, className, ...internal }) => {
61623
61643
  const { fileInputRef, disabled, readOnly, onBlur, onFocus } = internal;
61624
61644
  const { inputId, ariaDescribedBy, labelId } = useFieldAttributes();
61625
- const textId = useId();
61645
+ const textId = useId2();
61626
61646
  const handlePress = useCallback(() => {
61627
61647
  fileInputRef.current?.click();
61628
61648
  }, [