@dynamic-framework/ui-react 1.35.0 → 1.36.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.
Files changed (36) hide show
  1. package/dist/css/dynamic-ui-non-root.css +377 -86
  2. package/dist/css/dynamic-ui-non-root.min.css +2 -2
  3. package/dist/css/dynamic-ui-root.css +4 -1
  4. package/dist/css/dynamic-ui-root.min.css +2 -2
  5. package/dist/css/dynamic-ui.css +380 -86
  6. package/dist/css/dynamic-ui.min.css +2 -2
  7. package/dist/index.esm.js +125 -19
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js +126 -18
  10. package/dist/index.js.map +1 -1
  11. package/dist/types/components/DBoxFile/useDBoxFile.d.ts +1 -1
  12. package/dist/types/components/DDatePicker/DDatePicker.d.ts +4 -3
  13. package/dist/types/components/DDatePicker/components/DDatePickerHeaderSelector.d.ts +3 -1
  14. package/dist/types/components/DDatePicker/components/DDatePickerTime.d.ts +5 -7
  15. package/dist/types/components/DInputPhone/DInputPhone.d.ts +26 -0
  16. package/dist/types/components/DInputPhone/index.d.ts +2 -0
  17. package/dist/types/components/DSelect/DSelect.d.ts +2 -1
  18. package/dist/types/components/index.d.ts +1 -0
  19. package/dist/types/utils/index.d.ts +1 -0
  20. package/dist/types/utils/validatePhoneNumber.d.ts +1 -0
  21. package/jest/setup.js +15 -2
  22. package/package.json +9 -3
  23. package/src/style/abstracts/_utilities.scss +11 -1
  24. package/src/style/abstracts/variables/_+import.scss +2 -1
  25. package/src/style/abstracts/variables/_datepicker.scss +5 -8
  26. package/src/style/abstracts/variables/_input-phone.scss +62 -0
  27. package/src/style/abstracts/variables/_navs.scss +3 -1
  28. package/src/style/abstracts/variables/_typography.scss +2 -0
  29. package/src/style/base/_form-switch.scss +1 -1
  30. package/src/style/base/_nav.scss +9 -13
  31. package/src/style/components/_+import.scss +1 -0
  32. package/src/style/components/_d-datepicker.scss +84 -153
  33. package/src/style/components/_d-input-phone.scss +286 -0
  34. package/src/style/components/_d-select.scss +22 -2
  35. package/src/style/components/_d-timepicker.scss +43 -29
  36. package/src/style/root/_root.scss +4 -0
package/dist/index.esm.js CHANGED
@@ -8,13 +8,14 @@ import { SplideSlide, Splide } from '@splidejs/react-splide';
8
8
  import currency from 'currency.js';
9
9
  import DatePicker from 'react-datepicker';
10
10
  import { getYear, format, getMonth } from 'date-fns';
11
- import { enUS } from 'date-fns/locale';
12
11
  import Select, { components } from 'react-select';
13
12
  import { InputMask } from '@react-input/mask';
14
13
  import ResponsivePagination from 'react-responsive-pagination';
