@dynamic-framework/ui-react 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +223 -21
- package/README.md +3 -15
- package/dist/css/dynamic-ui.css +3888 -1310
- package/dist/css/dynamic-ui.min.css +1 -1
- package/dist/index.esm.js +887 -555
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +941 -604
- package/dist/index.js.map +1 -1
- package/dist/types/components/DAlert.d.ts +16 -0
- package/dist/types/components/DBadge.d.ts +11 -0
- package/dist/types/components/DBoxFile.d.ts +3 -4
- package/dist/types/components/DButton.d.ts +21 -0
- package/dist/types/components/DCard.d.ts +2 -2
- package/dist/types/components/DCardAccount.d.ts +3 -3
- package/dist/types/components/DCardBody.d.ts +2 -2
- package/dist/types/components/DCardFooter.d.ts +2 -2
- package/dist/types/components/DCardHeader.d.ts +2 -2
- package/dist/types/components/DCarousel.d.ts +3 -3
- package/dist/types/components/DCarouselSlide.d.ts +1 -1
- package/dist/types/components/DChip.d.ts +10 -0
- package/dist/types/components/DCollapse.d.ts +4 -4
- package/dist/types/components/DCollapseIconText.d.ts +3 -4
- package/dist/types/components/DCurrencyText.d.ts +1 -1
- package/dist/types/components/DDatePicker.d.ts +5 -5
- package/dist/types/components/DDatePickerHeader.d.ts +4 -4
- package/dist/types/components/DDatePickerInput.d.ts +7 -7
- package/dist/types/components/DDatePickerTime.d.ts +6 -6
- package/dist/types/components/DFormikInput.d.ts +2 -2
- package/dist/types/components/DFormikInputCurrency.d.ts +1 -1
- package/dist/types/components/DFormikInputSelect.d.ts +3 -6
- package/dist/types/components/DIcon.d.ts +16 -0
- package/dist/types/components/DInput.d.ts +32 -0
- package/dist/types/components/DInputCheck.d.ts +15 -0
- package/dist/types/components/DInputCounter.d.ts +22 -0
- package/dist/types/components/DInputCurrency.d.ts +4 -8
- package/dist/types/components/DInputCurrencyBase.d.ts +24 -0
- package/dist/types/components/DInputPassword.d.ts +17 -0
- package/dist/types/components/DInputPin.d.ts +19 -0
- package/dist/types/components/DInputSearch.d.ts +19 -0
- package/dist/types/components/DInputSelect.d.ts +23 -0
- package/dist/types/components/DInputSwitch.d.ts +11 -0
- package/dist/types/components/DList.d.ts +4 -3
- package/dist/types/components/DListItem.d.ts +4 -4
- package/dist/types/components/DListItemMovement.d.ts +2 -2
- package/dist/types/components/DModal.d.ts +14 -0
- package/dist/types/components/DModalBody.d.ts +6 -0
- package/dist/types/components/DModalFooter.d.ts +6 -0
- package/dist/types/components/DModalHeader.d.ts +7 -0
- package/dist/types/components/DMonthPicker.d.ts +4 -4
- package/dist/types/components/DOffcanvas.d.ts +10 -0
- package/dist/types/components/DOffcanvasBody.d.ts +6 -0
- package/dist/types/components/DOffcanvasFooter.d.ts +6 -0
- package/dist/types/components/DOffcanvasHeader.d.ts +7 -0
- package/dist/types/components/DPaginator.d.ts +4 -4
- package/dist/types/components/DPopover.d.ts +3 -2
- package/dist/types/components/DProgress.d.ts +9 -0
- package/dist/types/components/DQuickActionButton.d.ts +22 -0
- package/dist/types/components/DQuickActionCheck.d.ts +13 -0
- package/dist/types/components/DQuickActionSelect.d.ts +12 -0
- package/dist/types/components/DQuickActionSwitch.d.ts +11 -0
- package/dist/types/components/DSkeleton.d.ts +2 -2
- package/dist/types/components/DStepper.d.ts +3 -3
- package/dist/types/components/DStepperDesktop.d.ts +2 -2
- package/dist/types/components/DStepperMobile.d.ts +2 -2
- package/dist/types/components/DTabContent.d.ts +1 -1
- package/dist/types/components/DTabs.d.ts +5 -5
- package/dist/types/components/DToastContainer.d.ts +2 -3
- package/dist/types/components/DTooltip.d.ts +2 -2
- package/dist/types/components/banking/{MPermissionGroup.d.ts → DPermissionGroup.d.ts} +2 -2
- package/dist/types/components/banking/DPermissionItem.d.ts +1 -1
- package/dist/types/components/banking/{MSummaryCard.d.ts → DSummaryCard.d.ts} +2 -2
- package/dist/types/components/banking/index.d.ts +2 -2
- package/dist/types/components/banking/interface.d.ts +1 -1
- package/dist/types/components/config.d.ts +5 -0
- package/dist/types/components/index.d.ts +46 -20
- package/dist/types/components/interface.d.ts +44 -0
- package/dist/types/contexts/ModalContext.d.ts +12 -12
- package/dist/types/contexts/OffcanvasContext.d.ts +12 -12
- package/dist/types/hooks/useScreenshot.d.ts +1 -1
- package/dist/types/hooks/useToast.d.ts +3 -3
- package/dist/types/stories/components/DBadge.stories.d.ts +1 -1
- package/dist/types/stories/components/DBoxFile.stories.d.ts +1 -1
- package/dist/types/stories/components/DButton.stories.d.ts +1 -1
- package/dist/types/stories/components/DChip.stories.d.ts +1 -1
- package/dist/types/stories/components/DCurrencyText.stories.d.ts +1 -1
- package/dist/types/stories/components/DDatePicker.stories.d.ts +1 -1
- package/dist/types/stories/components/DFormikInput.stories.d.ts +1 -1
- package/dist/types/stories/components/DFormikInputCurrency.stories.d.ts +1 -1
- package/dist/types/stories/components/DFormikInputSelect.stories.d.ts +1 -1
- package/dist/types/stories/components/DIcon.stories.d.ts +1 -1
- package/dist/types/stories/components/DInput.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputCheck.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputCounter.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputCurrency.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputCurrencyBase.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputPassword.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputPin.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputSearch.stories.d.ts +1 -1
- package/dist/types/stories/components/DInputSelect.stories.d.ts +7 -3
- package/dist/types/stories/components/DInputSwitch.stories.d.ts +1 -1
- package/dist/types/stories/components/DList.stories.d.ts +1 -1
- package/dist/types/stories/components/DListItem.stories.d.ts +1 -1
- package/dist/types/stories/components/DListItemMovement.stories.d.ts +1 -1
- package/dist/types/stories/components/DPaginator.stories.d.ts +1 -1
- package/dist/types/stories/components/DProgress.stories.d.ts +1 -1
- package/dist/types/stories/components/DQuickActionButton.stories.d.ts +1 -1
- package/dist/types/stories/components/DQuickActionCheck.stories.d.ts +1 -1
- package/dist/types/stories/components/DQuickActionSelect.stories.d.ts +1 -1
- package/dist/types/stories/components/DQuickActionSwitch.stories.d.ts +1 -1
- package/dist/types/stories/components/DSkeleton.stories.d.ts +1 -1
- package/dist/types/stories/components/DStepper.stories.d.ts +1 -1
- package/dist/types/stories/components/DStepperDesktop.stories.d.ts +1 -1
- package/dist/types/stories/components/DStepperMobile.stories.d.ts +1 -1
- package/dist/types/stories/components/DTooltip.stories.d.ts +1 -1
- package/dist/types/stories/hooks/useFormatCurrency.stories.d.ts +1 -1
- package/dist/types/stories/hooks/useModalContext.stories.d.ts +1 -1
- package/dist/types/stories/hooks/useOffcanvasContext.stories.d.ts +1 -1
- package/dist/types/stories/hooks/useToast.stories.d.ts +2 -2
- package/dist/types/stories/patterns/DAlert.stories.d.ts +1 -1
- package/dist/types/stories/{components → patterns}/DCard.stories.d.ts +1 -1
- package/dist/types/stories/{components → patterns}/DCardAccount.stories.d.ts +1 -1
- package/dist/types/stories/patterns/DCarousel.stories.d.ts +1 -1
- package/dist/types/stories/patterns/DCollapse.stories.d.ts +1 -1
- package/dist/types/stories/patterns/DCollapseIconText.stories.d.ts +1 -1
- package/dist/types/stories/patterns/DModal.stories.d.ts +1 -1
- package/dist/types/stories/patterns/DOffcanvas.stories.d.ts +1 -1
- package/dist/types/stories/patterns/DPopover.stories.d.ts +2 -1
- package/dist/types/stories/patterns/DTabs.stories.d.ts +1 -1
- package/dist/types/utils/format-currency.d.ts +2 -0
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/liquid-parser.d.ts +20 -0
- package/package.json +62 -49
- package/src/style/_shame.scss +4 -0
- package/src/style/abstracts/_+import.scss +14 -2
- package/src/style/abstracts/_funcions.scss +55 -0
- package/src/style/abstracts/_maps.scss +1 -0
- package/src/style/abstracts/_mixins.scss +133 -0
- package/src/style/abstracts/_utilities.scss +78 -0
- package/src/style/abstracts/variables/_+import.scss +159 -0
- package/src/style/abstracts/variables/_accordion.scss +35 -0
- package/src/style/abstracts/variables/_alerts.scss +27 -0
- package/src/style/abstracts/variables/_badges.scss +15 -0
- package/src/style/abstracts/variables/_body.scss +52 -0
- package/src/style/abstracts/variables/_border.scss +29 -0
- package/src/style/abstracts/variables/_box-shadow.scss +6 -0
- package/src/style/abstracts/variables/_breadcrumb.scss +15 -0
- package/src/style/abstracts/variables/_buttons.scss +55 -0
- package/src/style/abstracts/variables/_cards.scss +23 -0
- package/src/style/abstracts/variables/_carousel.scss +37 -0
- package/src/style/abstracts/variables/_chips.scss +13 -0
- package/src/style/abstracts/variables/_close.scss +16 -0
- package/src/style/abstracts/variables/_code.scss +16 -0
- package/src/style/abstracts/variables/_colors.scss +515 -0
- package/src/style/abstracts/variables/_cursors.scss +32 -0
- package/src/style/abstracts/variables/_dropdowns.scss +54 -0
- package/src/style/abstracts/variables/_figures.scss +6 -0
- package/src/style/abstracts/variables/_forms.scss +313 -0
- package/src/style/abstracts/variables/_grid.scss +41 -0
- package/src/style/abstracts/variables/_list-group.scss +43 -0
- package/src/style/abstracts/variables/_modals.scss +58 -0
- package/src/style/abstracts/variables/_navbar.scss +43 -0
- package/src/style/abstracts/variables/_navs.scss +44 -0
- package/src/style/abstracts/variables/_offcanvas.scss +20 -0
- package/src/style/abstracts/variables/_options.scss +24 -0
- package/src/style/abstracts/variables/_pagination.scss +41 -0
- package/src/style/abstracts/variables/_popovers.scss +31 -0
- package/src/style/abstracts/variables/_progress.scss +17 -0
- package/src/style/abstracts/variables/_quick-action-button.scss +31 -0
- package/src/style/abstracts/variables/_quick-action-check.scss +22 -0
- package/src/style/abstracts/variables/_quick-action-select.scss +16 -0
- package/src/style/abstracts/variables/_quick-action-switch.scss +21 -0
- package/src/style/abstracts/variables/_spacers.scss +28 -0
- package/src/style/abstracts/variables/_spinners.scss +13 -0
- package/src/style/abstracts/variables/_tables.scss +57 -0
- package/src/style/abstracts/variables/_thumbnails.scss +10 -0
- package/src/style/abstracts/variables/_toasts.scss +19 -0
- package/src/style/abstracts/variables/_tooltips.scss +29 -0
- package/src/style/abstracts/variables/_typography.scss +122 -0
- package/src/style/abstracts/variables/_z-index.scss +28 -0
- package/src/style/base/_+import.scss +15 -0
- package/src/style/base/_root.scss +248 -0
- package/src/style/base/_tables.scss +171 -0
- package/src/style/components/_+import.scss +44 -0
- package/src/style/components/_d-alert.scss +45 -0
- package/src/style/components/_d-badge.scss +26 -0
- package/src/style/components/_d-button.scss +191 -0
- package/src/style/components/_d-card-account.scss +1 -1
- package/src/style/components/_d-chip.scss +52 -0
- package/src/style/components/_d-icon.scss +32 -0
- package/src/style/components/_d-input-check.scss +20 -0
- package/src/style/components/_d-input-pin.scss +121 -0
- package/src/style/components/_d-input-select.scss +20 -0
- package/src/style/components/_d-input-switch.scss +58 -0
- package/src/style/components/_d-input.scss +168 -0
- package/src/style/components/_d-modal.scss +55 -0
- package/src/style/components/_d-offcanvas.scss +45 -0
- package/src/style/components/_d-popover.scss +4 -1
- package/src/style/components/_d-progress.scss +9 -0
- package/src/style/components/_d-quick-action-button.scss +111 -0
- package/src/style/components/_d-quick-action-check.scss +74 -0
- package/src/style/components/_d-quick-action-select.scss +56 -0
- package/src/style/components/_d-quick-action-switch.scss +71 -0
- package/src/style/dynamic-root.scss +5 -1
- package/src/style/dynamic-ui.scss +13 -1
- package/src/style/helpers/_+import.scss +13 -0
- package/src/style/helpers/_color-bg.scss +7 -0
- package/dist/css/dynamic-ui-all.css +0 -16620
- package/dist/css/dynamic-ui-all.min.css +0 -1
- package/dist/css/dynamic-ui-react.css +0 -1919
- package/dist/css/dynamic-ui-react.min.css +0 -1
- package/dist/types/components/proxies.d.ts +0 -23
- package/dist/types/components/react-component-lib/createComponent.d.ts +0 -10
- package/dist/types/components/react-component-lib/createOverlayComponent.d.ts +0 -21
- package/dist/types/components/react-component-lib/index.d.ts +0 -2
- package/dist/types/components/react-component-lib/interfaces.d.ts +0 -29
- package/dist/types/components/react-component-lib/utils/attachProps.d.ts +0 -16
- package/dist/types/components/react-component-lib/utils/case.d.ts +0 -2
- package/dist/types/components/react-component-lib/utils/dev.d.ts +0 -2
- package/dist/types/components/react-component-lib/utils/index.d.ts +0 -10
- package/src/style/dynamic-ui-all.scss +0 -3
- package/src/style/dynamic-ui-react.scss +0 -7
- /package/dist/types/stories/{constants.d.ts → config/constants.d.ts} +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,284 +1,303 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
2
|
+
import { useMemo, useState, useEffect, useCallback, createContext, useContext, forwardRef, useRef, useImperativeHandle } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
4
|
import { __rest } from 'tslib';
|
|
5
|
+
import { useDropzone } from 'react-dropzone';
|
|
6
|
+
import { Splide, SplideSlide } from '@splidejs/react-splide';
|
|
7
|
+
import currency from 'currency.js';
|
|
5
8
|
import DatePicker from 'react-datepicker';
|
|
6
9
|
import { DateTime } from 'luxon';
|
|
7
|
-
import React, { createElement, createContext, useMemo, useContext, useState, useCallback, useEffect, forwardRef, useImperativeHandle, useRef } from 'react';
|
|
8
|
-
import { defineCustomElement } from '@dynamic-framework/ui/components/d-alert.js';
|
|
9
|
-
import { defineCustomElement as defineCustomElement$1 } from '@dynamic-framework/ui/components/d-badge.js';
|
|
10
|
-
import { defineCustomElement as defineCustomElement$2 } from '@dynamic-framework/ui/components/d-button.js';
|
|
11
|
-
import { defineCustomElement as defineCustomElement$3 } from '@dynamic-framework/ui/components/d-chip.js';
|
|
12
|
-
import { defineCustomElement as defineCustomElement$4 } from '@dynamic-framework/ui/components/d-icon.js';
|
|
13
|
-
import { defineCustomElement as defineCustomElement$5 } from '@dynamic-framework/ui/components/d-input.js';
|
|
14
|
-
import { defineCustomElement as defineCustomElement$6 } from '@dynamic-framework/ui/components/d-input-check.js';
|
|
15
|
-
import { defineCustomElement as defineCustomElement$7 } from '@dynamic-framework/ui/components/d-input-counter.js';
|
|
16
|
-
import { defineCustomElement as defineCustomElement$8 } from '@dynamic-framework/ui/components/d-input-currency-base.js';
|
|
17
|
-
import { defineCustomElement as defineCustomElement$9 } from '@dynamic-framework/ui/components/d-input-password.js';
|
|
18
|
-
import { defineCustomElement as defineCustomElement$a } from '@dynamic-framework/ui/components/d-input-pin.js';
|
|
19
|
-
import { defineCustomElement as defineCustomElement$b } from '@dynamic-framework/ui/components/d-input-search.js';
|
|
20
|
-
import { defineCustomElement as defineCustomElement$c } from '@dynamic-framework/ui/components/d-input-select.js';
|
|
21
|
-
import { defineCustomElement as defineCustomElement$d } from '@dynamic-framework/ui/components/d-input-switch.js';
|
|
22
|
-
import { defineCustomElement as defineCustomElement$e } from '@dynamic-framework/ui/components/d-modal.js';
|
|
23
|
-
import { defineCustomElement as defineCustomElement$f } from '@dynamic-framework/ui/components/d-offcanvas.js';
|
|
24
|
-
import { defineCustomElement as defineCustomElement$g } from '@dynamic-framework/ui/components/d-progress.js';
|
|
25
|
-
import { defineCustomElement as defineCustomElement$h } from '@dynamic-framework/ui/components/d-quick-action-button.js';
|
|
26
|
-
import { defineCustomElement as defineCustomElement$i } from '@dynamic-framework/ui/components/d-quick-action-check.js';
|
|
27
|
-
import { defineCustomElement as defineCustomElement$j } from '@dynamic-framework/ui/components/d-quick-action-select.js';
|
|
28
|
-
import { defineCustomElement as defineCustomElement$k } from '@dynamic-framework/ui/components/d-quick-action-switch.js';
|
|
29
|
-
import { liquidParser, PREFIX_BS, formatCurrency } from '@dynamic-framework/ui';
|
|
30
|
-
export { liquidParser } from '@dynamic-framework/ui';
|
|
31
|
-
import ContentLoader from 'react-content-loader';
|
|
32
|
-
import classNames from 'classnames';
|
|
33
|
-
import { useFloating, offset, flip, shift, autoUpdate, useClick, useDismiss, useRole, useInteractions, useId, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
|
|
34
10
|
import { useField } from 'formik';
|
|
35
|
-
import { useDropzone } from 'react-dropzone';
|
|
36
|
-
import { Splide, SplideSlide } from '@splidejs/react-splide';
|
|
37
11
|
import ResponsivePagination from 'react-responsive-pagination';
|
|
12
|
+
import { useFloating, offset, flip, shift, autoUpdate, useClick, useDismiss, useRole, useInteractions, useId, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
|
|
13
|
+
import ContentLoader from 'react-content-loader';
|
|
14
|
+
import { toast, Slide, ToastContainer } from 'react-toastify';
|
|
38
15
|
import i18n from 'i18next';
|
|
39
16
|
import { initReactI18next } from 'react-i18next';
|
|
40
17
|
import html2canvas from 'html2canvas';
|
|
41
18
|
import { createPortal } from 'react-dom';
|
|
42
19
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
}
|
|
20
|
+
function DBadge({ text, isDot = false, theme = 'primary', id, className, style, }) {
|
|
21
|
+
const generateClasses = useMemo(() => ({
|
|
22
|
+
badge: true,
|
|
23
|
+
'badge-dot': isDot,
|
|
24
|
+
[`badge-${theme}`]: !!theme,
|
|
25
|
+
}), [isDot, theme]);
|
|
26
|
+
return (jsx("span", Object.assign({ className: classNames(generateClasses, className), style: style }, id && { id }, { children: jsx("span", { children: text }) })));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function DInputSwitch({ label, id, name, isChecked, isDisabled, isReadonly, onChange, }) {
|
|
30
|
+
const [internalIsChecked, setInternalIsChecked] = useState(isChecked);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setInternalIsChecked(isChecked);
|
|
33
|
+
}, [isChecked]);
|
|
34
|
+
const changeHandler = useCallback((event) => {
|
|
35
|
+
const value = event.currentTarget.checked;
|
|
36
|
+
setInternalIsChecked(value);
|
|
37
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
38
|
+
}, [onChange]);
|
|
39
|
+
return (jsxs("div", { className: "form-check form-switch", children: [jsx("input", { id: id, name: name, onChange: isReadonly ? () => false : changeHandler, className: "form-check-input", type: "checkbox", role: "switch", checked: internalIsChecked, disabled: isDisabled }), label && (jsx("label", { className: "form-check-label", htmlFor: id, children: label }))] }));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function DPermissionItem({ permission, permissionState, onChange, onAction = () => { }, }) {
|
|
43
|
+
return (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: () => { }, className: "d-flex permission-item align-items-center", onClick: onAction, children: [jsx("span", { className: "flex-grow-1 label", children: permission.label }), permission.type === 'custom' && (jsx(DBadge, { theme: "tertiary", text: permissionState })), jsx(DInputSwitch, { id: permission.id, isChecked: !!permission.value, isDisabled: !permission.enabled, onChange: (isChecked) => onChange(isChecked) })] }));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function DPermissionGroup({ title, description, permissionState, permissionList, onChangePermission, onCustomAction = () => { }, }) {
|
|
47
|
+
return (jsxs("div", { className: "row operation-group g-0 mb-3 mb-lg-0", children: [jsxs("div", { className: "col-12 col-lg-4 d-flex flex-column justify-content-center", children: [jsx("h6", { className: "fw-bold mb-3 mb-lg-2", children: title }), jsx("p", { className: "fs-8 d-none d-lg-block m-0", children: description })] }), jsx("div", { className: "col-12 offset-lg-1 col-lg-7", children: permissionList.map((permission) => (jsx(DPermissionItem, { permission: permission, permissionState: permissionState, onChange: (isChecked) => onChangePermission(permission, isChecked), onAction: () => onCustomAction(permission) }, permission.id))) })] }));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const PREFIX_BS = 'bs-';
|
|
51
|
+
const ALERT_TYPE_ICON = {
|
|
52
|
+
warning: 'exclamation-circle',
|
|
53
|
+
danger: 'exclamation-triangle',
|
|
54
|
+
success: 'check-circle',
|
|
55
|
+
info: 'info-circle',
|
|
56
|
+
light: 'info-circle',
|
|
57
|
+
dark: 'info-circle',
|
|
83
58
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
|
|
90
|
-
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
|
|
91
|
-
const finalClassNames = [];
|
|
92
|
-
// loop through each of the current classes on the component
|
|
93
|
-
// to see if it should be a part of the classNames added
|
|
94
|
-
currentClasses.forEach((currentClass) => {
|
|
95
|
-
if (incomingPropClasses.has(currentClass)) {
|
|
96
|
-
// add it as its already included in classnames coming in from newProps
|
|
97
|
-
finalClassNames.push(currentClass);
|
|
98
|
-
incomingPropClasses.delete(currentClass);
|
|
59
|
+
|
|
60
|
+
function DIcon({ icon, theme, className = '', size = '1.5rem', isLoading = false, loadingDuration = 1.8, hasCircle = false, circleSize = `calc(var(--${PREFIX_BS}icon-component-size) * 1)`, color, backgroundColor, familyClass = 'bi', familyPrefix = 'bi-', }) {
|
|
61
|
+
const getColorStyle = useMemo(() => {
|
|
62
|
+
if (color) {
|
|
63
|
+
return { [`--${PREFIX_BS}component-color`]: color };
|
|
99
64
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
finalClassNames.push(currentClass);
|
|
65
|
+
if (theme) {
|
|
66
|
+
return { [`--${PREFIX_BS}icon-component-color`]: `var(--${PREFIX_BS}${theme})` };
|
|
103
67
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
* Transforms a React event name to a browser event name.
|
|
110
|
-
*/
|
|
111
|
-
const transformReactEventName = (eventNameSuffix) => {
|
|
112
|
-
switch (eventNameSuffix) {
|
|
113
|
-
case 'doubleclick':
|
|
114
|
-
return 'dblclick';
|
|
115
|
-
}
|
|
116
|
-
return eventNameSuffix;
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Checks if an event is supported in the current execution environment.
|
|
120
|
-
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
121
|
-
*/
|
|
122
|
-
const isCoveredByReact = (eventNameSuffix) => {
|
|
123
|
-
if (typeof document === 'undefined') {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
const eventName = 'on' + transformReactEventName(eventNameSuffix);
|
|
128
|
-
let isSupported = eventName in document;
|
|
129
|
-
if (!isSupported) {
|
|
130
|
-
const element = document.createElement('div');
|
|
131
|
-
element.setAttribute(eventName, 'return;');
|
|
132
|
-
isSupported = typeof element[eventName] === 'function';
|
|
68
|
+
return {};
|
|
69
|
+
}, [color, theme]);
|
|
70
|
+
const getBackgroundStyle = useMemo(() => {
|
|
71
|
+
if (backgroundColor) {
|
|
72
|
+
return { [`--${PREFIX_BS}icon-component-bg-color`]: backgroundColor };
|
|
133
73
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const oldEventHandler = eventStore[eventName];
|
|
140
|
-
// Remove old listener so they don't double up.
|
|
141
|
-
if (oldEventHandler) {
|
|
142
|
-
node.removeEventListener(eventName, oldEventHandler);
|
|
143
|
-
}
|
|
144
|
-
// Bind new listener.
|
|
145
|
-
node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
|
|
146
|
-
if (newEventHandler) {
|
|
147
|
-
newEventHandler.call(this, e);
|
|
74
|
+
if (hasCircle) {
|
|
75
|
+
if (theme) {
|
|
76
|
+
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}${theme}-rgb), 0.1)` };
|
|
77
|
+
}
|
|
78
|
+
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}body-color-rgb), 0.1)` };
|
|
148
79
|
}
|
|
149
|
-
|
|
150
|
-
};
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
};
|
|
80
|
+
return {};
|
|
81
|
+
}, [backgroundColor, hasCircle, theme]);
|
|
82
|
+
const getCircleSizeStyle = useMemo(() => {
|
|
83
|
+
if (hasCircle) {
|
|
84
|
+
return { [`--${PREFIX_BS}icon-component-padding`]: circleSize };
|
|
85
|
+
}
|
|
86
|
+
return { [`--${PREFIX_BS}icon-component-padding`]: '0' };
|
|
87
|
+
}, [circleSize, hasCircle]);
|
|
88
|
+
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign(Object.assign({ [`--${PREFIX_BS}icon-component-size`]: size, [`--${PREFIX_BS}icon-component-loading-duration`]: `${loadingDuration}s` }, getColorStyle), getBackgroundStyle), getCircleSizeStyle)), [size, loadingDuration, getColorStyle, getBackgroundStyle, getCircleSizeStyle]);
|
|
89
|
+
const generateClasses = useMemo(() => ({
|
|
90
|
+
'd-icon': true,
|
|
91
|
+
[className]: !!className,
|
|
92
|
+
[familyClass]: true,
|
|
93
|
+
[`${familyPrefix}${icon}`]: true,
|
|
94
|
+
'd-icon-loading': isLoading,
|
|
95
|
+
}), [familyClass, familyPrefix, icon, className, isLoading]);
|
|
96
|
+
return (jsx("i", { className: classNames(generateClasses), style: generateStyleVariables }));
|
|
97
|
+
}
|
|
156
98
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
else if (ref != null) {
|
|
162
|
-
// Cast as a MutableRef so we can assign current
|
|
163
|
-
ref.current = value;
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
const mergeRefs = (...refs) => {
|
|
167
|
-
return (value) => {
|
|
168
|
-
refs.forEach((ref) => {
|
|
169
|
-
setRef(ref, value);
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
const createForwardRef = (ReactComponent, displayName) => {
|
|
174
|
-
const forwardRef = (props, ref) => {
|
|
175
|
-
return jsx(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
|
|
176
|
-
};
|
|
177
|
-
forwardRef.displayName = displayName;
|
|
178
|
-
const forwardedRef = React.forwardRef(forwardRef);
|
|
179
|
-
forwardedRef.displayName = displayName;
|
|
180
|
-
return forwardedRef;
|
|
181
|
-
};
|
|
99
|
+
function DSummaryCard({ title, description, icon, iconSize, iconTheme, Summary, }) {
|
|
100
|
+
return (jsxs("div", { children: [jsx("h6", { className: "fw-bold fs-6", children: title }), jsx("p", { className: "fs-8", children: description }), jsxs("div", { className: "bg-white rounded p-4 d-flex gap-3 shadow-sm text-gray-700 fs-8", children: [jsx(DIcon, { icon: icon, theme: iconTheme, size: iconSize }), Summary] })] }));
|
|
101
|
+
}
|
|
182
102
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
103
|
+
function DAlert({ type = 'light', icon, iconFamilyClass, iconFamilyPrefix, showIcon = false, showClose, onClose, children, id, className, style, }) {
|
|
104
|
+
const generateClasses = useMemo(() => ({
|
|
105
|
+
alert: true,
|
|
106
|
+
[`alert-${type}`]: true,
|
|
107
|
+
'fade show': !!showClose,
|
|
108
|
+
className: !!className,
|
|
109
|
+
}), [type, showClose, className]);
|
|
110
|
+
const getIcon = useMemo(() => icon || ALERT_TYPE_ICON[type] || '', [icon, type]);
|
|
111
|
+
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign(Object.assign({}, style), { [`--${PREFIX_BS}alert-component-separator-opacity`]: '0.3' }), type === 'light' && {
|
|
112
|
+
[`--${PREFIX_BS}alert-component-icon-color`]: `var(--${PREFIX_BS}secondary)`,
|
|
113
|
+
})), [style, type]);
|
|
114
|
+
return (jsxs("div", { className: classNames(generateClasses), style: generateStyleVariables, role: "alert", id: id, children: [(showIcon || icon) && (jsx(DIcon, Object.assign({ className: "alert-icon", icon: getIcon }, iconFamilyClass && { familyClass: iconFamilyClass }, iconFamilyPrefix && { familyPrefix: iconFamilyPrefix }))), jsx("div", { className: "alert-text", children: children }), showClose && (jsx("div", { className: "alert-separator" })), showClose && (jsx("button", { type: "button", className: "btn-close", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { className: "alert-close-icon", icon: "x-lg", familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) }))] }));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function DBoxFile(_a) {
|
|
118
|
+
var { icon = 'cloud-upload', iconFamilyClass, iconFamilyPrefix, isDisabled = false, children } = _a, dropzoneOptions = __rest(_a, ["icon", "iconFamilyClass", "iconFamilyPrefix", "isDisabled", "children"]);
|
|
119
|
+
const { acceptedFiles, getRootProps, getInputProps, } = useDropzone(Object.assign({ disabled: isDisabled }, dropzoneOptions));
|
|
120
|
+
return (jsxs("section", { className: classNames('d-box-file', {
|
|
121
|
+
'd-box-file-selected': !!acceptedFiles.length,
|
|
122
|
+
}), children: [jsxs("div", Object.assign({}, getRootProps({
|
|
123
|
+
className: classNames('d-box-file-dropzone', {
|
|
124
|
+
disabled: isDisabled,
|
|
125
|
+
}),
|
|
126
|
+
}), { children: [jsx("input", Object.assign({}, getInputProps())), jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }), jsx("div", { className: "d-box-content", children: children })] })), !!acceptedFiles.length && (jsx("aside", { className: "d-box-files", children: acceptedFiles.map((file) => (jsx("div", { className: "d-box-files-text", children: `${file.name} - ${file.size} bytes` }, file.name))) }))] }));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function DButton({ theme = 'primary', size, variant, state, text = '', iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, value, type = 'button', isPill = false, isLoading = false, isDisabled = false, isStopPropagationEnabled = true, className, onClick, }) {
|
|
130
|
+
const generateClasses = useMemo(() => {
|
|
131
|
+
const variantClass = variant
|
|
132
|
+
? `btn-${variant}-${theme}`
|
|
133
|
+
: `btn-${theme}`;
|
|
134
|
+
return Object.assign(Object.assign(Object.assign({ btn: true, [variantClass]: true }, size && { [`btn-${size}`]: true }), (state && state !== 'disabled') && { [state]: true }), { loading: isLoading });
|
|
135
|
+
}, [variant, theme, size, state, isLoading]);
|
|
136
|
+
const generateStyleVariables = useMemo(() => {
|
|
137
|
+
if (isPill) {
|
|
138
|
+
return {
|
|
139
|
+
[`--${PREFIX_BS}btn-component-border-radius`]: `var(--${PREFIX_BS}border-radius-pill)`,
|
|
140
|
+
[`--${PREFIX_BS}btn-component-lg-border-radius`]: `var(--${PREFIX_BS}border-radius-pill)`,
|
|
141
|
+
[`--${PREFIX_BS}btn-component-sm-border-radius`]: `var(--${PREFIX_BS}border-radius-pill)`,
|
|
193
142
|
};
|
|
194
143
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
144
|
+
return {};
|
|
145
|
+
}, [isPill]);
|
|
146
|
+
const clickHandler = useCallback((event) => {
|
|
147
|
+
if (isStopPropagationEnabled) {
|
|
148
|
+
event.stopPropagation();
|
|
200
149
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
206
|
-
const eventName = name.substring(2).toLowerCase();
|
|
207
|
-
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
208
|
-
acc[name] = value;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
// we should only render strings, booleans, and numbers as attrs in html.
|
|
213
|
-
// objects, functions, arrays etc get synced via properties on mount.
|
|
214
|
-
const type = typeof value;
|
|
215
|
-
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
216
|
-
acc[camelToDashCase(name)] = value;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return acc;
|
|
220
|
-
}, {});
|
|
221
|
-
if (manipulatePropsFunction) {
|
|
222
|
-
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
223
|
-
}
|
|
224
|
-
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
|
|
225
|
-
/**
|
|
226
|
-
* We use createElement here instead of
|
|
227
|
-
* React.createElement to work around a
|
|
228
|
-
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
229
|
-
* React.createElement causes all elements to be rendered
|
|
230
|
-
* as <tagname> instead of the actual Web Component.
|
|
231
|
-
*/
|
|
232
|
-
return createElement(tagName, newProps, children);
|
|
233
|
-
}
|
|
234
|
-
static get displayName() {
|
|
235
|
-
return displayName;
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
// If context was passed to createReactComponent then conditionally add it to the Component Class
|
|
239
|
-
if (ReactComponentContext) {
|
|
240
|
-
ReactComponent.contextType = ReactComponentContext;
|
|
241
|
-
}
|
|
242
|
-
return createForwardRef(ReactComponent, displayName);
|
|
243
|
-
};
|
|
150
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
151
|
+
}, [isStopPropagationEnabled, onClick]);
|
|
152
|
+
return (jsxs("button", Object.assign({ className: classNames(generateClasses, className), style: generateStyleVariables, type: type, disabled: state === 'disabled' || isLoading || isDisabled }, value && { value }, { onClick: clickHandler, children: [iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })), (text && !isLoading) && (jsx("span", { children: text })), isLoading && (jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) })), iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix }))] })));
|
|
153
|
+
}
|
|
244
154
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const DButton = /*@__PURE__*/ createReactComponent('d-button', undefined, undefined, defineCustomElement$2);
|
|
249
|
-
const DChip = /*@__PURE__*/ createReactComponent('d-chip', undefined, undefined, defineCustomElement$3);
|
|
250
|
-
const DIcon = /*@__PURE__*/ createReactComponent('d-icon', undefined, undefined, defineCustomElement$4);
|
|
251
|
-
const DInput = /*@__PURE__*/ createReactComponent('d-input', undefined, undefined, defineCustomElement$5);
|
|
252
|
-
const DInputCheck = /*@__PURE__*/ createReactComponent('d-input-check', undefined, undefined, defineCustomElement$6);
|
|
253
|
-
const DInputCounter = /*@__PURE__*/ createReactComponent('d-input-counter', undefined, undefined, defineCustomElement$7);
|
|
254
|
-
const DInputCurrencyBase = /*@__PURE__*/ createReactComponent('d-input-currency-base', undefined, undefined, defineCustomElement$8);
|
|
255
|
-
const DInputPassword = /*@__PURE__*/ createReactComponent('d-input-password', undefined, undefined, defineCustomElement$9);
|
|
256
|
-
const DInputPin = /*@__PURE__*/ createReactComponent('d-input-pin', undefined, undefined, defineCustomElement$a);
|
|
257
|
-
const DInputSearch = /*@__PURE__*/ createReactComponent('d-input-search', undefined, undefined, defineCustomElement$b);
|
|
258
|
-
const DInputSelect = /*@__PURE__*/ createReactComponent('d-input-select', undefined, undefined, defineCustomElement$c);
|
|
259
|
-
const DInputSwitch = /*@__PURE__*/ createReactComponent('d-input-switch', undefined, undefined, defineCustomElement$d);
|
|
260
|
-
const DModal = /*@__PURE__*/ createReactComponent('d-modal', undefined, undefined, defineCustomElement$e);
|
|
261
|
-
const DOffcanvas = /*@__PURE__*/ createReactComponent('d-offcanvas', undefined, undefined, defineCustomElement$f);
|
|
262
|
-
const DProgress = /*@__PURE__*/ createReactComponent('d-progress', undefined, undefined, defineCustomElement$g);
|
|
263
|
-
const DQuickActionButton = /*@__PURE__*/ createReactComponent('d-quick-action-button', undefined, undefined, defineCustomElement$h);
|
|
264
|
-
const DQuickActionCheck = /*@__PURE__*/ createReactComponent('d-quick-action-check', undefined, undefined, defineCustomElement$i);
|
|
265
|
-
const DQuickActionSelect = /*@__PURE__*/ createReactComponent('d-quick-action-select', undefined, undefined, defineCustomElement$j);
|
|
266
|
-
const DQuickActionSwitch = /*@__PURE__*/ createReactComponent('d-quick-action-switch', undefined, undefined, defineCustomElement$k);
|
|
155
|
+
function DCard({ className, style, children, }) {
|
|
156
|
+
return (jsx("div", { style: style, className: classNames('card', className), children: children }));
|
|
157
|
+
}
|
|
267
158
|
|
|
268
|
-
function
|
|
269
|
-
return (
|
|
159
|
+
function DCardBody({ className, children, }) {
|
|
160
|
+
return (jsx("div", { className: classNames('card-body', className), children: children }));
|
|
270
161
|
}
|
|
271
162
|
|
|
272
|
-
function
|
|
273
|
-
return (
|
|
163
|
+
function DCardFooter({ className, children, }) {
|
|
164
|
+
return (jsx("div", { className: classNames('card-footer', className), children: children }));
|
|
274
165
|
}
|
|
275
166
|
|
|
276
|
-
function
|
|
277
|
-
return (
|
|
167
|
+
function DCardHeader({ className, children, }) {
|
|
168
|
+
return (jsx("div", { className: classNames('card-header', className), children: children }));
|
|
278
169
|
}
|
|
279
170
|
|
|
280
|
-
function
|
|
281
|
-
return (jsx(
|
|
171
|
+
function DCardAccount({ className, icon, theme, name, number, balance, balanceText, onClick, actionText, }) {
|
|
172
|
+
return (jsx(DCard, { className: classNames('d-card-account', className), children: jsxs(DCardBody, { children: [jsxs("div", { className: "d-flex gap-3 align-items-center", children: [jsx(DIcon, { icon: icon, hasCircle: true, theme: theme, size: "1.5rem" }), jsxs("div", { className: "d-block flex-grow-1", children: [jsx("p", { className: "text-gray-700", children: name }), jsx("small", { className: "text-gray-500", children: number })] })] }), jsxs("div", { className: "d-block", children: [jsx("p", { className: "fw-bold fs-6 text-body", children: balance }), jsx("small", { className: "text-gray-700", children: balanceText })] }), jsx("div", { className: "d-flex justify-content-end", children: jsx(DButton, { text: actionText, variant: "link", size: "sm", theme: "secondary", iconEnd: "chevron-right", onClick: onClick }) })] }) }));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function DCarousel(_a) {
|
|
176
|
+
var { children, className, options } = _a, props = __rest(_a, ["children", "className", "options"]);
|
|
177
|
+
return (jsx(Splide, Object.assign({ className: classNames('d-carousel', className), options: Object.assign(Object.assign({}, options), { classes: {
|
|
178
|
+
// Arrows
|
|
179
|
+
arrows: 'splide__arrows d-carousel-arrows',
|
|
180
|
+
arrow: 'splide__arrow d-carousel-arrow',
|
|
181
|
+
prev: 'splide__arrow--prev d-carousel-arrow-prev',
|
|
182
|
+
next: 'splide__arrow--next d-carousel-arrow-next',
|
|
183
|
+
// Paginator
|
|
184
|
+
pagination: 'splide__pagination d-carousel-pagination',
|
|
185
|
+
page: 'splide__pagination__page d-carousel-pagination-page',
|
|
186
|
+
} }) }, props, { children: children })));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function DCarouselSlide(_a) {
|
|
190
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
191
|
+
return (jsx(SplideSlide, Object.assign({ className: classNames('d-carousel-slide', className) }, props)));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function DChip({ theme = 'primary', text, icon, iconFamilyClass, iconFamilyPrefix, showClose = false, onClose, }) {
|
|
195
|
+
const generateClasses = useMemo(() => ({
|
|
196
|
+
'd-chip': true,
|
|
197
|
+
[`d-chip-${theme}`]: !!theme,
|
|
198
|
+
}), [theme]);
|
|
199
|
+
return (jsxs("span", { className: classNames(generateClasses), children: [icon && (jsx("div", { className: "d-chip-icon-container", children: jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) })), jsx("span", { children: text }), showClose && (jsx("button", { type: "button", className: "d-chip-icon-container", onClick: onClose, children: jsx(DIcon, { icon: "x-lg" }) }))] }));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function DCollapse({ id, className, Component, hasSeparator = false, defaultCollapsed = false, onChange, children, }) {
|
|
203
|
+
const [toggle, setToggle] = useState(defaultCollapsed);
|
|
204
|
+
const onChangeCollapse = () => setToggle((prev) => !prev);
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
if (onChange) {
|
|
207
|
+
onChange(toggle);
|
|
208
|
+
}
|
|
209
|
+
}, [toggle, onChange]);
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
setToggle(defaultCollapsed);
|
|
212
|
+
}, [defaultCollapsed]);
|
|
213
|
+
const generateStyles = useMemo(() => ({
|
|
214
|
+
[`--${PREFIX_BS}collapse-separator-display`]: hasSeparator ? 'block' : 'none',
|
|
215
|
+
}), [hasSeparator]);
|
|
216
|
+
return (jsxs("div", { id: id, className: classNames('collapse-container', className), children: [jsxs("button", { className: "collapse-button", type: "button", onClick: onChangeCollapse, children: [jsx("div", { className: "flex-grow-1", children: Component }), jsx(DIcon, { color: `var(--${PREFIX_BS}gray)`, size: `var(--${PREFIX_BS}ref-fs-small)`, icon: toggle ? 'chevron-up' : 'chevron-down' })] }), toggle && (jsx("div", { className: classNames({
|
|
217
|
+
'collapse-body': true,
|
|
218
|
+
}), style: generateStyles, children: children }))] }));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function DCollapseIconText({ children, icon, iconSize = '1.5rem', iconTheme = 'primary', title, iconFamilyClass, iconFamilyPrefix, }) {
|
|
222
|
+
return (jsx(DCollapse, { defaultCollapsed: true, className: "d-collapse-icon-text", Component: (jsxs("div", { className: "d-collapse-icon-text-header", children: [jsx(DIcon, { icon: icon, size: iconSize, theme: iconTheme, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, hasCircle: true }), jsx("span", { className: "d-collapse-icon-text-title", children: title })] })), children: children }));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
226
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
227
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
228
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
229
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
230
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
231
|
+
var liquidParser = {
|
|
232
|
+
library: {},
|
|
233
|
+
engine: undefined,
|
|
234
|
+
init(library, Liquid) {
|
|
235
|
+
this.library = library;
|
|
236
|
+
if (Liquid) {
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,global-require
|
|
238
|
+
this.engine = new Liquid.Liquid({
|
|
239
|
+
strictFilters: true,
|
|
240
|
+
strictVariables: true,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* Parse a liquid string
|
|
246
|
+
* @param liquidString Target Content Space UID
|
|
247
|
+
* @returns a usable object or string
|
|
248
|
+
*/
|
|
249
|
+
async parseLiquidAsync(liquidString) {
|
|
250
|
+
try {
|
|
251
|
+
return this.engine.parseAndRender(liquidString, this.library);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
return error.message;
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
/**
|
|
258
|
+
* Parse a liquid string
|
|
259
|
+
* @param liquidString Target Content Space UID
|
|
260
|
+
* @returns a usable object or string
|
|
261
|
+
*/
|
|
262
|
+
parseLiquid(liquidString) {
|
|
263
|
+
try {
|
|
264
|
+
return this.engine.parseAndRenderSync(liquidString, this.library);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
return error.message;
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
parse(liquidString) {
|
|
271
|
+
if (this.engine) {
|
|
272
|
+
return this.parseLiquid(liquidString);
|
|
273
|
+
}
|
|
274
|
+
return liquidString;
|
|
275
|
+
},
|
|
276
|
+
async parseAsync(liquidString) {
|
|
277
|
+
if (this.engine) {
|
|
278
|
+
return this.parseLiquidAsync(liquidString);
|
|
279
|
+
}
|
|
280
|
+
return liquidString;
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
function formatCurrency(amount, options) {
|
|
285
|
+
return currency(amount, options).format();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const LANG = liquidParser.parse('{{site.language}}');
|
|
289
|
+
async function configureI8n(resources, _a = {}) {
|
|
290
|
+
var { lng = LANG, fallbackLng = 'es' } = _a, config = __rest(_a, ["lng", "fallbackLng"]);
|
|
291
|
+
return i18n
|
|
292
|
+
.use(initReactI18next)
|
|
293
|
+
.init(Object.assign({ resources,
|
|
294
|
+
lng, initImmediate: true, fallbackLng, interpolation: {
|
|
295
|
+
escapeValue: false,
|
|
296
|
+
prefix: '{',
|
|
297
|
+
suffix: '}',
|
|
298
|
+
// skipOnVariables: false,
|
|
299
|
+
} }, config))
|
|
300
|
+
.then((t) => t);
|
|
282
301
|
}
|
|
283
302
|
|
|
284
303
|
const LiquidContext = createContext({
|
|
@@ -300,7 +319,7 @@ function LiquidContextProvider({ children, }) {
|
|
|
300
319
|
decimal: liquidParser.parse('{{vars.currency-decimal}}'),
|
|
301
320
|
},
|
|
302
321
|
}), []);
|
|
303
|
-
return (jsx(LiquidContext.Provider,
|
|
322
|
+
return (jsx(LiquidContext.Provider, { value: value, children: children }));
|
|
304
323
|
}
|
|
305
324
|
function useLiquidContext() {
|
|
306
325
|
const context = useContext(LiquidContext);
|
|
@@ -430,10 +449,10 @@ function ModalContextProvider({ portalName, children, availableModals, }) {
|
|
|
430
449
|
openModal,
|
|
431
450
|
closeModal,
|
|
432
451
|
}), [stack, openModal, closeModal]);
|
|
433
|
-
return (jsxs(ModalContext.Provider,
|
|
452
|
+
return (jsxs(ModalContext.Provider, { value: value, children: [children, hasPortal && createPortal(jsxs(Fragment, { children: [stack.map(({ Component, modalName, callbacks, payload, }) => {
|
|
434
453
|
const EnhancedComponent = enhanceModal(Component, callbacks);
|
|
435
454
|
return (jsx(EnhancedComponent, { name: modalName, payload: payload, openModal: openModal, closeModal: closeModal }, modalName));
|
|
436
|
-
}), !!stack.length && jsx("div", { className: "modal-backdrop fade show" })] }), document.getElementById(portalName))] }))
|
|
455
|
+
}), !!stack.length && jsx("div", { className: "modal-backdrop fade show" })] }), document.getElementById(portalName))] }));
|
|
437
456
|
}
|
|
438
457
|
function useModalContext() {
|
|
439
458
|
const context = useContext(ModalContext);
|
|
@@ -517,10 +536,10 @@ function OffcanvasContextProvider({ portalName, children, availableOffcanvas, })
|
|
|
517
536
|
openOffcanvas,
|
|
518
537
|
closeOffcanvas,
|
|
519
538
|
}), [stack, openOffcanvas, closeOffcanvas]);
|
|
520
|
-
return (jsxs(OffcanvasContext.Provider,
|
|
539
|
+
return (jsxs(OffcanvasContext.Provider, { value: value, children: [children, hasPortal && createPortal(jsxs(Fragment, { children: [stack.map(({ Component, offcanvasName, callbacks, payload, }) => {
|
|
521
540
|
const EnhancedComponent = enhanceOffcanvas(Component, callbacks);
|
|
522
541
|
return (jsx(EnhancedComponent, { name: offcanvasName, payload: payload, openOffcanvas: openOffcanvas, closeOffcanvas: closeOffcanvas }, offcanvasName));
|
|
523
|
-
}), !!stack.length && jsx("div", { className: "offcanvas-backdrop fade show" })] }), document.getElementById(portalName))] }))
|
|
542
|
+
}), !!stack.length && jsx("div", { className: "offcanvas-backdrop fade show" })] }), document.getElementById(portalName))] }));
|
|
524
543
|
}
|
|
525
544
|
function useOffcanvasContext() {
|
|
526
545
|
const context = useContext(OffcanvasContext);
|
|
@@ -530,49 +549,99 @@ function useOffcanvasContext() {
|
|
|
530
549
|
return context;
|
|
531
550
|
}
|
|
532
551
|
|
|
552
|
+
function useFormatCurrency(...args) {
|
|
553
|
+
const { currency } = useLiquidContext();
|
|
554
|
+
const format = useCallback((value) => formatCurrency(value, currency), [currency]);
|
|
555
|
+
const values = (args || []).map((value) => (formatCurrency(value !== null && value !== void 0 ? value : 0, currency)));
|
|
556
|
+
return {
|
|
557
|
+
format,
|
|
558
|
+
values,
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function DCurrencyText({ value, className, }) {
|
|
563
|
+
const { values: [valueFormatted] } = useFormatCurrency(value);
|
|
564
|
+
return (jsx("span", { className: className, children: valueFormatted }));
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function DInput({ id, style, className, name, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, placeholder = '', type = 'text', value = '', innerInputMode, pattern, isDisabled = false, isReadOnly = false, isLoading = false, iconFamilyClass, iconFamilyPrefix, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, hint, isInvalid = false, isValid = false, inputStart, onChange, onBlur, onFocus, onWheel, onIconStartClick, onIconEndClick, }, ref) {
|
|
568
|
+
const innerRef = useRef(null);
|
|
569
|
+
const [internalValue, setInternalValue] = useState(value);
|
|
570
|
+
useEffect(() => {
|
|
571
|
+
setInternalValue(value);
|
|
572
|
+
}, [value]);
|
|
573
|
+
useImperativeHandle(ref, () => ({
|
|
574
|
+
blur() {
|
|
575
|
+
var _a;
|
|
576
|
+
(_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
577
|
+
},
|
|
578
|
+
focus() {
|
|
579
|
+
var _a;
|
|
580
|
+
(_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
581
|
+
},
|
|
582
|
+
}), []);
|
|
583
|
+
const handleInputChange = useCallback((event) => {
|
|
584
|
+
setInternalValue(event.target.value);
|
|
585
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
586
|
+
}, [onChange]);
|
|
587
|
+
return (jsxs("div", { className: classNames({
|
|
588
|
+
'd-input': true,
|
|
589
|
+
className: !!className,
|
|
590
|
+
}), style: style, children: [label && (jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsx(DIcon, { className: "d-input-icon", icon: labelIcon, size: `var(--${PREFIX_BS}input-label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix }))] })), jsxs("div", { className: "d-input-control", children: [jsxs("div", { className: classNames({
|
|
591
|
+
'input-group': true,
|
|
592
|
+
'has-validation': isInvalid,
|
|
593
|
+
disabled: isDisabled || isLoading,
|
|
594
|
+
}), children: [!!inputStart && (jsx("div", { className: "input-group-text", children: inputStart })), iconStart && (jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: onIconStartClick, disabled: isDisabled || isLoading, children: iconStart && (jsx(DIcon, { className: "d-input-icon", icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })) })), jsx("input", Object.assign({ ref: innerRef, id: id, name: name, type: type, className: classNames('form-control', {
|
|
595
|
+
'is-invalid': isInvalid,
|
|
596
|
+
'is-valid': isValid,
|
|
597
|
+
}), placeholder: placeholder, "aria-label": label, disabled: isDisabled || isLoading, readOnly: isReadOnly, value: internalValue, "aria-describedby": `${id}Add ${id}Hint`, pattern: pattern, onChange: (event) => handleInputChange(event), onBlur: onBlur, onFocus: onFocus, onWheel: onWheel }, innerInputMode && { inputMode: innerInputMode })), ((isInvalid || isValid) && !iconEnd && !isLoading) && (jsx("span", { className: "input-group-text", id: `${id}State`, children: jsx(DIcon, { className: "d-input-validation-icon", icon: isInvalid ? 'exclamation-circle' : 'check', familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) })), (iconEnd && !isLoading) && (jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: onIconEndClick, disabled: isDisabled || isLoading, children: iconEnd && (jsx(DIcon, { className: "d-input-icon", icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) })), isLoading && (jsx("div", { className: "input-group-text d-input-icon", 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 }))] })] }));
|
|
598
|
+
}
|
|
599
|
+
const ForwardedDInput = forwardRef(DInput);
|
|
600
|
+
ForwardedDInput.displayName = 'DInput';
|
|
601
|
+
var DInput$1 = ForwardedDInput;
|
|
602
|
+
|
|
533
603
|
function DDatePickerTime(_a) {
|
|
534
|
-
var { value,
|
|
535
|
-
return (jsxs("div",
|
|
536
|
-
|
|
537
|
-
}, { type: "time",
|
|
604
|
+
var { value, onChange, id, label } = _a, props = __rest(_a, ["value", "onChange", "id", "label"]);
|
|
605
|
+
return (jsxs("div", { className: "d-flex align-items-center gap-2 flex-column d-datepicker-time", children: [label && (jsx("p", { className: "d-datepicker-time-label", children: label })), jsx(DInput$1, Object.assign({}, onChange && {
|
|
606
|
+
onChange: (event) => onChange(event.target.value),
|
|
607
|
+
}, { type: "time", id: id, value: value }, props))] }));
|
|
538
608
|
}
|
|
539
609
|
|
|
540
610
|
function DDatePickerInput(_a, ref) {
|
|
541
|
-
var { value,
|
|
611
|
+
var { value, onClick, id, iconEnd } = _a, props = __rest(_a, ["value", "onClick", "id", "iconEnd"]);
|
|
542
612
|
useImperativeHandle(ref, () => ({}), []);
|
|
543
|
-
return (jsx("div",
|
|
613
|
+
return (jsx("div", { role: "button", onClick: onClick, onKeyDown: () => { }, tabIndex: -1, children: jsx(DInput$1, Object.assign({ isReadOnly: true, type: "text", id: id, value: value, onIconEndClick: onClick, iconEnd: iconEnd }, props)) }));
|
|
544
614
|
}
|
|
545
|
-
|
|
615
|
+
const ForwardedDDatePickerInput = forwardRef(DDatePickerInput);
|
|
616
|
+
ForwardedDDatePickerInput.displayName = 'DDatePickerInput';
|
|
617
|
+
var DDatePickerInput$1 = ForwardedDDatePickerInput;
|
|
546
618
|
|
|
547
619
|
function DMonthPicker(_a) {
|
|
548
|
-
var {
|
|
549
|
-
const dateJS = (value) => DateTime.fromISO(value).toJSDate();
|
|
620
|
+
var { onChangeDate, date } = _a, props = __rest(_a, ["onChangeDate", "date"]);
|
|
550
621
|
const { language } = useLiquidContext();
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
622
|
+
const selected = useMemo(() => DateTime.fromISO(date).toJSDate(), [date]);
|
|
623
|
+
const locale = useMemo(() => language || 'en', [language]);
|
|
624
|
+
const dateFormatted = useMemo(() => (DateTime.fromISO(date).setLocale(locale).toFormat('MMMM yyyy')), [date, locale]);
|
|
625
|
+
return (jsx(DatePicker, Object.assign({ showMonthYearPicker: true, selected: selected, calendarClassName: "d-month-picker", onChange: onChangeDate, customInput: (jsx("p", { className: "fw-bold text-capitalize", children: dateFormatted })), renderCustomHeader: ({ monthDate, decreaseYear, increaseYear, prevYearButtonDisabled, nextYearButtonDisabled, }) => (jsxs("div", { className: "d-flex align-items-center justify-content-between gap-4 fs-6 bg-dark", children: [jsx(DButton, { iconStart: "chevron-left", size: "sm", variant: "link", theme: "light", onClick: decreaseYear, isDisabled: prevYearButtonDisabled }), jsx("p", { className: "fs-6 fw-bold", children: monthDate.getFullYear() }), jsx(DButton, { iconStart: "chevron-right", size: "sm", variant: "link", theme: "light", onClick: increaseYear, isDisabled: nextYearButtonDisabled })] })) }, props)));
|
|
555
626
|
}
|
|
556
627
|
|
|
557
628
|
function DDatePickerHeader({ monthDate, changeMonth, changeYear, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, withMonthSelector, decreaseMonthIcon, increaseMonthIcon, iconSize, buttonVariant, buttonTheme, }) {
|
|
558
629
|
const { language } = useLiquidContext();
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
630
|
+
const locale = useMemo(() => language || 'en', [language]);
|
|
631
|
+
const onChangeDate = useCallback((value) => {
|
|
632
|
+
if (value) {
|
|
633
|
+
changeMonth(DateTime.fromJSDate(value).month - 1);
|
|
634
|
+
changeYear(DateTime.fromJSDate(value).year);
|
|
635
|
+
}
|
|
636
|
+
}, [changeMonth, changeYear]);
|
|
637
|
+
return (jsxs("div", { className: "d-flex align-items-center justify-content-between d-datepicker-header", children: [jsx(DButton, { iconStart: decreaseMonthIcon, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: decreaseMonth, isDisabled: prevMonthButtonDisabled }), jsx(DMonthPicker, Object.assign({}, !withMonthSelector && { readOnly: true }, { date: monthDate.toISOString(), onChangeDate: onChangeDate }, locale && { locale })), jsx(DButton, { iconStart: increaseMonthIcon, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: increaseMonth, isDisabled: nextMonthButtonDisabled })] }));
|
|
566
638
|
}
|
|
567
639
|
|
|
568
640
|
function DDatePicker(_a) {
|
|
569
|
-
var {
|
|
570
|
-
const
|
|
641
|
+
var { onChangeDate, date, selectsRange, withMonthSelector, inputLabel, inputIcon = 'calendar', inputId = 'input-calendar', timeId = 'input-time', timeLabel, headerDecreaseMonthIcon = 'chevron-left', headerIncreaseMonthIcon = 'chevron-right', headerIconSize = 'sm', headerButtonVariant = 'link', headerButtonTheme = 'dark' } = _a, props = __rest(_a, ["onChangeDate", "date", "selectsRange", "withMonthSelector", "inputLabel", "inputIcon", "inputId", "timeId", "timeLabel", "headerDecreaseMonthIcon", "headerIncreaseMonthIcon", "headerIconSize", "headerButtonVariant", "headerButtonTheme"]);
|
|
642
|
+
const selected = useMemo(() => DateTime.fromISO(date).toJSDate(), [date]);
|
|
571
643
|
const { language } = useLiquidContext();
|
|
572
|
-
const
|
|
573
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
574
|
-
const InputPicker = forwardRef(({ value, onClick }, ref) => (jsx(DDatePickerInput$1, { label: inputLabel, innerId: inputId, iconEnd: inputIcon, value: value, onEventClick: onClick, ref: ref })));
|
|
575
|
-
const TimeInputPicker = useCallback(({ value, onChange }) => (jsx(DDatePickerTime, { onEventChange: onChange, value: value, label: timeLabel, innerId: timeId })), [timeLabel, timeId]);
|
|
644
|
+
const locale = useMemo(() => language || 'en', [language]);
|
|
576
645
|
const DatePickerHeader = useCallback((headerProps) => (jsx(DDatePickerHeader, Object.assign({}, headerProps, { decreaseMonthIcon: headerDecreaseMonthIcon, increaseMonthIcon: headerIncreaseMonthIcon, iconSize: headerIconSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, withMonthSelector: !!withMonthSelector }))), [headerButtonTheme,
|
|
577
646
|
headerButtonVariant,
|
|
578
647
|
headerDecreaseMonthIcon,
|
|
@@ -580,260 +649,299 @@ function DDatePicker(_a) {
|
|
|
580
649
|
headerIncreaseMonthIcon,
|
|
581
650
|
withMonthSelector,
|
|
582
651
|
]);
|
|
583
|
-
return (jsx(DatePicker, Object.assign({ selected:
|
|
584
|
-
onEventChangeDate(value);
|
|
585
|
-
}, renderCustomHeader: (headerProps) => jsx(DatePickerHeader, Object.assign({}, headerProps)), customInput: jsx(InputPicker, {}), customTimeInput: jsx(TimeInputPicker, {}), selectsRange: selectsRange }, lang && { locale: lang }, props)));
|
|
652
|
+
return (jsx(DatePicker, Object.assign({ selected: selected, calendarClassName: "m-date-picker", onChange: onChangeDate, renderCustomHeader: (headerProps) => jsx(DatePickerHeader, Object.assign({}, headerProps)), customInput: jsx(DDatePickerInput$1, { id: inputId, iconEnd: inputIcon }), customTimeInput: jsx(DDatePickerTime, { id: timeId, label: timeLabel }), selectsRange: selectsRange }, locale && { locale }, props)));
|
|
586
653
|
}
|
|
587
654
|
|
|
588
|
-
function
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
655
|
+
function DFormikInput(_a) {
|
|
656
|
+
var { name, hint } = _a, props = __rest(_a, ["name", "hint"]);
|
|
657
|
+
const [field, meta, helpers] = useField(name);
|
|
658
|
+
return (jsx(DInput$1, Object.assign({}, props, { name: field.name, value: field.value, onChange: ({ target }) => helpers.setValue(target.value), onBlur: ({ target }) => field.onBlur(target.value), isInvalid: !!meta.error, hint: meta.error || hint })));
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function DInputCurrencyBase(_a) {
|
|
662
|
+
var { id, name, label = '', placeholder = '', value, isDisabled = false, isReadOnly = false, isLoading = false, hint, isInvalid = false, isValid = false, minValue, maxValue, currencyOptions, currencyCode, onChange, onBlur, onFocus } = _a, rest = __rest(_a, ["id", "name", "label", "placeholder", "value", "isDisabled", "isReadOnly", "isLoading", "hint", "isInvalid", "isValid", "minValue", "maxValue", "currencyOptions", "currencyCode", "onChange", "onBlur", "onFocus"]);
|
|
663
|
+
const [internalValueAsNumber, setInternalValueAsNumber] = useState(value);
|
|
664
|
+
const [internalValueAsFormat, setInternalValueAsFormat] = useState('');
|
|
665
|
+
const [internalType, setInternalType] = useState('text');
|
|
666
|
+
const [internalIsInvalid, setInternalIsInvalid] = useState(false);
|
|
667
|
+
const currencyInputRef = useRef(null);
|
|
668
|
+
const changeHandler = useCallback((event) => {
|
|
669
|
+
event.stopPropagation();
|
|
670
|
+
const eventValue = event.target.value;
|
|
671
|
+
const valueAsNumber = eventValue ? parseFloat(eventValue) : undefined;
|
|
672
|
+
const valueAsFormat = valueAsNumber !== undefined
|
|
673
|
+
? currency(valueAsNumber, Object.assign(Object.assign({}, currencyOptions), { symbol: '' })).format()
|
|
674
|
+
: '';
|
|
675
|
+
setInternalValueAsNumber(valueAsNumber);
|
|
676
|
+
setInternalValueAsFormat(valueAsFormat);
|
|
677
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(valueAsNumber);
|
|
678
|
+
}, [currencyOptions, onChange]);
|
|
679
|
+
const blurHandler = useCallback((event) => {
|
|
680
|
+
event.stopPropagation();
|
|
681
|
+
setInternalType('text');
|
|
682
|
+
setInternalValueAsFormat(internalValueAsNumber !== undefined
|
|
683
|
+
? currency(internalValueAsNumber, Object.assign(Object.assign({}, currencyOptions), { symbol: '' })).format()
|
|
684
|
+
: '');
|
|
685
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(internalValueAsNumber);
|
|
686
|
+
}, [currencyOptions, internalValueAsNumber, onBlur]);
|
|
687
|
+
const focusHandler = useCallback((event) => {
|
|
688
|
+
event.stopPropagation();
|
|
689
|
+
setInternalType('number');
|
|
690
|
+
setInternalValueAsFormat(internalValueAsNumber !== undefined
|
|
691
|
+
? currency(internalValueAsNumber, Object.assign(Object.assign({}, currencyOptions), { symbol: '' })).format()
|
|
692
|
+
: '');
|
|
693
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(internalValueAsNumber);
|
|
694
|
+
}, [currencyOptions, internalValueAsNumber, onFocus]);
|
|
695
|
+
const wheelHandler = useCallback((event) => {
|
|
696
|
+
var _a;
|
|
697
|
+
event.stopPropagation();
|
|
698
|
+
(_a = currencyInputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
699
|
+
}, []);
|
|
700
|
+
const isValidValue = useCallback((internalValue) => {
|
|
701
|
+
if (internalValue === undefined) {
|
|
702
|
+
return true;
|
|
592
703
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
const innerForegroundColor = useMemo(() => {
|
|
597
|
-
if (foregroundColor) {
|
|
598
|
-
return foregroundColor;
|
|
704
|
+
if (internalType === 'number') {
|
|
705
|
+
return ((minValue === undefined || internalValue >= minValue)
|
|
706
|
+
&& (maxValue === undefined || internalValue <= maxValue));
|
|
599
707
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
708
|
+
return true;
|
|
709
|
+
}, [internalType, maxValue, minValue]);
|
|
710
|
+
const valueAsType = useMemo(() => {
|
|
711
|
+
if (internalType === 'number') {
|
|
712
|
+
return internalValueAsNumber;
|
|
713
|
+
}
|
|
714
|
+
return internalValueAsFormat;
|
|
715
|
+
}, [internalType, internalValueAsFormat, internalValueAsNumber]);
|
|
716
|
+
useEffect(() => {
|
|
717
|
+
setInternalIsInvalid(!isValidValue(value));
|
|
718
|
+
}, [isValidValue, value]);
|
|
719
|
+
useEffect(() => {
|
|
720
|
+
setInternalValueAsNumber(value);
|
|
721
|
+
}, [value]);
|
|
722
|
+
const generateStyleVariables = useMemo(() => ({
|
|
723
|
+
[`--${PREFIX_BS}input-currency-component-symbol-color`]: `var(--${PREFIX_BS}secondary)`,
|
|
724
|
+
[`--${PREFIX_BS}input-currency-symbol-color`]: `var(--${PREFIX_BS}input-currency-component-symbol-color)`,
|
|
725
|
+
}), []);
|
|
726
|
+
const generateSymbolStyleVariables = useMemo(() => ({
|
|
727
|
+
color: `var(--${PREFIX_BS}m-input-currency-symbol-color)`,
|
|
728
|
+
}), []);
|
|
729
|
+
return (jsx(DInput$1, Object.assign({ ref: currencyInputRef, style: generateStyleVariables, id: id, name: name, label: label, placeholder: placeholder, value: valueAsType, isDisabled: isDisabled, isReadOnly: isReadOnly, isLoading: isLoading, hint: hint, isInvalid: isInvalid || internalIsInvalid, isValid: isValid, type: internalType, innerInputMode: "decimal", pattern: "^[0-9]", onChange: changeHandler, onBlur: blurHandler, onFocus: focusHandler, onWheel: wheelHandler, inputStart: (jsx("span", { slot: "input-start", style: generateSymbolStyleVariables, children: currencyCode || currencyOptions.symbol })) }, rest)));
|
|
604
730
|
}
|
|
605
731
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
732
|
+
function DInputCurrency(props) {
|
|
733
|
+
const { currency } = useLiquidContext();
|
|
734
|
+
return (jsx(DInputCurrencyBase, Object.assign({ currencyOptions: currency }, props)));
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function DFormikInputCurrency(_a) {
|
|
738
|
+
var { name, hint } = _a, props = __rest(_a, ["name", "hint"]);
|
|
739
|
+
const [field, meta, helpers] = useField(name);
|
|
740
|
+
return (jsx(DInputCurrency, Object.assign({}, props, { name: field.name, value: field.value, onChange: (value) => helpers.setValue(value), onBlur: (value) => field.onBlur(value), isInvalid: !!meta.error, hint: (meta === null || meta === void 0 ? void 0 : meta.error) || hint })));
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function DInputSelect({ id, name, label = '', options, labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, isDisabled = false, isLoading = false, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, hint, selectedOption, valueExtractor, labelExtractor, onChange, onBlur, onIconStartClick, onIconEndClick, }) {
|
|
744
|
+
const internalValueExtractor = useCallback((option) => {
|
|
745
|
+
if (valueExtractor) {
|
|
746
|
+
return valueExtractor(option);
|
|
612
747
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}, [
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
748
|
+
if ('value' in option) {
|
|
749
|
+
return option === null || option === void 0 ? void 0 : option.value;
|
|
750
|
+
}
|
|
751
|
+
throw new Error('Must provide a valueExtractor for custom object forms');
|
|
752
|
+
}, [valueExtractor]);
|
|
753
|
+
const internalLabelExtractor = useCallback((option) => {
|
|
754
|
+
if (labelExtractor) {
|
|
755
|
+
return labelExtractor(option);
|
|
756
|
+
}
|
|
757
|
+
if ('label' in option) {
|
|
758
|
+
return option === null || option === void 0 ? void 0 : option.label;
|
|
759
|
+
}
|
|
760
|
+
throw new Error('Must provide a labelExtractor for custom object forms');
|
|
761
|
+
}, [labelExtractor]);
|
|
762
|
+
const changeHandler = useCallback((event) => {
|
|
763
|
+
const selected = options
|
|
764
|
+
.find((option) => internalValueExtractor(option).toString() === event.currentTarget.value);
|
|
765
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(selected);
|
|
766
|
+
}, [onChange, options, internalValueExtractor]);
|
|
767
|
+
const blurHandler = useCallback((event) => {
|
|
768
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
769
|
+
}, [onBlur]);
|
|
770
|
+
const iconStartClickHandler = useCallback((event) => {
|
|
771
|
+
onIconStartClick === null || onIconStartClick === void 0 ? void 0 : onIconStartClick(event);
|
|
772
|
+
}, [onIconStartClick]);
|
|
773
|
+
const iconEndClickHandler = useCallback((event) => {
|
|
774
|
+
onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(event);
|
|
775
|
+
}, [onIconEndClick]);
|
|
776
|
+
return (jsxs("div", { className: "d-input", children: [label && (jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsx(DIcon, { className: "mdinput-icon", icon: labelIcon, size: `var(--${PREFIX_BS}input-label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix }))] })), jsxs("div", { className: "d-input-control", children: [jsxs("div", { className: classNames({
|
|
777
|
+
'input-group': true,
|
|
778
|
+
disabled: isDisabled || isLoading,
|
|
779
|
+
}), children: [iconStart && (jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: iconStartClickHandler, disabled: isDisabled || isLoading, children: iconStart && (jsx(DIcon, { className: "d-input-icon", icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })) })), jsx("select", Object.assign({ id: id, name: name, className: "form-select", "aria-label": label, disabled: isDisabled || isLoading, "aria-describedby": `${id}Add ${id}Hint`, onChange: changeHandler, onBlur: blurHandler }, selectedOption && { value: internalValueExtractor(selectedOption) }, { children: options.map((option) => (jsx("option", { value: internalValueExtractor(option), children: internalLabelExtractor(option) }, internalValueExtractor(option)))) })), iconEnd && !isLoading && (jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: iconEndClickHandler, disabled: isDisabled || isLoading, children: iconEnd && (jsx(DIcon, { className: "d-input-icon", icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) })), isLoading && (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 }))] })] }));
|
|
628
780
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
return context;
|
|
781
|
+
|
|
782
|
+
function DFormikInputSelect(_a) {
|
|
783
|
+
var { name } = _a, props = __rest(_a, ["name"]);
|
|
784
|
+
const [field, , helpers] = useField(name);
|
|
785
|
+
return (jsx(DInputSelect, Object.assign({}, props, { name: field.name, selectedOption: field.value, onChange: (selected) => helpers.setValue(selected), onBlur: (selected) => field.onBlur(selected) })));
|
|
635
786
|
}
|
|
636
787
|
|
|
637
|
-
function
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
788
|
+
function DInputCheck({ type, name, label, isChecked = false, id, isDisabled = false, isIndeterminate, value, onChange, }) {
|
|
789
|
+
const innerRef = useRef(null);
|
|
790
|
+
const handleChange = useCallback((event) => {
|
|
791
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
792
|
+
}, [onChange]);
|
|
793
|
+
useEffect(() => {
|
|
794
|
+
if (innerRef.current) {
|
|
795
|
+
innerRef.current.indeterminate = Boolean(isIndeterminate);
|
|
796
|
+
}
|
|
797
|
+
}, [isIndeterminate]);
|
|
798
|
+
useEffect(() => {
|
|
799
|
+
if (innerRef.current) {
|
|
800
|
+
innerRef.current.checked = isChecked;
|
|
801
|
+
}
|
|
802
|
+
}, [isChecked]);
|
|
803
|
+
if (!label) {
|
|
804
|
+
return (jsx("input", { ref: innerRef, onChange: handleChange, className: "form-check-input", id: id, disabled: isDisabled, type: type, name: name, value: value }));
|
|
641
805
|
}
|
|
642
|
-
return (
|
|
806
|
+
return (jsxs("div", { className: "form-check", children: [jsx("input", { ref: innerRef, onChange: handleChange, className: "form-check-input", id: id, disabled: isDisabled, type: type, name: name, value: value }), jsx("label", { className: "form-check-label", htmlFor: id, children: label })] }));
|
|
643
807
|
}
|
|
644
808
|
|
|
645
|
-
function
|
|
646
|
-
|
|
809
|
+
function DInputCounter(_a) {
|
|
810
|
+
var { id, name, label = '', value, isDisabled = false, isReadOnly = false, isLoading = false, iconStart = 'dash-square', iconEnd = 'plus-square', hint, isInvalid = false, isValid = false, minValue, maxValue, style, className, onChange } = _a, rest = __rest(_a, ["id", "name", "label", "value", "isDisabled", "isReadOnly", "isLoading", "iconStart", "iconEnd", "hint", "isInvalid", "isValid", "minValue", "maxValue", "style", "className", "onChange"]);
|
|
811
|
+
const [internalIsInvalid, setInternalIsInvalid] = useState(false);
|
|
812
|
+
const [internalValue, setInternalValue] = useState(value);
|
|
647
813
|
useEffect(() => {
|
|
648
|
-
|
|
649
|
-
}, [
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
814
|
+
setInternalValue(value);
|
|
815
|
+
}, [value]);
|
|
816
|
+
useEffect(() => {
|
|
817
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(internalValue);
|
|
818
|
+
}, [internalValue, onChange]);
|
|
819
|
+
const changeHandler = useCallback((event) => {
|
|
820
|
+
event.stopPropagation();
|
|
821
|
+
const newValue = parseInt(event.target.value || '0', 10);
|
|
822
|
+
setInternalValue(newValue);
|
|
823
|
+
}, []);
|
|
824
|
+
const clickHandler = useCallback((action) => {
|
|
825
|
+
if (action) {
|
|
826
|
+
setInternalValue((prevInternalValue) => {
|
|
827
|
+
const newValue = prevInternalValue + 1;
|
|
828
|
+
return newValue <= maxValue ? newValue : maxValue;
|
|
829
|
+
});
|
|
654
830
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
offset(0),
|
|
661
|
-
flip({ fallbackAxisSideDirection: 'none' }),
|
|
662
|
-
shift(),
|
|
663
|
-
],
|
|
664
|
-
whileElementsMounted: autoUpdate,
|
|
665
|
-
});
|
|
666
|
-
const click = useClick(context);
|
|
667
|
-
const dismiss = useDismiss(context);
|
|
668
|
-
const role = useRole(context);
|
|
669
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
670
|
-
click,
|
|
671
|
-
dismiss,
|
|
672
|
-
role,
|
|
673
|
-
]);
|
|
674
|
-
const headingId = useId();
|
|
675
|
-
return (jsxs("div", Object.assign({ className: "d-popover" }, { children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: renderComponent(innerIsOpen) })), innerIsOpen && (jsx(FloatingFocusManager, Object.assign({ context: context, modal: false }, { children: jsx("div", Object.assign({ className: "d-popover-content", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: children })) })))] })));
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
function useFormatCurrency(...args) {
|
|
679
|
-
const { currency } = useLiquidContext();
|
|
680
|
-
const format = useCallback((value) => formatCurrency(value, currency), [currency]);
|
|
681
|
-
const values = (args || []).map((value) => (formatCurrency(value !== null && value !== void 0 ? value : 0, currency)));
|
|
682
|
-
return {
|
|
683
|
-
format,
|
|
684
|
-
values,
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
function DCurrencyText({ value, className, }) {
|
|
689
|
-
const { values: [valueFormatted] } = useFormatCurrency(value);
|
|
690
|
-
return (jsx("span", Object.assign({ className: className }, { children: valueFormatted })));
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
function DFormikInput(_a) {
|
|
694
|
-
var { name, hint } = _a, props = __rest(_a, ["name", "hint"]);
|
|
695
|
-
const [field, meta, helpers] = useField(name);
|
|
696
|
-
return (jsx(DInput, Object.assign({}, props, { name: field.name, value: field.value, onEventChange: ({ detail }) => helpers.setValue(detail), onEventBlur: ({ detail }) => field.onBlur(detail), isInvalid: !!meta.error, hint: meta.error || hint })));
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
function DFormikInputSelect(_a) {
|
|
700
|
-
var { name, labelExtractor = (item) => item === null || item === void 0 ? void 0 : item.label, valueExtractor = (item) => item === null || item === void 0 ? void 0 : item.value } = _a, props = __rest(_a, ["name", "labelExtractor", "valueExtractor"]);
|
|
701
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
702
|
-
const [field, , helpers] = useField(name);
|
|
703
|
-
return (jsx(DInputSelect, Object.assign({}, props, { name: field.name, selectedOption: field.value, labelExtractor: labelExtractor, valueExtractor: valueExtractor, onEventChange: ({ detail }) => helpers.setValue(detail), onEventBlur: ({ detail }) => field.onBlur(detail) })));
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
const TOOLTIP_FONT_SIZE_BY_SIZE = {
|
|
707
|
-
sm: `var(--${PREFIX_BS}ref-fs-small)`,
|
|
708
|
-
default: `var(--${PREFIX_BS}body-font-size)`,
|
|
709
|
-
lg: `var(--${PREFIX_BS}ref-fs-6)`,
|
|
710
|
-
};
|
|
711
|
-
const ARROW_WIDTH = 8;
|
|
712
|
-
const ARROW_HEIGHT = 4;
|
|
713
|
-
const GAP = 2;
|
|
714
|
-
function DTooltip({ classNameContainer, className, offSet = ARROW_HEIGHT + GAP, padding, withFocus = false, withClick = false, withHover = true, isOpen = false, placement = 'top', size, Component, children, }) {
|
|
715
|
-
const [open, setOpen] = useState(isOpen);
|
|
716
|
-
const styleVariables = useMemo(() => {
|
|
717
|
-
const defaultFontSize = size
|
|
718
|
-
? TOOLTIP_FONT_SIZE_BY_SIZE[size]
|
|
719
|
-
: TOOLTIP_FONT_SIZE_BY_SIZE.default;
|
|
720
|
-
return {
|
|
721
|
-
background: `var(--${PREFIX_BS}tooltip-bg, var(--${PREFIX_BS}tooltip-component-bg, var(--${PREFIX_BS}secondary)))`,
|
|
722
|
-
borderRadius: `var(--${PREFIX_BS}tooltip-border-radius, var(--${PREFIX_BS}tooltip-component-border-radius, var(--${PREFIX_BS}border-radius)))`,
|
|
723
|
-
color: `var(--${PREFIX_BS}tooltip-color, var(--${PREFIX_BS}tooltip-component-color, var(--${PREFIX_BS}white)))`,
|
|
724
|
-
fontSize: `var(--${PREFIX_BS}tooltip-font-size, var(--${PREFIX_BS}tooltip-component-font-size, ${defaultFontSize}))`,
|
|
725
|
-
padding: `var(--${PREFIX_BS}tooltip-padding, var(--${PREFIX_BS}tooltip-component-padding, var(--${PREFIX_BS}ref-spacer-2)))`,
|
|
726
|
-
maxWidth: `var(--${PREFIX_BS}tooltip-max-width, var(--${PREFIX_BS}tooltip-component-max-width, 300px))`,
|
|
727
|
-
};
|
|
728
|
-
}, [size]);
|
|
729
|
-
const arrowRef = useRef(null);
|
|
730
|
-
const { refs, context, floatingStyles, } = useFloating({
|
|
731
|
-
open,
|
|
732
|
-
onOpenChange: setOpen,
|
|
733
|
-
placement,
|
|
734
|
-
whileElementsMounted: autoUpdate,
|
|
735
|
-
middleware: [
|
|
736
|
-
offset(offSet),
|
|
737
|
-
flip(),
|
|
738
|
-
shift({
|
|
739
|
-
padding,
|
|
740
|
-
}),
|
|
741
|
-
arrow({
|
|
742
|
-
element: arrowRef,
|
|
743
|
-
}),
|
|
744
|
-
],
|
|
745
|
-
});
|
|
746
|
-
const hover = useHover(context, { move: false });
|
|
747
|
-
const focus = useFocus(context);
|
|
748
|
-
const dismiss = useDismiss(context);
|
|
749
|
-
const click = useClick(context);
|
|
750
|
-
const role = useRole(context, { role: 'tooltip' });
|
|
751
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
752
|
-
withHover ? hover : undefined,
|
|
753
|
-
withClick ? click : undefined,
|
|
754
|
-
withFocus ? focus : undefined,
|
|
755
|
-
dismiss,
|
|
756
|
-
role,
|
|
757
|
-
]);
|
|
758
|
-
return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: className, ref: refs.setReference }, getReferenceProps(), { children: Component })), jsx(FloatingPortal, { children: open && (jsxs("div", Object.assign({ className: classNameContainer, ref: refs.setFloating, style: Object.assign(Object.assign({}, floatingStyles), styleVariables) }, getFloatingProps(), { children: [jsx(FloatingArrow, { ref: arrowRef, context: context, style: {
|
|
759
|
-
fill: styleVariables.background,
|
|
760
|
-
}, width: ARROW_WIDTH, height: ARROW_HEIGHT }), children] }))) })] }));
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
function DCollapse({ id, className, Component, hasSeparator = false, defaultCollapsed = false, onEventChange, children, }) {
|
|
764
|
-
const [toggle, setToggle] = useState(defaultCollapsed);
|
|
765
|
-
const onChangeCollapse = () => setToggle((prev) => !prev);
|
|
766
|
-
useEffect(() => {
|
|
767
|
-
if (onEventChange) {
|
|
768
|
-
onEventChange(toggle);
|
|
831
|
+
else {
|
|
832
|
+
setInternalValue((prevInternalValue) => {
|
|
833
|
+
const newValue = prevInternalValue - 1;
|
|
834
|
+
return newValue >= minValue ? newValue : minValue;
|
|
835
|
+
});
|
|
769
836
|
}
|
|
770
|
-
}, [
|
|
837
|
+
}, [maxValue, minValue]);
|
|
838
|
+
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign({}, style), { [`--${PREFIX_BS}input-component-form-control-text-align`]: 'center' })), [style]);
|
|
771
839
|
useEffect(() => {
|
|
772
|
-
|
|
773
|
-
}, [
|
|
774
|
-
return (
|
|
775
|
-
'collapse-body': true,
|
|
776
|
-
}), style: {
|
|
777
|
-
[`--${PREFIX_BS}collapse-separator-display`]: hasSeparator ? 'block' : 'none',
|
|
778
|
-
} }, { children: children })))] })));
|
|
840
|
+
setInternalIsInvalid(!(internalValue >= minValue && internalValue <= maxValue));
|
|
841
|
+
}, [internalValue, minValue, maxValue]);
|
|
842
|
+
return (jsx(DInput$1, Object.assign({ id: id, style: generateStyleVariables, className: className, name: name, label: label, value: internalValue, isDisabled: isDisabled, isReadOnly: isReadOnly, isLoading: isLoading, hint: hint, iconStart: iconStart, iconEnd: iconEnd, isInvalid: internalIsInvalid || isInvalid, isValid: isValid, type: "number", onChange: changeHandler, onIconStartClick: () => clickHandler(false), onIconEndClick: () => clickHandler(true) }, rest)));
|
|
779
843
|
}
|
|
780
844
|
|
|
781
|
-
function
|
|
782
|
-
var {
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
},
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
function DBoxFile(_a) {
|
|
792
|
-
var { icon = 'cloud-upload', iconFamilyClass, iconFamilyPrefix, isDisabled = false, children } = _a, dropzoneOptions = __rest(_a, ["icon", "iconFamilyClass", "iconFamilyPrefix", "isDisabled", "children"]);
|
|
793
|
-
const { acceptedFiles, getRootProps, getInputProps, } = useDropzone(Object.assign({ disabled: isDisabled }, dropzoneOptions));
|
|
794
|
-
return (jsxs("section", Object.assign({ className: classNames('d-box-file', {
|
|
795
|
-
'd-box-file-selected': !!acceptedFiles.length,
|
|
796
|
-
}) }, { children: [jsxs("div", Object.assign({}, getRootProps({
|
|
797
|
-
className: classNames('d-box-file-dropzone', {
|
|
798
|
-
disabled: isDisabled,
|
|
799
|
-
}),
|
|
800
|
-
}), { children: [jsx("input", Object.assign({}, getInputProps())), jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }), jsx("div", Object.assign({ className: "d-box-content" }, { children: children }))] })), !!acceptedFiles.length && (jsx("aside", Object.assign({ className: "d-box-files" }, { children: acceptedFiles.map((file) => (jsx("div", Object.assign({ className: "d-box-files-text" }, { children: `${file.name} - ${file.size} bytes` }), file.name))) })))] })));
|
|
845
|
+
function DInputPassword(_a) {
|
|
846
|
+
var { id, name, label = '', placeholder = '', value = '', isDisabled = false, isReadOnly = false, isLoading = false, hint, isInvalid = false, isValid = false, onChange } = _a, rest = __rest(_a, ["id", "name", "label", "placeholder", "value", "isDisabled", "isReadOnly", "isLoading", "hint", "isInvalid", "isValid", "onChange"]);
|
|
847
|
+
const [visible, setVisible] = useState(false);
|
|
848
|
+
const changeHandler = useCallback((event) => {
|
|
849
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event.target.value);
|
|
850
|
+
}, [onChange]);
|
|
851
|
+
const visibilityHandler = useCallback(() => {
|
|
852
|
+
setVisible((prevVisible) => !prevVisible);
|
|
853
|
+
}, []);
|
|
854
|
+
return (jsx(DInput$1, Object.assign({ id: id, name: name, label: label, placeholder: placeholder, value: value, iconEnd: !visible ? 'eye-slash' : 'eye', type: !visible ? 'password' : 'text', isDisabled: isDisabled, isReadOnly: isReadOnly, isLoading: isLoading, hint: hint, isInvalid: isInvalid, isValid: isValid, onChange: changeHandler, onIconEndClick: visibilityHandler }, rest)));
|
|
801
855
|
}
|
|
802
856
|
|
|
803
|
-
function
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
857
|
+
function DInputPin({ id, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, placeholder = '•', type = 'text', isDisabled = false, isLoading = false, isSecret = false, iconFamilyClass, iconFamilyPrefix, characters = 4, innerInputMode = 'text', hint, isInvalid = false, isValid = false, onChange, }) {
|
|
858
|
+
const [pattern, setPattern] = useState('');
|
|
859
|
+
useEffect(() => {
|
|
860
|
+
setPattern(type === 'number' ? '[0-9]+' : '^[a-zA-Z0-9]+$');
|
|
861
|
+
}, [type]);
|
|
862
|
+
const nextInput = useCallback((event) => {
|
|
863
|
+
var _a;
|
|
864
|
+
const input = event.target;
|
|
865
|
+
const regex = new RegExp(pattern);
|
|
866
|
+
if (!regex.test(input.value)) {
|
|
867
|
+
input.value = '';
|
|
868
|
+
}
|
|
869
|
+
if (input.value !== '') {
|
|
870
|
+
if (input.nextSibling) {
|
|
871
|
+
(_a = input.nextSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
input.blur();
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}, [pattern]);
|
|
878
|
+
const prevInput = useCallback((event) => {
|
|
879
|
+
var _a;
|
|
880
|
+
if (event.key === 'Backspace') {
|
|
881
|
+
const { value } = event.currentTarget;
|
|
882
|
+
if (event.currentTarget.previousSibling && value === '') {
|
|
883
|
+
(_a = event.currentTarget.previousSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
event.currentTarget.blur();
|
|
887
|
+
event.currentTarget.focus();
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}, []);
|
|
891
|
+
const focusInput = useCallback((event) => {
|
|
892
|
+
// eslint-disable-next-line no-param-reassign
|
|
893
|
+
event.currentTarget.value = '';
|
|
894
|
+
}, []);
|
|
895
|
+
const wheelInput = useCallback((event) => {
|
|
896
|
+
event.currentTarget.blur();
|
|
897
|
+
}, []);
|
|
898
|
+
const formChange = useCallback((event) => {
|
|
899
|
+
const formData = new FormData(event.currentTarget);
|
|
900
|
+
const values = Array.from(formData.values()).join('');
|
|
901
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values);
|
|
902
|
+
}, [onChange]);
|
|
903
|
+
const preventDefaultEvent = useCallback((event) => {
|
|
904
|
+
event.preventDefault();
|
|
905
|
+
}, []);
|
|
906
|
+
return (jsxs("div", { className: "d-input-pin", children: [label && (jsxs("label", { htmlFor: "pinIndex0", children: [label, labelIcon && (jsx(DIcon, { className: "d-input-pin-icon", icon: labelIcon, size: `var(--${PREFIX_BS}input-label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix }))] })), jsxs("form", { id: id, className: "d-input-pin-controls", onInput: formChange, onSubmit: preventDefaultEvent, children: [Array.from({ length: characters }).map((_, index) => (jsx("input", Object.assign({ className: classNames({
|
|
907
|
+
'form-control': true,
|
|
908
|
+
'is-invalid': isInvalid,
|
|
909
|
+
'is-valid': isValid,
|
|
910
|
+
}), type: isSecret ? 'password' : type, "aria-describedby": `${id}State`, inputMode: innerInputMode, id: `pinIndex${index}`, name: `pin-${index}`, maxLength: 1, onChange: nextInput, onKeyDown: prevInput, onFocus: focusInput, onWheel: wheelInput, onClick: preventDefaultEvent, autoComplete: "off", placeholder: placeholder, disabled: isDisabled || isLoading, required: true }, type === 'number' && ({ min: 0, max: 9 })), index))), (isInvalid || isValid) && !isLoading && (jsx("span", { className: "input-group-text", id: `${id}State`, children: jsx(DIcon, { className: "d-input-pin-validation-icon", icon: isInvalid ? 'exclamation-circle' : 'check', familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) })), isLoading && (jsx("div", { className: "input-group-text d-input-pin-icon", 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 }))] }));
|
|
815
911
|
}
|
|
816
912
|
|
|
817
|
-
function
|
|
818
|
-
var {
|
|
819
|
-
|
|
913
|
+
function DInputSearch(_a) {
|
|
914
|
+
var { id, name, label, placeholder, value, isDisabled, isReadOnly, isLoading, hint, isInvalid, isValid, onChange, onClick } = _a, rest = __rest(_a, ["id", "name", "label", "placeholder", "value", "isDisabled", "isReadOnly", "isLoading", "hint", "isInvalid", "isValid", "onChange", "onClick"]);
|
|
915
|
+
const [internalValue, setInternalValue] = useState(value);
|
|
916
|
+
useEffect(() => {
|
|
917
|
+
setInternalValue(value);
|
|
918
|
+
}, [value]);
|
|
919
|
+
const changeHandler = useCallback((event) => {
|
|
920
|
+
event.stopPropagation();
|
|
921
|
+
setInternalValue(event.target.value);
|
|
922
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
923
|
+
}, [onChange]);
|
|
924
|
+
const clickHandler = useCallback(() => {
|
|
925
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(internalValue);
|
|
926
|
+
}, [internalValue, onClick]);
|
|
927
|
+
return (jsx(DInput$1, Object.assign({ id: id, name: name, label: label, placeholder: placeholder, value: internalValue, iconEnd: "search", isDisabled: isDisabled, isReadOnly: isReadOnly, isLoading: isLoading, hint: hint, isInvalid: isInvalid, isValid: isValid, onChange: changeHandler, onIconEndClick: clickHandler }, rest)));
|
|
820
928
|
}
|
|
821
929
|
|
|
822
930
|
function DList({ children, className, isFlush = false, isNumbered = false, isHorizontal = false, horizontalBreakpoint, }) {
|
|
823
931
|
if (isFlush && isHorizontal) {
|
|
824
932
|
throw new Error("Horizontal and Flush props don't work together");
|
|
825
933
|
}
|
|
826
|
-
return (jsx("div",
|
|
934
|
+
return (jsx("div", { className: classNames('list-group', {
|
|
827
935
|
'list-group-flush': isFlush && !isHorizontal,
|
|
828
936
|
'list-group-numbered': isNumbered,
|
|
829
937
|
'list-group-horizontal': isHorizontal && !horizontalBreakpoint,
|
|
830
|
-
}, (isHorizontal && horizontalBreakpoint) && `list-group-horizontal-${horizontalBreakpoint}`, className)
|
|
938
|
+
}, (isHorizontal && horizontalBreakpoint) && `list-group-horizontal-${horizontalBreakpoint}`, className), children: children }));
|
|
831
939
|
}
|
|
832
940
|
|
|
833
|
-
function DListItem({ children, className, isActive = false, isDisabled = false, theme,
|
|
834
|
-
const Tag = useMemo(() => (
|
|
941
|
+
function DListItem({ children, className, isActive = false, isDisabled = false, theme, onClick, }) {
|
|
942
|
+
const Tag = useMemo(() => (onClick ? 'button' : 'div'), [onClick]);
|
|
835
943
|
return (jsx(Tag, Object.assign({}, Tag === 'button' && {
|
|
836
|
-
onClick
|
|
944
|
+
onClick,
|
|
837
945
|
type: 'button',
|
|
838
946
|
}, { className: classNames('list-group-item list-group-item-action', theme ? `list-group-item-${theme}` : undefined, className, {
|
|
839
947
|
active: isActive,
|
|
@@ -843,7 +951,7 @@ function DListItem({ children, className, isActive = false, isDisabled = false,
|
|
|
843
951
|
|
|
844
952
|
function useToast() {
|
|
845
953
|
const toast$1 = useCallback((message, { position = 'top-right', type = 'info', showClose = true, autoClose = false, } = {}) => {
|
|
846
|
-
toast(({ closeToast }) => (jsx(DAlert,
|
|
954
|
+
toast(({ closeToast }) => (jsx(DAlert, { type: type, showClose: showClose, onClose: closeToast, id: "alertID", children: message })), {
|
|
847
955
|
transition: Slide,
|
|
848
956
|
position,
|
|
849
957
|
autoClose,
|
|
@@ -933,28 +1041,202 @@ function DListItemMovement(_a) {
|
|
|
933
1041
|
valueFormatted,
|
|
934
1042
|
};
|
|
935
1043
|
}, [format, amount]);
|
|
936
|
-
return (jsx(DListItem, Object.assign({}, props, { children: jsxs("div",
|
|
1044
|
+
return (jsx(DListItem, Object.assign({}, props, { children: jsxs("div", { className: classNames('d-flex justify-content-between align-items-center p-3 gap-3', classNameMovement), children: [jsxs("div", { className: "d-flex flex-column gap-1", children: [jsx("span", { className: "fs-6", children: description }), jsx("span", { className: "small text-gray-700", children: date })] }), jsx("span", { className: classNames('fs-6', value.theme), children: value.valueFormatted })] }) })));
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
function DModal({ name, className = '', isStatic, isScrollable, isCentered, isFullScreen, fullScreenFrom, modalSize, children, }) {
|
|
1048
|
+
const fullScreenClass = useMemo(() => {
|
|
1049
|
+
if (isFullScreen) {
|
|
1050
|
+
if (fullScreenFrom) {
|
|
1051
|
+
return `modal-fullscreen-${fullScreenFrom}-down`;
|
|
1052
|
+
}
|
|
1053
|
+
return 'modal-fullscreen';
|
|
1054
|
+
}
|
|
1055
|
+
return '';
|
|
1056
|
+
}, [fullScreenFrom, isFullScreen]);
|
|
1057
|
+
const generateClasses = useMemo(() => ({
|
|
1058
|
+
'modal fade show': true,
|
|
1059
|
+
[`${className}`]: !!className,
|
|
1060
|
+
}), [className]);
|
|
1061
|
+
const generateModalDialogClasses = useMemo(() => (Object.assign({ 'modal-dialog': true, 'modal-dialog-centered': !!isCentered, 'modal-dialog-scrollable': !!isScrollable, [fullScreenClass]: !!isFullScreen }, modalSize && { [`modal-${modalSize}`]: true })), [fullScreenClass, isCentered, isFullScreen, isScrollable, modalSize]);
|
|
1062
|
+
return (jsx("div", Object.assign({ className: classNames(generateClasses), id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false" }, isStatic && ({
|
|
1063
|
+
[`data-${PREFIX_BS}backdrop`]: 'static',
|
|
1064
|
+
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1065
|
+
}), { children: jsx("div", { className: classNames(generateModalDialogClasses), children: jsx("div", { className: "modal-content", children: children }) }) })));
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
function DModalBody({ children }) {
|
|
1069
|
+
return (jsx("div", { className: "d-modal-slot modal-body", children: children }));
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
function DModalFooter({ actionPlacement = 'fill', children, }) {
|
|
1073
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: "d-modal-separator" }), jsx("div", { className: `d-modal-slot modal-footer d-modal-action-${actionPlacement}`, children: children })] }));
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function DModalHeader({ showCloseButton, onClose, children, }) {
|
|
1077
|
+
return (jsxs("div", { className: "modal-header", children: [showCloseButton && (jsx("button", { type: "button", className: "d-modal-close", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { icon: "x-lg" }) })), children] }));
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function DOffcanvas({ name, isStatic, isScrollable, openFrom = 'end', children, }) {
|
|
1081
|
+
return (jsx("div", Object.assign({ className: `offcanvas offcanvas-${openFrom} show`, id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false" }, isStatic && ({
|
|
1082
|
+
[`data-${PREFIX_BS}backdrop`]: 'static',
|
|
1083
|
+
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1084
|
+
}), isScrollable && ({
|
|
1085
|
+
[`data-${PREFIX_BS}scroll`]: 'true',
|
|
1086
|
+
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1087
|
+
}), { children: children })));
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
function DOffcanvasBody({ children }) {
|
|
1091
|
+
return (jsx("div", { className: "d-offcanvas-slot offcanvas-body", children: children }));
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
function DOffcanvasFooter({ footerActionPlacement = 'fill', children, }) {
|
|
1095
|
+
return (jsx("div", { className: `d-offcanvas-slot d-offcanvas-footer d-offcanvas-action-${footerActionPlacement}`, children: children }));
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
function DOffcanvasHeader({ showCloseButton, onClose, children, }) {
|
|
1099
|
+
return (jsxs("div", { className: "offcanvas-header", children: [jsx("div", { className: "d-offcanvas-slot", children: children }), showCloseButton && (jsx("button", { type: "button", className: "d-offcanvas-close", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { icon: "x-lg" }) }))] }));
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
function DPaginator(_a) {
|
|
1103
|
+
var { className, nextLabel, previousLabel, showArrows = true, page, onPageChange } = _a, props = __rest(_a, ["className", "nextLabel", "previousLabel", "showArrows", "page", "onPageChange"]);
|
|
1104
|
+
return (jsx(ResponsivePagination, Object.assign({ extraClassName: classNames('pagination', className), nextClassName: classNames('arrow arrow-next', !nextLabel && 'no-label'), nextLabel: nextLabel, previousClassName: classNames('arrow arrow-prev', !previousLabel && 'no-label'), previousLabel: previousLabel, renderNav: showArrows, current: page, onPageChange: onPageChange }, props)));
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
function DPopover({ children, renderComponent, isOpen, setEventIsOpen, adjustContentToRender = false, }) {
|
|
1108
|
+
const [innerIsOpen, setInnerIsOpen] = useState(false);
|
|
1109
|
+
useEffect(() => {
|
|
1110
|
+
setInnerIsOpen(isOpen);
|
|
1111
|
+
}, [isOpen]);
|
|
1112
|
+
const onOpenChange = useCallback((value) => {
|
|
1113
|
+
setInnerIsOpen(value);
|
|
1114
|
+
if (setEventIsOpen) {
|
|
1115
|
+
setEventIsOpen(value);
|
|
1116
|
+
}
|
|
1117
|
+
}, [setEventIsOpen]);
|
|
1118
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
1119
|
+
open: innerIsOpen,
|
|
1120
|
+
onOpenChange,
|
|
1121
|
+
middleware: [
|
|
1122
|
+
offset(0),
|
|
1123
|
+
flip({ fallbackAxisSideDirection: 'none' }),
|
|
1124
|
+
shift(),
|
|
1125
|
+
],
|
|
1126
|
+
whileElementsMounted: autoUpdate,
|
|
1127
|
+
});
|
|
1128
|
+
const click = useClick(context);
|
|
1129
|
+
const dismiss = useDismiss(context);
|
|
1130
|
+
const role = useRole(context);
|
|
1131
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
1132
|
+
click,
|
|
1133
|
+
dismiss,
|
|
1134
|
+
role,
|
|
1135
|
+
]);
|
|
1136
|
+
const headingId = useId();
|
|
1137
|
+
return (jsxs("div", { className: "d-popover", children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: renderComponent(innerIsOpen) })), innerIsOpen && (jsx(FloatingFocusManager, { context: context, modal: false, children: jsx("div", Object.assign({ className: classNames('d-popover-content', {
|
|
1138
|
+
'w-100': adjustContentToRender,
|
|
1139
|
+
}), ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: children })) }))] }));
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function DProgress({ currentValue, minValue = 0, maxValue = 100, hideCurrentValue = false, enableStripedAnimation = false, }) {
|
|
1143
|
+
const formatProgress = useMemo(() => `${currentValue}%`, [currentValue]);
|
|
1144
|
+
const generateClasses = useMemo(() => ({
|
|
1145
|
+
'progress-bar': true,
|
|
1146
|
+
'progress-bar-striped progress-bar-animated': enableStripedAnimation,
|
|
1147
|
+
}), [enableStripedAnimation]);
|
|
1148
|
+
return (jsx("div", { className: "progress", children: jsx("div", { className: classNames(generateClasses), role: "progressbar", "aria-label": "Progress bar", style: { width: `${currentValue}%` }, "aria-valuenow": currentValue, "aria-valuemin": minValue, "aria-valuemax": maxValue, children: !hideCurrentValue && formatProgress }) }));
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
function DQuickActionButton({ line1, line2, actionLinkText, actionLinkTheme = 'secondary', actionIcon, secondaryActionIcon, actionIconFamilyClass, actionIconFamilyPrefix, representativeImage, representativeIcon, representativeIconTheme = 'secondary', representativeIconHasCircle = false, representativeIconFamilyClass, representativeIconFamilyPrefix, onClick, onClickSecondary, style, }) {
|
|
1152
|
+
const globalClickHandler = useCallback(() => {
|
|
1153
|
+
if (actionLinkText) {
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
1157
|
+
}, [actionLinkText, onClick]);
|
|
1158
|
+
const actionLinkClickHandler = useCallback(() => {
|
|
1159
|
+
if (!actionLinkText) {
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
1163
|
+
}, [actionLinkText, onClick]);
|
|
1164
|
+
const secondaryActionLinkClickHandler = useCallback(() => {
|
|
1165
|
+
onClickSecondary === null || onClickSecondary === void 0 ? void 0 : onClickSecondary();
|
|
1166
|
+
}, [onClickSecondary]);
|
|
1167
|
+
const Tag = useMemo(() => (actionLinkText ? 'div' : 'button'), [actionLinkText]);
|
|
1168
|
+
return (jsxs(Tag, { className: "d-quick-action-button", onClick: !actionLinkText ? globalClickHandler : undefined, style: style, children: [representativeIcon && (jsx(DIcon, { className: "d-quick-action-button-representative-icon", size: representativeIconHasCircle
|
|
1169
|
+
? `var(--${PREFIX_BS}quick-action-button-representative-icon-size)`
|
|
1170
|
+
: `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 })] }) }), secondaryActionIcon && (jsx(DButton, { className: "d-quick-action-button-secondary-action-link", type: "button", variant: "link", iconStart: secondaryActionIcon, iconStartFamilyClass: actionIconFamilyClass, iconStartFamilyPrefix: actionIconFamilyPrefix, theme: actionLinkTheme, onClick: secondaryActionLinkClickHandler, isStopPropagationEnabled: true })), actionLinkText && !actionIcon && (jsx(DButton, { className: "d-quick-action-button-action-link", type: "button", variant: "link", theme: actionLinkTheme, text: actionLinkText, onClick: actionLinkClickHandler, isStopPropagationEnabled: true })), actionIcon && !actionLinkText && (jsx(DIcon, { className: "d-quick-action-button-action-icon", icon: actionIcon, size: `var(--${PREFIX_BS}quick-action-button-action-icon-size)`, familyClass: actionIconFamilyClass, familyPrefix: actionIconFamilyPrefix }))] }));
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
function DQuickActionCheck({ id, name, value, line1, line2, line3, isChecked, onChange, }) {
|
|
1174
|
+
const changeHandler = useCallback((event) => {
|
|
1175
|
+
event.stopPropagation();
|
|
1176
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1177
|
+
}, [onChange]);
|
|
1178
|
+
return (jsxs("label", { className: "d-quick-action-check", htmlFor: id, children: [jsx(DInputCheck, { id: id, type: "radio", name: name, value: value, isChecked: isChecked, 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 })] }));
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
function DQuickActionSelect({ id, name, value, line1, line2, isSelected = false, onChange, }) {
|
|
1182
|
+
const innerRef = useRef(null);
|
|
1183
|
+
const changeHandler = useCallback((event) => {
|
|
1184
|
+
event.stopPropagation();
|
|
1185
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1186
|
+
}, [onChange]);
|
|
1187
|
+
useEffect(() => {
|
|
1188
|
+
if (innerRef.current) {
|
|
1189
|
+
innerRef.current.checked = isSelected;
|
|
1190
|
+
}
|
|
1191
|
+
}, [isSelected]);
|
|
1192
|
+
return (jsxs("label", { className: "d-quick-action-select", htmlFor: id, 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 })] }));
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
function DQuickActionSwitch({ id, name, label, hint, isChecked, isDisabled, onClick, }) {
|
|
1196
|
+
const clickHandler = useCallback((event) => {
|
|
1197
|
+
event.stopPropagation();
|
|
1198
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(isChecked);
|
|
1199
|
+
}, [isChecked, onClick]);
|
|
1200
|
+
return (jsxs("button", { className: "d-quick-action-switch", type: "button", onClick: clickHandler, children: [jsxs("div", { className: "d-quick-action-switch-content", children: [jsx(DInputSwitch, { id: id, name: name, isDisabled: isDisabled, isChecked: isChecked, isReadonly: true }), jsx("label", { className: "d-quick-action-switch-label", htmlFor: id, children: label })] }), jsx("div", { className: "d-quick-action-switch-hint", children: hint })] }));
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
function DSkeleton({ speed = 2, viewBox, backgroundColor, foregroundColor, children, }) {
|
|
1204
|
+
const innerBackgroundColor = useMemo(() => {
|
|
1205
|
+
if (backgroundColor) {
|
|
1206
|
+
return backgroundColor;
|
|
1207
|
+
}
|
|
1208
|
+
const computedStyle = getComputedStyle(document.documentElement);
|
|
1209
|
+
return computedStyle.getPropertyValue(`--${PREFIX_BS}secondary-100`);
|
|
1210
|
+
}, [backgroundColor]);
|
|
1211
|
+
const innerForegroundColor = useMemo(() => {
|
|
1212
|
+
if (foregroundColor) {
|
|
1213
|
+
return foregroundColor;
|
|
1214
|
+
}
|
|
1215
|
+
const computedStyle = getComputedStyle(document.documentElement);
|
|
1216
|
+
return computedStyle.getPropertyValue(`--${PREFIX_BS}gray-100`);
|
|
1217
|
+
}, [foregroundColor]);
|
|
1218
|
+
return (jsx(ContentLoader, { speed: speed, viewBox: viewBox, backgroundColor: innerBackgroundColor, foregroundColor: innerForegroundColor, children: children }));
|
|
937
1219
|
}
|
|
938
1220
|
|
|
939
1221
|
function DStepper$2({ options, currentStep, successIcon = 'check', isVertical = false, }) {
|
|
940
1222
|
if (currentStep < 1 || currentStep > options.length) {
|
|
941
|
-
throw new Error('Current step should be in the range from 1 to options
|
|
1223
|
+
throw new Error('Current step should be in the range from 1 to options length');
|
|
942
1224
|
}
|
|
943
|
-
return (jsx("div",
|
|
1225
|
+
return (jsx("div", { className: classNames({
|
|
944
1226
|
'd-stepper-desktop': true,
|
|
945
1227
|
'is-vertical': isVertical,
|
|
946
|
-
})
|
|
1228
|
+
}), children: options.map(({ label, value }) => (jsxs("div", { className: "d-step", children: [jsx("div", { className: "d-step-value", children: jsx("div", { className: classNames({
|
|
947
1229
|
'd-step-icon-container': true,
|
|
948
1230
|
'd-step-check': value < currentStep,
|
|
949
1231
|
'd-step-current': value === currentStep,
|
|
950
|
-
})
|
|
951
|
-
? (jsx(DIcon, { icon: successIcon,
|
|
952
|
-
: value })
|
|
1232
|
+
}), children: value < currentStep
|
|
1233
|
+
? (jsx(DIcon, { icon: successIcon, className: "d-step-icon" }))
|
|
1234
|
+
: value }) }), jsx("div", { className: "d-step-label", children: label })] }, value))) }));
|
|
953
1235
|
}
|
|
954
1236
|
|
|
955
1237
|
function DStepper$1({ options, currentStep, }) {
|
|
956
1238
|
if (currentStep < 1 || currentStep > options.length) {
|
|
957
|
-
throw new Error('Current step should be in the range from 1 to options
|
|
1239
|
+
throw new Error('Current step should be in the range from 1 to options length');
|
|
958
1240
|
}
|
|
959
1241
|
const currentOption = useMemo(() => { var _a; return (_a = options[currentStep - 1]) !== null && _a !== void 0 ? _a : {}; }, [currentStep, options]);
|
|
960
1242
|
const [currentAngle, setCurrentAngle] = useState(0);
|
|
@@ -979,62 +1261,112 @@ function DStepper$1({ options, currentStep, }) {
|
|
|
979
1261
|
from 180deg,
|
|
980
1262
|
var(--${PREFIX_BS}step-progress-outter-fill-background-color) ${currentAngle}deg,
|
|
981
1263
|
var(--${PREFIX_BS}step-progress-outter-background-color) 0deg)`, [currentAngle]);
|
|
982
|
-
return (jsxs("div",
|
|
1264
|
+
return (jsxs("div", { className: "d-stepper", 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 || '' })] })) })] }));
|
|
983
1265
|
}
|
|
984
1266
|
|
|
985
1267
|
function DStepper({ options, currentStep, successIcon = 'check', isVertical = false, breakpoint = 'lg', }) {
|
|
986
|
-
return (jsxs(Fragment, { children: [jsx("div",
|
|
1268
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: `d-block d-${breakpoint}-none`, children: jsx(DStepper$1, { options: options, currentStep: currentStep }) }), jsx("div", { className: `d-none d-${breakpoint}-block`, children: jsx(DStepper$2, { options: options, currentStep: currentStep, successIcon: successIcon, isVertical: isVertical }) })] }));
|
|
987
1269
|
}
|
|
988
1270
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
const [
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1271
|
+
const TabContext = createContext(undefined);
|
|
1272
|
+
function DTabs({ children, defaultSelected, onChange, options, className, isVertical, }) {
|
|
1273
|
+
const [selected, setSelected] = useState(defaultSelected);
|
|
1274
|
+
const onSelect = useCallback((option) => {
|
|
1275
|
+
if (option.tab) {
|
|
1276
|
+
setSelected(option.tab);
|
|
1277
|
+
}
|
|
1278
|
+
onChange(option);
|
|
1279
|
+
}, [onChange]);
|
|
1280
|
+
useEffect(() => {
|
|
1281
|
+
setSelected(defaultSelected);
|
|
1282
|
+
}, [defaultSelected]);
|
|
1283
|
+
const isSelected = useCallback((tab) => (selected === tab), [selected]);
|
|
1284
|
+
const value = useMemo(() => ({
|
|
1285
|
+
isSelected,
|
|
1286
|
+
}), [isSelected]);
|
|
1287
|
+
return (jsx(TabContext.Provider, { value: value, children: jsxs("div", { className: classNames({
|
|
1288
|
+
'd-tabs': true,
|
|
1289
|
+
'd-tabs-vertical': isVertical,
|
|
1290
|
+
}), children: [jsx("nav", { className: "nav", children: options.map((option) => (jsx("button", { id: `${option.tab}Tab`, className: classNames('nav-link', {
|
|
1291
|
+
active: option.tab === selected,
|
|
1292
|
+
}, className), type: "button", role: "tab", "aria-controls": `${option.tab}Pane`, "aria-selected": option.tab === selected, disabled: option.isDisabled, onClick: () => onSelect(option), children: option.label }, option.label))) }), jsx("div", { className: "tab-content", children: children })] }) }));
|
|
1009
1293
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1294
|
+
function useTabContext() {
|
|
1295
|
+
const context = useContext(TabContext);
|
|
1296
|
+
if (context === undefined) {
|
|
1297
|
+
throw new Error('useTabContext was used outside of MTab');
|
|
1298
|
+
}
|
|
1299
|
+
return context;
|
|
1013
1300
|
}
|
|
1014
1301
|
|
|
1015
|
-
function
|
|
1016
|
-
|
|
1302
|
+
function DTabContent({ tab, children }) {
|
|
1303
|
+
const { isSelected } = useTabContext();
|
|
1304
|
+
if (!isSelected(tab)) {
|
|
1305
|
+
return null;
|
|
1306
|
+
}
|
|
1307
|
+
return (jsx("div", { className: "tab-pane fade show active", id: `${tab}Pane`, role: "tabpanel", tabIndex: 0, "aria-labelledby": `${tab}Tab`, children: children }));
|
|
1017
1308
|
}
|
|
1018
1309
|
|
|
1019
|
-
|
|
1020
|
-
var
|
|
1021
|
-
|
|
1310
|
+
const TOOLTIP_FONT_SIZE_BY_SIZE = {
|
|
1311
|
+
sm: `var(--${PREFIX_BS}ref-fs-small)`,
|
|
1312
|
+
default: `var(--${PREFIX_BS}body-font-size)`,
|
|
1313
|
+
lg: `var(--${PREFIX_BS}ref-fs-6)`,
|
|
1314
|
+
};
|
|
1315
|
+
const ARROW_WIDTH = 8;
|
|
1316
|
+
const ARROW_HEIGHT = 4;
|
|
1317
|
+
const GAP = 2;
|
|
1318
|
+
function DTooltip({ classNameContainer, className, offSet = ARROW_HEIGHT + GAP, padding, withFocus = false, withClick = false, withHover = true, isOpen = false, placement = 'top', size, Component, children, }) {
|
|
1319
|
+
const [open, setOpen] = useState(isOpen);
|
|
1320
|
+
const styleVariables = useMemo(() => {
|
|
1321
|
+
const defaultFontSize = size
|
|
1322
|
+
? TOOLTIP_FONT_SIZE_BY_SIZE[size]
|
|
1323
|
+
: TOOLTIP_FONT_SIZE_BY_SIZE.default;
|
|
1324
|
+
return {
|
|
1325
|
+
background: `var(--${PREFIX_BS}tooltip-bg, var(--${PREFIX_BS}tooltip-component-bg, var(--${PREFIX_BS}secondary)))`,
|
|
1326
|
+
borderRadius: `var(--${PREFIX_BS}tooltip-border-radius, var(--${PREFIX_BS}tooltip-component-border-radius, var(--${PREFIX_BS}border-radius)))`,
|
|
1327
|
+
color: `var(--${PREFIX_BS}tooltip-color, var(--${PREFIX_BS}tooltip-component-color, var(--${PREFIX_BS}white)))`,
|
|
1328
|
+
fontSize: `var(--${PREFIX_BS}tooltip-font-size, var(--${PREFIX_BS}tooltip-component-font-size, ${defaultFontSize}))`,
|
|
1329
|
+
padding: `var(--${PREFIX_BS}tooltip-padding, var(--${PREFIX_BS}tooltip-component-padding, var(--${PREFIX_BS}ref-spacer-2)))`,
|
|
1330
|
+
maxWidth: `var(--${PREFIX_BS}tooltip-max-width, var(--${PREFIX_BS}tooltip-component-max-width, 300px))`,
|
|
1331
|
+
};
|
|
1332
|
+
}, [size]);
|
|
1333
|
+
const arrowRef = useRef(null);
|
|
1334
|
+
const { refs, context, floatingStyles, } = useFloating({
|
|
1335
|
+
open,
|
|
1336
|
+
onOpenChange: setOpen,
|
|
1337
|
+
placement,
|
|
1338
|
+
whileElementsMounted: autoUpdate,
|
|
1339
|
+
middleware: [
|
|
1340
|
+
offset(offSet),
|
|
1341
|
+
flip(),
|
|
1342
|
+
shift({
|
|
1343
|
+
padding,
|
|
1344
|
+
}),
|
|
1345
|
+
arrow({
|
|
1346
|
+
element: arrowRef,
|
|
1347
|
+
}),
|
|
1348
|
+
],
|
|
1349
|
+
});
|
|
1350
|
+
const hover = useHover(context, { move: false });
|
|
1351
|
+
const focus = useFocus(context);
|
|
1352
|
+
const dismiss = useDismiss(context);
|
|
1353
|
+
const click = useClick(context);
|
|
1354
|
+
const role = useRole(context, { role: 'tooltip' });
|
|
1355
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
1356
|
+
withHover ? hover : undefined,
|
|
1357
|
+
withClick ? click : undefined,
|
|
1358
|
+
withFocus ? focus : undefined,
|
|
1359
|
+
dismiss,
|
|
1360
|
+
role,
|
|
1361
|
+
]);
|
|
1362
|
+
return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: className, ref: refs.setReference }, getReferenceProps(), { children: Component })), jsx(FloatingPortal, { children: open && (jsxs("div", Object.assign({ className: classNameContainer, ref: refs.setFloating, style: Object.assign(Object.assign({}, floatingStyles), styleVariables) }, getFloatingProps(), { children: [jsx(FloatingArrow, { ref: arrowRef, context: context, style: {
|
|
1363
|
+
fill: styleVariables.background,
|
|
1364
|
+
}, width: ARROW_WIDTH, height: ARROW_HEIGHT }), children] }))) })] }));
|
|
1022
1365
|
}
|
|
1023
1366
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
var { lng = LANG, fallbackLng = 'es' } = _a, config = __rest(_a, ["lng", "fallbackLng"]);
|
|
1027
|
-
return i18n
|
|
1028
|
-
.use(initReactI18next)
|
|
1029
|
-
.init(Object.assign({ resources,
|
|
1030
|
-
lng, initImmediate: true, fallbackLng, interpolation: {
|
|
1031
|
-
escapeValue: false,
|
|
1032
|
-
prefix: '{',
|
|
1033
|
-
suffix: '}',
|
|
1034
|
-
// skipOnVariables: false,
|
|
1035
|
-
} }, config))
|
|
1036
|
-
.then((t) => t);
|
|
1367
|
+
function DToastContainer({ style, position = 'top-right', }) {
|
|
1368
|
+
return (jsx(ToastContainer, { toastClassName: () => 'shadow-none p-0 cursor-default', position: position, autoClose: false, hideProgressBar: true, closeOnClick: false, closeButton: false, transition: Slide, style: style }));
|
|
1037
1369
|
}
|
|
1038
1370
|
|
|
1039
|
-
export { DAlert, DBadge, DBoxFile, DButton, DCard, DCardAccount, DCardBody, DCardFooter, DCardHeader, DCarousel, DCarouselSlide, DChip, DCollapse, DCollapseIconText, DCurrencyText, DDatePicker, DFormikInput, DFormikInputCurrency, DFormikInputSelect, DIcon, DInput, DInputCheck, DInputCounter, DInputCurrency, DInputCurrencyBase, DInputPassword, DInputPin, DInputSearch, DInputSelect, DInputSwitch, DList, DListItem, DListItemMovement, DModal, DOffcanvas, DPaginator, DPermissionItem, DPopover, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTabs, DToastContainer, DTooltip, LiquidContext$1 as LiquidContext, LiquidContextProvider,
|
|
1371
|
+
export { DAlert, DBadge, DBoxFile, DButton, DCard, DCardAccount, DCardBody, DCardFooter, DCardHeader, DCarousel, DCarouselSlide, DChip, DCollapse, DCollapseIconText, DCurrencyText, DDatePicker, DFormikInput, DFormikInputCurrency, DFormikInputSelect, DIcon, DInput$1 as DInput, DInputCheck, DInputCounter, DInputCurrency, DInputCurrencyBase, DInputPassword, DInputPin, DInputSearch, DInputSelect, DInputSwitch, DList, DListItem, DListItemMovement, DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPermissionGroup, DPermissionItem, DPopover, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DSummaryCard, DTabContent, DTabs, DToastContainer, DTooltip, LiquidContext$1 as LiquidContext, LiquidContextProvider, ModalContext, ModalContextProvider, OffcanvasContext, OffcanvasContextProvider, configureI8n as configureI18n, formatCurrency, liquidParser, useFormatCurrency, useLiquidContext, useModalContext, useOffcanvasContext, useScreenshot, useScreenshotDownload, useScreenshotWebShare, useTabContext, useToast };
|
|
1040
1372
|
//# sourceMappingURL=index.esm.js.map
|