@opexa/portal-components 0.0.395 → 0.0.397

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 (62) hide show
  1. package/dist/client/hooks/useSignUpMutation.js +3 -2
  2. package/dist/components/Account/Account.lazy.d.ts +7 -0
  3. package/dist/components/Account/Account.lazy.js +16 -7
  4. package/dist/components/PortalProvider/CXDTokenObserver.js +11 -11
  5. package/dist/components/PortalProvider/Providers.d.ts +1 -1
  6. package/dist/components/PortalProvider/Providers.js +2 -1
  7. package/dist/components/SignUp/SignUpDefault/SignUpDefaultForm.js +3 -1
  8. package/dist/components/SignUp/SignUpKYC/SignUpKYCForm.js +3 -1
  9. package/dist/constants/StorageKey.d.ts +0 -1
  10. package/dist/constants/StorageKey.js +0 -1
  11. package/dist/handlers/getSession.js +1 -4
  12. package/dist/handlers/index.d.ts +7 -7
  13. package/dist/handlers/patchSession.js +2 -9
  14. package/dist/ui/AlertDialog/AlertDialog.d.ts +154 -154
  15. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +14 -14
  16. package/dist/ui/Avatar/Avatar.d.ts +9 -9
  17. package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
  18. package/dist/ui/Badge/Badge.d.ts +12 -12
  19. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  20. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  21. package/dist/ui/Carousel/Carousel.d.ts +99 -99
  22. package/dist/ui/Carousel/carousel.recipe.d.ts +11 -11
  23. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  24. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  25. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  26. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  27. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  28. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  29. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  30. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  31. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  32. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  33. package/dist/ui/Dialog/Dialog.d.ts +154 -154
  34. package/dist/ui/Dialog/dialog.recipe.d.ts +14 -14
  35. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  36. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  37. package/dist/ui/Field/Field.d.ts +21 -21
  38. package/dist/ui/Field/field.recipe.d.ts +3 -3
  39. package/dist/ui/Menu/Menu.d.ts +198 -198
  40. package/dist/ui/Menu/menu.recipe.d.ts +11 -11
  41. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  42. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  43. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  44. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  45. package/dist/ui/PinInput/PinInput.d.ts +12 -12
  46. package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
  47. package/dist/ui/Popover/Popover.d.ts +121 -121
  48. package/dist/ui/Popover/popover.recipe.d.ts +11 -11
  49. package/dist/ui/Progress/Progress.d.ts +27 -27
  50. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  51. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  52. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  53. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  54. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  55. package/dist/ui/Select/Select.d.ts +45 -45
  56. package/dist/ui/Select/select.recipe.d.ts +3 -3
  57. package/dist/ui/Table/Table.d.ts +21 -21
  58. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  59. package/dist/ui/Table/table.recipe.d.ts +3 -3
  60. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  61. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  62. package/package.json +1 -1
@@ -3,6 +3,7 @@ import { registerMemberAccountViaMobile, } from '../../services/account.js';
3
3
  import { getSignUpMutationKey } from '../../utils/mutationKeys.js';
4
4
  import { getSession } from '../services/getSession.js';
