@opexa/portal-components 0.0.243 → 0.0.244

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 (74) hide show
  1. package/dist/client/hooks/useCamera.js +13 -4
  2. package/dist/client/hooks/useFeatureFlag.d.ts +2 -5
  3. package/dist/client/hooks/useFeatureFlag.js +29 -36
  4. package/dist/components/KYC/AutoOpen.js +8 -3
  5. package/dist/components/PortalProvider/FeatureFlag.js +14 -6
  6. package/dist/components/SignUp/SignUpForm.js +1 -2
  7. package/dist/components/shared/SelfieField.js +6 -7
  8. package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
  9. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
  10. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  11. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  12. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  13. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  14. package/dist/ui/Dialog/Dialog.d.ts +88 -88
  15. package/dist/ui/Dialog/dialog.recipe.d.ts +8 -8
  16. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  17. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  18. package/dist/ui/Field/Field.d.ts +21 -21
  19. package/dist/ui/Field/field.recipe.d.ts +3 -3
  20. package/dist/ui/Popover/Popover.d.ts +55 -55
  21. package/dist/ui/Popover/popover.recipe.d.ts +5 -5
  22. package/dist/ui/Select/Select.d.ts +45 -45
  23. package/dist/ui/Select/select.recipe.d.ts +3 -3
  24. package/package.json +8 -8
  25. package/dist/components/KYC/backup/Header.d.ts +0 -1
  26. package/dist/components/KYC/backup/Header.js +0 -8
  27. package/dist/components/KYC/backup/Indicator.d.ts +0 -1
  28. package/dist/components/KYC/backup/Indicator.js +0 -9
  29. package/dist/components/KYC/backup/KYC.d.ts +0 -1
  30. package/dist/components/KYC/backup/KYC.js +0 -14
  31. package/dist/components/KYC/backup/KYC.lazy.d.ts +0 -1
  32. package/dist/components/KYC/backup/KYC.lazy.js +0 -26
  33. package/dist/components/KYC/backup/KYCContext.d.ts +0 -6
  34. package/dist/components/KYC/backup/KYCContext.js +0 -2
  35. package/dist/components/KYC/backup/Step1.d.ts +0 -1
  36. package/dist/components/KYC/backup/Step1.js +0 -13
  37. package/dist/components/KYC/backup/Step2.d.ts +0 -1
  38. package/dist/components/KYC/backup/Step2.js +0 -13
  39. package/dist/components/KYC/backup/Step3.d.ts +0 -1
  40. package/dist/components/KYC/backup/Step3.js +0 -13
  41. package/dist/components/KYC/backup/Step4.d.ts +0 -1
  42. package/dist/components/KYC/backup/Step4.js +0 -7
  43. package/dist/components/KYC/backup/useKYC.d.ts +0 -10
  44. package/dist/components/KYC/backup/useKYC.js +0 -8
  45. package/dist/components/KYC/loadModels.d.ts +0 -1
  46. package/dist/components/KYC/loadModels.js +0 -9
  47. package/dist/components/Messages/Message.d.ts +0 -1
  48. package/dist/components/Messages/Message.js +0 -35
  49. package/dist/components/Messages/MessageContext.d.ts +0 -6
  50. package/dist/components/Messages/MessageContext.js +0 -2
  51. package/dist/components/Messages/MessagePopup.d.ts +0 -1
  52. package/dist/components/Messages/MessagePopup.js +0 -20
  53. package/dist/components/Messages/MessageTrigger.d.ts +0 -8
  54. package/dist/components/Messages/MessageTrigger.js +0 -19
  55. package/dist/components/Quests/CountdownTimer.d.ts +0 -15
  56. package/dist/components/Quests/CountdownTimer.js +0 -33
  57. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +0 -4
  58. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +0 -78
  59. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +0 -8
  60. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +0 -9
  61. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +0 -4
  62. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +0 -4
  63. package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +0 -4
  64. package/dist/components/Quests/WageringQuest/WageringQuest.js +0 -20
  65. package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +0 -9
  66. package/dist/components/Quests/WageringQuest/WageringQuestModal.js +0 -9
  67. package/dist/constants/BranchCode.d.ts +0 -4
  68. package/dist/constants/BranchCode.js +0 -42
  69. package/dist/icons/BellRingIcon.d.ts +0 -2
  70. package/dist/icons/BellRingIcon.js +0 -4
  71. package/dist/utils/dataUrlToBlob.d.ts +0 -1
  72. package/dist/utils/dataUrlToBlob.js +0 -11
  73. package/dist/utils/resizeImageSize.d.ts +0 -2
  74. package/dist/utils/resizeImageSize.js +0 -11
