@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.cjs CHANGED
@@ -59290,11 +59290,11 @@ var PhoneInput = ({ children }) => {
59290
59290
  }));
59291
59291
  };
59292
59292
  var CountryButton = ({ children, className }) => {
59293
- const { inputId, labelId } = useFieldAttributes();
59293
+ const { labelId } = useFieldAttributes();
59294
59294
  const { hasError, disabled, readOnly } = useFieldPropsV2();
59295
59295
  const { t } = useTranslation2();
59296
59296
  const { selectedCountryCode, countries } = usePhoneInputContext();
59297
- const buttonId = `${inputId}-country`;
59297
+ const buttonId = React172.useId();
59298
59298
  const selectedCountry = selectedCountryCode ? countries.find((c) => c.shortCountryCode === selectedCountryCode) : void 0;
59299
59299
  const dialingCode = selectedCountry ? getCallingCode2(selectedCountry.longCountryCode) || "" : "";
59300
59300
  const countryCodeLabel = t("field.phone.country-code.aria-label");
@@ -59332,9 +59332,12 @@ var CountryButtonEmptyState = ({ children, className }) => {
59332
59332
  CountryButton.Flag = CountryButtonFlag;
59333
59333
  CountryButton.EmptyState = CountryButtonEmptyState;
59334
59334
  var CountryOptions = ({ children, className, "aria-label": ariaLabel, placement, offset, ...internal }) => {
59335
- const { triggerRef, optionsRef, isForcedOpen } = internal;
59335
+ const { triggerRef, optionsRef, isForcedOpen, isOpen } = internal;
59336
59336
  const { popoverContainer } = usePhoneInputContext();
59337
59337
  const searchElement = findChildOfType(children, CountryOptions.Search);
59338
+ if (!isOpen) {
59339
+ return null;
59340
+ }
59338
59341
  const content = /* @__PURE__ */ React172__default.default.createElement(CountryOptionsContent, {
59339
59342
  isForcedOpen
59340
59343
  }, children);
@@ -59492,24 +59495,54 @@ var PhoneNumber2 = ({ className }) => {
59492
59495
  className
59493
59496
  });
59494
59497
  };
59498
+ var CountryPopover = ({ children, ...internal }) => {
59499
+ const pickerProps = internal;
59500
+ const { isForcedOpen } = pickerProps;
59501
+ const { disabled, readOnly, required, hasError } = useFieldPropsV2();
59502
+ const [isOpen, setIsOpen] = React172.useState(false);
59503
+ const { t } = useTranslation2();
59504
+ const { selectedCountryCode, handleCountryCodeChange } = usePhoneInputContext();
59505
+ const isPopoverOpen = isForcedOpen || isOpen && !disabled && !readOnly;
59506
+ return /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.Select, {
59507
+ "aria-label": t("field.phone.country-code.aria-label"),
59508
+ value: selectedCountryCode ?? null,
59509
+ onChange: (key) => handleCountryCodeChange(key),
59510
+ isDisabled: disabled || readOnly,
59511
+ isInvalid: hasError,
59512
+ isRequired: required,
59513
+ placeholder: "",
59514
+ isOpen: isPopoverOpen,
59515
+ allowsEmptyCollection: true,
59516
+ onOpenChange: isForcedOpen ? void 0 : setIsOpen
59517
+ }, findChildOfType(children, PhoneInput.CountryButton), applyInternalProps(findChildOfType(children, PhoneInput.CountryOptions.Popover), {
59518
+ ...pickerProps,
59519
+ isOpen: isPopoverOpen
59520
+ }));
59521
+ };
59522
+ var CountryDrawer = ({ children, ...internal }) => {
59523
+ const pickerProps = internal;
59524
+ return /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.DialogTrigger, null, findChildOfType(children, PhoneInput.CountryButton), applyInternalProps(findChildOfType(children, PhoneInput.CountryOptions.Modal), pickerProps));
59525
+ };
59495
59526
  var Control7 = ({ children, className }) => {
59496
59527
  const controlRef = React172.useRef(null);
59497
59528
  const optionsRef = React172.useRef(null);
59498
59529
  const isFocused = React172.useRef(false);
59499
- const { id: id6, disabled, readOnly, required, hasError, showFlag, onFocus, onBlur } = useFieldPropsV2();
59500
- const [isOpen, setIsOpen] = React172.useState(false);
59530
+ const { id: id6, disabled, hasError, showFlag, onFocus, onBlur } = useFieldPropsV2();
59501
59531
  const invokeBlur = useInvokeCallback(onBlur);
59502
- const { t } = useTranslation2();
59503
- const { selectedCountryCode, handleCountryCodeChange, countries } = usePhoneInputContext();
59504
- const countryButtonElement = findChildOfType(children, PhoneInput.CountryButton);
59505
- const modalElement = findChildOfType(children, PhoneInput.CountryOptions.Modal);
59506
- const countryOptionsElement = modalElement ?? findChildOfType(children, PhoneInput.CountryOptions.Popover);
59532
+ const { countries } = usePhoneInputContext();
59533
+ const drawerElement = findChildOfType(children, PhoneInput.CountryDrawer);
59534
+ const popoverElement = findChildOfType(children, PhoneInput.CountryPopover);
59507
59535
  const phoneNumberElement = findChildOfType(children, PhoneInput.PhoneNumber);
59508
59536
  const hasCountryOptions2 = countries.length > 1;
59509
- const isForcedOpen = useIsForcedOpenDropdown(id6) && !modalElement && hasCountryOptions2;
59537
+ const isForcedOpen = useIsForcedOpenDropdown(id6) && !!popoverElement && hasCountryOptions2;
59510
59538
  const controlClassName = typeof className === "function" ? className({
59511
59539
  hasCountryOptions: hasCountryOptions2
59512
59540
  }) : className;
59541
+ const pickerProps = {
59542
+ triggerRef: controlRef,
59543
+ optionsRef,
59544
+ isForcedOpen
59545
+ };
59513
59546
  const focusHandlers = {
59514
59547
  onFocus: () => {
59515
59548
  if (!isFocused.current) {
@@ -59536,32 +59569,19 @@ var Control7 = ({ children, className }) => {
59536
59569
  longCountryCode: countries[0].longCountryCode
59537
59570
  }), phoneNumberElement);
59538
59571
  }
59539
- const selector = /* @__PURE__ */ React172__default.default.createElement(React172__default.default.Fragment, null, countryButtonElement, applyInternalProps(countryOptionsElement, {
59540
- triggerRef: controlRef,
59541
- optionsRef,
59542
- isForcedOpen
59543
- }));
59544
59572
  return /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.Group, {
59545
59573
  ref: controlRef,
59546
59574
  className: controlClassName,
59547
59575
  isDisabled: disabled,
59548
59576
  isInvalid: hasError,
59549
59577
  ...focusHandlers
59550
- }, modalElement ? /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.DialogTrigger, null, selector) : /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.Select, {
59551
- "aria-label": t("field.phone.country-code.aria-label"),
59552
- value: selectedCountryCode ?? null,
59553
- onChange: (key) => handleCountryCodeChange(key),
59554
- isDisabled: disabled || readOnly,
59555
- isInvalid: hasError,
59556
- isRequired: required,
59557
- placeholder: "",
59558
- isOpen: isForcedOpen || isOpen && !disabled && !readOnly,
59559
- onOpenChange: isForcedOpen ? void 0 : setIsOpen
59560
- }, selector), phoneNumberElement);
59578
+ }, !isForcedOpen && applyInternalProps(drawerElement, pickerProps), applyInternalProps(popoverElement, pickerProps), phoneNumberElement);
59561
59579
  };
