@dynamic-framework/ui-react 1.36.2 → 2.0.0-dev.10
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/css/dynamic-ui-non-root.css +7051 -3728
- package/dist/css/dynamic-ui-non-root.min.css +3 -3
- package/dist/css/dynamic-ui-root.css +339 -161
- package/dist/css/dynamic-ui-root.min.css +3 -3
- package/dist/css/dynamic-ui.css +7392 -3891
- package/dist/css/dynamic-ui.min.css +3 -3
- package/dist/index.esm.js +643 -410
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +687 -437
- package/dist/index.js.map +1 -1
- package/dist/js/bootstrap.bundle.js +3 -6
- package/dist/js/bootstrap.bundle.min.js +2 -2
- package/dist/js/bootstrap.esm.js +3 -6
- package/dist/js/bootstrap.esm.min.js +2 -2
- package/dist/js/bootstrap.js +3 -6
- package/dist/js/bootstrap.min.js +2 -2
- package/dist/types/components/DAlert/DAlert.d.ts +3 -3
- package/dist/types/components/DAvatar/DAvatar.d.ts +1 -3
- package/dist/types/components/DBadge/DBadge.d.ts +4 -3
- package/dist/types/components/DBox/DBox.d.ts +5 -0
- package/dist/types/components/DBox/index.d.ts +2 -0
- package/dist/types/components/DBoxFile/DBoxFile.d.ts +1 -1
- package/dist/types/components/DBoxFile/useDBoxFile.d.ts +2 -2
- package/dist/types/components/DButton/DButton.d.ts +8 -17
- package/dist/types/components/DButtonIcon/DButtonIcon.d.ts +3 -3
- package/dist/types/components/DCarousel/components/DCarouselSlide.d.ts +3 -1
- package/dist/types/components/DChip/DChip.d.ts +3 -3
- package/dist/types/components/DCollapse/DCollapse.d.ts +2 -2
- package/dist/types/components/DCreditCard/DCreditCard.d.ts +12 -0
- package/dist/types/components/DCreditCard/index.d.ts +2 -0
- package/dist/types/components/DDatePicker/DDatePicker.d.ts +3 -3
- package/dist/types/components/DDatePicker/components/DDatePickerHeaderSelector.d.ts +2 -4
- package/dist/types/components/DDropdown/DDropdown.d.ts +20 -0
- package/dist/types/components/DDropdown/index.d.ts +2 -0
- package/dist/types/components/DIconBase/DIconBase.d.ts +13 -9
- package/dist/types/components/DInput/DInput.d.ts +3 -2
- package/dist/types/components/DInputCheck/DInputCheck.d.ts +2 -1
- package/dist/types/components/DInputCounter/DInputCounter.d.ts +3 -2
- package/dist/types/components/DInputCurrency/DInputCurrency.d.ts +4 -3
- package/dist/types/components/DInputMask/DInputMask.d.ts +7 -17
- package/dist/types/components/DInputPhone/DInputPhone.d.ts +2 -2
- package/dist/types/components/DInputPin/DInputPin.d.ts +3 -3
- package/dist/types/components/DInputRange/DInputRange.d.ts +2 -2
- package/dist/types/components/DInputSelect/DInputSelect.d.ts +3 -3
- package/dist/types/components/DInputSwitch/DInputSwitch.d.ts +2 -1
- package/dist/types/components/DLayout/DLayout.d.ts +22 -0
- package/dist/types/components/DLayout/components/DLayoutPane.d.ts +13 -0
- package/dist/types/components/DLayout/index.d.ts +3 -0
- package/dist/types/components/DListGroup/components/DListGroupItem.d.ts +4 -4
- package/dist/types/components/DModal/DModal.d.ts +3 -1
- package/dist/types/components/DOffcanvas/DOffcanvas.d.ts +3 -1
- package/dist/types/components/DOtp/DOtp.d.ts +16 -0
- package/dist/types/components/DOtp/DOtpspec.d.ts +0 -0
- package/dist/types/components/DOtp/components/OtpCountdown.d.ts +7 -0
- package/dist/types/components/DOtp/hooks/useCountdown.d.ts +4 -0
- package/dist/types/components/DOtp/index.d.ts +2 -0
- package/dist/types/components/DPaginator/DPaginator.d.ts +2 -27
- package/dist/types/components/DPasswordStrengthMeter/DPasswordStrengthMeter.d.ts +23 -0
- package/dist/types/components/DPasswordStrengthMeter/PasswordCheckItem.d.ts +7 -0
- package/dist/types/components/DPasswordStrengthMeter/PasswordCheckList.d.ts +14 -0
- package/dist/types/components/DPasswordStrengthMeter/PasswordStrength.d.ts +6 -0
- package/dist/types/components/DPasswordStrengthMeter/index.d.ts +3 -0
- package/dist/types/components/DPopover/DPopover.d.ts +1 -1
- package/dist/types/components/DProgress/DProgress.d.ts +2 -1
- package/dist/types/components/DSelect/DSelect.d.ts +3 -3
- package/dist/types/components/DTabs/DTabs.d.ts +2 -2
- package/dist/types/components/DTimeline/DTimeline.d.ts +15 -0
- package/dist/types/components/DTimeline/index.d.ts +2 -0
- package/dist/types/components/DToastContainer/useDToast.d.ts +2 -2
- package/dist/types/components/DTooltip/DTooltip.d.ts +1 -2
- package/dist/types/components/DVoucher/DVoucher.d.ts +14 -0
- package/dist/types/components/DVoucher/hooks/useScreenshot.d.ts +5 -0
- package/dist/types/components/DVoucher/hooks/useScreenshotDownload.d.ts +5 -0
- package/dist/types/components/DVoucher/hooks/useScreenshotWebShare.d.ts +5 -0
- package/dist/types/components/DVoucher/index.d.ts +2 -0
- package/dist/types/components/config.d.ts +0 -2
- package/dist/types/components/index.d.ts +8 -9
- package/dist/types/components/interface.d.ts +3 -8
- package/dist/types/contexts/DContext.d.ts +0 -2
- package/dist/types/hooks/tests/useDisableBodyScrollEffect.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useDisableInputWheel.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useFormatCurrency.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useInputCurrency.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useItemSelection.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useMediaBreakpointUp.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useMediaQuery.spec.d.ts +1 -0
- package/dist/types/hooks/tests/usePortal.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useProvidedRefOrCreate.spec.d.ts +1 -0
- package/dist/types/hooks/tests/useStackState.spec.d.ts +1 -0
- package/dist/types/hooks/useInputCurrency.d.ts +1 -1
- package/dist/types/hooks/useProvidedRefOrCreate.d.ts +1 -1
- package/dist/types/hooks/useResponsiveProp.d.ts +35 -0
- package/dist/types/types/polymorphic.d.ts +3 -3
- package/dist/types/utils/tests/attr-accept.spec.d.ts +1 -0
- package/dist/types/utils/tests/changeQueryString.spec.d.ts +1 -0
- package/dist/types/utils/tests/configureI18n.spec.d.ts +1 -0
- package/dist/types/utils/tests/formatCurrency.spec.d.ts +1 -0
- package/dist/types/utils/tests/getCssVariable.spec.d.ts +1 -0
- package/dist/types/utils/tests/getKeyboardFocusableElements.spec.d.ts +1 -0
- package/dist/types/utils/tests/getQueryString.spec.d.ts +1 -0
- package/dist/types/utils/tests/mediaQuery.spec.d.ts +1 -0
- package/dist/types/utils/tests/validatePhoneNumber.spec.d.ts +1 -0
- package/jest/setup.js +93 -2
- package/package.json +57 -57
- package/src/style/_shame.scss +42 -1
- package/src/style/abstracts/_mixins.scss +35 -23
- package/src/style/abstracts/_utilities.scss +70 -1
- package/src/style/abstracts/variables/_+import.scss +3 -2
- package/src/style/abstracts/variables/_alerts.scss +2 -0
- package/src/style/abstracts/variables/_body.scss +10 -3
- package/src/style/abstracts/variables/_border.scss +5 -5
- package/src/style/abstracts/variables/_buttons.scss +19 -11
- package/src/style/abstracts/variables/_cards.scss +6 -4
- package/src/style/abstracts/variables/_chips.scss +2 -2
- package/src/style/abstracts/variables/_colors.scss +147 -70
- package/src/style/abstracts/variables/_datepicker.scss +10 -9
- package/src/style/abstracts/variables/_dropdowns.scss +6 -4
- package/src/style/abstracts/variables/_forms.scss +4 -4
- package/src/style/abstracts/variables/_list-group.scss +2 -2
- package/src/style/abstracts/variables/_modals.scss +4 -3
- package/src/style/abstracts/variables/_offcanvas.scss +1 -0
- package/src/style/abstracts/variables/_pagination.scss +4 -4
- package/src/style/abstracts/variables/_shadow.scss +1 -0
- package/src/style/abstracts/variables/_tables.scss +8 -3
- package/src/style/abstracts/variables/_tooltip.scss +1 -1
- package/src/style/abstracts/variables/_typography.scss +7 -7
- package/src/style/base/_+import.scss +1 -0
- package/src/style/base/_alert.scss +1 -27
- package/src/style/base/_badge.scss +50 -12
- package/src/style/base/_buttons.scss +33 -30
- package/src/style/base/_dropdown.scss +18 -0
- package/src/style/base/_input-group.scss +5 -0
- package/src/style/base/_label.scss +0 -4
- package/src/style/base/_list-group.scss +6 -0
- package/src/style/base/_pagination.scss +2 -0
- package/src/style/base/_tables.scss +4 -0
- package/src/style/base/_tooltip.scss +1 -10
- package/src/style/components/_+import.scss +5 -4
- package/src/style/components/_d-avatar.scss +2 -20
- package/src/style/components/_d-box-file.scss +1 -1
- package/src/style/components/_d-box.scss +13 -0
- package/src/style/components/_d-carousel.scss +19 -1
- package/src/style/components/_d-credit-card.scss +67 -0
- package/src/style/components/_d-datepicker.scss +83 -26
- package/src/style/components/_d-icon.scss +10 -3
- package/src/style/components/_d-modal.scss +3 -0
- package/src/style/components/_d-stepper-desktop.scss +61 -65
- package/src/style/components/_d-stepper-mobile.scss +2 -2
- package/src/style/components/_d-tabs.scss +37 -0
- package/src/style/components/_d-timeline.scss +108 -0
- package/src/style/components/_d-voucher.scss +29 -0
- package/src/style/helpers/_color-bg.scss +13 -3
- package/src/style/root/_root.scss +109 -86
- package/dist/css/bootstrap-icons.css +0 -2106
- package/dist/css/bootstrap-icons.json +0 -2080
- package/dist/css/bootstrap-icons.min.css +0 -5
- package/dist/css/bootstrap-icons.scss +0 -2118
- package/dist/css/fonts/bootstrap-icons.woff +0 -0
- package/dist/css/fonts/bootstrap-icons.woff2 +0 -0
- package/dist/types/components/DInputCurrencyBase/DInputCurrencyBase.d.ts +0 -26
- package/dist/types/components/DInputCurrencyBase/index.d.ts +0 -2
- package/dist/types/components/DInputSearch/DInputSearch.d.ts +0 -17
- package/dist/types/components/DInputSearch/index.d.ts +0 -2
- package/dist/types/components/DList/DList.d.ts +0 -17
- package/dist/types/components/DList/components/DListItem.d.ts +0 -13
- package/dist/types/components/DList/index.d.ts +0 -3
- package/dist/types/components/DQuickActionButton/DQuickActionButton.d.ts +0 -20
- package/dist/types/components/DQuickActionButton/index.d.ts +0 -2
- package/dist/types/components/DQuickActionCheck/DQuickActionCheck.d.ts +0 -17
- package/dist/types/components/DQuickActionCheck/index.d.ts +0 -2
- package/dist/types/components/DQuickActionSelect/DQuickActionSelect.d.ts +0 -13
- package/dist/types/components/DQuickActionSelect/index.d.ts +0 -2
- package/dist/types/components/DQuickActionSwitch/DQuickActionSwitch.d.ts +0 -15
- package/dist/types/components/DQuickActionSwitch/index.d.ts +0 -2
- package/dist/types/components/DSkeleton/DSkeleton.d.ts +0 -11
- package/dist/types/components/DSkeleton/index.d.ts +0 -2
- package/dist/types/components/DTableHead/DTableHead.d.ts +0 -9
- package/dist/types/components/DTableHead/index.d.ts +0 -2
- package/src/style/components/_d-quick-action-button.scss +0 -121
- package/src/style/components/_d-quick-action-check.scss +0 -74
- package/src/style/components/_d-quick-action-select.scss +0 -58
- package/src/style/components/_d-quick-action-switch.scss +0 -64
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { useMemo, useEffect, useState, useCallback, useContext, createContext, Fragment, useLayoutEffect, forwardRef, useId, useRef, useSyncExternalStore } from 'react';
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
2
|
import classNames from 'classnames';
|
|
3
|
+
import React, { useEffect, useState, useCallback, useMemo, useContext, createContext, useLayoutEffect, useSyncExternalStore, forwardRef, useId, useRef } from 'react';
|
|
4
4
|
import { __rest } from 'tslib';
|
|
5
|
+
import * as LucideIcons from 'lucide-react';
|
|
5
6
|
import { createPortal } from 'react-dom';
|
|
7
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
6
8
|
import { fromEvent } from 'file-selector';
|
|
7
9
|
import { SplideSlide, Splide } from '@splidejs/react-splide';
|
|
8
10
|
import currency from 'currency.js';
|
|
@@ -12,57 +14,15 @@ import Select, { components } from 'react-select';
|
|
|
12
14
|
import { InputMask } from '@react-input/mask';
|
|
13
15
|
import ResponsivePagination from 'react-responsive-pagination';
|
|
14
16
|
import { useFloating, autoUpdate, offset, flip, shift, useClick, useDismiss, useRole, useInteractions, useId as useId$1, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
|
|
15
|
-
import ContentLoader from 'react-content-loader';
|
|
16
17
|
import { Toaster, toast } from 'react-hot-toast';
|
|
17
18
|
import { defaultCountries, parseCountry, usePhoneInput, CountrySelector } from 'react-international-phone';
|
|
18
19
|
import { PhoneNumberUtil } from 'google-libphonenumber';
|
|
20
|
+
import html2canvas from 'html2canvas';
|
|
19
21
|
import i18n from 'i18next';
|
|
20
22
|
import { initReactI18next } from 'react-i18next';
|
|
21
23
|
|
|
22
24
|
const PREFIX_BS = 'bs-';
|
|
23
25
|
|
|
24
|
-
function DIconBase({ icon, theme, style, className, size, loading = false, loadingDuration = 1.8, hasCircle = false, circleSize = `calc(var(--${PREFIX_BS}icon-size) * 1)`, color, backgroundColor, materialStyle = false, familyClass = 'bi', familyPrefix = 'bi-', dataAttributes, }) {
|
|
25
|
-
const colorStyle = useMemo(() => {
|
|
26
|
-
if (color) {
|
|
27
|
-
return { [`--${PREFIX_BS}icon-component-color`]: color };
|
|
28
|
-
}
|
|
29
|
-
if (theme) {
|
|
30
|
-
return { [`--${PREFIX_BS}icon-component-color`]: `var(--${PREFIX_BS}${theme})` };
|
|
31
|
-
}
|
|
32
|
-
return {};
|
|
33
|
-
}, [color, theme]);
|
|
34
|
-
const backgroundStyle = useMemo(() => {
|
|
35
|
-
if (backgroundColor) {
|
|
36
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: backgroundColor };
|
|
37
|
-
}
|
|
38
|
-
if (hasCircle) {
|
|
39
|
-
if (theme) {
|
|
40
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}${theme}-rgb), 0.1)` };
|
|
41
|
-
}
|
|
42
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}body-color-rgb), 0.1)` };
|
|
43
|
-
}
|
|
44
|
-
return {};
|
|
45
|
-
}, [backgroundColor, hasCircle, theme]);
|
|
46
|
-
const circleSizeStyle = useMemo(() => {
|
|
47
|
-
if (hasCircle) {
|
|
48
|
-
return { [`--${PREFIX_BS}icon-component-padding`]: circleSize };
|
|
49
|
-
}
|
|
50
|
-
return { [`--${PREFIX_BS}icon-component-padding`]: '0' };
|
|
51
|
-
}, [circleSize, hasCircle]);
|
|
52
|
-
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ [`--${PREFIX_BS}icon-component-loading-duration`]: `${loadingDuration}s` }, size && { [`--${PREFIX_BS}icon-component-size`]: size }), colorStyle), backgroundStyle), circleSizeStyle), style)), [size, loadingDuration, colorStyle, backgroundStyle, circleSizeStyle, style]);
|
|
53
|
-
const generateClasses = useMemo(() => (Object.assign(Object.assign({ 'd-icon': true, [familyClass]: true, 'd-icon-loading': loading }, !materialStyle && {
|
|
54
|
-
[`${familyPrefix}${icon}`]: true,
|
|
55
|
-
}), className && { [className]: true })), [
|
|
56
|
-
familyClass,
|
|
57
|
-
loading,
|
|
58
|
-
className,
|
|
59
|
-
materialStyle,
|
|
60
|
-
familyPrefix,
|
|
61
|
-
icon,
|
|
62
|
-
]);
|
|
63
|
-
return (jsx("i", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: materialStyle && icon })));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
26
|
function useDisableBodyScrollEffect(disable) {
|
|
67
27
|
useEffect(() => {
|
|
68
28
|
if (disable) {
|
|
@@ -219,7 +179,10 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
|
|
|
219
179
|
return (jsxs(DPortalContext.Provider, { value: value, children: [children, created && createPortal(
|
|
220
180
|
// eslint-disable-next-line max-len
|
|
221
181
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
222
|
-
jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children:
|
|
182
|
+
jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: jsx(AnimatePresence, { children: stack.flatMap(({ Component, name, payload, }) => [
|
|
183
|
+
jsx(motion.div, { className: "backdrop", initial: { opacity: 0 }, animate: { opacity: 0.5 }, exit: { opacity: 0, transition: { delay: 0.3 } }, transition: { duration: 0.15, ease: 'linear' } }, `${name}-backdrop`),
|
|
184
|
+
jsx(Component, { name: name, payload: payload }, name),
|
|
185
|
+
]) }) }), document.getElementById(portalName))] }));
|
|
223
186
|
}
|
|
224
187
|
function useDPortalContext() {
|
|
225
188
|
const context = useContext(DPortalContext);
|
|
@@ -248,33 +211,27 @@ const DEFAULT_STATE = {
|
|
|
248
211
|
materialStyle: false,
|
|
249
212
|
},
|
|
250
213
|
iconMap: {
|
|
251
|
-
x: '
|
|
252
|
-
xLg: '
|
|
253
|
-
chevronUp: '
|
|
254
|
-
chevronDown: '
|
|
255
|
-
chevronLeft: '
|
|
256
|
-
chevronRight: '
|
|
257
|
-
upload: '
|
|
258
|
-
calendar: '
|
|
259
|
-
check: '
|
|
214
|
+
x: 'X',
|
|
215
|
+
xLg: 'X',
|
|
216
|
+
chevronUp: 'ChevronUp',
|
|
217
|
+
chevronDown: 'ChevronDown',
|
|
218
|
+
chevronLeft: 'ChevronLeft',
|
|
219
|
+
chevronRight: 'ChevronRight',
|
|
220
|
+
upload: 'Upload',
|
|
221
|
+
calendar: 'Calendar',
|
|
222
|
+
check: 'Check',
|
|
260
223
|
alert: {
|
|
261
|
-
warning: '
|
|
262
|
-
danger: '
|
|
263
|
-
success: '
|
|
264
|
-
info: '
|
|
265
|
-
dark: 'info-circle',
|
|
266
|
-
light: 'info-circle',
|
|
267
|
-
primary: 'info-circle',
|
|
268
|
-
secondary: 'info-circle',
|
|
224
|
+
warning: 'AlertCircle',
|
|
225
|
+
danger: 'AlertTriangle',
|
|
226
|
+
success: 'CheckCircle',
|
|
227
|
+
info: 'Info',
|
|
269
228
|
},
|
|
270
229
|
input: {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
increase: 'plus-square',
|
|
277
|
-
decrease: 'dash-square',
|
|
230
|
+
search: 'Search',
|
|
231
|
+
show: 'Eye',
|
|
232
|
+
hide: 'EyeOff',
|
|
233
|
+
increase: 'Plus',
|
|
234
|
+
decrease: 'Minus',
|
|
278
235
|
},
|
|
279
236
|
},
|
|
280
237
|
breakpoints: {
|
|
@@ -321,31 +278,170 @@ function useDContext() {
|
|
|
321
278
|
return context;
|
|
322
279
|
}
|
|
323
280
|
|
|
281
|
+
function subscribeToMediaQuery(query, callback) {
|
|
282
|
+
const mediaQueryList = window.matchMedia(query);
|
|
283
|
+
mediaQueryList.addEventListener('change', callback);
|
|
284
|
+
return () => {
|
|
285
|
+
mediaQueryList.removeEventListener('change', callback);
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function checkMediaQuery(query) {
|
|
289
|
+
return window.matchMedia(query).matches;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function useMediaQuery(mediaQuery, useListener = false) {
|
|
293
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
294
|
+
const noop = (_) => () => { };
|
|
295
|
+
return useSyncExternalStore(useListener ? (cb) => subscribeToMediaQuery(mediaQuery, cb) : noop, () => (mediaQuery ? checkMediaQuery(mediaQuery) : true), () => false);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function useMediaBreakpointUp(breakpoint, useListener = false) {
|
|
299
|
+
const { breakpoints } = useDContext();
|
|
300
|
+
const mediaQuery = useMemo(() => (`(min-width: ${breakpoints[breakpoint]})`), [breakpoint, breakpoints]);
|
|
301
|
+
return useMediaQuery(mediaQuery, useListener);
|
|
302
|
+
}
|
|
303
|
+
function useMediaBreakpointUpXs(useListener = false) {
|
|
304
|
+
return useMediaBreakpointUp('xs', useListener);
|
|
305
|
+
}
|
|
306
|
+
function useMediaBreakpointUpSm(useListener = false) {
|
|
307
|
+
return useMediaBreakpointUp('sm', useListener);
|
|
308
|
+
}
|
|
309
|
+
function useMediaBreakpointUpMd(useListener = false) {
|
|
310
|
+
return useMediaBreakpointUp('md', useListener);
|
|
311
|
+
}
|
|
312
|
+
function useMediaBreakpointUpLg(useListener = false) {
|
|
313
|
+
return useMediaBreakpointUp('lg', useListener);
|
|
314
|
+
}
|
|
315
|
+
function useMediaBreakpointUpXl(useListener = false) {
|
|
316
|
+
return useMediaBreakpointUp('xl', useListener);
|
|
317
|
+
}
|
|
318
|
+
function useMediaBreakpointUpXxl(useListener = false) {
|
|
319
|
+
return useMediaBreakpointUp('xxl', useListener);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* React hook to resolve a responsive property value based on the current viewport breakpoint.
|
|
324
|
+
*
|
|
325
|
+
* Given a `ResponsiveProp` object, this hook returns the value for the highest matching breakpoint.
|
|
326
|
+
* If multiple breakpoints match, the value for the largest (highest) breakpoint is used.
|
|
327
|
+
* If no breakpoints match, `undefined` is returned.
|
|
328
|
+
*
|
|
329
|
+
* @param useListener - Whether to listen for breakpoint changes (default: false).
|
|
330
|
+
* @returns An object with a `responsivePropValue` function that takes a
|
|
331
|
+
* `ResponsiveProp` and returns the resolved value.
|
|
332
|
+
*
|
|
333
|
+
* Usage example:
|
|
334
|
+
* ```ts
|
|
335
|
+
* const { responsivePropValue } = useResponsiveProp();
|
|
336
|
+
* const value = responsivePropValue({ xs: "A", md: "B", xl: "C" });
|
|
337
|
+
* // value will be "C" if xl breakpoint is active, "B" if md is active, etc.
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
function useResponsiveProp(useListener = false) {
|
|
341
|
+
const bpXsUp = useMediaBreakpointUpXs(useListener);
|
|
342
|
+
const bpSmUp = useMediaBreakpointUpSm(useListener);
|
|
343
|
+
const bpMdUp = useMediaBreakpointUpMd(useListener);
|
|
344
|
+
const bpLgUp = useMediaBreakpointUpLg(useListener);
|
|
345
|
+
const bpXlUp = useMediaBreakpointUpXl(useListener);
|
|
346
|
+
const bpXxlUp = useMediaBreakpointUpXxl(useListener);
|
|
347
|
+
const responsivePropValue = useCallback((prop) => {
|
|
348
|
+
// Pick the highest matched breakpoint value that is defined in prop
|
|
349
|
+
if (prop.xxl !== undefined && bpXxlUp)
|
|
350
|
+
return prop.xxl;
|
|
351
|
+
if (prop.xl !== undefined && bpXlUp)
|
|
352
|
+
return prop.xl;
|
|
353
|
+
if (prop.lg !== undefined && bpLgUp)
|
|
354
|
+
return prop.lg;
|
|
355
|
+
if (prop.md !== undefined && bpMdUp)
|
|
356
|
+
return prop.md;
|
|
357
|
+
if (prop.sm !== undefined && bpSmUp)
|
|
358
|
+
return prop.sm;
|
|
359
|
+
if (prop.xs !== undefined && bpXsUp)
|
|
360
|
+
return prop.xs;
|
|
361
|
+
// Fallback: return undefined if no breakpoint matches
|
|
362
|
+
return undefined;
|
|
363
|
+
}, [bpSmUp, bpMdUp, bpLgUp, bpXlUp, bpXxlUp, bpXsUp]);
|
|
364
|
+
return { responsivePropValue };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function DIconBase({ icon, color, style, className, size, useListenerSize = false, hasCircle = false, materialStyle = false, familyClass, familyPrefix, strokeWidth = 2, dataAttributes, }) {
|
|
368
|
+
// If materialStyle is true, use Material Design icons (legacy)
|
|
369
|
+
const useMaterialIcons = materialStyle;
|
|
370
|
+
// Get Lucide icon component
|
|
371
|
+
const LucideIcon = useMemo(() => {
|
|
372
|
+
if (useMaterialIcons)
|
|
373
|
+
return null;
|
|
374
|
+
// Try to find the icon in Lucide (expects PascalCase)
|
|
375
|
+
const icons = LucideIcons;
|
|
376
|
+
return icons[icon] || null;
|
|
377
|
+
}, [icon, useMaterialIcons]);
|
|
378
|
+
const colorStyle = useMemo(() => {
|
|
379
|
+
if (color) {
|
|
380
|
+
return { [`--${PREFIX_BS}icon-component-color`]: `var(--${PREFIX_BS}${color})` };
|
|
381
|
+
}
|
|
382
|
+
return {};
|
|
383
|
+
}, [color]);
|
|
384
|
+
const backgroundStyle = useMemo(() => {
|
|
385
|
+
if (hasCircle) {
|
|
386
|
+
if (color) {
|
|
387
|
+
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}${color}-rgb), 0.1)` };
|
|
388
|
+
}
|
|
389
|
+
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}body-color-rgb), 0.1)` };
|
|
390
|
+
}
|
|
391
|
+
return {};
|
|
392
|
+
}, [hasCircle, color]);
|
|
393
|
+
const { responsivePropValue } = useResponsiveProp(useListenerSize);
|
|
394
|
+
const resolvedSize = useMemo(() => {
|
|
395
|
+
if (!size)
|
|
396
|
+
return undefined;
|
|
397
|
+
if (typeof size === 'string')
|
|
398
|
+
return size;
|
|
399
|
+
return responsivePropValue(size);
|
|
400
|
+
}, [responsivePropValue, size]);
|
|
401
|
+
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, resolvedSize && { [`--${PREFIX_BS}icon-component-size`]: resolvedSize }), colorStyle), backgroundStyle), hasCircle && { [`--${PREFIX_BS}icon-component-padding`]: `calc(var(--${PREFIX_BS}icon-component-size, 24px) * 0.4)` }), style)), [resolvedSize, colorStyle, backgroundStyle, hasCircle, style]);
|
|
402
|
+
const generateClasses = useMemo(() => (Object.assign({ 'd-icon': true }, className && { [className]: true })), [className]);
|
|
403
|
+
const iconSize = useMemo(() => {
|
|
404
|
+
if (resolvedSize) {
|
|
405
|
+
const numSize = parseInt(resolvedSize, 10);
|
|
406
|
+
return !Number.isNaN(numSize) ? numSize : resolvedSize;
|
|
407
|
+
}
|
|
408
|
+
return undefined;
|
|
409
|
+
}, [resolvedSize]);
|
|
410
|
+
// Render Material Design icon (legacy support)
|
|
411
|
+
if (useMaterialIcons) {
|
|
412
|
+
return (jsx("i", Object.assign({ className: classNames(generateClasses, familyClass), style: generateStyleVariables }, dataAttributes, { children: icon })));
|
|
413
|
+
}
|
|
414
|
+
// Render Lucide icon
|
|
415
|
+
if (!LucideIcon) {
|
|
416
|
+
if (familyClass && familyPrefix) {
|
|
417
|
+
return (jsx("i", Object.assign({ className: classNames(generateClasses, familyClass, `${familyPrefix}${icon}`), style: generateStyleVariables }, dataAttributes)));
|
|
418
|
+
}
|
|
419
|
+
// eslint-disable-next-line no-console
|
|
420
|
+
console.warn(`Icon "${icon}" not found in Lucide. Make sure to use PascalCase names (e.g., "Home", "User", "Settings")`);
|
|
421
|
+
return (jsx("span", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: "?" })));
|
|
422
|
+
}
|
|
423
|
+
return (jsx("span", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: jsx(LucideIcon, { size: iconSize || 24, strokeWidth: strokeWidth }) })));
|
|
424
|
+
}
|
|
425
|
+
|
|
324
426
|
function DIcon(_a) {
|
|
325
427
|
var { familyClass: propFamilyClass, familyPrefix: propFamilyPrefix, materialStyle: propMaterialStyle } = _a, props = __rest(_a, ["familyClass", "familyPrefix", "materialStyle"]);
|
|
326
428
|
const { icon: { familyClass, familyPrefix, materialStyle, }, } = useDContext();
|
|
327
429
|
return (jsx(DIconBase, Object.assign({ familyClass: propFamilyClass || familyClass, familyPrefix: propFamilyPrefix || familyPrefix, materialStyle: propMaterialStyle || materialStyle }, props)));
|
|
328
430
|
}
|
|
329
431
|
|
|
330
|
-
function DAlert({
|
|
432
|
+
function DAlert({ color = 'success', icon: iconProp, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle = false, iconClose: iconCloseProp, iconCloseFamilyClass, iconCloseFamilyPrefix, iconCloseMaterialStyle = false, showClose, onClose, children, id, className, style, dataAttributes, }) {
|
|
331
433
|
const { iconMap: { alert, xLg, }, } = useDContext();
|
|
332
|
-
const icon = useMemo(() => iconProp || alert[
|
|
434
|
+
const icon = useMemo(() => iconProp || alert[color], [alert, iconProp, color]);
|
|
333
435
|
const iconClose = useMemo(() => (iconCloseProp || xLg), [iconCloseProp, xLg]);
|
|
334
|
-
const generateClasses = useMemo(() => (Object.assign({ alert: true, [`alert-${
|
|
436
|
+
const generateClasses = useMemo(() => (Object.assign({ alert: true, [`alert-${color}`]: true, 'fade show': !!showClose }, className && { [className]: true })), [color, showClose, className]);
|
|
335
437
|
return (jsxs("div", Object.assign({ className: classNames(generateClasses), style: style, role: "alert", id: id }, dataAttributes, { children: [icon && (jsx(DIcon, { className: "alert-icon", icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsx("div", { className: "alert-text", children: children }), showClose && (jsx("button", { type: "button", className: "d-close", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { icon: iconClose, familyClass: iconCloseFamilyClass, familyPrefix: iconCloseFamilyPrefix, materialStyle: iconCloseMaterialStyle }) }))] })));
|
|
336
438
|
}
|
|
337
439
|
|
|
338
|
-
function DAvatar({ id, size, image, name: nameProp, useNameAsInitials = false,
|
|
339
|
-
const generateClasses = useMemo(() => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
return {
|
|
344
|
-
'd-avatar': true,
|
|
345
|
-
[variantClass]: true,
|
|
346
|
-
[`d-avatar-${size}`]: !!size,
|
|
347
|
-
};
|
|
348
|
-
}, [variant, theme, size]);
|
|
440
|
+
function DAvatar({ id, size, image, name: nameProp, useNameAsInitials = false, className, style, dataAttributes, }) {
|
|
441
|
+
const generateClasses = useMemo(() => ({
|
|
442
|
+
'd-avatar': true,
|
|
443
|
+
[`d-avatar-${size}`]: !!size,
|
|
444
|
+
}), [size]);
|
|
349
445
|
const name = useMemo(() => {
|
|
350
446
|
if (!nameProp) {
|
|
351
447
|
return undefined;
|
|
@@ -358,16 +454,21 @@ function DAvatar({ id, size, image, name: nameProp, useNameAsInitials = false, t
|
|
|
358
454
|
return (jsxs("div", Object.assign({ className: classNames(generateClasses, className), style: style, id: id }, dataAttributes, { children: [image && jsx("img", { src: image, alt: nameProp, className: "d-avatar-img" }), (name && !image) && jsx("span", { className: "d-avatar-name", children: name })] })));
|
|
359
455
|
}
|
|
360
456
|
|
|
361
|
-
function DBadge({ text, soft = false,
|
|
457
|
+
function DBadge({ text, soft = false, color = 'primary', id, rounded, className, size, style, iconStart, iconEnd, iconMaterialStyle, iconFamilyClass, iconFamilyPrefix, dataAttributes, }) {
|
|
362
458
|
const generateClasses = useMemo(() => ({
|
|
363
459
|
badge: true,
|
|
364
|
-
[`badge-${
|
|
365
|
-
[`badge-soft-${
|
|
460
|
+
[`badge-${color}`]: !!color && !soft,
|
|
461
|
+
[`badge-soft-${color}`]: !!color && soft,
|
|
366
462
|
'rounded-pill': !!rounded,
|
|
367
|
-
|
|
463
|
+
[`badge-${size}`]: !!size,
|
|
464
|
+
}), [rounded, soft, color, size]);
|
|
368
465
|
return (jsxs("span", Object.assign({ className: classNames(generateClasses, className), style: style }, id && { id }, dataAttributes, { children: [iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsx("span", { children: text }), iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }))] })));
|
|
369
466
|
}
|
|
370
467
|
|
|
468
|
+
function DBox({ className, style, children, dataAttributes, }) {
|
|
469
|
+
return (jsx("div", Object.assign({ style: style, className: classNames('d-box', className) }, dataAttributes, { children: children })));
|
|
470
|
+
}
|
|
471
|
+
|
|
371
472
|
/* eslint-disable */
|
|
372
473
|
/**
|
|
373
474
|
* This file is originally from `@primer/react`
|
|
@@ -389,7 +490,7 @@ function useProvidedRefOrCreate(providedRef) {
|
|
|
389
490
|
}
|
|
390
491
|
|
|
391
492
|
function DInput(_a, ref) {
|
|
392
|
-
var { id: idProp, style, className, label = '',
|
|
493
|
+
var { id: idProp, style, className, label = '', disabled = false, loading = false, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, iconStart, iconStartDisabled, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconStartMaterialStyle, iconEnd, iconEndDisabled, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, iconEndMaterialStyle, hint, size, invalid = false, valid = false, floatingLabel = false, inputStart, inputEnd, value, placeholder = '', dataAttributes, readonly, onChange, onIconStartClick, onIconEndClick } = _a, inputProps = __rest(_a, ["id", "style", "className", "label", "disabled", "loading", "iconFamilyClass", "iconFamilyPrefix", "iconMaterialStyle", "iconStart", "iconStartDisabled", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconStartMaterialStyle", "iconEnd", "iconEndDisabled", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "iconEndMaterialStyle", "hint", "size", "invalid", "valid", "floatingLabel", "inputStart", "inputEnd", "value", "placeholder", "dataAttributes", "readonly", "onChange", "onIconStartClick", "onIconEndClick"]);
|
|
393
494
|
const inputRef = useProvidedRefOrCreate(ref);
|
|
394
495
|
const innerId = useId();
|
|
395
496
|
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -426,7 +527,7 @@ function DInput(_a, ref) {
|
|
|
426
527
|
const inputComponent = useMemo(() => (jsx("input", Object.assign({ ref: inputRef, id: id, className: classNames('form-control', {
|
|
427
528
|
'is-invalid': invalid,
|
|
428
529
|
'is-valid': valid,
|
|
429
|
-
}), disabled: disabled || loading, value: value, onChange: handleOnChange }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
|
|
530
|
+
}), disabled: disabled || loading, readOnly: readonly, value: value, onChange: handleOnChange }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
|
|
430
531
|
ariaDescribedby,
|
|
431
532
|
disabled,
|
|
432
533
|
handleOnChange,
|
|
@@ -439,14 +540,11 @@ function DInput(_a, ref) {
|
|
|
439
540
|
floatingLabel,
|
|
440
541
|
valid,
|
|
441
542
|
value,
|
|
543
|
+
readonly,
|
|
442
544
|
]);
|
|
443
|
-
const labelComponent = useMemo(() => (
|
|
545
|
+
const labelComponent = useMemo(() => (jsx("label", { htmlFor: id, children: label })), [
|
|
444
546
|
id,
|
|
445
547
|
label,
|
|
446
|
-
labelIcon,
|
|
447
|
-
labelIconFamilyClass,
|
|
448
|
-
labelIconFamilyPrefix,
|
|
449
|
-
labelIconMaterialStyle,
|
|
450
548
|
]);
|
|
451
549
|
const dynamicComponent = useMemo(() => {
|
|
452
550
|
if (floatingLabel) {
|
|
@@ -575,7 +673,7 @@ async function urlToFile(url) {
|
|
|
575
673
|
null,
|
|
576
674
|
{
|
|
577
675
|
code: ErrorCodes.FailedFetch,
|
|
578
|
-
message: `Failed to fetch file from ${url}`,
|
|
676
|
+
message: `Failed to fetch file from ${url} (HTTP ${res.status})`,
|
|
579
677
|
},
|
|
580
678
|
];
|
|
581
679
|
}
|
|
@@ -585,11 +683,13 @@ async function urlToFile(url) {
|
|
|
585
683
|
return [file, null];
|
|
586
684
|
}
|
|
587
685
|
catch (error) {
|
|
686
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
687
|
+
const isCorsError = errorMessage.includes('CORS') || errorMessage.includes('Failed to fetch');
|
|
588
688
|
return [
|
|
589
689
|
null,
|
|
590
690
|
{
|
|
591
691
|
code: ErrorCodes.FailedFetch,
|
|
592
|
-
message: `Failed to fetch file from ${url}}`,
|
|
692
|
+
message: `Failed to fetch file from ${url}${isCorsError ? ' (CORS error - file may not be accessible from this domain)' : ` (${errorMessage})`}`,
|
|
593
693
|
},
|
|
594
694
|
];
|
|
595
695
|
}
|
|
@@ -855,43 +955,77 @@ function DBoxFile(_a) {
|
|
|
855
955
|
const { iconMap: { upload } } = useDContext();
|
|
856
956
|
const icon = useMemo(() => iconProp || upload, [iconProp, upload]);
|
|
857
957
|
const { inputRef, rootRef, isDragValid, isDragInvalid, acceptAttr, files, handleFileSelect, handleDrop, handleDragEnter, handleDragLeave, handleClick, handleKeyDown, handleRemoveFile, openFileDialog, } = useDBoxFile(props);
|
|
858
|
-
return (jsxs(Fragment
|
|
958
|
+
return (jsxs(Fragment, { children: [jsx("section", Object.assign({ className: classNames('d-box-file', {
|
|
859
959
|
'd-box-file-selected': files.length > 0,
|
|
860
960
|
'd-box-file-disabled': props.disabled,
|
|
861
961
|
'd-box-file-valid': isDragValid,
|
|
862
962
|
'd-box-file-invalid': isDragInvalid,
|
|
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'
|
|
963
|
+
}, 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 }), icon && iconProp !== false && (jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsx("div", { className: "d-box-content", children: typeof children === 'function'
|
|
864
964
|
? children(openFileDialog)
|
|
865
|
-
: children })] })) })), !!files.length && (jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsx(ForwardedDInput, { value: file.name, iconStart: "
|
|
965
|
+
: children || (jsx("p", { className: "text-center m-0", children: "Drag and drop some files here, or click to select files" })) })] })) })), !!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}`))) }))] }));
|
|
866
966
|
}
|
|
867
967
|
|
|
868
|
-
|
|
869
|
-
const
|
|
968
|
+
const DButton = forwardRef((props, ref) => {
|
|
969
|
+
const { color = 'primary', size, variant, text, children, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartMaterialStyle, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndMaterialStyle, loading = false, loadingText, loadingAriaLabel, disabled = false, className, style, dataAttributes, onClick, type = 'button' } = props, rest = __rest(props, ["color", "size", "variant", "text", "children", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartMaterialStyle", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndMaterialStyle", "loading", "loadingText", "loadingAriaLabel", "disabled", "className", "style", "dataAttributes", "onClick", "type"]);
|
|
970
|
+
const [buttonWidth, setButtonWidth] = useState();
|
|
971
|
+
const buttonRef = useRef(null);
|
|
972
|
+
const isDisabled = useMemo(() => disabled || loading, [disabled, loading]);
|
|
973
|
+
const content = useMemo(() => children || text, [children, text]);
|
|
974
|
+
const classes = useMemo(() => {
|
|
870
975
|
const variantClass = variant
|
|
871
|
-
? `btn-${variant}-${
|
|
872
|
-
: `btn-${
|
|
873
|
-
return
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
976
|
+
? `btn-${variant}-${color}`
|
|
977
|
+
: `btn-${color}`;
|
|
978
|
+
return {
|
|
979
|
+
btn: true,
|
|
980
|
+
[variantClass]: true,
|
|
981
|
+
[`btn-${size}`]: !!size,
|
|
982
|
+
loading,
|
|
983
|
+
};
|
|
984
|
+
}, [variant, color, size, loading]);
|
|
985
|
+
const ariaLabel = useMemo(() => {
|
|
986
|
+
const ariaLabelProp = rest['aria-label'];
|
|
987
|
+
return loading
|
|
988
|
+
? loadingAriaLabel || ariaLabelProp || text
|
|
989
|
+
: ariaLabelProp || text;
|
|
990
|
+
}, [loading, loadingAriaLabel, rest, text]);
|
|
991
|
+
const handleClick = useCallback((event) => {
|
|
992
|
+
if (disabled || loading) {
|
|
993
|
+
event.preventDefault();
|
|
994
|
+
return;
|
|
878
995
|
}
|
|
879
996
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
880
|
-
}, [
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
}
|
|
997
|
+
}, [disabled, loading, onClick]);
|
|
998
|
+
useEffect(() => {
|
|
999
|
+
if (!loading && buttonRef.current) {
|
|
1000
|
+
const width = buttonRef.current.offsetWidth;
|
|
1001
|
+
if (width > 0)
|
|
1002
|
+
setButtonWidth(width);
|
|
1003
|
+
}
|
|
1004
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1005
|
+
}, [content, iconEnd, iconStart]);
|
|
1006
|
+
return (jsxs("button", Object.assign({ ref: (node) => {
|
|
1007
|
+
buttonRef.current = node;
|
|
1008
|
+
if (typeof ref === 'function')
|
|
1009
|
+
ref(node);
|
|
1010
|
+
// eslint-disable-next-line max-len
|
|
1011
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
1012
|
+
else if (ref)
|
|
1013
|
+
ref.current = node;
|
|
1014
|
+
},
|
|
1015
|
+
// eslint-disable-next-line react/button-has-type
|
|
1016
|
+
type: type, className: classNames(classes, className), style: Object.assign(Object.assign({}, style), (loading && buttonWidth
|
|
1017
|
+
? { minWidth: `${buttonWidth}px` }
|
|
1018
|
+
: undefined)), disabled: isDisabled, "aria-label": ariaLabel, "aria-busy": loading, "aria-disabled": isDisabled, onClick: handleClick }, dataAttributes, rest, { children: [loading && (jsxs("span", { className: "btn-loading", children: [jsx("span", { className: "spinner-border spinner-border-sm", "aria-hidden": "true" }), loadingText && jsx("span", { role: "status", children: loadingText })] })), !loading && (jsxs(Fragment, { children: [iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle })), content, iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle }))] }))] })));
|
|
1019
|
+
});
|
|
1020
|
+
DButton.displayName = 'DButton';
|
|
887
1021
|
|
|
888
|
-
function DButtonIcon({ id, icon, size, className, variant, state, loadingAriaLabel, iconMaterialStyle, ariaLabel,
|
|
1022
|
+
function DButtonIcon({ id, icon, size, className, variant, state, loadingAriaLabel, iconMaterialStyle, ariaLabel, color = 'primary', type = 'button', loading = false, disabled = false, stopPropagationEnabled = true, style, iconFamilyClass, iconFamilyPrefix, dataAttributes, onClick, }) {
|
|
889
1023
|
const generateClasses = useMemo(() => {
|
|
890
1024
|
const variantClass = variant
|
|
891
|
-
? `btn-${variant}-${
|
|
892
|
-
: `btn-${
|
|
1025
|
+
? `btn-${variant}-${color}`
|
|
1026
|
+
: `btn-${color}`;
|
|
893
1027
|
return Object.assign(Object.assign(Object.assign({ 'btn d-button-icon': true, [variantClass]: true }, size && { [`btn-${size}`]: true }), (state && state !== 'disabled') && { [state]: true }), { loading });
|
|
894
|
-
}, [variant,
|
|
1028
|
+
}, [variant, color, size, state, loading]);
|
|
895
1029
|
const clickHandler = useCallback((event) => {
|
|
896
1030
|
if (stopPropagationEnabled) {
|
|
897
1031
|
event.stopPropagation();
|
|
@@ -952,11 +1086,11 @@ var DCarousel$1 = Object.assign(ForwardedDCarousel, {
|
|
|
952
1086
|
Slide: DCarouselSlide,
|
|
953
1087
|
});
|
|
954
1088
|
|
|
955
|
-
function DChip({
|
|
1089
|
+
function DChip({ color = 'primary', text, icon, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, iconClose: iconCloseProp, iconCloseFamilyClass, iconCloseFamilyPrefix, iconCloseMaterialStyle, showClose = false, closeAriaLabel = 'close', className, style, dataAttributes, onClose, }) {
|
|
956
1090
|
const generateClasses = useMemo(() => ({
|
|
957
1091
|
'd-chip': true,
|
|
958
|
-
[`d-chip-${
|
|
959
|
-
}), [
|
|
1092
|
+
[`d-chip-${color}`]: !!color,
|
|
1093
|
+
}), [color]);
|
|
960
1094
|
const { iconMap: { xLg, }, } = useDContext();
|
|
961
1095
|
const iconClose = useMemo(() => iconCloseProp || xLg, [iconCloseProp, xLg]);
|
|
962
1096
|
return (jsxs("span", Object.assign({ className: classNames(generateClasses, className), style: style }, dataAttributes, { children: [icon && (jsx("div", { className: "d-chip-icon-container", children: jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }) })), jsx("span", { children: text }), showClose && (jsx("button", { type: "button", className: "d-chip-icon-container", onClick: onClose, "aria-label": closeAriaLabel, children: jsx(DIcon, { icon: iconClose, familyClass: iconCloseFamilyClass, familyPrefix: iconCloseFamilyPrefix, materialStyle: iconCloseMaterialStyle }) }))] })));
|
|
@@ -979,7 +1113,7 @@ function DCollapse({ id, className, style, Component, hasSeparator = false, defa
|
|
|
979
1113
|
const generateStyles = useMemo(() => ({
|
|
980
1114
|
[`--${PREFIX_BS}collapse-separator-display`]: hasSeparator ? 'block' : 'none',
|
|
981
1115
|
}), [hasSeparator]);
|
|
982
|
-
return (jsxs("div", Object.assign({ id: id, className: classNames('collapse-container', className), style: style }, dataAttributes, { children: [jsxs("button", { className: "collapse-button", type: "button", onClick: onChangeCollapse, children: [jsx("div", { className: "flex-grow-1", children: Component }), jsx(DIcon, { color:
|
|
1116
|
+
return (jsxs("div", Object.assign({ id: id, className: classNames('collapse-container', className), style: style }, dataAttributes, { children: [jsxs("button", { className: "collapse-button", type: "button", onClick: onChangeCollapse, children: [jsx("div", { className: "flex-grow-1", children: Component }), jsx(DIcon, { color: "gray", size: "1rem", icon: collapsed ? iconOpen : iconClose, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })] }), !collapsed && (jsx("div", { className: classNames({
|
|
983
1117
|
'collapse-body': true,
|
|
984
1118
|
}), style: generateStyles, children: children }))] })));
|
|
985
1119
|
}
|
|
@@ -1018,7 +1152,7 @@ const ForwardedDDatePickerInput = forwardRef(DDatePickerInput);
|
|
|
1018
1152
|
ForwardedDDatePickerInput.displayName = 'DDatePickerInput';
|
|
1019
1153
|
|
|
1020
1154
|
function DInputCheck(_a) {
|
|
1021
|
-
var { id: idProp, type, name, label, ariaLabel, checked = false, disabled = false, invalid = false, valid = false, indeterminate, value, hint, onChange, className, style, dataAttributes } = _a, props = __rest(_a, ["id", "type", "name", "label", "ariaLabel", "checked", "disabled", "invalid", "valid", "indeterminate", "value", "hint", "onChange", "className", "style", "dataAttributes"]);
|
|
1155
|
+
var { id: idProp, type, name, label, ariaLabel, checked = false, disabled = false, invalid = false, valid = false, indeterminate, inputClassName, value, hint, onChange, className, style, dataAttributes } = _a, props = __rest(_a, ["id", "type", "name", "label", "ariaLabel", "checked", "disabled", "invalid", "valid", "indeterminate", "inputClassName", "value", "hint", "onChange", "className", "style", "dataAttributes"]);
|
|
1022
1156
|
const innerRef = useRef(null);
|
|
1023
1157
|
const innerId = useId();
|
|
1024
1158
|
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -1046,11 +1180,11 @@ function DInputCheck(_a) {
|
|
|
1046
1180
|
const inputComponent = useMemo(() => (jsx("input", Object.assign({ ref: innerRef, onChange: handleChange, className: classNames('form-check-input', {
|
|
1047
1181
|
'is-invalid': invalid,
|
|
1048
1182
|
'is-valid': valid,
|
|
1049
|
-
},
|
|
1183
|
+
}, inputClassName), style: style, id: id, disabled: disabled, type: type, name: name, value: value, "aria-label": ariaLabel }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, props))), [
|
|
1050
1184
|
handleChange,
|
|
1051
1185
|
invalid,
|
|
1052
1186
|
valid,
|
|
1053
|
-
|
|
1187
|
+
inputClassName,
|
|
1054
1188
|
style,
|
|
1055
1189
|
id,
|
|
1056
1190
|
disabled,
|
|
@@ -1064,7 +1198,7 @@ function DInputCheck(_a) {
|
|
|
1064
1198
|
if (!label) {
|
|
1065
1199
|
return inputComponent;
|
|
1066
1200
|
}
|
|
1067
|
-
return (jsxs("div", Object.assign({ className:
|
|
1201
|
+
return (jsxs("div", Object.assign({ className: classNames('form-check', className) }, dataAttributes, { children: [inputComponent, jsx("label", { className: "form-check-label", htmlFor: id, children: label }), hint && (jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1068
1202
|
}
|
|
1069
1203
|
|
|
1070
1204
|
function DSelectOptionCheck(_a) {
|
|
@@ -1143,7 +1277,7 @@ function DSelectPlaceholder(_a) {
|
|
|
1143
1277
|
}
|
|
1144
1278
|
|
|
1145
1279
|
function DSelect(_a) {
|
|
1146
|
-
var { id: idProp, className, style, label,
|
|
1280
|
+
var { id: idProp, className, style, label, 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", "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"]);
|
|
1147
1281
|
const innerId = useId();
|
|
1148
1282
|
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1149
1283
|
const handleOnIconStartClick = useCallback(() => {
|
|
@@ -1155,7 +1289,7 @@ function DSelect(_a) {
|
|
|
1155
1289
|
return (jsxs("div", Object.assign({ className: classNames('d-select', className, {
|
|
1156
1290
|
'd-select-floating': floatingLabel,
|
|
1157
1291
|
disabled: disabled || loading,
|
|
1158
|
-
}), style: style }, dataAttributes, { children: [label && (
|
|
1292
|
+
}), style: style }, dataAttributes, { children: [label && (jsx("label", { htmlFor: id, children: label })), jsxs("div", { className: classNames({
|
|
1159
1293
|
'input-group': true,
|
|
1160
1294
|
'has-validation': invalid,
|
|
1161
1295
|
disabled: disabled || loading,
|
|
@@ -1189,7 +1323,7 @@ var PickerType;
|
|
|
1189
1323
|
PickerType["Month"] = "month";
|
|
1190
1324
|
PickerType["Year"] = "year";
|
|
1191
1325
|
})(PickerType || (PickerType = {}));
|
|
1192
|
-
function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, decreaseYear, increaseYear, monthDate, pickerType, prevMonthButtonDisabled, nextMonthButtonDisabled, monthsShown = 1, iconPrev, iconNext, prevYearButtonDisabled, nextYearButtonDisabled,
|
|
1326
|
+
function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, decreaseYear, increaseYear, monthDate, pickerType, prevMonthButtonDisabled, nextMonthButtonDisabled, monthsShown = 1, iconPrev, iconNext, prevYearButtonDisabled, nextYearButtonDisabled, prevMonthAriaLabel = 'decrease month', nextMonthAriaLabel = 'increase month', prevYearAriaLabel = 'decrease year', nextYearAriaLabel = 'increase year', iconSize, style, className, minYearSelect = 1900, maxYearSelect = 2100, showHeaderSelectors = false, customHeaderCount, locale, }) {
|
|
1193
1327
|
const { iconMap: { chevronLeft, chevronRight, }, } = useDContext();
|
|
1194
1328
|
const arrayYears = useMemo(() => Array.from({ length: maxYearSelect - minYearSelect + 1 }, (_, index) => minYearSelect + index), [maxYearSelect, minYearSelect]);
|
|
1195
1329
|
const years = useMemo(() => arrayYears.map((year) => ({
|
|
@@ -1214,16 +1348,16 @@ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMont
|
|
|
1214
1348
|
}, [date]);
|
|
1215
1349
|
const [startYear, endYear] = getYearRange();
|
|
1216
1350
|
if (pickerType === PickerType.Year) {
|
|
1217
|
-
return (jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-year-selector', className), style: style, children: [jsx(
|
|
1351
|
+
return (jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-year-selector', className), style: style, children: [jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevYearButtonDisabled, ariaLabel: prevYearAriaLabel, className: "header-button" }), jsx("p", { children: `${startYear} - ${endYear}` }), jsx(DButtonIcon, { icon: iconNext || chevronRight, size: iconSize, variant: "link", onClick: increaseYear, disabled: nextYearButtonDisabled, ariaLabel: nextYearAriaLabel, className: "header-button" })] }));
|
|
1218
1352
|
}
|
|
1219
1353
|
if (pickerType === PickerType.Quarter || pickerType === PickerType.Month) {
|
|
1220
|
-
return (jsxs("div", { className: classNames(`react-datepicker__header-selector react-datepicker__header-${pickerType}-selector`, className), style: style, children: [jsx(
|
|
1354
|
+
return (jsxs("div", { className: classNames(`react-datepicker__header-selector react-datepicker__header-${pickerType}-selector`, className), style: style, children: [jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), jsx("div", { className: "d-flex justify-content-center flex-grow-1", children: showHeaderSelectors ? (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("p", { children: defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label })) }), jsx(DButtonIcon, { icon: iconNext || chevronRight, size: iconSize, variant: "link", onClick: increaseYear, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === monthsShown - 1 ? 'visible' : 'hidden' } })] }));
|
|
1221
1355
|
}
|
|
1222
|
-
return (jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-day-selector', className), style: style, children: [jsx(
|
|
1356
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: "datepicker-top-header", children: [showHeaderSelectors && (jsx(DSelect$1, { options: years, value: defaultYear, defaultValue: defaultYear, onChange: (year) => changeYear(Number(year === null || year === void 0 ? void 0 : year.value)), searchable: false, className: "custom-year-selector" })), jsx("h4", { className: "mb-0 fw-normal", children: format(monthDate, 'LLLL, dd', { locale }) })] }), jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-day-selector', className), style: style, children: [jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseMonth, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), showHeaderSelectors ? (jsx(DSelect$1, { options: months, value: defaultMonth, defaultValue: defaultMonth, onChange: (month) => changeMonth((month === null || month === void 0 ? void 0 : month.value) || 0), searchable: false, className: "custom-month-selector" })) : (jsx("p", { children: `${defaultMonth.label} ${defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label}` })), jsx(DButtonIcon, { icon: iconNext || chevronRight, size: iconSize, variant: "link", onClick: increaseMonth, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === monthsShown - 1 ? 'visible' : 'hidden' } })] })] }));
|
|
1223
1357
|
}
|
|
1224
1358
|
|
|
1225
1359
|
function DDatePicker(_a) {
|
|
1226
|
-
var { inputLabel, inputHint, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeInputLabel,
|
|
1360
|
+
var { inputLabel, inputHint, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeInputLabel, minYearSelect, maxYearSelect, iconHeaderSize, iconMaterialStyle, iconInput, headerPrevMonthAriaLabel, headerNextMonthAriaLabel, invalid = false, valid = false, renderCustomHeader: renderCustomHeaderProp, className, dateFormatCalendar: dateFormatCalendarProp, style, dataAttributes, placeholder, showHeaderSelectors } = _a, props = __rest(_a, ["inputLabel", "inputHint", "inputAriaLabel", "inputActionAriaLabel", "inputId", "timeId", "timeInputLabel", "minYearSelect", "maxYearSelect", "iconHeaderSize", "iconMaterialStyle", "iconInput", "headerPrevMonthAriaLabel", "headerNextMonthAriaLabel", "invalid", "valid", "renderCustomHeader", "className", "dateFormatCalendar", "style", "dataAttributes", "placeholder", "showHeaderSelectors"]);
|
|
1227
1361
|
const pickerType = useMemo(() => {
|
|
1228
1362
|
if (props.showQuarterYearPicker)
|
|
1229
1363
|
return PickerType.Quarter;
|
|
@@ -1237,15 +1371,10 @@ function DDatePicker(_a) {
|
|
|
1237
1371
|
props.showMonthYearPicker,
|
|
1238
1372
|
props.showYearPicker,
|
|
1239
1373
|
]);
|
|
1240
|
-
const DatePickerHeader = useCallback((headerProps) => (jsx(DDatePickerHeaderSelector, Object.assign({}, headerProps, { monthsShown: props.monthsShown,
|
|
1241
|
-
iconHeaderNext,
|
|
1242
|
-
iconHeaderPrev,
|
|
1243
|
-
iconMaterialStyle,
|
|
1374
|
+
const DatePickerHeader = useCallback((headerProps) => (jsx(DDatePickerHeaderSelector, Object.assign({}, headerProps, { monthsShown: props.monthsShown, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: iconHeaderSize, minYearSelect: minYearSelect, maxYearSelect: maxYearSelect, pickerType: pickerType, showHeaderSelectors: showHeaderSelectors, locale: props.locale }))), [
|
|
1244
1375
|
headerPrevMonthAriaLabel,
|
|
1245
1376
|
headerNextMonthAriaLabel,
|
|
1246
1377
|
iconHeaderSize,
|
|
1247
|
-
headerButtonVariant,
|
|
1248
|
-
headerButtonTheme,
|
|
1249
1378
|
minYearSelect,
|
|
1250
1379
|
maxYearSelect,
|
|
1251
1380
|
pickerType,
|
|
@@ -1258,6 +1387,33 @@ function DDatePicker(_a) {
|
|
|
1258
1387
|
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 })) })));
|
|
1259
1388
|
}
|
|
1260
1389
|
|
|
1390
|
+
function DLayoutPane({ className, style, children, cols, colsXs, colsSm, colsMd, colsLg, colsXl, colsXxl, dataAttributes, }) {
|
|
1391
|
+
const colsClass = cols ? `g-col-${cols}` : undefined;
|
|
1392
|
+
const colsXsClass = colsXs ? `g-col-${colsXs}` : undefined;
|
|
1393
|
+
const colsSmClass = colsSm ? `g-col-sm-${colsSm}` : undefined;
|
|
1394
|
+
const colsMdClass = colsMd ? `g-col-md-${colsMd}` : undefined;
|
|
1395
|
+
const colsLgClass = colsLg ? `g-col-lg-${colsLg}` : undefined;
|
|
1396
|
+
const colsXlClass = colsXl ? `g-col-xl-${colsXl}` : undefined;
|
|
1397
|
+
const colsXxlClass = colsXxl ? `g-col-xxl-${colsXxl}` : undefined;
|
|
1398
|
+
return (jsx("div", Object.assign({ className: classNames(colsClass, colsXsClass, colsSmClass, colsMdClass, colsLgClass, colsXlClass, colsXxlClass, className), style: style }, dataAttributes, { children: children })));
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function DLayout({ className, style, children, gap, columns, gapSm, gapMd, gapLg, gapXl, gapXxl, dataAttributes, }) {
|
|
1402
|
+
const gapClasses = classNames({
|
|
1403
|
+
[`gap-${gap}`]: gap !== undefined,
|
|
1404
|
+
[`gap-sm-${gapSm}`]: gapSm !== undefined,
|
|
1405
|
+
[`gap-md-${gapMd}`]: gapMd !== undefined,
|
|
1406
|
+
[`gap-lg-${gapLg}`]: gapLg !== undefined,
|
|
1407
|
+
[`gap-xl-${gapXl}`]: gapXl !== undefined,
|
|
1408
|
+
[`gap-xxl-${gapXxl}`]: gapXxl !== undefined,
|
|
1409
|
+
});
|
|
1410
|
+
const styleWithColumns = Object.assign(Object.assign({}, style), { '--bs-columns': columns });
|
|
1411
|
+
return (jsx("div", Object.assign({ style: styleWithColumns, className: classNames('grid', gapClasses, className) }, dataAttributes, { children: children })));
|
|
1412
|
+
}
|
|
1413
|
+
var DLayout$1 = Object.assign(DLayout, {
|
|
1414
|
+
Pane: DLayoutPane,
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1261
1417
|
function DInputMask(props, ref) {
|
|
1262
1418
|
return (jsx(InputMask, Object.assign({ ref: ref, component: ForwardedDInput }, props)));
|
|
1263
1419
|
}
|
|
@@ -1362,47 +1518,6 @@ function useItemSelection({ getItemIdentifier: getItemIdentifierProp, previousSe
|
|
|
1362
1518
|
};
|
|
1363
1519
|
}
|
|
1364
1520
|
|
|
1365
|
-
function subscribeToMediaQuery(query, callback) {
|
|
1366
|
-
const mediaQueryList = window.matchMedia(query);
|
|
1367
|
-
mediaQueryList.addEventListener('change', callback);
|
|
1368
|
-
return () => {
|
|
1369
|
-
mediaQueryList.removeEventListener('change', callback);
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
function checkMediaQuery(query) {
|
|
1373
|
-
return window.matchMedia(query).matches;
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
function useMediaQuery(mediaQuery, useListener = false) {
|
|
1377
|
-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
1378
|
-
const noop = (_) => () => { };
|
|
1379
|
-
return useSyncExternalStore(useListener ? (cb) => subscribeToMediaQuery(mediaQuery, cb) : noop, () => (mediaQuery ? checkMediaQuery(mediaQuery) : true), () => false);
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
function useMediaBreakpointUp(breakpoint, useListener = false) {
|
|
1383
|
-
const { breakpoints } = useDContext();
|
|
1384
|
-
const mediaQuery = useMemo(() => (`(min-width: ${breakpoints[breakpoint]})`), [breakpoint, breakpoints]);
|
|
1385
|
-
return useMediaQuery(mediaQuery, useListener);
|
|
1386
|
-
}
|
|
1387
|
-
function useMediaBreakpointUpXs(useListener = false) {
|
|
1388
|
-
return useMediaBreakpointUp('xs', useListener);
|
|
1389
|
-
}
|
|
1390
|
-
function useMediaBreakpointUpSm(useListener = false) {
|
|
1391
|
-
return useMediaBreakpointUp('sm', useListener);
|
|
1392
|
-
}
|
|
1393
|
-
function useMediaBreakpointUpMd(useListener = false) {
|
|
1394
|
-
return useMediaBreakpointUp('md', useListener);
|
|
1395
|
-
}
|
|
1396
|
-
function useMediaBreakpointUpLg(useListener = false) {
|
|
1397
|
-
return useMediaBreakpointUp('lg', useListener);
|
|
1398
|
-
}
|
|
1399
|
-
function useMediaBreakpointUpXl(useListener = false) {
|
|
1400
|
-
return useMediaBreakpointUp('xl', useListener);
|
|
1401
|
-
}
|
|
1402
|
-
function useMediaBreakpointUpXxl(useListener = false) {
|
|
1403
|
-
return useMediaBreakpointUp('xxl', useListener);
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
1521
|
function DInputCounter(_a, ref) {
|
|
1407
1522
|
var { minValue, maxValue, value = minValue, invalid, iconStart: iconStartProp, iconEnd: iconEndProp, iconStartAriaLabel = 'decrease action', iconEndAriaLabel = 'increase action', style, onChange } = _a, props = __rest(_a, ["minValue", "maxValue", "value", "invalid", "iconStart", "iconEnd", "iconStartAriaLabel", "iconEndAriaLabel", "style", "onChange"]);
|
|
1408
1523
|
const { handleOnWheel, } = useDisableInputWheel(ref);
|
|
@@ -1441,18 +1556,6 @@ function DInputCounter(_a, ref) {
|
|
|
1441
1556
|
const ForwardedDInputCounter = forwardRef(DInputCounter);
|
|
1442
1557
|
ForwardedDInputCounter.displayName = 'DInputCounter';
|
|
1443
1558
|
|
|
1444
|
-
/**
|
|
1445
|
-
* @deprecated
|
|
1446
|
-
*/
|
|
1447
|
-
function DInputCurrencyBase(_a, ref) {
|
|
1448
|
-
var { value, minValue, maxValue, currencyOptions, currencyCode, onFocus, onBlur, onChange } = _a, inputProps = __rest(_a, ["value", "minValue", "maxValue", "currencyOptions", "currencyCode", "onFocus", "onBlur", "onChange"]);
|
|
1449
|
-
const { handleOnWheel, } = useDisableInputWheel(ref);
|
|
1450
|
-
const { inputRef, innerValue, innerType, handleOnFocus, handleOnChange, handleOnBlur, generateStyleVariables, generateSymbolStyleVariables, } = useInputCurrency(currencyOptions, value, onFocus, onChange, onBlur, ref);
|
|
1451
|
-
return (jsx(ForwardedDInput, Object.assign({ ref: inputRef, value: innerValue, onChange: handleOnChange, style: generateStyleVariables, inputMode: "decimal", type: innerType, onFocus: handleOnFocus, onBlur: handleOnBlur, onWheel: handleOnWheel, inputStart: (jsx("span", { slot: "input-start", style: generateSymbolStyleVariables, children: currencyCode || currencyOptions.symbol })) }, inputProps)));
|
|
1452
|
-
}
|
|
1453
|
-
const ForwardedDInputCurrencyBase$1 = forwardRef(DInputCurrencyBase);
|
|
1454
|
-
ForwardedDInputCurrencyBase$1.displayName = 'DInputCurrencyBase';
|
|
1455
|
-
|
|
1456
1559
|
function DInputCurrency(_a, ref) {
|
|
1457
1560
|
var { value, minValue, maxValue, currencyCode, onFocus, onBlur, onChange } = _a, props = __rest(_a, ["value", "minValue", "maxValue", "currencyCode", "onFocus", "onBlur", "onChange"]);
|
|
1458
1561
|
const { currency: currencyOptions } = useDContext();
|
|
@@ -1460,19 +1563,8 @@ function DInputCurrency(_a, ref) {
|
|
|
1460
1563
|
const { inputRef, innerValue, innerType, handleOnFocus, handleOnChange, handleOnBlur, generateStyleVariables, generateSymbolStyleVariables, } = useInputCurrency(currencyOptions, value, onFocus, onChange, onBlur, ref);
|
|
1461
1564
|
return (jsx(ForwardedDInput, Object.assign({ ref: inputRef, value: innerValue, onChange: handleOnChange, style: generateStyleVariables, inputMode: "decimal", type: innerType, onFocus: handleOnFocus, onBlur: handleOnBlur, onWheel: handleOnWheel, inputStart: (jsx("span", { slot: "input-start", style: generateSymbolStyleVariables, children: currencyCode || currencyOptions.symbol })) }, props)));
|
|
1462
1565
|
}
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
/**
|
|
1467
|
-
* @deprecated
|
|
1468
|
-
*/
|
|
1469
|
-
function DInputSearch(_a, ref) {
|
|
1470
|
-
var { type, iconEnd: iconEndProp, iconEndAriaLabel = 'search' } = _a, props = __rest(_a, ["type", "iconEnd", "iconEndAriaLabel"]);
|
|
1471
|
-
const inputRef = useProvidedRefOrCreate(ref);
|
|
1472
|
-
return (jsx(ForwardedDInput, Object.assign({ ref: inputRef, type: "text", iconEnd: "search", iconEndAriaLabel: iconEndAriaLabel }, props)));
|
|
1473
|
-
}
|
|
1474
|
-
const ForwardedDInputSearch = forwardRef(DInputSearch);
|
|
1475
|
-
ForwardedDInputSearch.displayName = 'DInputSearch';
|
|
1566
|
+
const ForwardedDInputCurrency = forwardRef(DInputCurrency);
|
|
1567
|
+
ForwardedDInputCurrency.displayName = 'DInputCurrency';
|
|
1476
1568
|
|
|
1477
1569
|
function DInputPassword(_a, ref) {
|
|
1478
1570
|
var { onIconEndClick, iconEndAriaLabel = 'show/hide password' } = _a, props = __rest(_a, ["onIconEndClick", "iconEndAriaLabel"]);
|
|
@@ -1489,7 +1581,87 @@ function DInputPassword(_a, ref) {
|
|
|
1489
1581
|
const ForwardedDInputPassword = forwardRef(DInputPassword);
|
|
1490
1582
|
ForwardedDInputPassword.displayName = 'DInputPassword';
|
|
1491
1583
|
|
|
1492
|
-
function
|
|
1584
|
+
function PasswordCheckItem({ password, regex, text, }) {
|
|
1585
|
+
const isValid = regex.test(password);
|
|
1586
|
+
return (jsxs("li", { className: "d-flex gap-2 align-items-start small text-gray-600", children: [jsx(DIcon, { className: classNames('flex-shrink-0', isValid ? 'text-success' : 'text-gray-300'), icon: isValid ? 'CircleCheck' : 'Circle', size: "16px" }), jsx("span", { className: classNames({ 'text-success': isValid }), children: text })] }));
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
const getColorClass = (strength, total) => {
|
|
1590
|
+
const percentage = total > 0 ? strength / total : 0;
|
|
1591
|
+
if (percentage === 0)
|
|
1592
|
+
return 'bg-gray-200';
|
|
1593
|
+
if (percentage <= 0.25)
|
|
1594
|
+
return 'bg-danger';
|
|
1595
|
+
if (percentage <= 0.5)
|
|
1596
|
+
return 'bg-warning';
|
|
1597
|
+
if (percentage <= 0.75)
|
|
1598
|
+
return 'bg-info';
|
|
1599
|
+
return 'bg-success';
|
|
1600
|
+
};
|
|
1601
|
+
function PasswordStrengthBar({ strength, total }) {
|
|
1602
|
+
const percentage = total > 0 ? (strength / total) * 100 : 0;
|
|
1603
|
+
return (jsx("div", { className: "w-100 rounded-3 overflow-hidden bg-gray-100 mb-2", style: { height: '8px' }, children: jsx("div", { className: `h-100 ${getColorClass(strength, total)}`, style: {
|
|
1604
|
+
width: `${percentage}%`,
|
|
1605
|
+
transition: 'width 0.3s ease-in-out',
|
|
1606
|
+
} }) }));
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
const CHECK_REGEX = {
|
|
1610
|
+
uppercase: /[A-Z]/,
|
|
1611
|
+
lowercase: /[a-z]/,
|
|
1612
|
+
number: /\d/,
|
|
1613
|
+
specialChar: /[~!@#$^*\-_=[\]{}|;,.?]/,
|
|
1614
|
+
};
|
|
1615
|
+
function PasswordChecksList({ password, validationMessages, enabledChecks, }) {
|
|
1616
|
+
const allChecks = [
|
|
1617
|
+
{
|
|
1618
|
+
key: 'uppercase',
|
|
1619
|
+
regex: CHECK_REGEX.uppercase,
|
|
1620
|
+
text: validationMessages.uppercaseLetter,
|
|
1621
|
+
},
|
|
1622
|
+
{
|
|
1623
|
+
key: 'lowercase',
|
|
1624
|
+
regex: CHECK_REGEX.lowercase,
|
|
1625
|
+
text: validationMessages.lowercaseLetter,
|
|
1626
|
+
},
|
|
1627
|
+
{
|
|
1628
|
+
key: 'number',
|
|
1629
|
+
regex: CHECK_REGEX.number,
|
|
1630
|
+
text: validationMessages.number,
|
|
1631
|
+
},
|
|
1632
|
+
{
|
|
1633
|
+
key: 'specialChar',
|
|
1634
|
+
regex: CHECK_REGEX.specialChar,
|
|
1635
|
+
text: validationMessages.especialChar,
|
|
1636
|
+
},
|
|
1637
|
+
];
|
|
1638
|
+
const passwordChecks = allChecks.filter((check) => enabledChecks.includes(check.key));
|
|
1639
|
+
const passed = passwordChecks.filter((r) => r.regex.test(password)).length;
|
|
1640
|
+
const total = passwordChecks.length;
|
|
1641
|
+
return (jsxs("div", { className: "mt-2", children: [jsx(PasswordStrengthBar, { strength: passed, total: total }), jsx("ul", { className: "list-unstyled m-0 d-flex flex-column gap-2", children: passwordChecks.map(({ key, regex, text }) => (jsx(PasswordCheckItem, { password: password, regex: regex, text: text }, key))) })] }));
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
const DEFAULT_VALIDATION_MESSAGES = {
|
|
1645
|
+
number: 'At least one number',
|
|
1646
|
+
lowercaseLetter: 'At least one lowercase letter',
|
|
1647
|
+
uppercaseLetter: 'At least one uppercase letter',
|
|
1648
|
+
especialChar: 'At least one of these special characters: ~!@#$^*-_=[]{}|;,.?',
|
|
1649
|
+
notMatch: 'The password confirmation and the new password do not match.',
|
|
1650
|
+
};
|
|
1651
|
+
const DEFAULT_ENABLED_CHECKS = ['uppercase', 'lowercase', 'number', 'specialChar'];
|
|
1652
|
+
function DPasswordStrengthMeter({ id, label = 'Password', placeholder, value = '', name, disabled = false, invalid = false, validationMessages = DEFAULT_VALIDATION_MESSAGES, enabledChecks = DEFAULT_ENABLED_CHECKS, className, style, dataAttributes, onChange, }) {
|
|
1653
|
+
const [password, setPassword] = useState(value);
|
|
1654
|
+
useEffect(() => {
|
|
1655
|
+
setPassword(value);
|
|
1656
|
+
}, [value]);
|
|
1657
|
+
const handleChange = (newValue) => {
|
|
1658
|
+
setPassword(newValue);
|
|
1659
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
1660
|
+
};
|
|
1661
|
+
return (jsxs("div", Object.assign({ className: className, style: style }, dataAttributes, { children: [jsx(ForwardedDInputPassword, { id: id, label: label, placeholder: placeholder, value: password, name: name, disabled: disabled, invalid: invalid, onChange: handleChange }), jsx(PasswordChecksList, { password: password, validationMessages: validationMessages, enabledChecks: enabledChecks })] })));
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
function DInputPin({ id: idProp, label = '', placeholder, type = 'text', disabled = false, loading = false, secret = false, characters = 4, innerInputMode = 'text', hint, invalid = false, valid = false, className, style, dataAttributes, onChange, }) {
|
|
1493
1665
|
const innerId = useId();
|
|
1494
1666
|
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1495
1667
|
const [pattern, setPattern] = useState('');
|
|
@@ -1522,7 +1694,8 @@ function DInputPin({ id: idProp, label = '', labelIcon, labelIconFamilyClass, la
|
|
|
1522
1694
|
}
|
|
1523
1695
|
if (input.value !== '') {
|
|
1524
1696
|
setActiveInput((prev) => {
|
|
1525
|
-
const newValue = prev
|
|
1697
|
+
const newValue = [...prev];
|
|
1698
|
+
newValue[index] = input.value;
|
|
1526
1699
|
return newValue;
|
|
1527
1700
|
});
|
|
1528
1701
|
if (input.nextSibling) {
|
|
@@ -1538,7 +1711,8 @@ function DInputPin({ id: idProp, label = '', labelIcon, labelIconFamilyClass, la
|
|
|
1538
1711
|
if (key === 'Backspace') {
|
|
1539
1712
|
const { value } = currentTarget;
|
|
1540
1713
|
setActiveInput((prev) => {
|
|
1541
|
-
const newVal = prev
|
|
1714
|
+
const newVal = [...prev];
|
|
1715
|
+
newVal[index] = '';
|
|
1542
1716
|
return newVal;
|
|
1543
1717
|
});
|
|
1544
1718
|
if (currentTarget.previousSibling && value === '') {
|
|
@@ -1551,19 +1725,23 @@ function DInputPin({ id: idProp, label = '', labelIcon, labelIconFamilyClass, la
|
|
|
1551
1725
|
}
|
|
1552
1726
|
}, []);
|
|
1553
1727
|
const focusInput = useCallback((index) => {
|
|
1554
|
-
setActiveInput((prev) =>
|
|
1728
|
+
setActiveInput((prev) => {
|
|
1729
|
+
const newVal = [...prev];
|
|
1730
|
+
newVal[index] = '';
|
|
1731
|
+
return newVal;
|
|
1732
|
+
});
|
|
1555
1733
|
}, []);
|
|
1556
1734
|
const wheelInput = useCallback((event) => {
|
|
1557
1735
|
event.currentTarget.blur();
|
|
1558
1736
|
}, []);
|
|
1559
|
-
return (jsxs("div", Object.assign({ className: classNames('d-input-pin', className), style: style }, dataAttributes, { children: [label && (
|
|
1737
|
+
return (jsxs("div", Object.assign({ className: classNames('d-input-pin', className), style: style }, dataAttributes, { children: [label && (jsx("label", { htmlFor: "pinIndex0", children: label })), jsxs("div", { className: "d-input-pin-group", id: id, children: [Array.from({ length: characters }).map((_, index) => (jsx("input", Object.assign({ className: classNames({
|
|
1560
1738
|
'form-control': true,
|
|
1561
1739
|
'is-invalid': invalid,
|
|
1562
1740
|
'is-valid': valid,
|
|
1563
1741
|
}), value: activeInput[index], type: secret ? 'password' : type, "aria-describedby": `${id}State`, inputMode: innerInputMode, id: `pinIndex${index}`, name: `pin-${index}`, maxLength: 1, onInput: (event) => nextInput(event, index), onKeyDown: (event) => prevInput(event, index), onFocus: () => focusInput(index), onWheel: wheelInput, onClick: (event) => event.preventDefault(), onPaste: (event) => handlePaste(event), autoComplete: "off", placeholder: placeholder, disabled: disabled || loading, required: true }, type === 'number' && ({ min: 0, max: 9 })), index))), loading && (jsx("div", { className: "input-group-text", children: jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) }) }))] }), hint && (jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1564
1742
|
}
|
|
1565
1743
|
|
|
1566
|
-
function DInputSelect({ id: idProp, name, label = '', className, style, options = [],
|
|
1744
|
+
function DInputSelect({ id: idProp, name, label = '', className, style, options = [], disabled = false, loading = false, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, hint, value, size, floatingLabel = false, invalid = false, valid = false, dataAttributes, valueExtractor, labelExtractor, onChange, onBlur, onIconStartClick, onIconEndClick, }) {
|
|
1567
1745
|
const innerId = useId();
|
|
1568
1746
|
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1569
1747
|
const internalValueExtractor = useCallback((option) => {
|
|
@@ -1631,12 +1809,9 @@ function DInputSelect({ id: idProp, name, label = '', className, style, options
|
|
|
1631
1809
|
valid,
|
|
1632
1810
|
size,
|
|
1633
1811
|
]);
|
|
1634
|
-
const labelComponent = useMemo(() => (
|
|
1812
|
+
const labelComponent = useMemo(() => (jsx("label", { htmlFor: id, children: label })), [
|
|
1635
1813
|
id,
|
|
1636
1814
|
label,
|
|
1637
|
-
labelIcon,
|
|
1638
|
-
labelIconFamilyClass,
|
|
1639
|
-
labelIconFamilyPrefix,
|
|
1640
1815
|
]);
|
|
1641
1816
|
const dynamicComponent = useMemo(() => {
|
|
1642
1817
|
if (floatingLabel) {
|
|
@@ -1649,7 +1824,7 @@ function DInputSelect({ id: idProp, name, label = '', className, style, options
|
|
|
1649
1824
|
}), children: [iconStart && (jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: iconStartClickHandler, disabled: disabled || loading, "aria-label": iconStartAriaLabel, children: iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })) })), dynamicComponent, iconEnd && !loading && (jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: iconEndClickHandler, disabled: disabled || loading, "aria-label": iconEndAriaLabel, children: iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) })), loading && (jsx("div", { className: "input-group-text form-control-icon loading", children: jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) }) }))] }), hint && (jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1650
1825
|
}
|
|
1651
1826
|
|
|
1652
|
-
function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, invalid = false, valid = false, readonly, className, style, dataAttributes, onChange, }) {
|
|
1827
|
+
function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, invalid = false, valid = false, readonly, className, style, dataAttributes, inputClassName, onChange, }) {
|
|
1653
1828
|
const innerId = useId();
|
|
1654
1829
|
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1655
1830
|
const [internalIsChecked, setInternalIsChecked] = useState(checked);
|
|
@@ -1661,10 +1836,10 @@ function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, i
|
|
|
1661
1836
|
setInternalIsChecked(value);
|
|
1662
1837
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
1663
1838
|
}, [onChange]);
|
|
1664
|
-
return (jsxs("div", Object.assign({ className:
|
|
1839
|
+
return (jsxs("div", Object.assign({ className: classNames('form-check', className) }, dataAttributes, { children: [jsx("input", { id: id, name: name, onChange: readonly ? () => false : changeHandler, className: classNames('form-check-input', {
|
|
1665
1840
|
'is-invalid': invalid,
|
|
1666
1841
|
'is-valid': valid,
|
|
1667
|
-
},
|
|
1842
|
+
}, inputClassName), style: style, type: "checkbox", role: "switch", checked: internalIsChecked, disabled: disabled, "aria-label": ariaLabel }), label && (jsx("label", { className: "form-check-label", htmlFor: id, children: label }))] })));
|
|
1668
1843
|
}
|
|
1669
1844
|
|
|
1670
1845
|
function DInputRange(_a, ref) {
|
|
@@ -1699,43 +1874,12 @@ function DInputRange(_a, ref) {
|
|
|
1699
1874
|
if (!label) {
|
|
1700
1875
|
return inputComponent;
|
|
1701
1876
|
}
|
|
1702
|
-
return (jsxs(Fragment
|
|
1877
|
+
return (jsxs(Fragment, { children: [jsx("label", { className: "form-label", htmlFor: id, children: label }), inputComponent] }));
|
|
1703
1878
|
}
|
|
1704
1879
|
const ForwardedDInputRange = forwardRef(DInputRange);
|
|
1705
1880
|
ForwardedDInputRange.displayName = 'DInputRange';
|
|
1706
1881
|
|
|
1707
|
-
|
|
1708
|
-
* @deprecated Please use DListGroup.Item or DListGroupItem instead
|
|
1709
|
-
*/
|
|
1710
|
-
function DListItem({ children, className, style, active = false, disabled = false, theme, onClick, }) {
|
|
1711
|
-
const Tag = useMemo(() => (onClick ? 'button' : 'div'), [onClick]);
|
|
1712
|
-
return (jsx(Tag, Object.assign({}, Tag === 'button' && {
|
|
1713
|
-
onClick,
|
|
1714
|
-
type: 'button',
|
|
1715
|
-
}, { className: classNames('list-group-item list-group-item-action', theme ? `list-group-item-${theme}` : undefined, className, {
|
|
1716
|
-
active,
|
|
1717
|
-
disabled,
|
|
1718
|
-
}), style: style }, active && { 'aria-current': true }, { children: children })));
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
/**
|
|
1722
|
-
* @deprecated Please use DListGroup instead
|
|
1723
|
-
*/
|
|
1724
|
-
function DList({ children, className, style, flush = false, numbered = false, horizontal = false, horizontalBreakpoint, dataAttributes, }) {
|
|
1725
|
-
if (flush && horizontal) {
|
|
1726
|
-
throw new Error("Horizontal and Flush props don't work together");
|
|
1727
|
-
}
|
|
1728
|
-
return (jsx("div", Object.assign({ className: classNames('list-group', {
|
|
1729
|
-
'list-group-flush': flush && !horizontal,
|
|
1730
|
-
'list-group-numbered': numbered,
|
|
1731
|
-
'list-group-horizontal': horizontal && !horizontalBreakpoint,
|
|
1732
|
-
}, (horizontal && horizontalBreakpoint) && `list-group-horizontal-${horizontalBreakpoint}`, className), style: style }, dataAttributes, { children: children })));
|
|
1733
|
-
}
|
|
1734
|
-
var DList$1 = Object.assign(DList, {
|
|
1735
|
-
Item: DListItem,
|
|
1736
|
-
});
|
|
1737
|
-
|
|
1738
|
-
function DListGroupItem({ as = 'li', action: actionProp, active, disabled, href, onClick, theme, children, className, style, dataAttributes, }) {
|
|
1882
|
+
function DListGroupItem({ as = 'li', action: actionProp, active, disabled, href, onClick, color, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartMaterialStyle, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndMaterialStyle, children, className, style, dataAttributes, }) {
|
|
1739
1883
|
const Tag = useMemo(() => {
|
|
1740
1884
|
if (href) {
|
|
1741
1885
|
return 'a';
|
|
@@ -1754,17 +1898,17 @@ function DListGroupItem({ as = 'li', action: actionProp, active, disabled, href,
|
|
|
1754
1898
|
const generateClasses = useMemo(() => ({
|
|
1755
1899
|
'list-group-item': true,
|
|
1756
1900
|
'list-group-item-action': action,
|
|
1757
|
-
[`list-group-item-${
|
|
1901
|
+
[`list-group-item-${color}`]: !!color,
|
|
1758
1902
|
active,
|
|
1759
1903
|
disabled,
|
|
1760
|
-
}), [action, active, disabled,
|
|
1904
|
+
}), [action, active, disabled, color]);
|
|
1761
1905
|
const ariaAttributes = useMemo(() => {
|
|
1762
1906
|
if (Tag === 'button') {
|
|
1763
1907
|
return Object.assign(Object.assign({}, active && { 'aria-current': true }), disabled && { disabled: true });
|
|
1764
1908
|
}
|
|
1765
1909
|
return Object.assign(Object.assign({}, active && { 'aria-current': true }), disabled && { 'aria-disabled': true });
|
|
1766
1910
|
}, [Tag, active, disabled]);
|
|
1767
|
-
return (
|
|
1911
|
+
return (jsxs(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, Tag === 'a' && href && { href }, onClick && { onClick }, ariaAttributes, dataAttributes, Tag === 'button' && { type: 'button' }, { children: [iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle })), children, iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle, className: "ms-auto" }))] })));
|
|
1768
1912
|
}
|
|
1769
1913
|
|
|
1770
1914
|
function DListGroup({ as = 'ul', numbered, flush, horizontal, children, className, style, dataAttributes, }) {
|
|
@@ -1794,7 +1938,7 @@ var DListGroup$1 = Object.assign(DListGroup, {
|
|
|
1794
1938
|
function DModalHeader({ showCloseButton, onClose, children, className, style, iconFamilyClass, iconFamilyPrefix, icon: iconProp, materialStyle = false, }) {
|
|
1795
1939
|
const { iconMap: { xLg, }, } = useDContext();
|
|
1796
1940
|
const icon = useMemo(() => iconProp || xLg, [iconProp, xLg]);
|
|
1797
|
-
return (jsxs(Fragment
|
|
1941
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: classNames('modal-header', className), style: style, children: [jsx("div", { children: children }), showCloseButton && (jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: materialStyle }) }))] }), jsx("div", { className: "d-modal-separator" })] }));
|
|
1798
1942
|
}
|
|
1799
1943
|
|
|
1800
1944
|
function DModalBody({ children, className, style, }) {
|
|
@@ -1806,10 +1950,14 @@ function DModalFooter({ className, style, actionPlacement, children, }) {
|
|
|
1806
1950
|
'modal-footer': true,
|
|
1807
1951
|
[`d-modal-action-${actionPlacement}`]: !!actionPlacement,
|
|
1808
1952
|
}), [actionPlacement]);
|
|
1809
|
-
return (jsxs(Fragment
|
|
1953
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: "d-modal-separator" }), jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
|
|
1810
1954
|
}
|
|
1811
1955
|
|
|
1812
|
-
|
|
1956
|
+
const defaultTransition$1 = {
|
|
1957
|
+
ease: 'easeInOut',
|
|
1958
|
+
duration: 0.3,
|
|
1959
|
+
};
|
|
1960
|
+
function DModal({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom, size, transition, children, dataAttributes, }) {
|
|
1813
1961
|
const fullScreenClass = useMemo(() => {
|
|
1814
1962
|
if (fullScreen) {
|
|
1815
1963
|
if (fullScreenFrom) {
|
|
@@ -1820,7 +1968,7 @@ function DModal({ name, className, style, staticBackdrop, scrollable, centered,
|
|
|
1820
1968
|
return '';
|
|
1821
1969
|
}, [fullScreenFrom, fullScreen]);
|
|
1822
1970
|
const generateModalDialogClasses = useMemo(() => (Object.assign({ 'modal-dialog': true, 'modal-dialog-centered': !!centered, 'modal-dialog-scrollable': !!scrollable, [fullScreenClass]: !!fullScreen }, size && { [`modal-${size}`]: true })), [fullScreenClass, centered, fullScreen, scrollable, size]);
|
|
1823
|
-
return (jsx(
|
|
1971
|
+
return (jsx(motion.div, Object.assign({ className: classNames('modal portal show', className), id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false", style: style, initial: { opacity: 0, scale: 0.95 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.95 }, transition: Object.assign(Object.assign({}, (transition !== null && transition !== void 0 ? transition : defaultTransition$1)), { delay: 0.15 }) }, staticBackdrop && ({
|
|
1824
1972
|
[`data-${PREFIX_BS}backdrop`]: 'static',
|
|
1825
1973
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1826
1974
|
}), dataAttributes, { children: jsx("div", { className: classNames(generateModalDialogClasses), children: jsx("div", { className: "modal-content", children: children }) }) })));
|
|
@@ -1834,7 +1982,7 @@ var DModal$1 = Object.assign(DModal, {
|
|
|
1834
1982
|
function DOffcanvasHeader({ showCloseButton, onClose, children, className, style, iconFamilyClass, iconFamilyPrefix, icon: iconProp, materialStyle = false, }) {
|
|
1835
1983
|
const { iconMap: { xLg, }, } = useDContext();
|
|
1836
1984
|
const icon = useMemo(() => iconProp || xLg, [iconProp, xLg]);
|
|
1837
|
-
return (jsxs(Fragment
|
|
1985
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: classNames('offcanvas-header', className), style: style, children: [jsx("div", { children: children }), showCloseButton && (jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: materialStyle }) }))] }), jsx("div", { className: "d-offcanvas-separator" })] }));
|
|
1838
1986
|
}
|
|
1839
1987
|
|
|
1840
1988
|
function DOffcanvasBody({ children, className, style, }) {
|
|
@@ -1846,13 +1994,39 @@ function DOffcanvasFooter({ actionPlacement, children, className, style, }) {
|
|
|
1846
1994
|
'd-offcanvas-footer': true,
|
|
1847
1995
|
[`d-offcanvas-action-${actionPlacement}`]: !!actionPlacement,
|
|
1848
1996
|
}), [actionPlacement]);
|
|
1849
|
-
return (jsxs(Fragment
|
|
1997
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: "d-offcanvas-separator" }), jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
|
|
1850
1998
|
}
|
|
1851
1999
|
|
|
1852
|
-
|
|
1853
|
-
|
|
2000
|
+
const variants = {
|
|
2001
|
+
hidden: (openFrom) => {
|
|
2002
|
+
const properties = {};
|
|
2003
|
+
if (openFrom === 'start') {
|
|
2004
|
+
properties.x = '-100%';
|
|
2005
|
+
}
|
|
2006
|
+
if (openFrom === 'end') {
|
|
2007
|
+
properties.x = '100%';
|
|
2008
|
+
}
|
|
2009
|
+
if (openFrom === 'top') {
|
|
2010
|
+
properties.y = '-100%';
|
|
2011
|
+
}
|
|
2012
|
+
if (openFrom === 'bottom') {
|
|
2013
|
+
properties.y = '100%';
|
|
2014
|
+
}
|
|
2015
|
+
return properties;
|
|
2016
|
+
},
|
|
2017
|
+
visible: {
|
|
2018
|
+
x: 0,
|
|
2019
|
+
y: 0,
|
|
2020
|
+
},
|
|
2021
|
+
};
|
|
2022
|
+
const defaultTransition = {
|
|
2023
|
+
ease: 'easeInOut',
|
|
2024
|
+
duration: 0.3,
|
|
2025
|
+
};
|
|
2026
|
+
function DOffcanvas({ name, className, style, staticBackdrop, scrollable, openFrom = 'end', transition, children, dataAttributes, }) {
|
|
2027
|
+
return (jsx(motion.div, Object.assign({ className: classNames('offcanvas portal show', {
|
|
1854
2028
|
[`offcanvas-${openFrom}`]: openFrom,
|
|
1855
|
-
}, className), style: style, id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false" }, staticBackdrop && ({
|
|
2029
|
+
}, className), style: Object.assign(Object.assign({}, style), { transition: 'none' }), id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false", custom: openFrom, variants: variants, initial: "hidden", animate: "visible", exit: "hidden", transition: Object.assign(Object.assign({}, (transition !== null && transition !== void 0 ? transition : defaultTransition)), { delay: 0.15 }) }, staticBackdrop && ({
|
|
1856
2030
|
[`data-${PREFIX_BS}backdrop`]: 'static',
|
|
1857
2031
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1858
2032
|
}), scrollable && ({
|
|
@@ -1867,11 +2041,8 @@ var DOffcanvas$1 = Object.assign(DOffcanvas, {
|
|
|
1867
2041
|
});
|
|
1868
2042
|
|
|
1869
2043
|
function DPaginator(_a) {
|
|
1870
|
-
var {
|
|
1871
|
-
|
|
1872
|
-
extraClassName: className,
|
|
1873
|
-
})), [props, page, current, showArrows, className]);
|
|
1874
|
-
return (jsx(ResponsivePagination, Object.assign({ navClassName: classNames('page-item-arrow', navClassName) }, backwardCompatibilityProps)));
|
|
2044
|
+
var { navClassName } = _a, props = __rest(_a, ["navClassName"]);
|
|
2045
|
+
return (jsx(ResponsivePagination, Object.assign({ navClassName: classNames('page-item-arrow', navClassName) }, props)));
|
|
1875
2046
|
}
|
|
1876
2047
|
|
|
1877
2048
|
function DPopover({ children, renderComponent, open, setOpen, adjustContentToRender = false, className, style, dataAttributes, }) {
|
|
@@ -1904,123 +2075,22 @@ function DPopover({ children, renderComponent, open, setOpen, adjustContentToRen
|
|
|
1904
2075
|
role,
|
|
1905
2076
|
]);
|
|
1906
2077
|
const headingId = useId$1();
|
|
1907
|
-
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign({}, style), adjustContentToRender && {
|
|
2078
|
+
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign({}, style), (adjustContentToRender && {
|
|
1908
2079
|
[`--${PREFIX_BS}popover-component-min-width`]: 'auto',
|
|
1909
|
-
})), [style, adjustContentToRender]);
|
|
2080
|
+
}))), [style, adjustContentToRender]);
|
|
1910
2081
|
return (jsxs("div", Object.assign({ className: classNames('d-popover', className), style: generateStyleVariables }, dataAttributes, { children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: renderComponent(isOpen) })), isOpen && (jsx(FloatingFocusManager, { context: context, modal: false, children: jsx("div", Object.assign({ className: classNames('d-popover-content', {
|
|
1911
2082
|
'w-100': adjustContentToRender,
|
|
1912
2083
|
}), ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: children })) }))] })));
|
|
1913
2084
|
}
|
|
1914
2085
|
|
|
1915
|
-
function DProgress({ className, style, currentValue, minValue = 0, maxValue = 100, hideCurrentValue = false, enableStripedAnimation = false, dataAttributes, }) {
|
|
2086
|
+
function DProgress({ className, style, currentValue, minValue = 0, maxValue = 100, hideCurrentValue = false, enableStripedAnimation = false, height, dataAttributes, }) {
|
|
1916
2087
|
const percentage = useMemo(() => (Math.round((currentValue * 100) / maxValue)), [currentValue, maxValue]);
|
|
1917
2088
|
const formatProgress = useMemo(() => `${percentage}%`, [percentage]);
|
|
1918
2089
|
const generateClasses = useMemo(() => ({
|
|
1919
2090
|
'progress-bar': true,
|
|
1920
2091
|
'progress-bar-striped progress-bar-animated': enableStripedAnimation,
|
|
1921
2092
|
}), [enableStripedAnimation]);
|
|
1922
|
-
return (jsx("div", Object.assign({ className: classNames('progress', className) }, dataAttributes, { children: jsx("div", { className: classNames(generateClasses), role: "progressbar", "aria-label": "Progress bar", style:
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
function DQuickActionButton({ line1, line2, className, actionIcon, actionIconFamilyClass, actionIconFamilyPrefix, actionIconTheme, representativeImage, representativeIcon, representativeIconTheme = 'secondary', representativeIconHasCircle = false, representativeIconFamilyClass, representativeIconFamilyPrefix, onClick, href, hrefTarget, style, dataAttributes, }) {
|
|
1926
|
-
const Tag = useMemo(() => {
|
|
1927
|
-
if (href) {
|
|
1928
|
-
return 'a';
|
|
1929
|
-
}
|
|
1930
|
-
if (onClick) {
|
|
1931
|
-
return 'button';
|
|
1932
|
-
}
|
|
1933
|
-
return 'div';
|
|
1934
|
-
}, [href, onClick]);
|
|
1935
|
-
const tagProps = useMemo(() => {
|
|
1936
|
-
if (href) {
|
|
1937
|
-
return {
|
|
1938
|
-
className: classNames('d-quick-action-button', 'd-quick-action-button-feedback', className),
|
|
1939
|
-
href,
|
|
1940
|
-
target: hrefTarget,
|
|
1941
|
-
};
|
|
1942
|
-
}
|
|
1943
|
-
if (onClick) {
|
|
1944
|
-
return {
|
|
1945
|
-
className: classNames('d-quick-action-button', 'd-quick-action-button-feedback', className),
|
|
1946
|
-
onClick,
|
|
1947
|
-
};
|
|
1948
|
-
}
|
|
1949
|
-
return {
|
|
1950
|
-
className: classNames('d-quick-action-button', className),
|
|
1951
|
-
};
|
|
1952
|
-
}, [
|
|
1953
|
-
className,
|
|
1954
|
-
href,
|
|
1955
|
-
hrefTarget,
|
|
1956
|
-
onClick,
|
|
1957
|
-
]);
|
|
1958
|
-
return (jsxs(Tag, Object.assign({ style: style }, tagProps, dataAttributes, { children: [representativeIcon && (jsx(DIcon, { className: "d-quick-action-button-representative-icon", size: representativeIconHasCircle
|
|
1959
|
-
? `var(--${PREFIX_BS}quick-action-button-representative-icon-size)`
|
|
1960
|
-
: `var(--${PREFIX_BS}quick-action-button-representative-image-size)`, icon: representativeIcon, hasCircle: representativeIconHasCircle, theme: representativeIconTheme, familyClass: representativeIconFamilyClass, familyPrefix: representativeIconFamilyPrefix })), representativeImage && (jsx("img", { className: "d-quick-action-button-representative-image", src: representativeImage, alt: "" })), jsx("div", { className: "d-quick-action-button-content", children: jsxs("div", { className: "d-quick-action-button-text", children: [jsx("span", { className: "d-quick-action-button-line1", children: line1 }), jsx("small", { className: "d-quick-action-button-line2", children: line2 })] }) }), actionIcon && (jsx(DIcon, { className: "d-quick-action-button-action-icon", icon: actionIcon, size: `var(--${PREFIX_BS}quick-action-button-action-icon-size)`, theme: actionIconTheme, familyClass: actionIconFamilyClass, familyPrefix: actionIconFamilyPrefix }))] })));
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
/**
|
|
1964
|
-
* @deprecated
|
|
1965
|
-
*/
|
|
1966
|
-
function DQuickActionCheck({ id: idProp, name, value, line1, line2, line3, className, style, checked, dataAttributes, onChange, }) {
|
|
1967
|
-
const innerId = useId();
|
|
1968
|
-
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1969
|
-
const changeHandler = useCallback((event) => {
|
|
1970
|
-
event.stopPropagation();
|
|
1971
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1972
|
-
}, [onChange]);
|
|
1973
|
-
return (jsxs("label", Object.assign({ className: classNames('d-quick-action-check', className), htmlFor: id, style: style }, dataAttributes, { children: [jsx(DInputCheck, { id: id, type: "radio", name: name, value: value, checked: checked, onChange: changeHandler }), jsxs("div", { className: "d-quick-action-check-detail", children: [jsx("span", { className: "d-quick-action-check-line1", children: line1 }), jsx("span", { className: "d-quick-action-check-line2", children: line2 })] }), jsx("span", { className: "d-quick-action-check-line3", children: line3 })] })));
|
|
1974
|
-
}
|
|
1975
|
-
|
|
1976
|
-
function DQuickActionSelect({ id: idProp, name, value, line1, line2, className, style, selected = false, dataAttributes, onChange, }) {
|
|
1977
|
-
const innerRef = useRef(null);
|
|
1978
|
-
const innerId = useId();
|
|
1979
|
-
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1980
|
-
const changeHandler = useCallback((event) => {
|
|
1981
|
-
event.stopPropagation();
|
|
1982
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1983
|
-
}, [onChange]);
|
|
1984
|
-
useEffect(() => {
|
|
1985
|
-
if (innerRef.current) {
|
|
1986
|
-
innerRef.current.checked = selected;
|
|
1987
|
-
}
|
|
1988
|
-
}, [selected]);
|
|
1989
|
-
return (jsxs("label", Object.assign({ className: classNames('d-quick-action-select', className), htmlFor: id, style: style }, dataAttributes, { children: [jsx("input", { ref: innerRef, id: id, type: "radio", name: name, value: value, onChange: changeHandler }), jsx("span", { className: "d-quick-action-select-line1", children: line1 }), jsx("span", { className: "d-quick-action-select-line2", children: line2 })] })));
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
|
-
/**
|
|
1993
|
-
* @deprecated
|
|
1994
|
-
*/
|
|
1995
|
-
function DQuickActionSwitch({ id: idProp, name, label, hint, checked, disabled, className, style, dataAttributes, onClick, }) {
|
|
1996
|
-
const innerId = useId();
|
|
1997
|
-
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1998
|
-
const clickHandler = useCallback((event) => {
|
|
1999
|
-
event.stopPropagation();
|
|
2000
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(checked);
|
|
2001
|
-
}, [checked, onClick]);
|
|
2002
|
-
return (jsxs("button", Object.assign({ className: classNames('d-quick-action-switch', className), type: "button", onClick: clickHandler, style: style }, dataAttributes, { children: [jsx("div", { className: "d-quick-action-switch-content", children: jsx(DInputSwitch, { id: id, name: name, disabled: disabled, checked: checked, readonly: true, label: label }) }), jsx("div", { className: "d-quick-action-switch-hint", children: hint })] })));
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
/**
|
|
2006
|
-
* @deprecated Please use https://getbootstrap.com/docs/5.3/components/placeholders/ instead
|
|
2007
|
-
*/
|
|
2008
|
-
function DSkeleton({ speed = 2, viewBox, backgroundColor, foregroundColor, children, }) {
|
|
2009
|
-
const innerBackgroundColor = useMemo(() => {
|
|
2010
|
-
if (backgroundColor) {
|
|
2011
|
-
return backgroundColor;
|
|
2012
|
-
}
|
|
2013
|
-
const computedStyle = getComputedStyle(document.documentElement);
|
|
2014
|
-
return computedStyle.getPropertyValue(`--${PREFIX_BS}secondary-100`);
|
|
2015
|
-
}, [backgroundColor]);
|
|
2016
|
-
const innerForegroundColor = useMemo(() => {
|
|
2017
|
-
if (foregroundColor) {
|
|
2018
|
-
return foregroundColor;
|
|
2019
|
-
}
|
|
2020
|
-
const computedStyle = getComputedStyle(document.documentElement);
|
|
2021
|
-
return computedStyle.getPropertyValue(`--${PREFIX_BS}gray-100`);
|
|
2022
|
-
}, [foregroundColor]);
|
|
2023
|
-
return (jsx(ContentLoader, { speed: speed, viewBox: viewBox, backgroundColor: innerBackgroundColor, foregroundColor: innerForegroundColor, children: children }));
|
|
2093
|
+
return (jsx("div", Object.assign({ className: classNames('progress', className), style: Object.assign({ height }, style) }, dataAttributes, { children: jsx("div", { className: classNames(generateClasses), role: "progressbar", "aria-label": "Progress bar", style: { width: formatProgress }, "aria-valuenow": currentValue, "aria-valuemin": minValue, "aria-valuemax": maxValue, children: !hideCurrentValue && formatProgress }) })));
|
|
2024
2094
|
}
|
|
2025
2095
|
|
|
2026
2096
|
function DStepper$2({ options, currentStep, iconSuccess: iconSuccessProp, iconSuccessFamilyClass, iconSuccessFamilyPrefix, iconSuccessMaterialStyle = false, vertical = false, completed, alignStart = false, className, style, }) {
|
|
@@ -2033,13 +2103,13 @@ function DStepper$2({ options, currentStep, iconSuccess: iconSuccessProp, iconSu
|
|
|
2033
2103
|
'd-stepper-desktop': true,
|
|
2034
2104
|
'is-vertical': vertical,
|
|
2035
2105
|
'is-align-start': alignStart && !vertical,
|
|
2036
|
-
}, className), style: style, children: options.map(({ label, value, description }) => (jsxs("div", { className:
|
|
2106
|
+
}, className), style: style, children: options.map(({ label, value, description }) => (jsxs("div", { className: classNames({
|
|
2107
|
+
'd-step': true,
|
|
2108
|
+
'd-step-current': value === currentStep && !completed,
|
|
2109
|
+
}), children: [jsx("div", { className: "d-step-value", children: jsxs("div", { className: classNames({
|
|
2037
2110
|
'd-step-icon-container': true,
|
|
2038
2111
|
'd-step-check': value < currentStep || completed,
|
|
2039
|
-
|
|
2040
|
-
}), children: value < currentStep || completed
|
|
2041
|
-
? (jsx(DIcon, { icon: icon, familyClass: iconSuccessFamilyClass, familyPrefix: iconSuccessFamilyPrefix, materialStyle: iconSuccessMaterialStyle, className: "d-step-icon" }))
|
|
2042
|
-
: value }) }), jsxs("div", { className: "d-step-text-container", children: [jsx("div", { className: "d-step-label", children: label }), description && (jsx("div", { className: "d-step-description", children: description }))] })] }, value))) }));
|
|
2112
|
+
}), children: [((value < currentStep) || completed) && (jsx(DIcon, { icon: icon, familyClass: iconSuccessFamilyClass, familyPrefix: iconSuccessFamilyPrefix, materialStyle: iconSuccessMaterialStyle, className: "d-step-icon" })), value] }) }), jsxs("div", { className: "d-step-text-container", children: [jsx("div", { className: "d-step-label", children: label }), description && (jsx("div", { className: "d-step-description", children: description }))] })] }, value))) }));
|
|
2043
2113
|
}
|
|
2044
2114
|
|
|
2045
2115
|
function DStepper$1({ options, currentStep, className, style, }) {
|
|
@@ -2069,7 +2139,7 @@ function DStepper$1({ options, currentStep, className, style, }) {
|
|
|
2069
2139
|
from 0deg,
|
|
2070
2140
|
var(--${PREFIX_BS}step-progress-outter-fill-background-color) ${currentAngle}deg,
|
|
2071
2141
|
var(--${PREFIX_BS}step-progress-outter-background-color) 0deg)`, [currentAngle]);
|
|
2072
|
-
return (jsxs("div", { className: classNames('d-stepper', className), style: style, children: [jsx("div", { className: "d-step-bar", style: { background: progressStyle }, children: jsx("p", { className: "d-step-number", children: `${currentStep}/${options.length}` }) }), jsx("div", { className: "d-step-info", children: Object.keys(currentOption).length > 0 && (jsxs(Fragment
|
|
2142
|
+
return (jsxs("div", { className: classNames('d-stepper', className), style: style, children: [jsx("div", { className: "d-step-bar", style: { background: progressStyle }, children: jsx("p", { className: "d-step-number", children: `${currentStep}/${options.length}` }) }), jsx("div", { className: "d-step-info", children: Object.keys(currentOption).length > 0 && (jsxs(Fragment, { children: [jsx("div", { className: "d-step-label", children: currentOption.label }), jsx("div", { className: "d-step-description", children: currentOption.description || '' })] })) })] }));
|
|
2073
2143
|
}
|
|
2074
2144
|
|
|
2075
2145
|
function DStepper({ options, currentStep, iconSuccess, iconSuccessFamilyClass, iconSuccessFamilyPrefix, iconSuccessMaterialStyle = false, vertical = false, breakpoint = 'lg', className, completed = false, style, dataAttributes, }) {
|
|
@@ -2079,7 +2149,7 @@ function DStepper({ options, currentStep, iconSuccess, iconSuccessFamilyClass, i
|
|
|
2079
2149
|
const ARROW_WIDTH = 8;
|
|
2080
2150
|
const ARROW_HEIGHT = 4;
|
|
2081
2151
|
const GAP = 2;
|
|
2082
|
-
function DTooltip({ className, childrenClassName, style, offSet = ARROW_HEIGHT + GAP, padding, withFocus = false, withClick = false, withHover = true, open = false,
|
|
2152
|
+
function DTooltip({ className, childrenClassName, style, offSet = ARROW_HEIGHT + GAP, padding, withFocus = false, withClick = false, withHover = true, open = false, placement = 'top', size, Component, children, }) {
|
|
2083
2153
|
const [isOpen, setIsOpen] = useState(open);
|
|
2084
2154
|
const arrowRef = useRef(null);
|
|
2085
2155
|
const { refs, context, floatingStyles, } = useFloating({
|
|
@@ -2110,8 +2180,14 @@ function DTooltip({ className, childrenClassName, style, offSet = ARROW_HEIGHT +
|
|
|
2110
2180
|
dismiss,
|
|
2111
2181
|
role,
|
|
2112
2182
|
]);
|
|
2113
|
-
const generateClasses = useMemo(() => (Object.assign({ 'tooltip show': true, [`tooltip-${size}`]: !!size
|
|
2114
|
-
return (jsxs(Fragment
|
|
2183
|
+
const generateClasses = useMemo(() => (Object.assign({ 'tooltip show': true, [`tooltip-${size}`]: !!size }, className && { [className]: true })), [size, className]);
|
|
2184
|
+
return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: childrenClassName, ref: refs.setReference }, getReferenceProps(), { children: Component })), jsx(FloatingPortal, { children: isOpen && (jsxs("div", Object.assign({ className: classNames(generateClasses), ref: refs.setFloating, style: Object.assign(Object.assign({}, floatingStyles), style) }, getFloatingProps(), { children: [jsx(FloatingArrow, { ref: arrowRef, context: context, width: ARROW_WIDTH, height: ARROW_HEIGHT }), jsx("div", { className: "tooltip-inner", children: children })] }))) })] }));
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
function DTimeline({ className, style, dataAttributes, items, }) {
|
|
2188
|
+
return (jsx("div", Object.assign({ style: style, className: classNames('d-timeline', className) }, dataAttributes, { children: items.map((item, index) => (jsxs("div", { className: classNames('d-timeline-item', {
|
|
2189
|
+
[`d-timeline-item-${item.status}`]: item.status,
|
|
2190
|
+
}), children: [jsx("div", { className: "d-timeline-item-connector" }), jsx("div", { className: "d-timeline-item-icon", children: jsx("i", { className: `bi bi-${item.icon || 'check'}` }) }), jsxs("div", { className: "d-timeline-item-content", children: [jsx("div", { className: "d-timeline-item-title", children: item.title }), item.description && jsx("div", { className: "d-timeline-item-description", children: item.description }), item.time && jsx("div", { className: "d-timeline-item-time", children: item.time }), item.children] })] }, index))) })));
|
|
2115
2191
|
}
|
|
2116
2192
|
|
|
2117
2193
|
const TabContext = createContext(undefined);
|
|
@@ -2152,7 +2228,7 @@ function DTabs({ children, defaultSelected, onChange, options, className, classN
|
|
|
2152
2228
|
'flex-column': !vertical || variant === 'tabs',
|
|
2153
2229
|
}), style: style }, dataAttributes, { children: [jsx("nav", { className: classNames(generateClasses), children: options.map((option) => (jsx("button", { id: `${option.tab}Tab`, className: classNames('nav-link', {
|
|
2154
2230
|
active: option.tab === selected,
|
|
2155
|
-
}, classNameTab), type: "button", role: "tab", "aria-controls": `${option.tab}Pane`, "aria-selected": option.tab === selected, disabled: option.disabled, onClick: () => onSelect(option), children: option.label }, option.
|
|
2231
|
+
}, classNameTab), type: "button", role: "tab", "aria-controls": `${option.tab}Pane`, "aria-selected": option.tab === selected, disabled: option.disabled, onClick: () => onSelect(option), children: option.label }, option.tab))) }), jsx("div", { className: "tab-content w-100", children: children })] })) }));
|
|
2156
2232
|
}
|
|
2157
2233
|
var DTabs$1 = Object.assign(DTabs, {
|
|
2158
2234
|
Tab: DTabContent,
|
|
@@ -2184,20 +2260,18 @@ function useDToast() {
|
|
|
2184
2260
|
if (typeof data === 'function') {
|
|
2185
2261
|
return toast.custom(data, toastProps);
|
|
2186
2262
|
}
|
|
2187
|
-
const { title, description, icon, closeIcon, timestamp,
|
|
2263
|
+
const { title, description, icon, closeIcon, timestamp, color, } = data;
|
|
2188
2264
|
return toast.custom(({ id, visible }) => {
|
|
2189
2265
|
if (!visible) {
|
|
2190
2266
|
return null;
|
|
2191
2267
|
}
|
|
2192
2268
|
if (!description) {
|
|
2193
2269
|
return (jsx(DToast$1, { className: classNames({
|
|
2194
|
-
[`toast-${
|
|
2195
|
-
[`toast-soft-${theme}`]: !!theme && !!soft,
|
|
2270
|
+
[`toast-${color}`]: !!color,
|
|
2196
2271
|
}, 'show'), children: jsxs(DToast$1.Body, { children: [icon && (jsx(DIcon, { className: "toast-icon", icon: icon })), jsx("p", { className: "toast-title", children: title }), jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: () => toast.dismiss(id), children: jsx(DIcon, { icon: closeIcon || xLg }) })] }) }));
|
|
2197
2272
|
}
|
|
2198
2273
|
return (jsxs(DToast$1, { className: classNames({
|
|
2199
|
-
[`toast-${
|
|
2200
|
-
[`toast-soft-${theme}`]: !!theme && !!soft,
|
|
2274
|
+
[`toast-${color}`]: !!color,
|
|
2201
2275
|
}, 'show'), children: [jsxs(DToast$1.Header, { children: [icon && (jsx(DIcon, { className: "toast-icon", icon: icon })), jsx("p", { className: "toast-title", children: title }), timestamp && (jsx("small", { className: "toast-timestamp", children: timestamp })), jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: () => toast.dismiss(id), children: jsx(DIcon, { icon: closeIcon || xLg }) })] }), jsx(DToast$1.Body, { children: jsx("span", { children: description }) })] }));
|
|
2202
2276
|
}, toastProps);
|
|
2203
2277
|
}, [xLg]);
|
|
@@ -2206,19 +2280,6 @@ function useDToast() {
|
|
|
2206
2280
|
};
|
|
2207
2281
|
}
|
|
2208
2282
|
|
|
2209
|
-
function DTableHead({ className, style, field, label, value = '', onChange, }) {
|
|
2210
|
-
const handleOnChange = useCallback(() => {
|
|
2211
|
-
if (value === field) {
|
|
2212
|
-
return onChange(`-${field}`);
|
|
2213
|
-
}
|
|
2214
|
-
if (value === `-${field}`) {
|
|
2215
|
-
return onChange('');
|
|
2216
|
-
}
|
|
2217
|
-
return onChange(field);
|
|
2218
|
-
}, [field, value, onChange]);
|
|
2219
|
-
return (jsx("th", { style: style, className: classNames('d-table-head', className), children: jsxs("button", { type: "button", onClick: handleOnChange, children: [label, value && value.includes(field) && (jsx(DIcon, { icon: value === field ? 'arrow-up' : 'arrow-down' }))] }) }));
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
2283
|
async function configureI8n(resources, _a = {}) {
|
|
2223
2284
|
var { lng = 'en', fallbackLng = 'en' } = _a, config = __rest(_a, ["lng", "fallbackLng"]);
|
|
2224
2285
|
return i18n
|
|
@@ -2268,7 +2329,7 @@ function validatePhoneNumber(phone) {
|
|
|
2268
2329
|
}
|
|
2269
2330
|
|
|
2270
2331
|
function DInputPhone(_a, ref) {
|
|
2271
|
-
var { id: idProp, style, className, label = '',
|
|
2332
|
+
var { id: idProp, style, className, label = '', 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", "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
2333
|
const innerRef = useProvidedRefOrCreate(ref);
|
|
2273
2334
|
const innerId = useId();
|
|
2274
2335
|
const id = useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -2327,13 +2388,9 @@ function DInputPhone(_a, ref) {
|
|
|
2327
2388
|
placeholder,
|
|
2328
2389
|
valid,
|
|
2329
2390
|
]);
|
|
2330
|
-
const labelComponent = useMemo(() => (
|
|
2391
|
+
const labelComponent = useMemo(() => (jsx("label", { htmlFor: id, children: label })), [
|
|
2331
2392
|
id,
|
|
2332
2393
|
label,
|
|
2333
|
-
labelIcon,
|
|
2334
|
-
labelIconFamilyClass,
|
|
2335
|
-
labelIconFamilyPrefix,
|
|
2336
|
-
labelIconMaterialStyle,
|
|
2337
2394
|
]);
|
|
2338
2395
|
const dynamicComponent = useMemo(() => {
|
|
2339
2396
|
if (floatingLabel) {
|
|
@@ -2354,5 +2411,181 @@ function DInputPhone(_a, ref) {
|
|
|
2354
2411
|
const ForwardedDInputPhone = forwardRef(DInputPhone);
|
|
2355
2412
|
ForwardedDInputPhone.displayName = 'DInputPhone';
|
|
2356
2413
|
|
|
2357
|
-
|
|
2414
|
+
const DEFAULT_IMAGE = 'https://cdn.modyo.cloud/uploads/06b434f7-b943-4f54-9543-84a904e189aa/original/Visa_Logo_1_.png';
|
|
2415
|
+
const CHIP_IMAGE = 'https://cdn.modyo.cloud/uploads/4660ad00-e5d8-477e-8919-52b53d0a26fb/original/chip-debit-svgrepo-com_1_.png';
|
|
2416
|
+
function DCreditCard({ brand = 'visa', name, number, holderText = 'Card Holder', logoImage, isChipVisible = true, className, isVertical = false, }) {
|
|
2417
|
+
return (jsxs("div", { className: classNames('d-credit-card overflow-hidden text-white', 'position-relative rounded-3', 'd-none d-lg-flex', isVertical && 'is-vertical', className), children: [jsxs("div", { className: "d-credit-card-header", children: [jsx("img", { src: logoImage || DEFAULT_IMAGE, alt: brand, className: "d-credit-card-logo", width: 100 }), isChipVisible && (jsx("div", { className: "d-credit-card-chip p-2 rounded-2", children: jsx("img", { src: CHIP_IMAGE, alt: "chip", width: 30, className: "d-credit-card-chip-image" }) }))] }), jsxs("div", { className: "d-credit-card-details mt-auto d-none d-sm-block", children: [jsx("div", { className: "d-credit-card-number d-none d-sm-block mb-4", children: number }), jsx("small", { className: "d-block opacity-50", children: holderText }), jsx("span", { className: "name", children: name })] })] }));
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
const getItemClass = (action) => {
|
|
2421
|
+
const base = `dropdown-item d-flex align-items-center
|
|
2422
|
+
${action.color ? `dropdown-item-${action.color}` : ''} ${action.disabled ? 'disabled' : ''}`;
|
|
2423
|
+
return base;
|
|
2424
|
+
};
|
|
2425
|
+
function DDropdown({ actions, dropdownToggle, className, }) {
|
|
2426
|
+
const [open, setOpen] = useState(false);
|
|
2427
|
+
const dropdownRef = useRef(null);
|
|
2428
|
+
const [position, setPosition] = useState('down'); // 🆕
|
|
2429
|
+
// Cerrar al hacer click fuera
|
|
2430
|
+
useEffect(() => {
|
|
2431
|
+
const handleClickOutside = (event) => {
|
|
2432
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
2433
|
+
setOpen(false);
|
|
2434
|
+
}
|
|
2435
|
+
};
|
|
2436
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
2437
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
2438
|
+
}, []);
|
|
2439
|
+
// 🆕 Calcular posición del menú al abrir
|
|
2440
|
+
useEffect(() => {
|
|
2441
|
+
if (open && dropdownRef.current) {
|
|
2442
|
+
const rect = dropdownRef.current.getBoundingClientRect();
|
|
2443
|
+
const spaceBottom = window.innerHeight - rect.bottom;
|
|
2444
|
+
const spaceRight = window.innerWidth - rect.right;
|
|
2445
|
+
if (spaceBottom < 150) {
|
|
2446
|
+
setPosition('up');
|
|
2447
|
+
}
|
|
2448
|
+
else if (spaceRight < 150) {
|
|
2449
|
+
setPosition('start');
|
|
2450
|
+
}
|
|
2451
|
+
else {
|
|
2452
|
+
setPosition('down');
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
}, [open]);
|
|
2456
|
+
let ToggleElement;
|
|
2457
|
+
if (dropdownToggle) {
|
|
2458
|
+
if (typeof dropdownToggle === 'function') {
|
|
2459
|
+
ToggleElement = dropdownToggle({ open, toggle: () => setOpen(!open) });
|
|
2460
|
+
}
|
|
2461
|
+
else {
|
|
2462
|
+
ToggleElement = dropdownToggle;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
else {
|
|
2466
|
+
ToggleElement = (jsx(DButtonIcon, { variant: "link", stopPropagationEnabled: false, onClick: () => setOpen(!open), icon: "MoreVertical" }));
|
|
2467
|
+
}
|
|
2468
|
+
return (jsxs("div", { className: `dropdown position-relative drop-${position} ${className}`, ref: dropdownRef, children: [ToggleElement, jsx("ul", { style: {
|
|
2469
|
+
position: 'absolute',
|
|
2470
|
+
top: position === 'up' ? 'auto' : '100%',
|
|
2471
|
+
bottom: position === 'up' ? '100%' : 'auto',
|
|
2472
|
+
left: position === 'start' ? 'auto' : 0,
|
|
2473
|
+
right: position === 'start' ? '0' : 'auto',
|
|
2474
|
+
transform: 'translateY(4px)',
|
|
2475
|
+
}, className: `dropdown-menu p-2 ${open ? 'show' : ''}`, children: actions.map((action, index) => {
|
|
2476
|
+
if (action.isDivider) {
|
|
2477
|
+
return (jsx("hr", { className: "dropdown-divider" }, index));
|
|
2478
|
+
}
|
|
2479
|
+
return (jsx("li", { children: action.href ? (jsxs("a", { className: getItemClass(action), href: action.href, onClick: (e) => {
|
|
2480
|
+
if (action.disabled) {
|
|
2481
|
+
e.preventDefault();
|
|
2482
|
+
}
|
|
2483
|
+
else {
|
|
2484
|
+
setOpen(false);
|
|
2485
|
+
}
|
|
2486
|
+
}, children: [action.icon && (jsx(DIcon, { icon: action.icon, className: "me-2", size: "1rem" })), action.label] })) : (jsxs("button", { className: getItemClass(action), type: "button", onClick: () => {
|
|
2487
|
+
var _a;
|
|
2488
|
+
if (!action.disabled) {
|
|
2489
|
+
(_a = action.onClick) === null || _a === void 0 ? void 0 : _a.call(action);
|
|
2490
|
+
setOpen(false);
|
|
2491
|
+
}
|
|
2492
|
+
}, disabled: action.disabled, children: [action.icon && (jsx(DIcon, { icon: action.icon, className: "me-2", size: "1rem" })), action.label] })) }, index));
|
|
2493
|
+
}) })] }));
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
function useScreenshot() {
|
|
2497
|
+
const clipRef = useRef(null);
|
|
2498
|
+
const takeBlob = useCallback(async (type) => {
|
|
2499
|
+
if (!clipRef.current) {
|
|
2500
|
+
throw new Error('set the clipRef');
|
|
2501
|
+
}
|
|
2502
|
+
const canvas = await html2canvas(clipRef === null || clipRef === void 0 ? void 0 : clipRef.current, {
|
|
2503
|
+
allowTaint: true,
|
|
2504
|
+
useCORS: true,
|
|
2505
|
+
});
|
|
2506
|
+
return (new Promise((resolve, reject) => {
|
|
2507
|
+
canvas.toBlob((innerBlob) => {
|
|
2508
|
+
if (!innerBlob) {
|
|
2509
|
+
return reject();
|
|
2510
|
+
}
|
|
2511
|
+
return resolve(innerBlob);
|
|
2512
|
+
}, type);
|
|
2513
|
+
}));
|
|
2514
|
+
}, []);
|
|
2515
|
+
return {
|
|
2516
|
+
clipRef,
|
|
2517
|
+
takeBlob,
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
function useScreenshotDownload() {
|
|
2522
|
+
const { clipRef, takeBlob } = useScreenshot();
|
|
2523
|
+
const download = useCallback(async () => {
|
|
2524
|
+
const blob = await takeBlob();
|
|
2525
|
+
const url = window.URL.createObjectURL(blob);
|
|
2526
|
+
const link = window.document.createElement('a');
|
|
2527
|
+
link.style.display = 'none';
|
|
2528
|
+
link.href = url;
|
|
2529
|
+
link.download = 'voucher.jpg';
|
|
2530
|
+
document.body.appendChild(link);
|
|
2531
|
+
link.click();
|
|
2532
|
+
document.body.removeChild(link);
|
|
2533
|
+
window.URL.revokeObjectURL(url);
|
|
2534
|
+
}, [takeBlob]);
|
|
2535
|
+
return {
|
|
2536
|
+
download,
|
|
2537
|
+
downloadRef: clipRef,
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
function useScreenshotWebShare() {
|
|
2542
|
+
const { takeBlob, clipRef } = useScreenshot();
|
|
2543
|
+
const share = useCallback(async () => {
|
|
2544
|
+
const blob = await takeBlob();
|
|
2545
|
+
const image = new File([blob], 'voucher.jpeg', { type: 'image/jpeg' });
|
|
2546
|
+
if (!navigator.canShare
|
|
2547
|
+
&& (navigator.canShare && !navigator.canShare({ files: [image] }))) {
|
|
2548
|
+
window.print();
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
await navigator.share({ files: [image] });
|
|
2552
|
+
}, [takeBlob]);
|
|
2553
|
+
return {
|
|
2554
|
+
share,
|
|
2555
|
+
shareRef: clipRef,
|
|
2556
|
+
};
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
function DVoucher({ amount, amountDetails, icon = 'CircleCheckBig', color = 'success', title, onError, message, downloadText = 'Download', shareText = 'Share', children, }) {
|
|
2560
|
+
const { shareRef, share } = useScreenshotWebShare();
|
|
2561
|
+
const { downloadRef, download } = useScreenshotDownload();
|
|
2562
|
+
const handleShare = () => {
|
|
2563
|
+
share()
|
|
2564
|
+
.catch(async (err) => {
|
|
2565
|
+
if (onError) {
|
|
2566
|
+
await onError(err);
|
|
2567
|
+
}
|
|
2568
|
+
})
|
|
2569
|
+
.catch(() => {
|
|
2570
|
+
// Error already handled by onError
|
|
2571
|
+
});
|
|
2572
|
+
};
|
|
2573
|
+
const handleDownload = () => {
|
|
2574
|
+
download()
|
|
2575
|
+
.catch(async (err) => {
|
|
2576
|
+
if (onError) {
|
|
2577
|
+
await onError(err);
|
|
2578
|
+
}
|
|
2579
|
+
})
|
|
2580
|
+
.catch(() => {
|
|
2581
|
+
// Error already handled by onError
|
|
2582
|
+
});
|
|
2583
|
+
};
|
|
2584
|
+
return (jsx("div", { className: "d-voucher", ref: (el) => {
|
|
2585
|
+
shareRef.current = el;
|
|
2586
|
+
downloadRef.current = el;
|
|
2587
|
+
}, children: jsxs("div", { children: [jsxs("div", { className: "d-voucher-header", children: [jsx(DIcon, { icon: icon, color: color }), jsxs("div", { className: "text-center", children: [jsx("h3", { className: "mb-2", children: title }), jsx("p", { className: "m-0", children: message })] })] }), amount && (jsxs("div", { className: "d-voucher-amount", children: [jsx("div", { className: classNames('text-center fw-bold fs-3', amountDetails ? 'mb-1' : 'm-0'), children: amount }), amountDetails] })), jsx("hr", { className: "my-4" }), children, jsx("hr", { className: "my-4" }), jsxs("div", { className: "d-voucher-footer", children: [jsx(DButton, { onClick: handleShare, iconStart: "Share2", text: shareText, variant: "outline", size: "sm" }), jsx(DButton, { onClick: handleDownload, iconStart: "Download", text: downloadText, variant: "outline", size: "sm" })] })] }) }));
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
export { DAlert, DAvatar, DBadge, DBox, DBoxFile, DButton, DButtonIcon, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCreditCard, DCurrencyText, DDatePicker, DDropdown, DIcon, DIconBase, ForwardedDInput as DInput, DInputCheck, ForwardedDInputCounter as DInputCounter, ForwardedDInputCurrency as DInputCurrency, ForwardedDInputMask as DInputMask, ForwardedDInputPassword as DInputPassword, ForwardedDInputPhone as DInputPhone, DInputPin, ForwardedDInputRange as DInputRange, DInputSelect, DInputSwitch, DLayout$1 as DLayout, DLayoutPane, DListGroup$1 as DListGroup, DListGroupItem, DModal$1 as DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPasswordStrengthMeter, DPopover, DProgress, DSelect$1 as DSelect, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTabs$1 as DTabs, DTimeline, DToast$1 as DToast, DToastContainer, DTooltip, DVoucher, 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 };
|
|
2358
2591
|
//# sourceMappingURL=index.esm.js.map
|