@opexa/portal-components 0.0.221 → 0.0.223

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.
Files changed (119) hide show
  1. package/dist/client/hooks/useCamera.d.ts +36 -0
  2. package/dist/client/hooks/useCamera.js +174 -0
  3. package/dist/client/hooks/useClaimCashbackBonusMutation.js +1 -1
  4. package/dist/components/Bonuses/Bonuses.client.js +6 -0
  5. package/dist/components/CashbackBonus/CashbackBonus.client.d.ts +2 -0
  6. package/dist/components/CashbackBonus/CashbackBonus.client.js +9 -0
  7. package/dist/components/CashbackBonus/CashbackBonus.d.ts +10 -0
  8. package/dist/components/CashbackBonus/CashbackBonus.js +5 -0
  9. package/dist/components/CashbackBonus/index.d.ts +1 -0
  10. package/dist/components/CashbackBonus/index.js +1 -0
  11. package/dist/components/DepositWithdrawal/Deposit/LibanganDeposit/LibanganDeposit.js +1 -0
  12. package/dist/components/DepositWithdrawal/DepositWithdrawal.lazy.d.ts +1 -0
  13. package/dist/components/DepositWithdrawal/PaymentMethods.js +8 -1
  14. package/dist/components/Empty.d.ts +1 -2
  15. package/dist/components/GamesSearch/GamesSearch.d.ts +6 -1
  16. package/dist/components/GamesSearch/GamesSearch.js +13 -8
  17. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.js +2 -2
  18. package/dist/components/Jackpots/JackpotsList/JackpotsListItemDesktop.js +2 -2
  19. package/dist/components/Jackpots/JackpotsList/JackpotsListItemMobile.js +2 -2
  20. package/dist/components/KYC/Header.js +4 -2
  21. package/dist/components/KYC/KYCReminder.lazy.js +1 -1
  22. package/dist/components/KYC/Step1.js +3 -2
  23. package/dist/components/KYC/Step2.js +3 -2
  24. package/dist/components/KYC/Step3.js +4 -2
  25. package/dist/components/KYC/Step4.js +3 -2
  26. package/dist/components/KYC/backup/KYCContext.d.ts +5 -1
  27. package/dist/components/KYC/loadModels.d.ts +1 -0
  28. package/dist/components/KYC/loadModels.js +9 -0
  29. package/dist/components/Messages/Message.js +2 -3
  30. package/dist/components/Messages/MessageContext.d.ts +5 -1
  31. package/dist/components/Messages/MessagePopup.js +2 -3
  32. package/dist/components/Promo/PromoContent.d.ts +2 -0
  33. package/dist/components/Promo/PromoContent.js +9 -0
  34. package/dist/components/Promos/PromoCarousel.d.ts +2 -0
  35. package/dist/components/Promos/PromoCarousel.js +41 -0
  36. package/dist/components/Promos/PromoGrid.d.ts +2 -0
  37. package/dist/components/Promos/PromoGrid.js +12 -0
  38. package/dist/components/Promos/PromoItem.d.ts +7 -0
  39. package/dist/components/Promos/PromoItem.js +10 -0
  40. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +1 -1
  41. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +10 -5
  42. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +4 -3
  43. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +1 -1
  44. package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +1 -1
  45. package/dist/components/Quests/WageringQuest/WageringQuest.js +3 -2
  46. package/dist/components/Quests/WageringQuest/WageringQuestModal.js +4 -3
  47. package/dist/components/SignUp/SignUpForm.js +6 -1
  48. package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.js +1 -1
  49. package/dist/components/TransactionRecords/DepositRecordsTable.js +1 -1
  50. package/dist/components/shared/IdDocumentField.d.ts +11 -3
  51. package/dist/components/shared/IdDocumentField.js +106 -13
  52. package/dist/components/shared/SelfieField.d.ts +11 -3
  53. package/dist/components/shared/SelfieField.js +98 -9
  54. package/dist/constants/BranchCode.d.ts +4 -0
  55. package/dist/constants/BranchCode.js +42 -0
  56. package/dist/constants/endpoints.d.ts +10 -0
  57. package/dist/constants/endpoints.js +41 -0
  58. package/dist/constants/gameProviders.d.ts +1 -2
  59. package/dist/constants/gameProviders.js +6 -0
  60. package/dist/constants/gameTypes.d.ts +1 -2
  61. package/dist/constants/headerKeys.d.ts +1 -0
  62. package/dist/constants/headerKeys.js +1 -0
  63. package/dist/constants/secretQuestions.d.ts +1 -1
  64. package/dist/icons/CameraOffIcon.d.ts +2 -0
  65. package/dist/icons/CameraOffIcon.js +4 -0
  66. package/dist/icons/RefreshCcw01Icon.d.ts +2 -0
  67. package/dist/icons/RefreshCcw01Icon.js +4 -0
  68. package/dist/icons/Spinner02Icon.d.ts +2 -0
  69. package/dist/icons/Spinner02Icon.js +4 -0
  70. package/dist/images/responsible-gaming-yellow.png +0 -0
  71. package/dist/services/wallet.d.ts +2 -0
  72. package/dist/styles/theme.css +1 -1
  73. package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
  74. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +11 -11
  75. package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
  76. package/dist/ui/Badge/Badge.d.ts +12 -12
  77. package/dist/ui/Carousel/Carousel.d.ts +45 -45
  78. package/dist/ui/Carousel/carousel.recipe.d.ts +5 -5
  79. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  80. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  81. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  82. package/dist/ui/Collapsible/Collapsible.d.ts +32 -32
  83. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  84. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  85. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  86. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  87. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  88. package/dist/ui/Dialog/Dialog.d.ts +88 -88
  89. package/dist/ui/Dialog/dialog.recipe.d.ts +11 -11
  90. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  91. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  92. package/dist/ui/Menu/Menu.d.ts +144 -144
  93. package/dist/ui/Menu/menu.recipe.d.ts +20 -20
  94. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  95. package/dist/ui/Popover/Popover.d.ts +55 -55
  96. package/dist/ui/Popover/popover.recipe.d.ts +8 -8
  97. package/dist/ui/Presence.d.ts +1 -1
  98. package/dist/ui/Presence.js +1 -1
  99. package/dist/ui/Progress/Progress.d.ts +27 -27
  100. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  101. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  102. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  103. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  104. package/dist/ui/Select/Select.d.ts +45 -45
  105. package/dist/ui/Select/select.recipe.d.ts +3 -3
  106. package/dist/ui/Table/Table.d.ts +21 -21
  107. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  108. package/dist/ui/Table/table.recipe.d.ts +3 -3
  109. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  110. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  111. package/dist/utils/createErrorFromCode.d.ts +2 -0
  112. package/dist/utils/createErrorFromCode.js +11 -0
  113. package/dist/utils/validateFile.d.ts +28 -0
  114. package/dist/utils/validateFile.js +37 -0
  115. package/package.json +1 -1
  116. package/dist/utils/constants.d.ts +0 -2
  117. package/dist/utils/constants.js +0 -2
  118. package/dist/utils/isBetween3amAnd3pm.d.ts +0 -1
  119. package/dist/utils/isBetween3amAnd3pm.js +0 -5