59562
59580
  PhoneInput.Label = Label;
59563
59581
  PhoneInput.Control = Control7;
59564
59582
  PhoneInput.CountryButton = CountryButton;
59583
+ PhoneInput.CountryDrawer = CountryDrawer;
59584
+ PhoneInput.CountryPopover = CountryPopover;
59565
59585
  PhoneInput.CountryOptions = CountryOptions;
59566
59586
  PhoneInput.PhoneNumber = PhoneNumber2;
59567
59587
  PhoneInput.Description = Description;
@@ -60722,7 +60742,7 @@ var SignaturePad = class _SignaturePad extends SignatureEventTarget {
60722
60742
  return svg.outerHTML;
60723
60743
  }
60724
60744
  };
60725
- var useId = typeof React172__default.default.useId === "function" ? React172__default.default.useId : () => React172.useRef(generateUUID()).current;
60745
+ var useId2 = typeof React172__default.default.useId === "function" ? React172__default.default.useId : () => React172.useRef(generateUUID()).current;
60726
60746
 
60727
60747
  // ../form-fields/dist/esm/ui/signature-field/signature-types.js
60728
60748
  var SignatureFormat = /* @__PURE__ */ (function(SignatureFormat2) {
@@ -61632,7 +61652,7 @@ var Upload = ({ children, className, imageAlt, ...internal }) => {
61632
61652
  var UploadButton = ({ children, className, ...internal }) => {
61633
61653
  const { fileInputRef, disabled, readOnly, onBlur, onFocus } = internal;
61634
61654
  const { inputId, ariaDescribedBy, labelId } = useFieldAttributes();
61635
- const textId = useId();
61655
+ const textId = useId2();
61636
61656
  const handlePress = React172.useCallback(() => {
61637
61657
  fileInputRef.current?.click();
61638
61658
  }, [