@opexa/portal-components 0.0.930 → 0.0.931
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/components/Banner/Banner.client.d.ts +12 -0
- package/dist/components/Banner/Banner.client.js +49 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/useAurixPayQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/DepositWithdrawal.lazy.d.ts +7 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.js +26 -14
- package/dist/components/DigitainLauncher/Loading.js +1 -1
- package/dist/components/ForgotPassword/Crazywin/ForgotPassword.module.css +42 -42
- package/dist/components/Jackpots/Jackpots.module.css +288 -288
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
- package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
- package/dist/components/KYC/BasicInformation.js +1 -1
- package/dist/components/KYC/IdentityVerification.js +1 -1
- package/dist/components/KYC/KYC.lazy.js +1 -1
- package/dist/components/KYC/KYCDefault/KYCVerificationStatus.lazy.js +2 -2
- package/dist/components/KYC/KYCNonPagCor/KYCVerificationStatus.lazy.js +2 -2
- package/dist/components/KYC/KYCVerificationStatus.lazy.js +5 -8
- package/dist/components/KYC/PersonalInformation.js +1 -1
- package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +1 -0
- package/dist/components/PortalProvider/AndroidOnlyComponents.js +12 -0
- package/dist/components/PortalProvider/CXDTokenObserver.js +11 -11
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
- package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
- package/dist/images/phone-icon.svg +10 -10
- package/dist/services/queries.js +3369 -3369
- package/dist/styles/theme.css +776 -776
- package/package.json +179 -179
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.d.ts +0 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.js +0 -11
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.d.ts +0 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.js +0 -11
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.d.ts +0 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.js +0 -126
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.d.ts +0 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.js +0 -10
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.d.ts +0 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.js +0 -12
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.d.ts +0 -17
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.js +0 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.d.ts +0 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.js +0 -41
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.d.ts +0 -13
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.js +0 -91
- package/dist/components/Disclaimer/ResponsibleGaming.d.ts +0 -10
- package/dist/components/Disclaimer/ResponsibleGaming.js +0 -13
- package/dist/components/Disclaimer/TermsOfUse.d.ts +0 -11
- package/dist/components/Disclaimer/TermsOfUse.js +0 -13
- package/dist/components/FeatureFlag/FeatureFlag.d.ts +0 -1
- package/dist/components/FeatureFlag/FeatureFlag.js +0 -29
- package/dist/components/FeatureFlag/index.d.ts +0 -1
- package/dist/components/FeatureFlag/index.js +0 -1
- package/dist/components/KYC/AutoOpen.d.ts +0 -1
- package/dist/components/KYC/AutoOpen.js +0 -40
- package/dist/components/KYC/CaptureIdDocument.d.ts +0 -1
- package/dist/components/KYC/CaptureIdDocument.js +0 -219
- package/dist/components/KYC/CaptureSelfie.d.ts +0 -1
- package/dist/components/KYC/CaptureSelfie.js +0 -285
- package/dist/components/KYC/DisplayImage.d.ts +0 -5
- package/dist/components/KYC/DisplayImage.js +0 -8
- package/dist/components/KYC/FileUpload.d.ts +0 -10
- package/dist/components/KYC/FileUpload.js +0 -72
- package/dist/components/KYC/NoCameraError.d.ts +0 -7
- package/dist/components/KYC/NoCameraError.js +0 -6
- package/dist/components/KYC/PersonOverlayDesktop.d.ts +0 -7
- package/dist/components/KYC/PersonOverlayDesktop.js +0 -9
- package/dist/components/KYC/backup/Header.d.ts +0 -1
- package/dist/components/KYC/backup/Header.js +0 -8
- package/dist/components/KYC/backup/Indicator.d.ts +0 -1
- package/dist/components/KYC/backup/Indicator.js +0 -9
- package/dist/components/KYC/backup/KYC.d.ts +0 -1
- package/dist/components/KYC/backup/KYC.js +0 -14
- package/dist/components/KYC/backup/KYC.lazy.d.ts +0 -1
- package/dist/components/KYC/backup/KYC.lazy.js +0 -26
- package/dist/components/KYC/backup/KYCContext.d.ts +0 -6
- package/dist/components/KYC/backup/KYCContext.js +0 -2
- package/dist/components/KYC/backup/Step1.d.ts +0 -1
- package/dist/components/KYC/backup/Step1.js +0 -13
- package/dist/components/KYC/backup/Step2.d.ts +0 -1
- package/dist/components/KYC/backup/Step2.js +0 -13
- package/dist/components/KYC/backup/Step3.d.ts +0 -1
- package/dist/components/KYC/backup/Step3.js +0 -13
- package/dist/components/KYC/backup/Step4.d.ts +0 -1
- package/dist/components/KYC/backup/Step4.js +0 -7
- package/dist/components/KYC/backup/useKYC.d.ts +0 -10
- package/dist/components/KYC/backup/useKYC.js +0 -8
- package/dist/components/KYC/loadModels.d.ts +0 -1
- package/dist/components/KYC/loadModels.js +0 -9
- package/dist/components/KYC/utils.d.ts +0 -9
- package/dist/components/KYC/utils.js +0 -79
- package/dist/components/Messages/Message.d.ts +0 -1
- package/dist/components/Messages/Message.js +0 -35
- package/dist/components/Messages/MessageContext.d.ts +0 -6
- package/dist/components/Messages/MessageContext.js +0 -2
- package/dist/components/Messages/MessagePopup.d.ts +0 -1
- package/dist/components/Messages/MessagePopup.js +0 -20
- package/dist/components/Messages/MessageTrigger.d.ts +0 -8
- package/dist/components/Messages/MessageTrigger.js +0 -19
- package/dist/components/Quests/CountdownTimer.d.ts +0 -15
- package/dist/components/Quests/CountdownTimer.js +0 -33
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +0 -4
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +0 -78
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +0 -8
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +0 -9
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +0 -4
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +0 -4
- package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +0 -4
- package/dist/components/Quests/WageringQuest/WageringQuest.js +0 -20
- package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +0 -9
- package/dist/components/Quests/WageringQuest/WageringQuestModal.js +0 -9
- package/dist/components/SignUp/SignUp.lazy.d.ts +0 -12
- package/dist/components/SignUp/SignUp.lazy.js +0 -18
- package/dist/components/SignUp/SignUpContext.d.ts +0 -6
- package/dist/components/SignUp/SignUpContext.js +0 -2
- package/dist/components/SignUp/SignUpDefault/SignUp.lazy.d.ts +0 -17
- package/dist/components/SignUp/SignUpDefault/SignUp.lazy.js +0 -18
- package/dist/components/SignUp/SignUpDefault/SignUpContext.d.ts +0 -6
- package/dist/components/SignUp/SignUpDefault/SignUpContext.js +0 -2
- package/dist/components/SignUp/SignUpDefault/SignUpForm.d.ts +0 -1
- package/dist/components/SignUp/SignUpDefault/SignUpForm.js +0 -310
- package/dist/components/SignUp/SignUpForm.d.ts +0 -1
- package/dist/components/SignUp/SignUpForm.js +0 -284
- package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.d.ts +0 -1
- package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.js +0 -198
- package/dist/components/SignUp/SignUpKYC/CaptureSelfie.d.ts +0 -1
- package/dist/components/SignUp/SignUpKYC/CaptureSelfie.js +0 -251
- package/dist/components/SignUp/SignUpKYC/ImageUploader.d.ts +0 -10
- package/dist/components/SignUp/SignUpKYC/ImageUploader.js +0 -42
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.d.ts +0 -7
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.js +0 -9
- package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.d.ts +0 -1
- package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.js +0 -464
- package/dist/components/SignUp/SignUpKYC/useImageUploader.d.ts +0 -11
- package/dist/components/SignUp/SignUpKYC/useImageUploader.js +0 -20
- package/dist/components/SignUp/SignUpKYC/utils.d.ts +0 -9
- package/dist/components/SignUp/SignUpKYC/utils.js +0 -79
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +0 -198
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +0 -251
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +0 -10
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +0 -41
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +0 -429
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +0 -13
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +0 -26
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +0 -7
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +0 -2
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +0 -11
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +0 -20
- package/dist/components/shared/IdDocumentField.client.d.ts +0 -25
- package/dist/components/shared/IdDocumentField.client.js +0 -204
- package/dist/components/shared/IdDocumentField.d.ts +0 -2
- package/dist/components/shared/IdDocumentField.js +0 -11
- package/dist/components/shared/SelfieField.client.d.ts +0 -20
- package/dist/components/shared/SelfieField.client.js +0 -327
- package/dist/components/shared/SelfieField.d.ts +0 -2
- package/dist/components/shared/SelfieField.js +0 -11
- package/dist/constants/BranchCode.d.ts +0 -4
- package/dist/constants/BranchCode.js +0 -42
- package/dist/handlers/postTransformIdFrontImage.d.ts +0 -3
- package/dist/handlers/postTransformIdFrontImage.js +0 -67
- package/dist/handlers/postTransformSelfieImage.d.ts +0 -3
- package/dist/handlers/postTransformSelfieImage.js +0 -71
- package/dist/handlers.d.ts +0 -43
- package/dist/handlers.js +0 -297
- package/dist/icons/BellRingIcon.d.ts +0 -2
- package/dist/icons/BellRingIcon.js +0 -4
- package/dist/utils/dataUrlToBlob.d.ts +0 -1
- package/dist/utils/dataUrlToBlob.js +0 -11
- package/dist/utils/gamesAvailable3pmTo3am.d.ts +0 -1
- package/dist/utils/gamesAvailable3pmTo3am.js +0 -1
- package/dist/utils/getGameName.d.ts +0 -1
- package/dist/utils/getGameName.js +0 -6
- package/dist/utils/isBetween3amAnd3pm.d.ts +0 -1
- package/dist/utils/isBetween3amAnd3pm.js +0 -5
- package/dist/utils/resizeImageSize.d.ts +0 -2
- package/dist/utils/resizeImageSize.js +0 -11
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useFieldContext } from '@ark-ui/react';
|
|
3
|
-
import Image from 'next/image';
|
|
4
|
-
import { useEffect, useId, useRef, useState, } from 'react';
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
6
|
-
import { useMediaQuery } from 'usehooks-ts';
|
|
7
|
-
import { useCamera } from '../../client/hooks/useCamera.js';
|
|
8
|
-
import { useControllableState } from '../../client/hooks/useControllableState.js';
|
|
9
|
-
import { useDisclosure } from '../../client/hooks/useDisclosure.js';
|
|
10
|
-
import { useFileQuery } from '../../client/hooks/useFileQuery.js';
|
|
11
|
-
import { useUploadImageFileMutation } from '../../client/hooks/useUploadImageFileMutation.js';
|
|
12
|
-
import { createContext } from '../../client/utils/createContext.js';
|
|
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 { validateFile } from '../../utils/validateFile.js';
|
|
25
|
-
export function IdDocumentField__client(props) {
|
|
26
|
-
const context = useIdDocumentField(props);
|
|
27
|
-
return (_jsxs(IdDocumentFieldProvider, { value: context, 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) => {
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
const file = e.dataTransfer.files?.[0];
|
|
30
|
-
if (!file)
|
|
31
|
-
return;
|
|
32
|
-
const error = validateFile(file);
|
|
33
|
-
if (error)
|
|
34
|
-
return props.onError?.(error);
|
|
35
|
-
context.mutation.mutate({ file });
|
|
36
|
-
}, "aria-describedby": context.field?.ariaDescribedby, children: [_jsx("input", { id: context.field?.ids?.control, ref: context.inputRef, type: "file", accept: "image/png, image/jpeg", onChange: (e) => {
|
|
37
|
-
const file = e.target.files?.[0];
|
|
38
|
-
if (!file)
|
|
39
|
-
return;
|
|
40
|
-
const error = validateFile(file);
|
|
41
|
-
if (error)
|
|
42
|
-
return props.onError?.(error);
|
|
43
|
-
context.mutation.mutate({ file });
|
|
44
|
-
}, disabled: context.field?.disabled ||
|
|
45
|
-
context.query.isLoading ||
|
|
46
|
-
context.mutation.isPending ||
|
|
47
|
-
props.disabled, readOnly: context.field?.readOnly || props.readOnly, required: context.field?.required || props.required, className: "sr-only" }), !context.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: () => {
|
|
48
|
-
context.inputRef.current?.click();
|
|
49
|
-
}, disabled: context.field?.disabled ||
|
|
50
|
-
context.field?.readOnly ||
|
|
51
|
-
context.query.isLoading ||
|
|
52
|
-
context.mutation.isPending ||
|
|
53
|
-
props.disabled ||
|
|
54
|
-
props.readOnly, 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: () => {
|
|
55
|
-
context.disclosure.setOpen(true);
|
|
56
|
-
}, disabled: context.field?.disabled ||
|
|
57
|
-
context.field?.readOnly ||
|
|
58
|
-
context.query.isLoading ||
|
|
59
|
-
context.mutation.isPending ||
|
|
60
|
-
props.disabled ||
|
|
61
|
-
props.readOnly, children: "Take a photo" })] })), context.query.data?.url && (_jsxs("div", { className: "relative", children: [_jsx(Image, { src: context.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: () => {
|
|
62
|
-
context.setValue('');
|
|
63
|
-
}, children: _jsx(XIcon, { className: "size-5" }) })] }))] }), _jsx(Camera, {})] }));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* -------------------------------------
|
|
67
|
-
* Camera
|
|
68
|
-
* -------------------------------------
|
|
69
|
-
*/
|
|
70
|
-
function Camera() {
|
|
71
|
-
const context = useIdDocumentFieldContext();
|
|
72
|
-
return (_jsx(Dialog.Root, { open: context.disclosure.open, onOpenChange: (details) => {
|
|
73
|
-
context.disclosure.setOpen(details.open);
|
|
74
|
-
}, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: context.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)] overflow-y-auto 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: [_jsx(Video, {}), context.camera.error && (_jsxs("div", { className: "border-border-disabled flex aspect-[4/3] flex-col items-center justify-center rounded-md border bg-black px-4 lg:aspect-video", 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: context.camera.error.name }), _jsx("p", { className: "text-text-tertiary-600 mt-0.5 text-center text-xs lg:mt-1 lg:text-sm", children: context.camera.error.message }), _jsx(Button, { size: "xs", variant: "outline", colorScheme: "gray", fullWidth: false, className: "mt-4 lg:mt-5", onClick: () => {
|
|
75
|
-
context.camera.reopen();
|
|
76
|
-
}, children: "Try again" })] })), context.camera.loading && (_jsx("div", { className: "border-border-disabled flex aspect-[4/3] flex-col items-center justify-center rounded-md border bg-black px-4 lg:aspect-video", children: _jsx(Spinner02Icon, { className: "text-text-placeholder size-8" }) })), context.camera.data && (_jsx("div", { className: "border-border-disabled aspect-[4/3] w-full overflow-hidden rounded-md border bg-black lg:aspect-video", children: _jsx(Image, { src: context.camera.data.url, alt: "", width: 600, height: 378.08, unoptimized: true, className: "mx-auto mt-2 block h-[calc(100%-1rem)] w-auto" }) }))] }), !context.camera.data && (_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 py-lg lg:w-[10rem]", onClick: () => {
|
|
77
|
-
context.camera.snap({
|
|
78
|
-
crop: context.guideRef.current?.getBoundingClientRect(),
|
|
79
|
-
});
|
|
80
|
-
}, disabled: context.camera.snapping ||
|
|
81
|
-
context.camera.loading ||
|
|
82
|
-
!!context.camera.error, children: [context.camera.snapping ? (_jsx(Spinner02Icon, { className: "size-5" })) : (_jsx(Camera01Icon, { className: "size-5" })), "Capture"] }) })), context.camera.data && (_jsxs("div", { className: "mt-5 flex gap-3 lg:mt-10 lg:justify-center", children: [_jsxs(Button, { onClick: () => {
|
|
83
|
-
const file = context.camera.data?.file;
|
|
84
|
-
if (!file)
|
|
85
|
-
return;
|
|
86
|
-
context.mutation.mutate({ file });
|
|
87
|
-
context.disclosure.setOpen(false);
|
|
88
|
-
}, className: "w-full lg:w-[10rem]", children: [_jsx(CheckCircleIcon, { className: "size-5" }), "Use Photo"] }), _jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
|
|
89
|
-
context.camera.reset();
|
|
90
|
-
}, className: "w-full lg:w-[10rem]", children: [_jsx(RefreshCcw01Icon, { className: "size-5" }), " Retake"] })] }))] }) })] }) }));
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* -------------------------------------
|
|
94
|
-
* Video
|
|
95
|
-
* -------------------------------------
|
|
96
|
-
*/
|
|
97
|
-
function Video() {
|
|
98
|
-
const id = useId();
|
|
99
|
-
const context = useIdDocumentFieldContext();
|
|
100
|
-
const [maskBox, setMaskBox] = useState({
|
|
101
|
-
x: 0,
|
|
102
|
-
y: 0,
|
|
103
|
-
width: 0,
|
|
104
|
-
height: 0,
|
|
105
|
-
});
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
const update = () => {
|
|
108
|
-
const guide = context.guideRef.current;
|
|
109
|
-
const mask = context.maskRef.current;
|
|
110
|
-
if (!guide || !mask)
|
|
111
|
-
return;
|
|
112
|
-
const guideRect = guide.getBoundingClientRect();
|
|
113
|
-
const maskRect = mask.getBoundingClientRect();
|
|
114
|
-
const x = guideRect.left - maskRect.left;
|
|
115
|
-
const y = guideRect.top - maskRect.top;
|
|
116
|
-
const width = guideRect.width;
|
|
117
|
-
const height = guideRect.height;
|
|
118
|
-
if (width && height) {
|
|
119
|
-
setMaskBox({
|
|
120
|
-
x,
|
|
121
|
-
y,
|
|
122
|
-
width,
|
|
123
|
-
height,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
const observer = new ResizeObserver(update);
|
|
128
|
-
if (context.guideRef.current)
|
|
129
|
-
observer.observe(context.guideRef.current);
|
|
130
|
-
if (context.maskRef.current)
|
|
131
|
-
observer.observe(context.maskRef.current);
|
|
132
|
-
requestAnimationFrame(update);
|
|
133
|
-
return () => observer.disconnect();
|
|
134
|
-
}, [context.guideRef, context.maskRef]);
|
|
135
|
-
return (_jsxs("div", { className: twMerge('relative h-auto w-full overflow-hidden', !context.camera.data && !context.camera.error && !context.camera.loading
|
|
136
|
-
? 'block'
|
|
137
|
-
: 'hidden'), children: [_jsx("video", { ...context.camera.videoProps }), _jsx("svg", { className: "pointer-events-none absolute -inset-4 size-[200%]", children: _jsx("defs", { children: _jsxs("mask", { id: id, maskUnits: "userSpaceOnUse", children: [_jsx("rect", { x: "0", y: "0", width: "200%", height: "200%", fill: "white" }), _jsx("rect", { x: maskBox.x, y: maskBox.y, width: maskBox.width, height: maskBox.height, fill: "black", rx: "8", ry: "8" })] }) }) }), _jsx("div", { ref: context.maskRef, className: "absolute -inset-4 size-[200%] bg-black/60 backdrop-blur-sm", style: {
|
|
138
|
-
mask: `url(#${id})`,
|
|
139
|
-
WebkitMask: `url(#${id})`,
|
|
140
|
-
maskRepeat: 'no-repeat',
|
|
141
|
-
WebkitMaskRepeat: 'no-repeat',
|
|
142
|
-
} }), _jsx("div", { ref: context.guideRef, className: "border-utility-warning-700 pointer-events-none absolute left-1/2 top-1/2 z-10 aspect-[85.6/53.98] w-[calc(100%-1rem)] max-w-[24.688rem] -translate-x-1/2 -translate-y-1/2 rounded-md border-2 border-dashed transition-all duration-200" })] }));
|
|
143
|
-
}
|
|
144
|
-
function useIdDocumentField(props) {
|
|
145
|
-
const field = useFieldContext();
|
|
146
|
-
const [value, setValue] = useControllableState({
|
|
147
|
-
value: props.value,
|
|
148
|
-
defaultValue: props.defaultValue ?? '',
|
|
149
|
-
onChange: props.onChange,
|
|
150
|
-
});
|
|
151
|
-
const query = useFileQuery(value, {
|
|
152
|
-
refetchInterval({ state }) {
|
|
153
|
-
return !state.data || state.data.status === 'UPLOADING' ? 1000 : false;
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
const mutation = useUploadImageFileMutation({
|
|
157
|
-
onSuccess(id) {
|
|
158
|
-
setValue(id);
|
|
159
|
-
},
|
|
160
|
-
onMutate() {
|
|
161
|
-
setValue('');
|
|
162
|
-
},
|
|
163
|
-
onError(error) {
|
|
164
|
-
toaster.error({
|
|
165
|
-
title: 'Upload Failed',
|
|
166
|
-
description: error.message,
|
|
167
|
-
});
|
|
168
|
-
},
|
|
169
|
-
onSettled() {
|
|
170
|
-
if (inputRef.current) {
|
|
171
|
-
inputRef.current.value = '';
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
const inputRef = useRef(null);
|
|
176
|
-
const maskRef = useRef(null);
|
|
177
|
-
const guideRef = useRef(null);
|
|
178
|
-
const desktop = useMediaQuery('(min-width: 1024px)');
|
|
179
|
-
const camera = useCamera({
|
|
180
|
-
video: {
|
|
181
|
-
facingMode: desktop ? 'user' : 'environment',
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
const disclosure = useDisclosure({
|
|
185
|
-
onOpenChange(open) {
|
|
186
|
-
if (open) {
|
|
187
|
-
camera.open();
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
return {
|
|
192
|
-
field,
|
|
193
|
-
value,
|
|
194
|
-
setValue,
|
|
195
|
-
query,
|
|
196
|
-
mutation,
|
|
197
|
-
camera,
|
|
198
|
-
disclosure,
|
|
199
|
-
inputRef,
|
|
200
|
-
guideRef,
|
|
201
|
-
maskRef,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
const [IdDocumentFieldProvider, useIdDocumentFieldContext] = createContext();
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import dynamic from 'next/dynamic';
|
|
4
|
-
import { Spinner02Icon } from '../../icons/Spinner02Icon.js';
|
|
5
|
-
const Component = dynamic(() => import('./IdDocumentField.client.js').then((mod) => mod.IdDocumentField__client), {
|
|
6
|
-
ssr: false,
|
|
7
|
-
loading: () => (_jsx("div", { className: "border-border-primary bg-bg-primary flex aspect-[352/180] w-full shrink-0 items-center justify-center rounded-xl border", children: _jsx(Spinner02Icon, { className: "text-text-quinary size-8" }) })),
|
|
8
|
-
});
|
|
9
|
-
export function IdDocumentField(props) {
|
|
10
|
-
return _jsx(Component, { ...props });
|
|
11
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties, type RefObject } from 'react';
|
|
2
|
-
import { type ValidateFileError } from '../../utils/validateFile';
|
|
3
|
-
export interface SelfieFieldProps extends UseSelfieFieldProps {
|
|
4
|
-
ref?: RefObject<HTMLDivElement | null>;
|
|
5
|
-
id?: string;
|
|
6
|
-
style?: CSSProperties;
|
|
7
|
-
className?: string;
|
|
8
|
-
invalid?: boolean;
|
|
9
|
-
readOnly?: boolean;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
onError?: (error: ValidateFileError<'FaceNotFoundError'>) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function SelfieField__client(props: SelfieFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
interface UseSelfieFieldProps {
|
|
16
|
-
value?: string;
|
|
17
|
-
onChange?: (value: string) => void;
|
|
18
|
-
defaultValue?: string;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useFieldContext } from '@ark-ui/react';
|
|
3
|
-
import { FaceDetector, FilesetResolver } from '@mediapipe/tasks-vision';
|
|
4
|
-
import Image from 'next/image';
|
|
5
|
-
import { useEffect, useId, useRef, useState, } from 'react';
|
|
6
|
-
import { twMerge } from 'tailwind-merge';
|
|
7
|
-
import { useInterval } from 'usehooks-ts';
|
|
8
|
-
import { useCamera } from '../../client/hooks/useCamera.js';
|
|
9
|
-
import { useControllableState } from '../../client/hooks/useControllableState.js';
|
|
10
|
-
import { useDisclosure } from '../../client/hooks/useDisclosure.js';
|
|
11
|
-
import { useFileQuery } from '../../client/hooks/useFileQuery.js';
|
|
12
|
-
import { useUploadImageFileMutation } from '../../client/hooks/useUploadImageFileMutation.js';
|
|
13
|
-
import { createContext } from '../../client/utils/createContext.js';
|
|
14
|
-
import { toaster } from '../../client/utils/toaster.js';
|
|
15
|
-
import { Camera01Icon } from '../../icons/Camera01Icon.js';
|
|
16
|
-
import { CameraOffIcon } from '../../icons/CameraOffIcon.js';
|
|
17
|
-
import { CheckCircleIcon } from '../../icons/CheckCircleIcon.js';
|
|
18
|
-
import { RefreshCcw01Icon } from '../../icons/RefreshCcw01Icon.js';
|
|
19
|
-
import { Spinner02Icon } from '../../icons/Spinner02Icon.js';
|
|
20
|
-
import { UploadCloud02Icon } from '../../icons/UploadCloud02Icon.js';
|
|
21
|
-
import { XIcon } from '../../icons/XIcon.js';
|
|
22
|
-
import { Button } from '../../ui/Button/index.js';
|
|
23
|
-
import { Dialog } from '../../ui/Dialog/index.js';
|
|
24
|
-
import { Portal } from '../../ui/Portal/index.js';
|
|
25
|
-
import { validateFile } from '../../utils/validateFile.js';
|
|
26
|
-
export function SelfieField__client(props) {
|
|
27
|
-
const context = useSelfieField(props);
|
|
28
|
-
return (_jsxs(SelfieFieldProvider, { value: context, children: [_jsxs("div", { ref: props.ref, id: props.id, style: props.style, className: twMerge('group', 'border', 'border-border-primary', 'bg-bg-primary', 'relative', 'w-full', 'aspect-[352/180]', 'shrink-0', 'rounded-xl', 'p-xl', props.className), onDragOver: (e) => e.preventDefault(), onDragEnter: (e) => e.preventDefault(), onDragLeave: (e) => e.preventDefault(), onDrop: async (e) => {
|
|
29
|
-
e.preventDefault();
|
|
30
|
-
const file = e.dataTransfer.files?.[0];
|
|
31
|
-
if (!file)
|
|
32
|
-
return;
|
|
33
|
-
const error = validateFile(file);
|
|
34
|
-
if (error)
|
|
35
|
-
return props.onError?.(error);
|
|
36
|
-
context.mutation.mutate({ file });
|
|
37
|
-
}, "aria-describedby": context.field?.ariaDescribedby, children: [_jsx("input", { id: context.field?.ids?.control, ref: context.inputRef, type: "file", accept: "image/png, image/jpeg", onChange: async (e) => {
|
|
38
|
-
const file = e.target.files?.[0];
|
|
39
|
-
if (!file)
|
|
40
|
-
return;
|
|
41
|
-
const error = validateFile(file);
|
|
42
|
-
if (error)
|
|
43
|
-
return props.onError?.(error);
|
|
44
|
-
context.mutation.mutate({ file });
|
|
45
|
-
}, disabled: context.field?.disabled ||
|
|
46
|
-
context.query.isLoading ||
|
|
47
|
-
context.mutation.isPending ||
|
|
48
|
-
props.disabled, readOnly: context.field?.readOnly || props.readOnly, required: context.field?.required || props.required, className: "sr-only" }), !context.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: () => {
|
|
49
|
-
context.inputRef.current?.click();
|
|
50
|
-
}, disabled: context.field?.disabled ||
|
|
51
|
-
context.field?.readOnly ||
|
|
52
|
-
context.query.isLoading ||
|
|
53
|
-
context.mutation.isPending ||
|
|
54
|
-
props.disabled ||
|
|
55
|
-
props.readOnly, 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: () => {
|
|
56
|
-
context.disclosure.setOpen(true);
|
|
57
|
-
}, disabled: context.field?.disabled ||
|
|
58
|
-
context.field?.readOnly ||
|
|
59
|
-
context.query.isLoading ||
|
|
60
|
-
context.mutation.isPending ||
|
|
61
|
-
props.disabled ||
|
|
62
|
-
props.readOnly, children: "Take a photo" })] })), context.query.data?.url && (_jsxs("div", { className: "relative", children: [_jsx(Image, { src: context.query.data.url, alt: "", width: 600, height: 600, 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: () => {
|
|
63
|
-
context.setValue('');
|
|
64
|
-
}, children: _jsx(XIcon, { className: "size-5" }) })] }))] }), _jsx(Camera, {})] }));
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* -------------------------------------
|
|
68
|
-
* Camera
|
|
69
|
-
* -------------------------------------
|
|
70
|
-
*/
|
|
71
|
-
function Camera() {
|
|
72
|
-
const context = useSelfieFieldContext();
|
|
73
|
-
return (_jsx(Dialog.Root, { open: context.disclosure.open, onOpenChange: (details) => {
|
|
74
|
-
context.disclosure.setOpen(details.open);
|
|
75
|
-
}, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: context.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)] overflow-y-auto 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 Selfie Holding Your ID" }), _jsx(Dialog.Description, { className: "text-text-tertiary-600 mt-md text-center text-xs lg:text-base", children: "Make sure your face and ID are clearly visible, with no glare\u00A0or\u00A0blur." }), _jsxs("div", { className: "relative mt-5 lg:mt-10 lg:px-3xl", children: [_jsx(Video, {}), context.camera.error && (_jsxs("div", { className: "border-border-disabled flex aspect-[4/3] flex-col items-center justify-center rounded-md border bg-black px-4 lg:aspect-video", 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: context.camera.error.name }), _jsx("p", { className: "text-text-tertiary-600 mt-0.5 text-center text-xs lg:mt-1 lg:text-sm", children: context.camera.error.message }), _jsx(Button, { size: "xs", variant: "outline", colorScheme: "gray", fullWidth: false, className: "mt-4 lg:mt-5", onClick: () => {
|
|
76
|
-
context.camera.reopen();
|
|
77
|
-
}, children: "Try again" })] })), context.camera.loading && (_jsx("div", { className: "border-border-disabled flex aspect-[4/3] flex-col items-center justify-center rounded-md border bg-black px-4 lg:aspect-video", children: _jsx(Spinner02Icon, { className: "text-text-placeholder size-8" }) })), context.camera.data && (_jsx("div", { className: "border-border-disabled aspect-[4/3] w-full overflow-hidden rounded-md border bg-black lg:aspect-video", children: _jsx(Image, { src: context.camera.data.url, alt: "", width: 600, height: 600, unoptimized: true, className: "mx-auto mt-2 block h-[calc(100%-1rem)] w-auto" }) }))] }), !context.camera.data && (_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 py-lg lg:w-[10rem]", onClick: () => {
|
|
78
|
-
context.camera.snap({
|
|
79
|
-
crop: context.guideRef.current?.getBoundingClientRect(),
|
|
80
|
-
});
|
|
81
|
-
}, disabled: !context.faceFound ||
|
|
82
|
-
context.camera.loading ||
|
|
83
|
-
context.camera.snapping ||
|
|
84
|
-
!!context.camera.error, children: [context.camera.snapping ? (_jsx(Spinner02Icon, { className: "size-5" })) : (_jsx(Camera01Icon, { className: "size-5" })), "Capture"] }) })), context.camera.data && (_jsxs("div", { className: "mt-5 flex gap-3 lg:mt-10 lg:justify-center", children: [_jsxs(Button, { onClick: () => {
|
|
85
|
-
const file = context.camera.data?.file;
|
|
86
|
-
if (!file)
|
|
87
|
-
return;
|
|
88
|
-
context.mutation.mutate({ file });
|
|
89
|
-
context.disclosure.setOpen(false);
|
|
90
|
-
}, className: "w-full lg:w-[10rem]", children: [_jsx(CheckCircleIcon, { className: "size-5" }), "Use Photo"] }), _jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
|
|
91
|
-
context.camera.reset();
|
|
92
|
-
}, className: "w-full lg:w-[10rem]", children: [_jsx(RefreshCcw01Icon, { className: "size-5" }), " Retake"] })] }))] }) })] }) }));
|
|
93
|
-
}
|
|
94
|
-
/*
|
|
95
|
-
* -------------------------------------
|
|
96
|
-
* Video
|
|
97
|
-
* -------------------------------------
|
|
98
|
-
*/
|
|
99
|
-
function Video() {
|
|
100
|
-
const id = useId();
|
|
101
|
-
const context = useSelfieFieldContext();
|
|
102
|
-
const [maskBox, setMaskBox] = useState({
|
|
103
|
-
x: 0,
|
|
104
|
-
y: 0,
|
|
105
|
-
width: 0,
|
|
106
|
-
height: 0,
|
|
107
|
-
});
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
const update = () => {
|
|
110
|
-
const guide = context.guideRef.current;
|
|
111
|
-
const mask = context.maskRef.current;
|
|
112
|
-
if (!guide || !mask)
|
|
113
|
-
return;
|
|
114
|
-
const guideRect = guide.getBoundingClientRect();
|
|
115
|
-
const maskRect = mask.getBoundingClientRect();
|
|
116
|
-
const x = guideRect.left - maskRect.left;
|
|
117
|
-
const y = guideRect.top - maskRect.top;
|
|
118
|
-
const width = guideRect.width;
|
|
119
|
-
const height = guideRect.height;
|
|
120
|
-
if (width && height) {
|
|
121
|
-
setMaskBox({
|
|
122
|
-
x,
|
|
123
|
-
y,
|
|
124
|
-
width,
|
|
125
|
-
height,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const observer = new ResizeObserver(update);
|
|
130
|
-
if (context.guideRef.current)
|
|
131
|
-
observer.observe(context.guideRef.current);
|
|
132
|
-
if (context.maskRef.current)
|
|
133
|
-
observer.observe(context.maskRef.current);
|
|
134
|
-
requestAnimationFrame(update);
|
|
135
|
-
return () => observer.disconnect();
|
|
136
|
-
}, [context.guideRef, context.maskRef]);
|
|
137
|
-
const [videoSize, setVideoSize] = useState({
|
|
138
|
-
width: 0,
|
|
139
|
-
height: 0,
|
|
140
|
-
});
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
const video = context.camera.videoRef.current;
|
|
143
|
-
if (!video)
|
|
144
|
-
return;
|
|
145
|
-
const updateVideoWidth = () => {
|
|
146
|
-
const rect = video.getBoundingClientRect();
|
|
147
|
-
setVideoSize({
|
|
148
|
-
width: rect.width,
|
|
149
|
-
height: rect.height,
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
video.addEventListener('loadedmetadata', updateVideoWidth);
|
|
153
|
-
video.addEventListener('resize', updateVideoWidth);
|
|
154
|
-
return () => {
|
|
155
|
-
video.removeEventListener('loadedmetadata', updateVideoWidth);
|
|
156
|
-
video.removeEventListener('resize', updateVideoWidth);
|
|
157
|
-
};
|
|
158
|
-
}, [context.camera.videoRef]);
|
|
159
|
-
const guideWidth = videoSize.width <= 0 || videoSize.height <= 0
|
|
160
|
-
? 0
|
|
161
|
-
: videoSize.width > videoSize.height
|
|
162
|
-
? videoSize.height
|
|
163
|
-
: videoSize.width;
|
|
164
|
-
return (_jsxs("div", { className: twMerge('relative h-auto w-full overflow-hidden', !context.camera.data && !context.camera.error && !context.camera.loading
|
|
165
|
-
? 'block'
|
|
166
|
-
: 'hidden'), children: [_jsx("video", { ...context.camera.videoProps }), _jsx("svg", { className: "pointer-events-none absolute -inset-4 size-[200%]", children: _jsx("defs", { children: _jsxs("mask", { id: id, maskUnits: "userSpaceOnUse", children: [_jsx("rect", { x: "0", y: "0", width: "200%", height: "200%", fill: "white" }), _jsx("rect", { x: maskBox.x, y: maskBox.y, width: maskBox.width, height: maskBox.height, fill: "black", rx: "8", ry: "8" })] }) }) }), _jsx("div", { ref: context.maskRef, className: "absolute -inset-4 size-[200%] bg-black/60 backdrop-blur-sm", style: {
|
|
167
|
-
mask: `url(#${id})`,
|
|
168
|
-
WebkitMask: `url(#${id})`,
|
|
169
|
-
maskRepeat: 'no-repeat',
|
|
170
|
-
WebkitMaskRepeat: 'no-repeat',
|
|
171
|
-
} }), _jsx("div", { ref: context.guideRef, className: twMerge('border-utility-warning-700 absolute left-1/2 top-1/2 z-20 aspect-square -translate-x-1/2 -translate-y-1/2 rounded-md border-2 border-dashed', context.faceFound && 'border-utility-success-700', guideWidth <= 0 ? 'hidden' : 'block'), style: {
|
|
172
|
-
width: `calc(${guideWidth}px - 2rem)`,
|
|
173
|
-
} })] }));
|
|
174
|
-
}
|
|
175
|
-
function useSelfieField(props) {
|
|
176
|
-
const field = useFieldContext();
|
|
177
|
-
const [value, setValue] = useControllableState({
|
|
178
|
-
value: props.value,
|
|
179
|
-
defaultValue: props.defaultValue ?? '',
|
|
180
|
-
onChange: props.onChange,
|
|
181
|
-
});
|
|
182
|
-
const query = useFileQuery(value, {
|
|
183
|
-
refetchInterval({ state }) {
|
|
184
|
-
return !state.data || state.data.status === 'UPLOADING' ? 1000 : false;
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
const mutation = useUploadImageFileMutation({
|
|
188
|
-
onSuccess(id) {
|
|
189
|
-
setValue(id);
|
|
190
|
-
},
|
|
191
|
-
onMutate() {
|
|
192
|
-
setValue('');
|
|
193
|
-
},
|
|
194
|
-
onError(error) {
|
|
195
|
-
toaster.error({
|
|
196
|
-
title: 'Upload Failed',
|
|
197
|
-
description: error.message,
|
|
198
|
-
});
|
|
199
|
-
},
|
|
200
|
-
onSettled() {
|
|
201
|
-
if (inputRef.current) {
|
|
202
|
-
inputRef.current.value = '';
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
const inputRef = useRef(null);
|
|
207
|
-
const maskRef = useRef(null);
|
|
208
|
-
const guideRef = useRef(null);
|
|
209
|
-
const camera = useCamera({
|
|
210
|
-
async validate(data) {
|
|
211
|
-
/*
|
|
212
|
-
* 💁♂️
|
|
213
|
-
* Check if we still have the face.
|
|
214
|
-
* User could have moved away from the camera
|
|
215
|
-
*/
|
|
216
|
-
const ok = await validateFaceFromImage(data.image);
|
|
217
|
-
if (!ok) {
|
|
218
|
-
return {
|
|
219
|
-
name: 'FaceNotFoundError',
|
|
220
|
-
message: 'Please ensure your face is clearly visible in the photo.',
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
const disclosure = useDisclosure({
|
|
226
|
-
onOpenChange(open) {
|
|
227
|
-
if (open) {
|
|
228
|
-
camera.open();
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
const [faceFound, setFaceFound] = useState(false);
|
|
233
|
-
useInterval(async () => {
|
|
234
|
-
if (!camera.videoRef.current || !guideRef.current) {
|
|
235
|
-
return setFaceFound(false);
|
|
236
|
-
}
|
|
237
|
-
setFaceFound(await validateFace(camera.videoRef.current, guideRef.current));
|
|
238
|
-
}, disclosure.open && !camera.data && !camera.error && !camera.loading
|
|
239
|
-
? 1000
|
|
240
|
-
: null);
|
|
241
|
-
return {
|
|
242
|
-
field,
|
|
243
|
-
value,
|
|
244
|
-
setValue,
|
|
245
|
-
query,
|
|
246
|
-
mutation,
|
|
247
|
-
camera,
|
|
248
|
-
disclosure,
|
|
249
|
-
inputRef,
|
|
250
|
-
guideRef,
|
|
251
|
-
maskRef,
|
|
252
|
-
faceFound,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
const [SelfieFieldProvider, useSelfieFieldContext] = createContext();
|
|
256
|
-
/*
|
|
257
|
-
* -------------------------------------
|
|
258
|
-
* Utils
|
|
259
|
-
* -------------------------------------
|
|
260
|
-
*/
|
|
261
|
-
let __video_detector__;
|
|
262
|
-
let __image_detector__;
|
|
263
|
-
async function getDetector(mode) {
|
|
264
|
-
if (mode === 'VIDEO' && __video_detector__)
|
|
265
|
-
return __video_detector__;
|
|
266
|
-
if (mode === 'IMAGE' && __image_detector__)
|
|
267
|
-
return __image_detector__;
|
|
268
|
-
const vision = await FilesetResolver.forVisionTasks('https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.0/wasm');
|
|
269
|
-
if (mode === 'VIDEO') {
|
|
270
|
-
__video_detector__ = await FaceDetector.createFromOptions(vision, {
|
|
271
|
-
baseOptions: {
|
|
272
|
-
modelAssetPath: 'https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite',
|
|
273
|
-
delegate: 'GPU',
|
|
274
|
-
},
|
|
275
|
-
runningMode: 'VIDEO',
|
|
276
|
-
});
|
|
277
|
-
return __video_detector__;
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
__image_detector__ = await FaceDetector.createFromOptions(vision, {
|
|
281
|
-
baseOptions: {
|
|
282
|
-
modelAssetPath: 'https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite',
|
|
283
|
-
delegate: 'GPU',
|
|
284
|
-
},
|
|
285
|
-
runningMode: 'IMAGE',
|
|
286
|
-
});
|
|
287
|
-
return __image_detector__;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
async function validateFace(video, guide) {
|
|
291
|
-
if (video.readyState < 2)
|
|
292
|
-
return false;
|
|
293
|
-
const detector = await getDetector('VIDEO');
|
|
294
|
-
const result = detector.detectForVideo(video, performance.now());
|
|
295
|
-
const detection = result.detections.at(0);
|
|
296
|
-
if (!detection)
|
|
297
|
-
return false;
|
|
298
|
-
const category = detection.categories.at(0);
|
|
299
|
-
if (!category || category.score < 0.75)
|
|
300
|
-
return false;
|
|
301
|
-
const videoRect = video.getBoundingClientRect(); // DOM position & size
|
|
302
|
-
const guideRect = guide.getBoundingClientRect();
|
|
303
|
-
if (!detection.boundingBox)
|
|
304
|
-
return false;
|
|
305
|
-
const faceLeft = videoRect.left +
|
|
306
|
-
(detection.boundingBox.originX / video.videoWidth) * videoRect.width;
|
|
307
|
-
const faceTop = videoRect.top +
|
|
308
|
-
(detection.boundingBox.originY / video.videoHeight) * videoRect.height;
|
|
309
|
-
const faceRight = faceLeft +
|
|
310
|
-
(detection.boundingBox.width / video.videoWidth) * videoRect.width;
|
|
311
|
-
const faceBottom = faceTop +
|
|
312
|
-
(detection.boundingBox.height / video.videoHeight) * videoRect.height;
|
|
313
|
-
const isInside = faceLeft >= guideRect.left &&
|
|
314
|
-
faceTop >= guideRect.top &&
|
|
315
|
-
faceRight <= guideRect.right &&
|
|
316
|
-
faceBottom <= guideRect.bottom;
|
|
317
|
-
return isInside;
|
|
318
|
-
}
|
|
319
|
-
async function validateFaceFromImage(image) {
|
|
320
|
-
const detector = await getDetector('IMAGE');
|
|
321
|
-
const result = detector.detect(image);
|
|
322
|
-
const detection = result.detections.at(0);
|
|
323
|
-
if (!detection)
|
|
324
|
-
return false;
|
|
325
|
-
const category = detection.categories.at(0);
|
|
326
|
-
return !category || category.score < 0.75 ? false : true;
|
|
327
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import dynamic from 'next/dynamic';
|
|
4
|
-
import { Spinner02Icon } from '../../icons/Spinner02Icon.js';
|
|
5
|
-
const Component = dynamic(() => import('./SelfieField.client.js').then((mod) => mod.SelfieField__client), {
|
|
6
|
-
ssr: false,
|
|
7
|
-
loading: () => (_jsx("div", { className: "border-border-primary bg-bg-primary flex aspect-[352/180] w-full shrink-0 items-center justify-center rounded-xl border", children: _jsx(Spinner02Icon, { className: "text-text-quinary size-8" }) })),
|
|
8
|
-
});
|
|
9
|
-
export function SelfieField(props) {
|
|
10
|
-
return _jsx(Component, { ...props });
|
|
11
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export const BRANCH_CODES = [
|
|
2
|
-
{
|
|
3
|
-
code: 'BRCAL',
|
|
4
|
-
name: 'Bingo Republic 2nd floor Primark Center Deparo St., Caloocan City',
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
code: 'BRNAG',
|
|
8
|
-
name: 'Bingo Republic 3rd floor Robinsons Mall, Naga City, Camarines Sur',
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
code: 'BRANT',
|
|
12
|
-
name: 'Bingo Republic 2nd floor Robinsons Mall, San Vicente,Antique',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
code: 'BRCLA',
|
|
16
|
-
name: 'Clark',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
code: 'BRLAG',
|
|
20
|
-
name: 'Laguna',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
code: 'BREAS',
|
|
24
|
-
name: 'Eastwood City, Quezon City',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
code: 'BRMAR',
|
|
28
|
-
name: 'Bingo ng Bayan 4th floor Marikina Public Market, Marikina City',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
code: 'BRILO',
|
|
32
|
-
name: 'Iloilo',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
code: 'BRFIM',
|
|
36
|
-
name: 'Fisher Mall,Quezon City',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: 'BRCAC',
|
|
40
|
-
name: 'Villa Caceres Hotel, Naga City,Camsur',
|
|
41
|
-
},
|
|
42
|
-
];
|