@dynamic-framework/ui-react 2.1.0 → 2.1.1

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * dynamic-framework 2.1.0
2
+ * dynamic-framework 2.1.1
3
3
  * bootstrap ~5.3.8
4
4
  * license https://github.com/dynamic-framework/dynamic-ui/blob/master/libraries/dynamic-ui-react/LICENSE.md
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * dynamic-framework 2.1.0
2
+ * dynamic-framework 2.1.1
3
3
  * bootstrap ~5.3.8
4
4
  * license https://github.com/dynamic-framework/dynamic-ui/blob/master/libraries/dynamic-ui-react/LICENSE.md
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * dynamic-framework 2.1.0
2
+ * dynamic-framework 2.1.1
3
3
  * bootstrap ~5.3.8
4
4
  * license https://github.com/dynamic-framework/dynamic-ui/blob/master/libraries/dynamic-ui-react/LICENSE.md
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * dynamic-framework 2.1.0
2
+ * dynamic-framework 2.1.1
3
3
  * bootstrap ~5.3.8
4
4
  * license https://github.com/dynamic-framework/dynamic-ui/blob/master/libraries/dynamic-ui-react/LICENSE.md
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * dynamic-framework 2.1.0
2
+ * dynamic-framework 2.1.1
3
3
  * bootstrap ~5.3.8
4
4
  * license https://github.com/dynamic-framework/dynamic-ui/blob/master/libraries/dynamic-ui-react/LICENSE.md
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * dynamic-framework 2.1.0
2
+ * dynamic-framework 2.1.1
3
3
  * bootstrap ~5.3.8
4
4
  * license https://github.com/dynamic-framework/dynamic-ui/blob/master/libraries/dynamic-ui-react/LICENSE.md
5
5
  */
package/dist/index.esm.js CHANGED
@@ -1107,6 +1107,9 @@ function DCollapse({ id, className, style, Component, hasSeparator = false, defa
1107
1107
  return next;
1108
1108
  });
1109
1109
  };
1110
+ useEffect(() => {
1111
+ setCollapsed(defaultCollapsed);
1112
+ }, [defaultCollapsed]);
1110
1113
  const { iconMap: { chevronDown, chevronUp, }, } = useDContext();
1111
1114
  const iconOpen = useMemo(() => iconOpenProp || chevronDown, [chevronDown, iconOpenProp]);
1112
1115
  const iconClose = useMemo(() => iconCloseProp || chevronUp, [chevronUp, iconCloseProp]);
@@ -1837,7 +1840,7 @@ function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, i
1837
1840
  setInternalIsChecked(value);
1838
1841
  onChange === null || onChange === void 0 ? void 0 : onChange(value);
1839
1842
  }, [onChange]);
1840
- return (jsxs("div", Object.assign({ className: classNames('form-check', className) }, dataAttributes, { children: [jsx("input", { id: id, name: name, onChange: readonly ? () => false : changeHandler, className: classNames('form-check-input', {
1843
+ return (jsxs("div", Object.assign({ className: classNames('form-check form-switch', className) }, dataAttributes, { children: [jsx("input", { id: id, name: name, onChange: readonly ? () => false : changeHandler, className: classNames('form-check-input', {
1841
1844
  'is-invalid': invalid,
1842
1845
  'is-valid': valid,
1843
1846
  }, inputClassName), style: style, type: "checkbox", role: "switch", checked: internalIsChecked, disabled: disabled, "aria-label": ariaLabel }), label && (jsx("label", { className: "form-check-label", htmlFor: id, children: label }))] })));
@@ -2588,5 +2591,74 @@ function DVoucher({ amount, amountDetails, icon = 'CircleCheckBig', color = 'suc
2588
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" })] })] }) }));
2589
2592
  }
2590
2593
 
2591
- 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, 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 };
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 };
2592
2664
  //# sourceMappingURL=index.esm.js.map