@wix/form-public 0.503.0 → 0.504.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 +124 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +125 -46
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import ReactDOM from 'react-dom';
|
|
|
7
7
|
import camelCase2 from 'lodash.camelcase';
|
|
8
8
|
import mapKeys from 'lodash.mapkeys';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
|
-
import { CheckboxField, CheckboxButton, TextField, Input, ListBoxItem, ListBox, Dialog, OverlayTriggerStateContext, ModalOverlay, Modal, SearchField, RadioGroup as RadioGroup$1, Button, useSlottedContext, PopoverContext, Popover, Autocomplete, RadioField, RadioButton, CheckboxGroup as CheckboxGroup$1, I18nProvider, DatePicker as DatePicker$1, Select, NumberField, TimeField, SelectValue, CalendarCell, Calendar as Calendar$1, CalendarMonthPicker, CalendarYearPicker, CalendarGrid, DatePickerStateContext,
|
|
10
|
+
import { CheckboxField, CheckboxButton, TextField, Input, ListBoxItem, ListBox, Dialog, OverlayTriggerStateContext, ModalOverlay, Modal, SearchField, Group, RadioGroup as RadioGroup$1, Button, useSlottedContext, PopoverContext, Popover, Autocomplete, RadioField, RadioButton, CheckboxGroup as CheckboxGroup$1, I18nProvider, DatePicker as DatePicker$1, Select, NumberField, TimeField, SelectValue, CalendarCell, Calendar as Calendar$1, CalendarMonthPicker, CalendarYearPicker, CalendarGrid, DatePickerStateContext, DateInput as DateInput$1, DateSegment, TimeFieldStateContext, FileTrigger, DropZone as DropZone$1, Text as Text$1, ProgressBar, ComboBox, DialogTrigger, TextArea as TextArea$1, ComboBoxStateContext } from 'react-aria-components';
|
|
11
11
|
|
|
12
12
|
var __create = Object.create;
|
|
13
13
|
var __defProp = Object.defineProperty;
|
|
@@ -53734,6 +53734,49 @@ var DatePickerTriggerButton = /* @__PURE__ */ forwardRef((props2, ref) => {
|
|
|
53734
53734
|
onPress: handlePress
|
|
53735
53735
|
});
|
|
53736
53736
|
});
|
|
53737
|
+
var DROPDOWN_FIELD_TYPES = [
|
|
53738
|
+
FIELD_TYPES.DROPDOWN,
|
|
53739
|
+
FIELD_TYPES.DEXT_DROPDOWN,
|
|
53740
|
+
FIELD_TYPES.SERVICES_DROPDOWN,
|
|
53741
|
+
FIELD_TYPES.DATE_INPUT,
|
|
53742
|
+
FIELD_TYPES.CONTACTS_BIRTHDATE,
|
|
53743
|
+
FIELD_TYPES.DATE_TIME_INPUT,
|
|
53744
|
+
FIELD_TYPES.DEXT_DATE_TIME_INPUT
|
|
53745
|
+
];
|
|
53746
|
+
var PHONE_FIELD_TYPES = [
|
|
53747
|
+
FIELD_TYPES.PHONE,
|
|
53748
|
+
FIELD_TYPES.CONTACTS_PHONE,
|
|
53749
|
+
FIELD_TYPES.BOOKINGS_PHONE,
|
|
53750
|
+
FIELD_TYPES.DEXT_PHONE
|
|
53751
|
+
];
|
|
53752
|
+
var ADDRESS_FIELD_TYPES = [
|
|
53753
|
+
FIELD_TYPES.MULTILINE_ADDRESS,
|
|
53754
|
+
FIELD_TYPES.BOOKINGS_ADDRESS,
|
|
53755
|
+
FIELD_TYPES.ECOM_ADDRESS
|
|
53756
|
+
];
|
|
53757
|
+
var hasCountryOptions = ({ properties }) => properties.validation?.string?.phoneOptions?.allowedCountryCodes?.length !== 1;
|
|
53758
|
+
var showsCountry = ({ properties }) => properties.fieldSettings?.country?.show !== false;
|
|
53759
|
+
var hasDropdown = (field, isMobile2) => {
|
|
53760
|
+
if (PHONE_FIELD_TYPES.includes(field.fieldType)) {
|
|
53761
|
+
return !isMobile2 && hasCountryOptions(field);
|
|
53762
|
+
}
|
|
53763
|
+
if (ADDRESS_FIELD_TYPES.includes(field.fieldType)) {
|
|
53764
|
+
return showsCountry(field);
|
|
53765
|
+
}
|
|
53766
|
+
return DROPDOWN_FIELD_TYPES.includes(field.fieldType);
|
|
53767
|
+
};
|
|
53768
|
+
var isOpenableDropdown = (field, isMobile2) => hasDropdown(field, isMobile2) && !field.properties.hidden && !field.properties.disabled && !field.properties.readOnly;
|
|
53769
|
+
var byLayoutPosition = (first2, second) => first2.layout.row - second.layout.row || first2.layout.column - second.layout.column;
|
|
53770
|
+
var useIsForcedOpenDropdown = (fieldId) => {
|
|
53771
|
+
const isOpenState = useElementProps().dropdown?.open === true;
|
|
53772
|
+
const formView = useContext(FormViewContext);
|
|
53773
|
+
const { isMobile: isMobile2 = false } = useConfig();
|
|
53774
|
+
const firstDropdownId = useMemo(() => formView && !formView.parentId ? formView.fields.filter((field) => isOpenableDropdown(field, isMobile2)).sort(byLayoutPosition)[0]?.id : void 0, [
|
|
53775
|
+
formView,
|
|
53776
|
+
isMobile2
|
|
53777
|
+
]);
|
|
53778
|
+
return isOpenState && firstDropdownId === fieldId;
|
|
53779
|
+
};
|
|
53737
53780
|
|
|
53738
53781
|
// ../form-fields/dist/esm/ui/date-input-field/date-input-field-headless.js
|
|
53739
53782
|
var DateInput = ({ children, className }) => {
|
|
@@ -53769,11 +53812,12 @@ var DateInput = ({ children, className }) => {
|
|
|
53769
53812
|
});
|
|
53770
53813
|
};
|
|
53771
53814
|
var Month = ({ children, className }) => {
|
|
53772
|
-
const { disabled, readOnly, showDateLabels, hidePlaceholder } = useFieldPropsV2();
|
|
53815
|
+
const { id: id6, disabled, readOnly, showDateLabels, hidePlaceholder } = useFieldPropsV2();
|
|
53773
53816
|
const { labelId } = useDateFieldAttributes(SupportedDateParts.MONTH);
|
|
53774
53817
|
const { partValue, partError, onPartChange } = useDatePart(SupportedDateParts.MONTH);
|
|
53775
53818
|
const { t } = useTranslation2();
|
|
53776
53819
|
const [isOpen, setIsOpen] = useState(false);
|
|
53820
|
+
const isForcedOpen = useIsForcedOpenDropdown(id6);
|
|
53777
53821
|
const [container, setContainer] = useState(null);
|
|
53778
53822
|
const placeholder = hidePlaceholder ? void 0 : t("field.date.placeholder.month");
|
|
53779
53823
|
const handleMonthChange = useCallback((selectedValue) => {
|
|
@@ -53810,9 +53854,11 @@ var Month = ({ children, className }) => {
|
|
|
53810
53854
|
isDisabled: disabled,
|
|
53811
53855
|
isInvalid: partError,
|
|
53812
53856
|
placeholder,
|
|
53813
|
-
isOpen,
|
|
53814
|
-
onOpenChange: handleOpenChange
|
|
53815
|
-
}, triggerElement, optionsElement
|
|
53857
|
+
isOpen: isForcedOpen || isOpen,
|
|
53858
|
+
onOpenChange: isForcedOpen ? void 0 : handleOpenChange
|
|
53859
|
+
}, triggerElement, applyInternalProps(optionsElement, {
|
|
53860
|
+
isForcedOpen
|
|
53861
|
+
}))));
|
|
53816
53862
|
};
|
|
53817
53863
|
var MonthLabel = ({ className }) => {
|
|
53818
53864
|
return /* @__PURE__ */ React172.createElement(DateLabel, {
|
|
@@ -53839,7 +53885,8 @@ var MonthTrigger = ({ children, className }) => {
|
|
|
53839
53885
|
"data-readonly": readOnly || void 0
|
|
53840
53886
|
}, /* @__PURE__ */ React172.createElement(SelectValue, null), children);
|
|
53841
53887
|
};
|
|
53842
|
-
var MonthOptions = ({ children, className }) => {
|
|
53888
|
+
var MonthOptions = ({ children, className, ...internal }) => {
|
|
53889
|
+
const { isForcedOpen } = internal;
|
|
53843
53890
|
const { language } = useConfig();
|
|
53844
53891
|
const months = useMemo(() => getMonthList(language), [
|
|
53845
53892
|
language
|
|
@@ -53849,7 +53896,9 @@ var MonthOptions = ({ children, className }) => {
|
|
|
53849
53896
|
className,
|
|
53850
53897
|
containerPadding: 0,
|
|
53851
53898
|
offset: 0
|
|
53852
|
-
}, /* @__PURE__ */ React172.createElement(ListBox,
|
|
53899
|
+
}, /* @__PURE__ */ React172.createElement(ListBox, {
|
|
53900
|
+
autoFocus: isForcedOpen ? false : void 0
|
|
53901
|
+
}, months.map((month, index2) => applyInternalProps(optionElement, {
|
|
53853
53902
|
key: String(index2 + 1),
|
|
53854
53903
|
value: String(index2 + 1),
|
|
53855
53904
|
label: month
|
|
@@ -54349,11 +54398,12 @@ var DateTimeInput = ({ children, className }) => {
|
|
|
54349
54398
|
});
|
|
54350
54399
|
};
|
|
54351
54400
|
var Month2 = ({ children, className }) => {
|
|
54352
|
-
const { disabled, readOnly, showDateLabels, hidePlaceholder } = useFieldPropsV2();
|
|
54401
|
+
const { id: id6, disabled, readOnly, showDateLabels, hidePlaceholder } = useFieldPropsV2();
|
|
54353
54402
|
const { labelId } = useDateTimeFieldAttributes(SupportedDateParts.MONTH);
|
|
54354
54403
|
const { partValue, partError, onPartChange } = useFieldPart(SupportedDateParts.MONTH);
|
|
54355
54404
|
const { t } = useTranslation2();
|
|
54356
54405
|
const [isOpen, setIsOpen] = useState(false);
|
|
54406
|
+
const isForcedOpen = useIsForcedOpenDropdown(id6);
|
|
54357
54407
|
const [container, setContainer] = useState(null);
|
|
54358
54408
|
const placeholder = hidePlaceholder ? void 0 : t("field.date.placeholder.month");
|
|
54359
54409
|
const handleMonthChange = useCallback((selectedValue) => {
|
|
@@ -54390,9 +54440,11 @@ var Month2 = ({ children, className }) => {
|
|
|
54390
54440
|
isDisabled: disabled,
|
|
54391
54441
|
isInvalid: partError,
|
|
54392
54442
|
placeholder,
|
|
54393
|
-
isOpen,
|
|
54394
|
-
onOpenChange: handleOpenChange
|
|
54395
|
-
}, triggerElement, optionsElement
|
|
54443
|
+
isOpen: isForcedOpen || isOpen,
|
|
54444
|
+
onOpenChange: isForcedOpen ? void 0 : handleOpenChange
|
|
54445
|
+
}, triggerElement, applyInternalProps(optionsElement, {
|
|
54446
|
+
isForcedOpen
|
|
54447
|
+
}))));
|
|
54396
54448
|
};
|
|
54397
54449
|
var MonthLabel2 = ({ className }) => {
|
|
54398
54450
|
return /* @__PURE__ */ React172.createElement(DateTimeLabel, {
|
|
@@ -54419,7 +54471,8 @@ var MonthTrigger3 = ({ children, className }) => {
|
|
|
54419
54471
|
"data-readonly": readOnly || void 0
|
|
54420
54472
|
}, /* @__PURE__ */ React172.createElement(SelectValue, null), children);
|
|
54421
54473
|
};
|
|
54422
|
-
var MonthOptions2 = ({ children, className }) => {
|
|
54474
|
+
var MonthOptions2 = ({ children, className, ...internal }) => {
|
|
54475
|
+
const { isForcedOpen } = internal;
|
|
54423
54476
|
const { language } = useConfig();
|
|
54424
54477
|
const months = useMemo(() => getMonthList(language), [
|
|
54425
54478
|
language
|
|
@@ -54429,7 +54482,9 @@ var MonthOptions2 = ({ children, className }) => {
|
|
|
54429
54482
|
className,
|
|
54430
54483
|
containerPadding: 0,
|
|
54431
54484
|
offset: 0
|
|
54432
|
-
}, /* @__PURE__ */ React172.createElement(ListBox,
|
|
54485
|
+
}, /* @__PURE__ */ React172.createElement(ListBox, {
|
|
54486
|
+
autoFocus: isForcedOpen ? false : void 0
|
|
54487
|
+
}, months.map((month, index2) => applyInternalProps(optionElement, {
|
|
54433
54488
|
key: String(index2 + 1),
|
|
54434
54489
|
value: String(index2 + 1),
|
|
54435
54490
|
label: month
|
|
@@ -55167,23 +55222,6 @@ Donation.Options = Options2;
|
|
|
55167
55222
|
Donation.OtherInput = OtherInput2;
|
|
55168
55223
|
Donation.Description = Description;
|
|
55169
55224
|
Donation.Error = Error2;
|
|
55170
|
-
var DROPDOWN_FIELD_TYPES = [
|
|
55171
|
-
FIELD_TYPES.DROPDOWN,
|
|
55172
|
-
FIELD_TYPES.DEXT_DROPDOWN,
|
|
55173
|
-
FIELD_TYPES.SERVICES_DROPDOWN
|
|
55174
|
-
];
|
|
55175
|
-
var isOpenableDropdown = ({ fieldType, properties }) => DROPDOWN_FIELD_TYPES.includes(fieldType) && !properties.hidden && !properties.disabled && !properties.readOnly;
|
|
55176
|
-
var byLayoutPosition = (first2, second) => first2.layout.row - second.layout.row || first2.layout.column - second.layout.column;
|
|
55177
|
-
var useIsForcedOpenDropdown = (fieldId) => {
|
|
55178
|
-
const isOpenState = useElementProps().dropdown?.open === true;
|
|
55179
|
-
const formView = useContext(FormViewContext);
|
|
55180
|
-
const firstDropdownId = useMemo(() => formView && !formView.parentId ? formView.fields.filter(isOpenableDropdown).sort(byLayoutPosition)[0]?.id : void 0, [
|
|
55181
|
-
formView
|
|
55182
|
-
]);
|
|
55183
|
-
return isOpenState && firstDropdownId === fieldId;
|
|
55184
|
-
};
|
|
55185
|
-
|
|
55186
|
-
// ../form-fields/dist/esm/ui/dropdown-field/dropdown-field-headless.js
|
|
55187
55225
|
var Dropdown = ({ children }) => {
|
|
55188
55226
|
const { id: id6, value, defaultValue, options = [], readOnly, onChange, placeholder, disabled, required, onBlur, onFocus, FieldLayout, hasError } = useFieldPropsV2();
|
|
55189
55227
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -57766,6 +57804,26 @@ City.Error = Error2;
|
|
|
57766
57804
|
|
|
57767
57805
|
// ../form-fields/dist/esm/ui/multiline-address-field/headless/country-field-headless.js
|
|
57768
57806
|
init_esm2();
|
|
57807
|
+
var KeepComboBoxOpen = ({ isOpen }) => {
|
|
57808
|
+
const state = useContext(ComboBoxStateContext);
|
|
57809
|
+
const wasOpen = useRef(false);
|
|
57810
|
+
useEffect(() => {
|
|
57811
|
+
if (isOpen && state && !state.isOpen) {
|
|
57812
|
+
state.open(null, "manual");
|
|
57813
|
+
}
|
|
57814
|
+
if (isOpen && state?.selectionManager.focusedKey != null) {
|
|
57815
|
+
state.selectionManager.setFocusedKey(null);
|
|
57816
|
+
}
|
|
57817
|
+
if (!isOpen && wasOpen.current) {
|
|
57818
|
+
state?.close();
|
|
57819
|
+
}
|
|
57820
|
+
wasOpen.current = isOpen;
|
|
57821
|
+
}, [
|
|
57822
|
+
isOpen,
|
|
57823
|
+
state
|
|
57824
|
+
]);
|
|
57825
|
+
return null;
|
|
57826
|
+
};
|
|
57769
57827
|
var useOpenOnClick = ({ readOnly, disabled } = {}) => {
|
|
57770
57828
|
const state = useContext(ComboBoxStateContext);
|
|
57771
57829
|
return useCallback(() => {
|
|
@@ -57851,7 +57909,8 @@ var useOptionComboBox = ({ options, value, commit, clear, onBlur }) => {
|
|
|
57851
57909
|
};
|
|
57852
57910
|
|
|
57853
57911
|
// ../form-fields/dist/esm/ui/multiline-address-field/headless/country-field-headless.js
|
|
57854
|
-
var Country = ({ children }) => {
|
|
57912
|
+
var Country = ({ children, ...internal }) => {
|
|
57913
|
+
const { isForcedOpen = false } = internal;
|
|
57855
57914
|
const { id: id6, value, onChange, disabled, readOnly, required, hasError, onBlur, onFocus, FieldLayout, options } = useFieldPropsV2();
|
|
57856
57915
|
const { labelId } = useFieldAttributes();
|
|
57857
57916
|
const { t } = useTranslation2();
|
|
@@ -57906,6 +57965,8 @@ var Country = ({ children }) => {
|
|
|
57906
57965
|
onKeyDown: onInputKeyDown
|
|
57907
57966
|
}), applyInternalProps(optionsElement, {
|
|
57908
57967
|
options: countryOptions
|
|
57968
|
+
}), /* @__PURE__ */ React172.createElement(KeepComboBoxOpen, {
|
|
57969
|
+
isOpen: isForcedOpen
|
|
57909
57970
|
})),
|
|
57910
57971
|
renderDescription: () => /* @__PURE__ */ React172.createElement(React172.Fragment, null, errorElement, descriptionElement)
|
|
57911
57972
|
});
|
|
@@ -58688,7 +58749,10 @@ var MultilineAddress = ({ children }) => {
|
|
|
58688
58749
|
const field = form?.fields?.find((f) => "target" in f && f.target === firstError?.errorPath);
|
|
58689
58750
|
return field?.id;
|
|
58690
58751
|
});
|
|
58691
|
-
const
|
|
58752
|
+
const isForcedOpen = useIsForcedOpenDropdown(id6);
|
|
58753
|
+
const countryElement = applyInternalProps(findChildOfType(children, MultilineAddress.Country), {
|
|
58754
|
+
isForcedOpen
|
|
58755
|
+
});
|
|
58692
58756
|
const subdivisionElement = findChildOfType(children, MultilineAddress.Subdivision);
|
|
58693
58757
|
const cityElement = findChildOfType(children, MultilineAddress.City);
|
|
58694
58758
|
const addressLineElement = findChildOfType(children, MultilineAddress.AddressLine);
|
|
@@ -59210,10 +59274,12 @@ var CountryButtonEmptyState = ({ children, className }) => {
|
|
|
59210
59274
|
CountryButton.Flag = CountryButtonFlag;
|
|
59211
59275
|
CountryButton.EmptyState = CountryButtonEmptyState;
|
|
59212
59276
|
var CountryOptions = ({ children, className, "aria-label": ariaLabel, placement, offset, ...internal }) => {
|
|
59213
|
-
const { triggerRef, optionsRef } = internal;
|
|
59277
|
+
const { triggerRef, optionsRef, isForcedOpen } = internal;
|
|
59214
59278
|
const { popoverContainer } = usePhoneInputContext();
|
|
59215
59279
|
const searchElement = findChildOfType(children, CountryOptions.Search);
|
|
59216
|
-
const content = /* @__PURE__ */ React172.createElement(CountryOptionsContent,
|
|
59280
|
+
const content = /* @__PURE__ */ React172.createElement(CountryOptionsContent, {
|
|
59281
|
+
isForcedOpen
|
|
59282
|
+
}, children);
|
|
59217
59283
|
return /* @__PURE__ */ React172.createElement($72abaeab4d80592f$export$78efe591171d7d45, {
|
|
59218
59284
|
getContainer: () => popoverContainer
|
|
59219
59285
|
}, /* @__PURE__ */ React172.createElement(NonModalPopover, {
|
|
@@ -59223,7 +59289,7 @@ var CountryOptions = ({ children, className, "aria-label": ariaLabel, placement,
|
|
|
59223
59289
|
placement,
|
|
59224
59290
|
offset,
|
|
59225
59291
|
containerPadding: 0
|
|
59226
|
-
}, searchElement ? /* @__PURE__ */ React172.createElement(Dialog, {
|
|
59292
|
+
}, searchElement && !isForcedOpen ? /* @__PURE__ */ React172.createElement(Dialog, {
|
|
59227
59293
|
"aria-label": ariaLabel
|
|
59228
59294
|
}, content) : content));
|
|
59229
59295
|
};
|
|
@@ -59253,7 +59319,7 @@ var CountryOptionsModal = ({ children, className, overlayClassName, "aria-label"
|
|
|
59253
59319
|
}
|
|
59254
59320
|
}, children)))));
|
|
59255
59321
|
};
|
|
59256
|
-
var CountryOptionsContent = ({ children, listBoxProps }) => {
|
|
59322
|
+
var CountryOptionsContent = ({ children, listBoxProps, isForcedOpen }) => {
|
|
59257
59323
|
const { countries } = usePhoneInputContext();
|
|
59258
59324
|
const optionElement = findChildOfType(children, CountryOptions.Option);
|
|
59259
59325
|
const searchElement = findChildOfType(children, CountryOptions.Search);
|
|
@@ -59276,16 +59342,20 @@ var CountryOptionsContent = ({ children, listBoxProps }) => {
|
|
|
59276
59342
|
const country = countries.find((item) => item.shortCountryCode === node.key);
|
|
59277
59343
|
return !!country && isCountryMatching(country, query);
|
|
59278
59344
|
}
|
|
59279
|
-
}, searchElement,
|
|
59345
|
+
}, isForcedOpen ? applyInternalProps(searchElement, {
|
|
59346
|
+
autoFocus: false
|
|
59347
|
+
}) : searchElement, listbox) : listbox;
|
|
59280
59348
|
};
|
|
59281
59349
|
CountryOptions.Popover = CountryOptions;
|
|
59282
59350
|
CountryOptions.Modal = CountryOptionsModal;
|
|
59283
|
-
var CountrySearch = ({ className, children, "aria-label": ariaLabel }) => {
|
|
59351
|
+
var CountrySearch = ({ className, children, "aria-label": ariaLabel, ...internal }) => {
|
|
59352
|
+
const { autoFocus = true } = internal;
|
|
59284
59353
|
return /* @__PURE__ */ React172.createElement(SearchField, {
|
|
59285
|
-
className,
|
|
59286
59354
|
"aria-label": ariaLabel,
|
|
59287
|
-
autoFocus
|
|
59288
|
-
},
|
|
59355
|
+
autoFocus
|
|
59356
|
+
}, /* @__PURE__ */ React172.createElement(Group, {
|
|
59357
|
+
className
|
|
59358
|
+
}, children));
|
|
59289
59359
|
};
|
|
59290
59360
|
var CountrySearchInput = ({ className, placeholder }) => /* @__PURE__ */ React172.createElement(Input, {
|
|
59291
59361
|
className,
|
|
@@ -59368,7 +59438,8 @@ var Control7 = ({ children, className }) => {
|
|
|
59368
59438
|
const controlRef = useRef(null);
|
|
59369
59439
|
const optionsRef = useRef(null);
|
|
59370
59440
|
const isFocused = useRef(false);
|
|
59371
|
-
const { disabled, readOnly, required, hasError, showFlag, onFocus, onBlur } = useFieldPropsV2();
|
|
59441
|
+
const { id: id6, disabled, readOnly, required, hasError, showFlag, onFocus, onBlur } = useFieldPropsV2();
|
|
59442
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
59372
59443
|
const invokeBlur = useInvokeCallback(onBlur);
|
|
59373
59444
|
const { t } = useTranslation2();
|
|
59374
59445
|
const { selectedCountryCode, handleCountryCodeChange, countries } = usePhoneInputContext();
|
|
@@ -59376,6 +59447,11 @@ var Control7 = ({ children, className }) => {
|
|
|
59376
59447
|
const modalElement = findChildOfType(children, PhoneInput.CountryOptions.Modal);
|
|
59377
59448
|
const countryOptionsElement = modalElement ?? findChildOfType(children, PhoneInput.CountryOptions.Popover);
|
|
59378
59449
|
const phoneNumberElement = findChildOfType(children, PhoneInput.PhoneNumber);
|
|
59450
|
+
const hasCountryOptions2 = countries.length > 1;
|
|
59451
|
+
const isForcedOpen = useIsForcedOpenDropdown(id6) && !modalElement && hasCountryOptions2;
|
|
59452
|
+
const controlClassName = typeof className === "function" ? className({
|
|
59453
|
+
hasCountryOptions: hasCountryOptions2
|
|
59454
|
+
}) : className;
|
|
59379
59455
|
const focusHandlers = {
|
|
59380
59456
|
onFocus: () => {
|
|
59381
59457
|
if (!isFocused.current) {
|
|
@@ -59394,7 +59470,7 @@ var Control7 = ({ children, className }) => {
|
|
|
59394
59470
|
if (countries.length === 1) {
|
|
59395
59471
|
return /* @__PURE__ */ React172.createElement(Group, {
|
|
59396
59472
|
ref: controlRef,
|
|
59397
|
-
className,
|
|
59473
|
+
className: controlClassName,
|
|
59398
59474
|
isDisabled: disabled,
|
|
59399
59475
|
isInvalid: hasError,
|
|
59400
59476
|
...focusHandlers
|
|
@@ -59404,11 +59480,12 @@ var Control7 = ({ children, className }) => {
|
|
|
59404
59480
|
}
|
|
59405
59481
|
const selector = /* @__PURE__ */ React172.createElement(React172.Fragment, null, countryButtonElement, applyInternalProps(countryOptionsElement, {
|
|
59406
59482
|
triggerRef: controlRef,
|
|
59407
|
-
optionsRef
|
|
59483
|
+
optionsRef,
|
|
59484
|
+
isForcedOpen
|
|
59408
59485
|
}));
|
|
59409
59486
|
return /* @__PURE__ */ React172.createElement(Group, {
|
|
59410
59487
|
ref: controlRef,
|
|
59411
|
-
className,
|
|
59488
|
+
className: controlClassName,
|
|
59412
59489
|
isDisabled: disabled,
|
|
59413
59490
|
isInvalid: hasError,
|
|
59414
59491
|
...focusHandlers
|
|
@@ -59419,7 +59496,9 @@ var Control7 = ({ children, className }) => {
|
|
|
59419
59496
|
isDisabled: disabled || readOnly,
|
|
59420
59497
|
isInvalid: hasError,
|
|
59421
59498
|
isRequired: required,
|
|
59422
|
-
placeholder: ""
|
|
59499
|
+
placeholder: "",
|
|
59500
|
+
isOpen: isForcedOpen || isOpen && !disabled && !readOnly,
|
|
59501
|
+
onOpenChange: isForcedOpen ? void 0 : setIsOpen
|
|
59423
59502
|
}, selector), phoneNumberElement);
|
|
59424
59503
|
};
|
|
59425
59504
|
PhoneInput.Label = Label;
|