@@ -1,11 +1,11 @@
1
1
  import { isBoolean, isFunction, isObject } from 'lodash-es';
2
- import { useCallback, useMemo, useRef, useState, } from 'react';
2
+ import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
3
3
  import invariant from 'tiny-invariant';
4
4
  import { useMediaQuery } from 'usehooks-ts';
5
5
  export function useCamera(options = {}) {
6
6
  const { transform, validate, ...constraints } = options;
7
7
  const videoRef = useRef(null);
8
- const stream = useRef(null);
8
+ const streamRef = useRef(null);
9
9
  const [data, setData] = useState(null);
10
10
  const [error, setError] = useState(null);
11
11
  const [loading, setLoading] = useState(false);
@@ -51,7 +51,7 @@ export function useCamera(options = {}) {
51
51
  },
52
52
  });
53
53
  node.srcObject = result;
54
- stream.current = result;
54
+ streamRef.current = result;
55
55
  setMirror(!isObject(constraints.video)
56
56
  ? true
57
57
  : constraints.video.facingMode === 'environment'
@@ -92,7 +92,7 @@ export function useCamera(options = {}) {
92
92
  setLoading(false);
93
93
  setSnapping(false);
94
94
  return new Promise((resolve) => {
95
- stream.current?.getTracks().forEach((track) => track.stop());
95
+ streamRef.current?.getTracks().forEach((track) => track.stop());
96
96
  videoRef.current?.pause();
97
97
  resolve();
98
98
  });
@@ -218,8 +218,17 @@ export function useCamera(options = {}) {
218
218
  boxSizing: 'border-box',
219
219
  background: 'transparent',
220
220
  transform: mirror ? 'scaleX(-1)' : 'none',
221
+ pointerEvents: 'none',
221
222
  },
222
223
  }), [mirror]);
