@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/css/dynamic-ui.css
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -2591,5 +2591,74 @@ function DVoucher({ amount, amountDetails, icon = 'CircleCheckBig', color = 'suc
|
|
|
2591
2591
|
}, children: jsxs("div", { children: [jsxs("div", { className: "d-voucher-header", children: [jsx(DIcon, { icon: icon, color: color }), jsxs("div", { className: "text-center", children: [jsx("h3", { className: "mb-2", children: title }), jsx("p", { className: "m-0", children: message })] })] }), amount && (jsxs("div", { className: "d-voucher-amount", children: [jsx("div", { className: classNames('text-center fw-bold fs-3', amountDetails ? 'mb-1' : 'm-0'), children: amount }), amountDetails] })), jsx("hr", { className: "my-4" }), children, jsx("hr", { className: "my-4" }), jsxs("div", { className: "d-voucher-footer", children: [jsx(DButton, { onClick: handleShare, iconStart: "Share2", text: shareText, variant: "outline", size: "sm" }), jsx(DButton, { onClick: handleDownload, iconStart: "Download", text: downloadText, variant: "outline", size: "sm" })] })] }) }));
|
|
2592
2592
|
}
|
|
2593
2593
|
|
|
2594
|
-
|
|
2594
|
+
function useCountdown(seconds) {
|
|
2595
|
+
const [secondsLeft, setSecondsLeft] = useState(seconds);
|
|
2596
|
+
const [isActive, setIsActive] = useState(true);
|
|
2597
|
+
const resetCountdown = useCallback((newSeconds = seconds) => {
|
|
2598
|
+
setIsActive(false);
|
|
2599
|
+
setSecondsLeft(newSeconds);
|
|
2600
|
+
}, [seconds]);
|
|
2601
|
+
const restartCountdown = useCallback(() => {
|
|
2602
|
+
resetCountdown(seconds);
|
|
2603
|
+
setIsActive(true);
|
|
2604
|
+
}, [resetCountdown, seconds]);
|
|
2605
|
+
useEffect(() => {
|
|
2606
|
+
if (!isActive) {
|
|
2607
|
+
return () => { };
|
|
2608
|
+
}
|
|
2609
|
+
const interval = setInterval(() => {
|
|
2610
|
+
setSecondsLeft((prevSeconds) => {
|
|
2611
|
+
const newSeconds = prevSeconds - 1;
|
|
2612
|
+
if (newSeconds <= 0) {
|
|
2613
|
+
clearInterval(interval);
|
|
2614
|
+
setIsActive(false);
|
|
2615
|
+
return 0;
|
|
2616
|
+
}
|
|
2617
|
+
return newSeconds;
|
|
2618
|
+
});
|
|
2619
|
+
}, 1000);
|
|
2620
|
+
return () => clearInterval(interval);
|
|
2621
|
+
}, [isActive]);
|
|
2622
|
+
return { secondsLeft, restartCountdown };
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
const defaultMessage = (secs) => (secs > 0
|
|
2626
|
+
? `Didn't get any code? Resend in: ${secs}s`
|
|
2627
|
+
: "Didn't get any code?");
|
|
2628
|
+
function OtpCountdown({ seconds, resendText, message, }) {
|
|
2629
|
+
const { secondsLeft, restartCountdown } = useCountdown(seconds);
|
|
2630
|
+
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 })] }));
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
const TEXT_PROPS = {
|
|
2634
|
+
resend: 'Resend',
|
|
2635
|
+
resendText: 'Resend code',
|
|
2636
|
+
submit: 'Authorize and continue',
|
|
2637
|
+
title: 'We will send you a 6-digit code to your associated phone number so you can continue with your request.',
|
|
2638
|
+
contact: (jsxs(Fragment, { children: [jsx("span", { children: "Problems with your digital token? Contact us" }), ' ', jsx("a", { href: "https://www.modyo.com", className: "link-primary text-nowrap", target: "_blank", rel: "noreferrer", children: "Contact us" })] })),
|
|
2639
|
+
};
|
|
2640
|
+
function DOtp({ className, action, isLoading, otpSize = 6, texts = TEXT_PROPS, seconds = 15, }) {
|
|
2641
|
+
const [otp, setOtp] = useState('');
|
|
2642
|
+
const [invalid, setInvalid] = useState(false);
|
|
2643
|
+
const handler = useCallback(async () => {
|
|
2644
|
+
if (otp.length < otpSize) {
|
|
2645
|
+
setInvalid(true);
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2648
|
+
setInvalid(false);
|
|
2649
|
+
await action();
|
|
2650
|
+
}, [
|
|
2651
|
+
otp.length,
|
|
2652
|
+
action,
|
|
2653
|
+
otpSize,
|
|
2654
|
+
]);
|
|
2655
|
+
return (jsxs("div", { className: className, children: [jsx("p", { children: texts.title }), jsxs("div", { className: "d-flex flex-column gap-6 pb-4 px-3", children: [jsxs("div", { className: "d-flex flex-column gap-6", children: [jsx(DInputPin, { className: "modal-otp-pin", characters: otpSize, onChange: (e) => setOtp(e), invalid: invalid && otp.length < otpSize, placeholder: "0" }), jsx(OtpCountdown, { seconds: seconds, resendText: texts.resend })] }), jsx("hr", { className: "m-0" }), jsxs("div", { className: "d-flex flex-column flex-lg-row gap-4 align-items-center", children: [jsx(DButton, { text: texts.submit, onClick: () => {
|
|
2656
|
+
handler().catch((err) => {
|
|
2657
|
+
// eslint-disable-next-line no-console
|
|
2658
|
+
console.error('Error in DOtp action:', err);
|
|
2659
|
+
});
|
|
2660
|
+
}, loading: isLoading }), jsx("p", { className: "small ms-lg-auto mb-0", children: texts.contact })] })] })] }));
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
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, DDatePicker, DDropdown, 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 };
|
|
2595
2664
|
//# sourceMappingURL=index.esm.js.map
|