@dynamic-framework/ui-react 2.0.0-dev.22 → 2.0.0-dev.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/dynamic-ui-non-root.css +13424 -895
- package/dist/css/dynamic-ui-non-root.min.css +2 -2
- package/dist/css/dynamic-ui-root.css +1 -17
- package/dist/css/dynamic-ui-root.min.css +2 -2
- package/dist/css/dynamic-ui.css +13424 -911
- package/dist/css/dynamic-ui.min.css +2 -2
- package/dist/index.esm.js +98 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +106 -29
- package/dist/index.js.map +1 -1
- package/dist/types/components/DBadge/DBadge.d.ts +3 -2
- package/dist/types/components/DButton/DButton.d.ts +3 -2
- package/dist/types/components/DCreditCard/DCreditCard.d.ts +2 -1
- package/dist/types/components/DDataStateWrapper/DDataStateWrapper.d.ts +14 -0
- package/dist/types/components/DDataStateWrapper/components/EmptyState.d.ts +8 -0
- package/dist/types/components/DDataStateWrapper/components/ErrorState.d.ts +8 -0
- package/dist/types/components/DDataStateWrapper/components/LoadingState.d.ts +6 -0
- package/dist/types/components/DDataStateWrapper/index.d.ts +2 -0
- package/dist/types/components/DErrorBoundary/DErrorBoundary.d.ts +11 -0
- package/dist/types/components/DErrorBoundary/components/DefaultErrorBoundary.d.ts +6 -0
- package/dist/types/components/DErrorBoundary/index.d.ts +3 -0
- package/dist/types/components/index.d.ts +2 -0
- package/package.json +8 -14
- package/src/style/abstracts/_utilities-dark.scss +72 -0
- package/src/style/abstracts/_utilities.scss +7 -8
- package/src/style/abstracts/variables/_+import.scss +0 -4
- package/src/style/abstracts/variables/_alerts.scss +1 -1
- package/src/style/abstracts/variables/_input-phone.scss +1 -1
- package/src/style/abstracts/variables/_tooltip.scss +2 -2
- package/src/style/abstracts/variables/_typography.scss +0 -40
- package/src/style/base/_badge.scss +2 -2
- package/src/style/base/_type.scss +3 -6
- package/src/style/components/_d-credit-card.scss +22 -12
- package/src/style/components/_d-icon.scss +17 -0
- package/src/style/dynamic-ui-non-root.scss +2 -0
- package/src/style/dynamic-ui.scss +2 -0
- package/src/style/helpers/_color-bg.scss +1 -3
- package/src/style/root/_root.scss +0 -5
- package/src/style/abstracts/variables/_quick-action-button.scss +0 -31
- package/src/style/abstracts/variables/_quick-action-check.scss +0 -22
- package/src/style/abstracts/variables/_quick-action-select.scss +0 -16
- package/src/style/abstracts/variables/_quick-action-switch.scss +0 -19
package/dist/index.esm.js
CHANGED
|
@@ -11,12 +11,14 @@ import currency from 'currency.js';
|
|
|
11
11
|
import DatePicker from 'react-datepicker';
|
|
12
12
|
import { getYear, format, getMonth } from 'date-fns';
|
|
13
13
|
import Select, { components } from 'react-select';
|
|
14
|
+
import { getErrorMessage, ErrorBoundary } from 'react-error-boundary';
|
|
15
|
+
export { getErrorMessage, useErrorBoundary } from 'react-error-boundary';
|
|
14
16
|
import { InputMask } from '@react-input/mask';
|
|
17
|
+
import { defaultCountries, parseCountry, usePhoneInput, CountrySelector } from 'react-international-phone';
|
|
18
|
+
import { PhoneNumberUtil } from 'google-libphonenumber';
|
|
15
19
|
import ResponsivePagination from 'react-responsive-pagination';
|
|
16
20
|
import { useFloating, autoUpdate, offset, flip, shift, useClick, useDismiss, useRole, useInteractions, useId as useId$1, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
|
|
17
21
|
import { Toaster, toast } from 'react-hot-toast';
|
|
18
|
-
import { defaultCountries, parseCountry, usePhoneInput, CountrySelector } from 'react-international-phone';
|
|
19
|
-
import { PhoneNumberUtil } from 'google-libphonenumber';
|
|
20
22
|
import html2canvas from 'html2canvas';
|
|
21
23
|
import i18n from 'i18next';
|
|
22
24
|
import { initReactI18next } from 'react-i18next';
|
|
@@ -410,21 +412,6 @@ function DIconBase({ icon, color, style, className, size, useListenerSize = fals
|
|
|
410
412
|
const icons = LucideIcons;
|
|
411
413
|
return icons[icon] || null;
|
|
412
414
|
}, [icon, useMaterialIcons]);
|
|
413
|
-
const colorStyle = useMemo(() => {
|
|
414
|
-
if (color) {
|
|
415
|
-
return { [`--${PREFIX_BS}icon-component-color`]: `var(--${PREFIX_BS}${color})` };
|
|
416
|
-
}
|
|
417
|
-
return {};
|
|
418
|
-
}, [color]);
|
|
419
|
-
const backgroundStyle = useMemo(() => {
|
|
420
|
-
if (hasCircle) {
|
|
421
|
-
if (color) {
|
|
422
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}${color}-rgb), 0.1)` };
|
|
423
|
-
}
|
|
424
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}body-color-rgb), 0.1)` };
|
|
425
|
-
}
|
|
426
|
-
return {};
|
|
427
|
-
}, [hasCircle, color]);
|
|
428
415
|
const { responsivePropValue } = useResponsiveProp(useListenerSize);
|
|
429
416
|
const resolvedSize = useMemo(() => {
|
|
430
417
|
if (!size)
|
|
@@ -433,8 +420,8 @@ function DIconBase({ icon, color, style, className, size, useListenerSize = fals
|
|
|
433
420
|
return size;
|
|
434
421
|
return responsivePropValue(size);
|
|
435
422
|
}, [responsivePropValue, size]);
|
|
436
|
-
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign(Object.assign(
|
|
437
|
-
const generateClasses = useMemo(() => (Object.assign({ 'd-icon': true }, className && { [className]: true })), [className]);
|
|
423
|
+
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign(Object.assign({}, resolvedSize && { [`--${PREFIX_BS}icon-component-size`]: resolvedSize }), hasCircle && { [`--${PREFIX_BS}icon-component-padding`]: `calc(var(--${PREFIX_BS}icon-component-size, 24px) * 0.4)` }), style)), [resolvedSize, hasCircle, style]);
|
|
424
|
+
const generateClasses = useMemo(() => (Object.assign(Object.assign(Object.assign({ 'd-icon': true }, className && { [className]: true }), { 'd-icon-has-circle': hasCircle }), color && { [`d-icon-color-${color}`]: true })), [className, hasCircle, color]);
|
|
438
425
|
const iconSize = useMemo(() => {
|
|
439
426
|
if (resolvedSize) {
|
|
440
427
|
const numSize = parseInt(resolvedSize, 10);
|
|
@@ -489,14 +476,24 @@ function DAvatar({ id, size, image, name: nameProp, useNameAsInitials = false, c
|
|
|
489
476
|
return (jsxs("div", Object.assign({ className: classNames(generateClasses, className), style: style, id: id }, dataAttributes, { children: [image && jsx("img", { src: image, alt: nameProp, className: "d-avatar-img" }), (name && !image) && jsx("span", { className: "d-avatar-name", children: name })] })));
|
|
490
477
|
}
|
|
491
478
|
|
|
492
|
-
function DBadge(
|
|
479
|
+
function DBadge(props) {
|
|
480
|
+
const { text, soft = false, color = 'primary', id, rounded, className, size, style, iconStart, iconEnd, iconMaterialStyle, iconFamilyClass, iconFamilyPrefix, dataAttributes, } = props;
|
|
481
|
+
// Responsive size resolution using useResponsiveProp
|
|
482
|
+
const { responsivePropValue } = useResponsiveProp(true);
|
|
483
|
+
const resolvedSize = useMemo(() => {
|
|
484
|
+
if (!size)
|
|
485
|
+
return undefined;
|
|
486
|
+
if (typeof size === 'string')
|
|
487
|
+
return size;
|
|
488
|
+
return responsivePropValue(size);
|
|
489
|
+
}, [responsivePropValue, size]);
|
|
493
490
|
const generateClasses = useMemo(() => ({
|
|
494
491
|
badge: true,
|
|
495
492
|
[`badge-${color}`]: !!color && !soft,
|
|
496
493
|
[`badge-soft-${color}`]: !!color && soft,
|
|
497
494
|
'rounded-pill': !!rounded,
|
|
498
|
-
[`badge-${
|
|
499
|
-
}), [rounded, soft, color,
|
|
495
|
+
[`badge-${resolvedSize}`]: !!resolvedSize,
|
|
496
|
+
}), [rounded, soft, color, resolvedSize]);
|
|
500
497
|
return (jsxs("span", Object.assign({ className: classNames(generateClasses, className), style: style }, id && { id }, dataAttributes, { children: [iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsx("span", { children: text }), iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }))] })));
|
|
501
498
|
}
|
|
502
499
|
|
|
@@ -1001,7 +998,16 @@ function DBoxFile(_a) {
|
|
|
1001
998
|
}
|
|
1002
999
|
|
|
1003
1000
|
const DButton = forwardRef((props, ref) => {
|
|
1004
|
-
const { color = 'primary', size, variant, text, children, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartMaterialStyle, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndMaterialStyle, loading = false, loadingText, loadingAriaLabel, disabled = false, className, style, dataAttributes, onClick, type = 'button', target, rel } = props, rest = __rest(props, ["color", "size", "variant", "text", "children", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartMaterialStyle", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndMaterialStyle", "loading", "loadingText", "loadingAriaLabel", "disabled", "className", "style", "dataAttributes", "onClick", "type", "target", "rel"]);
|
|
1001
|
+
const { color = 'primary', size, variant, text, children, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartMaterialStyle, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndMaterialStyle, loading = false, loadingText, loadingAriaLabel, disabled = false, className, style, dataAttributes, onClick, type = 'button', target, rel, href } = props, rest = __rest(props, ["color", "size", "variant", "text", "children", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartMaterialStyle", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndMaterialStyle", "loading", "loadingText", "loadingAriaLabel", "disabled", "className", "style", "dataAttributes", "onClick", "type", "target", "rel", "href"]);
|
|
1002
|
+
// Responsive size resolution using useResponsiveProp
|
|
1003
|
+
const { responsivePropValue } = useResponsiveProp(true);
|
|
1004
|
+
const resolvedSize = useMemo(() => {
|
|
1005
|
+
if (!size)
|
|
1006
|
+
return undefined;
|
|
1007
|
+
if (typeof size === 'string')
|
|
1008
|
+
return size;
|
|
1009
|
+
return responsivePropValue(size);
|
|
1010
|
+
}, [responsivePropValue, size]);
|
|
1005
1011
|
const [buttonWidth, setButtonWidth] = useState();
|
|
1006
1012
|
const buttonRef = useRef(null);
|
|
1007
1013
|
const isDisabled = useMemo(() => disabled || loading, [disabled, loading]);
|
|
@@ -1013,10 +1019,10 @@ const DButton = forwardRef((props, ref) => {
|
|
|
1013
1019
|
return {
|
|
1014
1020
|
btn: true,
|
|
1015
1021
|
[variantClass]: true,
|
|
1016
|
-
[`btn-${
|
|
1022
|
+
[`btn-${resolvedSize}`]: !!resolvedSize,
|
|
1017
1023
|
loading,
|
|
1018
1024
|
};
|
|
1019
|
-
}, [variant, color,
|
|
1025
|
+
}, [variant, color, loading, resolvedSize]);
|
|
1020
1026
|
const ariaLabel = useMemo(() => {
|
|
1021
1027
|
const ariaLabelProp = rest['aria-label'];
|
|
1022
1028
|
return loading
|
|
@@ -1038,8 +1044,8 @@ const DButton = forwardRef((props, ref) => {
|
|
|
1038
1044
|
}
|
|
1039
1045
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1040
1046
|
}, [content, iconEnd, iconStart]);
|
|
1041
|
-
if (
|
|
1042
|
-
return (jsxs("a", Object.assign({ href:
|
|
1047
|
+
if (href) {
|
|
1048
|
+
return (jsxs("a", Object.assign({ href: href, target: target, rel: rel, ref: (node) => {
|
|
1043
1049
|
buttonRef.current = node;
|
|
1044
1050
|
if (typeof ref === 'function')
|
|
1045
1051
|
ref(node);
|
|
@@ -2474,8 +2480,12 @@ ForwardedDInputPhone.displayName = 'DInputPhone';
|
|
|
2474
2480
|
|
|
2475
2481
|
const DEFAULT_IMAGE = 'https://cdn.modyo.cloud/uploads/06b434f7-b943-4f54-9543-84a904e189aa/original/Visa_Logo_1_.png';
|
|
2476
2482
|
const CHIP_IMAGE = 'https://cdn.modyo.cloud/uploads/4660ad00-e5d8-477e-8919-52b53d0a26fb/original/chip-debit-svgrepo-com_1_.png';
|
|
2483
|
+
const BRAND_LOGOS = {
|
|
2484
|
+
visa: DEFAULT_IMAGE,
|
|
2485
|
+
mastercard: 'https://cdn.modyo.cloud/uploads/f686b9aa-65ab-4369-9db3-89ceece84f29/original/mastercard.png',
|
|
2486
|
+
};
|
|
2477
2487
|
function DCreditCard({ brand = 'visa', name, number, holderText = 'Card Holder', logoImage, isChipVisible = true, className, isVertical = false, }) {
|
|
2478
|
-
return (jsxs("div", { className: classNames('d-credit-card
|
|
2488
|
+
return (jsxs("div", { className: classNames('d-credit-card', isVertical && 'is-vertical', className), children: [jsxs("div", { className: "d-credit-card-header", children: [jsx("img", { src: logoImage || BRAND_LOGOS[brand] || DEFAULT_IMAGE, alt: brand, className: "d-credit-card-logo", width: 100 }), isChipVisible && (jsx("div", { className: "d-credit-card-chip", children: jsx("img", { src: CHIP_IMAGE, alt: "chip", width: 30, className: "d-credit-card-chip-image" }) }))] }), jsxs("div", { className: "d-credit-card-details", children: [jsx("div", { className: "d-credit-card-number", children: number }), jsx("small", { className: "d-credit-card-holder-text", children: holderText }), jsx("span", { className: "d-credit-card-name", children: name })] })] }));
|
|
2479
2489
|
}
|
|
2480
2490
|
|
|
2481
2491
|
const getItemClass = (action) => {
|
|
@@ -2699,7 +2709,7 @@ const defaultMessage = (secs) => (secs > 0
|
|
|
2699
2709
|
: "Didn't get any code?");
|
|
2700
2710
|
function OtpCountdown({ seconds, resendText, message, }) {
|
|
2701
2711
|
const { secondsLeft, restartCountdown } = useCountdown(seconds);
|
|
2702
|
-
return (jsxs("div", { className: "d-flex gap-2 align-items-center", children: [jsx("p", { className: "mb-0", children: message ? message(secondsLeft) : defaultMessage(secondsLeft) }), jsx(DButton, { text: resendText, variant: "link", disabled: secondsLeft > 0, onClick: restartCountdown })] }));
|
|
2712
|
+
return (jsxs("div", { className: "d-flex gap-2 align-items-center", children: [jsx("p", { className: "mb-0 flex-1", children: message ? message(secondsLeft) : defaultMessage(secondsLeft) }), jsx(DButton, { text: resendText, variant: "link", className: "text-nowrap", disabled: secondsLeft > 0, onClick: restartCountdown })] }));
|
|
2703
2713
|
}
|
|
2704
2714
|
|
|
2705
2715
|
const TEXT_PROPS = {
|
|
@@ -2732,5 +2742,63 @@ function DOtp({ className, action, isLoading, otpSize = 6, texts = TEXT_PROPS, s
|
|
|
2732
2742
|
}, loading: isLoading }), jsx("p", { className: "small ms-lg-auto mb-0", children: texts.contact })] })] })] }));
|
|
2733
2743
|
}
|
|
2734
2744
|
|
|
2735
|
-
|
|
2745
|
+
function DefaultErrorBoundary({ resetErrorBoundary }) {
|
|
2746
|
+
return (jsx(DAlert, { color: "danger", showClose: false, children: jsxs("div", { className: "d-flex align-items-center gap-2", children: [jsx("span", { children: "An unexpected error occurred." }), jsx(DButton, { color: "secondary", variant: "outline", size: "sm", onClick: resetErrorBoundary, children: "Retry" })] }) }));
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
function DErrorBoundary({ name, fallback, resetKeys, onReset, onError, children, }) {
|
|
2750
|
+
const handleError = useCallback((error, info) => {
|
|
2751
|
+
// eslint-disable-next-line no-console
|
|
2752
|
+
console.error(`[DErrorBoundary${name ? `:${name}` : ''}]`, getErrorMessage(error), info);
|
|
2753
|
+
onError === null || onError === void 0 ? void 0 : onError(error, info);
|
|
2754
|
+
}, [name, onError]);
|
|
2755
|
+
const FallbackRender = useCallback((props) => {
|
|
2756
|
+
if (fallback)
|
|
2757
|
+
return fallback(props);
|
|
2758
|
+
return (jsx(DefaultErrorBoundary, { resetErrorBoundary: props.resetErrorBoundary }));
|
|
2759
|
+
}, [fallback]);
|
|
2760
|
+
return (jsx(ErrorBoundary, { resetKeys: resetKeys, onReset: onReset, onError: handleError, fallbackRender: FallbackRender, children: children }));
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
function ErrorState({ message, onRetry, retryMessage = 'Retry', color = 'danger', }) {
|
|
2764
|
+
return (jsxs(DAlert, { color: color, className: "d-flex align-items-center gap-3", children: [jsx("div", { className: "flex-grow-1", children: jsx("p", { className: "mb-0", children: message !== null && message !== void 0 ? message : 'An unexpected error occurred.' }) }), onRetry && (jsx(DButton, { onClick: onRetry, text: retryMessage, variant: "outline", iconStart: "RefreshCw" }))] }));
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
function EmptyState({ message, icon = 'FileText', actionText, onAction, }) {
|
|
2768
|
+
return (jsxs("div", { className: "d-flex flex-column align-items-center justify-content-center p-5 text-center", children: [jsx(DIcon, { icon: icon, size: "3rem", className: "text-secondary mb-3" }), jsx("p", { className: "text-secondary mb-3", children: message !== null && message !== void 0 ? message : 'No data available.' }), actionText && onAction && (jsx(DButton, { onClick: onAction, text: actionText, variant: "outline" }))] }));
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
function LoadingState({ ariaLabel = 'Loading...', className }) {
|
|
2772
|
+
return (jsx("div", { className: `d-flex align-items-center justify-content-center p-4 ${className || ''}`.trim(), "aria-busy": "true", "aria-live": "polite", children: jsx("span", { className: "spinner-border", role: "status", "aria-label": ariaLabel }) }));
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
function render(renderable) {
|
|
2776
|
+
if (renderable === undefined)
|
|
2777
|
+
return null;
|
|
2778
|
+
return typeof renderable === 'function' ? renderable() : renderable;
|
|
2779
|
+
}
|
|
2780
|
+
function DDataStateWrapper({ isLoading, isError, data, onRetry, renderLoading, renderEmpty, renderError, children, }) {
|
|
2781
|
+
// 1. Loading
|
|
2782
|
+
if (isLoading) {
|
|
2783
|
+
if (renderLoading)
|
|
2784
|
+
return render(renderLoading);
|
|
2785
|
+
return jsx(LoadingState, {});
|
|
2786
|
+
}
|
|
2787
|
+
// 2. Error
|
|
2788
|
+
if (isError) {
|
|
2789
|
+
if (renderError)
|
|
2790
|
+
return render(renderError);
|
|
2791
|
+
return (jsx(ErrorState, { onRetry: onRetry }));
|
|
2792
|
+
}
|
|
2793
|
+
// 3. Empty
|
|
2794
|
+
if (!(data === null || data === void 0 ? void 0 : data.length)) {
|
|
2795
|
+
if (renderEmpty)
|
|
2796
|
+
return render(renderEmpty);
|
|
2797
|
+
return (jsx(EmptyState, {}));
|
|
2798
|
+
}
|
|
2799
|
+
// 4. Success
|
|
2800
|
+
return jsx(Fragment, { children: children(data) });
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
export { DAlert, DAvatar, DBadge, DBox, DBoxFile, DButton, DButtonIcon, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCreditCard, DCurrencyText, DDataStateWrapper, DDatePicker, DDropdown, DErrorBoundary, DIcon, DIconBase, ForwardedDInput as DInput, DInputCheck, ForwardedDInputCounter as DInputCounter, ForwardedDInputCurrency as DInputCurrency, ForwardedDInputMask as DInputMask, ForwardedDInputPassword as DInputPassword, ForwardedDInputPhone as DInputPhone, DInputPin, ForwardedDInputRange as DInputRange, DInputSelect, DInputSwitch, DLayout$1 as DLayout, DLayoutPane, DListGroup$1 as DListGroup, DListGroupItem, DModal$1 as DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DOtp, DPaginator, DPasswordStrengthMeter, DPopover, DProgress, DSelect$1 as DSelect, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTabs$1 as DTabs, DTimeline, DToast$1 as DToast, DToastContainer, DTooltip, DVoucher, changeQueryString, checkMediaQuery, configureI8n as configureI18n, formatCurrency, getCssVariable, getQueryString, subscribeToMediaQuery, useDContext, useDPortalContext, useDToast, useDisableBodyScrollEffect, useDisableInputWheel, useFormatCurrency, useInputCurrency, useItemSelection, useMediaBreakpointUpLg, useMediaBreakpointUpMd, useMediaBreakpointUpSm, useMediaBreakpointUpXl, useMediaBreakpointUpXs, useMediaBreakpointUpXxl, useMediaQuery, usePortal, useProvidedRefOrCreate, useStackState, useTabContext, validatePhoneNumber };
|
|
2736
2804
|
//# sourceMappingURL=index.esm.js.map
|