@dynamic-framework/ui-react 1.35.1 → 1.36.1

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 (42) hide show
  1. package/dist/css/bootstrap-icons.css +31 -3
  2. package/dist/css/bootstrap-icons.json +29 -1
  3. package/dist/css/bootstrap-icons.min.css +2 -2
  4. package/dist/css/bootstrap-icons.scss +29 -1
  5. package/dist/css/dynamic-ui-non-root.css +373 -85
  6. package/dist/css/dynamic-ui-non-root.min.css +2 -2
  7. package/dist/css/dynamic-ui-root.css +4 -1
  8. package/dist/css/dynamic-ui-root.min.css +2 -2
  9. package/dist/css/dynamic-ui.css +376 -85
  10. package/dist/css/dynamic-ui.min.css +2 -2
  11. package/dist/css/fonts/bootstrap-icons.woff +0 -0
  12. package/dist/css/fonts/bootstrap-icons.woff2 +0 -0
  13. package/dist/index.esm.js +125 -19
  14. package/dist/index.esm.js.map +1 -1
  15. package/dist/index.js +126 -18
  16. package/dist/index.js.map +1 -1
  17. package/dist/types/components/DBoxFile/useDBoxFile.d.ts +1 -1
  18. package/dist/types/components/DDatePicker/DDatePicker.d.ts +4 -3
  19. package/dist/types/components/DDatePicker/components/DDatePickerHeaderSelector.d.ts +3 -1
  20. package/dist/types/components/DDatePicker/components/DDatePickerTime.d.ts +5 -7
  21. package/dist/types/components/DInputPhone/DInputPhone.d.ts +26 -0
  22. package/dist/types/components/DInputPhone/index.d.ts +2 -0
  23. package/dist/types/components/DSelect/DSelect.d.ts +2 -1
  24. package/dist/types/components/index.d.ts +1 -0
  25. package/dist/types/utils/index.d.ts +1 -0
  26. package/dist/types/utils/validatePhoneNumber.d.ts +1 -0
  27. package/jest/setup.js +15 -0
  28. package/package.json +10 -4
  29. package/src/style/abstracts/_utilities.scss +11 -1
  30. package/src/style/abstracts/variables/_+import.scss +2 -1
  31. package/src/style/abstracts/variables/_datepicker.scss +5 -8
  32. package/src/style/abstracts/variables/_input-phone.scss +62 -0
  33. package/src/style/abstracts/variables/_navs.scss +3 -1
  34. package/src/style/abstracts/variables/_typography.scss +2 -0
  35. package/src/style/base/_form-switch.scss +1 -1
  36. package/src/style/base/_nav.scss +9 -13
  37. package/src/style/components/_+import.scss +1 -0
  38. package/src/style/components/_d-datepicker.scss +79 -152
  39. package/src/style/components/_d-input-phone.scss +286 -0
  40. package/src/style/components/_d-select.scss +22 -2
  41. package/src/style/components/_d-timepicker.scss +43 -29
  42. package/src/style/root/_root.scss +4 -0
package/dist/index.js CHANGED
@@ -10,13 +10,14 @@ var reactSplide = require('@splidejs/react-splide');
10
10
  var currency = require('currency.js');
11
11
  var DatePicker = require('react-datepicker');
12
12
  var dateFns = require('date-fns');
13
- var locale = require('date-fns/locale');
14
13
  var Select = require('react-select');
15
14
  var mask = require('@react-input/mask');
16
15
  var ResponsivePagination = require('react-responsive-pagination');
17
16
  var react = require('@floating-ui/react');
18
17
  var ContentLoader = require('react-content-loader');
19
18
  var reactHotToast = require('react-hot-toast');
19
+ var reactInternationalPhone = require('react-international-phone');
20
+ var googleLibphonenumber = require('google-libphonenumber');
20
21
  var i18n = require('i18next');
21
22
  var reactI18next = require('react-i18next');
22
23
 