@@ -7,7 +7,7 @@ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
7
  import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
8
8
  import { useMarkMessageAsReadMutation } from '../../client/hooks/useMarkMessageAsReadMutation.js';
9
9
  import { useMessageContext } from './MessageContext.js';
10
- import { getMessageIcon } from './utils.js';
10
+ import { MessageIcon } from './MessageIcon.js';
11
11
  export function Message() {
12
12
  const message = useMessageContext();
13
13
  const localeInfo = useLocaleInfo();
@@ -16,7 +16,6 @@ export function Message() {
16
16
  messages: ctx.messages,
17
17
  })));
18
18
  const markMessageAsReadMutation = useMarkMessageAsReadMutation();
19
- const Icon = getMessageIcon(message.icon);
20
19
  const handleViewMessage = async () => {
21
20
  globalStore.message.setData(message);
22
21
  globalStore.message.setOpen(true);
@@ -31,5 +30,5 @@ export function Message() {
31
30
  };
32
31
  return (_jsxs("div", { role: "button", tabIndex: 0, className: "border-border-secondary rounded-xs bg-bg-secondary flex h-auto flex-shrink-0 cursor-pointer flex-col border px-3.5 py-2.5", onClick: handleViewMessage, "aria-pressed": "false", children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx("p", { className: "text-text-tertiary-600 text-xs font-normal", children: format(new Date(message.dateTimeCreated), 'M/d/yyyy - h:mma', {
33
32
  in: tz(localeInfo.timezone),
34
- }) }), !message.markedAsRead && (_jsx("div", { className: "bg-utility-success-500 h-2.5 w-2.5 rounded-full" }))] }), _jsxs("div", { className: "mb-2 flex items-center space-x-2", children: [_jsx(Icon, { className: "text-brand-400" }), _jsx("p", { className: "text-text-primary-brand text-sm font-semibold", children: message.title })] }), _jsx("p", { className: "line-clamp-3 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: message.content } }), message.actions.length > 0 && (_jsx("div", { className: "mt-2 flex flex-wrap items-center justify-end gap-2", children: message.actions.map((action, index) => (_jsx(Link, { className: "border-button-secondary-border text-button-secondary-fg rounded-md border px-3 py-2 text-sm", href: action.url, onClick: handleActionClick, children: action.name }, index))) }))] }));
33
+ }) }), !message.markedAsRead && (_jsx("div", { className: "bg-utility-success-500 h-2.5 w-2.5 rounded-full" }))] }), _jsxs("div", { className: "mb-2 flex items-center space-x-2", children: [_jsx(MessageIcon, { type: message.icon, className: "text-brand-400 size-5" }), _jsx("p", { className: "text-text-primary-brand text-sm font-semibold", children: message.title })] }), _jsx("p", { className: "line-clamp-3 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: message.content } }), message.actions.length > 0 && (_jsx("div", { className: "mt-2 flex flex-wrap items-center justify-end gap-2", children: message.actions.map((action, index) => (_jsx(Link, { className: "border-button-secondary-border text-button-secondary-fg rounded-md border px-3 py-2 text-sm", href: action.url, onClick: handleActionClick, children: action.name }, index))) }))] }));
35
34
  }
@@ -1,2 +1,6 @@
1
1
  import type { Message } from '../../types';
2
- export declare const MessageContext: import("react").Context<Message>, useMessageContext: () => Message;
2
+ export declare const MessageContext: (props: {
3
+ value: Message;
4
+ } & {
5
+ children?: import("react").ReactNode | undefined;
6
+ }) => React.ReactNode, useMessageContext: () => Message;
@@ -6,13 +6,12 @@ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
6
6
  import { XIcon } from '../../icons/XIcon.js';
7
7
  import { Dialog } from '../../ui/Dialog/index.js';
8
8
  import { Portal } from '../../ui/Portal/index.js';
9
- import { getMessageIcon } from './utils.js';
9
+ import { MessageIcon } from './MessageIcon.js';
10
10
  export const MessagePopup = () => {
11
11
  const globalStore = useGlobalStore(useShallow((ctx) => ({ message: ctx.message })));
12
- const Icon = getMessageIcon(globalStore.message.data?.icon ?? 'MESSAGE');
13
12
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: globalStore.message.open, onOpenChange: ({ open }) => {
14
13
  globalStore.message.setOpen(open);
15
- }, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl px-xl pb-0 pt-5 shadow-xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "pb-6", children: [_jsx("div", { className: "bg-bg-brand-secondary mx-auto w-fit rounded-full p-3", children: _jsx(Icon, { className: "text-text-brand", height: "24", width: "24" }) }), _jsx("p", { className: "text-text-primary-brand mt-lg text-center text-lg font-semibold leading-tight", children: globalStore.message.data?.title }), _jsx("div", { className: "text-shadow-text-secondary-700 mt-xs text-center text-sm font-normal leading-tight", dangerouslySetInnerHTML: {
14
+ }, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl px-xl pb-0 pt-5 shadow-xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "pb-6", children: [_jsx("div", { className: "bg-bg-brand-secondary mx-auto w-fit rounded-full p-3", children: _jsx(MessageIcon, { type: globalStore.message.data?.icon ?? 'INFO', className: "text-text-brand size-6" }) }), _jsx("p", { className: "text-text-primary-brand mt-lg text-center text-lg font-semibold leading-tight", children: globalStore.message.data?.title }), _jsx("div", { className: "text-shadow-text-secondary-700 mt-xs text-center text-sm font-normal leading-tight", dangerouslySetInnerHTML: {
16
15
  __html: globalStore.message.data?.content ?? '',
17
16
  } })] }), globalStore.message.data?.actions.length ? (_jsx("div", { className: "flex flex-col space-y-2 px-4 pb-8 pt-6 text-center", children: globalStore.message.data.actions.map((action, index) => (_jsx(Link, { className: "bg-button-primary-bg rounded-xs text-button-primary-fg w-full px-4 py-2.5 text-base font-semibold", href: action.url, onClick: () => {
18
17
  globalStore.message.setOpen(false);
@@ -0,0 +1,2 @@
1
+ import type { PromoProps } from './Promo';
2
+ export declare function PromoContent(props: PromoProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import Image from 'next/image';
4
+ import Link from 'next/link';
5
+ import { ChevronLeftIcon } from '../../icons/index.js';
6
+ import { Button, Prose } from '../../ui/index.js';
7
+ export function PromoContent(props) {
8
+ return (_jsxs("div", { className: props.className, children: [_jsxs(Link, { href: props.viewAllPromosUrl ?? '/promos', className: "text-button-tertiary-fg flex w-fit items-center gap-lg text-lg font-semibold", children: [_jsx(ChevronLeftIcon, { className: "size-6" }), "Back to all Promotions"] }), _jsx(Image, { src: "https://s3.ap-east-1.amazonaws.com/opexa-assets.opexasystem.com/assets/BSxIXEsa59_zzMAR27-ALLDAYREBATE06-STATIC-WEB-HB-1920x1080.png", alt: "", width: 1024, height: 600, className: "mt-xl h-auto w-full rounded-xl lg:mt-6" }), _jsx(Button, { className: "mt-xl lg:mt-6", children: "Deposit Now" }), _jsx("h1", { className: "mt-xl text-2xl font-semibold lg:mt-6 lg:text-3xl", children: "Welcome Bonus 100% up to $500 + 10 Free Spins" }), _jsx("p", { className: "text-text-secondary-700 mt-xl lg:mt-6", children: "Ends 5/26/2025, 1:59:59 AM" }), _jsxs(Prose, { className: "mt-2xl lg:mt-6", children: [_jsx("p", { children: "Mi tincidunt elit, id quisque ligula ac diam, amet. Vel etiam suspendisse morbi eleifend faucibus eget vestibulum felis. Dictum quis montes, sit sit. Tellus aliquam enim urna, etiam. Mauris posuere vulputate arcu amet, vitae nisi, tellus tincidunt. At feugiat sapien varius id." }), _jsx("p", { children: "Eget quis mi enim, leo lacinia pharetra, semper. Eget in volutpat mollis at volutpat lectus velit, sed auctor. Porttitor fames arcu quis fusce augue enim. Quis at habitant diam at. Suscipit tristique risus, at donec. In turpis vel et quam imperdiet. Ipsum molestie aliquet sodales id est ac volutpat." }), _jsx("p", { children: "Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus. Quis velit eget ut tortor tellus. Sed vel, congue felis elit erat nam nibh orci." }), _jsx("p", { children: "Dolor enim eu tortor urna sed duis nulla. Aliquam vestibulum, nulla odio nisl vitae. In aliquet pellentesque aenean hac vestibulum turpis mi bibendum diam. Tempor integer aliquam in vitae malesuada fringilla." }), _jsx("p", { children: "Elit nisi in eleifend sed nisi. Pulvinar at orci, proin imperdiet commodo consectetur convallis risus. Sed condimentum enim dignissim adipiscing faucibus consequat, urna. Viverra purus et erat auctor aliquam. Risus, volutpat vulputate posuere purus sit congue convallis aliquet. Arcu id augue ut feugiat donec porttitor neque. Mauris, neque ultricies eu vestibulum, bibendum quam lorem id. Dolor lacus, eget nunc lectus in tellus, pharetra, porttitor." }), _jsx("p", { children: "Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus. Quis velit eget ut tortor tellus. Sed vel, congue felis elit erat nam nibh orci." }), _jsx("h5", { children: "General Conditions:" }), _jsx("p", { children: "Mi tincidunt elit, id quisque ligula ac diam, amet. Vel etiam suspendisse morbi eleifend faucibus eget vestibulum felis. Dictum quis montes, sit sit. Tellus aliquam enim urna, etiam. Mauris posuere vulputate arcu amet, vitae nisi, tellus tincidunt. At feugiat sapien varius id." }), _jsx("p", { children: "Eget quis mi enim, leo lacinia pharetra, semper. Eget in volutpat mollis at volutpat lectus velit, sed auctor. Porttitor fames arcu quis fusce augue enim. Quis at habitant diam at. Suscipit tristique risus, at donec. In turpis vel et quam imperdiet. Ipsum molestie aliquet sodales id est ac volutpat." })] }), _jsxs(Prose, { className: "bg-bg-secondary mt-xl rounded-2xl p-2xl lg:mt-16 lg:p-4xl", children: [_jsx("h2", { children: "Conclusion" }), _jsx("p", { children: "Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse." }), _jsx("p", { children: "Nunc sed faucibus bibendum feugiat sed interdum. Ipsum egestas condimentum mi massa. In tincidunt pharetra consectetur sed duis facilisis metus. Etiam egestas in nec sed et. Quis lobortis at sit dictum eget nibh tortor commodo cursus." }), _jsx("p", { children: "Odio felis sagittis, morbi feugiat tortor vitae feugiat fusce aliquet. Nam elementum urna nisi aliquet erat dolor enim. Ornare id morbi eget ipsum. Aliquam senectus neque ut id eget consectetur dictum. Donec posuere pharetra odio consequat scelerisque et, nunc tortor." })] })] }));
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { PromosProps } from './Promos';
2
+ export declare function PromoCarousel(props: PromosProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import useEmblaCarousel, {} from 'embla-carousel-react';
4
+ import Link from 'next/link';
5
+ import { useCallback, useEffect, useState } from 'react';
6
+ import { twMerge } from 'tailwind-merge';
7
+ import { usePromosQuery } from '../../client/hooks/index.js';
8
+ import { ArrowLeftIcon, ArrowRightIcon, ChevronRightIcon, Gift01Icon, } from '../../icons/index.js';
9
+ import { Button } from '../../ui/index.js';
10
+ import { Empty } from '../Empty.js';
11
+ import { PromosItem } from './PromoItem.js';
12
+ export function PromoCarousel(props) {
13
+ const promosQuery = usePromosQuery({});
14
+ const promos = promosQuery.data || [];
15
+ const [emblaRef, emblaApi] = useEmblaCarousel({
16
+ align: 'start',
17
+ slidesToScroll: 1,
18
+ breakpoints: {
19
+ '(min-width: 1024px)': {
20
+ slidesToScroll: 3,
21
+ },
22
+ },
23
+ });
24
+ const [prevBtnDisabled, setPrevBtnDisabled] = useState(true);
25
+ const [nextBtnDisabled, setNextBtnDisabled] = useState(true);
26
+ const onPrevButtonClick = useCallback(() => emblaApi?.scrollPrev(), [emblaApi]);
27
+ const onNextButtonClick = useCallback(async () => {
28
+ emblaApi?.scrollNext();
29
+ }, [emblaApi]);
30
+ const onSelect = useCallback((emblaApi) => {
31
+ setPrevBtnDisabled(!emblaApi?.canScrollPrev());
32
+ setNextBtnDisabled(!emblaApi?.canScrollNext());
33
+ }, []);
34
+ useEffect(() => {
35
+ if (!emblaApi)
36
+ return;
37
+ onSelect(emblaApi);
38
+ emblaApi.on('reInit', onSelect).on('select', onSelect);
39
+ }, [emblaApi, onSelect]);
40
+ return (_jsxs("div", { className: props.className, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Promotions' }), _jsx("div", { className: "grow" }), _jsxs("div", { className: "flex items-center justify-center gap-xl", children: [_jsxs(Link, { href: props.viewAllUrl ?? '/promos', className: "text-button-tertiary-fg flex gap-sm text-sm font-semibold", children: ["See All", _jsx(ChevronRightIcon, { className: "size-5 lg:hidden" })] }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-r-none border-r-0", onClick: onPrevButtonClick, disabled: prevBtnDisabled, "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-l-none", onClick: onNextButtonClick, disabled: nextBtnDisabled, "aria-label": "Next", children: _jsx(ArrowRightIcon, { className: "size-5" }) })] })] })] }), promos.length <= 0 && (_jsx(Empty, { icon: Gift01Icon, title: "No Promos", message: "No promo is currently available.", className: "mt-8" })), promos.length >= 1 && (_jsx("div", { ref: emblaRef, className: "relative mt-lg lg:overflow-hidden", children: _jsx("div", { className: twMerge('grid auto-cols-[calc((100%-(0.375rem*2))/1)] grid-flow-col gap-sm lg:auto-cols-[calc((100%-(0.5rem*5))/3)] lg:gap-md'), children: promos.map((promo) => (_jsx(PromosItem, { promo: promo, shouldShowDescription: props.shouldShowDescription }, promo.id))) }) }))] }));
41
+ }
@@ -0,0 +1,2 @@
1
+ import type { PromosProps } from './Promos';
2
+ export declare function PromoGrid(props: PromosProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { twMerge } from 'tailwind-merge';
4
+ import { usePromosQuery } from '../../client/hooks/index.js';
5
+ import { Gift01Icon } from '../../icons/index.js';
6
+ import { Empty } from '../Empty.js';
7
+ import { PromosItem } from './PromoItem.js';
8
+ export function PromoGrid(props) {
9
+ const promosQuery = usePromosQuery({});
10
+ const promos = promosQuery.data || [];
11
+ return (_jsxs("div", { className: props.className, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Promos' }), _jsx("div", { className: "grow" })] }), promos.length <= 0 && (_jsx(Empty, { icon: Gift01Icon, title: "No Promos", message: "No promo is currently available.", className: "mt-lg" })), promos.length >= 1 && (_jsx("div", { className: "relative mt-lg lg:overflow-hidden", children: _jsx("div", { className: twMerge('grid grid-cols-1 gap-sm lg:grid-cols-3 lg:gap-md'), children: promos.map((promo) => (_jsx(PromosItem, { promo: promo, shouldShowDescription: props.shouldShowDescription }, promo.id))) }) }))] }));
12
+ }
@@ -0,0 +1,7 @@
1
+ import type { Promo } from '@opexa/portal-sdk-core';
2
+ interface PromosItemProps {
3
+ promo: Promo;
4
+ shouldShowDescription?: boolean;
5
+ }
6
+ export declare function PromosItem(props: PromosItemProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Image from 'next/image';
3
+ import { useRouter } from 'next/navigation';
4
+ import { twJoin } from 'tailwind-merge';
5
+ import { Button } from '../../ui/index.js';
6
+ export function PromosItem(props) {
7
+ const { promo } = props;
8
+ const router = useRouter();
9
+ return (_jsxs("div", { className: "border-border-primary bg-accent-50 relative flex h-full flex-col rounded-md border", children: [promo.banner.url && (_jsx(Image, { src: promo.banner.url, alt: promo.name, width: 1200, height: 500, priority: true, className: "aspect-[1200/500] w-full rounded-t-md object-cover" })), _jsxs("div", { className: "flex flex-grow flex-col p-4", children: [_jsx("p", { className: twJoin('w-full text-xl font-bold', props.shouldShowDescription ? 'text-start' : 'text-center'), children: promo.name }), props.shouldShowDescription && promo.description && (_jsx("p", { className: "text-gray-600 mb-2 line-clamp-2 w-full overflow-hidden text-start text-sm", dangerouslySetInnerHTML: { __html: promo.description } })), _jsx("div", { className: "mt-auto pt-4", children: _jsx(Button, { className: "w-full text-sm font-semibold", onClick: () => router.push(`/promos/${promo.id}`), children: "Get Bonus" }) })] })] }, promo.id));
10
+ }
@@ -1,4 +1,4 @@
1
- import type { Quest } from '@opexa/portal-sdk-core';
1
+ import type { Quest } from '../../../types';
2
2
  export declare function DailyCheckInQuest({ quest }: {
3
3
  quest: Quest;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -3,11 +3,16 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { addDays, isEqual, startOfDay } from 'date-fns';
4
4
  import { useState } from 'react';
5
5
  import { twMerge } from 'tailwind-merge';
6
- import { useCheckInDailyCheckInQuestMutation } from '../../../client/hooks/index.js';
7
- import { toaster } from '../../../client/utils/index.js';
8
- import { CalendarIcon, CheckIcon, ClockStopWatchIcon, InfoCircleIcon, } from '../../../icons/index.js';
9
- import { Badge, Button } from '../../../ui/index.js';
10
- import { getAvailableQuestsQueryKey, getQueryClient } from '../../../utils/index.js';
6
+ import { useCheckInDailyCheckInQuestMutation } from '../../../client/hooks/useCheckInDailyCheckInQuestMutation.js';
7
+ import { toaster } from '../../../client/utils/toaster.js';
8
+ import { CalendarIcon } from '../../../icons/CalendarIcon.js';
9
+ import { CheckIcon } from '../../../icons/CheckIcon.js';
10
+ import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
11
+ import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
12
+ import { Badge } from '../../../ui/Badge/index.js';
13
+ import { Button } from '../../../ui/Button/index.js';
14
+ import { getQueryClient } from '../../../utils/getQueryClient.js';
15
+ import { getAvailableQuestsQueryKey } from '../../../utils/queryKeys.js';
11
16
  import CountdownTimer from '../CountdownTimer.js';
12
17
  import { DailyCheckInQuestModal } from './DailyCheckInQuestModal.js';
13
18
  export function DailyCheckInQuest({ quest }) {
@@ -1,8 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Portal } from '@ark-ui/react';
4
- import { XIcon } from '../../../icons/index.js';
5
- import { Button, Dialog } from '../../../ui/index.js';
3
+ import { XIcon } from '../../../icons/XIcon.js';
4
+ import { Button } from '../../../ui/Button/index.js';
5
+ import { Dialog } from '../../../ui/Dialog/index.js';
6
+ import { Portal } from '../../../ui/Portal/index.js';
6
7
  export function DailyCheckInQuestModal(props) {
7
8
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: props.modalState.isOpen, onOpenChange: ({ open }) => props.modalState.setIsOpen(open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("p", { className: "text-text-primary-900 text-lg font-semibold", children: "Daily Check-In Rules" }), _jsxs("ul", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Earn rewards just for checking in each day!" }), _jsx("li", { children: "Stay consistent to unlock special rewards on the 3rd, 5th, and 7th day." }), _jsx("li", { children: "Missing a day will reset your streak, starting again from Day 1." }), _jsx("li", { children: "Each check-in unlocks the next one on the following day." }), _jsx("li", { children: "Successfully check in for 7 consecutive days to complete the quest and reset the cycle." })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => props.modalState.setIsOpen(false), children: "Ok" }) })] }) })] }) }));
8
9
  }
@@ -1,4 +1,4 @@
1
- import type { Quest } from '@opexa/portal-sdk-core';
1
+ import type { Quest } from '../../../types';
2
2
  export declare function OnboardingQuest(props: {
3
3
  quest: Quest;
4
4
  }): null;
@@ -1,4 +1,4 @@
1
- import type { Quest } from '@opexa/portal-sdk-core';
1
+ import type { Quest } from '../../../types';
2
2
  export declare function WageringQuest({ quest }: {
3
3
  quest: Quest;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,9 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useState } from 'react';
4
4
  import { twMerge } from 'tailwind-merge';
5
- import { ClockStopWatchIcon, InfoCircleIcon } from '../../../icons/index.js';
6
- import { Badge } from '../../../ui/index.js';
5
+ import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
6
+ import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
7
+ import { Badge } from '../../../ui/Badge/index.js';
7
8
  import CountdownTimer from '../CountdownTimer.js';
8
9
  import { WageringQuestModal } from './WageringQuestModal.js';
9
10
  export function WageringQuest({ quest }) {
@@ -1,8 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Portal } from '@ark-ui/react';
4
- import { XIcon } from '../../../icons/index.js';
5
- import { Button, Dialog } from '../../../ui/index.js';
3
+ import { XIcon } from '../../../icons/XIcon.js';
4
+ import { Button } from '../../../ui/Button/index.js';
5
+ import { Dialog } from '../../../ui/Dialog/index.js';
6
+ import { Portal } from '../../../ui/Portal/index.js';
6
7
  export function WageringQuestModal(props) {
7
8
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: props.modalState.isOpen, onOpenChange: ({ open }) => props.modalState.setIsOpen(open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("p", { className: "text-text-primary-900 text-lg font-semibold", children: props.questName }), _jsxs("ul", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Earn extra rewards just by playing Slots, every bet counts, win or lose!" }), _jsx("li", { children: "Reach the wagering requirement in bets to complete the quest and claim your reward." })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => props.modalState.setIsOpen(false), children: "Ok" }) })] }) })] }) }));
8
9
  }
@@ -46,6 +46,9 @@ export function SignUpForm() {
46
46
  itemToValue: (item) => item.code,
47
47
  itemToString: (item) => `${item.code} - ${item.name}`,
48
48
  });
49
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
50
+ kyc: ctx.kyc,
51
+ })));
49
52
  const [step, setStep] = useState(1);
50
53
  const dialog = useDialogContext();
51
54
  const search = useSearchParams();
@@ -192,6 +195,7 @@ export function SignUpForm() {
192
195
  mobileNumber: mobileNumberParser.format(mobileNumber),
193
196
  verificationCode: verificationCode.join(''),
194
197
  referralCode: search.get('referralCode') ?? undefined,
198
+ domain: search.get('domain') ?? undefined,
195
199
  btag: search.get('btag') ?? undefined,
196
200
  });
197
201
  const name = mobileNumberParser.format(mobileNumber);
@@ -238,6 +242,7 @@ export function SignUpForm() {
238
242
  dialog.setOpen(false);
239
243
  step1Form.reset();
240
244
  step2Form.reset();
245
+ globalStore.kyc.setOpen(true);
241
246
  setStep(1);
242
247
  }
243
248
  catch (error) {
@@ -251,7 +256,7 @@ export function SignUpForm() {
251
256
  o.field.onChange(details.value);
252
257
  }, onValueComplete: () => {
253
258
  form2Ref.current?.requestSubmit();
254
- }, blurOnComplete: true, readOnly: step2Form.formState.isSubmitting, type: "numeric", children: [_jsxs(PinInput.Control, { className: "grid-cols-[1fr_1fr_1fr_auto_1fr_1fr_1fr] items-center gap-md", children: [_jsx(PinInput.Input, { index: 0 }), _jsx(PinInput.Input, { index: 1 }), _jsx(PinInput.Input, { index: 2 }), _jsx("span", { className: "text-text-placeholder-subtle text-2xl font-medium", children: "\u2013" }), _jsx(PinInput.Input, { index: 3 }), _jsx(PinInput.Input, { index: 4 }), _jsx(PinInput.Input, { index: 5 })] }), _jsx(PinInput.HiddenInput, {})] }), _jsx(Field.ErrorText, { children: o.formState.errors.verificationCode?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: step2Form.formState.isSubmitting, children: "Verify" }), _jsxs("div", { className: "mt-3 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-secondary-700", children: "Didn't recieve the code?" }), _jsx("button", { type: "button", className: "text-button-secondary-fg font-semibold disabled:cursor-not-allowed disabled:opacity-75", disabled: cooldown.cooling, onClick: async () => {
259
+ }, children: [_jsxs(PinInput.Control, { className: "grid-cols-[1fr_1fr_1fr_auto_1fr_1fr_1fr] items-center gap-md", children: [_jsx(PinInput.Input, { index: 0 }), _jsx(PinInput.Input, { index: 1 }), _jsx(PinInput.Input, { index: 2 }), _jsx("span", { className: "text-text-placeholder-subtle text-2xl font-medium", children: "\u2013" }), _jsx(PinInput.Input, { index: 3 }), _jsx(PinInput.Input, { index: 4 }), _jsx(PinInput.Input, { index: 5 })] }), _jsx(PinInput.HiddenInput, {})] }), _jsx(Field.ErrorText, { children: o.formState.errors.verificationCode?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: step2Form.formState.isSubmitting, children: "Verify" }), _jsxs("div", { className: "mt-3 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-secondary-700", children: "Didn't recieve the code?" }), _jsx("button", { type: "button", className: "text-button-secondary-fg font-semibold disabled:cursor-not-allowed disabled:opacity-75", disabled: cooldown.cooling, onClick: async () => {
255
260
  await sendVerificationCodeMutation.mutateAsync({
256
261
  channel: 'SMS',
257
262
  recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
@@ -35,7 +35,7 @@ import { ChevronDownIcon } from '../../../icons/ChevronDownIcon.js';
35
35
  import { ChevronLeftIcon } from '../../../icons/ChevronLeftIcon.js';
36
36
  import { ChevronRightIcon } from '../../../icons/ChevronRightIcon.js';
37
37
  import pagcorLogo from '../../../images/pagcor.png';
38
- import responsibleGamingLogo from '../../../images/responsible-gaming.png';
38
+ import responsibleGamingLogo from '../../../images/responsible-gaming-yellow.png';
39
39
  import { ObjectType } from '../../../services/ObjectType.js';
40
40
  import { Button } from '../../../ui/Button/index.js';
41
41
  import { Checkbox } from '../../../ui/Checkbox/index.js';
@@ -85,7 +85,7 @@ export function DepositRecordsTable() {
85
85
  depositStatus: true,
86
86
  } }), rows.length <= 0 && (_jsx(Empty, { icon: loading ? SpinnerIcon : File02Icon, title: loading ? 'Just a moment' : 'No data', message: loading
87
87
  ? 'Fetching latest deposit records...'
88
- : 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-xl', 'border-y', 'border-border-secondary', 'bleed', 'lg:not-bleed', 'lg:mt-3xl', 'lg:w-full', 'lg:rounded-xl', 'lg:border-x'), children: [_jsx("div", { className: "border-border-secondary scrollbar-thumb:bg-bg-quaternary scrollbar-track:bg-transparent scrollbar:h-2 scrollbar-thumb:rounded-full overflow-hidden overflow-x-auto rounded-none border-b lg:rounded-t-xl", children: _jsxs(Table.Root, { className: "border-0", children: [_jsx(Table.Header, { children: _jsxs(Table.Row, { children: [_jsx(Table.Heading, { children: "Deposit No." }), _jsx(Table.Heading, { children: "Reference" }), _jsx(Table.Heading, { children: "Deposit Method" }), _jsx(Table.Heading, { children: "Applied Amount" }), _jsx(Table.Heading, { children: "Recieved Amount" }), _jsx(Table.Heading, { children: "Transaction Fee" }), _jsx(Table.Heading, { children: "Deposit Time" }), _jsx(Table.Heading, { children: "Recieved Time" }), _jsx(Table.Heading, { children: "Status" })] }) }), _jsx(Table.Body, { children: rows.map((data) => (_jsxs(Table.Row, { children: [_jsx(Table.Cell, { className: "!py-1", children: data.depositNumber }), _jsx(Table.Cell, { className: "!py-1", children: data.reference }), _jsx(Table.Cell, { className: "!py-1", children: capitalize(data.type, {
88
+ : 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-xl', 'border-y', 'border-border-secondary', 'bleed', 'lg:not-bleed', 'lg:mt-3xl', 'lg:w-full', 'lg:rounded-xl', 'lg:border-x'), children: [_jsx("div", { className: "border-border-secondary scrollbar-thumb:bg-bg-quaternary scrollbar-track:bg-transparent scrollbar:h-2 scrollbar-thumb:rounded-full overflow-hidden overflow-x-auto rounded-none border-b lg:rounded-t-xl", children: _jsxs(Table.Root, { className: "border-0", children: [_jsx(Table.Header, { children: _jsxs(Table.Row, { children: [_jsx(Table.Heading, { children: "Deposit No." }), _jsx(Table.Heading, { children: "Reference" }), _jsx(Table.Heading, { children: "Deposit Method" }), _jsx(Table.Heading, { children: "Applied Amount" }), _jsx(Table.Heading, { children: "Received Amount" }), _jsx(Table.Heading, { children: "Transaction Fee" }), _jsx(Table.Heading, { children: "Deposit Time" }), _jsx(Table.Heading, { children: "Received Time" }), _jsx(Table.Heading, { children: "Status" })] }) }), _jsx(Table.Body, { children: rows.map((data) => (_jsxs(Table.Row, { children: [_jsx(Table.Cell, { className: "!py-1", children: data.depositNumber }), _jsx(Table.Cell, { className: "!py-1", children: data.reference }), _jsx(Table.Cell, { className: "!py-1", children: capitalize(data.type, {
89
89
  delimiter: capitalize.delimiters.UNDERSCORE,
90
90
  }) }), _jsx(Table.Cell, { className: "!py-1", children: formatNumber(data.amount, {
91
91
  currency: localeInfo.currency.code,
@@ -1,9 +1,17 @@
1
- import type { CSSProperties } from 'react';
1
+ import { type CSSProperties, type Ref } from 'react';
2
+ import { type ValidateFileError } from '../../utils/validateFile';
2
3
  export interface IdDocumentFieldProps {
4
+ ref?: Ref<HTMLDivElement>;
5
+ id?: string;
6
+ style?: CSSProperties;
7
+ className?: string;
3
8
  value?: string;
4
9
  onChange?: (value: string) => void;
5
10
  defaultValue?: string;
6
- className?: string;
7
- style?: CSSProperties;
11
+ invalid?: boolean;
12
+ readOnly?: boolean;
13
+ disabled?: boolean;
14
+ required?: boolean;
15
+ onError?: (error: ValidateFileError) => void;
8
16
  }
9
17
  export declare function IdDocumentField(props: IdDocumentFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -1,24 +1,41 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useFieldContext } from '@ark-ui/react';
4
+ import Image from 'next/image';
5
+ import { useRef } from 'react';
3
6
  import { twMerge } from 'tailwind-merge';
7
+ import { useMediaQuery } from 'usehooks-ts';
8
+ import { useCamera } from '../../client/hooks/useCamera.js';
4
9
  import { useControllableState } from '../../client/hooks/useControllableState.js';
10
+ import { useDisclosure } from '../../client/hooks/useDisclosure.js';
5
11
  import { useFileQuery } from '../../client/hooks/useFileQuery.js';
6
12
  import { useUploadImageFileMutation } from '../../client/hooks/useUploadImageFileMutation.js';
7
13
  import { toaster } from '../../client/utils/toaster.js';
14
+ import { Camera01Icon } from '../../icons/Camera01Icon.js';
15
+ import { CameraOffIcon } from '../../icons/CameraOffIcon.js';
16
+ import { CheckCircleIcon } from '../../icons/CheckCircleIcon.js';
17
+ import { RefreshCcw01Icon } from '../../icons/RefreshCcw01Icon.js';
18
+ import { Spinner02Icon } from '../../icons/Spinner02Icon.js';
19
+ import { UploadCloud02Icon } from '../../icons/UploadCloud02Icon.js';
20
+ import { XIcon } from '../../icons/XIcon.js';
21
+ import { Button } from '../../ui/Button/index.js';
22
+ import { Dialog } from '../../ui/Dialog/index.js';
23
+ import { Portal } from '../../ui/Portal/index.js';
24
+ import { dataAttr } from '../../utils/dataAttr.js';
25
+ import { validateFile } from '../../utils/validateFile.js';
8
26
  export function IdDocumentField(props) {
27
+ const field = useFieldContext();
9
28
  const [value, setValue] = useControllableState({
10
29
  value: props.value,
11
30
  defaultValue: props.defaultValue ?? '',
12
31
  onChange: props.onChange,
13
32
  });
14
- const fileQuery = useFileQuery(value, {
15
- refetchInterval(ctx) {
16
- return !ctx.state.data || ctx.state.data.status === 'UPLOADING'
17
- ? 1000
18
- : false;
33
+ const query = useFileQuery(value, {
34
+ refetchInterval({ state }) {
35
+ return !state.data || state.data.status === 'UPLOADING' ? 1000 : false;
19
36
  },
20
37
  });
21
- const uploadImageFileMutation = useUploadImageFileMutation({
38
+ const mutation = useUploadImageFileMutation({
22
39
  onSuccess(id) {
23
40
  setValue(id);
24
41
  },
@@ -31,11 +48,87 @@ export function IdDocumentField(props) {
31
48
  description: error.message,
32
49
  });
33
50
  },
51
+ onSettled() {
52
+ if (inputRef.current) {
53
+ inputRef.current.value = '';
54
+ }
55
+ },
56
+ });
57
+ const inputRef = useRef(null);
58
+ const guideRef = useRef(null);
59
+ const desktop = useMediaQuery('(min-width: 1024px)');
60
+ const camera = useCamera({
61
+ video: {
62
+ facingMode: desktop ? 'user' : 'environment',
63
+ },
64
+ });
65
+ const disclosure = useDisclosure({
66
+ onOpenChange(open) {
67
+ if (open) {
68
+ camera.open();
69
+ }
70
+ },
34
71
  });
35
- return (_jsx("div", { className: twMerge('relative', props.className), style: props.style, children: _jsx("input", { type: "file", accept: "image/png,image/jpeg,image/jpg", onChange: (e) => {
36
- const file = e.target.files?.[0];
37
- if (file) {
38
- uploadImageFileMutation.mutate({ file });
39
- }
40
- }, className: "sr-only" }) }));
72
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: props.ref, id: props.id, style: props.style, className: twMerge('border-border-primary bg-bg-primary group relative aspect-[352/180] w-full shrink-0 rounded-xl border p-xl', props.className), onDragOver: (e) => e.preventDefault(), onDragEnter: (e) => e.preventDefault(), onDragLeave: (e) => e.preventDefault(), onDrop: (e) => {
73
+ e.preventDefault();
74
+ const file = e.dataTransfer.files?.[0];
75
+ if (!file)
76
+ return;
77
+ const error = validateFile(file);
78
+ if (error)
79
+ return props.onError?.(error);
80
+ mutation.mutate({ file });
81
+ }, "data-invalid": dataAttr(props.invalid ?? field?.invalid), "data-readonly": dataAttr(props.readOnly ?? field?.readOnly), "data-disabled": dataAttr(props.disabled ?? field?.disabled), "data-required": dataAttr(props.required ?? field?.required), "data-loading": dataAttr(query.isLoading || mutation.isPending), "aria-describedby": field?.ariaDescribedby, children: [_jsx("input", { id: field?.ids?.control, ref: inputRef, type: "file", accept: "image/png, image/jpeg", onChange: (e) => {
82
+ const file = e.target.files?.[0];
83
+ if (!file)
84
+ return;
85
+ const error = validateFile(file);
86
+ if (error)
87
+ return props.onError?.(error);
88
+ mutation.mutate({ file });
89
+ }, disabled: field?.disabled ||
90
+ props.disabled ||
91
+ query.isLoading ||
92
+ mutation.isPending, readOnly: field?.readOnly || props.readOnly, required: field?.required || props.required, className: "sr-only" }), !query.data?.url && (_jsxs("div", { className: "flex size-full flex-col justify-center", children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-placeholder-subtle size-4" }) }), _jsxs("h2", { className: "text-text-tertiary-600 mt-lg", children: [_jsxs("span", { className: "block text-center text-sm", children: [_jsx("button", { type: "button", onClick: () => {
93
+ inputRef.current?.click();
94
+ }, disabled: field?.disabled ||
95
+ field?.readOnly ||
96
+ props.disabled ||
97
+ props.readOnly ||
98
+ query.isLoading ||
99
+ mutation.isPending, "data-required": dataAttr(props.required ?? field?.required), "data-readonly": dataAttr(props.readOnly ?? field?.readOnly), "data-loading": dataAttr(query.isLoading || mutation.isPending), "data-invalid": dataAttr(props.invalid ?? field?.invalid), className: "text-button-secondary-fg font-semibold disabled:opacity-60", children: "Click to upload" }), ' ', "or drag and drop"] }), _jsx("span", { className: "mt-xs block text-center text-xs", children: "PNG, JPG or JPEG (max. 10mb)" }), _jsx("span", { className: "m-txs block text-center text-xs", children: "or" })] }), _jsx(Button, { size: "sm", variant: "outline", className: "mx-auto mt-md w-auto", onClick: () => {
100
+ disclosure.setOpen(true);
101
+ }, disabled: field?.disabled ||
102
+ field?.readOnly ||
103
+ props.disabled ||
104
+ props.readOnly ||
105
+ query.isLoading ||
106
+ mutation.isPending, "data-required": dataAttr(props.required ?? field?.required), "data-readonly": dataAttr(props.readOnly ?? field?.readOnly), "data-loading": dataAttr(query.isLoading || mutation.isPending), "data-invalid": dataAttr(props.invalid ?? field?.invalid), children: "Take a photo" })] })), query.data?.url && (_jsxs("div", { className: "relative", children: [_jsx(Image, { src: query.data.url, alt: "", width: 600, height: 378.08, unoptimized: true, className: "h-auto w-full rounded-md" }), _jsx("button", { type: "button", className: "backdrop-blur-xs absolute right-2 top-2 rounded-full bg-white/10 p-1", onClick: () => {
107
+ setValue('');
108
+ }, children: _jsx(XIcon, { className: "size-5" }) })] }))] }), _jsx(Dialog.Root, { open: disclosure.open, onOpenChange: (details) => {
109
+ disclosure.setOpen(details.open);
110
+ }, onExitComplete: camera.close, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center overflow-y-auto py-4", children: _jsxs(Dialog.Content, { className: "bg-bg-primary-alt mx-auto w-[calc(100dvw-1rem)] max-w-[calc(100dvw-1rem)] rounded-lg px-4 py-5 lg:w-[747px] lg:max-w-[747px] lg:px-3xl lg:py-4xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx(Dialog.Title, { className: "text-center font-semibold lg:text-xl", children: "Take a Picture of Your Front ID" }), _jsxs(Dialog.Description, { className: "text-text-tertiary-600 mt-md text-center text-xs lg:text-base", children: ["Make sure your ID is clearly visible, well-lit, and not blurry.", ' ', _jsx("br", { className: "hidden lg:block" }), "Avoid glare or reflections, and ensure all corners are within\u00A0the\u00A0frame."] }), _jsxs("div", { className: "relative mt-5 lg:mt-10 lg:px-3xl", children: [_jsxs("div", { className: twMerge('border-border-disabled relative w-full overflow-hidden rounded-md border bg-black lg:rounded-lg', !camera.data && !camera.error && !camera.loading
111
+ ? 'block'
112
+ : 'hidden'), children: [_jsx("video", { ...camera.videoProps }), _jsx("div", { ref: guideRef, className: "border-utility-warning-700 absolute left-1/2 top-1/2 aspect-[85.60/53.98] w-[calc(100%-1rem)] -translate-x-1/2 -translate-y-1/2 rounded-md border-2 border-dashed lg:w-[29.688rem]" })] }), camera.error && (_jsxs("div", { className: "border-border-disabled flex aspect-[85.60/53.98] flex-col items-center justify-center rounded-md border bg-black px-4 lg:rounded-lg", children: [_jsx(CameraOffIcon, { className: "text-text-placeholder-subtle size-10 text-center lg:size-12" }), _jsx("h2", { className: "mt-3 text-sm font-semibold lg:mt-4 lg:text-base", children: camera.error.name }), _jsx("p", { className: "text-text-tertiary-600 mt-0.5 text-center text-xs lg:mt-1 lg:text-sm", children: camera.error.message }), _jsx(Button, { size: "xs", variant: "outline", colorScheme: "gray", fullWidth: false, className: "mt-4 lg:mt-5", onClick: () => {
113
+ camera.reopen();
114
+ }, children: "Try again" })] })), camera.loading && (_jsx("div", { className: "border-border-disabled flex aspect-[85.60/53.98] flex-col items-center justify-center rounded-md border bg-black px-4 lg:rounded-lg", children: _jsx(Spinner02Icon, { className: "text-text-placeholder size-8" }) })), camera.data && (_jsx("div", { className: "border-border-disabled h-auto w-full overflow-hidden rounded-md border bg-black lg:rounded-lg", children: _jsx(Image, { src: camera.data.url, alt: "", width: 600, height: 378.08, unoptimized: true, className: "block h-auto w-full" }) }))] }), !camera.data && !camera.error && !camera.loading && (_jsx("div", { className: "mt-5 lg:mt-10", children: _jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto w-full px-xl lg:w-auto", onClick: () => {
115
+ const rect = guideRef.current?.getBoundingClientRect();
116
+ const crop = !rect
117
+ ? undefined
118
+ : {
119
+ y: rect.y,
120
+ x: rect.x,
121
+ width: rect.width,
122
+ height: rect.height,
123
+ };
124
+ camera.snap({ crop });
125
+ }, children: [_jsx(Camera01Icon, { className: "size-5" }), "Capture"] }) })), camera.data && (_jsxs("div", { className: "mt-5 flex gap-3 lg:mt-10", children: [_jsxs(Button, { onClick: () => {
126
+ const file = camera.data?.file;
127
+ if (!file)
128
+ return;
129
+ mutation.mutate({ file });
130
+ disclosure.setOpen(false);
131
+ }, children: [_jsx(CheckCircleIcon, { className: "size-5" }), "Use Photo"] }), _jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
132
+ camera.reset();
133
+ }, children: [_jsx(RefreshCcw01Icon, { className: "size-5" }), " Retake"] })] }))] }) })] }) })] }));
41
134
  }
@@ -1,9 +1,17 @@
1
- import type { CSSProperties } from 'react';
1
+ import { type CSSProperties, type Ref } from 'react';
2
+ import { type ValidateFileError } from '../../utils/validateFile';
2
3
  export interface SelfieFieldProps {
4
+ ref?: Ref<HTMLDivElement>;
5
+ id?: string;
6
+ style?: CSSProperties;
7
+ className?: string;
3
8
  value?: string;
4
9
  onChange?: (value: string) => void;
5
10
  defaultValue?: string;
6
- className?: string;
7
- style?: CSSProperties;
11
+ invalid?: boolean;
12
+ readOnly?: boolean;
13
+ disabled?: boolean;
14
+ required?: boolean;
15
+ onError?: (error: ValidateFileError) => void;
8
16
  }
9
17
  export declare function SelfieField(props: SelfieFieldProps): import("react/jsx-runtime").JSX.Element;