@dynamic-framework/ui-react 1.19.0 → 1.19.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.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import React, { useMemo, useEffect, useState, useCallback, createContext, useContext, forwardRef, useRef } from 'react';
2
+ import React, { useMemo, useEffect, useState, useCallback, createContext, useContext, Fragment as Fragment$1, forwardRef, useRef } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { __rest } from 'tslib';
5
5
  import { createPortal } from 'react-dom';
@@ -7,9 +7,9 @@ import { useDropzone } from 'react-dropzone';
7
7
  import { SplideSlide, Splide } from '@splidejs/react-splide';
8
8
  import currency from 'currency.js';
9
9
  import DatePicker from 'react-datepicker';
10
- import { parseISO, format, getMonth, getYear } from 'date-fns';
11
- import { InputMask } from '@react-input/mask';
10
+ import { getYear, format, getMonth, parseISO } from 'date-fns';
12
11
  import Select, { components } from 'react-select';
12
+ import { InputMask } from '@react-input/mask';
13
13
  import ResponsivePagination from 'react-responsive-pagination';
14
14
  import { useFloating, offset, flip, shift, autoUpdate, useClick, useDismiss, useRole, useInteractions, useId, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
15
15
  import ContentLoader from 'react-content-loader';
@@ -98,29 +98,31 @@ function usePortal(portalName) {
98
98
  * @returns The list and controls to modify the stack
99
99
  * @see https://react-hooks.org/docs/useStackState
100
100
  */
101
- function useStackState(initialList) {
101
+ function useStackState(initialList = []) {
102
102
  const [list, setList] = useState(initialList);
103
- const { length } = list;
104
- const push = useCallback((item) => {
105
- setList((prevList) => [
106
- ...prevList,
107
- item,
108
- ]);
109
- }, []);
110
- const pop = useCallback(() => {
111
- setList((prevList) => (prevList.slice(0, prevList.length - 1)));
112
- }, []);
103
+ const push = useCallback((item) => (setList((prevList) => [
104
+ ...prevList,
105
+ item,
106
+ ])), []);
107
+ const pop = useCallback(() => (setList((prevList) => (prevList.slice(0, prevList.length - 1)))), []);
113
108
  const peek = useCallback(() => list.at(-1), [list]);
114
- const clear = () => setList([]);
115
- const isEmpty = useCallback(() => list.length === 0, [list]);
116
- const controls = {
109
+ const clear = useCallback(() => setList([]), []);
110
+ const isEmpty = useCallback(() => list.length === 0, [list.length]);
111
+ const controls = useMemo(() => ({
117
112
  clear,
118
113
  isEmpty,
119
- length,
114
+ length: list.length,
120
115
  peek,
121
116
  pop,
122
117
  push,
123
- };
118
+ }), [
119
+ clear,
120
+ isEmpty,
121
+ list.length,
122
+ peek,
123
+ pop,
124
+ push,
125
+ ]);
124
126
  return [list, controls];
125
127
  }
126
128
 
@@ -154,7 +156,7 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
154
156
  openPortal,
155
157
  closePortal,
156
158
  }), [stack, openPortal, closePortal]);
157
- return (jsxs(DPortalContext.Provider, { value: value, children: [children, created && createPortal(jsx(Fragment, { children: stack.map(({ Component, name, payload, }) => (jsxs(Fragment, { children: [jsx("div", { className: "backdrop fade show" }), jsx(Component, { name: name, payload: payload })] }))) }), document.getElementById(portalName))] }));
159
+ return (jsxs(DPortalContext.Provider, { value: value, children: [children, created && createPortal(jsx(Fragment, { children: stack.map(({ Component, name, payload, }) => (jsxs(Fragment$1, { children: [jsx("div", { className: "backdrop fade show" }), jsx(Component, { name: name, payload: payload })] }, name))) }), document.getElementById(portalName))] }));
158
160
  }
159
161
  function useDPortalContext() {
160
162
  const context = useContext(DPortalContext);
@@ -469,58 +471,187 @@ var DInput$1 = ForwardedDInput;
469
471
 
470
472
  function DDatePickerTime(_a) {
471
473
  var { value, onChange, id, label, className, style } = _a, props = __rest(_a, ["value", "onChange", "id", "label", "className", "style"]);
472
- 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(DInput$1, Object.assign({}, onChange && {
474
+ 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(DInput$1, Object.assign({ className: "w-100" }, onChange && {
473
475
  onChange,
474
476
  }, { type: "time", id: id, value: value }, props))] }));
475
477
  }
476
478
 
