@dynamic-framework/ui-react 2.0.0-dev.2 → 2.0.0-dev.21
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/README.md +52 -3
- package/dist/css/dynamic-ui-non-root.css +6344 -627
- package/dist/css/dynamic-ui-non-root.min.css +3 -3
- package/dist/css/dynamic-ui-root.css +63 -557
- package/dist/css/dynamic-ui-root.min.css +3 -3
- package/dist/css/dynamic-ui.css +6405 -1182
- package/dist/css/dynamic-ui.min.css +3 -3
- package/dist/index.esm.js +520 -159
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +542 -179
- package/dist/index.js.map +1 -1
- package/dist/types/components/DBoxFile/DBoxFile.d.ts +1 -1
- package/dist/types/components/DButton/DButton.d.ts +7 -17
- package/dist/types/components/DCollapse/DCollapse.d.ts +6 -0
- package/dist/types/components/DDatePicker/DDatePicker.d.ts +2 -1
- package/dist/types/components/DDatePicker/components/DDatePickerHeaderSelector.d.ts +2 -1
- package/dist/types/components/DIconBase/DIconBase.d.ts +10 -2
- package/dist/types/components/DInput/DInput.d.ts +2 -1
- 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 +3 -2
- package/dist/types/components/DInputMask/DInputMask.d.ts +7 -17
- package/dist/types/components/DInputPhone/DInputPhone.d.ts +1 -1
- package/dist/types/components/DInputSwitch/DInputSwitch.d.ts +2 -1
- package/dist/types/components/DLayout/DLayout.d.ts +13 -2
- package/dist/types/components/DModal/DModal.d.ts +3 -1
- package/dist/types/components/DOffcanvas/DOffcanvas.d.ts +3 -1
- 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/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 +4 -1
- package/dist/types/hooks/useResponsiveProp.d.ts +35 -0
- package/jest/setup.js +0 -2
- package/package.json +38 -40
- package/src/style/abstracts/_mixins.scss +34 -20
- package/src/style/abstracts/_utilities-hover.scss +55 -0
- package/src/style/abstracts/_utilities.scss +19 -0
- package/src/style/abstracts/variables/_buttons.scss +2 -0
- package/src/style/abstracts/variables/_colors.scss +8 -2
- package/src/style/base/_buttons.scss +25 -142
- package/src/style/base/_label.scss +0 -4
- package/src/style/components/_+import.scss +1 -0
- package/src/style/components/_d-box-file.scss +1 -1
- package/src/style/components/_d-carousel.scss +4 -3
- package/src/style/components/_d-datepicker.scss +23 -4
- package/src/style/components/_d-voucher.scss +29 -0
- package/src/style/dynamic-ui-non-root.scss +2 -0
- package/src/style/dynamic-ui.scss +2 -0
- package/src/style/root/_root.scss +94 -88
- package/dist/types/components/DBarChart/DBarChart.d.ts +0 -9
- package/dist/types/components/DMinimalLineChart/DMinimalLineChart.d.ts +0 -9
- package/dist/types/components/DMultiLineChart/DMultiLineChart.d.ts +0 -9
- package/dist/types/components/DPieChart/DPieChart.d.ts +0 -9
- package/dist/types/components/DRadialBarChart/DRadialBarChart.d.ts +0 -6
- package/dist/types/components/DTableHead/DTableHead.d.ts +0 -9
- package/dist/types/components/DTableHead/index.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var tslib = require('tslib');
|
|
7
7
|
var LucideIcons = require('lucide-react');
|
|
8
8
|
var reactDom = require('react-dom');
|
|
9
|
+
var framerMotion = require('framer-motion');
|
|
9
10
|
var fileSelector = require('file-selector');
|
|
10
11
|
var reactSplide = require('@splidejs/react-splide');
|
|
11
12
|
var currency = require('currency.js');
|
|
@@ -18,6 +19,7 @@ var react = require('@floating-ui/react');
|
|
|
18
19
|
var reactHotToast = require('react-hot-toast');
|
|
19
20
|
var reactInternationalPhone = require('react-international-phone');
|
|
20
21
|
var googleLibphonenumber = require('google-libphonenumber');
|
|
22
|
+
var html2canvas = require('html2canvas');
|
|
21
23
|
var i18n = require('i18next');
|
|
22
24
|
var reactI18next = require('react-i18next');
|
|
23
25
|
|
|
@@ -42,60 +44,6 @@ var LucideIcons__namespace = /*#__PURE__*/_interopNamespaceDefault(LucideIcons);
|
|
|
42
44
|
|
|
43
45
|
const PREFIX_BS = 'bs-';
|
|
44
46
|
|
|
45
|
-
function DIconBase({ icon, color, style, className, size, hasCircle = false, materialStyle = false, familyClass = 'material-symbols-outlined', strokeWidth = 2, dataAttributes, }) {
|
|
46
|
-
// If materialStyle is true, use Material Design icons (legacy)
|
|
47
|
-
const useMaterialIcons = materialStyle;
|
|
48
|
-
// Get Lucide icon component
|
|
49
|
-
const LucideIcon = React.useMemo(() => {
|
|
50
|
-
if (useMaterialIcons)
|
|
51
|
-
return null;
|
|
52
|
-
// Try to find the icon in Lucide (expects PascalCase)
|
|
53
|
-
const icons = LucideIcons__namespace;
|
|
54
|
-
return icons[icon] || null;
|
|
55
|
-
}, [icon, useMaterialIcons]);
|
|
56
|
-
const colorStyle = React.useMemo(() => {
|
|
57
|
-
if (color) {
|
|
58
|
-
return { [`--${PREFIX_BS}icon-component-color`]: `var(--${PREFIX_BS}${color})` };
|
|
59
|
-
}
|
|
60
|
-
return {};
|
|
61
|
-
}, [color]);
|
|
62
|
-
const backgroundStyle = React.useMemo(() => {
|
|
63
|
-
if (hasCircle) {
|
|
64
|
-
if (color) {
|
|
65
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}${color}-rgb), 0.1)` };
|
|
66
|
-
}
|
|
67
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}body-color-rgb), 0.1)` };
|
|
68
|
-
}
|
|
69
|
-
return {};
|
|
70
|
-
}, [hasCircle, color]);
|
|
71
|
-
const generateStyleVariables = React.useMemo(() => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, size && { [`--${PREFIX_BS}icon-component-size`]: size }), colorStyle), backgroundStyle), hasCircle && { [`--${PREFIX_BS}icon-component-padding`]: `calc(var(--${PREFIX_BS}icon-component-size, 24px) * 0.4)` }), style)), [size, colorStyle, backgroundStyle, hasCircle, style]);
|
|
72
|
-
const generateClasses = React.useMemo(() => (Object.assign(Object.assign({ 'd-icon': true }, useMaterialIcons && {
|
|
73
|
-
[familyClass]: true,
|
|
74
|
-
}), className && { [className]: true })), [
|
|
75
|
-
className,
|
|
76
|
-
useMaterialIcons,
|
|
77
|
-
familyClass,
|
|
78
|
-
]);
|
|
79
|
-
const iconSize = React.useMemo(() => {
|
|
80
|
-
if (size) {
|
|
81
|
-
const numSize = parseInt(size, 10);
|
|
82
|
-
return !Number.isNaN(numSize) ? numSize : size;
|
|
83
|
-
}
|
|
84
|
-
return undefined;
|
|
85
|
-
}, [size]);
|
|
86
|
-
// Render Material Design icon (legacy support)
|
|
87
|
-
if (useMaterialIcons) {
|
|
88
|
-
return (jsxRuntime.jsx("i", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: icon })));
|
|
89
|
-
}
|
|
90
|
-
// Render Lucide icon
|
|
91
|
-
if (!LucideIcon) {
|
|
92
|
-
// eslint-disable-next-line no-console
|
|
93
|
-
console.warn(`Icon "${icon}" not found in Lucide. Make sure to use PascalCase names (e.g., "Home", "User", "Settings")`);
|
|
94
|
-
return (jsxRuntime.jsx("span", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: "?" })));
|
|
95
|
-
}
|
|
96
|
-
return (jsxRuntime.jsx("span", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: jsxRuntime.jsx(LucideIcon, { size: iconSize || 24, strokeWidth: strokeWidth }) })));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
47
|
function useDisableBodyScrollEffect(disable) {
|
|
100
48
|
React.useEffect(() => {
|
|
101
49
|
if (disable) {
|
|
@@ -252,7 +200,10 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
|
|
|
252
200
|
return (jsxRuntime.jsxs(DPortalContext.Provider, { value: value, children: [children, created && reactDom.createPortal(
|
|
253
201
|
// eslint-disable-next-line max-len
|
|
254
202
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
255
|
-
jsxRuntime.jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children:
|
|
203
|
+
jsxRuntime.jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: jsxRuntime.jsx(framerMotion.AnimatePresence, { children: stack.flatMap(({ Component, name, payload, }) => [
|
|
204
|
+
jsxRuntime.jsx(framerMotion.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`),
|
|
205
|
+
jsxRuntime.jsx(Component, { name: name, payload: payload }, name),
|
|
206
|
+
]) }) }), document.getElementById(portalName))] }));
|
|
256
207
|
}
|
|
257
208
|
function useDPortalContext() {
|
|
258
209
|
const context = React.useContext(DPortalContext);
|
|
@@ -348,6 +299,151 @@ function useDContext() {
|
|
|
348
299
|
return context;
|
|
349
300
|
}
|
|
350
301
|
|
|
302
|
+
function subscribeToMediaQuery(query, callback) {
|
|
303
|
+
const mediaQueryList = window.matchMedia(query);
|
|
304
|
+
mediaQueryList.addEventListener('change', callback);
|
|
305
|
+
return () => {
|
|
306
|
+
mediaQueryList.removeEventListener('change', callback);
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function checkMediaQuery(query) {
|
|
310
|
+
return window.matchMedia(query).matches;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function useMediaQuery(mediaQuery, useListener = false) {
|
|
314
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
315
|
+
const noop = (_) => () => { };
|
|
316
|
+
return React.useSyncExternalStore(useListener ? (cb) => subscribeToMediaQuery(mediaQuery, cb) : noop, () => (mediaQuery ? checkMediaQuery(mediaQuery) : true), () => false);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function useMediaBreakpointUp(breakpoint, useListener = false) {
|
|
320
|
+
const { breakpoints } = useDContext();
|
|
321
|
+
const mediaQuery = React.useMemo(() => (`(min-width: ${breakpoints[breakpoint]})`), [breakpoint, breakpoints]);
|
|
322
|
+
return useMediaQuery(mediaQuery, useListener);
|
|
323
|
+
}
|
|
324
|
+
function useMediaBreakpointUpXs(useListener = false) {
|
|
325
|
+
return useMediaBreakpointUp('xs', useListener);
|
|
326
|
+
}
|
|
327
|
+
function useMediaBreakpointUpSm(useListener = false) {
|
|
328
|
+
return useMediaBreakpointUp('sm', useListener);
|
|
329
|
+
}
|
|
330
|
+
function useMediaBreakpointUpMd(useListener = false) {
|
|
331
|
+
return useMediaBreakpointUp('md', useListener);
|
|
332
|
+
}
|
|
333
|
+
function useMediaBreakpointUpLg(useListener = false) {
|
|
334
|
+
return useMediaBreakpointUp('lg', useListener);
|
|
335
|
+
}
|
|
336
|
+
function useMediaBreakpointUpXl(useListener = false) {
|
|
337
|
+
return useMediaBreakpointUp('xl', useListener);
|
|
338
|
+
}
|
|
339
|
+
function useMediaBreakpointUpXxl(useListener = false) {
|
|
340
|
+
return useMediaBreakpointUp('xxl', useListener);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* React hook to resolve a responsive property value based on the current viewport breakpoint.
|
|
345
|
+
*
|
|
346
|
+
* Given a `ResponsiveProp` object, this hook returns the value for the highest matching breakpoint.
|
|
347
|
+
* If multiple breakpoints match, the value for the largest (highest) breakpoint is used.
|
|
348
|
+
* If no breakpoints match, `undefined` is returned.
|
|
349
|
+
*
|
|
350
|
+
* @param useListener - Whether to listen for breakpoint changes (default: false).
|
|
351
|
+
* @returns An object with a `responsivePropValue` function that takes a
|
|
352
|
+
* `ResponsiveProp` and returns the resolved value.
|
|
353
|
+
*
|
|
354
|
+
* Usage example:
|
|
355
|
+
* ```ts
|
|
356
|
+
* const { responsivePropValue } = useResponsiveProp();
|
|
357
|
+
* const value = responsivePropValue({ xs: "A", md: "B", xl: "C" });
|
|
358
|
+
* // value will be "C" if xl breakpoint is active, "B" if md is active, etc.
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
function useResponsiveProp(useListener = false) {
|
|
362
|
+
const bpXsUp = useMediaBreakpointUpXs(useListener);
|
|
363
|
+
const bpSmUp = useMediaBreakpointUpSm(useListener);
|
|
364
|
+
const bpMdUp = useMediaBreakpointUpMd(useListener);
|
|
365
|
+
const bpLgUp = useMediaBreakpointUpLg(useListener);
|
|
366
|
+
const bpXlUp = useMediaBreakpointUpXl(useListener);
|
|
367
|
+
const bpXxlUp = useMediaBreakpointUpXxl(useListener);
|
|
368
|
+
const responsivePropValue = React.useCallback((prop) => {
|
|
369
|
+
// Pick the highest matched breakpoint value that is defined in prop
|
|
370
|
+
if (prop.xxl !== undefined && bpXxlUp)
|
|
371
|
+
return prop.xxl;
|
|
372
|
+
if (prop.xl !== undefined && bpXlUp)
|
|
373
|
+
return prop.xl;
|
|
374
|
+
if (prop.lg !== undefined && bpLgUp)
|
|
375
|
+
return prop.lg;
|
|
376
|
+
if (prop.md !== undefined && bpMdUp)
|
|
377
|
+
return prop.md;
|
|
378
|
+
if (prop.sm !== undefined && bpSmUp)
|
|
379
|
+
return prop.sm;
|
|
380
|
+
if (prop.xs !== undefined && bpXsUp)
|
|
381
|
+
return prop.xs;
|
|
382
|
+
// Fallback: return undefined if no breakpoint matches
|
|
383
|
+
return undefined;
|
|
384
|
+
}, [bpSmUp, bpMdUp, bpLgUp, bpXlUp, bpXxlUp, bpXsUp]);
|
|
385
|
+
return { responsivePropValue };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function DIconBase({ icon, color, style, className, size, useListenerSize = false, hasCircle = false, materialStyle = false, familyClass, familyPrefix, strokeWidth = 2, dataAttributes, }) {
|
|
389
|
+
// If materialStyle is true, use Material Design icons (legacy)
|
|
390
|
+
const useMaterialIcons = materialStyle;
|
|
391
|
+
// Get Lucide icon component
|
|
392
|
+
const LucideIcon = React.useMemo(() => {
|
|
393
|
+
if (useMaterialIcons)
|
|
394
|
+
return null;
|
|
395
|
+
// Try to find the icon in Lucide (expects PascalCase)
|
|
396
|
+
const icons = LucideIcons__namespace;
|
|
397
|
+
return icons[icon] || null;
|
|
398
|
+
}, [icon, useMaterialIcons]);
|
|
399
|
+
const colorStyle = React.useMemo(() => {
|
|
400
|
+
if (color) {
|
|
401
|
+
return { [`--${PREFIX_BS}icon-component-color`]: `var(--${PREFIX_BS}${color})` };
|
|
402
|
+
}
|
|
403
|
+
return {};
|
|
404
|
+
}, [color]);
|
|
405
|
+
const backgroundStyle = React.useMemo(() => {
|
|
406
|
+
if (hasCircle) {
|
|
407
|
+
if (color) {
|
|
408
|
+
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}${color}-rgb), 0.1)` };
|
|
409
|
+
}
|
|
410
|
+
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}body-color-rgb), 0.1)` };
|
|
411
|
+
}
|
|
412
|
+
return {};
|
|
413
|
+
}, [hasCircle, color]);
|
|
414
|
+
const { responsivePropValue } = useResponsiveProp(useListenerSize);
|
|
415
|
+
const resolvedSize = React.useMemo(() => {
|
|
416
|
+
if (!size)
|
|
417
|
+
return undefined;
|
|
418
|
+
if (typeof size === 'string')
|
|
419
|
+
return size;
|
|
420
|
+
return responsivePropValue(size);
|
|
421
|
+
}, [responsivePropValue, size]);
|
|
422
|
+
const generateStyleVariables = React.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]);
|
|
423
|
+
const generateClasses = React.useMemo(() => (Object.assign({ 'd-icon': true }, className && { [className]: true })), [className]);
|
|
424
|
+
const iconSize = React.useMemo(() => {
|
|
425
|
+
if (resolvedSize) {
|
|
426
|
+
const numSize = parseInt(resolvedSize, 10);
|
|
427
|
+
return !Number.isNaN(numSize) ? numSize : resolvedSize;
|
|
428
|
+
}
|
|
429
|
+
return undefined;
|
|
430
|
+
}, [resolvedSize]);
|
|
431
|
+
// Render Material Design icon (legacy support)
|
|
432
|
+
if (useMaterialIcons) {
|
|
433
|
+
return (jsxRuntime.jsx("i", Object.assign({ className: classNames(generateClasses, familyClass), style: generateStyleVariables }, dataAttributes, { children: icon })));
|
|
434
|
+
}
|
|
435
|
+
// Render Lucide icon
|
|
436
|
+
if (!LucideIcon) {
|
|
437
|
+
if (familyClass && familyPrefix) {
|
|
438
|
+
return (jsxRuntime.jsx("i", Object.assign({ className: classNames(generateClasses, familyClass, `${familyPrefix}${icon}`), style: generateStyleVariables }, dataAttributes)));
|
|
439
|
+
}
|
|
440
|
+
// eslint-disable-next-line no-console
|
|
441
|
+
console.warn(`Icon "${icon}" not found in Lucide. Make sure to use PascalCase names (e.g., "Home", "User", "Settings")`);
|
|
442
|
+
return (jsxRuntime.jsx("span", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: "?" })));
|
|
443
|
+
}
|
|
444
|
+
return (jsxRuntime.jsx("span", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: jsxRuntime.jsx(LucideIcon, { size: iconSize || 24, strokeWidth: strokeWidth }) })));
|
|
445
|
+
}
|
|
446
|
+
|
|
351
447
|
function DIcon(_a) {
|
|
352
448
|
var { familyClass: propFamilyClass, familyPrefix: propFamilyPrefix, materialStyle: propMaterialStyle } = _a, props = tslib.__rest(_a, ["familyClass", "familyPrefix", "materialStyle"]);
|
|
353
449
|
const { icon: { familyClass, familyPrefix, materialStyle, }, } = useDContext();
|
|
@@ -415,7 +511,7 @@ function useProvidedRefOrCreate(providedRef) {
|
|
|
415
511
|
}
|
|
416
512
|
|
|
417
513
|
function DInput(_a, ref) {
|
|
418
|
-
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, onChange, onIconStartClick, onIconEndClick } = _a, inputProps = tslib.__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", "onChange", "onIconStartClick", "onIconEndClick"]);
|
|
514
|
+
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 = tslib.__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"]);
|
|
419
515
|
const inputRef = useProvidedRefOrCreate(ref);
|
|
420
516
|
const innerId = React.useId();
|
|
421
517
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -452,7 +548,7 @@ function DInput(_a, ref) {
|
|
|
452
548
|
const inputComponent = React.useMemo(() => (jsxRuntime.jsx("input", Object.assign({ ref: inputRef, id: id, className: classNames('form-control', {
|
|
453
549
|
'is-invalid': invalid,
|
|
454
550
|
'is-valid': valid,
|
|
455
|
-
}), disabled: disabled || loading, value: value, onChange: handleOnChange }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
|
|
551
|
+
}), disabled: disabled || loading, readOnly: readonly, value: value, onChange: handleOnChange }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
|
|
456
552
|
ariaDescribedby,
|
|
457
553
|
disabled,
|
|
458
554
|
handleOnChange,
|
|
@@ -465,6 +561,7 @@ function DInput(_a, ref) {
|
|
|
465
561
|
floatingLabel,
|
|
466
562
|
valid,
|
|
467
563
|
value,
|
|
564
|
+
readonly,
|
|
468
565
|
]);
|
|
469
566
|
const labelComponent = React.useMemo(() => (jsxRuntime.jsx("label", { htmlFor: id, children: label })), [
|
|
470
567
|
id,
|
|
@@ -884,31 +981,64 @@ function DBoxFile(_a) {
|
|
|
884
981
|
'd-box-file-disabled': props.disabled,
|
|
885
982
|
'd-box-file-valid': isDragValid,
|
|
886
983
|
'd-box-file-invalid': isDragInvalid,
|
|
887
|
-
}, className), style: style }, dataAttributes, { children: jsxRuntime.jsxs("div", Object.assign({ className: "d-box-file-dropzone", ref: rootRef, onDragEnter: handleDragEnter, onDragOver: (e) => e.preventDefault(), onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleClick, onKeyDown: handleKeyDown }, (!props.disabled && !props.noKeyboard ? { tabIndex: 0 } : {}), { role: "presentation", children: [jsxRuntime.jsx("input", { type: "file", multiple: props.multiple, style: { display: 'none' }, ref: inputRef, disabled: props.disabled, onChange: handleFileSelect, onClick: (e) => e.stopPropagation(), tabIndex: -1, accept: acceptAttr }), jsxRuntime.jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }), jsxRuntime.jsx("div", { className: "d-box-content", children: typeof children === 'function'
|
|
984
|
+
}, className), style: style }, dataAttributes, { children: jsxRuntime.jsxs("div", Object.assign({ className: "d-box-file-dropzone", ref: rootRef, onDragEnter: handleDragEnter, onDragOver: (e) => e.preventDefault(), onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleClick, onKeyDown: handleKeyDown }, (!props.disabled && !props.noKeyboard ? { tabIndex: 0 } : {}), { role: "presentation", children: [jsxRuntime.jsx("input", { type: "file", multiple: props.multiple, style: { display: 'none' }, ref: inputRef, disabled: props.disabled, onChange: handleFileSelect, onClick: (e) => e.stopPropagation(), tabIndex: -1, accept: acceptAttr }), icon && iconProp !== false && (jsxRuntime.jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsxRuntime.jsx("div", { className: "d-box-content", children: typeof children === 'function'
|
|
888
985
|
? children(openFileDialog)
|
|
889
|
-
: children })] })) })), !!files.length && (jsxRuntime.jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsxRuntime.jsx(ForwardedDInput, { value: file.name, iconStart: "
|
|
986
|
+
: children || (jsxRuntime.jsx("p", { className: "text-center m-0", children: "Drag and drop some files here, or click to select files" })) })] })) })), !!files.length && (jsxRuntime.jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsxRuntime.jsx(ForwardedDInput, { value: file.name, iconStart: "Paperclip", iconEnd: "Trash", readOnly: true, onIconEndClick: () => handleRemoveFile(index) }, `${file.name} ${index}`))) }))] }));
|
|
890
987
|
}
|
|
891
988
|
|
|
892
|
-
|
|
893
|
-
const
|
|
989
|
+
const DButton = React.forwardRef((props, ref) => {
|
|
990
|
+
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 = tslib.__rest(props, ["color", "size", "variant", "text", "children", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartMaterialStyle", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndMaterialStyle", "loading", "loadingText", "loadingAriaLabel", "disabled", "className", "style", "dataAttributes", "onClick", "type"]);
|
|
991
|
+
const [buttonWidth, setButtonWidth] = React.useState();
|
|
992
|
+
const buttonRef = React.useRef(null);
|
|
993
|
+
const isDisabled = React.useMemo(() => disabled || loading, [disabled, loading]);
|
|
994
|
+
const content = React.useMemo(() => children || text, [children, text]);
|
|
995
|
+
const classes = React.useMemo(() => {
|
|
894
996
|
const variantClass = variant
|
|
895
997
|
? `btn-${variant}-${color}`
|
|
896
998
|
: `btn-${color}`;
|
|
897
|
-
return
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
999
|
+
return {
|
|
1000
|
+
btn: true,
|
|
1001
|
+
[variantClass]: true,
|
|
1002
|
+
[`btn-${size}`]: !!size,
|
|
1003
|
+
loading,
|
|
1004
|
+
};
|
|
1005
|
+
}, [variant, color, size, loading]);
|
|
1006
|
+
const ariaLabel = React.useMemo(() => {
|
|
1007
|
+
const ariaLabelProp = rest['aria-label'];
|
|
1008
|
+
return loading
|
|
1009
|
+
? loadingAriaLabel || ariaLabelProp || text
|
|
1010
|
+
: ariaLabelProp || text;
|
|
1011
|
+
}, [loading, loadingAriaLabel, rest, text]);
|
|
1012
|
+
const handleClick = React.useCallback((event) => {
|
|
1013
|
+
if (disabled || loading) {
|
|
1014
|
+
event.preventDefault();
|
|
1015
|
+
return;
|
|
902
1016
|
}
|
|
903
1017
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
904
|
-
}, [
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1018
|
+
}, [disabled, loading, onClick]);
|
|
1019
|
+
React.useEffect(() => {
|
|
1020
|
+
if (!loading && buttonRef.current) {
|
|
1021
|
+
const width = buttonRef.current.offsetWidth;
|
|
1022
|
+
if (width > 0)
|
|
1023
|
+
setButtonWidth(width);
|
|
1024
|
+
}
|
|
1025
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1026
|
+
}, [content, iconEnd, iconStart]);
|
|
1027
|
+
return (jsxRuntime.jsxs("button", Object.assign({ ref: (node) => {
|
|
1028
|
+
buttonRef.current = node;
|
|
1029
|
+
if (typeof ref === 'function')
|
|
1030
|
+
ref(node);
|
|
1031
|
+
// eslint-disable-next-line max-len
|
|
1032
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
1033
|
+
else if (ref)
|
|
1034
|
+
ref.current = node;
|
|
1035
|
+
},
|
|
1036
|
+
// eslint-disable-next-line react/button-has-type
|
|
1037
|
+
type: type, className: classNames(classes, className), style: Object.assign(Object.assign({}, style), (loading && buttonWidth
|
|
1038
|
+
? { minWidth: `${buttonWidth}px` }
|
|
1039
|
+
: undefined)), disabled: isDisabled, "aria-label": ariaLabel, "aria-busy": loading, "aria-disabled": isDisabled, onClick: handleClick }, dataAttributes, rest, { children: [loading && (jsxRuntime.jsxs("span", { className: "btn-loading", children: [jsxRuntime.jsx("span", { className: "spinner-border spinner-border-sm", "aria-hidden": "true" }), loadingText && jsxRuntime.jsx("span", { role: "status", children: loadingText })] })), !loading && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle })), content, iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle }))] }))] })));
|
|
1040
|
+
});
|
|
1041
|
+
DButton.displayName = 'DButton';
|
|
912
1042
|
|
|
913
1043
|
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, }) {
|
|
914
1044
|
const generateClasses = React.useMemo(() => {
|
|
@@ -944,10 +1074,10 @@ function DCardFooter({ className, style, children, }) {
|
|
|
944
1074
|
return (jsxRuntime.jsx("div", { className: classNames('card-footer', className), style: style, children: children }));
|
|
945
1075
|
}
|
|
946
1076
|
|
|
947
|
-
function DCard({ className, style, children, dataAttributes, }) {
|
|
1077
|
+
function DCard$1({ className, style, children, dataAttributes, }) {
|
|
948
1078
|
return (jsxRuntime.jsx("div", Object.assign({ style: style, className: classNames('card', className) }, dataAttributes, { children: children })));
|
|
949
1079
|
}
|
|
950
|
-
var DCard
|
|
1080
|
+
var DCard = Object.assign(DCard$1, {
|
|
951
1081
|
Header: DCardHeader,
|
|
952
1082
|
Body: DCardBody,
|
|
953
1083
|
Footer: DCardFooter,
|
|
@@ -958,7 +1088,7 @@ function DCarouselSlide(_a) {
|
|
|
958
1088
|
return (jsxRuntime.jsx(reactSplide.SplideSlide, Object.assign({ className: classNames('d-carousel-slide', className) }, props)));
|
|
959
1089
|
}
|
|
960
1090
|
|
|
961
|
-
function DCarousel(_a, ref) {
|
|
1091
|
+
function DCarousel$1(_a, ref) {
|
|
962
1092
|
var { children, className, style, options, dataAttributes } = _a, props = tslib.__rest(_a, ["children", "className", "style", "options", "dataAttributes"]);
|
|
963
1093
|
return (jsxRuntime.jsx(reactSplide.Splide, Object.assign({ className: classNames('d-carousel', className), style: style, ref: ref, options: Object.assign(Object.assign({}, options), { classes: {
|
|
964
1094
|
// Arrows
|
|
@@ -971,9 +1101,9 @@ function DCarousel(_a, ref) {
|
|
|
971
1101
|
page: 'splide__pagination__page d-carousel-pagination-page',
|
|
972
1102
|
} }) }, dataAttributes, props, { children: children })));
|
|
973
1103
|
}
|
|
974
|
-
const ForwardedDCarousel = React.forwardRef(DCarousel);
|
|
1104
|
+
const ForwardedDCarousel = React.forwardRef(DCarousel$1);
|
|
975
1105
|
ForwardedDCarousel.displayName = 'DCarousel';
|
|
976
|
-
var DCarousel
|
|
1106
|
+
var DCarousel = Object.assign(ForwardedDCarousel, {
|
|
977
1107
|
Slide: DCarouselSlide,
|
|
978
1108
|
});
|
|
979
1109
|
|
|
@@ -998,6 +1128,9 @@ function DCollapse({ id, className, style, Component, hasSeparator = false, defa
|
|
|
998
1128
|
return next;
|
|
999
1129
|
});
|
|
1000
1130
|
};
|
|
1131
|
+
React.useEffect(() => {
|
|
1132
|
+
setCollapsed(defaultCollapsed);
|
|
1133
|
+
}, [defaultCollapsed]);
|
|
1001
1134
|
const { iconMap: { chevronDown, chevronUp, }, } = useDContext();
|
|
1002
1135
|
const iconOpen = React.useMemo(() => iconOpenProp || chevronDown, [chevronDown, iconOpenProp]);
|
|
1003
1136
|
const iconClose = React.useMemo(() => iconCloseProp || chevronUp, [chevronUp, iconCloseProp]);
|
|
@@ -1043,7 +1176,7 @@ const ForwardedDDatePickerInput = React.forwardRef(DDatePickerInput);
|
|
|
1043
1176
|
ForwardedDDatePickerInput.displayName = 'DDatePickerInput';
|
|
1044
1177
|
|
|
1045
1178
|
function DInputCheck(_a) {
|
|
1046
|
-
var { id: idProp, type, name, label, ariaLabel, checked = false, disabled = false, invalid = false, valid = false, indeterminate, value, hint, onChange, className, style, dataAttributes } = _a, props = tslib.__rest(_a, ["id", "type", "name", "label", "ariaLabel", "checked", "disabled", "invalid", "valid", "indeterminate", "value", "hint", "onChange", "className", "style", "dataAttributes"]);
|
|
1179
|
+
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 = tslib.__rest(_a, ["id", "type", "name", "label", "ariaLabel", "checked", "disabled", "invalid", "valid", "indeterminate", "inputClassName", "value", "hint", "onChange", "className", "style", "dataAttributes"]);
|
|
1047
1180
|
const innerRef = React.useRef(null);
|
|
1048
1181
|
const innerId = React.useId();
|
|
1049
1182
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -1071,11 +1204,11 @@ function DInputCheck(_a) {
|
|
|
1071
1204
|
const inputComponent = React.useMemo(() => (jsxRuntime.jsx("input", Object.assign({ ref: innerRef, onChange: handleChange, className: classNames('form-check-input', {
|
|
1072
1205
|
'is-invalid': invalid,
|
|
1073
1206
|
'is-valid': valid,
|
|
1074
|
-
},
|
|
1207
|
+
}, inputClassName), style: style, id: id, disabled: disabled, type: type, name: name, value: value, "aria-label": ariaLabel }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, props))), [
|
|
1075
1208
|
handleChange,
|
|
1076
1209
|
invalid,
|
|
1077
1210
|
valid,
|
|
1078
|
-
|
|
1211
|
+
inputClassName,
|
|
1079
1212
|
style,
|
|
1080
1213
|
id,
|
|
1081
1214
|
disabled,
|
|
@@ -1089,7 +1222,7 @@ function DInputCheck(_a) {
|
|
|
1089
1222
|
if (!label) {
|
|
1090
1223
|
return inputComponent;
|
|
1091
1224
|
}
|
|
1092
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className:
|
|
1225
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames('form-check', className) }, dataAttributes, { children: [inputComponent, jsxRuntime.jsx("label", { className: "form-check-label", htmlFor: id, children: label }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1093
1226
|
}
|
|
1094
1227
|
|
|
1095
1228
|
function DSelectOptionCheck(_a) {
|
|
@@ -1167,7 +1300,7 @@ function DSelectPlaceholder(_a) {
|
|
|
1167
1300
|
return (jsxRuntime.jsx(Select.components.Placeholder, Object.assign({ innerProps: innerProps, selectProps: selectProps }, props, { children: children })));
|
|
1168
1301
|
}
|
|
1169
1302
|
|
|
1170
|
-
function DSelect(_a) {
|
|
1303
|
+
function DSelect$1(_a) {
|
|
1171
1304
|
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 = tslib.__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"]);
|
|
1172
1305
|
const innerId = React.useId();
|
|
1173
1306
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -1193,7 +1326,7 @@ function DSelect(_a) {
|
|
|
1193
1326
|
'is-valid': valid,
|
|
1194
1327
|
}), classNamePrefix: "d-select", isDisabled: disabled || loading, isClearable: clearable, isLoading: loading, isRtl: rtl, isSearchable: searchable, isMulti: multi, defaultValue: defaultValue, placeholder: floatingLabel ? '' : placeholder, unstyled: true, components: Object.assign({ Placeholder: DSelectPlaceholder, DropdownIndicator: DSelectDropdownIndicator, ClearIndicator: DSelectClearIndicator, MultiValueRemove: DSelectMultiValueRemove, LoadingIndicator: DSelectLoadingIndicator }, components) }, props)), (iconEnd && !loading) && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading, "aria-label": iconEndAriaLabel, tabIndex: iconEndTabIndex, children: iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1195
1328
|
}
|
|
1196
|
-
var DSelect
|
|
1329
|
+
var DSelect = Object.assign(DSelect$1, {
|
|
1197
1330
|
OptionCheck: DSelectOptionCheck,
|
|
1198
1331
|
OptionIcon: DSelectOptionIcon,
|
|
1199
1332
|
SingleValueIconText: DSelectSingleValueIconText,
|
|
@@ -1214,7 +1347,7 @@ var PickerType;
|
|
|
1214
1347
|
PickerType["Month"] = "month";
|
|
1215
1348
|
PickerType["Year"] = "year";
|
|
1216
1349
|
})(PickerType || (PickerType = {}));
|
|
1217
|
-
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, }) {
|
|
1350
|
+
function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, decreaseYear, increaseYear, monthDate, formatHeaderDate = 'EE, LLLL d', 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, }) {
|
|
1218
1351
|
const { iconMap: { chevronLeft, chevronRight, }, } = useDContext();
|
|
1219
1352
|
const arrayYears = React.useMemo(() => Array.from({ length: maxYearSelect - minYearSelect + 1 }, (_, index) => minYearSelect + index), [maxYearSelect, minYearSelect]);
|
|
1220
1353
|
const years = React.useMemo(() => arrayYears.map((year) => ({
|
|
@@ -1242,13 +1375,13 @@ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMont
|
|
|
1242
1375
|
return (jsxRuntime.jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-year-selector', className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevYearButtonDisabled, ariaLabel: prevYearAriaLabel, className: "header-button" }), jsxRuntime.jsx("p", { children: `${startYear} - ${endYear}` }), jsxRuntime.jsx(DButtonIcon, { icon: iconNext || chevronRight, size: iconSize, variant: "link", onClick: increaseYear, disabled: nextYearButtonDisabled, ariaLabel: nextYearAriaLabel, className: "header-button" })] }));
|
|
1243
1376
|
}
|
|
1244
1377
|
if (pickerType === PickerType.Quarter || pickerType === PickerType.Month) {
|
|
1245
|
-
return (jsxRuntime.jsxs("div", { className: classNames(`react-datepicker__header-selector react-datepicker__header-${pickerType}-selector`, className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), jsxRuntime.jsx("div", { className: "d-flex justify-content-center flex-grow-1", children: showHeaderSelectors ? (jsxRuntime.jsx(DSelect
|
|
1378
|
+
return (jsxRuntime.jsxs("div", { className: classNames(`react-datepicker__header-selector react-datepicker__header-${pickerType}-selector`, className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), jsxRuntime.jsx("div", { className: "d-flex justify-content-center flex-grow-1", children: showHeaderSelectors ? (jsxRuntime.jsx(DSelect, { options: years, value: defaultYear, defaultValue: defaultYear, onChange: (year) => changeYear(Number(year === null || year === void 0 ? void 0 : year.value)), searchable: false })) : (jsxRuntime.jsx("p", { children: defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label })) }), jsxRuntime.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' } })] }));
|
|
1246
1379
|
}
|
|
1247
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "datepicker-top-header", children: [showHeaderSelectors && (jsxRuntime.jsx(
|
|
1380
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "datepicker-top-header", children: [showHeaderSelectors && (jsxRuntime.jsx(DSelect, { 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" })), jsxRuntime.jsx("h4", { className: "mb-0 fw-normal", children: dateFns.format(monthDate, formatHeaderDate, { locale }) })] }), jsxRuntime.jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-day-selector', className), style: style, children: [jsxRuntime.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 ? (jsxRuntime.jsx(DSelect, { 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" })) : (jsxRuntime.jsx("p", { children: `${defaultMonth.label} ${defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label}` })), jsxRuntime.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' } })] })] }));
|
|
1248
1381
|
}
|
|
1249
1382
|
|
|
1250
1383
|
function DDatePicker(_a) {
|
|
1251
|
-
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 = tslib.__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"]);
|
|
1384
|
+
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, formatHeaderDate } = _a, props = tslib.__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", "formatHeaderDate"]);
|
|
1252
1385
|
const pickerType = React.useMemo(() => {
|
|
1253
1386
|
if (props.showQuarterYearPicker)
|
|
1254
1387
|
return PickerType.Quarter;
|
|
@@ -1262,7 +1395,7 @@ function DDatePicker(_a) {
|
|
|
1262
1395
|
props.showMonthYearPicker,
|
|
1263
1396
|
props.showYearPicker,
|
|
1264
1397
|
]);
|
|
1265
|
-
const DatePickerHeader = React.useCallback((headerProps) => (jsxRuntime.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 }))), [
|
|
1398
|
+
const DatePickerHeader = React.useCallback((headerProps) => (jsxRuntime.jsx(DDatePickerHeaderSelector, Object.assign({}, headerProps, { monthsShown: props.monthsShown, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: iconHeaderSize, minYearSelect: minYearSelect, maxYearSelect: maxYearSelect, pickerType: pickerType, showHeaderSelectors: showHeaderSelectors, formatHeaderDate: formatHeaderDate, locale: props.locale }))), [
|
|
1266
1399
|
headerPrevMonthAriaLabel,
|
|
1267
1400
|
headerNextMonthAriaLabel,
|
|
1268
1401
|
iconHeaderSize,
|
|
@@ -1270,6 +1403,7 @@ function DDatePicker(_a) {
|
|
|
1270
1403
|
maxYearSelect,
|
|
1271
1404
|
pickerType,
|
|
1272
1405
|
showHeaderSelectors,
|
|
1406
|
+
formatHeaderDate,
|
|
1273
1407
|
props.monthsShown,
|
|
1274
1408
|
props.locale,
|
|
1275
1409
|
]);
|
|
@@ -1289,11 +1423,19 @@ function DLayoutPane({ className, style, children, cols, colsXs, colsSm, colsMd,
|
|
|
1289
1423
|
return (jsxRuntime.jsx("div", Object.assign({ className: classNames(colsClass, colsXsClass, colsSmClass, colsMdClass, colsLgClass, colsXlClass, colsXxlClass, className), style: style }, dataAttributes, { children: children })));
|
|
1290
1424
|
}
|
|
1291
1425
|
|
|
1292
|
-
function DLayout({ className, style, children, gap, dataAttributes, }) {
|
|
1293
|
-
const
|
|
1294
|
-
|
|
1426
|
+
function DLayout$1({ className, style, children, gap, columns, gapSm, gapMd, gapLg, gapXl, gapXxl, dataAttributes, }) {
|
|
1427
|
+
const gapClasses = classNames({
|
|
1428
|
+
[`gap-${gap}`]: gap !== undefined,
|
|
1429
|
+
[`gap-sm-${gapSm}`]: gapSm !== undefined,
|
|
1430
|
+
[`gap-md-${gapMd}`]: gapMd !== undefined,
|
|
1431
|
+
[`gap-lg-${gapLg}`]: gapLg !== undefined,
|
|
1432
|
+
[`gap-xl-${gapXl}`]: gapXl !== undefined,
|
|
1433
|
+
[`gap-xxl-${gapXxl}`]: gapXxl !== undefined,
|
|
1434
|
+
});
|
|
1435
|
+
const styleWithColumns = Object.assign(Object.assign({}, style), { '--bs-columns': columns });
|
|
1436
|
+
return (jsxRuntime.jsx("div", Object.assign({ style: styleWithColumns, className: classNames('grid', gapClasses, className) }, dataAttributes, { children: children })));
|
|
1295
1437
|
}
|
|
1296
|
-
var DLayout
|
|
1438
|
+
var DLayout = Object.assign(DLayout$1, {
|
|
1297
1439
|
Pane: DLayoutPane,
|
|
1298
1440
|
});
|
|
1299
1441
|
|
|
@@ -1401,47 +1543,6 @@ function useItemSelection({ getItemIdentifier: getItemIdentifierProp, previousSe
|
|
|
1401
1543
|
};
|
|
1402
1544
|
}
|
|
1403
1545
|
|
|
1404
|
-
function subscribeToMediaQuery(query, callback) {
|
|
1405
|
-
const mediaQueryList = window.matchMedia(query);
|
|
1406
|
-
mediaQueryList.addEventListener('change', callback);
|
|
1407
|
-
return () => {
|
|
1408
|
-
mediaQueryList.removeEventListener('change', callback);
|
|
1409
|
-
};
|
|
1410
|
-
}
|
|
1411
|
-
function checkMediaQuery(query) {
|
|
1412
|
-
return window.matchMedia(query).matches;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
function useMediaQuery(mediaQuery, useListener = false) {
|
|
1416
|
-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
1417
|
-
const noop = (_) => () => { };
|
|
1418
|
-
return React.useSyncExternalStore(useListener ? (cb) => subscribeToMediaQuery(mediaQuery, cb) : noop, () => (mediaQuery ? checkMediaQuery(mediaQuery) : true), () => false);
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
function useMediaBreakpointUp(breakpoint, useListener = false) {
|
|
1422
|
-
const { breakpoints } = useDContext();
|
|
1423
|
-
const mediaQuery = React.useMemo(() => (`(min-width: ${breakpoints[breakpoint]})`), [breakpoint, breakpoints]);
|
|
1424
|
-
return useMediaQuery(mediaQuery, useListener);
|
|
1425
|
-
}
|
|
1426
|
-
function useMediaBreakpointUpXs(useListener = false) {
|
|
1427
|
-
return useMediaBreakpointUp('xs', useListener);
|
|
1428
|
-
}
|
|
1429
|
-
function useMediaBreakpointUpSm(useListener = false) {
|
|
1430
|
-
return useMediaBreakpointUp('sm', useListener);
|
|
1431
|
-
}
|
|
1432
|
-
function useMediaBreakpointUpMd(useListener = false) {
|
|
1433
|
-
return useMediaBreakpointUp('md', useListener);
|
|
1434
|
-
}
|
|
1435
|
-
function useMediaBreakpointUpLg(useListener = false) {
|
|
1436
|
-
return useMediaBreakpointUp('lg', useListener);
|
|
1437
|
-
}
|
|
1438
|
-
function useMediaBreakpointUpXl(useListener = false) {
|
|
1439
|
-
return useMediaBreakpointUp('xl', useListener);
|
|
1440
|
-
}
|
|
1441
|
-
function useMediaBreakpointUpXxl(useListener = false) {
|
|
1442
|
-
return useMediaBreakpointUp('xxl', useListener);
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
1546
|
function DInputCounter(_a, ref) {
|
|
1446
1547
|
var { minValue, maxValue, value = minValue, invalid, iconStart: iconStartProp, iconEnd: iconEndProp, iconStartAriaLabel = 'decrease action', iconEndAriaLabel = 'increase action', style, onChange } = _a, props = tslib.__rest(_a, ["minValue", "maxValue", "value", "invalid", "iconStart", "iconEnd", "iconStartAriaLabel", "iconEndAriaLabel", "style", "onChange"]);
|
|
1447
1548
|
const { handleOnWheel, } = useDisableInputWheel(ref);
|
|
@@ -1505,6 +1606,86 @@ function DInputPassword(_a, ref) {
|
|
|
1505
1606
|
const ForwardedDInputPassword = React.forwardRef(DInputPassword);
|
|
1506
1607
|
ForwardedDInputPassword.displayName = 'DInputPassword';
|
|
1507
1608
|
|
|
1609
|
+
function PasswordCheckItem({ password, regex, text, }) {
|
|
1610
|
+
const isValid = regex.test(password);
|
|
1611
|
+
return (jsxRuntime.jsxs("li", { className: "d-flex gap-2 align-items-start small text-gray-600", children: [jsxRuntime.jsx(DIcon, { className: classNames('flex-shrink-0', isValid ? 'text-success' : 'text-gray-300'), icon: isValid ? 'CircleCheck' : 'Circle', size: "16px" }), jsxRuntime.jsx("span", { className: classNames({ 'text-success': isValid }), children: text })] }));
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
const getColorClass = (strength, total) => {
|
|
1615
|
+
const percentage = total > 0 ? strength / total : 0;
|
|
1616
|
+
if (percentage === 0)
|
|
1617
|
+
return 'bg-gray-200';
|
|
1618
|
+
if (percentage <= 0.25)
|
|
1619
|
+
return 'bg-danger';
|
|
1620
|
+
if (percentage <= 0.5)
|
|
1621
|
+
return 'bg-warning';
|
|
1622
|
+
if (percentage <= 0.75)
|
|
1623
|
+
return 'bg-info';
|
|
1624
|
+
return 'bg-success';
|
|
1625
|
+
};
|
|
1626
|
+
function PasswordStrengthBar({ strength, total }) {
|
|
1627
|
+
const percentage = total > 0 ? (strength / total) * 100 : 0;
|
|
1628
|
+
return (jsxRuntime.jsx("div", { className: "w-100 rounded-3 overflow-hidden bg-gray-100 mb-2", style: { height: '8px' }, children: jsxRuntime.jsx("div", { className: `h-100 ${getColorClass(strength, total)}`, style: {
|
|
1629
|
+
width: `${percentage}%`,
|
|
1630
|
+
transition: 'width 0.3s ease-in-out',
|
|
1631
|
+
} }) }));
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
const CHECK_REGEX = {
|
|
1635
|
+
uppercase: /[A-Z]/,
|
|
1636
|
+
lowercase: /[a-z]/,
|
|
1637
|
+
number: /\d/,
|
|
1638
|
+
specialChar: /[~!@#$^*\-_=[\]{}|;,.?]/,
|
|
1639
|
+
};
|
|
1640
|
+
function PasswordChecksList({ password, validationMessages, enabledChecks, }) {
|
|
1641
|
+
const allChecks = [
|
|
1642
|
+
{
|
|
1643
|
+
key: 'uppercase',
|
|
1644
|
+
regex: CHECK_REGEX.uppercase,
|
|
1645
|
+
text: validationMessages.uppercaseLetter,
|
|
1646
|
+
},
|
|
1647
|
+
{
|
|
1648
|
+
key: 'lowercase',
|
|
1649
|
+
regex: CHECK_REGEX.lowercase,
|
|
1650
|
+
text: validationMessages.lowercaseLetter,
|
|
1651
|
+
},
|
|
1652
|
+
{
|
|
1653
|
+
key: 'number',
|
|
1654
|
+
regex: CHECK_REGEX.number,
|
|
1655
|
+
text: validationMessages.number,
|
|
1656
|
+
},
|
|
1657
|
+
{
|
|
1658
|
+
key: 'specialChar',
|
|
1659
|
+
regex: CHECK_REGEX.specialChar,
|
|
1660
|
+
text: validationMessages.especialChar,
|
|
1661
|
+
},
|
|
1662
|
+
];
|
|
1663
|
+
const passwordChecks = allChecks.filter((check) => enabledChecks.includes(check.key));
|
|
1664
|
+
const passed = passwordChecks.filter((r) => r.regex.test(password)).length;
|
|
1665
|
+
const total = passwordChecks.length;
|
|
1666
|
+
return (jsxRuntime.jsxs("div", { className: "mt-2", children: [jsxRuntime.jsx(PasswordStrengthBar, { strength: passed, total: total }), jsxRuntime.jsx("ul", { className: "list-unstyled m-0 d-flex flex-column gap-2", children: passwordChecks.map(({ key, regex, text }) => (jsxRuntime.jsx(PasswordCheckItem, { password: password, regex: regex, text: text }, key))) })] }));
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
const DEFAULT_VALIDATION_MESSAGES = {
|
|
1670
|
+
number: 'At least one number',
|
|
1671
|
+
lowercaseLetter: 'At least one lowercase letter',
|
|
1672
|
+
uppercaseLetter: 'At least one uppercase letter',
|
|
1673
|
+
especialChar: 'At least one of these special characters: ~!@#$^*-_=[]{}|;,.?',
|
|
1674
|
+
notMatch: 'The password confirmation and the new password do not match.',
|
|
1675
|
+
};
|
|
1676
|
+
const DEFAULT_ENABLED_CHECKS = ['uppercase', 'lowercase', 'number', 'specialChar'];
|
|
1677
|
+
function DPasswordStrengthMeter({ id, label = 'Password', placeholder, value = '', name, disabled = false, invalid = false, validationMessages = DEFAULT_VALIDATION_MESSAGES, enabledChecks = DEFAULT_ENABLED_CHECKS, className, style, dataAttributes, onChange, }) {
|
|
1678
|
+
const [password, setPassword] = React.useState(value);
|
|
1679
|
+
React.useEffect(() => {
|
|
1680
|
+
setPassword(value);
|
|
1681
|
+
}, [value]);
|
|
1682
|
+
const handleChange = (newValue) => {
|
|
1683
|
+
setPassword(newValue);
|
|
1684
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
1685
|
+
};
|
|
1686
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: className, style: style }, dataAttributes, { children: [jsxRuntime.jsx(ForwardedDInputPassword, { id: id, label: label, placeholder: placeholder, value: password, name: name, disabled: disabled, invalid: invalid, onChange: handleChange }), jsxRuntime.jsx(PasswordChecksList, { password: password, validationMessages: validationMessages, enabledChecks: enabledChecks })] })));
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1508
1689
|
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, }) {
|
|
1509
1690
|
const innerId = React.useId();
|
|
1510
1691
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -1668,7 +1849,7 @@ function DInputSelect({ id: idProp, name, label = '', className, style, options
|
|
|
1668
1849
|
}), children: [iconStart && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: iconStartClickHandler, disabled: disabled || loading, "aria-label": iconStartAriaLabel, children: iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })) })), dynamicComponent, iconEnd && !loading && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: iconEndClickHandler, disabled: disabled || loading, "aria-label": iconEndAriaLabel, children: iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) })), loading && (jsxRuntime.jsx("div", { className: "input-group-text form-control-icon loading", children: jsxRuntime.jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsxRuntime.jsx("span", { className: "visually-hidden", children: "Loading..." }) }) }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1669
1850
|
}
|
|
1670
1851
|
|
|
1671
|
-
function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, invalid = false, valid = false, readonly, className, style, dataAttributes, onChange, }) {
|
|
1852
|
+
function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, invalid = false, valid = false, readonly, className, style, dataAttributes, inputClassName, onChange, }) {
|
|
1672
1853
|
const innerId = React.useId();
|
|
1673
1854
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1674
1855
|
const [internalIsChecked, setInternalIsChecked] = React.useState(checked);
|
|
@@ -1680,10 +1861,10 @@ function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, i
|
|
|
1680
1861
|
setInternalIsChecked(value);
|
|
1681
1862
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
1682
1863
|
}, [onChange]);
|
|
1683
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className:
|
|
1864
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames('form-check form-switch', className) }, dataAttributes, { children: [jsxRuntime.jsx("input", { id: id, name: name, onChange: readonly ? () => false : changeHandler, className: classNames('form-check-input', {
|
|
1684
1865
|
'is-invalid': invalid,
|
|
1685
1866
|
'is-valid': valid,
|
|
1686
|
-
},
|
|
1867
|
+
}, inputClassName), style: style, type: "checkbox", role: "switch", checked: internalIsChecked, disabled: disabled, "aria-label": ariaLabel }), label && (jsxRuntime.jsx("label", { className: "form-check-label", htmlFor: id, children: label }))] })));
|
|
1687
1868
|
}
|
|
1688
1869
|
|
|
1689
1870
|
function DInputRange(_a, ref) {
|
|
@@ -1752,10 +1933,10 @@ function DListGroupItem({ as = 'li', action: actionProp, active, disabled, href,
|
|
|
1752
1933
|
}
|
|
1753
1934
|
return Object.assign(Object.assign({}, active && { 'aria-current': true }), disabled && { 'aria-disabled': true });
|
|
1754
1935
|
}, [Tag, active, disabled]);
|
|
1755
|
-
return (jsxRuntime.jsxs(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, Tag === 'a' && href && { href }, onClick && { onClick }, ariaAttributes, dataAttributes, Tag === 'button' && { type: 'button' }, { children: [iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle })),
|
|
1936
|
+
return (jsxRuntime.jsxs(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, Tag === 'a' && href && { href }, onClick && { onClick }, ariaAttributes, dataAttributes, Tag === 'button' && { type: 'button' }, { children: [iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle })), children, iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle, className: "ms-auto" }))] })));
|
|
1756
1937
|
}
|
|
1757
1938
|
|
|
1758
|
-
function DListGroup({ as = 'ul', numbered, flush, horizontal, children, className, style, dataAttributes, }) {
|
|
1939
|
+
function DListGroup$1({ as = 'ul', numbered, flush, horizontal, children, className, style, dataAttributes, }) {
|
|
1759
1940
|
const Tag = React.useMemo(() => {
|
|
1760
1941
|
if (numbered) {
|
|
1761
1942
|
return 'ol';
|
|
@@ -1775,7 +1956,7 @@ function DListGroup({ as = 'ul', numbered, flush, horizontal, children, classNam
|
|
|
1775
1956
|
}, [flush, horizontal, numbered]);
|
|
1776
1957
|
return (jsxRuntime.jsx(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, dataAttributes, { children: children })));
|
|
1777
1958
|
}
|
|
1778
|
-
var DListGroup
|
|
1959
|
+
var DListGroup = Object.assign(DListGroup$1, {
|
|
1779
1960
|
Item: DListGroupItem,
|
|
1780
1961
|
});
|
|
1781
1962
|
|
|
@@ -1797,7 +1978,11 @@ function DModalFooter({ className, style, actionPlacement, children, }) {
|
|
|
1797
1978
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "d-modal-separator" }), jsxRuntime.jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
|
|
1798
1979
|
}
|
|
1799
1980
|
|
|
1800
|
-
|
|
1981
|
+
const defaultTransition$1 = {
|
|
1982
|
+
ease: 'easeInOut',
|
|
1983
|
+
duration: 0.3,
|
|
1984
|
+
};
|
|
1985
|
+
function DModal$1({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom, size, transition, children, dataAttributes, }) {
|
|
1801
1986
|
const fullScreenClass = React.useMemo(() => {
|
|
1802
1987
|
if (fullScreen) {
|
|
1803
1988
|
if (fullScreenFrom) {
|
|
@@ -1808,12 +1993,12 @@ function DModal({ name, className, style, staticBackdrop, scrollable, centered,
|
|
|
1808
1993
|
return '';
|
|
1809
1994
|
}, [fullScreenFrom, fullScreen]);
|
|
1810
1995
|
const generateModalDialogClasses = React.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]);
|
|
1811
|
-
return (jsxRuntime.jsx(
|
|
1996
|
+
return (jsxRuntime.jsx(framerMotion.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 && ({
|
|
1812
1997
|
[`data-${PREFIX_BS}backdrop`]: 'static',
|
|
1813
1998
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1814
1999
|
}), dataAttributes, { children: jsxRuntime.jsx("div", { className: classNames(generateModalDialogClasses), children: jsxRuntime.jsx("div", { className: "modal-content", children: children }) }) })));
|
|
1815
2000
|
}
|
|
1816
|
-
var DModal
|
|
2001
|
+
var DModal = Object.assign(DModal$1, {
|
|
1817
2002
|
Header: DModalHeader,
|
|
1818
2003
|
Body: DModalBody,
|
|
1819
2004
|
Footer: DModalFooter,
|
|
@@ -1837,10 +2022,36 @@ function DOffcanvasFooter({ actionPlacement, children, className, style, }) {
|
|
|
1837
2022
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "d-offcanvas-separator" }), jsxRuntime.jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
|
|
1838
2023
|
}
|
|
1839
2024
|
|
|
1840
|
-
|
|
1841
|
-
|
|
2025
|
+
const variants = {
|
|
2026
|
+
hidden: (openFrom) => {
|
|
2027
|
+
const properties = {};
|
|
2028
|
+
if (openFrom === 'start') {
|
|
2029
|
+
properties.x = '-100%';
|
|
2030
|
+
}
|
|
2031
|
+
if (openFrom === 'end') {
|
|
2032
|
+
properties.x = '100%';
|
|
2033
|
+
}
|
|
2034
|
+
if (openFrom === 'top') {
|
|
2035
|
+
properties.y = '-100%';
|
|
2036
|
+
}
|
|
2037
|
+
if (openFrom === 'bottom') {
|
|
2038
|
+
properties.y = '100%';
|
|
2039
|
+
}
|
|
2040
|
+
return properties;
|
|
2041
|
+
},
|
|
2042
|
+
visible: {
|
|
2043
|
+
x: 0,
|
|
2044
|
+
y: 0,
|
|
2045
|
+
},
|
|
2046
|
+
};
|
|
2047
|
+
const defaultTransition = {
|
|
2048
|
+
ease: 'easeInOut',
|
|
2049
|
+
duration: 0.3,
|
|
2050
|
+
};
|
|
2051
|
+
function DOffcanvas$1({ name, className, style, staticBackdrop, scrollable, openFrom = 'end', transition, children, dataAttributes, }) {
|
|
2052
|
+
return (jsxRuntime.jsx(framerMotion.motion.div, Object.assign({ className: classNames('offcanvas portal show', {
|
|
1842
2053
|
[`offcanvas-${openFrom}`]: openFrom,
|
|
1843
|
-
}, className), style: style, id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false" }, staticBackdrop && ({
|
|
2054
|
+
}, 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 && ({
|
|
1844
2055
|
[`data-${PREFIX_BS}backdrop`]: 'static',
|
|
1845
2056
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1846
2057
|
}), scrollable && ({
|
|
@@ -1848,7 +2059,7 @@ function DOffcanvas({ name, className, style, staticBackdrop, scrollable, openFr
|
|
|
1848
2059
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1849
2060
|
}), dataAttributes, { children: children })));
|
|
1850
2061
|
}
|
|
1851
|
-
var DOffcanvas
|
|
2062
|
+
var DOffcanvas = Object.assign(DOffcanvas$1, {
|
|
1852
2063
|
Header: DOffcanvasHeader,
|
|
1853
2064
|
Body: DOffcanvasBody,
|
|
1854
2065
|
Footer: DOffcanvasFooter,
|
|
@@ -2021,7 +2232,7 @@ function DTabContent({ tab, children, className, style, }) {
|
|
|
2021
2232
|
return (jsxRuntime.jsx("div", { className: classNames('tab-pane fade show active', className), id: `${tab}Pane`, role: "tabpanel", tabIndex: 0, "aria-labelledby": `${tab}Tab`, style: style, children: children }));
|
|
2022
2233
|
}
|
|
2023
2234
|
|
|
2024
|
-
function DTabs({ children, defaultSelected, onChange, options, className, classNameTab, style, vertical, variant = 'underline', dataAttributes, }) {
|
|
2235
|
+
function DTabs$1({ children, defaultSelected, onChange, options, className, classNameTab, style, vertical, variant = 'underline', dataAttributes, }) {
|
|
2025
2236
|
const [selected, setSelected] = React.useState(defaultSelected);
|
|
2026
2237
|
const onSelect = React.useCallback((option) => {
|
|
2027
2238
|
if (option.tab) {
|
|
@@ -2044,7 +2255,7 @@ function DTabs({ children, defaultSelected, onChange, options, className, classN
|
|
|
2044
2255
|
active: option.tab === selected,
|
|
2045
2256
|
}, 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))) }), jsxRuntime.jsx("div", { className: "tab-content w-100", children: children })] })) }));
|
|
2046
2257
|
}
|
|
2047
|
-
var DTabs
|
|
2258
|
+
var DTabs = Object.assign(DTabs$1, {
|
|
2048
2259
|
Tab: DTabContent,
|
|
2049
2260
|
});
|
|
2050
2261
|
|
|
@@ -2056,10 +2267,10 @@ function DToastBody({ children, className, style }) {
|
|
|
2056
2267
|
return (jsxRuntime.jsx("div", { className: classNames('toast-body', className), style: style, children: children }));
|
|
2057
2268
|
}
|
|
2058
2269
|
|
|
2059
|
-
function DToast({ children, className, style, dataAttributes, }) {
|
|
2270
|
+
function DToast$1({ children, className, style, dataAttributes, }) {
|
|
2060
2271
|
return (jsxRuntime.jsx("div", Object.assign({ className: classNames('toast', className), role: "alert", "aria-live": "assertive", "aria-atomic": "true", style: style }, dataAttributes, { children: children })));
|
|
2061
2272
|
}
|
|
2062
|
-
var DToast
|
|
2273
|
+
var DToast = Object.assign(DToast$1, {
|
|
2063
2274
|
Header: DToastHeader,
|
|
2064
2275
|
Body: DToastBody,
|
|
2065
2276
|
});
|
|
@@ -2080,13 +2291,13 @@ function useDToast() {
|
|
|
2080
2291
|
return null;
|
|
2081
2292
|
}
|
|
2082
2293
|
if (!description) {
|
|
2083
|
-
return (jsxRuntime.jsx(DToast
|
|
2294
|
+
return (jsxRuntime.jsx(DToast, { className: classNames({
|
|
2084
2295
|
[`toast-${color}`]: !!color,
|
|
2085
|
-
}, 'show'), children: jsxRuntime.jsxs(DToast
|
|
2296
|
+
}, 'show'), children: jsxRuntime.jsxs(DToast.Body, { children: [icon && (jsxRuntime.jsx(DIcon, { className: "toast-icon", icon: icon })), jsxRuntime.jsx("p", { className: "toast-title", children: title }), jsxRuntime.jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: () => reactHotToast.toast.dismiss(id), children: jsxRuntime.jsx(DIcon, { icon: closeIcon || xLg }) })] }) }));
|
|
2086
2297
|
}
|
|
2087
|
-
return (jsxRuntime.jsxs(DToast
|
|
2298
|
+
return (jsxRuntime.jsxs(DToast, { className: classNames({
|
|
2088
2299
|
[`toast-${color}`]: !!color,
|
|
2089
|
-
}, 'show'), children: [jsxRuntime.jsxs(DToast
|
|
2300
|
+
}, 'show'), children: [jsxRuntime.jsxs(DToast.Header, { children: [icon && (jsxRuntime.jsx(DIcon, { className: "toast-icon", icon: icon })), jsxRuntime.jsx("p", { className: "toast-title", children: title }), timestamp && (jsxRuntime.jsx("small", { className: "toast-timestamp", children: timestamp })), jsxRuntime.jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: () => reactHotToast.toast.dismiss(id), children: jsxRuntime.jsx(DIcon, { icon: closeIcon || xLg }) })] }), jsxRuntime.jsx(DToast.Body, { children: jsxRuntime.jsx("span", { children: description }) })] }));
|
|
2090
2301
|
}, toastProps);
|
|
2091
2302
|
}, [xLg]);
|
|
2092
2303
|
return {
|
|
@@ -2094,19 +2305,6 @@ function useDToast() {
|
|
|
2094
2305
|
};
|
|
2095
2306
|
}
|
|
2096
2307
|
|
|
2097
|
-
function DTableHead({ className, style, field, label, value = '', onChange, }) {
|
|
2098
|
-
const handleOnChange = React.useCallback(() => {
|
|
2099
|
-
if (value === field) {
|
|
2100
|
-
return onChange(`-${field}`);
|
|
2101
|
-
}
|
|
2102
|
-
if (value === `-${field}`) {
|
|
2103
|
-
return onChange('');
|
|
2104
|
-
}
|
|
2105
|
-
return onChange(field);
|
|
2106
|
-
}, [field, value, onChange]);
|
|
2107
|
-
return (jsxRuntime.jsx("th", { style: style, className: classNames('d-table-head', className), children: jsxRuntime.jsxs("button", { type: "button", onClick: handleOnChange, children: [label, value && value.includes(field) && (jsxRuntime.jsx(DIcon, { icon: value === field ? 'arrow-up' : 'arrow-down' }))] }) }));
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
2308
|
async function configureI8n(resources, _a = {}) {
|
|
2111
2309
|
var { lng = 'en', fallbackLng = 'en' } = _a, config = tslib.__rest(_a, ["lng", "fallbackLng"]);
|
|
2112
2310
|
return i18n
|
|
@@ -2320,6 +2518,169 @@ function DDropdown({ actions, dropdownToggle, className, }) {
|
|
|
2320
2518
|
}) })] }));
|
|
2321
2519
|
}
|
|
2322
2520
|
|
|
2521
|
+
function useScreenshot() {
|
|
2522
|
+
const clipRef = React.useRef(null);
|
|
2523
|
+
const takeBlob = React.useCallback(async (type) => {
|
|
2524
|
+
if (!clipRef.current) {
|
|
2525
|
+
throw new Error('set the clipRef');
|
|
2526
|
+
}
|
|
2527
|
+
const canvas = await html2canvas(clipRef === null || clipRef === void 0 ? void 0 : clipRef.current, {
|
|
2528
|
+
allowTaint: true,
|
|
2529
|
+
useCORS: true,
|
|
2530
|
+
});
|
|
2531
|
+
return (new Promise((resolve, reject) => {
|
|
2532
|
+
canvas.toBlob((innerBlob) => {
|
|
2533
|
+
if (!innerBlob) {
|
|
2534
|
+
return reject();
|
|
2535
|
+
}
|
|
2536
|
+
return resolve(innerBlob);
|
|
2537
|
+
}, type);
|
|
2538
|
+
}));
|
|
2539
|
+
}, []);
|
|
2540
|
+
return {
|
|
2541
|
+
clipRef,
|
|
2542
|
+
takeBlob,
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
function useScreenshotDownload() {
|
|
2547
|
+
const { clipRef, takeBlob } = useScreenshot();
|
|
2548
|
+
const download = React.useCallback(async () => {
|
|
2549
|
+
const blob = await takeBlob();
|
|
2550
|
+
const url = window.URL.createObjectURL(blob);
|
|
2551
|
+
const link = window.document.createElement('a');
|
|
2552
|
+
link.style.display = 'none';
|
|
2553
|
+
link.href = url;
|
|
2554
|
+
link.download = 'voucher.jpg';
|
|
2555
|
+
document.body.appendChild(link);
|
|
2556
|
+
link.click();
|
|
2557
|
+
document.body.removeChild(link);
|
|
2558
|
+
window.URL.revokeObjectURL(url);
|
|
2559
|
+
}, [takeBlob]);
|
|
2560
|
+
return {
|
|
2561
|
+
download,
|
|
2562
|
+
downloadRef: clipRef,
|
|
2563
|
+
};
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
function useScreenshotWebShare() {
|
|
2567
|
+
const { takeBlob, clipRef } = useScreenshot();
|
|
2568
|
+
const share = React.useCallback(async () => {
|
|
2569
|
+
const blob = await takeBlob();
|
|
2570
|
+
const image = new File([blob], 'voucher.jpeg', { type: 'image/jpeg' });
|
|
2571
|
+
if (!navigator.canShare
|
|
2572
|
+
&& (navigator.canShare && !navigator.canShare({ files: [image] }))) {
|
|
2573
|
+
window.print();
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
await navigator.share({ files: [image] });
|
|
2577
|
+
}, [takeBlob]);
|
|
2578
|
+
return {
|
|
2579
|
+
share,
|
|
2580
|
+
shareRef: clipRef,
|
|
2581
|
+
};
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
function DVoucher({ amount, amountDetails, icon = 'CircleCheckBig', color = 'success', title, onError, message, downloadText = 'Download', shareText = 'Share', children, }) {
|
|
2585
|
+
const { shareRef, share } = useScreenshotWebShare();
|
|
2586
|
+
const { downloadRef, download } = useScreenshotDownload();
|
|
2587
|
+
const handleShare = () => {
|
|
2588
|
+
share()
|
|
2589
|
+
.catch(async (err) => {
|
|
2590
|
+
if (onError) {
|
|
2591
|
+
await onError(err);
|
|
2592
|
+
}
|
|
2593
|
+
})
|
|
2594
|
+
.catch(() => {
|
|
2595
|
+
// Error already handled by onError
|
|
2596
|
+
});
|
|
2597
|
+
};
|
|
2598
|
+
const handleDownload = () => {
|
|
2599
|
+
download()
|
|
2600
|
+
.catch(async (err) => {
|
|
2601
|
+
if (onError) {
|
|
2602
|
+
await onError(err);
|
|
2603
|
+
}
|
|
2604
|
+
})
|
|
2605
|
+
.catch(() => {
|
|
2606
|
+
// Error already handled by onError
|
|
2607
|
+
});
|
|
2608
|
+
};
|
|
2609
|
+
return (jsxRuntime.jsx("div", { className: "d-voucher", ref: (el) => {
|
|
2610
|
+
shareRef.current = el;
|
|
2611
|
+
downloadRef.current = el;
|
|
2612
|
+
}, children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: "d-voucher-header", children: [jsxRuntime.jsx(DIcon, { icon: icon, color: color }), jsxRuntime.jsxs("div", { className: "text-center", children: [jsxRuntime.jsx("h3", { className: "mb-2", children: title }), jsxRuntime.jsx("p", { className: "m-0", children: message })] })] }), amount && (jsxRuntime.jsxs("div", { className: "d-voucher-amount", children: [jsxRuntime.jsx("div", { className: classNames('text-center fw-bold fs-3', amountDetails ? 'mb-1' : 'm-0'), children: amount }), amountDetails] })), jsxRuntime.jsx("hr", { className: "my-4" }), children, jsxRuntime.jsx("hr", { className: "my-4" }), jsxRuntime.jsxs("div", { className: "d-voucher-footer", children: [jsxRuntime.jsx(DButton, { onClick: handleShare, iconStart: "Share2", text: shareText, variant: "outline", size: "sm" }), jsxRuntime.jsx(DButton, { onClick: handleDownload, iconStart: "Download", text: downloadText, variant: "outline", size: "sm" })] })] }) }));
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
function useCountdown(seconds) {
|
|
2616
|
+
const [secondsLeft, setSecondsLeft] = React.useState(seconds);
|
|
2617
|
+
const [isActive, setIsActive] = React.useState(true);
|
|
2618
|
+
const resetCountdown = React.useCallback((newSeconds = seconds) => {
|
|
2619
|
+
setIsActive(false);
|
|
2620
|
+
setSecondsLeft(newSeconds);
|
|
2621
|
+
}, [seconds]);
|
|
2622
|
+
const restartCountdown = React.useCallback(() => {
|
|
2623
|
+
resetCountdown(seconds);
|
|
2624
|
+
setIsActive(true);
|
|
2625
|
+
}, [resetCountdown, seconds]);
|
|
2626
|
+
React.useEffect(() => {
|
|
2627
|
+
if (!isActive) {
|
|
2628
|
+
return () => { };
|
|
2629
|
+
}
|
|
2630
|
+
const interval = setInterval(() => {
|
|
2631
|
+
setSecondsLeft((prevSeconds) => {
|
|
2632
|
+
const newSeconds = prevSeconds - 1;
|
|
2633
|
+
if (newSeconds <= 0) {
|
|
2634
|
+
clearInterval(interval);
|
|
2635
|
+
setIsActive(false);
|
|
2636
|
+
return 0;
|
|
2637
|
+
}
|
|
2638
|
+
return newSeconds;
|
|
2639
|
+
});
|
|
2640
|
+
}, 1000);
|
|
2641
|
+
return () => clearInterval(interval);
|
|
2642
|
+
}, [isActive]);
|
|
2643
|
+
return { secondsLeft, restartCountdown };
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
const defaultMessage = (secs) => (secs > 0
|
|
2647
|
+
? `Didn't get any code? Resend in: ${secs}s`
|
|
2648
|
+
: "Didn't get any code?");
|
|
2649
|
+
function OtpCountdown({ seconds, resendText, message, }) {
|
|
2650
|
+
const { secondsLeft, restartCountdown } = useCountdown(seconds);
|
|
2651
|
+
return (jsxRuntime.jsxs("div", { className: "d-flex gap-2 align-items-center", children: [jsxRuntime.jsx("p", { className: "mb-0", children: message ? message(secondsLeft) : defaultMessage(secondsLeft) }), jsxRuntime.jsx(DButton, { text: resendText, variant: "link", disabled: secondsLeft > 0, onClick: restartCountdown })] }));
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
const TEXT_PROPS = {
|
|
2655
|
+
resend: 'Resend',
|
|
2656
|
+
resendText: 'Resend code',
|
|
2657
|
+
submit: 'Authorize and continue',
|
|
2658
|
+
title: 'We will send you a 6-digit code to your associated phone number so you can continue with your request.',
|
|
2659
|
+
contact: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { children: "Problems with your digital token? Contact us" }), ' ', jsxRuntime.jsx("a", { href: "https://www.modyo.com", className: "link-primary text-nowrap", target: "_blank", rel: "noreferrer", children: "Contact us" })] })),
|
|
2660
|
+
};
|
|
2661
|
+
function DOtp({ className, action, isLoading, otpSize = 6, texts = TEXT_PROPS, seconds = 15, }) {
|
|
2662
|
+
const [otp, setOtp] = React.useState('');
|
|
2663
|
+
const [invalid, setInvalid] = React.useState(false);
|
|
2664
|
+
const handler = React.useCallback(async () => {
|
|
2665
|
+
if (otp.length < otpSize) {
|
|
2666
|
+
setInvalid(true);
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
setInvalid(false);
|
|
2670
|
+
await action();
|
|
2671
|
+
}, [
|
|
2672
|
+
otp.length,
|
|
2673
|
+
action,
|
|
2674
|
+
otpSize,
|
|
2675
|
+
]);
|
|
2676
|
+
return (jsxRuntime.jsxs("div", { className: className, children: [jsxRuntime.jsx("p", { children: texts.title }), jsxRuntime.jsxs("div", { className: "d-flex flex-column gap-6 pb-4 px-3", children: [jsxRuntime.jsxs("div", { className: "d-flex flex-column gap-6", children: [jsxRuntime.jsx(DInputPin, { className: "modal-otp-pin", characters: otpSize, onChange: (e) => setOtp(e), invalid: invalid && otp.length < otpSize, placeholder: "0" }), jsxRuntime.jsx(OtpCountdown, { seconds: seconds, resendText: texts.resend })] }), jsxRuntime.jsx("hr", { className: "m-0" }), jsxRuntime.jsxs("div", { className: "d-flex flex-column flex-lg-row gap-4 align-items-center", children: [jsxRuntime.jsx(DButton, { text: texts.submit, onClick: () => {
|
|
2677
|
+
handler().catch((err) => {
|
|
2678
|
+
// eslint-disable-next-line no-console
|
|
2679
|
+
console.error('Error in DOtp action:', err);
|
|
2680
|
+
});
|
|
2681
|
+
}, loading: isLoading }), jsxRuntime.jsx("p", { className: "small ms-lg-auto mb-0", children: texts.contact })] })] })] }));
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2323
2684
|
exports.DAlert = DAlert;
|
|
2324
2685
|
exports.DAvatar = DAvatar;
|
|
2325
2686
|
exports.DBadge = DBadge;
|
|
@@ -2327,11 +2688,11 @@ exports.DBox = DBox;
|
|
|
2327
2688
|
exports.DBoxFile = DBoxFile;
|
|
2328
2689
|
exports.DButton = DButton;
|
|
2329
2690
|
exports.DButtonIcon = DButtonIcon;
|
|
2330
|
-
exports.DCard = DCard
|
|
2691
|
+
exports.DCard = DCard;
|
|
2331
2692
|
exports.DCardBody = DCardBody;
|
|
2332
2693
|
exports.DCardFooter = DCardFooter;
|
|
2333
2694
|
exports.DCardHeader = DCardHeader;
|
|
2334
|
-
exports.DCarousel = DCarousel
|
|
2695
|
+
exports.DCarousel = DCarousel;
|
|
2335
2696
|
exports.DCarouselSlide = DCarouselSlide;
|
|
2336
2697
|
exports.DChip = DChip;
|
|
2337
2698
|
exports.DCollapse = DCollapse;
|
|
@@ -2354,32 +2715,34 @@ exports.DInputPin = DInputPin;
|
|
|
2354
2715
|
exports.DInputRange = ForwardedDInputRange;
|
|
2355
2716
|
exports.DInputSelect = DInputSelect;
|
|
2356
2717
|
exports.DInputSwitch = DInputSwitch;
|
|
2357
|
-
exports.DLayout = DLayout
|
|
2718
|
+
exports.DLayout = DLayout;
|
|
2358
2719
|
exports.DLayoutPane = DLayoutPane;
|
|
2359
|
-
exports.DListGroup = DListGroup
|
|
2720
|
+
exports.DListGroup = DListGroup;
|
|
2360
2721
|
exports.DListGroupItem = DListGroupItem;
|
|
2361
|
-
exports.DModal = DModal
|
|
2722
|
+
exports.DModal = DModal;
|
|
2362
2723
|
exports.DModalBody = DModalBody;
|
|
2363
2724
|
exports.DModalFooter = DModalFooter;
|
|
2364
2725
|
exports.DModalHeader = DModalHeader;
|
|
2365
|
-
exports.DOffcanvas = DOffcanvas
|
|
2726
|
+
exports.DOffcanvas = DOffcanvas;
|
|
2366
2727
|
exports.DOffcanvasBody = DOffcanvasBody;
|
|
2367
2728
|
exports.DOffcanvasFooter = DOffcanvasFooter;
|
|
2368
2729
|
exports.DOffcanvasHeader = DOffcanvasHeader;
|
|
2730
|
+
exports.DOtp = DOtp;
|
|
2369
2731
|
exports.DPaginator = DPaginator;
|
|
2732
|
+
exports.DPasswordStrengthMeter = DPasswordStrengthMeter;
|
|
2370
2733
|
exports.DPopover = DPopover;
|
|
2371
2734
|
exports.DProgress = DProgress;
|
|
2372
|
-
exports.DSelect = DSelect
|
|
2735
|
+
exports.DSelect = DSelect;
|
|
2373
2736
|
exports.DStepper = DStepper;
|
|
2374
2737
|
exports.DStepperDesktop = DStepper$2;
|
|
2375
2738
|
exports.DStepperMobile = DStepper$1;
|
|
2376
2739
|
exports.DTabContent = DTabContent;
|
|
2377
|
-
exports.
|
|
2378
|
-
exports.DTabs = DTabs$1;
|
|
2740
|
+
exports.DTabs = DTabs;
|
|
2379
2741
|
exports.DTimeline = DTimeline;
|
|
2380
|
-
exports.DToast = DToast
|
|
2742
|
+
exports.DToast = DToast;
|
|
2381
2743
|
exports.DToastContainer = DToastContainer;
|
|
2382
2744
|
exports.DTooltip = DTooltip;
|
|
2745
|
+
exports.DVoucher = DVoucher;
|
|
2383
2746
|
exports.changeQueryString = changeQueryString;
|
|
2384
2747
|
exports.checkMediaQuery = checkMediaQuery;
|
|
2385
2748
|
exports.configureI18n = configureI8n;
|