@@ -623,7 +624,7 @@ const DEFAULT_PROPS = {
623
624
 
624
625
  /* eslint-disable no-param-reassign */
625
626
  function useDBoxFile(props) {
626
- const { accept, autoFocus, disabled, maxSize, minSize, multiple, maxFiles, value: preloadUrls, onDragEnter, onDragLeave, onDrop, onError, noClick, noKeyboard, noDrag, } = Object.assign(Object.assign({}, DEFAULT_PROPS), props);
627
+ 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);
627
628
  const inputRef = React.useRef(null);
628
629
  const rootRef = React.useRef(null);
629
630
  const dragTargetsRef = React.useRef([]);
@@ -663,12 +664,17 @@ function useDBoxFile(props) {
663
664
  const [accepted, errors] = await urlsToFiles(preloadUrls);
664
665
  if (accepted.length) {
665
666
  setFiles(accepted);
667
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(accepted);
666
668
  }
667
669
  if (errors.length) {
668
670
  onError === null || onError === void 0 ? void 0 : onError(new Error(errors.map((e) => e.message).join(', ')));
669
671
  }
670
672
  })();
671
- }, [preloadUrls, onError]);
673
+ }, [
674
+ preloadUrls,
675
+ onError,
676
+ onLoad,
677
+ ]);
672
678
  const processFiles = React.useCallback((inputFiles, event) => {
673
679
  let acceptedFiles = [];
674
680
  let rejectedFiles = [];
@@ -712,7 +718,7 @@ function useDBoxFile(props) {
712
718
  }
713
719
  }, [
714
720
  acceptAttr,
715
- files.length,
721
+ files,
716
722
  maxFiles,
717
723
  maxSize,
718
724
  minSize,
@@ -802,7 +808,9 @@ function useDBoxFile(props) {
802
808
  }, [processFiles]);
803
809
  const handleRemoveFile = React.useCallback((index) => {
804
810
  setFiles((prevFiles) => prevFiles.filter((_, i) => i !== index));
805
- }, []);
811
+ // Done twice to avoid mismatch between files and setFiles value
812
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(files.filter((_, i) => i !== index));
813
+ }, [files, onLoad]);
806
814
  const openFileDialog = React.useCallback(() => {
807
815
  var _a;
808
816
  if (disabled)
@@ -856,7 +864,7 @@ function DBoxFile(_a) {
856
864
  'd-box-file-invalid': isDragInvalid,
857
865
  }, className), style: style }, dataAttributes, { children: jsxRuntime.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: [jsxRuntime.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 }), jsxRuntime.jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }), jsxRuntime.jsx("div", { className: "d-box-content", children: typeof children === 'function'
858
866
  ? children(openFileDialog)
859
- : children })] })) })), !!files.length && (jsxRuntime.jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsxRuntime.jsx(ForwardedDInput, { value: file.name, iconStart: "paperclip", iconEnd: "trash", readOnly: true, onIconEndClick: () => handleRemoveFile(index) }, file.name))) }))] }));
867
+ : children })] })) })), !!files.length && (jsxRuntime.jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsxRuntime.jsx(ForwardedDInput, { value: file.name, iconStart: "paperclip", iconEnd: "trash", readOnly: true, onIconEndClick: () => handleRemoveFile(index) }, `${file.name} ${index}`))) }))] }));
860
868
  }
861
869
 
