@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.js
CHANGED
|
@@ -13,12 +13,13 @@ var currency = require('currency.js');
|
|
|
13
13
|
var DatePicker = require('react-datepicker');
|
|
14
14
|
var dateFns = require('date-fns');
|
|
15
15
|
var Select = require('react-select');
|
|
16
|
+
var reactErrorBoundary = require('react-error-boundary');
|
|
16
17
|
var mask = require('@react-input/mask');
|
|
18
|
+
var reactInternationalPhone = require('react-international-phone');
|
|
19
|
+
var googleLibphonenumber = require('google-libphonenumber');
|
|
17
20
|
var ResponsivePagination = require('react-responsive-pagination');
|
|
18
21
|
var react = require('@floating-ui/react');
|
|
19
22
|
var reactHotToast = require('react-hot-toast');
|
|
20
|
-
var reactInternationalPhone = require('react-international-phone');
|
|
21
|
-
var googleLibphonenumber = require('google-libphonenumber');
|
|
22
23
|
var html2canvas = require('html2canvas');
|
|
23
24
|
var i18n = require('i18next');
|
|
24
25
|
var reactI18next = require('react-i18next');
|
|
@@ -431,21 +432,6 @@ function DIconBase({ icon, color, style, className, size, useListenerSize = fals
|
|
|
431
432
|
const icons = LucideIcons__namespace;
|
|
432
433
|
return icons[icon] || null;
|
|
433
434
|
}, [icon, useMaterialIcons]);
|
|
434
|
-
const colorStyle = React.useMemo(() => {
|
|
435
|
-
if (color) {
|
|
436
|
-
return { [`--${PREFIX_BS}icon-component-color`]: `var(--${PREFIX_BS}${color})` };
|
|
437
|
-
}
|
|
438
|
-
return {};
|
|
439
|
-
}, [color]);
|
|
440
|
-
const backgroundStyle = React.useMemo(() => {
|
|
441
|
-
if (hasCircle) {
|
|
442
|
-
if (color) {
|
|
443
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}${color}-rgb), 0.1)` };
|
|
444
|
-
}
|
|
445
|
-
return { [`--${PREFIX_BS}icon-component-bg-color`]: `rgba(var(--${PREFIX_BS}body-color-rgb), 0.1)` };
|
|
446
|
-
}
|
|
447
|
-
return {};
|
|
448
|
-
}, [hasCircle, color]);
|
|
449
435
|
const { responsivePropValue } = useResponsiveProp(useListenerSize);
|
|
450
436
|
const resolvedSize = React.useMemo(() => {
|
|
451
437
|
if (!size)
|
|
@@ -454,8 +440,8 @@ function DIconBase({ icon, color, style, className, size, useListenerSize = fals
|
|
|
454
440
|
return size;
|
|
455
441
|
return responsivePropValue(size);
|
|
456
442
|
}, [responsivePropValue, size]);
|
|
457
|
-
const generateStyleVariables = React.useMemo(() => (Object.assign(Object.assign(Object.assign(
|
|
458
|
-
const generateClasses = React.useMemo(() => (Object.assign({ 'd-icon': true }, className && { [className]: true })), [className]);
|
|
443
|
+
const generateStyleVariables = React.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]);
|
|
444
|
+
const generateClasses = React.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]);
|
|
459
445
|
const iconSize = React.useMemo(() => {
|
|
460
446
|
if (resolvedSize) {
|
|
461
447
|
const numSize = parseInt(resolvedSize, 10);
|
|
@@ -510,14 +496,24 @@ function DAvatar({ id, size, image, name: nameProp, useNameAsInitials = false, c
|
|
|
510
496
|
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames(generateClasses, className), style: style, id: id }, dataAttributes, { children: [image && jsxRuntime.jsx("img", { src: image, alt: nameProp, className: "d-avatar-img" }), (name && !image) && jsxRuntime.jsx("span", { className: "d-avatar-name", children: name })] })));
|
|
511
497
|
}
|
|
512
498
|
|
|
513
|
-
function DBadge(
|
|
499
|
+
function DBadge(props) {
|
|
500
|
+
const { text, soft = false, color = 'primary', id, rounded, className, size, style, iconStart, iconEnd, iconMaterialStyle, iconFamilyClass, iconFamilyPrefix, dataAttributes, } = props;
|
|
501
|
+
// Responsive size resolution using useResponsiveProp
|
|
502
|
+
const { responsivePropValue } = useResponsiveProp(true);
|
|
503
|
+
const resolvedSize = React.useMemo(() => {
|
|
504
|
+
if (!size)
|
|
505
|
+
return undefined;
|
|
506
|
+
if (typeof size === 'string')
|
|
507
|
+
return size;
|
|
508
|
+
return responsivePropValue(size);
|
|
509
|
+
}, [responsivePropValue, size]);
|
|
514
510
|
const generateClasses = React.useMemo(() => ({
|
|
515
511
|
badge: true,
|
|
516
512
|
[`badge-${color}`]: !!color && !soft,
|
|
517
513
|
[`badge-soft-${color}`]: !!color && soft,
|
|
518
514
|
'rounded-pill': !!rounded,
|
|
519
|
-
[`badge-${
|
|
520
|
-
}), [rounded, soft, color,
|
|
515
|
+
[`badge-${resolvedSize}`]: !!resolvedSize,
|
|
516
|
+
}), [rounded, soft, color, resolvedSize]);
|
|
521
517
|
return (jsxRuntime.jsxs("span", Object.assign({ className: classNames(generateClasses, className), style: style }, id && { id }, dataAttributes, { children: [iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsxRuntime.jsx("span", { children: text }), iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }))] })));
|
|
522
518
|
}
|
|
523
519
|
|
|
@@ -1022,7 +1018,16 @@ function DBoxFile(_a) {
|
|
|
1022
1018
|
}
|
|
1023
1019
|
|
|
1024
1020
|
const DButton = React.forwardRef((props, ref) => {
|
|
1025
|
-
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 = tslib.__rest(props, ["color", "size", "variant", "text", "children", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartMaterialStyle", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndMaterialStyle", "loading", "loadingText", "loadingAriaLabel", "disabled", "className", "style", "dataAttributes", "onClick", "type", "target", "rel"]);
|
|
1021
|
+
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 = tslib.__rest(props, ["color", "size", "variant", "text", "children", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartMaterialStyle", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndMaterialStyle", "loading", "loadingText", "loadingAriaLabel", "disabled", "className", "style", "dataAttributes", "onClick", "type", "target", "rel", "href"]);
|
|
1022
|
+
// Responsive size resolution using useResponsiveProp
|
|
1023
|
+
const { responsivePropValue } = useResponsiveProp(true);
|
|
1024
|
+
const resolvedSize = React.useMemo(() => {
|
|
1025
|
+
if (!size)
|
|
1026
|
+
return undefined;
|
|
1027
|
+
if (typeof size === 'string')
|
|
1028
|
+
return size;
|
|
1029
|
+
return responsivePropValue(size);
|
|
1030
|
+
}, [responsivePropValue, size]);
|
|
1026
1031
|
const [buttonWidth, setButtonWidth] = React.useState();
|
|
1027
1032
|
const buttonRef = React.useRef(null);
|
|
1028
1033
|
const isDisabled = React.useMemo(() => disabled || loading, [disabled, loading]);
|
|
@@ -1034,10 +1039,10 @@ const DButton = React.forwardRef((props, ref) => {
|
|
|
1034
1039
|
return {
|
|
1035
1040
|
btn: true,
|
|
1036
1041
|
[variantClass]: true,
|
|
1037
|
-
[`btn-${
|
|
1042
|
+
[`btn-${resolvedSize}`]: !!resolvedSize,
|
|
1038
1043
|
loading,
|
|
1039
1044
|
};
|
|
1040
|
-
}, [variant, color,
|
|
1045
|
+
}, [variant, color, loading, resolvedSize]);
|
|
1041
1046
|
const ariaLabel = React.useMemo(() => {
|
|
1042
1047
|
const ariaLabelProp = rest['aria-label'];
|
|
1043
1048
|
return loading
|
|
@@ -1059,8 +1064,8 @@ const DButton = React.forwardRef((props, ref) => {
|
|
|
1059
1064
|
}
|
|
1060
1065
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1061
1066
|
}, [content, iconEnd, iconStart]);
|
|
1062
|
-
if (
|
|
1063
|
-
return (jsxRuntime.jsxs("a", Object.assign({ href:
|
|
1067
|
+
if (href) {
|
|
1068
|
+
return (jsxRuntime.jsxs("a", Object.assign({ href: href, target: target, rel: rel, ref: (node) => {
|
|
1064
1069
|
buttonRef.current = node;
|
|
1065
1070
|
if (typeof ref === 'function')
|
|
1066
1071
|
ref(node);
|
|
@@ -2495,8 +2500,12 @@ ForwardedDInputPhone.displayName = 'DInputPhone';
|
|
|
2495
2500
|
|
|
2496
2501
|
const DEFAULT_IMAGE = 'https://cdn.modyo.cloud/uploads/06b434f7-b943-4f54-9543-84a904e189aa/original/Visa_Logo_1_.png';
|
|
2497
2502
|
const CHIP_IMAGE = 'https://cdn.modyo.cloud/uploads/4660ad00-e5d8-477e-8919-52b53d0a26fb/original/chip-debit-svgrepo-com_1_.png';
|
|
2503
|
+
const BRAND_LOGOS = {
|
|
2504
|
+
visa: DEFAULT_IMAGE,
|
|
2505
|
+
mastercard: 'https://cdn.modyo.cloud/uploads/f686b9aa-65ab-4369-9db3-89ceece84f29/original/mastercard.png',
|
|
2506
|
+
};
|
|
2498
2507
|
function DCreditCard({ brand = 'visa', name, number, holderText = 'Card Holder', logoImage, isChipVisible = true, className, isVertical = false, }) {
|
|
2499
|
-
return (jsxRuntime.jsxs("div", { className: classNames('d-credit-card
|
|
2508
|
+
return (jsxRuntime.jsxs("div", { className: classNames('d-credit-card', isVertical && 'is-vertical', className), children: [jsxRuntime.jsxs("div", { className: "d-credit-card-header", children: [jsxRuntime.jsx("img", { src: logoImage || BRAND_LOGOS[brand] || DEFAULT_IMAGE, alt: brand, className: "d-credit-card-logo", width: 100 }), isChipVisible && (jsxRuntime.jsx("div", { className: "d-credit-card-chip", children: jsxRuntime.jsx("img", { src: CHIP_IMAGE, alt: "chip", width: 30, className: "d-credit-card-chip-image" }) }))] }), jsxRuntime.jsxs("div", { className: "d-credit-card-details", children: [jsxRuntime.jsx("div", { className: "d-credit-card-number", children: number }), jsxRuntime.jsx("small", { className: "d-credit-card-holder-text", children: holderText }), jsxRuntime.jsx("span", { className: "d-credit-card-name", children: name })] })] }));
|
|
2500
2509
|
}
|
|
2501
2510
|
|
|
2502
2511
|
const getItemClass = (action) => {
|
|
@@ -2720,7 +2729,7 @@ const defaultMessage = (secs) => (secs > 0
|
|
|
2720
2729
|
: "Didn't get any code?");
|
|
2721
2730
|
function OtpCountdown({ seconds, resendText, message, }) {
|
|
2722
2731
|
const { secondsLeft, restartCountdown } = useCountdown(seconds);
|
|
2723
|
-
return (jsxRuntime.jsxs("div", { className: "d-flex gap-2 align-items-center", children: [jsxRuntime.jsx("p", { className: "mb-0", children: message ? message(secondsLeft) : defaultMessage(secondsLeft) }), jsxRuntime.jsx(DButton, { text: resendText, variant: "link", disabled: secondsLeft > 0, onClick: restartCountdown })] }));
|
|
2732
|
+
return (jsxRuntime.jsxs("div", { className: "d-flex gap-2 align-items-center", children: [jsxRuntime.jsx("p", { className: "mb-0 flex-1", children: message ? message(secondsLeft) : defaultMessage(secondsLeft) }), jsxRuntime.jsx(DButton, { text: resendText, variant: "link", className: "text-nowrap", disabled: secondsLeft > 0, onClick: restartCountdown })] }));
|
|
2724
2733
|
}
|
|
2725
2734
|
|
|
2726
2735
|
const TEXT_PROPS = {
|
|
@@ -2753,6 +2762,72 @@ function DOtp({ className, action, isLoading, otpSize = 6, texts = TEXT_PROPS, s
|
|
|
2753
2762
|
}, loading: isLoading }), jsxRuntime.jsx("p", { className: "small ms-lg-auto mb-0", children: texts.contact })] })] })] }));
|
|
2754
2763
|
}
|
|
2755
2764
|
|
|
2765
|
+
function DefaultErrorBoundary({ resetErrorBoundary }) {
|
|
2766
|
+
return (jsxRuntime.jsx(DAlert, { color: "danger", showClose: false, children: jsxRuntime.jsxs("div", { className: "d-flex align-items-center gap-2", children: [jsxRuntime.jsx("span", { children: "An unexpected error occurred." }), jsxRuntime.jsx(DButton, { color: "secondary", variant: "outline", size: "sm", onClick: resetErrorBoundary, children: "Retry" })] }) }));
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
function DErrorBoundary({ name, fallback, resetKeys, onReset, onError, children, }) {
|
|
2770
|
+
const handleError = React.useCallback((error, info) => {
|
|
2771
|
+
// eslint-disable-next-line no-console
|
|
2772
|
+
console.error(`[DErrorBoundary${name ? `:${name}` : ''}]`, reactErrorBoundary.getErrorMessage(error), info);
|
|
2773
|
+
onError === null || onError === void 0 ? void 0 : onError(error, info);
|
|
2774
|
+
}, [name, onError]);
|
|
2775
|
+
const FallbackRender = React.useCallback((props) => {
|
|
2776
|
+
if (fallback)
|
|
2777
|
+
return fallback(props);
|
|
2778
|
+
return (jsxRuntime.jsx(DefaultErrorBoundary, { resetErrorBoundary: props.resetErrorBoundary }));
|
|
2779
|
+
}, [fallback]);
|
|
2780
|
+
return (jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, { resetKeys: resetKeys, onReset: onReset, onError: handleError, fallbackRender: FallbackRender, children: children }));
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
function ErrorState({ message, onRetry, retryMessage = 'Retry', color = 'danger', }) {
|
|
2784
|
+
return (jsxRuntime.jsxs(DAlert, { color: color, className: "d-flex align-items-center gap-3", children: [jsxRuntime.jsx("div", { className: "flex-grow-1", children: jsxRuntime.jsx("p", { className: "mb-0", children: message !== null && message !== void 0 ? message : 'An unexpected error occurred.' }) }), onRetry && (jsxRuntime.jsx(DButton, { onClick: onRetry, text: retryMessage, variant: "outline", iconStart: "RefreshCw" }))] }));
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
function EmptyState({ message, icon = 'FileText', actionText, onAction, }) {
|
|
2788
|
+
return (jsxRuntime.jsxs("div", { className: "d-flex flex-column align-items-center justify-content-center p-5 text-center", children: [jsxRuntime.jsx(DIcon, { icon: icon, size: "3rem", className: "text-secondary mb-3" }), jsxRuntime.jsx("p", { className: "text-secondary mb-3", children: message !== null && message !== void 0 ? message : 'No data available.' }), actionText && onAction && (jsxRuntime.jsx(DButton, { onClick: onAction, text: actionText, variant: "outline" }))] }));
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
function LoadingState({ ariaLabel = 'Loading...', className }) {
|
|
2792
|
+
return (jsxRuntime.jsx("div", { className: `d-flex align-items-center justify-content-center p-4 ${className || ''}`.trim(), "aria-busy": "true", "aria-live": "polite", children: jsxRuntime.jsx("span", { className: "spinner-border", role: "status", "aria-label": ariaLabel }) }));
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
function render(renderable) {
|
|
2796
|
+
if (renderable === undefined)
|
|
2797
|
+
return null;
|
|
2798
|
+
return typeof renderable === 'function' ? renderable() : renderable;
|
|
2799
|
+
}
|
|
2800
|
+
function DDataStateWrapper({ isLoading, isError, data, onRetry, renderLoading, renderEmpty, renderError, children, }) {
|
|
2801
|
+
// 1. Loading
|
|
2802
|
+
if (isLoading) {
|
|
2803
|
+
if (renderLoading)
|
|
2804
|
+
return render(renderLoading);
|
|
2805
|
+
return jsxRuntime.jsx(LoadingState, {});
|
|
2806
|
+
}
|
|
2807
|
+
// 2. Error
|
|
2808
|
+
if (isError) {
|
|
2809
|
+
if (renderError)
|
|
2810
|
+
return render(renderError);
|
|
2811
|
+
return (jsxRuntime.jsx(ErrorState, { onRetry: onRetry }));
|
|
2812
|
+
}
|
|
2813
|
+
// 3. Empty
|
|
2814
|
+
if (!(data === null || data === void 0 ? void 0 : data.length)) {
|
|
2815
|
+
if (renderEmpty)
|
|
2816
|
+
return render(renderEmpty);
|
|
2817
|
+
return (jsxRuntime.jsx(EmptyState, {}));
|
|
2818
|
+
}
|
|
2819
|
+
// 4. Success
|
|
2820
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children(data) });
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
Object.defineProperty(exports, "getErrorMessage", {
|
|
2824
|
+
enumerable: true,
|
|
2825
|
+
get: function () { return reactErrorBoundary.getErrorMessage; }
|
|
2826
|
+
});
|
|
2827
|
+
Object.defineProperty(exports, "useErrorBoundary", {
|
|
2828
|
+
enumerable: true,
|
|
2829
|
+
get: function () { return reactErrorBoundary.useErrorBoundary; }
|
|
2830
|
+
});
|
|
2756
2831
|
exports.DAlert = DAlert;
|
|
2757
2832
|
exports.DAvatar = DAvatar;
|
|
2758
2833
|
exports.DBadge = DBadge;
|
|
@@ -2772,8 +2847,10 @@ exports.DContext = DContext;
|
|
|
2772
2847
|
exports.DContextProvider = DContextProvider;
|
|
2773
2848
|
exports.DCreditCard = DCreditCard;
|
|
2774
2849
|
exports.DCurrencyText = DCurrencyText;
|
|
2850
|
+
exports.DDataStateWrapper = DDataStateWrapper;
|
|
2775
2851
|
exports.DDatePicker = DDatePicker;
|
|
2776
2852
|
exports.DDropdown = DDropdown;
|
|
2853
|
+
exports.DErrorBoundary = DErrorBoundary;
|
|
2777
2854
|
exports.DIcon = DIcon;
|
|
2778
2855
|
exports.DIconBase = DIconBase;
|
|
2779
2856
|
exports.DInput = ForwardedDInput;
|