5
5
  export const useSignUpMutation = (config) => {
6
+ const cellxpertCxd = config?.meta?.cellxpertCxd;
6
7
  return useMutation({
7
8
  ...config,
8
9
  mutationKey: getSignUpMutationKey(),
@@ -13,8 +14,8 @@ export const useSignUpMutation = (config) => {
13
14
  ...(session.btag && {
14
15
  btag: session.btag,
15
16
  }),
16
- ...(session.cellxpertCxd && {
17
- cellxpertCxd: session.cellxpertCxd,
17
+ ...(cellxpertCxd && {
18
+ cellxpertCxd,
18
19
  }),
19
20
  }, {
20
21
  headers: {
@@ -1,4 +1,11 @@
1
+ export interface ClassNameEntries {
2
+ root?: string;
3
+ walletActions?: string;
4
+ withdrawButton?: string;
5
+ depositButton?: string;
6
+ }
1
7
  export interface AccountProps {
8
+ className?: string | ClassNameEntries;
2
9
  /**
3
10
  * @default '0px'
4
11
  * @example
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { isString } from 'lodash-es';
3
4
  import Image from 'next/image';
4
5
  import Link from 'next/link';
5
6
  import { useRouter } from 'next/navigation';
@@ -54,26 +55,34 @@ export function Account(props) {
54
55
  const [mobileOffsetTop, desktopOffsetTop] = Array.isArray(props.offsetTop)
55
56
  ? props.offsetTop
56
57
  : [props.offsetTop ?? '0px', props.offsetTop ?? '0px'];
57
- return (_jsxs(AccountPropsContext, { value: Object.assign({}, defaultAccountProps, props), children: [_jsx(Drawer.Root, { open: globalStore.account__mobile.open, onOpenChange: (details) => {
58
+ const classNames = isString(props.className)
59
+ ? { root: props.className }
60
+ : (props.className ?? {});
61
+ const contextValue = {
62
+ ...defaultAccountProps,
63
+ ...props,
64
+ className: props.className ?? undefined,
65
+ };
66
+ return (_jsxs(AccountPropsContext, { value: contextValue, children: [_jsx(Drawer.Root, { open: globalStore.account__mobile.open, onOpenChange: (details) => {
58
67
  globalStore.account__mobile.setOpen(details.open);
59
- }, lazyMount: true, unmountOnExit: true, children: _jsx(Portal, { children: _jsx(Drawer.Positioner, { children: _jsxs(Drawer.Content, { className: twMerge('relative', 'flex', 'flex-col', 'top-[var(--offset-top-mobile)]', 'h-[calc(100%-var(--offset-top-mobile))]', 'w-full', 'px-xl', 'py-6', 'lg:top-[var(--offset-top-desktop)]', 'lg:h-[calc(100%-var(--offset-top-desktop))]', 'overflow-auto'), style: {
68
+ }, lazyMount: true, unmountOnExit: true, children: _jsx(Portal, { children: _jsx(Drawer.Positioner, { children: _jsxs(Drawer.Content, { className: twMerge('relative', 'flex', 'flex-col', 'top-[var(--offset-top-mobile)]', 'h-[calc(100%-var(--offset-top-mobile))]', 'w-full', 'px-xl', 'py-6', 'lg:top-[var(--offset-top-desktop)]', 'lg:h-[calc(100%-var(--offset-top-desktop))]', 'overflow-auto', classNames.root), style: {
60
69
  ['--offset-top-mobile']: mobileOffsetTop,
61
70
  ['--offset-top-desktop']: desktopOffsetTop,
62
- }, children: [_jsx(Profile, {}), _jsx(Wallet, {}), _jsx(Links, { router: router })] }) }) }) }), _jsx(Popover.Root, { open: globalStore.account.open, onOpenChange: (details) => {
71
+ }, children: [_jsx(Profile, {}), _jsx(Wallet, { classNames: classNames }), _jsx(Links, { router: router })] }) }) }) }), _jsx(Popover.Root, { open: globalStore.account.open, onOpenChange: (details) => {
63
72
  globalStore.account.setOpen(details.open);
64
73
  }, lazyMount: true, unmountOnExit: true, positioning: {
65
74
  placement: 'bottom',
66
75
  strategy: 'fixed',
67
76
  }, ids: {
68
77
  trigger: 'opexa-portal-components:account-trigger',
69
- }, children: _jsx(Portal, { children: _jsx(Popover.Positioner, { children: _jsxs(Popover.Content, { className: "relative z-popover w-[23.438rem] ui-closed:animate-fade-out ui-open:animate-fade-in overflow-hidden rounded-xl border border-border-primary bg-bg-primary p-xl", children: [_jsx(Profile, {}), _jsx(Wallet, {}), _jsx(Links, { router: router })] }) }) }) })] }));
78
+ }, children: _jsx(Portal, { children: _jsx(Popover.Positioner, { children: _jsxs(Popover.Content, { className: "relative z-popover w-[23.438rem] ui-closed:animate-fade-out ui-open:animate-fade-in overflow-hidden rounded-xl border border-border-primary bg-bg-primary p-xl", children: [_jsx(Profile, {}), _jsx(Wallet, { classNames: classNames }), _jsx(Links, { router: router })] }) }) }) })] }));
70
79
  }
71
80
  function Profile() {
72
81
  const accountQuery = useAccountQuery();
73
82
  const account = accountQuery.data;
74
83
  return (_jsxs("div", { className: "flex shrink-0 items-center gap-lg", children: [_jsx(Image, { src: avatarPlaceholder, alt: "", width: 48, height: 48, className: "size-12" }), _jsxs("div", { className: "grow", children: [_jsx("p", { className: "font-semibold text-text-secondary-700 leading-tight", children: account?.name }), _jsxs("div", { className: "flex", children: [_jsxs("p", { className: "grow items-center text-text-tertiary-600 leading-tight", children: ["ID: ", account?.id] }), _jsxs(Badge.Root, { colorScheme: account?.verified ? 'success' : 'danger', className: "self-start", children: [_jsx(Badge.Indicator, {}), _jsx(Badge.Label, { children: account?.verified ? 'Verified' : 'Unverified' })] })] })] })] }));
75
84
  }
76
- function Wallet() {
85
+ function Wallet({ classNames }) {
77
86
  const localeInfo = useLocaleInfo();
78
87
  const walletQuery = useWalletQuery({
79
88
  refetchInterval: 1000,
@@ -95,12 +104,12 @@ function Wallet() {
95
104
  }) })] }), _jsxs("div", { children: [_jsx("p", { className: "text-2xs text-text-secondary-700", children: "Bonus Balance" }), _jsx("p", { className: "text-medium text-text-primary-brand", children: formatNumber(bonusBalance, {
96
105
  currency: localeInfo?.currency.code,
97
106
  minDecimalPlaces: 2,
98
- }) })] })] })] }), ' ', _jsxs("div", { className: "mt-3 flex gap-lg", children: [_jsx(Button, { size: "xs", variant: "outline", onClick: () => {
107
+ }) })] })] })] }), ' ', _jsxs("div", { className: twMerge('mt-3 flex gap-lg', classNames.walletActions), children: [_jsx(Button, { size: "xs", variant: "outline", className: classNames.withdrawButton, onClick: () => {
99
108
  globalStore.depositWithdrawal.setOpen(true);
100
109
  globalStore.depositWithdrawal.setTab('WITHDRAWAL');
101
110
  globalStore.profile.setOpen(false);
102
111
  globalStore.mobileProfile.setOpen(false);
103
- }, children: "Withdraw" }), _jsx(Button, { size: "xs", onClick: () => {
112
+ }, children: "Withdraw" }), _jsx(Button, { size: "xs", className: classNames.depositButton, onClick: () => {
104
113
  globalStore.depositWithdrawal.setOpen(true);
105
114
  globalStore.depositWithdrawal.setTab('DEPOSIT');
106
115
  globalStore.profile.setOpen(false);
@@ -1,30 +1,30 @@
1
1
  'use client';
2
2
  import { addHours } from 'date-fns';
3
3
  import { clamp } from 'lodash-es';
4
+ import { useSearchParams } from 'next/navigation';
4
5
  import { useLocalStorage, useTimeout } from 'usehooks-ts';
5
6
  import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
6
7
  export function CXDTokenObserver() {
7
- const { data: account } = useAccountQuery();
8
- const accountCxd = {
9
- cxd: account?.cellxpertDetails?.cxd,
10
- };
11
- const [cxd, setCxd, removeCxd] = useLocalStorage('cxd', null);
8
+ const searchParams = useSearchParams();
9
+ const cxdToken = searchParams.get('cxd');
10
+ const accountQuery = useAccountQuery();
11
+ const account = accountQuery.data;
12
+ const [cxd, setCxd, removeCxd] = useLocalStorage('WebPortalCellxpertCxd', null);
12
13
  const now = new Date();
14
+ const shouldTimeoutRun = cxdToken && account;
13
15
  const removeCxdUntilInMs = cxd?.timestamp
14
16
  ? clamp(cxd.timestamp - now.getTime(), 0, Infinity)
15
17
  : 0;
16
18
  useTimeout(() => {
17
- const isSame = cxd?.cxd === accountCxd.cxd;
19
+ const isSame = cxd?.cxd === cxdToken;
18
20
  if (!isSame) {
19
21
  const extendedTimestamp = addHours(new Date(), 6).getTime();
20
22
  setCxd({
21
- cxd: accountCxd.cxd,
23
+ cxd: cxdToken,
22
24
  timestamp: extendedTimestamp,
23
25
  });
24
26
  }
25
- }, account ? 100 : null);
26
- useTimeout(() => {
27
- removeCxd();
28
- }, account ? removeCxdUntilInMs : null);
27
+ }, shouldTimeoutRun ? 100 : null);
28
+ useTimeout(() => removeCxd(), shouldTimeoutRun ? removeCxdUntilInMs : null);
29
29
  return null;
30
30
  }
@@ -1,4 +1,4 @@
1
- import type { PropsWithChildren } from 'react';
1
+ import { type PropsWithChildren } from 'react';
2
2
  export interface ProvidersProps {
3
3
  recaptchaSiteKey?: string;
4
4
  }
@@ -2,9 +2,10 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { QueryClientProvider } from '@tanstack/react-query';
4
4
  import { ReCaptchaProvider } from 'next-recaptcha-v3';
5
+ import { Suspense } from 'react';
5
6
  import { getQueryClient } from '../../utils/getQueryClient.js';
6
7
  import { CXDTokenObserver } from './CXDTokenObserver.js';
7
8
  export function Providers({ recaptchaSiteKey, children, }) {
8
9
  const queryClient = getQueryClient();
9
- return (_jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(CXDTokenObserver, {}), _jsx(ReCaptchaProvider, { reCaptchaKey: recaptchaSiteKey, children: children })] }));
10
+ return (_jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(Suspense, { children: _jsx(CXDTokenObserver, {}) }), _jsx(ReCaptchaProvider, { reCaptchaKey: recaptchaSiteKey, children: children })] }));
10
11
  }
@@ -59,7 +59,9 @@ export function SignUpDefaultForm() {
59
59
  responsibleGaming: ctx.responsibleGaming,
60
60
  })));
61
61
  const search = useSearchParams();
62
- const signUpMutation = useSignUpMutation();
62
+ const signUpMutation = useSignUpMutation({
63
+ meta: { cellxpertCxd: search.get('cxd') },
64
+ });
63
65
  const signInMutation = useSignInMutation();
64
66
  const updateAccountMutation = useUpdateAccountMutation();
65
67
  const sendVerificationCodeMutation = useSendVerificationCodeMutation();
@@ -67,7 +67,9 @@ export function SignUpKYCForm() {
67
67
  })));
68
68
  const dialog = useDialogContext();
69
69
  const search = useSearchParams();
70
- const signUpMutation = useSignUpMutation();
70
+ const signUpMutation = useSignUpMutation({
71
+ meta: { cellxpertCxd: search.get('cxd') },
72
+ });
71
73
  const signInMutation = useSignInMutation();
72
74
  const updateAccountMutation = useUpdateAccountMutation();
73
75
  const sendVerificationCodeMutation = useSendVerificationCodeMutation();
@@ -2,5 +2,4 @@ export declare const ACCESS_TOKEN_COOKIE_NAME: string;
2
2
  export declare const REFRESH_TOKEN_COOKIE_NAME: string;
3
3
  export declare const DOMAIN_COOKIE_NAME: string;
4
4
  export declare const BTAG_COOKIE_NAME: string;
5
- export declare const CELLXPERT_CXD_COOKIE_NAME: string;
6
5
  export declare const FEATURE_FLAG_LOCAL_STORAGE_KEY: string;
@@ -2,5 +2,4 @@ export const ACCESS_TOKEN_COOKIE_NAME = 'WebPortalAuthAccessToken';
2
2
  export const REFRESH_TOKEN_COOKIE_NAME = 'WebPortalAuthRefreshToken';
3
3
  export const DOMAIN_COOKIE_NAME = 'WebPortalDomain';
4
4
  export const BTAG_COOKIE_NAME = 'WebPortalBtag';
5
- export const CELLXPERT_CXD_COOKIE_NAME = 'WebPortalCellxpertCxd';
6
5
  export const FEATURE_FLAG_LOCAL_STORAGE_KEY = 'WebPortalFeatureFlag';
@@ -1,13 +1,12 @@
1
1
  import { addMinutes } from 'date-fns';
2
2
  import { NextResponse } from 'next/server';
3
- import { ACCESS_TOKEN_COOKIE_NAME, BTAG_COOKIE_NAME, CELLXPERT_CXD_COOKIE_NAME, DOMAIN_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
3
+ import { ACCESS_TOKEN_COOKIE_NAME, BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
4
4
  import { refreshSession } from '../services/auth.js';
5
5
  export async function getSession(request) {
6
6
  const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
7
7
  const refreshToken = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)?.value;
8
8
  const domain = request.cookies.get(DOMAIN_COOKIE_NAME)?.value;
9
9
  const btag = request.cookies.get(BTAG_COOKIE_NAME)?.value;
10
- const cellxpertCxd = request.cookies.get(CELLXPERT_CXD_COOKIE_NAME)?.value;
11
10
  if (!refreshToken) {
12
11
  const response = NextResponse.json({
13
12
  ok: true,
@@ -15,7 +14,6 @@ export async function getSession(request) {
15
14
  status: 'unauthenticated',
16
15
  domain,
17
16
  btag,
18
- cellxpertCxd,
19
17
  },
20
18
  });
21
19
  response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
@@ -58,7 +56,6 @@ export async function getSession(request) {
58
56
  status: 'unauthenticated',
59
57
  domain,
60
58
  btag,
61
- cellxpertCxd,
62
59
  },
63
60
  });
64
61
  response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
@@ -6,26 +6,26 @@ interface Context {
6
6
  params: Promise<Params>;
7
7
  }
8
8
  export declare const GET: (req: NextRequest, { params }: Context) => Promise<NextResponse<{
9
- ok: true;
10
- data?: never;
11
- } | {
12
9
  ok: false;
13
10
  message: string;
14
11
  __error?: unknown;
12
+ } | {
13
+ ok: true;
14
+ data: import("../types").Session;
15
15
  }> | NextResponse<{
16
+ ok: true;
17
+ data?: never;
18
+ } | {
16
19
  ok: false;
17
20
  message: string;
18
21
  __error?: unknown;
19
- } | {
20
- ok: true;
21
- data: Record<string, unknown>;
22
22
  }> | NextResponse<{
23
23
  ok: false;
24
24
  message: string;
25
25
  __error?: unknown;
26
26
  } | {
27
27
  ok: true;
28
- data: import("../types").Session;
28
+ data: Record<string, unknown>;
29
29
  }>>;
30
30
  export declare const DELETE: (req: NextRequest, { params }: Context) => Promise<NextResponse<{
31
31
  ok: true;
@@ -1,7 +1,7 @@
1
- import { addDays, addHours } from 'date-fns';
1
+ import { addDays } from 'date-fns';
2
2
  import { NextResponse } from 'next/server';
3
3
  import { z } from 'zod';
4
- import { BTAG_COOKIE_NAME, CELLXPERT_CXD_COOKIE_NAME, DOMAIN_COOKIE_NAME, } from '../constants/index.js';
4
+ import { BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME } from '../constants/index.js';
5
5
  const UpdateSessionDefinition = z.object({
6
6
  domain: z.string().optional().nullable(),
7
7
  btag: z.string().optional().nullable(),
@@ -24,13 +24,6 @@ export async function patchSession(request) {
24
24
  sameSite: 'strict',
25
25
  });
26
26
  }
27
- if (parsed.data.cellxpertCxd) {
28
- response.cookies.set(CELLXPERT_CXD_COOKIE_NAME, parsed.data.cellxpertCxd, {
29
- expires: addHours(new Date(), 6),
30
- httpOnly: true,
31
- sameSite: 'strict',
32
- });
33
- }
34
27
  if (parsed.data.btag) {
35
28
  response.cookies.set(BTAG_COOKIE_NAME, parsed.data.btag, {
36
29
  expires: addDays(new Date(), 30),