@dynamic-framework/ui-react 2.0.0-dev.20 → 2.0.0-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/dynamic-ui-non-root.css +1 -1
- package/dist/css/dynamic-ui-non-root.min.css +1 -1
- package/dist/css/dynamic-ui-root.css +1 -1
- package/dist/css/dynamic-ui-root.min.css +1 -1
- package/dist/css/dynamic-ui.css +1 -1
- package/dist/css/dynamic-ui.min.css +1 -1
- package/dist/index.esm.js +70 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -1
- package/dist/types/components/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2612,6 +2612,75 @@ function DVoucher({ amount, amountDetails, icon = 'CircleCheckBig', color = 'suc
|
|
|
2612
2612
|
}, children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: "d-voucher-header", children: [jsxRuntime.jsx(DIcon, { icon: icon, color: color }), jsxRuntime.jsxs("div", { className: "text-center", children: [jsxRuntime.jsx("h3", { className: "mb-2", children: title }), jsxRuntime.jsx("p", { className: "m-0", children: message })] })] }), amount && (jsxRuntime.jsxs("div", { className: "d-voucher-amount", children: [jsxRuntime.jsx("div", { className: classNames('text-center fw-bold fs-3', amountDetails ? 'mb-1' : 'm-0'), children: amount }), amountDetails] })), jsxRuntime.jsx("hr", { className: "my-4" }), children, jsxRuntime.jsx("hr", { className: "my-4" }), jsxRuntime.jsxs("div", { className: "d-voucher-footer", children: [jsxRuntime.jsx(DButton, { onClick: handleShare, iconStart: "Share2", text: shareText, variant: "outline", size: "sm" }), jsxRuntime.jsx(DButton, { onClick: handleDownload, iconStart: "Download", text: downloadText, variant: "outline", size: "sm" })] })] }) }));
|
|
2613
2613
|
}
|
|
2614
2614
|
|
|
2615
|
+
function useCountdown(seconds) {
|
|
2616
|
+
const [secondsLeft, setSecondsLeft] = React.useState(seconds);
|
|
2617
|
+
const [isActive, setIsActive] = React.useState(true);
|
|
2618
|
+
const resetCountdown = React.useCallback((newSeconds = seconds) => {
|
|
2619
|
+
setIsActive(false);
|
|
2620
|
+
setSecondsLeft(newSeconds);
|
|
2621
|
+
}, [seconds]);
|
|
2622
|
+
const restartCountdown = React.useCallback(() => {
|
|
2623
|
+
resetCountdown(seconds);
|
|
2624
|
+
setIsActive(true);
|
|
2625
|
+
}, [resetCountdown, seconds]);
|
|
2626
|
+
React.useEffect(() => {
|
|
2627
|
+
if (!isActive) {
|
|
2628
|
+
return () => { };
|
|
2629
|
+
}
|
|
2630
|
+
const interval = setInterval(() => {
|
|
2631
|
+
setSecondsLeft((prevSeconds) => {
|
|
2632
|
+
const newSeconds = prevSeconds - 1;
|
|
2633
|
+
if (newSeconds <= 0) {
|
|
2634
|
+
clearInterval(interval);
|
|
2635
|
+
setIsActive(false);
|
|
2636
|
+
return 0;
|
|
2637
|
+
}
|
|
2638
|
+
return newSeconds;
|
|
2639
|
+
});
|
|
2640
|
+
}, 1000);
|
|
2641
|
+
return () => clearInterval(interval);
|
|
2642
|
+
}, [isActive]);
|
|
2643
|
+
return { secondsLeft, restartCountdown };
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
const defaultMessage = (secs) => (secs > 0
|
|
2647
|
+
? `Didn't get any code? Resend in: ${secs}s`
|
|
2648
|
+
: "Didn't get any code?");
|
|
2649
|
+
function OtpCountdown({ seconds, resendText, message, }) {
|
|
2650
|
+
const { secondsLeft, restartCountdown } = useCountdown(seconds);
|
|
2651
|
+
return (jsxRuntime.jsxs("div", { className: "d-flex gap-2 align-items-center", children: [jsxRuntime.jsx("p", { className: "mb-0", children: message ? message(secondsLeft) : defaultMessage(secondsLeft) }), jsxRuntime.jsx(DButton, { text: resendText, variant: "link", disabled: secondsLeft > 0, onClick: restartCountdown })] }));
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
const TEXT_PROPS = {
|
|
2655
|
+
resend: 'Resend',
|
|
2656
|
+
resendText: 'Resend code',
|
|
2657
|
+
submit: 'Authorize and continue',
|
|
2658
|
+
title: 'We will send you a 6-digit code to your associated phone number so you can continue with your request.',
|
|
2659
|
+
contact: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { children: "Problems with your digital token? Contact us" }), ' ', jsxRuntime.jsx("a", { href: "https://www.modyo.com", className: "link-primary text-nowrap", target: "_blank", rel: "noreferrer", children: "Contact us" })] })),
|
|
2660
|
+
};
|
|
2661
|
+
function DOtp({ className, action, isLoading, otpSize = 6, texts = TEXT_PROPS, seconds = 15, }) {
|
|
2662
|
+
const [otp, setOtp] = React.useState('');
|
|
2663
|
+
const [invalid, setInvalid] = React.useState(false);
|
|
2664
|
+
const handler = React.useCallback(async () => {
|
|
2665
|
+
if (otp.length < otpSize) {
|
|
2666
|
+
setInvalid(true);
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
setInvalid(false);
|
|
2670
|
+
await action();
|
|
2671
|
+
}, [
|
|
2672
|
+
otp.length,
|
|
2673
|
+
action,
|
|
2674
|
+
otpSize,
|
|
2675
|
+
]);
|
|
2676
|
+
return (jsxRuntime.jsxs("div", { className: className, children: [jsxRuntime.jsx("p", { children: texts.title }), jsxRuntime.jsxs("div", { className: "d-flex flex-column gap-6 pb-4 px-3", children: [jsxRuntime.jsxs("div", { className: "d-flex flex-column gap-6", children: [jsxRuntime.jsx(DInputPin, { className: "modal-otp-pin", characters: otpSize, onChange: (e) => setOtp(e), invalid: invalid && otp.length < otpSize, placeholder: "0" }), jsxRuntime.jsx(OtpCountdown, { seconds: seconds, resendText: texts.resend })] }), jsxRuntime.jsx("hr", { className: "m-0" }), jsxRuntime.jsxs("div", { className: "d-flex flex-column flex-lg-row gap-4 align-items-center", children: [jsxRuntime.jsx(DButton, { text: texts.submit, onClick: () => {
|
|
2677
|
+
handler().catch((err) => {
|
|
2678
|
+
// eslint-disable-next-line no-console
|
|
2679
|
+
console.error('Error in DOtp action:', err);
|
|
2680
|
+
});
|
|
2681
|
+
}, loading: isLoading }), jsxRuntime.jsx("p", { className: "small ms-lg-auto mb-0", children: texts.contact })] })] })] }));
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2615
2684
|
exports.DAlert = DAlert;
|
|
2616
2685
|
exports.DAvatar = DAvatar;
|
|
2617
2686
|
exports.DBadge = DBadge;
|
|
@@ -2658,6 +2727,7 @@ exports.DOffcanvas = DOffcanvas;
|
|
|
2658
2727
|
exports.DOffcanvasBody = DOffcanvasBody;
|
|
2659
2728
|
exports.DOffcanvasFooter = DOffcanvasFooter;
|
|
2660
2729
|
exports.DOffcanvasHeader = DOffcanvasHeader;
|
|
2730
|
+
exports.DOtp = DOtp;
|
|
2661
2731
|
exports.DPaginator = DPaginator;
|
|
2662
2732
|
exports.DPasswordStrengthMeter = DPasswordStrengthMeter;
|
|
2663
2733
|
exports.DPopover = DPopover;
|