224
+ useEffect(() => {
225
+ return () => {
226
+ setData(null);
227
+ setError(null);
228
+ setLoading(false);
229
+ setSnapping(false);
230
+ };
231
+ }, []);
223
232
  return {
224
233
  snap,
225
234
  open,
@@ -4,12 +4,9 @@ export interface UseFeatureFlagReturn {
4
4
  disable(): Promise<void>;
5
5
  }
6
6
  export declare function useFeatureFlag(): UseFeatureFlagReturn;
7
- interface FeatureFlagEventDetail {
8
- enabled: boolean;
9
- }
10
- type FeatureFlagEvent = CustomEvent<FeatureFlagEventDetail>;
11
7
  interface EventsMap {
12
- 'web-portal::feature-flag': FeatureFlagEvent;
8
+ 'web-portal::feature-flag-enabled': CustomEvent;
9
+ 'web-portal::feature-flag-disabled': CustomEvent;
13
10
  }
14
11
  type Listener<K extends keyof EventsMap> = (this: Window, event: EventsMap[K]) => void;
15
12
  declare global {
@@ -1,52 +1,37 @@
1
- 'use client';
2
- import { useEffect, useState } from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
3
2
  import { FEATURE_FLAG_LOCAL_STORAGE_KEY } from '../../constants/index.js';
4
- const event = new CustomEvent('web-portal::feature-flag', {
5
- detail: {
6
- enabled: false,
7
- },
8
- bubbles: true,
9
- cancelable: false,
10
- });
11
3
  export function useFeatureFlag() {
12
4
  const [enabled, setEnabled] = useState(false);
13
- function enable() {
5
+ const enable = useCallback(() => {
14
6
  return new Promise((resolve) => {
15
- const event = new CustomEvent('web-portal::feature-flag', {
16
- detail: {
17
- enabled: true,
18
- },
19
- bubbles: true,
20
- cancelable: false,
21
- });
22
- window.dispatchEvent(event);
7
+ localStorage.setItem(FEATURE_FLAG_LOCAL_STORAGE_KEY, '');
8
+ window.dispatchEvent(FEATURE_FLAG_ENABLED_EVENT);
23
9
  resolve();
24
10
  });
25
- }
26
- function disable() {
11
+ }, []);
12
+ const disable = useCallback(() => {
27
13
  return new Promise((resolve) => {
28
- window.dispatchEvent(event);
14
+ localStorage.removeItem(FEATURE_FLAG_LOCAL_STORAGE_KEY);
15
+ window.dispatchEvent(FEATURE_FLAG_DISABLED_EVENT);
29
16
  resolve();
30
17
  });
31
- }
18
+ }, []);
32
19
  useEffect(() => {
33
- if (localStorage.getItem(FEATURE_FLAG_LOCAL_STORAGE_KEY) != null) {
34
- setEnabled(true);
35
- }
20
+ setEnabled(localStorage.getItem(FEATURE_FLAG_LOCAL_STORAGE_KEY) != null);
36
21
  }, []);
37
22
  useEffect(() => {
38
- const handle = (event) => {
39
- if (event.detail.enabled) {
40
- setEnabled(true);
41
- localStorage.setItem(FEATURE_FLAG_LOCAL_STORAGE_KEY, '');
42
- }
43
- else {
44
- setEnabled(false);
45
- localStorage.removeItem(FEATURE_FLAG_LOCAL_STORAGE_KEY);
46
- }
23
+ function handleEnabled() {
24
+ setEnabled(true);
25
+ }
26
+ function handleDisabled() {
27
+ setEnabled(false);
28
+ }
29
+ window.addEventListener('web-portal::feature-flag-enabled', handleEnabled);
30
+ window.addEventListener('web-portal::feature-flag-disabled', handleDisabled);
31
+ return () => {
32
+ window.removeEventListener('web-portal::feature-flag-enabled', handleEnabled);
33
+ window.removeEventListener('web-portal::feature-flag-disabled', handleDisabled);
47
34
  };
48
- window.addEventListener('web-portal::feature-flag', handle);
49
- return () => window.removeEventListener('web-portal::feature-flag', handle);
50
35
  }, []);
51
36
  return {
52
37
  enabled,
@@ -54,3 +39,11 @@ export function useFeatureFlag() {
54
39
  disable,
55
40
  };
56
41
  }
42
+ const FEATURE_FLAG_DISABLED_EVENT = new CustomEvent('web-portal::feature-flag-disabled', {
43
+ bubbles: true,
44
+ cancelable: false,
45
+ });
46
+ const FEATURE_FLAG_ENABLED_EVENT = new CustomEvent('web-portal::feature-flag-enabled', {
47
+ bubbles: true,
48
+ cancelable: false,
49
+ });
@@ -22,12 +22,17 @@ export function AutoOpen() {
22
22
  : isUploadCompleted
23
23
  ? 3
24
24
  : 2;
25
- const shouldOpen = !isBasicInfoCompleted || !isUploadCompleted || isRejected;
25
+ const shouldOpen = !account?.realName ||
26
+ !account?.birthDay ||
27
+ !verification ||
28
+ verification.status === 'REJECTED' ||
29
+ verification.status === 'UNVERIFIED';
26
30
  useEffect(() => {
27
31
  if (session?.status == 'authenticated' &&
32
+ !kycStore['~touched'] &&
28
33
  shouldOpen &&
29
- localStorage.getItem(KYC_PROMPT_LOCALSTORAGE_KEY) === null) {
30
- kycStore.setKycReminder(true);
34
+ localStorage.getItem(KYC_PROMPT_LOCALSTORAGE_KEY) == null) {
35
+ kycStore.setOpen(true);
31
36
  return;
32
37
  }
33
38
  }, [kycStore, session?.status, shouldOpen]);
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { usePathname, useRouter, useSearchParams } from 'next/navigation';
4
- import { useEffect } from 'react';
4
+ import { useCallback, useEffect } from 'react';
5
5
  import { useFeatureFlag } from '../../client/hooks/useFeatureFlag.js';
6
6
  import { Portal } from '../../ui/Portal/index.js';
7
7
  import { Presence } from '../../ui/Presence/index.js';
@@ -15,12 +15,20 @@ export function FeatureFlag() {
15
15
  featureFlag.enable();
16
16
  }
17
17
  }, [featureFlag, searchParams]);
18
+ const removeFutureParam = useCallback(() => {
19
+ return new Promise((resolve) => {
20
+ if (!searchParams.has('future'))
21
+ return resolve();
22
+ const newSearchParams = new URLSearchParams(searchParams);
23
+ newSearchParams.delete('future');
24
+ router.replace(`${pathname}?${newSearchParams.toString()}`, {
25
+ scroll: false,
26
+ });
27
+ setTimeout(resolve, 250);
28
+ });
29
+ }, [pathname, router, searchParams]);
18
30
  return (_jsx(Portal, { children: _jsx(Presence, { present: featureFlag.enabled, asChild: true, children: _jsx("div", { className: "fixed bottom-3 flex w-full flex-col items-center justify-center", children: _jsxs("div", { className: "rounded-full bg-black/50 px-2 py-1 text-sm leading-none backdrop-blur-md", children: ["Experimental features are enabled.", ' ', _jsx("button", { type: "button", className: "cursor-pointer underline underline-offset-2", onClick: async () => {
31
+ await removeFutureParam();
19
32
  await featureFlag.disable();
20
- const newSearchParams = new URLSearchParams(searchParams);
21
- newSearchParams.delete('future');
22
- router.replace(`${pathname}?${newSearchParams.toString()}`, {
23
- scroll: false,
24
- });
25
33
  }, children: "Disable" })] }) }) }) }));
26
34
  }
@@ -192,7 +192,6 @@ export function SignUpForm() {
192
192
  mobileNumber: mobileNumberParser.format(mobileNumber),
193
193
  verificationCode: verificationCode.join(''),
194
194
  referralCode: search.get('referralCode') ?? undefined,
195
- domain: search.get('domain') ?? undefined,
196
195
  btag: search.get('btag') ?? undefined,
197
196
  });
198
197
  const name = mobileNumberParser.format(mobileNumber);
@@ -252,7 +251,7 @@ export function SignUpForm() {
252
251
  o.field.onChange(details.value);
253
252
  }, onValueComplete: () => {
254
253
  form2Ref.current?.requestSubmit();
255
- }, 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 () => {
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 () => {
256
255
  await sendVerificationCodeMutation.mutateAsync({
257
256
  channel: 'SMS',
258
257
  recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
@@ -259,19 +259,18 @@ const [SelfieFieldProvider, useSelfieFieldContext] = createContext();
259
259
  * Utils
260
260
  * -------------------------------------
261
261
  */
262
- let __faceapi_models_loaded__ = false;
263
- async function loadFaceApiModels() {
264
- if (__faceapi_models_loaded__)
262
+ let __models_loaded__ = false;
263
+ async function loadModels() {
264
+ if (__models_loaded__)
265
265
  return;
266
266
  await Promise.all([
267
267
  faceapi.nets.tinyFaceDetector.loadFromUri('/models'),
268
- faceapi.nets.faceLandmark68Net.loadFromUri('/models'),
269
268
  faceapi.nets.faceRecognitionNet.loadFromUri('/models'),
270
269
  ]);
271
- __faceapi_models_loaded__ = true;
270
+ __models_loaded__ = true;
272
271
  }
273
272
  const validateFace = cache(async (video, guide) => {
274
- await loadFaceApiModels();
273
+ await loadModels();
275
274
  const videoRect = video.getBoundingClientRect();
276
275
  const guideRect = guide.getBoundingClientRect();
277
276
  const canvas = document.createElement('canvas');
@@ -310,7 +309,7 @@ const validateFace = cache(async (video, guide) => {
310
309
  return overlapRatio >= 0.6;
311
310
  });
312
311
  export async function validateFaceFromImage(img) {
313
- await loadFaceApiModels();
312
+ await loadModels();
314
313
  const detection = await faceapi.detectSingleFace(img, new faceapi.TinyFaceDetectorOptions({
315
314
  inputSize: 224,
316
315
  scoreThreshold: 0.5,