862
870
  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, }) {
@@ -997,11 +1005,10 @@ function DCurrencyText({ value, className, style, dataAttributes, }) {
997
1005
  return (jsxRuntime.jsx("span", Object.assign({ className: className, style: style }, dataAttributes, { children: valueFormatted })));
998
1006
  }
999
1007
 
1000
- function DDatePickerTime(_a) {
1001
- var { value, onChange, id, label, className, style } = _a, props = tslib.__rest(_a, ["value", "onChange", "id", "label", "className", "style"]);
1002
- return (jsxRuntime.jsxs("div", { className: classNames('d-flex align-items-center gap-2 flex-column d-datepicker-time', className), style: style, children: [label && (jsxRuntime.jsx("label", { htmlFor: id, className: "d-datepicker-time-label", children: label })), jsxRuntime.jsx(ForwardedDInput, Object.assign({ className: "w-100" }, onChange && {
1003
- onChange,
1004
- }, { type: "time", id: id, value: value }, props))] }));
1008
+ function DDatePickerTime({ value, onChange, id, }) {
1009
+ return (jsxRuntime.jsx(ForwardedDInput, { className: "d-datepicker-time", type: "time", value: value, id: id, onChange: (time) => {
1010
+ onChange === null || onChange === void 0 ? void 0 : onChange(time);
1011
+ } }));
1005
1012
  }
1006
1013
 
1007
1014
  function DDatePickerInput(_a, ref) {
@@ -1138,7 +1145,7 @@ function DSelectPlaceholder(_a) {
1138
1145
  }
1139
1146
 
1140
1147
  function DSelect(_a) {
1141
- 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 = tslib.__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"]);
1148
+ 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 = tslib.__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"]);
1142
1149
  const innerId = React.useId();
1143
1150
  const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
1144
1151
  const handleOnIconStartClick = React.useCallback(() => {
@@ -1148,6 +1155,7 @@ function DSelect(_a) {
1148
1155
  onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(defaultValue);
1149
1156
  }, [onIconEndClick, defaultValue]);
1150
1157
  return (jsxRuntime.jsxs("div", Object.assign({ className: classNames('d-select', className, {
1158
+ 'd-select-floating': floatingLabel,
1151
1159
  disabled: disabled || loading,
1152
1160
  }), style: style }, dataAttributes, { children: [label && (jsxRuntime.jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsxRuntime.jsx(DIcon, { icon: labelIcon, size: `var(--${PREFIX_BS}input-label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix }))] })), jsxRuntime.jsxs("div", { className: classNames({
1153
1161
  'input-group': true,
@@ -1160,7 +1168,7 @@ function DSelect(_a) {
1160
1168
  }, className: classNames('d-select-component', {
1161
1169
  'is-invalid': invalid,
1162
1170
  'is-valid': valid,
1163
- }), 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) && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading, "aria-label": iconEndAriaLabel, tabIndex: iconEndTabIndex, children: iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
1171
+ }), 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) && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading, "aria-label": iconEndAriaLabel, tabIndex: iconEndTabIndex, children: iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
1164
1172
  }
1165
1173
  var DSelect$1 = Object.assign(DSelect, {
1166
1174
  OptionCheck: DSelectOptionCheck,
@@ -1183,7 +1191,7 @@ var PickerType;
1183
1191
  PickerType["Month"] = "month";
1184
1192
  PickerType["Year"] = "year";
1185
1193
  })(PickerType || (PickerType = {}));
1186
- 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, }) {
1194
+ 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, }) {
1187
1195
  const { iconMap: { chevronLeft, chevronRight, }, } = useDContext();
1188
1196
  const arrayYears = React.useMemo(() => Array.from({ length: maxYearSelect - minYearSelect + 1 }, (_, index) => minYearSelect + index), [maxYearSelect, minYearSelect]);
1189
1197
  const years = React.useMemo(() => arrayYears.map((year) => ({
@@ -1191,7 +1199,7 @@ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMont
1191
1199
  value: year,
1192
1200
  })), [arrayYears]);
1193
1201
  const defaultYear = React.useMemo(() => years.find((year) => year.value === dateFns.getYear(monthDate)), [monthDate, years]);
1194
- const arrayMonths = React.useMemo(() => Array.from({ length: 12 }, (_, i) => dateFns.format(new Date(2000, i), 'LLLL', { locale: locale.enUS })), []);
1202
+ const arrayMonths = React.useMemo(() => Array.from({ length: 12 }, (_, i) => dateFns.format(new Date(2000, i), 'LLLL', { locale })), [locale]);
1195
1203
  const months = React.useMemo(() => arrayMonths.map((month, i) => ({
1196
1204
  label: month,
1197
1205
  value: i,
@@ -1217,7 +1225,7 @@ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMont
1217
1225
  }
1218
1226
 
1219
1227
  function DDatePicker(_a) {
1220
- 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 = tslib.__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"]);
1228
+ 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 = tslib.__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"]);
1221
1229
  const pickerType = React.useMemo(() => {
1222
1230
  if (props.showQuarterYearPicker)
1223
1231
  return PickerType.Quarter;
@@ -1231,7 +1239,7 @@ function DDatePicker(_a) {
1231
1239
  props.showMonthYearPicker,
1232
1240
  props.showYearPicker,
1233
1241
  ]);
1234
- const DatePickerHeader = React.useCallback((headerProps) => (jsxRuntime.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 }))), [
1242
+ const DatePickerHeader = React.useCallback((headerProps) => (jsxRuntime.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 }))), [
1235
1243
  iconHeaderNext,
1236
1244
  iconHeaderPrev,
1237
1245
  iconMaterialStyle,
@@ -1245,10 +1253,11 @@ function DDatePicker(_a) {
1245
1253
  pickerType,
1246
1254
  showHeaderSelectors,
1247
1255
  props.monthsShown,
1256
+ props.locale,
1248
1257
  ]);
1249
1258
  const defaultRenderCustomHeader = React.useCallback((headerProps) => (jsxRuntime.jsx(DatePickerHeader, Object.assign({}, headerProps))), [DatePickerHeader]);
1250
1259
  const renderCustomHeader = React.useMemo(() => (renderCustomHeaderProp || defaultRenderCustomHeader), [defaultRenderCustomHeader, renderCustomHeaderProp]);
1251
- return (jsxRuntime.jsx(DatePicker, Object.assign({ calendarClassName: "d-date-picker", renderCustomHeader: renderCustomHeader, customInput: (jsxRuntime.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: (jsxRuntime.jsx(DDatePickerTime, { id: timeId, label: timeLabel })), placeholderText: placeholder }, dataAttributes, props)));
1260
+ return (jsxRuntime.jsx(DatePicker, Object.assign({}, dataAttributes, props, { calendarClassName: "d-date-picker", renderCustomHeader: renderCustomHeader, placeholderText: placeholder, customInput: (jsxRuntime.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: (jsxRuntime.jsx(DDatePickerTime, { id: timeId })) })));
1252
1261
  }
1253
1262
 
1254
1263
  function DInputMask(props, ref) {
@@ -2250,6 +2259,103 @@ function changeQueryString(values, { useSearch = true, pushState = false, } = {}
2250
2259
  return searchParams.toString();
2251
2260
  }
2252
2261
 
2262
+ const phoneUtil = googleLibphonenumber.PhoneNumberUtil.getInstance();
2263
+ function validatePhoneNumber(phone) {
2264
+ try {
2265
+ return phoneUtil.isValidNumber(phoneUtil.parseAndKeepRawInput(phone));
2266
+ }
2267
+ catch (error) {
2268
+ return false;
2269
+ }
2270
+ }
2271
+
2272
+ function DInputPhone(_a, ref) {
2273
+ 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 = tslib.__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"]);
2274
+ const innerRef = useProvidedRefOrCreate(ref);
2275
+ const innerId = React.useId();
2276
+ const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
2277
+ const handleOnIconEndClick = React.useCallback(() => {
2278
+ onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(value);
2279
+ }, [onIconEndClick, value]);
2280
+ const ariaDescribedby = React.useMemo(() => ([
2281
+ (invalid || valid) && !iconEnd && !loading && `${id}State`,
2282
+ (iconEnd && !loading) && `${id}End`,
2283
+ loading && `${id}Loading`,
2284
+ !!inputEnd && `${id}InputEnd`,
2285
+ !!hint && `${id}Hint`,
2286
+ ]
2287
+ .filter(Boolean)
2288
+ .join(' ')), [
2289
+ id,
2290
+ invalid,
2291
+ valid,
2292
+ iconEnd,
2293
+ loading,
2294
+ inputEnd,
2295
+ hint,
2296
+ ]);
2297
+ const countries = React.useMemo(() => {
2298
+ if (filteredCountries === undefined) {
2299
+ return reactInternationalPhone.defaultCountries;
2300
+ }
2301
+ return reactInternationalPhone.defaultCountries.filter((country) => {
2302
+ const { iso2 } = reactInternationalPhone.parseCountry(country);
2303
+ return filteredCountries.includes(iso2);
2304
+ });
2305
+ }, [filteredCountries]);
2306
+ const { inputValue, handlePhoneValueChange, inputRef, country, setCountry, } = reactInternationalPhone.usePhoneInput({
2307
+ inputRef: innerRef,
2308
+ defaultCountry,
2309
+ value,
2310
+ countries,
2311
+ onChange: (data) => {
2312
+ onChange === null || onChange === void 0 ? void 0 : onChange(Object.assign(Object.assign({}, data), { isValid: validatePhoneNumber(data.phone) }));
2313
+ },
2314
+ });
2315
+ const inputComponent = React.useMemo(() => (jsxRuntime.jsx("input", Object.assign({ ref: inputRef, id: id, className: classNames('form-control', {
2316
+ 'is-invalid': invalid,
2317
+ 'is-valid': valid,
2318
+ }), disabled: disabled || loading, value: inputValue, onChange: handlePhoneValueChange, inputMode: "tel" }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
2319
+ ariaDescribedby,
2320
+ disabled,
2321
+ floatingLabel,
2322
+ handlePhoneValueChange,
2323
+ id,
2324
+ inputProps,
2325
+ inputRef,
2326
+ inputValue,
2327
+ invalid,
2328
+ loading,
2329
+ placeholder,
2330
+ valid,
2331
+ ]);
2332
+ const labelComponent = React.useMemo(() => (jsxRuntime.jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsxRuntime.jsx(DIcon, { icon: labelIcon, size: `var(--${PREFIX_BS}label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix, materialStyle: labelIconMaterialStyle }))] })), [
2333
+ id,
2334
+ label,
2335
+ labelIcon,
2336
+ labelIconFamilyClass,
2337
+ labelIconFamilyPrefix,
2338
+ labelIconMaterialStyle,
2339
+ ]);
2340
+ const dynamicComponent = React.useMemo(() => {
2341
+ if (floatingLabel) {
2342
+ return (jsxRuntime.jsxs("div", { className: "form-floating", children: [inputComponent, labelComponent] }));
2343
+ }
2344
+ return inputComponent;
2345
+ }, [
2346
+ floatingLabel,
2347
+ inputComponent,
2348
+ labelComponent,
2349
+ ]);
2350
+ return (jsxRuntime.jsxs("div", Object.assign({ className: classNames('d-input-phone', className), style: style }, dataAttributes, { children: [label && !floatingLabel && labelComponent, jsxRuntime.jsxs("div", { className: classNames({
2351
+ [`input-group-${size}`]: !!size,
2352
+ 'input-group': true,
2353
+ 'has-validation': invalid || valid,
2354
+ }), children: [jsxRuntime.jsx(reactInternationalPhone.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) && (jsxRuntime.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: jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle }) })), loading && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}Loading`, children: jsxRuntime.jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsxRuntime.jsx("span", { className: "visually-hidden", children: "Loading..." }) }) })), !!inputEnd && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}InputEnd`, children: inputEnd }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
2355
+ }
2356
+ const ForwardedDInputPhone = React.forwardRef(DInputPhone);
2357
+ ForwardedDInputPhone.displayName = 'DInputPhone';
2358
+
2253
2359
  exports.DAlert = DAlert;
2254
2360
  exports.DAvatar = DAvatar;
2255
2361
  exports.DBadge = DBadge;
@@ -2277,6 +2383,7 @@ exports.DInputCurrency = ForwardedDInputCurrencyBase;
2277
2383
  exports.DInputCurrencyBase = ForwardedDInputCurrencyBase$1;
2278
2384
  exports.DInputMask = ForwardedDInputMask;
2279
2385
  exports.DInputPassword = ForwardedDInputPassword;
2386
+ exports.DInputPhone = ForwardedDInputPhone;
2280
2387
  exports.DInputPin = DInputPin;
2281
2388
  exports.DInputRange = ForwardedDInputRange;
2282
2389
  exports.DInputSearch = ForwardedDInputSearch;
@@ -2338,4 +2445,5 @@ exports.usePortal = usePortal;
2338
2445
  exports.useProvidedRefOrCreate = useProvidedRefOrCreate;
2339
2446
  exports.useStackState = useStackState;
2340
2447
  exports.useTabContext = useTabContext;
2448
+ exports.validatePhoneNumber = validatePhoneNumber;
2341
2449
  //# sourceMappingURL=index.js.map