477
479
  function DDatePickerInput(_a, ref) {
478
- var { value, onClick, id, iconEnd, className, style } = _a, props = __rest(_a, ["value", "onClick", "id", "iconEnd", "className", "style"]);
479
- return (jsx(DInput$1, Object.assign({ ref: ref, onClick: onClick, readOnly: true, type: "text", id: id, value: value, onIconEndClick: onClick, iconEnd: iconEnd, className: className, style: style }, props)));
480
+ var { value, onClick, id, iconEnd, className, style, inputLabel } = _a, props = __rest(_a, ["value", "onClick", "id", "iconEnd", "className", "style", "inputLabel"]);
481
+ return (jsx(DInput$1, Object.assign({ ref: ref, onClick: onClick, readOnly: true, type: "text", id: id, value: value, onIconEndClick: onClick, iconEnd: iconEnd, className: className, style: style, label: inputLabel }, props)));
480
482
  }
481
483
  const ForwardedDDatePickerInput = forwardRef(DDatePickerInput);
482
484
  ForwardedDDatePickerInput.displayName = 'DDatePickerInput';
483
485
  var DDatePickerInput$1 = ForwardedDDatePickerInput;
484
486
 
485
- function DMonthPicker(_a) {
486
- var { onChange, date, locale, className, calendarClassName, headerPrevYearAriaLabel = 'decrease year', headerNextYearAriaLabel = 'increase year', iconFamilyClass, iconFamilyPrefix, iconPrevMonth: iconPrevMonthProp, iconNextMonth: iconNextMonthProp } = _a, props = __rest(_a, ["onChange", "date", "locale", "className", "calendarClassName", "headerPrevYearAriaLabel", "headerNextYearAriaLabel", "iconFamilyClass", "iconFamilyPrefix", "iconPrevMonth", "iconNextMonth"]);
487
- const selected = useMemo(() => parseISO(date), [date]);
488
- const { iconMap: { chevronLeft, chevronRight, }, } = useDContext();
489
- const iconPrevMonth = useMemo(() => iconPrevMonthProp || chevronLeft, [chevronLeft, iconPrevMonthProp]);
490
- const iconNextMonth = useMemo(() => iconNextMonthProp || chevronRight, [chevronRight, iconNextMonthProp]);
491
- const dateFormatted = useMemo(() => (format(new Date(date), 'MMMM yyyy', { locale })), [date, locale]);
492
- return (jsx(DatePicker, Object.assign({ showMonthYearPicker: true, selected: selected, className: className, calendarClassName: classNames('d-month-picker', calendarClassName), onChange: onChange }, locale && { locale }, { customInput: (jsx("p", { className: "fw-bold text-capitalize", children: dateFormatted })), renderCustomHeader: ({ monthDate, decreaseYear, increaseYear, prevYearButtonDisabled, nextYearButtonDisabled, }) => (jsxs("div", { className: "d-flex align-items-center justify-content-between gap-6 fs-6 bg-dark", children: [jsx(DButton, { iconStart: iconPrevMonth, size: "sm", variant: "link", theme: "light", onClick: decreaseYear, disabled: prevYearButtonDisabled, ariaLabel: headerPrevYearAriaLabel, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix }), jsx("p", { className: "fs-6 fw-bold", children: monthDate.getFullYear() }), jsx(DButton, { iconStart: iconNextMonth, size: "sm", variant: "link", theme: "light", onClick: increaseYear, disabled: nextYearButtonDisabled, ariaLabel: headerNextYearAriaLabel, iconEndFamilyClass: iconFamilyPrefix, iconEndFamilyPrefix: iconFamilyPrefix })] })) }, props)));
493
- }
494
-
495
- function DDatePickerHeader({ monthDate, changeMonth, changeYear, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, withMonthSelector, iconPrevMonth, iconNextMonth, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, prevMonthAriaLabel = 'decrease month', nextMonthAriaLabel = 'increase month', iconSize, buttonVariant, buttonTheme, locale, style, className, }) {
496
- const onChangeDate = useCallback((value) => {
497
- if (value) {
498
- changeMonth(getMonth(value));
499
- changeYear(getYear(value));
487
+ function DInputCheck({ type, name, label, ariaLabel, checked = false, id, disabled = false, indeterminate, value, onChange, className, style, }) {
488
+ const innerRef = useRef(null);
489
+ const handleChange = useCallback((event) => {
490
+ onChange === null || onChange === void 0 ? void 0 : onChange(event);
491
+ }, [onChange]);
492
+ useEffect(() => {
493
+ if (innerRef.current) {
494
+ innerRef.current.indeterminate = Boolean(indeterminate);
495
+ }
496
+ }, [indeterminate]);
497
+ useEffect(() => {
498
+ if (innerRef.current) {
499
+ innerRef.current.checked = checked;
500
500
  }
501
- }, [changeMonth, changeYear]);
502
- return (jsxs("div", { className: classNames('d-flex align-items-center justify-content-between d-datepicker-header', className), style: style, children: [jsx(DButton, { iconStart: iconPrevMonth, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: decreaseMonth, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel }), jsx(DMonthPicker, Object.assign({}, !withMonthSelector && { readOnly: true }, withMonthSelector && { className: 'cursor-pointer' }, { date: monthDate.toISOString(), onChange: onChangeDate, iconPrevMonth: iconPrevMonth, iconNextMonth: iconNextMonth }, locale && { locale })), jsx(DButton, { iconStart: iconNextMonth, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: increaseMonth, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel })] }));
501
+ }, [checked]);
502
+ if (!label) {
503
+ return (jsx("input", { ref: innerRef, onChange: handleChange, className: classNames('form-check-input', className), style: style, id: id, disabled: disabled, type: type, name: name, value: value, "aria-label": ariaLabel }));
504
+ }
505
+ return (jsxs("div", { className: "form-check", children: [jsx("input", { ref: innerRef, onChange: handleChange, className: classNames('form-check-input', className), style: style, id: id, disabled: disabled, type: type, name: name, value: value }), jsx("label", { className: "form-check-label", htmlFor: id, children: label })] }));
506
+ }
507
+
508
+ function DSelectOptionCheck(_a) {
509
+ var { innerProps, children, isSelected } = _a, props = __rest(_a, ["innerProps", "children", "isSelected"]);
510
+ return (jsx(components.Option, Object.assign({ className: classNames({
511
+ 'd-select__option': true,
512
+ 'd-select__option--is-checkbox': true,
513
+ }), isSelected: isSelected, innerProps: innerProps }, props, { children: jsxs("label", { htmlFor: `${innerProps.id}Check`, children: [jsx(DInputCheck, { type: "checkbox", checked: isSelected, id: `${innerProps.id}Check` }), children] }) })));
514
+ }
515
+
516
+ function DSelectOptionIcon(_a) {
517
+ var { children, data } = _a, props = __rest(_a, ["children", "data"]);
518
+ return (jsxs(components.Option, Object.assign({ className: classNames({
519
+ 'd-select__option--has-icon': true,
520
+ }), data: data }, props, { children: [jsx(DIcon, { icon: data.icon }), children] })));
521
+ }
522
+
523
+ function DSelectSingleValueIconText(_a) {
524
+ var { children, getValue } = _a, props = __rest(_a, ["children", "getValue"]);
525
+ const [value] = getValue();
526
+ return (jsxs(components.SingleValue, Object.assign({ className: classNames({
527
+ 'd-select__control--has-icon': true,
528
+ }), getValue: getValue }, props, { children: [jsx(DIcon, { icon: value.icon }), children] })));
529
+ }
530
+
531
+ function DSelectDropdownIndicator(props) {
532
+ const { iconMap: { chevronDown, }, } = useDContext();
533
+ return (jsx(components.DropdownIndicator, Object.assign({}, props, { children: jsx(DIcon, { icon: chevronDown }) })));
534
+ }
535
+
536
+ function DSelectClearIndicator(props) {
537
+ const { iconMap: { xLg, }, } = useDContext();
538
+ return (jsx(components.ClearIndicator, Object.assign({}, props, { children: jsx(DIcon, { icon: xLg }) })));
539
+ }
540
+
541
+ function DSelectMultiValueRemove(props) {
542
+ const { iconMap: { x, }, } = useDContext();
543
+ return (jsx(components.MultiValueRemove, Object.assign({}, props, { children: jsx(DIcon, { icon: x }) })));
544
+ }
545
+
546
+ function DSelectLoadingIndicator({ innerProps, }) {
547
+ return (jsx("div", Object.assign({ className: classNames({
548
+ 'd-select__indicator': true,
549
+ 'd-select__loading-indicator': true,
550
+ }) }, innerProps, { children: jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) }) })));
551
+ }
552
+
553
+ function DSelectOptionEmoji(_a) {
554
+ var { children, data } = _a, props = __rest(_a, ["children", "data"]);
555
+ return (jsxs(components.Option, Object.assign({ className: classNames({
556
+ 'd-select__option--has-icon': true,
557
+ }), data: data }, props, { children: [jsx("span", { children: data.emoji }), jsx("span", { children: children })] })));
558
+ }
559
+
560
+ function DSelectSingleValueEmoji(_a) {
561
+ var { children, getValue } = _a, props = __rest(_a, ["children", "getValue"]);
562
+ const [value] = getValue();
563
+ return (jsx(components.SingleValue, Object.assign({ className: classNames({
564
+ 'd-select__control--has-icon': true,
565
+ }), getValue: getValue }, props, { children: value.emoji })));
566
+ }
567
+
568
+ function DSelectSingleValueEmojiText(_a) {
569
+ var { children, getValue } = _a, props = __rest(_a, ["children", "getValue"]);
570
+ const [value] = getValue();
571
+ return (jsxs(components.SingleValue, Object.assign({ className: classNames({
572
+ 'd-select__control--has-icon': true,
573
+ }), getValue: getValue }, props, { children: [jsx("span", { children: value.emoji }), jsx("span", { children: children })] })));
574
+ }
575
+
576
+ function DSelect(_a) {
577
+ var { id, 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, onIconStartClick, onIconEndClick } = _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", "onIconStartClick", "onIconEndClick"]);
578
+ const handleOnIconStartClick = useCallback(() => {
579
+ onIconStartClick === null || onIconStartClick === void 0 ? void 0 : onIconStartClick(defaultValue);
580
+ }, [onIconStartClick, defaultValue]);
581
+ const handleOnIconEndClick = useCallback(() => {
582
+ onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(defaultValue);
583
+ }, [onIconEndClick, defaultValue]);
584
+ return (jsxs("div", { className: classNames('d-select', className, {
585
+ disabled: disabled || loading,
586
+ }), style: style, 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({
587
+ 'input-group': true,
588
+ 'has-validation': invalid,
589
+ disabled: disabled || loading,
590
+ }), children: [iconStart && (jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: handleOnIconStartClick, disabled: disabled || loading, "aria-label": iconStartAriaLabel, tabIndex: iconStartTabIndex, children: jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix }) })), jsx(Select, Object.assign({ styles: {
591
+ control: (base) => (Object.assign(Object.assign({}, base), { minHeight: 'unset' })),
592
+ container: (base) => (Object.assign(Object.assign({}, base), { flex: 1 })),
593
+ menu: (base) => (Object.assign(Object.assign({}, base), { width: menuWithMaxContent ? 'max-context' : '100%' })),
594
+ }, className: classNames('d-select-component', {
595
+ 'is-invalid': invalid,
596
+ 'is-valid': valid,
597
+ }), classNamePrefix: "d-select", isDisabled: disabled || loading, isClearable: clearable, isLoading: loading, isRtl: rtl, isSearchable: searchable, isMulti: multi, defaultValue: defaultValue, unstyled: true, components: Object.assign({ DropdownIndicator: DSelectDropdownIndicator, ClearIndicator: DSelectClearIndicator, MultiValueRemove: DSelectMultiValueRemove, LoadingIndicator: DSelectLoadingIndicator }, components) }, props)), ((invalid || valid) && !iconEnd && !loading) && (jsx("span", { className: "input-group-text", id: `${id}State`, children: jsx(DIcon, { className: "input-group-validation-icon", icon: invalid ? 'exclamation-circle' : 'check', familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) })), (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 }))] }));
598
+ }
599
+ var DSelect$1 = Object.assign(DSelect, {
600
+ OptionCheck: DSelectOptionCheck,
601
+ OptionIcon: DSelectOptionIcon,
602
+ SingleValueIconText: DSelectSingleValueIconText,
603
+ DropdownIndicator: DSelectDropdownIndicator,
604
+ ClearIndicator: DSelectClearIndicator,
605
+ MultiValueRemove: DSelectMultiValueRemove,
606
+ LoadingIndicator: DSelectLoadingIndicator,
607
+ OptionEmoji: DSelectOptionEmoji,
608
+ SingleValueEmoji: DSelectSingleValueEmoji,
609
+ SingleValueEmojiText: DSelectSingleValueEmojiText,
610
+ });
611
+
612
+ function DDatePickerHeader({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, iconPrevMonth, iconNextMonth, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, prevMonthAriaLabel = 'decrease month', nextMonthAriaLabel = 'increase month', iconSize, buttonVariant, buttonTheme, locale, style, className, minYearSelect, maxYearSelect, }) {
613
+ const arrayYears = useMemo(() => Array.from({ length: maxYearSelect - minYearSelect + 1 }, (_, index) => minYearSelect + index), [maxYearSelect, minYearSelect]);
614
+ const years = useMemo(() => arrayYears.map((year) => ({
615
+ label: year.toString(),
616
+ value: year,
617
+ })), [arrayYears]);
618
+ const defaultYear = useMemo(() => years.find((year) => year.value === getYear(date)), [date, years]);
619
+ const arrayMonths = useMemo(() => Array.from({ length: 12 }, (_, i) => format(new Date(2000, i), 'LLLL', { locale })), [locale]);
620
+ const months = useMemo(() => arrayMonths.map((month, i) => ({
621
+ label: month,
622
+ value: i,
623
+ })), [arrayMonths]);
624
+ const defaultMonth = useMemo(() => ({
625
+ label: arrayMonths[getMonth(date)],
626
+ value: getMonth(date),
627
+ }), [arrayMonths, date]);
628
+ return (jsxs("div", { className: classNames('d-flex align-items-center d-datepicker-header', className), style: style, children: [jsx(DButton, { iconStart: iconPrevMonth, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: decreaseMonth, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button" }), jsxs("div", { className: "d-flex justify-content-center flex-grow-1", children: [jsx(DSelect$1, { options: months, value: defaultMonth, defaultValue: defaultMonth, onChange: (month) => changeMonth((month === null || month === void 0 ? void 0 : month.value) || 0), searchable: false }), jsx(DSelect$1, { options: years, value: defaultYear, defaultValue: defaultYear, onChange: (year) => changeYear(Number(year === null || year === void 0 ? void 0 : year.value)), searchable: false })] }), jsx(DButton, { iconStart: iconNextMonth, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: increaseMonth, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button" })] }));
503
629
  }