15
14
  import { useFloating, autoUpdate, offset, flip, shift, useClick, useDismiss, useRole, useInteractions, useId as useId$1, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
16
15
  import ContentLoader from 'react-content-loader';
17
16
  import { Toaster, toast } from 'react-hot-toast';
17
+ import { defaultCountries, parseCountry, usePhoneInput, CountrySelector } from 'react-international-phone';
18
+ import { PhoneNumberUtil } from 'google-libphonenumber';
18
19
  import i18n from 'i18next';
19
20
  import { initReactI18next } from 'react-i18next';
20
21
 
@@ -621,7 +622,7 @@ const DEFAULT_PROPS = {
621
622
 
622
623
  /* eslint-disable no-param-reassign */
623
624
  function useDBoxFile(props) {
624
- const { accept, autoFocus, disabled, maxSize, minSize, multiple, maxFiles, value: preloadUrls, onDragEnter, onDragLeave, onDrop, onError, noClick, noKeyboard, noDrag, } = Object.assign(Object.assign({}, DEFAULT_PROPS), props);
625
+ const { accept, autoFocus, disabled, maxSize, minSize, multiple, maxFiles, value: preloadUrls, onDragEnter, onDragLeave, onDrop, onError, onLoad, noClick, noKeyboard, noDrag, } = Object.assign(Object.assign({}, DEFAULT_PROPS), props);
625
626
  const inputRef = useRef(null);
626
627
  const rootRef = useRef(null);
627
628
  const dragTargetsRef = useRef([]);
@@ -661,12 +662,17 @@ function useDBoxFile(props) {
661
662
  const [accepted, errors] = await urlsToFiles(preloadUrls);
662
663
  if (accepted.length) {
663
664
  setFiles(accepted);
665
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(accepted);
664
666
  }
665
667
  if (errors.length) {
666
668
  onError === null || onError === void 0 ? void 0 : onError(new Error(errors.map((e) => e.message).join(', ')));
667
669
  }
668
670
  })();
669
- }, [preloadUrls, onError]);
671
+ }, [
672
+ preloadUrls,
673
+ onError,
674
+ onLoad,
675
+ ]);
670
676
  const processFiles = useCallback((inputFiles, event) => {
671
677
  let acceptedFiles = [];
672
678
  let rejectedFiles = [];
@@ -710,7 +716,7 @@ function useDBoxFile(props) {
710
716
  }
711
717
  }, [
712
718
  acceptAttr,
713
- files.length,
719
+ files,
714
720
  maxFiles,
715
721
  maxSize,
716
722
  minSize,
@@ -800,7 +806,9 @@ function useDBoxFile(props) {
800
806
  }, [processFiles]);
801
807
  const handleRemoveFile = useCallback((index) => {
802
808
  setFiles((prevFiles) => prevFiles.filter((_, i) => i !== index));
803
- }, []);
809
+ // Done twice to avoid mismatch between files and setFiles value
810
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(files.filter((_, i) => i !== index));
811
+ }, [files, onLoad]);
804
812
  const openFileDialog = useCallback(() => {
805
813
  var _a;
806
814
  if (disabled)
@@ -854,7 +862,7 @@ function DBoxFile(_a) {
854
862
  'd-box-file-invalid': isDragInvalid,
855
863
  }, className), style: style }, dataAttributes, { children: jsxs("div", Object.assign({ className: "d-box-file-dropzone", ref: rootRef, onDragEnter: handleDragEnter, onDragOver: (e) => e.preventDefault(), onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleClick, onKeyDown: handleKeyDown }, (!props.disabled && !props.noKeyboard ? { tabIndex: 0 } : {}), { role: "presentation", children: [jsx("input", { type: "file", multiple: props.multiple, style: { display: 'none' }, ref: inputRef, disabled: props.disabled, onChange: handleFileSelect, onClick: (e) => e.stopPropagation(), tabIndex: -1, accept: acceptAttr }), jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }), jsx("div", { className: "d-box-content", children: typeof children === 'function'
856
864
  ? children(openFileDialog)
857
- : children })] })) })), !!files.length && (jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsx(ForwardedDInput, { value: file.name, iconStart: "paperclip", iconEnd: "trash", readOnly: true, onIconEndClick: () => handleRemoveFile(index) }, file.name))) }))] }));
865
+ : children })] })) })), !!files.length && (jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsx(ForwardedDInput, { value: file.name, iconStart: "paperclip", iconEnd: "trash", readOnly: true, onIconEndClick: () => handleRemoveFile(index) }, `${file.name} ${index}`))) }))] }));
858
866
  }
859
867
 