504
630
 
505
631
  function DDatePicker(_a) {
506
- var { date, selectsRange = false, withMonthSelector, inputLabel, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeLabel, iconInput: iconInputProp, iconHeaderPrevMonth: iconHeaderPrevMonthProp, iconHeaderNextMonth: iconHeaderNextMonthProp, iconMaterialStyle: iconMaterialStyleProp, iconFamilyClass, iconFamilyPrefix, headerPrevMonthAriaLabel = 'decrease month', headerNextMonthAriaLabel = 'increase month', headerIconSize = 'sm', headerButtonVariant = 'link', headerButtonTheme = 'dark', locale, className, style } = _a, props = __rest(_a, ["date", "selectsRange", "withMonthSelector", "inputLabel", "inputAriaLabel", "inputActionAriaLabel", "inputId", "timeId", "timeLabel", "iconInput", "iconHeaderPrevMonth", "iconHeaderNextMonth", "iconMaterialStyle", "iconFamilyClass", "iconFamilyPrefix", "headerPrevMonthAriaLabel", "headerNextMonthAriaLabel", "headerIconSize", "headerButtonVariant", "headerButtonTheme", "locale", "className", "style"]);
632
+ var { date, selectsRange = false, inputLabel, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeLabel, iconInput: iconInputProp, iconHeaderPrevMonth: iconHeaderPrevMonthProp, iconHeaderNextMonth: iconHeaderNextMonthProp, iconMaterialStyle: iconMaterialStyleProp, iconFamilyClass, iconFamilyPrefix, minYearSelect = 1900, maxYearSelect = 2100, iconHeaderSize = 'sm', headerPrevMonthAriaLabel = 'decrease month', headerNextMonthAriaLabel = 'increase month', headerButtonVariant = 'link', headerButtonTheme = 'dark', locale, className, formatWeekDay: formatWeekDayProp, style } = _a, props = __rest(_a, ["date", "selectsRange", "inputLabel", "inputAriaLabel", "inputActionAriaLabel", "inputId", "timeId", "timeLabel", "iconInput", "iconHeaderPrevMonth", "iconHeaderNextMonth", "iconMaterialStyle", "iconFamilyClass", "iconFamilyPrefix", "minYearSelect", "maxYearSelect", "iconHeaderSize", "headerPrevMonthAriaLabel", "headerNextMonthAriaLabel", "headerButtonVariant", "headerButtonTheme", "locale", "className", "formatWeekDay", "style"]);
507
633
  const { iconMap: { calendar, chevronLeft, chevronRight, }, } = useDContext();
508
634
  const selected = useMemo(() => (date ? parseISO(date) : null), [date]);
509
635
  const iconInput = useMemo(() => iconInputProp || calendar, [calendar, iconInputProp]);
636
+ const handleFormatWeekDay = useMemo(() => (formatWeekDayProp
637
+ ? (day) => formatWeekDayProp(day)
638
+ : (day) => day.substring(0, 1)), [formatWeekDayProp]);
510
639
  const iconPrevMonth = useMemo(() => iconHeaderPrevMonthProp || chevronLeft, [chevronLeft, iconHeaderPrevMonthProp]);
511
640
  const iconNextMonth = useMemo(() => iconHeaderNextMonthProp || chevronRight, [chevronRight, iconHeaderNextMonthProp]);
512
- const DatePickerHeader = useCallback((headerProps) => (jsx(DDatePickerHeader, Object.assign({}, headerProps, locale && { locale }, { iconPrevMonth: iconPrevMonth, iconNextMonth: iconNextMonth, iconMaterialStyle: iconMaterialStyleProp, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: headerIconSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, withMonthSelector: !!withMonthSelector }))), [locale,
641
+ const DatePickerHeader = useCallback((headerProps) => (jsx(DDatePickerHeader, Object.assign({}, headerProps, locale && { locale }, { iconPrevMonth: iconPrevMonth, iconNextMonth: iconNextMonth, iconMaterialStyle: iconMaterialStyleProp, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: iconHeaderSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, minYearSelect: minYearSelect, maxYearSelect: maxYearSelect }))), [
642
+ locale,
513
643
  iconPrevMonth,
514
644
  iconNextMonth,
515
645
  iconMaterialStyleProp,
516
646
  headerPrevMonthAriaLabel,
517
647
  headerNextMonthAriaLabel,
518
- headerIconSize,
648
+ iconHeaderSize,
519
649
  headerButtonVariant,
520
650
  headerButtonTheme,
521
- withMonthSelector,
651
+ minYearSelect,
652
+ maxYearSelect,
522
653
  ]);
523
- return (jsx(DatePicker, Object.assign({ selected: selected, calendarClassName: "d-date-picker", renderCustomHeader: (headerProps) => jsx(DatePickerHeader, Object.assign({}, headerProps)), customInput: (jsx(DDatePickerInput$1, { id: inputId, "aria-label": inputAriaLabel, iconEndAriaLabel: inputActionAriaLabel, iconMaterialStyle: iconMaterialStyleProp, iconEnd: iconInput, className: className, style: style })), customTimeInput: jsx(DDatePickerTime, { id: timeId, label: timeLabel }), selectsRange: selectsRange }, locale && { locale }, props)));
654
+ return (jsx(DatePicker, Object.assign({ selected: selected, calendarClassName: "d-date-picker", renderCustomHeader: (headerProps) => jsx(DatePickerHeader, Object.assign({}, headerProps)), selectsRange: selectsRange, formatWeekDay: handleFormatWeekDay, customInput: (jsx(DDatePickerInput$1, { id: inputId, "aria-label": inputAriaLabel, iconEndAriaLabel: inputActionAriaLabel, iconMaterialStyle: iconMaterialStyleProp, iconEnd: iconInput, inputLabel: inputLabel, className: className, style: style })), customTimeInput: (jsx(DDatePickerTime, { id: timeId, label: timeLabel })) }, locale && { locale }, props)));
524
655
  }
525
656
 
526
657
  function DInputMask(props, ref) {
@@ -689,27 +820,6 @@ const ForwardedDInputPassword = forwardRef(DInputPassword);
689
820
  ForwardedDInputPassword.displayName = 'DInputPassword';
690
821
  var DInputPassword$1 = ForwardedDInputPassword;
691
822
 
692
- function DInputCheck({ type, name, label, ariaLabel, checked = false, id, disabled = false, indeterminate, value, onChange, className, style, }) {
693
- const innerRef = useRef(null);
694
- const handleChange = useCallback((event) => {
695
- onChange === null || onChange === void 0 ? void 0 : onChange(event);
696
- }, [onChange]);
697
- useEffect(() => {
698
- if (innerRef.current) {
699
- innerRef.current.indeterminate = Boolean(indeterminate);
700
- }
701
- }, [indeterminate]);
702
- useEffect(() => {
703
- if (innerRef.current) {
704
- innerRef.current.checked = checked;
705
- }
706
- }, [checked]);
707
- if (!label) {
708
- return (jsx("input", { ref: innerRef, onChange: handleChange, className: classNames('form-check-input', className), style: style, id: id, disabled: disabled, type: type, name: name, value: value, "aria-label": ariaLabel }));
709
- }
710
- return (jsxs("div", { className: "form-check", children: [jsx("input", { ref: innerRef, onChange: handleChange, className: classNames('form-check-input', className), style: style, id: id, disabled: disabled, type: type, name: name, value: value }), jsx("label", { className: "form-check-label", htmlFor: id, children: label })] }));
711
- }
712
-
713
823
  function DInputPin({ id, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, placeholder, type = 'text', disabled = false, loading = false, secret = false, iconFamilyClass, iconFamilyPrefix, characters = 4, invalidIcon: invalidIconProp, validIcon: validIconProp, innerInputMode = 'text', hint, invalid = false, valid = false, className, style, onChange, }) {
714
824
  const [pattern, setPattern] = useState('');
715
825
  useEffect(() => {
@@ -860,110 +970,6 @@ function DInputSwitch({ label, ariaLabel, id, name, checked, disabled, readonly,
860
970
  return (jsxs("div", { className: "form-check form-switch", children: [jsx("input", { id: id, name: name, onChange: readonly ? () => false : changeHandler, className: classNames('form-check-input', className), style: style, type: "checkbox", role: "switch", checked: internalIsChecked, disabled: disabled, "aria-label": ariaLabel }), label && (jsx("label", { className: "form-check-label", htmlFor: id, children: label }))] }));
861
971
  }
862
972
 
863
- function DSelectOptionCheck(_a) {
864
- var { innerProps, children, isSelected } = _a, props = __rest(_a, ["innerProps", "children", "isSelected"]);
865
- return (jsx(components.Option, Object.assign({ className: classNames({
866
- 'd-select__option': true,
867
- 'd-select__option--is-checkbox': true,
868
- }), isSelected: isSelected, innerProps: innerProps }, props, { children: jsxs("label", { htmlFor: `${innerProps.id}Check`, children: [jsx(DInputCheck, { type: "checkbox", checked: isSelected, id: `${innerProps.id}Check` }), children] }) })));
869
- }
870
-
871
- function DSelectOptionIcon(_a) {
872
- var { children, data } = _a, props = __rest(_a, ["children", "data"]);
873
- return (jsxs(components.Option, Object.assign({ className: classNames({
874
- 'd-select__option--has-icon': true,
875
- }), data: data }, props, { children: [jsx(DIcon, { icon: data.icon }), children] })));
876
- }
877
-
878
- function DSelectSingleValueIconText(_a) {
879
- var { children, getValue } = _a, props = __rest(_a, ["children", "getValue"]);
880
- const [value] = getValue();
881
- return (jsxs(components.SingleValue, Object.assign({ className: classNames({
882
- 'd-select__control--has-icon': true,
883
- }), getValue: getValue }, props, { children: [jsx(DIcon, { icon: value.icon }), children] })));
884
- }
885
-
886
- function DSelectDropdownIndicator(props) {
887
- const { iconMap: { chevronDown, }, } = useDContext();
888
- return (jsx(components.DropdownIndicator, Object.assign({}, props, { children: jsx(DIcon, { icon: chevronDown }) })));
889
- }
890
-
891
- function DSelectClearIndicator(props) {
892
- const { iconMap: { xLg, }, } = useDContext();
893
- return (jsx(components.ClearIndicator, Object.assign({}, props, { children: jsx(DIcon, { icon: xLg }) })));
894
- }
895
-
896
- function DSelectMultiValueRemove(props) {
897
- const { iconMap: { x, }, } = useDContext();
898
- return (jsx(components.MultiValueRemove, Object.assign({}, props, { children: jsx(DIcon, { icon: x }) })));
899
- }
900
-
901
- function DSelectLoadingIndicator({ innerProps, }) {
902
- return (jsx("div", Object.assign({ className: classNames({
903
- 'd-select__indicator': true,
904
- 'd-select__loading-indicator': true,
905
- }) }, innerProps, { children: jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) }) })));
906
- }
907
-
908
- function DSelectOptionEmoji(_a) {
909
- var { children, data } = _a, props = __rest(_a, ["children", "data"]);
910
- return (jsxs(components.Option, Object.assign({ className: classNames({
911
- 'd-select__option--has-icon': true,
912
- }), data: data }, props, { children: [jsx("span", { children: data.emoji }), jsx("span", { children: children })] })));
913
- }
914
-
915
- function DSelectSingleValueEmoji(_a) {
916
- var { children, getValue } = _a, props = __rest(_a, ["children", "getValue"]);
917
- const [value] = getValue();
918
- return (jsx(components.SingleValue, Object.assign({ className: classNames({
919
- 'd-select__control--has-icon': true,
920
- }), getValue: getValue }, props, { children: value.emoji })));
921
- }
922
-
923
- function DSelectSingleValueEmojiText(_a) {
924
- var { children, getValue } = _a, props = __rest(_a, ["children", "getValue"]);
925
- const [value] = getValue();
926
- return (jsxs(components.SingleValue, Object.assign({ className: classNames({
927
- 'd-select__control--has-icon': true,
928
- }), getValue: getValue }, props, { children: [jsx("span", { children: value.emoji }), jsx("span", { children: children })] })));
929
- }
930
-
931
- function DSelect(_a) {
932
- var { id, 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, onIconStartClick, onIconEndClick } = _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", "onIconStartClick", "onIconEndClick"]);
933
- const handleOnIconStartClick = useCallback(() => {
934
- onIconStartClick === null || onIconStartClick === void 0 ? void 0 : onIconStartClick(defaultValue);
935
- }, [onIconStartClick, defaultValue]);
936
- const handleOnIconEndClick = useCallback(() => {
937
- onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(defaultValue);
938
- }, [onIconEndClick, defaultValue]);
939
- return (jsxs("div", { className: classNames('d-select', className, {
940
- disabled: disabled || loading,
941
- }), style: style, 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({
942
- 'input-group': true,
943
- 'has-validation': invalid,
944
- disabled: disabled || loading,
945
- }), children: [iconStart && (jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: handleOnIconStartClick, disabled: disabled || loading, "aria-label": iconStartAriaLabel, tabIndex: iconStartTabIndex, children: jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix }) })), jsx(Select, Object.assign({ styles: {
946
- control: (base) => (Object.assign(Object.assign({}, base), { minHeight: 'unset' })),
947
- container: (base) => (Object.assign(Object.assign({}, base), { flex: 1 })),
948
- menu: (base) => (Object.assign(Object.assign({}, base), { width: menuWithMaxContent ? 'max-context' : '100%' })),
949
- }, className: classNames('d-select-component', {
950
- 'is-invalid': invalid,
951
- 'is-valid': valid,
952
- }), classNamePrefix: "d-select", isDisabled: disabled || loading, isClearable: clearable, isLoading: loading, isRtl: rtl, isSearchable: searchable, isMulti: multi, defaultValue: defaultValue, unstyled: true, components: Object.assign({ DropdownIndicator: DSelectDropdownIndicator, ClearIndicator: DSelectClearIndicator, MultiValueRemove: DSelectMultiValueRemove, LoadingIndicator: DSelectLoadingIndicator }, components) }, props)), ((invalid || valid) && !iconEnd && !loading) && (jsx("span", { className: "input-group-text", id: `${id}State`, children: jsx(DIcon, { className: "input-group-validation-icon", icon: invalid ? 'exclamation-circle' : 'check', familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) })), (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 }))] }));
953
- }
954
- var DSelect$1 = Object.assign(DSelect, {
955
- OptionCheck: DSelectOptionCheck,
956
- OptionIcon: DSelectOptionIcon,
957
- SingleValueIconText: DSelectSingleValueIconText,
958
- DropdownIndicator: DSelectDropdownIndicator,
959
- ClearIndicator: DSelectClearIndicator,
960
- MultiValueRemove: DSelectMultiValueRemove,
961
- LoadingIndicator: DSelectLoadingIndicator,
962
- OptionEmoji: DSelectOptionEmoji,
963
- SingleValueEmoji: DSelectSingleValueEmoji,
964
- SingleValueEmojiText: DSelectSingleValueEmojiText,
965
- });
966
-
967
973
  function DListItem({ children, className, style, active = false, disabled = false, theme, onClick, }) {
968
974
  const Tag = useMemo(() => (onClick ? 'button' : 'div'), [onClick]);
969
975
  return (jsx(Tag, Object.assign({}, Tag === 'button' && {
@@ -1355,5 +1361,5 @@ async function configureI8n(resources, _a = {}) {
1355
1361
  .then((t) => t);
1356
1362
  }
1357
1363
 
1358
- export { DAlert, DBadge, DBoxFile, DButton, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCurrencyText, DDatePicker, DIcon, DIconBase, DInput$1 as DInput, DInputCheck, DInputCounter$1 as DInputCounter, DInputCurrency$1 as DInputCurrency, DInputCurrencyBase$1 as DInputCurrencyBase, DInputMask$1 as DInputMask, DInputPassword$1 as DInputPassword, DInputPin, DInputSearch$1 as DInputSearch, DInputSelect, DInputSwitch, DList$1 as DList, DListItem, DModal$1 as DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPopover, DPortalContext, DPortalContextProvider, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSelect$1 as DSelect, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTabs$1 as DTabs, DToastContainer, DTooltip, configureI8n as configureI18n, formatCurrency, useDContext, useDPortalContext, useDToast, useDisableBodyScrollEffect, useDisableInputWheel, useFormatCurrency, useInputCurrency, usePortal, useProvidedRefOrCreate, useStackState, useTabContext };
1364
+ export { DAlert, DBadge, DBoxFile, DButton, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCurrencyText, DDatePicker, DIcon, DIconBase, DInput$1 as DInput, DInputCheck, DInputCounter$1 as DInputCounter, DInputCurrency$1 as DInputCurrency, DInputCurrencyBase$1 as DInputCurrencyBase, DInputMask$1 as DInputMask, DInputPassword$1 as DInputPassword, DInputPin, DInputSearch$1 as DInputSearch, DInputSelect, DInputSwitch, DList$1 as DList, 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, DTabs$1 as DTabs, DToastContainer, DTooltip, configureI8n as configureI18n, formatCurrency, useDContext, useDPortalContext, useDToast, useDisableBodyScrollEffect, useDisableInputWheel, useFormatCurrency, useInputCurrency, usePortal, useProvidedRefOrCreate, useStackState, useTabContext };
1359
1365
  //# sourceMappingURL=index.esm.js.map