860
868
  function DButton({ theme = 'primary', size, variant, state, text = '', ariaLabel, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartMaterialStyle, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndMaterialStyle, value, type = 'button', loading = false, loadingAriaLabel, disabled = false, stopPropagationEnabled = true, className, style, form, dataAttributes, onClick, }) {
@@ -995,11 +1003,10 @@ function DCurrencyText({ value, className, style, dataAttributes, }) {
995
1003
  return (jsx("span", Object.assign({ className: className, style: style }, dataAttributes, { children: valueFormatted })));
996
1004
  }
997
1005
 
998
- function DDatePickerTime(_a) {
999
- var { value, onChange, id, label, className, style } = _a, props = __rest(_a, ["value", "onChange", "id", "label", "className", "style"]);
1000
- return (jsxs("div", { className: classNames('d-flex align-items-center gap-2 flex-column d-datepicker-time', className), style: style, children: [label && (jsx("label", { htmlFor: id, className: "d-datepicker-time-label", children: label })), jsx(ForwardedDInput, Object.assign({ className: "w-100" }, onChange && {
1001
- onChange,
1002
- }, { type: "time", id: id, value: value }, props))] }));
1006
+ function DDatePickerTime({ value, onChange, id, }) {
1007
+ return (jsx(ForwardedDInput, { className: "d-datepicker-time", type: "time", value: value, id: id, onChange: (time) => {
1008
+ onChange === null || onChange === void 0 ? void 0 : onChange(time);
1009
+ } }));
1003
1010
  }
1004
1011
 
1005
1012
  function DDatePickerInput(_a, ref) {
@@ -1136,7 +1143,7 @@ function DSelectPlaceholder(_a) {
1136
1143
  }
1137
1144
 
1138
1145
  function DSelect(_a) {
1139
- var { id: idProp, className, style, label, labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, hint, iconFamilyClass, iconFamilyPrefix, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, invalid, valid, menuWithMaxContent = false, disabled, clearable, loading, rtl, searchable, multi, components, defaultValue, placeholder, onIconStartClick, onIconEndClick, dataAttributes } = _a, props = __rest(_a, ["id", "className", "style", "label", "labelIcon", "labelIconFamilyClass", "labelIconFamilyPrefix", "hint", "iconFamilyClass", "iconFamilyPrefix", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "invalid", "valid", "menuWithMaxContent", "disabled", "clearable", "loading", "rtl", "searchable", "multi", "components", "defaultValue", "placeholder", "onIconStartClick", "onIconEndClick", "dataAttributes"]);
1146
+ var { id: idProp, className, style, label, labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, hint, iconFamilyClass, iconFamilyPrefix, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, invalid, valid, menuWithMaxContent = false, disabled, clearable, loading, floatingLabel = false, rtl, searchable, multi, components, defaultValue, placeholder, onIconStartClick, onIconEndClick, dataAttributes } = _a, props = __rest(_a, ["id", "className", "style", "label", "labelIcon", "labelIconFamilyClass", "labelIconFamilyPrefix", "hint", "iconFamilyClass", "iconFamilyPrefix", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "invalid", "valid", "menuWithMaxContent", "disabled", "clearable", "loading", "floatingLabel", "rtl", "searchable", "multi", "components", "defaultValue", "placeholder", "onIconStartClick", "onIconEndClick", "dataAttributes"]);
1140
1147
  const innerId = useId();
1141
1148
  const id = useMemo(() => idProp || innerId, [idProp, innerId]);
1142
1149
  const handleOnIconStartClick = useCallback(() => {
@@ -1146,6 +1153,7 @@ function DSelect(_a) {
1146
1153
  onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(defaultValue);
1147
1154
  }, [onIconEndClick, defaultValue]);
1148
1155
  return (jsxs("div", Object.assign({ className: classNames('d-select', className, {
1156
+ 'd-select-floating': floatingLabel,
1149
1157
  disabled: disabled || loading,
1150
1158
  }), style: style }, dataAttributes, { children: [label && (jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsx(DIcon, { icon: labelIcon, size: `var(--${PREFIX_BS}input-label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix }))] })), jsxs("div", { className: classNames({
1151
1159
  'input-group': true,
@@ -1158,7 +1166,7 @@ function DSelect(_a) {
1158
1166
  }, className: classNames('d-select-component', {
1159
1167
  'is-invalid': invalid,
1160
1168
  'is-valid': valid,
1161
- }), classNamePrefix: "d-select", isDisabled: disabled || loading, isClearable: clearable, isLoading: loading, isRtl: rtl, isSearchable: searchable, isMulti: multi, defaultValue: defaultValue, placeholder: placeholder, unstyled: true, components: Object.assign({ Placeholder: DSelectPlaceholder, DropdownIndicator: DSelectDropdownIndicator, ClearIndicator: DSelectClearIndicator, MultiValueRemove: DSelectMultiValueRemove, LoadingIndicator: DSelectLoadingIndicator }, components) }, props)), (iconEnd && !loading) && (jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading, "aria-label": iconEndAriaLabel, tabIndex: iconEndTabIndex, children: iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) }))] }), hint && (jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
1169
+ }), classNamePrefix: "d-select", isDisabled: disabled || loading, isClearable: clearable, isLoading: loading, isRtl: rtl, isSearchable: searchable, isMulti: multi, defaultValue: defaultValue, placeholder: floatingLabel ? '' : placeholder, unstyled: true, components: Object.assign({ Placeholder: DSelectPlaceholder, DropdownIndicator: DSelectDropdownIndicator, ClearIndicator: DSelectClearIndicator, MultiValueRemove: DSelectMultiValueRemove, LoadingIndicator: DSelectLoadingIndicator }, components) }, props)), (iconEnd && !loading) && (jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading, "aria-label": iconEndAriaLabel, tabIndex: iconEndTabIndex, children: iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) }))] }), hint && (jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
1162
1170
  }
1163
1171
  var DSelect$1 = Object.assign(DSelect, {
1164
1172
  OptionCheck: DSelectOptionCheck,
@@ -1181,7 +1189,7 @@ var PickerType;
1181
1189
  PickerType["Month"] = "month";
1182
1190
  PickerType["Year"] = "year";
1183
1191
  })(PickerType || (PickerType = {}));
1184
- function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, decreaseYear, increaseYear, monthDate, pickerType, prevMonthButtonDisabled, nextMonthButtonDisabled, monthsShown = 1, iconPrev, iconNext, prevYearButtonDisabled, nextYearButtonDisabled, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle = false, prevMonthAriaLabel = 'decrease month', nextMonthAriaLabel = 'increase month', prevYearAriaLabel = 'decrease year', nextYearAriaLabel = 'increase year', iconSize = 'sm', buttonVariant = 'link', buttonTheme = 'dark', style, className, minYearSelect = 1900, maxYearSelect = 2100, showHeaderSelectors = false, customHeaderCount, }) {
1192
+ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, decreaseYear, increaseYear, monthDate, pickerType, prevMonthButtonDisabled, nextMonthButtonDisabled, monthsShown = 1, iconPrev, iconNext, prevYearButtonDisabled, nextYearButtonDisabled, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle = false, prevMonthAriaLabel = 'decrease month', nextMonthAriaLabel = 'increase month', prevYearAriaLabel = 'decrease year', nextYearAriaLabel = 'increase year', iconSize, buttonVariant = 'link', buttonTheme = 'dark', style, className, minYearSelect = 1900, maxYearSelect = 2100, showHeaderSelectors = false, customHeaderCount, locale, }) {
1185
1193
  const { iconMap: { chevronLeft, chevronRight, }, } = useDContext();
1186
1194
  const arrayYears = useMemo(() => Array.from({ length: maxYearSelect - minYearSelect + 1 }, (_, index) => minYearSelect + index), [maxYearSelect, minYearSelect]);
1187
1195
  const years = useMemo(() => arrayYears.map((year) => ({
@@ -1189,7 +1197,7 @@ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMont
1189
1197
  value: year,
1190
1198
  })), [arrayYears]);
1191
1199
  const defaultYear = useMemo(() => years.find((year) => year.value === getYear(monthDate)), [monthDate, years]);
1192
- const arrayMonths = useMemo(() => Array.from({ length: 12 }, (_, i) => format(new Date(2000, i), 'LLLL', { locale: enUS })), []);
1200
+ const arrayMonths = useMemo(() => Array.from({ length: 12 }, (_, i) => format(new Date(2000, i), 'LLLL', { locale })), [locale]);
1193
1201
  const months = useMemo(() => arrayMonths.map((month, i) => ({
1194
1202
  label: month,
1195
1203
  value: i,
@@ -1215,7 +1223,7 @@ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMont
1215
1223
  }
1216
1224
 
1217
1225
  function DDatePicker(_a) {
1218
- var { inputLabel, inputHint, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeLabel, iconInput, iconHeaderPrev, iconHeaderNext, iconMaterialStyle, iconFamilyClass, iconFamilyPrefix, minYearSelect, maxYearSelect, iconHeaderSize, headerPrevMonthAriaLabel, headerNextMonthAriaLabel, headerButtonVariant, headerButtonTheme, invalid = false, valid = false, renderCustomHeader: renderCustomHeaderProp, className, dateFormatCalendar: dateFormatCalendarProp, style, dataAttributes, placeholder, showHeaderSelectors } = _a, props = __rest(_a, ["inputLabel", "inputHint", "inputAriaLabel", "inputActionAriaLabel", "inputId", "timeId", "timeLabel", "iconInput", "iconHeaderPrev", "iconHeaderNext", "iconMaterialStyle", "iconFamilyClass", "iconFamilyPrefix", "minYearSelect", "maxYearSelect", "iconHeaderSize", "headerPrevMonthAriaLabel", "headerNextMonthAriaLabel", "headerButtonVariant", "headerButtonTheme", "invalid", "valid", "renderCustomHeader", "className", "dateFormatCalendar", "style", "dataAttributes", "placeholder", "showHeaderSelectors"]);
1226
+ var { inputLabel, inputHint, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeInputLabel, iconInput, iconHeaderPrev, iconHeaderNext, iconMaterialStyle, iconFamilyClass, iconFamilyPrefix, minYearSelect, maxYearSelect, iconHeaderSize, headerPrevMonthAriaLabel, headerNextMonthAriaLabel, headerButtonVariant, headerButtonTheme, invalid = false, valid = false, renderCustomHeader: renderCustomHeaderProp, className, dateFormatCalendar: dateFormatCalendarProp, style, dataAttributes, placeholder, showHeaderSelectors } = _a, props = __rest(_a, ["inputLabel", "inputHint", "inputAriaLabel", "inputActionAriaLabel", "inputId", "timeId", "timeInputLabel", "iconInput", "iconHeaderPrev", "iconHeaderNext", "iconMaterialStyle", "iconFamilyClass", "iconFamilyPrefix", "minYearSelect", "maxYearSelect", "iconHeaderSize", "headerPrevMonthAriaLabel", "headerNextMonthAriaLabel", "headerButtonVariant", "headerButtonTheme", "invalid", "valid", "renderCustomHeader", "className", "dateFormatCalendar", "style", "dataAttributes", "placeholder", "showHeaderSelectors"]);
1219
1227
  const pickerType = useMemo(() => {
1220
1228
  if (props.showQuarterYearPicker)
1221
1229
  return PickerType.Quarter;
@@ -1229,7 +1237,7 @@ function DDatePicker(_a) {
1229
1237
  props.showMonthYearPicker,
1230
1238
  props.showYearPicker,
1231
1239
  ]);
1232
- const DatePickerHeader = useCallback((headerProps) => (jsx(DDatePickerHeaderSelector, Object.assign({}, headerProps, { monthsShown: props.monthsShown, iconPrev: iconHeaderPrev, iconNext: iconHeaderNext, iconMaterialStyle: iconMaterialStyle, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: iconHeaderSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, minYearSelect: minYearSelect, maxYearSelect: maxYearSelect, pickerType: pickerType, showHeaderSelectors: showHeaderSelectors }))), [
1240
+ const DatePickerHeader = useCallback((headerProps) => (jsx(DDatePickerHeaderSelector, Object.assign({}, headerProps, { monthsShown: props.monthsShown, iconPrev: iconHeaderPrev, iconNext: iconHeaderNext, iconMaterialStyle: iconMaterialStyle, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: iconHeaderSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, minYearSelect: minYearSelect, maxYearSelect: maxYearSelect, pickerType: pickerType, showHeaderSelectors: showHeaderSelectors, locale: props.locale }))), [
1233
1241
  iconHeaderNext,
1234
1242
  iconHeaderPrev,
1235
1243
  iconMaterialStyle,
@@ -1243,10 +1251,11 @@ function DDatePicker(_a) {
1243
1251
  pickerType,
1244
1252
  showHeaderSelectors,
1245
1253
  props.monthsShown,
1254
+ props.locale,
1246
1255
  ]);
1247
1256
  const defaultRenderCustomHeader = useCallback((headerProps) => (jsx(DatePickerHeader, Object.assign({}, headerProps))), [DatePickerHeader]);
1248
1257
  const renderCustomHeader = useMemo(() => (renderCustomHeaderProp || defaultRenderCustomHeader), [defaultRenderCustomHeader, renderCustomHeaderProp]);
1249
- return (jsx(DatePicker, Object.assign({ calendarClassName: "d-date-picker", renderCustomHeader: renderCustomHeader, customInput: (jsx(ForwardedDDatePickerInput, { id: inputId, "aria-label": inputAriaLabel, iconEndAriaLabel: inputActionAriaLabel, iconMaterialStyle: iconMaterialStyle, iconEnd: iconInput, inputLabel: inputLabel, className: className, style: style, invalid: invalid, valid: valid, hint: inputHint })), customTimeInput: (jsx(DDatePickerTime, { id: timeId, label: timeLabel })), placeholderText: placeholder }, dataAttributes, props)));
1258
+ return (jsx(DatePicker, Object.assign({}, dataAttributes, props, { calendarClassName: "d-date-picker", renderCustomHeader: renderCustomHeader, placeholderText: placeholder, customInput: (jsx(ForwardedDDatePickerInput, { id: inputId, "aria-label": inputAriaLabel, iconEndAriaLabel: inputActionAriaLabel, iconMaterialStyle: iconMaterialStyle, iconEnd: iconInput, inputLabel: inputLabel, className: className, style: style, invalid: invalid, valid: valid, hint: inputHint })), customTimeInput: (jsx(DDatePickerTime, { id: timeId })) })));
1250
1259
  }
1251
1260
 
1252
1261
  function DInputMask(props, ref) {
@@ -2248,5 +2257,102 @@ function changeQueryString(values, { useSearch = true, pushState = false, } = {}
2248
2257
  return searchParams.toString();
2249
2258
  }
2250
2259
 
2251
- export { DAlert, DAvatar, DBadge, DBoxFile, DButton, DButtonIcon, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCurrencyText, DDatePicker, DIcon, DIconBase, ForwardedDInput as DInput, DInputCheck, ForwardedDInputCounter as DInputCounter, ForwardedDInputCurrencyBase as DInputCurrency, ForwardedDInputCurrencyBase$1 as DInputCurrencyBase, ForwardedDInputMask as DInputMask, ForwardedDInputPassword as DInputPassword, DInputPin, ForwardedDInputRange as DInputRange, ForwardedDInputSearch as DInputSearch, DInputSelect, DInputSwitch, DList$1 as DList, DListGroup$1 as DListGroup, DListGroupItem, DListItem, DModal$1 as DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPopover, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSelect$1 as DSelect, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTableHead, DTabs$1 as DTabs, DToast$1 as DToast, DToastContainer, DTooltip, changeQueryString, checkMediaQuery, configureI8n as configureI18n, formatCurrency, getCssVariable, getQueryString, subscribeToMediaQuery, useDContext, useDPortalContext, useDToast, useDisableBodyScrollEffect, useDisableInputWheel, useFormatCurrency, useInputCurrency, useItemSelection, useMediaBreakpointUpLg, useMediaBreakpointUpMd, useMediaBreakpointUpSm, useMediaBreakpointUpXl, useMediaBreakpointUpXs, useMediaBreakpointUpXxl, useMediaQuery, usePortal, useProvidedRefOrCreate, useStackState, useTabContext };
2260
+ const phoneUtil = PhoneNumberUtil.getInstance();
2261
+ function validatePhoneNumber(phone) {
2262
+ try {
2263
+ return phoneUtil.isValidNumber(phoneUtil.parseAndKeepRawInput(phone));
2264
+ }
2265
+ catch (error) {
2266
+ return false;
2267
+ }
2268
+ }
2269
+
2270
+ function DInputPhone(_a, ref) {
2271
+ var { id: idProp, style, className, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, labelIconMaterialStyle, disabled = false, loading = false, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, iconEnd, iconEndDisabled, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, iconEndMaterialStyle, hint, size, invalid = false, valid = false, floatingLabel = false, inputEnd, value, placeholder = '', dataAttributes, onChange, onIconEndClick, countrySelectorProps, filteredCountries, defaultCountry = 'cl' } = _a, inputProps = __rest(_a, ["id", "style", "className", "label", "labelIcon", "labelIconFamilyClass", "labelIconFamilyPrefix", "labelIconMaterialStyle", "disabled", "loading", "iconFamilyClass", "iconFamilyPrefix", "iconMaterialStyle", "iconEnd", "iconEndDisabled", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "iconEndMaterialStyle", "hint", "size", "invalid", "valid", "floatingLabel", "inputEnd", "value", "placeholder", "dataAttributes", "onChange", "onIconEndClick", "countrySelectorProps", "filteredCountries", "defaultCountry"]);
2272
+ const innerRef = useProvidedRefOrCreate(ref);
2273
+ const innerId = useId();
2274
+ const id = useMemo(() => idProp || innerId, [idProp, innerId]);
2275
+ const handleOnIconEndClick = useCallback(() => {
2276
+ onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(value);
2277
+ }, [onIconEndClick, value]);
2278
+ const ariaDescribedby = useMemo(() => ([
2279
+ (invalid || valid) && !iconEnd && !loading && `${id}State`,
2280
+ (iconEnd && !loading) && `${id}End`,
2281
+ loading && `${id}Loading`,
2282
+ !!inputEnd && `${id}InputEnd`,
2283
+ !!hint && `${id}Hint`,
2284
+ ]
2285
+ .filter(Boolean)
2286
+ .join(' ')), [
2287
+ id,
2288
+ invalid,
2289
+ valid,
2290
+ iconEnd,
2291
+ loading,
2292
+ inputEnd,
2293
+ hint,
2294
+ ]);
2295
+ const countries = useMemo(() => {
2296
+ if (filteredCountries === undefined) {
2297
+ return defaultCountries;
2298
+ }
2299
+ return defaultCountries.filter((country) => {
2300
+ const { iso2 } = parseCountry(country);
2301
+ return filteredCountries.includes(iso2);
2302
+ });
2303
+ }, [filteredCountries]);
2304
+ const { inputValue, handlePhoneValueChange, inputRef, country, setCountry, } = usePhoneInput({
2305
+ inputRef: innerRef,
2306
+ defaultCountry,
2307
+ value,
2308
+ countries,
2309
+ onChange: (data) => {
2310
+ onChange === null || onChange === void 0 ? void 0 : onChange(Object.assign(Object.assign({}, data), { isValid: validatePhoneNumber(data.phone) }));
2311
+ },
2312
+ });
2313
+ const inputComponent = useMemo(() => (jsx("input", Object.assign({ ref: inputRef, id: id, className: classNames('form-control', {
2314
+ 'is-invalid': invalid,
2315
+ 'is-valid': valid,
2316
+ }), disabled: disabled || loading, value: inputValue, onChange: handlePhoneValueChange, inputMode: "tel" }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
2317
+ ariaDescribedby,
2318
+ disabled,
2319
+ floatingLabel,
2320
+ handlePhoneValueChange,
2321
+ id,
2322
+ inputProps,
2323
+ inputRef,
2324
+ inputValue,
2325
+ invalid,
2326
+ loading,
2327
+ placeholder,
2328
+ valid,
2329
+ ]);
2330
+ const labelComponent = useMemo(() => (jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsx(DIcon, { icon: labelIcon, size: `var(--${PREFIX_BS}label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix, materialStyle: labelIconMaterialStyle }))] })), [
2331
+ id,
2332
+ label,
2333
+ labelIcon,
2334
+ labelIconFamilyClass,
2335
+ labelIconFamilyPrefix,
2336
+ labelIconMaterialStyle,
2337
+ ]);
2338
+ const dynamicComponent = useMemo(() => {
2339
+ if (floatingLabel) {
2340
+ return (jsxs("div", { className: "form-floating", children: [inputComponent, labelComponent] }));
2341
+ }
2342
+ return inputComponent;
2343
+ }, [
2344
+ floatingLabel,
2345
+ inputComponent,
2346
+ labelComponent,
2347
+ ]);
2348
+ return (jsxs("div", Object.assign({ className: classNames('d-input-phone', className), style: style }, dataAttributes, { children: [label && !floatingLabel && labelComponent, jsxs("div", { className: classNames({
2349
+ [`input-group-${size}`]: !!size,
2350
+ 'input-group': true,
2351
+ 'has-validation': invalid || valid,
2352
+ }), children: [jsx(CountrySelector, Object.assign({}, countrySelectorProps, { selectedCountry: country.iso2, onSelect: ({ iso2 }) => setCountry(iso2), countries: countries, disabled: disabled || loading, className: classNames('input-group-text', countrySelectorProps === null || countrySelectorProps === void 0 ? void 0 : countrySelectorProps.className) })), dynamicComponent, (iconEnd && !loading) && (jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading || iconEndDisabled, "aria-label": iconEndAriaLabel, tabIndex: onIconEndClick ? iconEndTabIndex : -1, children: jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle }) })), loading && (jsx("div", { className: "input-group-text", id: `${id}Loading`, children: jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) }) })), !!inputEnd && (jsx("div", { className: "input-group-text", id: `${id}InputEnd`, children: inputEnd }))] }), hint && (jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
2353
+ }
2354
+ const ForwardedDInputPhone = forwardRef(DInputPhone);
2355
+ ForwardedDInputPhone.displayName = 'DInputPhone';
2356
+
2357
+ export { DAlert, DAvatar, DBadge, DBoxFile, DButton, DButtonIcon, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCurrencyText, DDatePicker, DIcon, DIconBase, ForwardedDInput as DInput, DInputCheck, ForwardedDInputCounter as DInputCounter, ForwardedDInputCurrencyBase as DInputCurrency, ForwardedDInputCurrencyBase$1 as DInputCurrencyBase, ForwardedDInputMask as DInputMask, ForwardedDInputPassword as DInputPassword, ForwardedDInputPhone as DInputPhone, DInputPin, ForwardedDInputRange as DInputRange, ForwardedDInputSearch as DInputSearch, DInputSelect, DInputSwitch, DList$1 as DList, DListGroup$1 as DListGroup, DListGroupItem, DListItem, DModal$1 as DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPopover, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSelect$1 as DSelect, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTableHead, DTabs$1 as DTabs, DToast$1 as DToast, DToastContainer, DTooltip, changeQueryString, checkMediaQuery, configureI8n as configureI18n, formatCurrency, getCssVariable, getQueryString, subscribeToMediaQuery, useDContext, useDPortalContext, useDToast, useDisableBodyScrollEffect, useDisableInputWheel, useFormatCurrency, useInputCurrency, useItemSelection, useMediaBreakpointUpLg, useMediaBreakpointUpMd, useMediaBreakpointUpSm, useMediaBreakpointUpXl, useMediaBreakpointUpXs, useMediaBreakpointUpXxl, useMediaQuery, usePortal, useProvidedRefOrCreate, useStackState, useTabContext, validatePhoneNumber };
2252
2358
  //# sourceMappingURL=index.esm.js.map