@customafk/lunas-ui 0.2.59 → 0.2.60

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/cms-layout-BMwn0Yv3.cjs +2 -0
  2. package/dist/cms-layout-BMwn0Yv3.cjs.map +1 -0
  3. package/dist/cms-layout-sd6GB6tR.mjs +2 -0
  4. package/dist/cms-layout-sd6GB6tR.mjs.map +1 -0
  5. package/dist/dialogs/detail-dialog/index.cjs +1 -1
  6. package/dist/dialogs/detail-dialog/index.cjs.map +1 -1
  7. package/dist/dialogs/detail-dialog/index.mjs +1 -1
  8. package/dist/dialogs/detail-dialog/index.mjs.map +1 -1
  9. package/dist/features/logo/index.cjs +2 -0
  10. package/dist/features/logo/index.cjs.map +1 -0
  11. package/dist/features/logo/index.d.cts +22 -0
  12. package/dist/features/logo/index.d.mts +22 -0
  13. package/dist/features/logo/index.mjs +2 -0
  14. package/dist/features/logo/index.mjs.map +1 -0
  15. package/dist/features/tables/index.cjs +1 -1
  16. package/dist/features/tables/index.mjs +1 -1
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +1 -1
  19. package/dist/index.d.mts +1 -1
  20. package/dist/index.mjs +1 -1
  21. package/dist/layouts/cms-layout/index.cjs +1 -1
  22. package/dist/layouts/cms-layout/index.mjs +1 -1
  23. package/dist/layouts/payment-layout/index.cjs +1 -1
  24. package/dist/layouts/payment-layout/index.mjs +1 -1
  25. package/dist/pages/FeatureDeveloping.cjs +1 -1
  26. package/dist/pages/FeatureDeveloping.cjs.map +1 -1
  27. package/dist/pages/FeatureDeveloping.mjs +1 -1
  28. package/dist/pages/FeatureDeveloping.mjs.map +1 -1
  29. package/dist/pages/FeatureFixing.cjs +1 -1
  30. package/dist/pages/FeatureFixing.cjs.map +1 -1
  31. package/dist/pages/FeatureFixing.mjs +1 -1
  32. package/dist/pages/FeatureFixing.mjs.map +1 -1
  33. package/dist/pages/LoginPage.cjs +1 -1
  34. package/dist/pages/LoginPage.cjs.map +1 -1
  35. package/dist/pages/LoginPage.mjs +1 -1
  36. package/dist/pages/LoginPage.mjs.map +1 -1
  37. package/dist/pages/NotAuthorized.cjs +1 -1
  38. package/dist/pages/NotAuthorized.cjs.map +1 -1
  39. package/dist/pages/NotAuthorized.mjs +1 -1
  40. package/dist/pages/NotAuthorized.mjs.map +1 -1
  41. package/dist/pages/NotFound.cjs +1 -1
  42. package/dist/pages/NotFound.cjs.map +1 -1
  43. package/dist/pages/NotFound.mjs +1 -1
  44. package/dist/pages/NotFound.mjs.map +1 -1
  45. package/dist/pages/RegisterPage.cjs +1 -1
  46. package/dist/pages/RegisterPage.cjs.map +1 -1
  47. package/dist/pages/RegisterPage.mjs +1 -1
  48. package/dist/pages/RegisterPage.mjs.map +1 -1
  49. package/dist/pages/VerifyEmailPage.cjs +1 -1
  50. package/dist/pages/VerifyEmailPage.cjs.map +1 -1
  51. package/dist/pages/VerifyEmailPage.mjs +1 -1
  52. package/dist/pages/VerifyEmailPage.mjs.map +1 -1
  53. package/dist/payment-layout-BLrXT-oc.cjs +2 -0
  54. package/dist/payment-layout-BLrXT-oc.cjs.map +1 -0
  55. package/dist/payment-layout-Dsz6wYT1.mjs +2 -0
  56. package/dist/{payment-layout-CG_l7Es-.mjs.map → payment-layout-Dsz6wYT1.mjs.map} +1 -1
  57. package/dist/{resizable-CVpc0g5U.d.cts → resizable-CFCYn9e_.d.cts} +2 -2
  58. package/dist/{resizable-CVpc0g5U.d.mts → resizable-CFCYn9e_.d.mts} +2 -2
  59. package/dist/{tables-UaA4qIaD.mjs → tables-B9cF58YD.mjs} +2 -2
  60. package/dist/{tables-UaA4qIaD.mjs.map → tables-B9cF58YD.mjs.map} +1 -1
  61. package/dist/{tables-CNJ10l7L.cjs → tables-NiAoBy75.cjs} +2 -2
  62. package/dist/{tables-CNJ10l7L.cjs.map → tables-NiAoBy75.cjs.map} +1 -1
  63. package/dist/tanstack-form-BMVn8ai_.cjs.map +1 -1
  64. package/dist/tanstack-form-DTCgWGCA.mjs.map +1 -1
  65. package/dist/ui/resizable.d.cts +1 -1
  66. package/dist/ui/resizable.d.mts +1 -1
  67. package/package.json +5 -1
  68. package/dist/cms-layout-Bsw2mKXo.cjs +0 -2
  69. package/dist/cms-layout-Bsw2mKXo.cjs.map +0 -1
  70. package/dist/cms-layout-IwpD0LvR.mjs +0 -2
  71. package/dist/cms-layout-IwpD0LvR.mjs.map +0 -1
  72. package/dist/payment-layout-CG_l7Es-.mjs +0 -2
  73. package/dist/payment-layout-Dlvc1P7b.cjs +0 -2
  74. package/dist/payment-layout-Dlvc1P7b.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NotAuthorized.cjs","names":["ShieldAlert","Button"],"sources":["../../packages/components/pages/NotAuthorized.tsx"],"sourcesContent":["import { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { ShieldAlert } from 'lucide-react';\n\nexport interface NotAuthorizedProps {\n /** Main heading shown beneath the shield icon. Defaults to `'Quyền truy cập bị từ chối'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese access-denied message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Quay lại'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `ShieldAlert` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 403 error screen shown when the current user lacks permission to access a resource.\n *\n * @example\n * ```tsx\n * import { NotAuthorized } from '@customafk/lunas-ui/pages/NotAuthorized';\n *\n * <NotAuthorized\n * title=\"Access Denied\"\n * subtitle=\"You do not have permission to view this page.\"\n * buttonText=\"Go Back\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotAuthorized = ({\n title = 'Quyền truy cập bị từ chối',\n subtitle = 'Xin lỗi, bạn không có quyền truy cập vào trang này.',\n buttonText = 'Quay lại',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotAuthorizedProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <div className=\"flex flex-col items-center gap-2\">\n <ShieldAlert className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">403</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotAuthorized;\n"],"mappings":"4OAkCA,MAAa,GAAiB,CAC5B,QAAQ,4BACR,WAAW,sDACX,aAAa,WACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,oBAGE,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,WAAA,EAAA,EAAA,GAAA,CAAc,8GAA+G,CAAS,WAA3I,EACE,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,4CAAf,EACE,EAAA,EAAA,IAAA,CAACA,EAAAA,YAAD,CAAa,WAAA,EAAA,EAAA,GAAA,CAAc,kCAAmC,CAAa,CAAI,CAAA,GAC/E,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,KAEL,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,GAElE,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,GAEhF,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
1
+ {"version":3,"file":"NotAuthorized.cjs","names":["LunasLogo","ShieldAlert","Button"],"sources":["../../packages/components/pages/NotAuthorized.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { ShieldAlert } from 'lucide-react';\nimport { LunasLogo } from '../features/logo';\n\nexport interface NotAuthorizedProps {\n /** Main heading shown beneath the shield icon. Defaults to `'Quyền truy cập bị từ chối'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese access-denied message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Quay lại'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `ShieldAlert` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 403 error screen shown when the current user lacks permission to access a resource.\n *\n * @example\n * ```tsx\n * import { NotAuthorized } from '@customafk/lunas-ui/pages/NotAuthorized';\n *\n * <NotAuthorized\n * title=\"Access Denied\"\n * subtitle=\"You do not have permission to view this page.\"\n * buttonText=\"Go Back\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotAuthorized = ({\n title = 'Quyền truy cập bị từ chối',\n subtitle = 'Xin lỗi, bạn không có quyền truy cập vào trang này.',\n buttonText = 'Quay lại',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotAuthorizedProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <LunasLogo variant=\"stacked\" size=\"sm\" />\n <div className=\"flex flex-col items-center gap-2\">\n <ShieldAlert className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">403</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotAuthorized;\n"],"mappings":"iSAqCA,MAAa,GAAiB,CAC5B,QAAQ,4BACR,WAAW,sDACX,aAAa,WACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,oBAGE,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,WAAA,EAAA,EAAA,GAAA,CAAc,8GAA+G,CAAS,WAA3I,EACE,EAAA,EAAA,IAAA,CAACA,EAAAA,UAAD,CAAW,QAAQ,UAAU,KAAK,IAAM,CAAA,GACxC,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,4CAAf,EACE,EAAA,EAAA,IAAA,CAACC,EAAAA,YAAD,CAAa,WAAA,EAAA,EAAA,GAAA,CAAc,kCAAmC,CAAa,CAAI,CAAA,GAC/E,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,KAEL,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,GAElE,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,GAEhF,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
@@ -1,2 +1,2 @@
1
- import{Button as e}from"../ui/button.mjs";import{ShieldAlert as t}from"lucide-react";import{cn as n}from"@customafk/react-toolkit/utils";import{jsx as r,jsxs as i}from"react/jsx-runtime";const a=({title:a=`Quyền truy cập bị từ chối`,subtitle:o=`Xin lỗi, bạn không có quyền truy cập vào trang này.`,buttonText:s=`Quay lại`,onButtonClick:c=()=>window.history.back(),className:l,iconClassName:u})=>i(`div`,{className:n(`flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full`,l),children:[i(`div`,{className:`flex flex-col items-center gap-2`,children:[r(t,{className:n(`size-16 sm:size-24 text-primary`,u)}),r(`div`,{className:`text-4xl sm:text-6xl font-bold text-primary`,children:`403`})]}),r(`h1`,{className:`text-xl sm:text-2xl font-semibold mt-2`,children:a}),r(`p`,{className:`text-muted-foreground max-w-md text-sm sm:text-base`,children:o}),r(e,{onClick:c,variant:`default`,className:`mt-2`,size:`sm`,children:s})]});export{a as NotAuthorized,a as default};
1
+ "use client";import{Button as e}from"../ui/button.mjs";import{LunasLogo as t}from"../features/logo/index.mjs";import{ShieldAlert as n}from"lucide-react";import{cn as r}from"@customafk/react-toolkit/utils";import{jsx as i,jsxs as a}from"react/jsx-runtime";const o=({title:o=`Quyền truy cập bị từ chối`,subtitle:s=`Xin lỗi, bạn không có quyền truy cập vào trang này.`,buttonText:c=`Quay lại`,onButtonClick:l=()=>window.history.back(),className:u,iconClassName:d})=>a(`div`,{className:r(`flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full`,u),children:[i(t,{variant:`stacked`,size:`sm`}),a(`div`,{className:`flex flex-col items-center gap-2`,children:[i(n,{className:r(`size-16 sm:size-24 text-primary`,d)}),i(`div`,{className:`text-4xl sm:text-6xl font-bold text-primary`,children:`403`})]}),i(`h1`,{className:`text-xl sm:text-2xl font-semibold mt-2`,children:o}),i(`p`,{className:`text-muted-foreground max-w-md text-sm sm:text-base`,children:s}),i(e,{onClick:l,variant:`default`,className:`mt-2`,size:`sm`,children:c})]});export{o as NotAuthorized,o as default};
2
2
  //# sourceMappingURL=NotAuthorized.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotAuthorized.mjs","names":[],"sources":["../../packages/components/pages/NotAuthorized.tsx"],"sourcesContent":["import { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { ShieldAlert } from 'lucide-react';\n\nexport interface NotAuthorizedProps {\n /** Main heading shown beneath the shield icon. Defaults to `'Quyền truy cập bị từ chối'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese access-denied message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Quay lại'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `ShieldAlert` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 403 error screen shown when the current user lacks permission to access a resource.\n *\n * @example\n * ```tsx\n * import { NotAuthorized } from '@customafk/lunas-ui/pages/NotAuthorized';\n *\n * <NotAuthorized\n * title=\"Access Denied\"\n * subtitle=\"You do not have permission to view this page.\"\n * buttonText=\"Go Back\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotAuthorized = ({\n title = 'Quyền truy cập bị từ chối',\n subtitle = 'Xin lỗi, bạn không có quyền truy cập vào trang này.',\n buttonText = 'Quay lại',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotAuthorizedProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <div className=\"flex flex-col items-center gap-2\">\n <ShieldAlert className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">403</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotAuthorized;\n"],"mappings":"2LAkCA,MAAa,GAAiB,CAC5B,QAAQ,4BACR,WAAW,sDACX,aAAa,WACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,mBAGE,EAAC,MAAD,CAAK,UAAW,EAAG,8GAA+G,CAAS,WAA3I,CACE,EAAC,MAAD,CAAK,UAAU,4CAAf,CACE,EAAC,EAAD,CAAa,UAAW,EAAG,kCAAmC,CAAa,CAAI,CAAA,EAC/E,EAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,IAEL,EAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,EAElE,EAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,EAEhF,EAAC,EAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
1
+ {"version":3,"file":"NotAuthorized.mjs","names":[],"sources":["../../packages/components/pages/NotAuthorized.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { ShieldAlert } from 'lucide-react';\nimport { LunasLogo } from '../features/logo';\n\nexport interface NotAuthorizedProps {\n /** Main heading shown beneath the shield icon. Defaults to `'Quyền truy cập bị từ chối'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese access-denied message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Quay lại'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `ShieldAlert` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 403 error screen shown when the current user lacks permission to access a resource.\n *\n * @example\n * ```tsx\n * import { NotAuthorized } from '@customafk/lunas-ui/pages/NotAuthorized';\n *\n * <NotAuthorized\n * title=\"Access Denied\"\n * subtitle=\"You do not have permission to view this page.\"\n * buttonText=\"Go Back\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotAuthorized = ({\n title = 'Quyền truy cập bị từ chối',\n subtitle = 'Xin lỗi, bạn không có quyền truy cập vào trang này.',\n buttonText = 'Quay lại',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotAuthorizedProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <LunasLogo variant=\"stacked\" size=\"sm\" />\n <div className=\"flex flex-col items-center gap-2\">\n <ShieldAlert className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">403</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotAuthorized;\n"],"mappings":"+PAqCA,MAAa,GAAiB,CAC5B,QAAQ,4BACR,WAAW,sDACX,aAAa,WACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,mBAGE,EAAC,MAAD,CAAK,UAAW,EAAG,8GAA+G,CAAS,WAA3I,CACE,EAAC,EAAD,CAAW,QAAQ,UAAU,KAAK,IAAM,CAAA,EACxC,EAAC,MAAD,CAAK,UAAU,4CAAf,CACE,EAAC,EAAD,CAAa,UAAW,EAAG,kCAAmC,CAAa,CAAI,CAAA,EAC/E,EAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,IAEL,EAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,EAElE,EAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,EAEhF,EAAC,EAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
@@ -1,2 +1,2 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../ui/button.cjs");let t=require("lucide-react"),n=require("@customafk/react-toolkit/utils"),r=require("react/jsx-runtime");const i=({title:i=`Không tìm thấy trang`,subtitle:a=`Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.`,buttonText:o=`Trở về trang chủ`,onButtonClick:s=()=>window.history.back(),className:c,iconClassName:l})=>(0,r.jsxs)(`div`,{className:(0,n.cn)(`flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full`,c),children:[(0,r.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,r.jsx)(t.FileQuestion,{className:(0,n.cn)(`size-16 sm:size-24 text-primary`,l)}),(0,r.jsx)(`div`,{className:`text-4xl sm:text-6xl font-bold text-primary`,children:`404`})]}),(0,r.jsx)(`h1`,{className:`text-xl sm:text-2xl font-semibold mt-2`,children:i}),(0,r.jsx)(`p`,{className:`text-muted-foreground max-w-md text-sm sm:text-base`,children:a}),(0,r.jsx)(e.Button,{onClick:s,variant:`default`,className:`mt-2`,size:`sm`,children:o})]});exports.NotFound=i,exports.default=i;
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../ui/button.cjs"),t=require("../features/logo/index.cjs");let n=require("lucide-react"),r=require("@customafk/react-toolkit/utils"),i=require("react/jsx-runtime");const a=({title:a=`Không tìm thấy trang`,subtitle:o=`Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.`,buttonText:s=`Trở về trang chủ`,onButtonClick:c=()=>window.history.back(),className:l,iconClassName:u})=>(0,i.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full`,l),children:[(0,i.jsx)(t.LunasLogo,{variant:`stacked`,size:`sm`}),(0,i.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,i.jsx)(n.FileQuestion,{className:(0,r.cn)(`size-16 sm:size-24 text-primary`,u)}),(0,i.jsx)(`div`,{className:`text-4xl sm:text-6xl font-bold text-primary`,children:`404`})]}),(0,i.jsx)(`h1`,{className:`text-xl sm:text-2xl font-semibold mt-2`,children:a}),(0,i.jsx)(`p`,{className:`text-muted-foreground max-w-md text-sm sm:text-base`,children:o}),(0,i.jsx)(e.Button,{onClick:c,variant:`default`,className:`mt-2`,size:`sm`,children:s})]});exports.NotFound=a,exports.default=a;
2
2
  //# sourceMappingURL=NotFound.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotFound.cjs","names":["FileQuestion","Button"],"sources":["../../packages/components/pages/NotFound.tsx"],"sourcesContent":["import { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { FileQuestion } from 'lucide-react';\n\nexport interface NotFoundProps {\n /** Main heading shown beneath the file-question icon. Defaults to `'Không tìm thấy trang'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese 404 message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Trở về trang chủ'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `FileQuestion` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 404 error screen displayed when a requested route or resource does not exist.\n *\n * @example\n * ```tsx\n * import { NotFound } from '@customafk/lunas-ui/pages/NotFound';\n *\n * <NotFound\n * title=\"Page Not Found\"\n * subtitle=\"The page you are looking for does not exist.\"\n * buttonText=\"Go Home\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotFound = ({\n title = 'Không tìm thấy trang',\n subtitle = 'Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.',\n buttonText = 'Trở về trang chủ',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotFoundProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <div className=\"flex flex-col items-center gap-2\">\n <FileQuestion className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">404</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotFound;\n"],"mappings":"4OAkCA,MAAa,GAAY,CACvB,QAAQ,uBACR,WAAW,uEACX,aAAa,mBACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,oBAGE,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,WAAA,EAAA,EAAA,GAAA,CAAc,8GAA+G,CAAS,WAA3I,EACE,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,4CAAf,EACE,EAAA,EAAA,IAAA,CAACA,EAAAA,aAAD,CAAc,WAAA,EAAA,EAAA,GAAA,CAAc,kCAAmC,CAAa,CAAI,CAAA,GAChF,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,KAEL,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,GAElE,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,GAEhF,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
1
+ {"version":3,"file":"NotFound.cjs","names":["LunasLogo","FileQuestion","Button"],"sources":["../../packages/components/pages/NotFound.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { FileQuestion } from 'lucide-react';\nimport { LunasLogo } from '../features/logo';\n\nexport interface NotFoundProps {\n /** Main heading shown beneath the file-question icon. Defaults to `'Không tìm thấy trang'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese 404 message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Trở về trang chủ'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `FileQuestion` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 404 error screen displayed when a requested route or resource does not exist.\n *\n * @example\n * ```tsx\n * import { NotFound } from '@customafk/lunas-ui/pages/NotFound';\n *\n * <NotFound\n * title=\"Page Not Found\"\n * subtitle=\"The page you are looking for does not exist.\"\n * buttonText=\"Go Home\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotFound = ({\n title = 'Không tìm thấy trang',\n subtitle = 'Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.',\n buttonText = 'Trở về trang chủ',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotFoundProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <LunasLogo variant=\"stacked\" size=\"sm\" />\n <div className=\"flex flex-col items-center gap-2\">\n <FileQuestion className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">404</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotFound;\n"],"mappings":"iSAqCA,MAAa,GAAY,CACvB,QAAQ,uBACR,WAAW,uEACX,aAAa,mBACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,oBAGE,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,WAAA,EAAA,EAAA,GAAA,CAAc,8GAA+G,CAAS,WAA3I,EACE,EAAA,EAAA,IAAA,CAACA,EAAAA,UAAD,CAAW,QAAQ,UAAU,KAAK,IAAM,CAAA,GACxC,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,4CAAf,EACE,EAAA,EAAA,IAAA,CAACC,EAAAA,aAAD,CAAc,WAAA,EAAA,EAAA,GAAA,CAAc,kCAAmC,CAAa,CAAI,CAAA,GAChF,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,KAEL,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,GAElE,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,GAEhF,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
@@ -1,2 +1,2 @@
1
- import{Button as e}from"../ui/button.mjs";import{FileQuestion as t}from"lucide-react";import{cn as n}from"@customafk/react-toolkit/utils";import{jsx as r,jsxs as i}from"react/jsx-runtime";const a=({title:a=`Không tìm thấy trang`,subtitle:o=`Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.`,buttonText:s=`Trở về trang chủ`,onButtonClick:c=()=>window.history.back(),className:l,iconClassName:u})=>i(`div`,{className:n(`flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full`,l),children:[i(`div`,{className:`flex flex-col items-center gap-2`,children:[r(t,{className:n(`size-16 sm:size-24 text-primary`,u)}),r(`div`,{className:`text-4xl sm:text-6xl font-bold text-primary`,children:`404`})]}),r(`h1`,{className:`text-xl sm:text-2xl font-semibold mt-2`,children:a}),r(`p`,{className:`text-muted-foreground max-w-md text-sm sm:text-base`,children:o}),r(e,{onClick:c,variant:`default`,className:`mt-2`,size:`sm`,children:s})]});export{a as NotFound,a as default};
1
+ "use client";import{Button as e}from"../ui/button.mjs";import{LunasLogo as t}from"../features/logo/index.mjs";import{FileQuestion as n}from"lucide-react";import{cn as r}from"@customafk/react-toolkit/utils";import{jsx as i,jsxs as a}from"react/jsx-runtime";const o=({title:o=`Không tìm thấy trang`,subtitle:s=`Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.`,buttonText:c=`Trở về trang chủ`,onButtonClick:l=()=>window.history.back(),className:u,iconClassName:d})=>a(`div`,{className:r(`flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full`,u),children:[i(t,{variant:`stacked`,size:`sm`}),a(`div`,{className:`flex flex-col items-center gap-2`,children:[i(n,{className:r(`size-16 sm:size-24 text-primary`,d)}),i(`div`,{className:`text-4xl sm:text-6xl font-bold text-primary`,children:`404`})]}),i(`h1`,{className:`text-xl sm:text-2xl font-semibold mt-2`,children:o}),i(`p`,{className:`text-muted-foreground max-w-md text-sm sm:text-base`,children:s}),i(e,{onClick:l,variant:`default`,className:`mt-2`,size:`sm`,children:c})]});export{o as NotFound,o as default};
2
2
  //# sourceMappingURL=NotFound.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotFound.mjs","names":[],"sources":["../../packages/components/pages/NotFound.tsx"],"sourcesContent":["import { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { FileQuestion } from 'lucide-react';\n\nexport interface NotFoundProps {\n /** Main heading shown beneath the file-question icon. Defaults to `'Không tìm thấy trang'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese 404 message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Trở về trang chủ'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `FileQuestion` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 404 error screen displayed when a requested route or resource does not exist.\n *\n * @example\n * ```tsx\n * import { NotFound } from '@customafk/lunas-ui/pages/NotFound';\n *\n * <NotFound\n * title=\"Page Not Found\"\n * subtitle=\"The page you are looking for does not exist.\"\n * buttonText=\"Go Home\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotFound = ({\n title = 'Không tìm thấy trang',\n subtitle = 'Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.',\n buttonText = 'Trở về trang chủ',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotFoundProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <div className=\"flex flex-col items-center gap-2\">\n <FileQuestion className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">404</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotFound;\n"],"mappings":"4LAkCA,MAAa,GAAY,CACvB,QAAQ,uBACR,WAAW,uEACX,aAAa,mBACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,mBAGE,EAAC,MAAD,CAAK,UAAW,EAAG,8GAA+G,CAAS,WAA3I,CACE,EAAC,MAAD,CAAK,UAAU,4CAAf,CACE,EAAC,EAAD,CAAc,UAAW,EAAG,kCAAmC,CAAa,CAAI,CAAA,EAChF,EAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,IAEL,EAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,EAElE,EAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,EAEhF,EAAC,EAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
1
+ {"version":3,"file":"NotFound.mjs","names":[],"sources":["../../packages/components/pages/NotFound.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../ui/button';\nimport { cn } from '@customafk/react-toolkit/utils';\nimport { FileQuestion } from 'lucide-react';\nimport { LunasLogo } from '../features/logo';\n\nexport interface NotFoundProps {\n /** Main heading shown beneath the file-question icon. Defaults to `'Không tìm thấy trang'`. */\n title?: string;\n /** Supporting text shown below the title. Defaults to a Vietnamese 404 message. */\n subtitle?: string;\n /** Label for the action button. Defaults to `'Trở về trang chủ'`. */\n buttonText?: string;\n /** Handler called when the action button is clicked. Defaults to `window.history.back()`. */\n onButtonClick?: () => void;\n /** Additional class names applied to the root container element. */\n className?: string;\n /** Additional class names applied to the `FileQuestion` icon. */\n iconClassName?: string;\n}\n\n/**\n * Full-page 404 error screen displayed when a requested route or resource does not exist.\n *\n * @example\n * ```tsx\n * import { NotFound } from '@customafk/lunas-ui/pages/NotFound';\n *\n * <NotFound\n * title=\"Page Not Found\"\n * subtitle=\"The page you are looking for does not exist.\"\n * buttonText=\"Go Home\"\n * onButtonClick={() => router.push('/')}\n * />\n * ```\n */\nexport const NotFound = ({\n title = 'Không tìm thấy trang',\n subtitle = 'Xin lỗi, trang bạn đang tìm kiếm không tồn tại hoặc đã bị di chuyển.',\n buttonText = 'Trở về trang chủ',\n onButtonClick = () => window.history.back(),\n className,\n iconClassName,\n}: NotFoundProps) => {\n return (\n <div className={cn('flex flex-col items-center justify-center min-h-[50vh] gap-4 sm:gap-6 py-8 sm:py-10 px-4 text-center w-full', className)}>\n <LunasLogo variant=\"stacked\" size=\"sm\" />\n <div className=\"flex flex-col items-center gap-2\">\n <FileQuestion className={cn('size-16 sm:size-24 text-primary', iconClassName)} />\n <div className=\"text-4xl sm:text-6xl font-bold text-primary\">404</div>\n </div>\n\n <h1 className=\"text-xl sm:text-2xl font-semibold mt-2\">{title}</h1>\n\n <p className=\"text-muted-foreground max-w-md text-sm sm:text-base\">{subtitle}</p>\n\n <Button onClick={onButtonClick} variant=\"default\" className=\"mt-2\" size=\"sm\">\n {buttonText}\n </Button>\n </div>\n );\n};\n\nexport default NotFound;\n"],"mappings":"gQAqCA,MAAa,GAAY,CACvB,QAAQ,uBACR,WAAW,uEACX,aAAa,mBACb,oBAAsB,OAAO,QAAQ,KAAK,EAC1C,YACA,mBAGE,EAAC,MAAD,CAAK,UAAW,EAAG,8GAA+G,CAAS,WAA3I,CACE,EAAC,EAAD,CAAW,QAAQ,UAAU,KAAK,IAAM,CAAA,EACxC,EAAC,MAAD,CAAK,UAAU,4CAAf,CACE,EAAC,EAAD,CAAc,UAAW,EAAG,kCAAmC,CAAa,CAAI,CAAA,EAChF,EAAC,MAAD,CAAK,UAAU,uDAA8C,KAAQ,CAAA,CAClE,IAEL,EAAC,KAAD,CAAI,UAAU,kDAA0C,CAAU,CAAA,EAElE,EAAC,IAAD,CAAG,UAAU,+DAAuD,CAAY,CAAA,EAEhF,EAAC,EAAD,CAAQ,QAAS,EAAe,QAAQ,UAAU,UAAU,OAAO,KAAK,cACrE,CACK,CAAA,CACL"}
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../ui/button.cjs"),t=require("../ui/dialog.cjs"),n=require("../ui/input.cjs"),r=require("../ui/label.cjs"),i=require("../alert-D31c6DLq.cjs");let a=require("lucide-react"),o=require("react"),s=require("react/jsx-runtime"),c=require("zod");const l=c.z.object({email:c.z.string().min(1,`Vui lòng nhập email`).email(`Email không hợp lệ`),password:c.z.string().min(8,`Mật khẩu phải có ít nhất 8 ký tự`).max(50,`Mật khẩu không được vượt quá 50 ký tự`).regex(/[A-Z]/,`Phải có ít nhất một chữ hoa`).regex(/[a-z]/,`Phải có ít nhất một chữ thường`).regex(/[0-9]/,`Phải có ít nhất một chữ số`).regex(/[^A-Za-z0-9]/,`Phải có ít nhất một ký tự đặc biệt`),confirmPassword:c.z.string().min(1,`Vui lòng xác nhận mật khẩu`)}).refine(e=>e.password===e.confirmPassword,{message:`Mật khẩu xác nhận không khớp`,path:[`confirmPassword`]}),u=({open:c,onOpenChange:u,onRegister:d,onLogin:f,isLoading:p=!1,errorMessage:m,title:h=`Đăng ký`,subtitle:g=`Tạo tài khoản mới để bắt đầu`})=>{let _=(0,o.useId)(),v=(0,o.useId)(),y=(0,o.useId)(),[b,x]=(0,o.useState)(``),[S,C]=(0,o.useState)(``),[w,T]=(0,o.useState)(``),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)({});return(0,s.jsx)(t.Dialog,{open:c,onOpenChange:u,children:(0,s.jsxs)(t.DialogContent,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[(0,s.jsxs)(t.DialogHeader,{children:[(0,s.jsx)(t.DialogTitle,{children:h}),(0,s.jsx)(t.DialogDescription,{children:g})]}),(0,s.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault();let t=l.safeParse({email:b,password:S,confirmPassword:w});if(!t.success){let e=t.error.flatten().fieldErrors;j({email:e.email?.[0],password:e.password?.[0],confirmPassword:e.confirmPassword?.[0]});return}j({}),await d(b,S)},noValidate:!0,className:`flex flex-col gap-4`,children:[m&&(0,s.jsx)(i.t,{variant:`destructive`,children:(0,s.jsx)(i.n,{children:m})}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,s.jsx)(r.Label,{htmlFor:_,children:`Email`}),(0,s.jsx)(n.Input,{id:_,type:`email`,autoComplete:`email`,placeholder:`you@example.com`,value:b,onChange:e=>x(e.target.value),"aria-invalid":!!A.email,disabled:p}),A.email&&(0,s.jsx)(`p`,{className:`text-destructive text-xs`,children:A.email})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,s.jsx)(r.Label,{htmlFor:v,children:`Mật khẩu`}),(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(n.Input,{id:v,type:E?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:S,onChange:e=>C(e.target.value),"aria-invalid":!!A.password,disabled:p,className:`pr-10`}),(0,s.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),D(e=>!e)},"aria-label":E?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:E?(0,s.jsx)(a.EyeOff,{size:16}):(0,s.jsx)(a.Eye,{size:16})})]}),A.password?(0,s.jsx)(`p`,{className:`text-destructive text-xs`,children:A.password}):(0,s.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,s.jsx)(r.Label,{htmlFor:y,children:`Xác nhận mật khẩu`}),(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(n.Input,{id:y,type:O?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:w,onChange:e=>T(e.target.value),"aria-invalid":!!A.confirmPassword,disabled:p,className:`pr-10`}),(0,s.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),k(e=>!e)},"aria-label":O?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:O?(0,s.jsx)(a.EyeOff,{size:16}):(0,s.jsx)(a.Eye,{size:16})})]}),A.confirmPassword&&(0,s.jsx)(`p`,{className:`text-destructive text-xs`,children:A.confirmPassword})]}),(0,s.jsx)(e.Button,{type:`submit`,isLoading:p,className:`w-full`,children:`Đăng ký`}),(0,s.jsx)(e.Button,{type:`button`,variant:`outline`,className:`w-full`,disabled:p,onClick:()=>u(!1),children:`Đóng hộp thoại`})]}),f&&(0,s.jsxs)(`div`,{className:`flex justify-center gap-1 text-muted-foreground text-sm`,children:[(0,s.jsx)(`span`,{children:`Đã có tài khoản?`}),(0,s.jsx)(e.Button,{variant:`link`,size:`sm`,className:`h-auto p-0`,onClick:f,children:`Đăng nhập`})]})]})})};exports.RegisterPage=u;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../ui/button.cjs"),t=require("../features/logo/index.cjs"),n=require("../ui/dialog.cjs"),r=require("../ui/input.cjs"),i=require("../ui/label.cjs"),a=require("../alert-D31c6DLq.cjs");let o=require("lucide-react"),s=require("react"),c=require("react/jsx-runtime"),l=require("zod");const u=l.z.object({email:l.z.string().min(1,`Vui lòng nhập email`).email(`Email không hợp lệ`),password:l.z.string().min(8,`Mật khẩu phải có ít nhất 8 ký tự`).max(50,`Mật khẩu không được vượt quá 50 ký tự`).regex(/[A-Z]/,`Phải có ít nhất một chữ hoa`).regex(/[a-z]/,`Phải có ít nhất một chữ thường`).regex(/[0-9]/,`Phải có ít nhất một chữ số`).regex(/[^A-Za-z0-9]/,`Phải có ít nhất một ký tự đặc biệt`),confirmPassword:l.z.string().min(1,`Vui lòng xác nhận mật khẩu`)}).refine(e=>e.password===e.confirmPassword,{message:`Mật khẩu xác nhận không khớp`,path:[`confirmPassword`]}),d=({open:l,onOpenChange:d,onRegister:f,onLogin:p,isLoading:m=!1,errorMessage:h,title:g=`Đăng ký`,subtitle:_=`Tạo tài khoản mới để bắt đầu`})=>{let v=(0,s.useId)(),y=(0,s.useId)(),b=(0,s.useId)(),[x,S]=(0,s.useState)(``),[C,w]=(0,s.useState)(``),[T,E]=(0,s.useState)(``),[D,O]=(0,s.useState)(!1),[k,A]=(0,s.useState)(!1),[j,M]=(0,s.useState)({});return(0,c.jsx)(n.Dialog,{open:l,onOpenChange:d,children:(0,c.jsxs)(n.DialogContent,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[(0,c.jsxs)(n.DialogHeader,{children:[(0,c.jsx)(t.LunasLogo,{variant:`horizontal`,size:`sm`,className:`mx-auto`}),(0,c.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,c.jsx)(n.DialogTitle,{children:g}),(0,c.jsx)(n.DialogDescription,{children:_})]})]}),(0,c.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault();let t=u.safeParse({email:x,password:C,confirmPassword:T});if(!t.success){let e=t.error.flatten().fieldErrors;M({email:e.email?.[0],password:e.password?.[0],confirmPassword:e.confirmPassword?.[0]});return}M({}),await f(x,C)},noValidate:!0,className:`flex flex-col gap-4`,children:[h&&(0,c.jsx)(a.t,{variant:`destructive`,children:(0,c.jsx)(a.n,{children:h})}),(0,c.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,c.jsx)(i.Label,{htmlFor:v,children:`Email`}),(0,c.jsx)(r.Input,{id:v,type:`email`,autoComplete:`email`,placeholder:`you@example.com`,value:x,onChange:e=>S(e.target.value),"aria-invalid":!!j.email,disabled:m}),j.email&&(0,c.jsx)(`p`,{className:`text-destructive text-xs`,children:j.email})]}),(0,c.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,c.jsx)(i.Label,{htmlFor:y,children:`Mật khẩu`}),(0,c.jsxs)(`div`,{className:`relative`,children:[(0,c.jsx)(r.Input,{id:y,type:D?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:C,onChange:e=>w(e.target.value),"aria-invalid":!!j.password,disabled:m,className:`pr-10`}),(0,c.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),O(e=>!e)},"aria-label":D?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:D?(0,c.jsx)(o.EyeOff,{size:16}):(0,c.jsx)(o.Eye,{size:16})})]}),j.password?(0,c.jsx)(`p`,{className:`text-destructive text-xs`,children:j.password}):(0,c.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.`})]}),(0,c.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,c.jsx)(i.Label,{htmlFor:b,children:`Xác nhận mật khẩu`}),(0,c.jsxs)(`div`,{className:`relative`,children:[(0,c.jsx)(r.Input,{id:b,type:k?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:T,onChange:e=>E(e.target.value),"aria-invalid":!!j.confirmPassword,disabled:m,className:`pr-10`}),(0,c.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),A(e=>!e)},"aria-label":k?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:k?(0,c.jsx)(o.EyeOff,{size:16}):(0,c.jsx)(o.Eye,{size:16})})]}),j.confirmPassword&&(0,c.jsx)(`p`,{className:`text-destructive text-xs`,children:j.confirmPassword})]}),(0,c.jsx)(e.Button,{type:`submit`,isLoading:m,className:`w-full`,children:`Đăng ký`}),(0,c.jsx)(e.Button,{type:`button`,variant:`outline`,className:`w-full`,disabled:m,onClick:()=>d(!1),children:`Đóng hộp thoại`})]}),p&&(0,c.jsxs)(`div`,{className:`flex justify-center gap-1 text-muted-foreground text-sm`,children:[(0,c.jsx)(`span`,{children:`Đã có tài khoản?`}),(0,c.jsx)(e.Button,{variant:`link`,size:`sm`,className:`h-auto p-0`,onClick:p,children:`Đăng nhập`})]})]})})};exports.RegisterPage=d;
2
2
  //# sourceMappingURL=RegisterPage.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegisterPage.cjs","names":["z","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription","Alert","AlertDescription","Label","Input","EyeOff","Eye","Button"],"sources":["../../packages/components/pages/RegisterPage.tsx"],"sourcesContent":["'use client';\n\nimport { useId, useState } from 'react';\n\nimport { Eye, EyeOff } from 'lucide-react';\nimport { z } from 'zod';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { Input } from '../ui/input';\nimport { Label } from '../ui/label';\n\nexport interface RegisterPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** Called when the user submits registration credentials */\n onRegister: (email: string, password: string) => Promise<void> | void;\n /** Called when the \"Đăng nhập\" link is clicked */\n onLogin?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Đăng ký\" */\n title?: string;\n /** Dialog subheading. Default: \"Tạo tài khoản mới để bắt đầu\" */\n subtitle?: string;\n}\n\nconst registerSchema = z\n .object({\n email: z.string().min(1, 'Vui lòng nhập email').email('Email không hợp lệ'),\n password: z\n .string()\n .min(8, 'Mật khẩu phải có ít nhất 8 ký tự')\n .max(50, 'Mật khẩu không được vượt quá 50 ký tự')\n .regex(/[A-Z]/, 'Phải có ít nhất một chữ hoa')\n .regex(/[a-z]/, 'Phải có ít nhất một chữ thường')\n .regex(/[0-9]/, 'Phải có ít nhất một chữ số')\n .regex(/[^A-Za-z0-9]/, 'Phải có ít nhất một ký tự đặc biệt'),\n confirmPassword: z.string().min(1, 'Vui lòng xác nhận mật khẩu'),\n })\n .refine(data => data.password === data.confirmPassword, {\n message: 'Mật khẩu xác nhận không khớp',\n path: ['confirmPassword'],\n });\n\n/**\n * Modal registration dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { RegisterPage } from '@customafk/lunas-ui/pages/RegisterPage';\n *\n * <RegisterPage\n * open={open}\n * onOpenChange={setOpen}\n * onRegister={async (email, password) => {\n * await authService.register(email, password);\n * setOpen(false);\n * }}\n * onLogin={() => { setOpen(false); setLoginOpen(true); }}\n * />\n * ```\n */\nexport const RegisterPage = ({\n open,\n onOpenChange,\n onRegister,\n onLogin,\n isLoading = false,\n errorMessage,\n title = 'Đăng ký',\n subtitle = 'Tạo tài khoản mới để bắt đầu',\n}: RegisterPageProps) => {\n const emailId = useId();\n const passwordId = useId();\n const confirmPasswordId = useId();\n const [email, setEmail] = useState('');\n const [password, setPassword] = useState('');\n const [confirmPassword, setConfirmPassword] = useState('');\n const [showPassword, setShowPassword] = useState(false);\n const [showConfirmPassword, setShowConfirmPassword] = useState(false);\n const [fieldErrors, setFieldErrors] = useState<{\n email?: string;\n password?: string;\n confirmPassword?: string;\n }>({});\n\n const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n const result = registerSchema.safeParse({ email, password, confirmPassword });\n if (!result.success) {\n const errors = result.error.flatten().fieldErrors;\n setFieldErrors({\n email: errors.email?.[0],\n password: errors.password?.[0],\n confirmPassword: errors.confirmPassword?.[0],\n });\n return;\n }\n setFieldErrors({});\n await onRegister(email, password);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{subtitle}</DialogDescription>\n </DialogHeader>\n\n <form onSubmit={handleSubmit} noValidate className=\"flex flex-col gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={emailId}>Email</Label>\n <Input\n id={emailId}\n type=\"email\"\n autoComplete=\"email\"\n placeholder=\"you@example.com\"\n value={email}\n onChange={e => setEmail(e.target.value)}\n aria-invalid={!!fieldErrors.email}\n disabled={isLoading}\n />\n {fieldErrors.email && <p className=\"text-destructive text-xs\">{fieldErrors.email}</p>}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={passwordId}>Mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={passwordId}\n type={showPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={password}\n onChange={e => setPassword(e.target.value)}\n aria-invalid={!!fieldErrors.password}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowPassword(v => !v);\n }}\n aria-label={showPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.password ? (\n <p className=\"text-destructive text-xs\">{fieldErrors.password}</p>\n ) : (\n <p className=\"text-muted-foreground text-xs\">Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.</p>\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={confirmPasswordId}>Xác nhận mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={confirmPasswordId}\n type={showConfirmPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={confirmPassword}\n onChange={e => setConfirmPassword(e.target.value)}\n aria-invalid={!!fieldErrors.confirmPassword}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowConfirmPassword(v => !v);\n }}\n aria-label={showConfirmPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showConfirmPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.confirmPassword && <p className=\"text-destructive text-xs\">{fieldErrors.confirmPassword}</p>}\n </div>\n\n <Button type=\"submit\" isLoading={isLoading} className=\"w-full\">\n Đăng ký\n </Button>\n <Button type=\"button\" variant=\"outline\" className=\"w-full\" disabled={isLoading} onClick={() => onOpenChange(false)}>\n Đóng hộp thoại\n </Button>\n </form>\n\n {onLogin && (\n <div className=\"flex justify-center gap-1 text-muted-foreground text-sm\">\n <span>Đã có tài khoản?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" onClick={onLogin}>\n Đăng nhập\n </Button>\n </div>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"gVAgCA,MAAM,EAAiBA,EAAAA,EACpB,OAAO,CACN,MAAOA,EAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,EAAG,qBAAqB,CAAC,CAAC,MAAM,oBAAoB,EAC1E,SAAUA,EAAAA,EACP,OAAO,CAAC,CACR,IAAI,EAAG,kCAAkC,CAAC,CAC1C,IAAI,GAAI,uCAAuC,CAAC,CAChD,MAAM,QAAS,6BAA6B,CAAC,CAC7C,MAAM,QAAS,gCAAgC,CAAC,CAChD,MAAM,QAAS,4BAA4B,CAAC,CAC5C,MAAM,eAAgB,oCAAoC,EAC7D,gBAAiBA,EAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,EAAG,4BAA4B,CACjE,CAAC,CAAC,CACD,OAAO,GAAQ,EAAK,WAAa,EAAK,gBAAiB,CACtD,Q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,kBAAS,SAEvD,CAAA,GACR,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,KAAK,SAAS,QAAQ,UAAU,UAAU,SAAS,SAAU,EAAW,YAAe,EAAa,EAAK,WAAG,gBAE5G,CAAA,CACJ,IAEL,IACC,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,mEAAf,EACE,EAAA,EAAA,IAAA,CAAC,OAAD,CAAA,SAAM,kBAAsB,CAAA,GAC5B,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,QAAQ,OAAO,KAAK,KAAK,UAAU,aAAa,QAAS,WAAS,WAElE,CAAA,CACL,GAEM,GACT,CAAA,CAEZ"}
1
+ {"version":3,"file":"RegisterPage.cjs","names":["z","Dialog","DialogContent","DialogHeader","LunasLogo","DialogTitle","DialogDescription","Alert","AlertDescription","Label","Input","EyeOff","Eye","Button"],"sources":["../../packages/components/pages/RegisterPage.tsx"],"sourcesContent":["'use client';\n\nimport { useId, useState } from 'react';\n\nimport { Eye, EyeOff } from 'lucide-react';\nimport { z } from 'zod';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { LunasLogo } from '../features/logo';\nimport { Input } from '../ui/input';\nimport { Label } from '../ui/label';\n\nexport interface RegisterPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** Called when the user submits registration credentials */\n onRegister: (email: string, password: string) => Promise<void> | void;\n /** Called when the \"Đăng nhập\" link is clicked */\n onLogin?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Đăng ký\" */\n title?: string;\n /** Dialog subheading. Default: \"Tạo tài khoản mới để bắt đầu\" */\n subtitle?: string;\n}\n\nconst registerSchema = z\n .object({\n email: z.string().min(1, 'Vui lòng nhập email').email('Email không hợp lệ'),\n password: z\n .string()\n .min(8, 'Mật khẩu phải có ít nhất 8 ký tự')\n .max(50, 'Mật khẩu không được vượt quá 50 ký tự')\n .regex(/[A-Z]/, 'Phải có ít nhất một chữ hoa')\n .regex(/[a-z]/, 'Phải có ít nhất một chữ thường')\n .regex(/[0-9]/, 'Phải có ít nhất một chữ số')\n .regex(/[^A-Za-z0-9]/, 'Phải có ít nhất một ký tự đặc biệt'),\n confirmPassword: z.string().min(1, 'Vui lòng xác nhận mật khẩu'),\n })\n .refine(data => data.password === data.confirmPassword, {\n message: 'Mật khẩu xác nhận không khớp',\n path: ['confirmPassword'],\n });\n\n/**\n * Modal registration dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { RegisterPage } from '@customafk/lunas-ui/pages/RegisterPage';\n *\n * <RegisterPage\n * open={open}\n * onOpenChange={setOpen}\n * onRegister={async (email, password) => {\n * await authService.register(email, password);\n * setOpen(false);\n * }}\n * onLogin={() => { setOpen(false); setLoginOpen(true); }}\n * />\n * ```\n */\nexport const RegisterPage = ({\n open,\n onOpenChange,\n onRegister,\n onLogin,\n isLoading = false,\n errorMessage,\n title = 'Đăng ký',\n subtitle = 'Tạo tài khoản mới để bắt đầu',\n}: RegisterPageProps) => {\n const emailId = useId();\n const passwordId = useId();\n const confirmPasswordId = useId();\n const [email, setEmail] = useState('');\n const [password, setPassword] = useState('');\n const [confirmPassword, setConfirmPassword] = useState('');\n const [showPassword, setShowPassword] = useState(false);\n const [showConfirmPassword, setShowConfirmPassword] = useState(false);\n const [fieldErrors, setFieldErrors] = useState<{\n email?: string;\n password?: string;\n confirmPassword?: string;\n }>({});\n\n const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n const result = registerSchema.safeParse({ email, password, confirmPassword });\n if (!result.success) {\n const errors = result.error.flatten().fieldErrors;\n setFieldErrors({\n email: errors.email?.[0],\n password: errors.password?.[0],\n confirmPassword: errors.confirmPassword?.[0],\n });\n return;\n }\n setFieldErrors({});\n await onRegister(email, password);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <LunasLogo variant=\"horizontal\" size=\"sm\" className=\"mx-auto\" />\n <div className=\"flex flex-col gap-0.5\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{subtitle}</DialogDescription>\n </div>\n </DialogHeader>\n\n <form onSubmit={handleSubmit} noValidate className=\"flex flex-col gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={emailId}>Email</Label>\n <Input\n id={emailId}\n type=\"email\"\n autoComplete=\"email\"\n placeholder=\"you@example.com\"\n value={email}\n onChange={e => setEmail(e.target.value)}\n aria-invalid={!!fieldErrors.email}\n disabled={isLoading}\n />\n {fieldErrors.email && <p className=\"text-destructive text-xs\">{fieldErrors.email}</p>}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={passwordId}>Mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={passwordId}\n type={showPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={password}\n onChange={e => setPassword(e.target.value)}\n aria-invalid={!!fieldErrors.password}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowPassword(v => !v);\n }}\n aria-label={showPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.password ? (\n <p className=\"text-destructive text-xs\">{fieldErrors.password}</p>\n ) : (\n <p className=\"text-muted-foreground text-xs\">Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.</p>\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={confirmPasswordId}>Xác nhận mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={confirmPasswordId}\n type={showConfirmPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={confirmPassword}\n onChange={e => setConfirmPassword(e.target.value)}\n aria-invalid={!!fieldErrors.confirmPassword}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowConfirmPassword(v => !v);\n }}\n aria-label={showConfirmPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showConfirmPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.confirmPassword && <p className=\"text-destructive text-xs\">{fieldErrors.confirmPassword}</p>}\n </div>\n\n <Button type=\"submit\" isLoading={isLoading} className=\"w-full\">\n Đăng ký\n </Button>\n <Button type=\"button\" variant=\"outline\" className=\"w-full\" disabled={isLoading} onClick={() => onOpenChange(false)}>\n Đóng hộp thoại\n </Button>\n </form>\n\n {onLogin && (\n <div className=\"flex justify-center gap-1 text-muted-foreground text-sm\">\n <span>Đã có tài khoản?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" onClick={onLogin}>\n Đăng nhập\n </Button>\n </div>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"wXAiCA,MAAM,EAAiBA,EAAAA,EACpB,OAAO,CACN,MA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Z,MAAO,EACP,SAAU,GAAK,EAAmB,EAAE,OAAO,KAAK,EAChD,eAAc,CAAC,CAAC,EAAY,gBAC5B,SAAU,EACV,UAAU,OACX,CAAA,GACD,EAAA,EAAA,IAAA,CAAC,SAAD,CACE,KAAK,SACL,UAAU,gGACV,YAAa,GAAK,CAChB,EAAE,eAAe,EACjB,EAAuB,GAAK,CAAC,CAAC,CAChC,EACA,aAAY,EAAsB,cAAgB,yBAEjD,GAAsB,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CAAQ,KAAM,EAAK,CAAA,GAAI,EAAA,EAAA,IAAA,CAACC,EAAAA,IAAD,CAAK,KAAM,EAAK,CAAA,CACxD,CAAA,CACL,IACJ,EAAY,kBAAmB,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,oCAA4B,EAAY,eAAmB,CAAA,CACrG,KAEL,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CAAQ,KAAK,SAAoB,YAAW,UAAU,kBAAS,SAEvD,CAAA,GACR,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,KAAK,SAAS,QAAQ,UAAU,UAAU,SAAS,SAAU,EAAW,YAAe,EAAa,EAAK,WAAG,gBAE5G,CAAA,CACJ,IAEL,IACC,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,mEAAf,EACE,EAAA,EAAA,IAAA,CAAC,OAAD,CAAA,SAAM,kBAAsB,CAAA,GAC5B,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,QAAQ,OAAO,KAAK,KAAK,UAAU,aAAa,QAAS,WAAS,WAElE,CAAA,CACL,GAEM,GACT,CAAA,CAEZ"}
@@ -1,2 +1,2 @@
1
- "use client";import{Button as e}from"../ui/button.mjs";import{Dialog as t,DialogContent as n,DialogDescription as r,DialogHeader as i,DialogTitle as a}from"../ui/dialog.mjs";import{Input as o}from"../ui/input.mjs";import{Label as s}from"../ui/label.mjs";import{n as c,t as l}from"../alert-OD1KJTEV.mjs";import{Eye as u,EyeOff as d}from"lucide-react";import{useId as f,useState as p}from"react";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{z as g}from"zod";const _=g.object({email:g.string().min(1,`Vui lòng nhập email`).email(`Email không hợp lệ`),password:g.string().min(8,`Mật khẩu phải có ít nhất 8 ký tự`).max(50,`Mật khẩu không được vượt quá 50 ký tự`).regex(/[A-Z]/,`Phải có ít nhất một chữ hoa`).regex(/[a-z]/,`Phải có ít nhất một chữ thường`).regex(/[0-9]/,`Phải có ít nhất một chữ số`).regex(/[^A-Za-z0-9]/,`Phải có ít nhất một ký tự đặc biệt`),confirmPassword:g.string().min(1,`Vui lòng xác nhận mật khẩu`)}).refine(e=>e.password===e.confirmPassword,{message:`Mật khẩu xác nhận không khớp`,path:[`confirmPassword`]}),v=({open:g,onOpenChange:v,onRegister:y,onLogin:b,isLoading:x=!1,errorMessage:S,title:C=`Đăng ký`,subtitle:w=`Tạo tài khoản mới để bắt đầu`})=>{let T=f(),E=f(),D=f(),[O,k]=p(``),[A,j]=p(``),[M,N]=p(``),[P,F]=p(!1),[I,L]=p(!1),[R,z]=p({});return m(t,{open:g,onOpenChange:v,children:h(n,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[h(i,{children:[m(a,{children:C}),m(r,{children:w})]}),h(`form`,{onSubmit:async e=>{e.preventDefault();let t=_.safeParse({email:O,password:A,confirmPassword:M});if(!t.success){let e=t.error.flatten().fieldErrors;z({email:e.email?.[0],password:e.password?.[0],confirmPassword:e.confirmPassword?.[0]});return}z({}),await y(O,A)},noValidate:!0,className:`flex flex-col gap-4`,children:[S&&m(l,{variant:`destructive`,children:m(c,{children:S})}),h(`div`,{className:`flex flex-col gap-1.5`,children:[m(s,{htmlFor:T,children:`Email`}),m(o,{id:T,type:`email`,autoComplete:`email`,placeholder:`you@example.com`,value:O,onChange:e=>k(e.target.value),"aria-invalid":!!R.email,disabled:x}),R.email&&m(`p`,{className:`text-destructive text-xs`,children:R.email})]}),h(`div`,{className:`flex flex-col gap-1.5`,children:[m(s,{htmlFor:E,children:`Mật khẩu`}),h(`div`,{className:`relative`,children:[m(o,{id:E,type:P?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:A,onChange:e=>j(e.target.value),"aria-invalid":!!R.password,disabled:x,className:`pr-10`}),m(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),F(e=>!e)},"aria-label":P?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:m(P?d:u,{size:16})})]}),R.password?m(`p`,{className:`text-destructive text-xs`,children:R.password}):m(`p`,{className:`text-muted-foreground text-xs`,children:`Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.`})]}),h(`div`,{className:`flex flex-col gap-1.5`,children:[m(s,{htmlFor:D,children:`Xác nhận mật khẩu`}),h(`div`,{className:`relative`,children:[m(o,{id:D,type:I?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:M,onChange:e=>N(e.target.value),"aria-invalid":!!R.confirmPassword,disabled:x,className:`pr-10`}),m(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),L(e=>!e)},"aria-label":I?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:m(I?d:u,{size:16})})]}),R.confirmPassword&&m(`p`,{className:`text-destructive text-xs`,children:R.confirmPassword})]}),m(e,{type:`submit`,isLoading:x,className:`w-full`,children:`Đăng ký`}),m(e,{type:`button`,variant:`outline`,className:`w-full`,disabled:x,onClick:()=>v(!1),children:`Đóng hộp thoại`})]}),b&&h(`div`,{className:`flex justify-center gap-1 text-muted-foreground text-sm`,children:[m(`span`,{children:`Đã có tài khoản?`}),m(e,{variant:`link`,size:`sm`,className:`h-auto p-0`,onClick:b,children:`Đăng nhập`})]})]})})};export{v as RegisterPage};
1
+ "use client";import{Button as e}from"../ui/button.mjs";import{LunasLogo as t}from"../features/logo/index.mjs";import{Dialog as n,DialogContent as r,DialogDescription as i,DialogHeader as a,DialogTitle as o}from"../ui/dialog.mjs";import{Input as s}from"../ui/input.mjs";import{Label as c}from"../ui/label.mjs";import{n as l,t as u}from"../alert-OD1KJTEV.mjs";import{Eye as d,EyeOff as f}from"lucide-react";import{useId as p,useState as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";import{z as _}from"zod";const v=_.object({email:_.string().min(1,`Vui lòng nhập email`).email(`Email không hợp lệ`),password:_.string().min(8,`Mật khẩu phải có ít nhất 8 ký tự`).max(50,`Mật khẩu không được vượt quá 50 ký tự`).regex(/[A-Z]/,`Phải có ít nhất một chữ hoa`).regex(/[a-z]/,`Phải có ít nhất một chữ thường`).regex(/[0-9]/,`Phải có ít nhất một chữ số`).regex(/[^A-Za-z0-9]/,`Phải có ít nhất một ký tự đặc biệt`),confirmPassword:_.string().min(1,`Vui lòng xác nhận mật khẩu`)}).refine(e=>e.password===e.confirmPassword,{message:`Mật khẩu xác nhận không khớp`,path:[`confirmPassword`]}),y=({open:_,onOpenChange:y,onRegister:b,onLogin:x,isLoading:S=!1,errorMessage:C,title:w=`Đăng ký`,subtitle:T=`Tạo tài khoản mới để bắt đầu`})=>{let E=p(),D=p(),O=p(),[k,A]=m(``),[j,M]=m(``),[N,P]=m(``),[F,I]=m(!1),[L,R]=m(!1),[z,B]=m({});return h(n,{open:_,onOpenChange:y,children:g(r,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[g(a,{children:[h(t,{variant:`horizontal`,size:`sm`,className:`mx-auto`}),g(`div`,{className:`flex flex-col gap-0.5`,children:[h(o,{children:w}),h(i,{children:T})]})]}),g(`form`,{onSubmit:async e=>{e.preventDefault();let t=v.safeParse({email:k,password:j,confirmPassword:N});if(!t.success){let e=t.error.flatten().fieldErrors;B({email:e.email?.[0],password:e.password?.[0],confirmPassword:e.confirmPassword?.[0]});return}B({}),await b(k,j)},noValidate:!0,className:`flex flex-col gap-4`,children:[C&&h(u,{variant:`destructive`,children:h(l,{children:C})}),g(`div`,{className:`flex flex-col gap-1.5`,children:[h(c,{htmlFor:E,children:`Email`}),h(s,{id:E,type:`email`,autoComplete:`email`,placeholder:`you@example.com`,value:k,onChange:e=>A(e.target.value),"aria-invalid":!!z.email,disabled:S}),z.email&&h(`p`,{className:`text-destructive text-xs`,children:z.email})]}),g(`div`,{className:`flex flex-col gap-1.5`,children:[h(c,{htmlFor:D,children:`Mật khẩu`}),g(`div`,{className:`relative`,children:[h(s,{id:D,type:F?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:j,onChange:e=>M(e.target.value),"aria-invalid":!!z.password,disabled:S,className:`pr-10`}),h(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),I(e=>!e)},"aria-label":F?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:h(F?f:d,{size:16})})]}),z.password?h(`p`,{className:`text-destructive text-xs`,children:z.password}):h(`p`,{className:`text-muted-foreground text-xs`,children:`Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.`})]}),g(`div`,{className:`flex flex-col gap-1.5`,children:[h(c,{htmlFor:O,children:`Xác nhận mật khẩu`}),g(`div`,{className:`relative`,children:[h(s,{id:O,type:L?`text`:`password`,autoComplete:`new-password`,placeholder:`••••••••`,value:N,onChange:e=>P(e.target.value),"aria-invalid":!!z.confirmPassword,disabled:S,className:`pr-10`}),h(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground`,onMouseDown:e=>{e.preventDefault(),R(e=>!e)},"aria-label":L?`Ẩn mật khẩu`:`Hiện mật khẩu`,children:h(L?f:d,{size:16})})]}),z.confirmPassword&&h(`p`,{className:`text-destructive text-xs`,children:z.confirmPassword})]}),h(e,{type:`submit`,isLoading:S,className:`w-full`,children:`Đăng ký`}),h(e,{type:`button`,variant:`outline`,className:`w-full`,disabled:S,onClick:()=>y(!1),children:`Đóng hộp thoại`})]}),x&&g(`div`,{className:`flex justify-center gap-1 text-muted-foreground text-sm`,children:[h(`span`,{children:`Đã có tài khoản?`}),h(e,{variant:`link`,size:`sm`,className:`h-auto p-0`,onClick:x,children:`Đăng nhập`})]})]})})};export{y as RegisterPage};
2
2
  //# sourceMappingURL=RegisterPage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegisterPage.mjs","names":[],"sources":["../../packages/components/pages/RegisterPage.tsx"],"sourcesContent":["'use client';\n\nimport { useId, useState } from 'react';\n\nimport { Eye, EyeOff } from 'lucide-react';\nimport { z } from 'zod';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { Input } from '../ui/input';\nimport { Label } from '../ui/label';\n\nexport interface RegisterPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** Called when the user submits registration credentials */\n onRegister: (email: string, password: string) => Promise<void> | void;\n /** Called when the \"Đăng nhập\" link is clicked */\n onLogin?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Đăng ký\" */\n title?: string;\n /** Dialog subheading. Default: \"Tạo tài khoản mới để bắt đầu\" */\n subtitle?: string;\n}\n\nconst registerSchema = z\n .object({\n email: z.string().min(1, 'Vui lòng nhập email').email('Email không hợp lệ'),\n password: z\n .string()\n .min(8, 'Mật khẩu phải có ít nhất 8 ký tự')\n .max(50, 'Mật khẩu không được vượt quá 50 ký tự')\n .regex(/[A-Z]/, 'Phải có ít nhất một chữ hoa')\n .regex(/[a-z]/, 'Phải có ít nhất một chữ thường')\n .regex(/[0-9]/, 'Phải có ít nhất một chữ số')\n .regex(/[^A-Za-z0-9]/, 'Phải có ít nhất một ký tự đặc biệt'),\n confirmPassword: z.string().min(1, 'Vui lòng xác nhận mật khẩu'),\n })\n .refine(data => data.password === data.confirmPassword, {\n message: 'Mật khẩu xác nhận không khớp',\n path: ['confirmPassword'],\n });\n\n/**\n * Modal registration dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { RegisterPage } from '@customafk/lunas-ui/pages/RegisterPage';\n *\n * <RegisterPage\n * open={open}\n * onOpenChange={setOpen}\n * onRegister={async (email, password) => {\n * await authService.register(email, password);\n * setOpen(false);\n * }}\n * onLogin={() => { setOpen(false); setLoginOpen(true); }}\n * />\n * ```\n */\nexport const RegisterPage = ({\n open,\n onOpenChange,\n onRegister,\n onLogin,\n isLoading = false,\n errorMessage,\n title = 'Đăng ký',\n subtitle = 'Tạo tài khoản mới để bắt đầu',\n}: RegisterPageProps) => {\n const emailId = useId();\n const passwordId = useId();\n const confirmPasswordId = useId();\n const [email, setEmail] = useState('');\n const [password, setPassword] = useState('');\n const [confirmPassword, setConfirmPassword] = useState('');\n const [showPassword, setShowPassword] = useState(false);\n const [showConfirmPassword, setShowConfirmPassword] = useState(false);\n const [fieldErrors, setFieldErrors] = useState<{\n email?: string;\n password?: string;\n confirmPassword?: string;\n }>({});\n\n const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n const result = registerSchema.safeParse({ email, password, confirmPassword });\n if (!result.success) {\n const errors = result.error.flatten().fieldErrors;\n setFieldErrors({\n email: errors.email?.[0],\n password: errors.password?.[0],\n confirmPassword: errors.confirmPassword?.[0],\n });\n return;\n }\n setFieldErrors({});\n await onRegister(email, password);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{subtitle}</DialogDescription>\n </DialogHeader>\n\n <form onSubmit={handleSubmit} noValidate className=\"flex flex-col gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={emailId}>Email</Label>\n <Input\n id={emailId}\n type=\"email\"\n autoComplete=\"email\"\n placeholder=\"you@example.com\"\n value={email}\n onChange={e => setEmail(e.target.value)}\n aria-invalid={!!fieldErrors.email}\n disabled={isLoading}\n />\n {fieldErrors.email && <p className=\"text-destructive text-xs\">{fieldErrors.email}</p>}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={passwordId}>Mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={passwordId}\n type={showPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={password}\n onChange={e => setPassword(e.target.value)}\n aria-invalid={!!fieldErrors.password}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowPassword(v => !v);\n }}\n aria-label={showPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.password ? (\n <p className=\"text-destructive text-xs\">{fieldErrors.password}</p>\n ) : (\n <p className=\"text-muted-foreground text-xs\">Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.</p>\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={confirmPasswordId}>Xác nhận mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={confirmPasswordId}\n type={showConfirmPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={confirmPassword}\n onChange={e => setConfirmPassword(e.target.value)}\n aria-invalid={!!fieldErrors.confirmPassword}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowConfirmPassword(v => !v);\n }}\n aria-label={showConfirmPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showConfirmPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.confirmPassword && <p className=\"text-destructive text-xs\">{fieldErrors.confirmPassword}</p>}\n </div>\n\n <Button type=\"submit\" isLoading={isLoading} className=\"w-full\">\n Đăng ký\n </Button>\n <Button type=\"button\" variant=\"outline\" className=\"w-full\" disabled={isLoading} onClick={() => onOpenChange(false)}>\n Đóng hộp thoại\n </Button>\n </form>\n\n {onLogin && (\n <div className=\"flex justify-center gap-1 text-muted-foreground text-sm\">\n <span>Đã có tài khoản?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" onClick={onLogin}>\n Đăng nhập\n </Button>\n </div>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"odAgCA,MAA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,SACX,EAAC,IAAD,CAAG,UAAU,oCAA4B,EAAY,QAAY,CAAA,EAEjE,EAAC,IAAD,CAAG,UAAU,yCAAgC,uEAAwE,CAAA,CAEpH,IAEL,EAAC,MAAD,CAAK,UAAU,iCAAf,CACE,EAAC,EAAD,CAAO,QAAS,WAAmB,mBAAwB,CAAA,EAC3D,EAAC,MAAD,CAAK,UAAU,oBAAf,CACE,EAAC,EAAD,CACE,GAAI,EACJ,KAAM,EAAsB,OAAS,WACrC,aAAa,eACb,YAAY,WACZ,MAAO,EACP,SAAU,GAAK,EAAmB,EAAE,OAAO,KAAK,EAChD,eAAc,CAAC,CAAC,EAAY,gBAC5B,SAAU,EACV,UAAU,OACX,CAAA,EACD,EAAC,SAAD,CACE,KAAK,SACL,UAAU,gGACV,YAAa,GAAK,CAChB,EAAE,eAAe,EACjB,EAAuB,GAAK,CAAC,CAAC,CAChC,EACA,aAAY,EAAsB,cAAgB,yBAE3B,EAAtB,EAAuB,EAAuB,EAAxB,CAAQ,KAAM,EAAK,CAAoB,CACxD,CAAA,CACL,IACJ,EAAY,iBAAmB,EAAC,IAAD,CAAG,UAAU,oCAA4B,EAAY,eAAmB,CAAA,CACrG,IAEL,EAAC,EAAD,CAAQ,KAAK,SAAoB,YAAW,UAAU,kBAAS,SAEvD,CAAA,EACR,EAAC,EAAD,CAAQ,KAAK,SAAS,QAAQ,UAAU,UAAU,SAAS,SAAU,EAAW,YAAe,EAAa,EAAK,WAAG,gBAE5G,CAAA,CACJ,IAEL,GACC,EAAC,MAAD,CAAK,UAAU,mEAAf,CACE,EAAC,OAAD,CAAA,SAAM,kBAAsB,CAAA,EAC5B,EAAC,EAAD,CAAQ,QAAQ,OAAO,KAAK,KAAK,UAAU,aAAa,QAAS,WAAS,WAElE,CAAA,CACL,GAEM,GACT,CAAA,CAEZ"}
1
+ {"version":3,"file":"RegisterPage.mjs","names":[],"sources":["../../packages/components/pages/RegisterPage.tsx"],"sourcesContent":["'use client';\n\nimport { useId, useState } from 'react';\n\nimport { Eye, EyeOff } from 'lucide-react';\nimport { z } from 'zod';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { LunasLogo } from '../features/logo';\nimport { Input } from '../ui/input';\nimport { Label } from '../ui/label';\n\nexport interface RegisterPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** Called when the user submits registration credentials */\n onRegister: (email: string, password: string) => Promise<void> | void;\n /** Called when the \"Đăng nhập\" link is clicked */\n onLogin?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Đăng ký\" */\n title?: string;\n /** Dialog subheading. Default: \"Tạo tài khoản mới để bắt đầu\" */\n subtitle?: string;\n}\n\nconst registerSchema = z\n .object({\n email: z.string().min(1, 'Vui lòng nhập email').email('Email không hợp lệ'),\n password: z\n .string()\n .min(8, 'Mật khẩu phải có ít nhất 8 ký tự')\n .max(50, 'Mật khẩu không được vượt quá 50 ký tự')\n .regex(/[A-Z]/, 'Phải có ít nhất một chữ hoa')\n .regex(/[a-z]/, 'Phải có ít nhất một chữ thường')\n .regex(/[0-9]/, 'Phải có ít nhất một chữ số')\n .regex(/[^A-Za-z0-9]/, 'Phải có ít nhất một ký tự đặc biệt'),\n confirmPassword: z.string().min(1, 'Vui lòng xác nhận mật khẩu'),\n })\n .refine(data => data.password === data.confirmPassword, {\n message: 'Mật khẩu xác nhận không khớp',\n path: ['confirmPassword'],\n });\n\n/**\n * Modal registration dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { RegisterPage } from '@customafk/lunas-ui/pages/RegisterPage';\n *\n * <RegisterPage\n * open={open}\n * onOpenChange={setOpen}\n * onRegister={async (email, password) => {\n * await authService.register(email, password);\n * setOpen(false);\n * }}\n * onLogin={() => { setOpen(false); setLoginOpen(true); }}\n * />\n * ```\n */\nexport const RegisterPage = ({\n open,\n onOpenChange,\n onRegister,\n onLogin,\n isLoading = false,\n errorMessage,\n title = 'Đăng ký',\n subtitle = 'Tạo tài khoản mới để bắt đầu',\n}: RegisterPageProps) => {\n const emailId = useId();\n const passwordId = useId();\n const confirmPasswordId = useId();\n const [email, setEmail] = useState('');\n const [password, setPassword] = useState('');\n const [confirmPassword, setConfirmPassword] = useState('');\n const [showPassword, setShowPassword] = useState(false);\n const [showConfirmPassword, setShowConfirmPassword] = useState(false);\n const [fieldErrors, setFieldErrors] = useState<{\n email?: string;\n password?: string;\n confirmPassword?: string;\n }>({});\n\n const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n const result = registerSchema.safeParse({ email, password, confirmPassword });\n if (!result.success) {\n const errors = result.error.flatten().fieldErrors;\n setFieldErrors({\n email: errors.email?.[0],\n password: errors.password?.[0],\n confirmPassword: errors.confirmPassword?.[0],\n });\n return;\n }\n setFieldErrors({});\n await onRegister(email, password);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <LunasLogo variant=\"horizontal\" size=\"sm\" className=\"mx-auto\" />\n <div className=\"flex flex-col gap-0.5\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{subtitle}</DialogDescription>\n </div>\n </DialogHeader>\n\n <form onSubmit={handleSubmit} noValidate className=\"flex flex-col gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={emailId}>Email</Label>\n <Input\n id={emailId}\n type=\"email\"\n autoComplete=\"email\"\n placeholder=\"you@example.com\"\n value={email}\n onChange={e => setEmail(e.target.value)}\n aria-invalid={!!fieldErrors.email}\n disabled={isLoading}\n />\n {fieldErrors.email && <p className=\"text-destructive text-xs\">{fieldErrors.email}</p>}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={passwordId}>Mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={passwordId}\n type={showPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={password}\n onChange={e => setPassword(e.target.value)}\n aria-invalid={!!fieldErrors.password}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowPassword(v => !v);\n }}\n aria-label={showPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.password ? (\n <p className=\"text-destructive text-xs\">{fieldErrors.password}</p>\n ) : (\n <p className=\"text-muted-foreground text-xs\">Tối thiểu 8 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.</p>\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={confirmPasswordId}>Xác nhận mật khẩu</Label>\n <div className=\"relative\">\n <Input\n id={confirmPasswordId}\n type={showConfirmPassword ? 'text' : 'password'}\n autoComplete=\"new-password\"\n placeholder=\"••••••••\"\n value={confirmPassword}\n onChange={e => setConfirmPassword(e.target.value)}\n aria-invalid={!!fieldErrors.confirmPassword}\n disabled={isLoading}\n className=\"pr-10\"\n />\n <button\n type=\"button\"\n className=\"absolute inset-y-0 right-0 flex items-center px-3 text-muted-foreground hover:text-foreground\"\n onMouseDown={e => {\n e.preventDefault();\n setShowConfirmPassword(v => !v);\n }}\n aria-label={showConfirmPassword ? 'Ẩn mật khẩu' : 'Hiện mật khẩu'}\n >\n {showConfirmPassword ? <EyeOff size={16} /> : <Eye size={16} />}\n </button>\n </div>\n {fieldErrors.confirmPassword && <p className=\"text-destructive text-xs\">{fieldErrors.confirmPassword}</p>}\n </div>\n\n <Button type=\"submit\" isLoading={isLoading} className=\"w-full\">\n Đăng ký\n </Button>\n <Button type=\"button\" variant=\"outline\" className=\"w-full\" disabled={isLoading} onClick={() => onOpenChange(false)}>\n Đóng hộp thoại\n </Button>\n </form>\n\n {onLogin && (\n <div className=\"flex justify-center gap-1 text-muted-foreground text-sm\">\n <span>Đã có tài khoản?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" onClick={onLogin}>\n Đăng nhập\n </Button>\n </div>\n )}\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"2gBAiCA,MAAM,EAAiB,EACpB,OAAO,CACN,MAAO,EAAE,OAAO,CAAC,CAAC,IAAI,EAAG,qBAAqB,CAAC,CAAC,MAAM,oBAAoB,EAC1E,SAAU,EACP,OAAO,CAAC,CACR,IAAI,EAAG,kCAAkC,CAAC,CAC1C,IAAI,GAAI,uCAAuC,CAAC,CAChD,MAAM,QAAS,6BAA6B,CAAC,CAC7C,MAAM,QAAS,gCAAgC,CAAC,CAChD,MAAM,QAAS,4BAA4B,CAAC,CAC5C,MAAM,eAAgB,oCAAoC,EAC7D,gBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,EAAG,4BAA4B,CACjE,CAAC,CAAC,CACD,OAAO,GAAQ,EAAK,WAAa,EAAK,gBAAiB,CACtD,QAAS,+BACT,KAAM,CAAC,iBAAiB,CAC1B,CAAC,EAoBU,GAAgB,CAC3B,OACA,eACA,aACA,UACA,YAAY,GACZ,eACA,QAAQ,UACR,WAAW,kCACY,CACvB,IAAM,EAAU,EAAM,EAChB,EAAa,EAAM,EACnB,EAAoB,EAAM,EAC1B,CAA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C,CAChC,EACA,aAAY,EAAsB,cAAgB,yBAE3B,EAAtB,EAAuB,EAAuB,EAAxB,CAAQ,KAAM,EAAK,CAAoB,CACxD,CAAA,CACL,IACJ,EAAY,iBAAmB,EAAC,IAAD,CAAG,UAAU,oCAA4B,EAAY,eAAmB,CAAA,CACrG,IAEL,EAAC,EAAD,CAAQ,KAAK,SAAoB,YAAW,UAAU,kBAAS,SAEvD,CAAA,EACR,EAAC,EAAD,CAAQ,KAAK,SAAS,QAAQ,UAAU,UAAU,SAAS,SAAU,EAAW,YAAe,EAAa,EAAK,WAAG,gBAE5G,CAAA,CACJ,IAEL,GACC,EAAC,MAAD,CAAK,UAAU,mEAAf,CACE,EAAC,OAAD,CAAA,SAAM,kBAAsB,CAAA,EAC5B,EAAC,EAAD,CAAQ,QAAQ,OAAO,KAAK,KAAK,UAAU,aAAa,QAAS,WAAS,WAElE,CAAA,CACL,GAEM,GACT,CAAA,CAEZ"}
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../ui/button.cjs"),t=require("../ui/dialog.cjs"),n=require("../alert-D31c6DLq.cjs"),r=require("../ui/input-otp.cjs");let i=require("react"),a=require("react/jsx-runtime");const o=({open:o,onOpenChange:s,email:c,onVerify:l,onResend:u,onBack:d,isLoading:f=!1,errorMessage:p,title:m=`Xác thực email`,subtitle:h,resendCooldownSeconds:g=60})=>{let[_,v]=(0,i.useState)(``),[y,b]=(0,i.useState)(g),x=(0,i.useRef)(null),S=(0,i.useCallback)(e=>{x.current&&clearInterval(x.current),b(e),x.current=setInterval(()=>{b(e=>e<=1?(x.current&&clearInterval(x.current),0):e-1)},1e3)},[]);(0,i.useEffect)(()=>(o&&g>0&&S(g),()=>{x.current&&clearInterval(x.current)}),[o,g,S]);let C=(0,i.useCallback)(async()=>{S(g),await u(c)},[c,u,g,S]),w=(0,i.useCallback)(async()=>{_.length<6||await l(c,_)},[c,_,l]);return(0,a.jsx)(t.Dialog,{open:o,onOpenChange:s,children:(0,a.jsxs)(t.DialogContent,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[(0,a.jsxs)(t.DialogHeader,{children:[(0,a.jsx)(t.DialogTitle,{children:m}),(0,a.jsx)(t.DialogDescription,{children:h??(0,a.jsxs)(a.Fragment,{children:[`Nhập mã OTP đã được gửi tới `,(0,a.jsx)(`span`,{className:`font-medium text-foreground`,children:c}),`. Mã có hiệu lực trong 10 phút.`]})})]}),(0,a.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[p&&(0,a.jsx)(n.t,{variant:`destructive`,className:`w-full`,children:(0,a.jsx)(n.n,{children:p})}),(0,a.jsxs)(r.InputOTP,{maxLength:6,value:_,onChange:v,onComplete:w,disabled:f,children:[(0,a.jsxs)(r.InputOTPGroup,{children:[(0,a.jsx)(r.InputOTPSlot,{index:0}),(0,a.jsx)(r.InputOTPSlot,{index:1}),(0,a.jsx)(r.InputOTPSlot,{index:2})]}),(0,a.jsx)(r.InputOTPSeparator,{}),(0,a.jsxs)(r.InputOTPGroup,{children:[(0,a.jsx)(r.InputOTPSlot,{index:3}),(0,a.jsx)(r.InputOTPSlot,{index:4}),(0,a.jsx)(r.InputOTPSlot,{index:5})]})]}),(0,a.jsx)(e.Button,{type:`button`,isLoading:f,disabled:_.length<6,className:`w-full`,onClick:w,children:`Xác thực`}),(0,a.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground text-sm`,children:[(0,a.jsx)(`span`,{children:`Chưa nhận được mã?`}),(0,a.jsx)(e.Button,{variant:`link`,size:`sm`,className:`h-auto p-0`,disabled:y>0||f,onClick:C,children:y>0?`Gửi lại (${y}s)`:`Gửi lại`})]}),d&&(0,a.jsx)(e.Button,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:d,children:`Quay lại`})]})]})})};exports.VerifyEmailPage=o;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../ui/button.cjs"),t=require("../features/logo/index.cjs"),n=require("../ui/dialog.cjs"),r=require("../alert-D31c6DLq.cjs"),i=require("../ui/input-otp.cjs");let a=require("react"),o=require("react/jsx-runtime");const s=({open:s,onOpenChange:c,email:l,onVerify:u,onResend:d,onBack:f,isLoading:p=!1,errorMessage:m,title:h=`Xác thực email`,subtitle:g,resendCooldownSeconds:_=60})=>{let[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(_),S=(0,a.useRef)(null),C=(0,a.useCallback)(e=>{S.current&&clearInterval(S.current),x(e),S.current=setInterval(()=>{x(e=>e<=1?(S.current&&clearInterval(S.current),0):e-1)},1e3)},[]);(0,a.useEffect)(()=>(s&&_>0&&C(_),()=>{S.current&&clearInterval(S.current)}),[s,_,C]);let w=(0,a.useCallback)(async()=>{C(_),await d(l)},[l,d,_,C]),T=(0,a.useCallback)(async()=>{v.length<6||await u(l,v)},[l,v,u]);return(0,o.jsx)(n.Dialog,{open:s,onOpenChange:c,children:(0,o.jsxs)(n.DialogContent,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[(0,o.jsxs)(n.DialogHeader,{children:[(0,o.jsx)(t.LunasLogo,{variant:`horizontal`,size:`sm`,className:`mx-auto`}),(0,o.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,o.jsx)(n.DialogTitle,{children:h}),(0,o.jsx)(n.DialogDescription,{children:g??(0,o.jsxs)(o.Fragment,{children:[`Nhập mã OTP đã được gửi tới `,(0,o.jsx)(`span`,{className:`font-medium text-foreground`,children:l}),`. Mã có hiệu lực trong 10 phút.`]})})]})]}),(0,o.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[m&&(0,o.jsx)(r.t,{variant:`destructive`,className:`w-full`,children:(0,o.jsx)(r.n,{children:m})}),(0,o.jsxs)(i.InputOTP,{maxLength:6,value:v,onChange:y,onComplete:T,disabled:p,children:[(0,o.jsxs)(i.InputOTPGroup,{children:[(0,o.jsx)(i.InputOTPSlot,{index:0}),(0,o.jsx)(i.InputOTPSlot,{index:1}),(0,o.jsx)(i.InputOTPSlot,{index:2})]}),(0,o.jsx)(i.InputOTPSeparator,{}),(0,o.jsxs)(i.InputOTPGroup,{children:[(0,o.jsx)(i.InputOTPSlot,{index:3}),(0,o.jsx)(i.InputOTPSlot,{index:4}),(0,o.jsx)(i.InputOTPSlot,{index:5})]})]}),(0,o.jsx)(e.Button,{type:`button`,isLoading:p,disabled:v.length<6,className:`w-full`,onClick:T,children:`Xác thực`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground text-sm`,children:[(0,o.jsx)(`span`,{children:`Chưa nhận được mã?`}),(0,o.jsx)(e.Button,{variant:`link`,size:`sm`,className:`h-auto p-0`,disabled:b>0||p,onClick:w,children:b>0?`Gửi lại (${b}s)`:`Gửi lại`})]}),f&&(0,o.jsx)(e.Button,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:f,children:`Quay lại`})]})]})})};exports.VerifyEmailPage=s;
2
2
  //# sourceMappingURL=VerifyEmailPage.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"VerifyEmailPage.cjs","names":["Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription","Alert","AlertDescription","InputOTP","InputOTPGroup","InputOTPSlot","InputOTPSeparator","Button"],"sources":["../../packages/components/pages/VerifyEmailPage.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from '../ui/input-otp';\n\nexport interface VerifyEmailPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** The email address the OTP was dispatched to — displayed as context and passed to callbacks */\n email: string;\n /** Called when the user submits the OTP code */\n onVerify: (email: string, otp: string) => Promise<void> | void;\n /** Called when the user requests a new OTP; triggers a fresh cooldown */\n onResend: (email: string) => Promise<void> | void;\n /** Called when the back link is clicked */\n onBack?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Xác thực email\" */\n title?: string;\n /** Dialog subheading. Default: built from the email prop */\n subtitle?: string;\n /** Seconds before the resend button becomes available. Default: 60 */\n resendCooldownSeconds?: number;\n}\n\n/**\n * Modal email OTP verification dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { VerifyEmailPage } from '@customafk/lunas-ui/pages/VerifyEmailPage';\n *\n * <VerifyEmailPage\n * open={open}\n * onOpenChange={setOpen}\n * email=\"user@example.com\"\n * onVerify={async (email, otp) => {\n * await authService.verifyEmail(email, otp);\n * setOpen(false);\n * }}\n * onResend={async (email) => {\n * await authService.resendVerification(email);\n * }}\n * />\n * ```\n */\nexport const VerifyEmailPage = ({\n open,\n onOpenChange,\n email,\n onVerify,\n onResend,\n onBack,\n isLoading = false,\n errorMessage,\n title = 'Xác thực email',\n subtitle,\n resendCooldownSeconds = 60,\n}: VerifyEmailPageProps) => {\n const [otp, setOtp] = useState('');\n const [countdown, setCountdown] = useState(resendCooldownSeconds);\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const startCountdown = useCallback((seconds: number) => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n setCountdown(seconds);\n intervalRef.current = setInterval(() => {\n setCountdown(prev => {\n if (prev <= 1) {\n if (intervalRef.current) clearInterval(intervalRef.current);\n return 0;\n }\n return prev - 1;\n });\n }, 1000);\n }, []);\n\n useEffect(() => {\n if (open && resendCooldownSeconds > 0) startCountdown(resendCooldownSeconds);\n return () => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n };\n }, [open, resendCooldownSeconds, startCountdown]);\n\n const handleResend = useCallback(async () => {\n startCountdown(resendCooldownSeconds);\n await onResend(email);\n }, [email, onResend, resendCooldownSeconds, startCountdown]);\n\n const handleVerify = useCallback(async () => {\n if (otp.length < 6) return;\n await onVerify(email, otp);\n }, [email, otp, onVerify]);\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>\n {subtitle ?? (\n <>\n Nhập mã OTP đã được gửi tới <span className=\"font-medium text-foreground\">{email}</span>. Mã có hiệu lực trong 10 phút.\n </>\n )}\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"flex flex-col items-center gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\" className=\"w-full\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <InputOTP maxLength={6} value={otp} onChange={setOtp} onComplete={handleVerify} disabled={isLoading}>\n <InputOTPGroup>\n <InputOTPSlot index={0} />\n <InputOTPSlot index={1} />\n <InputOTPSlot index={2} />\n </InputOTPGroup>\n <InputOTPSeparator />\n <InputOTPGroup>\n <InputOTPSlot index={3} />\n <InputOTPSlot index={4} />\n <InputOTPSlot index={5} />\n </InputOTPGroup>\n </InputOTP>\n\n <Button type=\"button\" isLoading={isLoading} disabled={otp.length < 6} className=\"w-full\" onClick={handleVerify}>\n Xác thực\n </Button>\n\n <div className=\"flex items-center gap-1 text-muted-foreground text-sm\">\n <span>Chưa nhận được mã?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" disabled={countdown > 0 || isLoading} onClick={handleResend}>\n {countdown > 0 ? `Gửi lại (${countdown}s)` : 'Gửi lại'}\n </Button>\n </div>\n\n {onBack && (\n <Button variant=\"ghost\" size=\"sm\" className=\"w-full\" onClick={onBack}>\n Quay lại\n </Button>\n )}\n </div>\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"4QAuDA,MAAa,GAAmB,CAC9B,OACA,eACA,QACA,WACA,WACA,SACA,YAAY,GACZ,eACA,QAAQ,iBACR,WACA,wBAAwB,MACE,CAC1B,GAAM,CAAC,EAAK,IAAA,EAAA,EAAA,SAAA,CAAmB,EAAE,EAC3B,CAAC,EAAW,IAAA,EAAA,EAAA,SAAA,CAAyB,CAAqB,EAC1D,GAAA,EAAA,EAAA,OAAA,CAA4D,IAAI,EAEhE,GAAA,EAAA,EAAA,YAAA,CAA8B,GAAoB,CAClD,EAAY,SAAS,cAAc,EAAY,OAAO,EAC1D,EAAa,CAAO,EACpB,EAAY,QAAU,gBAAkB,CACtC,EAAa,GACP,GAAQ,GACN,EAAY,SAAS,cAAc,EAAY,OAAO,EACnD,GAEF,EAAO,CACf,CACH,EAAG,GAAI,CACT,EAAG,CAAC,CAAC,GAEL,EAAA,EAAA,UAAA,MACM,GAAQ,EAAwB,GAAG,EAAe,CAAqB,MAC9D,CACP,EAAY,SAAS,cAAc,EAAY,OAAO,CAC5D,GACC,CAAC,EAAM,EAAuB,CAAc,CAAC,EAEhD,IAAM,GAAA,EAAA,EAAA,YAAA,CAA2B,SAAY,CAC3C,EAAe,CAAqB,EACpC,MAAM,EAAS,CAAK,CACtB,EAAG,C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,CAAA,CACZ,CAAA,CAAA,GACf,EAAA,EAAA,IAAA,CAACC,EAAAA,kBAAD,CAAoB,CAAA,GACpB,EAAA,EAAA,KAAA,CAACF,EAAAA,cAAD,CAAA,SAAA,EACE,EAAA,EAAA,IAAA,CAACC,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,GACzB,EAAA,EAAA,IAAA,CAACA,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,GACzB,EAAA,EAAA,IAAA,CAACA,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,CACZ,CAAA,CAAA,CACP,KAEV,EAAA,EAAA,IAAA,CAACE,EAAAA,OAAD,CAAQ,KAAK,SAAoB,YAAW,SAAU,EAAI,OAAS,EAAG,UAAU,SAAS,QAAS,WAAc,UAExG,CAAA,GAER,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,iEAAf,EACE,EAAA,EAAA,IAAA,CAAC,OAAD,CAAA,SAAM,oBAAwB,CAAA,GAC9B,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,QAAQ,OAAO,KAAK,KAAK,UAAU,aAAa,SAAU,EAAY,GAAK,EAAW,QAAS,WACpG,EAAY,EAAI,YAAY,EAAU,IAAM,SACvC,CAAA,CACL,IAEJ,IACC,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,QAAQ,QAAQ,KAAK,KAAK,UAAU,SAAS,QAAS,WAAQ,UAE9D,CAAA,CAEP,GACQ,GACT,CAAA,CAEZ"}
1
+ {"version":3,"file":"VerifyEmailPage.cjs","names":["Dialog","DialogContent","DialogHeader","LunasLogo","DialogTitle","DialogDescription","Alert","AlertDescription","InputOTP","InputOTPGroup","InputOTPSlot","InputOTPSeparator","Button"],"sources":["../../packages/components/pages/VerifyEmailPage.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { LunasLogo } from '../features/logo';\nimport { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from '../ui/input-otp';\n\nexport interface VerifyEmailPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** The email address the OTP was dispatched to — displayed as context and passed to callbacks */\n email: string;\n /** Called when the user submits the OTP code */\n onVerify: (email: string, otp: string) => Promise<void> | void;\n /** Called when the user requests a new OTP; triggers a fresh cooldown */\n onResend: (email: string) => Promise<void> | void;\n /** Called when the back link is clicked */\n onBack?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Xác thực email\" */\n title?: string;\n /** Dialog subheading. Default: built from the email prop */\n subtitle?: string;\n /** Seconds before the resend button becomes available. Default: 60 */\n resendCooldownSeconds?: number;\n}\n\n/**\n * Modal email OTP verification dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { VerifyEmailPage } from '@customafk/lunas-ui/pages/VerifyEmailPage';\n *\n * <VerifyEmailPage\n * open={open}\n * onOpenChange={setOpen}\n * email=\"user@example.com\"\n * onVerify={async (email, otp) => {\n * await authService.verifyEmail(email, otp);\n * setOpen(false);\n * }}\n * onResend={async (email) => {\n * await authService.resendVerification(email);\n * }}\n * />\n * ```\n */\nexport const VerifyEmailPage = ({\n open,\n onOpenChange,\n email,\n onVerify,\n onResend,\n onBack,\n isLoading = false,\n errorMessage,\n title = 'Xác thực email',\n subtitle,\n resendCooldownSeconds = 60,\n}: VerifyEmailPageProps) => {\n const [otp, setOtp] = useState('');\n const [countdown, setCountdown] = useState(resendCooldownSeconds);\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const startCountdown = useCallback((seconds: number) => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n setCountdown(seconds);\n intervalRef.current = setInterval(() => {\n setCountdown(prev => {\n if (prev <= 1) {\n if (intervalRef.current) clearInterval(intervalRef.current);\n return 0;\n }\n return prev - 1;\n });\n }, 1000);\n }, []);\n\n useEffect(() => {\n if (open && resendCooldownSeconds > 0) startCountdown(resendCooldownSeconds);\n return () => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n };\n }, [open, resendCooldownSeconds, startCountdown]);\n\n const handleResend = useCallback(async () => {\n startCountdown(resendCooldownSeconds);\n await onResend(email);\n }, [email, onResend, resendCooldownSeconds, startCountdown]);\n\n const handleVerify = useCallback(async () => {\n if (otp.length < 6) return;\n await onVerify(email, otp);\n }, [email, otp, onVerify]);\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <LunasLogo variant=\"horizontal\" size=\"sm\" className=\"mx-auto\" />\n <div className=\"flex flex-col gap-0.5\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>\n {subtitle ?? (\n <>\n Nhập mã OTP đã được gửi tới <span className=\"font-medium text-foreground\">{email}</span>. Mã có hiệu lực trong 10 phút.\n </>\n )}\n </DialogDescription>\n </div>\n </DialogHeader>\n\n <div className=\"flex flex-col items-center gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\" className=\"w-full\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <InputOTP maxLength={6} value={otp} onChange={setOtp} onComplete={handleVerify} disabled={isLoading}>\n <InputOTPGroup>\n <InputOTPSlot index={0} />\n <InputOTPSlot index={1} />\n <InputOTPSlot index={2} />\n </InputOTPGroup>\n <InputOTPSeparator />\n <InputOTPGroup>\n <InputOTPSlot index={3} />\n <InputOTPSlot index={4} />\n <InputOTPSlot index={5} />\n </InputOTPGroup>\n </InputOTP>\n\n <Button type=\"button\" isLoading={isLoading} disabled={otp.length < 6} className=\"w-full\" onClick={handleVerify}>\n Xác thực\n </Button>\n\n <div className=\"flex items-center gap-1 text-muted-foreground text-sm\">\n <span>Chưa nhận được mã?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" disabled={countdown > 0 || isLoading} onClick={handleResend}>\n {countdown > 0 ? `Gửi lại (${countdown}s)` : 'Gửi lại'}\n </Button>\n </div>\n\n {onBack && (\n <Button variant=\"ghost\" size=\"sm\" className=\"w-full\" onClick={onBack}>\n Quay lại\n </Button>\n )}\n </div>\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"oTAwDA,MAAa,GAAmB,CAC9B,OACA,eACA,QACA,WACA,WACA,SACA,YAAY,GACZ,eACA,QAAQ,iBACR,WACA,wBAAwB,MACE,CAC1B,GAAM,CAAC,EAAK,IAAA,EAAA,EAAA,SAAA,CAAmB,EAAE,EAC3B,CAAC,EAAW,IAAA,EAAA,EAAA,SAAA,CAAyB,CAAqB,EAC1D,GAAA,EAAA,EAAA,OAAA,CAA4D,IAAI,EAEhE,GAAA,EAAA,EAAA,YAAA,CAA8B,GAAoB,CAClD,EAAY,SAAS,cAAc,EAAY,OAAO,EAC1D,EAAa,CAAO,EACpB,EAAY,QAAU,gBAAkB,CACtC,EAAa,GACP,GAAQ,GACN,EAAY,SAAS,cAAc,EAAY,OAAO,EACnD,GAEF,EAAO,CACf,CACH,EAAG,GAAI,CACT,EAAG,CAAC,CAAC,GAEL,EAAA,EAAA,UAAA,MACM,GAAQ,EAAwB,GAAG,EAAe,CAAqB,MAC9D,CACP,EAAY,SAAS,cAAc,EAAY,OAAO,CAC5D,GACC,CAAC,EAAM,EAAuB,CAAc,CAAC,EAEhD,IAAM,GAAA,EAAA,EAAA,YAAA,CAA2B,SAAY,CAC3C,EAAe,CAAq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EACE,EAAA,EAAA,IAAA,CAACC,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,GACzB,EAAA,EAAA,IAAA,CAACA,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,GACzB,EAAA,EAAA,IAAA,CAACA,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,CACZ,CAAA,CAAA,GACf,EAAA,EAAA,IAAA,CAACC,EAAAA,kBAAD,CAAoB,CAAA,GACpB,EAAA,EAAA,KAAA,CAACF,EAAAA,cAAD,CAAA,SAAA,EACE,EAAA,EAAA,IAAA,CAACC,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,GACzB,EAAA,EAAA,IAAA,CAACA,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,GACzB,EAAA,EAAA,IAAA,CAACA,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,CACZ,CAAA,CAAA,CACP,KAEV,EAAA,EAAA,IAAA,CAACE,EAAAA,OAAD,CAAQ,KAAK,SAAoB,YAAW,SAAU,EAAI,OAAS,EAAG,UAAU,SAAS,QAAS,WAAc,UAExG,CAAA,GAER,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,iEAAf,EACE,EAAA,EAAA,IAAA,CAAC,OAAD,CAAA,SAAM,oBAAwB,CAAA,GAC9B,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,QAAQ,OAAO,KAAK,KAAK,UAAU,aAAa,SAAU,EAAY,GAAK,EAAW,QAAS,WACpG,EAAY,EAAI,YAAY,EAAU,IAAM,SACvC,CAAA,CACL,IAEJ,IACC,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAQ,QAAQ,QAAQ,KAAK,KAAK,UAAU,SAAS,QAAS,WAAQ,UAE9D,CAAA,CAEP,GACQ,GACT,CAAA,CAEZ"}
@@ -1,2 +1,2 @@
1
- "use client";import{Button as e}from"../ui/button.mjs";import{Dialog as t,DialogContent as n,DialogDescription as r,DialogHeader as i,DialogTitle as a}from"../ui/dialog.mjs";import{n as o,t as s}from"../alert-OD1KJTEV.mjs";import{InputOTP as c,InputOTPGroup as l,InputOTPSeparator as u,InputOTPSlot as d}from"../ui/input-otp.mjs";import{useCallback as f,useEffect as p,useRef as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";const y=({open:y,onOpenChange:b,email:x,onVerify:S,onResend:C,onBack:w,isLoading:T=!1,errorMessage:E,title:D=`Xác thực email`,subtitle:O,resendCooldownSeconds:k=60})=>{let[A,j]=h(``),[M,N]=h(k),P=m(null),F=f(e=>{P.current&&clearInterval(P.current),N(e),P.current=setInterval(()=>{N(e=>e<=1?(P.current&&clearInterval(P.current),0):e-1)},1e3)},[]);p(()=>(y&&k>0&&F(k),()=>{P.current&&clearInterval(P.current)}),[y,k,F]);let I=f(async()=>{F(k),await C(x)},[x,C,k,F]),L=f(async()=>{A.length<6||await S(x,A)},[x,A,S]);return _(t,{open:y,onOpenChange:b,children:v(n,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[v(i,{children:[_(a,{children:D}),_(r,{children:O??v(g,{children:[`Nhập mã OTP đã được gửi tới `,_(`span`,{className:`font-medium text-foreground`,children:x}),`. Mã có hiệu lực trong 10 phút.`]})})]}),v(`div`,{className:`flex flex-col items-center gap-4`,children:[E&&_(s,{variant:`destructive`,className:`w-full`,children:_(o,{children:E})}),v(c,{maxLength:6,value:A,onChange:j,onComplete:L,disabled:T,children:[v(l,{children:[_(d,{index:0}),_(d,{index:1}),_(d,{index:2})]}),_(u,{}),v(l,{children:[_(d,{index:3}),_(d,{index:4}),_(d,{index:5})]})]}),_(e,{type:`button`,isLoading:T,disabled:A.length<6,className:`w-full`,onClick:L,children:`Xác thực`}),v(`div`,{className:`flex items-center gap-1 text-muted-foreground text-sm`,children:[_(`span`,{children:`Chưa nhận được mã?`}),_(e,{variant:`link`,size:`sm`,className:`h-auto p-0`,disabled:M>0||T,onClick:I,children:M>0?`Gửi lại (${M}s)`:`Gửi lại`})]}),w&&_(e,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:w,children:`Quay lại`})]})]})})};export{y as VerifyEmailPage};
1
+ "use client";import{Button as e}from"../ui/button.mjs";import{LunasLogo as t}from"../features/logo/index.mjs";import{Dialog as n,DialogContent as r,DialogDescription as i,DialogHeader as a,DialogTitle as o}from"../ui/dialog.mjs";import{n as s,t as c}from"../alert-OD1KJTEV.mjs";import{InputOTP as l,InputOTPGroup as u,InputOTPSeparator as d,InputOTPSlot as f}from"../ui/input-otp.mjs";import{useCallback as p,useEffect as m,useRef as h,useState as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";const b=({open:b,onOpenChange:x,email:S,onVerify:C,onResend:w,onBack:T,isLoading:E=!1,errorMessage:D,title:O=`Xác thực email`,subtitle:k,resendCooldownSeconds:A=60})=>{let[j,M]=g(``),[N,P]=g(A),F=h(null),I=p(e=>{F.current&&clearInterval(F.current),P(e),F.current=setInterval(()=>{P(e=>e<=1?(F.current&&clearInterval(F.current),0):e-1)},1e3)},[]);m(()=>(b&&A>0&&I(A),()=>{F.current&&clearInterval(F.current)}),[b,A,I]);let L=p(async()=>{I(A),await w(S)},[S,w,A,I]),R=p(async()=>{j.length<6||await C(S,j)},[S,j,C]);return v(n,{open:b,onOpenChange:x,children:y(r,{className:`max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm`,children:[y(a,{children:[v(t,{variant:`horizontal`,size:`sm`,className:`mx-auto`}),y(`div`,{className:`flex flex-col gap-0.5`,children:[v(o,{children:O}),v(i,{children:k??y(_,{children:[`Nhập mã OTP đã được gửi tới `,v(`span`,{className:`font-medium text-foreground`,children:S}),`. Mã có hiệu lực trong 10 phút.`]})})]})]}),y(`div`,{className:`flex flex-col items-center gap-4`,children:[D&&v(c,{variant:`destructive`,className:`w-full`,children:v(s,{children:D})}),y(l,{maxLength:6,value:j,onChange:M,onComplete:R,disabled:E,children:[y(u,{children:[v(f,{index:0}),v(f,{index:1}),v(f,{index:2})]}),v(d,{}),y(u,{children:[v(f,{index:3}),v(f,{index:4}),v(f,{index:5})]})]}),v(e,{type:`button`,isLoading:E,disabled:j.length<6,className:`w-full`,onClick:R,children:`Xác thực`}),y(`div`,{className:`flex items-center gap-1 text-muted-foreground text-sm`,children:[v(`span`,{children:`Chưa nhận được mã?`}),v(e,{variant:`link`,size:`sm`,className:`h-auto p-0`,disabled:N>0||E,onClick:L,children:N>0?`Gửi lại (${N}s)`:`Gửi lại`})]}),T&&v(e,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:T,children:`Quay lại`})]})]})})};export{b as VerifyEmailPage};
2
2
  //# sourceMappingURL=VerifyEmailPage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"VerifyEmailPage.mjs","names":[],"sources":["../../packages/components/pages/VerifyEmailPage.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from '../ui/input-otp';\n\nexport interface VerifyEmailPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** The email address the OTP was dispatched to — displayed as context and passed to callbacks */\n email: string;\n /** Called when the user submits the OTP code */\n onVerify: (email: string, otp: string) => Promise<void> | void;\n /** Called when the user requests a new OTP; triggers a fresh cooldown */\n onResend: (email: string) => Promise<void> | void;\n /** Called when the back link is clicked */\n onBack?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Xác thực email\" */\n title?: string;\n /** Dialog subheading. Default: built from the email prop */\n subtitle?: string;\n /** Seconds before the resend button becomes available. Default: 60 */\n resendCooldownSeconds?: number;\n}\n\n/**\n * Modal email OTP verification dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { VerifyEmailPage } from '@customafk/lunas-ui/pages/VerifyEmailPage';\n *\n * <VerifyEmailPage\n * open={open}\n * onOpenChange={setOpen}\n * email=\"user@example.com\"\n * onVerify={async (email, otp) => {\n * await authService.verifyEmail(email, otp);\n * setOpen(false);\n * }}\n * onResend={async (email) => {\n * await authService.resendVerification(email);\n * }}\n * />\n * ```\n */\nexport const VerifyEmailPage = ({\n open,\n onOpenChange,\n email,\n onVerify,\n onResend,\n onBack,\n isLoading = false,\n errorMessage,\n title = 'Xác thực email',\n subtitle,\n resendCooldownSeconds = 60,\n}: VerifyEmailPageProps) => {\n const [otp, setOtp] = useState('');\n const [countdown, setCountdown] = useState(resendCooldownSeconds);\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const startCountdown = useCallback((seconds: number) => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n setCountdown(seconds);\n intervalRef.current = setInterval(() => {\n setCountdown(prev => {\n if (prev <= 1) {\n if (intervalRef.current) clearInterval(intervalRef.current);\n return 0;\n }\n return prev - 1;\n });\n }, 1000);\n }, []);\n\n useEffect(() => {\n if (open && resendCooldownSeconds > 0) startCountdown(resendCooldownSeconds);\n return () => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n };\n }, [open, resendCooldownSeconds, startCountdown]);\n\n const handleResend = useCallback(async () => {\n startCountdown(resendCooldownSeconds);\n await onResend(email);\n }, [email, onResend, resendCooldownSeconds, startCountdown]);\n\n const handleVerify = useCallback(async () => {\n if (otp.length < 6) return;\n await onVerify(email, otp);\n }, [email, otp, onVerify]);\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>\n {subtitle ?? (\n <>\n Nhập mã OTP đã được gửi tới <span className=\"font-medium text-foreground\">{email}</span>. Mã có hiệu lực trong 10 phút.\n </>\n )}\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"flex flex-col items-center gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\" className=\"w-full\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <InputOTP maxLength={6} value={otp} onChange={setOtp} onComplete={handleVerify} disabled={isLoading}>\n <InputOTPGroup>\n <InputOTPSlot index={0} />\n <InputOTPSlot index={1} />\n <InputOTPSlot index={2} />\n </InputOTPGroup>\n <InputOTPSeparator />\n <InputOTPGroup>\n <InputOTPSlot index={3} />\n <InputOTPSlot index={4} />\n <InputOTPSlot index={5} />\n </InputOTPGroup>\n </InputOTP>\n\n <Button type=\"button\" isLoading={isLoading} disabled={otp.length < 6} className=\"w-full\" onClick={handleVerify}>\n Xác thực\n </Button>\n\n <div className=\"flex items-center gap-1 text-muted-foreground text-sm\">\n <span>Chưa nhận được mã?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" disabled={countdown > 0 || isLoading} onClick={handleResend}>\n {countdown > 0 ? `Gửi lại (${countdown}s)` : 'Gửi lại'}\n </Button>\n </div>\n\n {onBack && (\n <Button variant=\"ghost\" size=\"sm\" className=\"w-full\" onClick={onBack}>\n Quay lại\n </Button>\n )}\n </div>\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"udAuDA,MAAa,GAAmB,CAC9B,OACA,eACA,QACA,WACA,WACA,SACA,YAAY,GACZ,eACA,QAAQ,iBACR,WACA,wBAAwB,MACE,CAC1B,GAAM,CAAC,EAAK,GAAU,EAAS,EAAE,EAC3B,CAAC,EAAW,GAAgB,EAAS,CAAqB,EAC1D,EAAc,EAA8C,IAAI,EAEhE,EAAiB,EAAa,GAAoB,CAClD,EAAY,SAAS,cAAc,EAAY,OAAO,EAC1D,EAAa,CAAO,EACpB,EAAY,QAAU,gBAAkB,CACtC,EAAa,GACP,GAAQ,GACN,EAAY,SAAS,cAAc,EAAY,OAAO,EACnD,GAEF,EAAO,CACf,CACH,EAAG,GAAI,CACT,EAAG,CAAC,CAAC,EAEL,OACM,GAAQ,EAAwB,GAAG,EAAe,CAAqB,MAC9D,CACP,EAAY,SAAS,cAAc,EAAY,OAAO,CAC5D,GACC,CAAC,EAAM,EAAuB,CAAc,CAAC,EAEhD,IAAM,EAAe,EAAY,SAAY,CAC3C,EAAe,CAAqB,EACpC,MAAM,EAAS,CAAK,CACtB,EAAG,CAAC,EAAO,EAAU,EAAuB,CAAc,CAAC,EAErD,EAAe,EAAY,SAAY,CACvC,EAAI,OAAS,GACjB,MAAM,EAAS,EAAO,CAAG,CAC3B,EAAG,CAAC,EAAO,EAAK,CAAQ,CAAC,EAEzB,OACE,EAAC,EAAD,CAAc,OAAoB,wBAChC,EAAC,EAAD,CAAe,UAAU,gVAAzB,CACE,EAAC,EAAD,CAAA,SAAA,CACE,EAAC,EAAD,CAAA,SAAc,CAAmB,CAAA,EACjC,EAAC,EAAD,CAAA,SACG,GACC,EAAA,EAAA,CAAA,SAAA,CAAE,+BAC4B,EAAC,OAAD,CAAM,UAAU,uCAA+B,C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{ useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Alert, AlertDescription } from '../ui/alert';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';\nimport { LunasLogo } from '../features/logo';\nimport { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from '../ui/input-otp';\n\nexport interface VerifyEmailPageProps {\n /** Controls whether the dialog is open */\n open: boolean;\n /** Called when the dialog open state changes */\n onOpenChange: (open: boolean) => void;\n /** The email address the OTP was dispatched to — displayed as context and passed to callbacks */\n email: string;\n /** Called when the user submits the OTP code */\n onVerify: (email: string, otp: string) => Promise<void> | void;\n /** Called when the user requests a new OTP; triggers a fresh cooldown */\n onResend: (email: string) => Promise<void> | void;\n /** Called when the back link is clicked */\n onBack?: () => void;\n /** Disables the form and shows a spinner on the submit button */\n isLoading?: boolean;\n /** Server-side error message rendered in a destructive Alert */\n errorMessage?: string;\n /** Dialog heading. Default: \"Xác thực email\" */\n title?: string;\n /** Dialog subheading. Default: built from the email prop */\n subtitle?: string;\n /** Seconds before the resend button becomes available. Default: 60 */\n resendCooldownSeconds?: number;\n}\n\n/**\n * Modal email OTP verification dialog for the client authentication flow.\n *\n * @example\n * ```tsx\n * import { VerifyEmailPage } from '@customafk/lunas-ui/pages/VerifyEmailPage';\n *\n * <VerifyEmailPage\n * open={open}\n * onOpenChange={setOpen}\n * email=\"user@example.com\"\n * onVerify={async (email, otp) => {\n * await authService.verifyEmail(email, otp);\n * setOpen(false);\n * }}\n * onResend={async (email) => {\n * await authService.resendVerification(email);\n * }}\n * />\n * ```\n */\nexport const VerifyEmailPage = ({\n open,\n onOpenChange,\n email,\n onVerify,\n onResend,\n onBack,\n isLoading = false,\n errorMessage,\n title = 'Xác thực email',\n subtitle,\n resendCooldownSeconds = 60,\n}: VerifyEmailPageProps) => {\n const [otp, setOtp] = useState('');\n const [countdown, setCountdown] = useState(resendCooldownSeconds);\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const startCountdown = useCallback((seconds: number) => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n setCountdown(seconds);\n intervalRef.current = setInterval(() => {\n setCountdown(prev => {\n if (prev <= 1) {\n if (intervalRef.current) clearInterval(intervalRef.current);\n return 0;\n }\n return prev - 1;\n });\n }, 1000);\n }, []);\n\n useEffect(() => {\n if (open && resendCooldownSeconds > 0) startCountdown(resendCooldownSeconds);\n return () => {\n if (intervalRef.current) clearInterval(intervalRef.current);\n };\n }, [open, resendCooldownSeconds, startCountdown]);\n\n const handleResend = useCallback(async () => {\n startCountdown(resendCooldownSeconds);\n await onResend(email);\n }, [email, onResend, resendCooldownSeconds, startCountdown]);\n\n const handleVerify = useCallback(async () => {\n if (otp.length < 6) return;\n await onVerify(email, otp);\n }, [email, otp, onVerify]);\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100 max-sm:top-auto max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none sm:max-w-sm\">\n <DialogHeader>\n <LunasLogo variant=\"horizontal\" size=\"sm\" className=\"mx-auto\" />\n <div className=\"flex flex-col gap-0.5\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>\n {subtitle ?? (\n <>\n Nhập mã OTP đã được gửi tới <span className=\"font-medium text-foreground\">{email}</span>. Mã có hiệu lực trong 10 phút.\n </>\n )}\n </DialogDescription>\n </div>\n </DialogHeader>\n\n <div className=\"flex flex-col items-center gap-4\">\n {errorMessage && (\n <Alert variant=\"destructive\" className=\"w-full\">\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n )}\n\n <InputOTP maxLength={6} value={otp} onChange={setOtp} onComplete={handleVerify} disabled={isLoading}>\n <InputOTPGroup>\n <InputOTPSlot index={0} />\n <InputOTPSlot index={1} />\n <InputOTPSlot index={2} />\n </InputOTPGroup>\n <InputOTPSeparator />\n <InputOTPGroup>\n <InputOTPSlot index={3} />\n <InputOTPSlot index={4} />\n <InputOTPSlot index={5} />\n </InputOTPGroup>\n </InputOTP>\n\n <Button type=\"button\" isLoading={isLoading} disabled={otp.length < 6} className=\"w-full\" onClick={handleVerify}>\n Xác thực\n </Button>\n\n <div className=\"flex items-center gap-1 text-muted-foreground text-sm\">\n <span>Chưa nhận được mã?</span>\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0\" disabled={countdown > 0 || isLoading} onClick={handleResend}>\n {countdown > 0 ? `Gửi lại (${countdown}s)` : 'Gửi lại'}\n </Button>\n </div>\n\n {onBack && (\n <Button variant=\"ghost\" size=\"sm\" className=\"w-full\" onClick={onBack}>\n Quay lại\n </Button>\n )}\n </div>\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":"8gBAwDA,MAAa,GAAmB,CAC9B,OACA,eACA,QACA,WACA,WACA,SACA,YAAY,GACZ,eACA,QAAQ,iBACR,WACA,wBAAwB,MACE,CAC1B,GAAM,CAAC,EAAK,GAAU,EAAS,EAAE,EAC3B,CAAC,EAAW,GAAgB,EAAS,CAAqB,EAC1D,EAAc,EAA8C,IAAI,EAEhE,EAAiB,EAAa,GAAoB,CAClD,EAAY,SAAS,cAAc,EAAY,OAAO,EAC1D,EAAa,CAAO,EACpB,EAAY,QAAU,gBAAkB,CACtC,EAAa,GACP,GAAQ,GACN,EAAY,SAAS,cAAc,EAAY,OAAO,EACnD,GAEF,EAAO,CACf,CACH,EAAG,GAAI,CACT,EAAG,CAAC,CAAC,EAEL,OACM,GAAQ,EAAwB,GAAG,EAAe,CAAqB,MAC9D,CACP,EAAY,SAAS,cAAc,EAAY,OAAO,CAC5D,GACC,CAAC,EAAM,EAAuB,CAAc,CAAC,EAEhD,IAAM,EAAe,EAAY,SAAY,CAC3C,EAAe,CAAqB,EACpC,MAA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EAAD,CAAQ,KAAK,SAAoB,YAAW,SAAU,EAAI,OAAS,EAAG,UAAU,SAAS,QAAS,WAAc,UAExG,CAAA,EAER,EAAC,MAAD,CAAK,UAAU,iEAAf,CACE,EAAC,OAAD,CAAA,SAAM,oBAAwB,CAAA,EAC9B,EAAC,EAAD,CAAQ,QAAQ,OAAO,KAAK,KAAK,UAAU,aAAa,SAAU,EAAY,GAAK,EAAW,QAAS,WACpG,EAAY,EAAI,YAAY,EAAU,IAAM,SACvC,CAAA,CACL,IAEJ,GACC,EAAC,EAAD,CAAQ,QAAQ,QAAQ,KAAK,KAAK,UAAU,SAAS,QAAS,WAAQ,UAE9D,CAAA,CAEP,GACQ,GACT,CAAA,CAEZ"}
@@ -0,0 +1,2 @@
1
+ const e=require("./dist-DzA--RwW.cjs"),t=require("./ui/button.cjs"),n=require("./typography/paragraph.cjs");require("./ui/skeleton.cjs");const r=require("./layouts/flex.cjs"),i=require("./ui/tooltip.cjs"),a=require("./ui/avatar.cjs"),o=require("./features/logo/index.cjs");require("./ui/separator.cjs");const s=require("./ui/sheet.cjs"),c=require("./ui/dropdown-menu.cjs");require("./ui/input.cjs");let l=require("lucide-react"),u=require("react"),d=require("@customafk/react-toolkit/utils"),f=require("class-variance-authority"),p=require("react/jsx-runtime"),m=require("@customafk/react-toolkit/color-hash"),h=require("@customafk/react-toolkit/hooks/useMobile");const g=(0,u.createContext)(null);function _(){let e=(0,u.useContext)(g);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function v({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:a,children:o,...s}){let c=(0,h.useIsMobile)(),[l,f]=(0,u.useState)(!1),[m,_]=(0,u.useState)(e),v=t??m,y=(0,u.useCallback)(e=>{let t=typeof e==`function`?e(v):e;n?n(t):_(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[n,v]),b=(0,u.useCallback)(()=>c?f(e=>!e):y(e=>!e),[c,y]);(0,u.useEffect)(()=>{let e=e=>{e.key===`b`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b]);let x=v?`expanded`:`collapsed`,S=(0,u.useMemo)(()=>({state:x,open:v,setOpen:y,isMobile:c,openMobile:l,setOpenMobile:f,toggleSidebar:b}),[x,v,y,c,l,b]);return(0,p.jsx)(g.Provider,{value:S,children:(0,p.jsx)(i.TooltipProvider,{delayDuration:0,children:(0,p.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`3rem`,...a},className:(0,d.cn)(`group/sidebar-wrapper flex h-dvh w-full`,r),...s,children:o})})})}function y({side:e=`left`,variant:n=`sidebar`,collapsible:r=`offcanvas`,className:i,children:a,...o}){let{isMobile:c,state:u,openMobile:f,setOpenMobile:m,toggleSidebar:h}=_();return r===`none`?(0,p.jsx)(`aside`,{"data-slot":`sidebar`,className:(0,d.cn)(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,i),...o,children:a}):c?(0,p.jsx)(s.Sheet,{open:f,onOpenChange:m,...o,children:(0,p.jsxs)(s.SheetContent,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground sm:max-w-3xs [&>button]:hidden`,style:{"--sidebar-width":`18rem`},side:e,children:[(0,p.jsxs)(s.SheetHeader,{className:`sr-only`,children:[(0,p.jsx)(s.SheetTitle,{children:`Sidebar`}),(0,p.jsx)(s.SheetDescription,{children:`Displays the mobile sidebar.`})]}),(0,p.jsxs)(`div`,{className:`flex size-full flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex flex-0 items-center gap-x-2 border-border-weak border-b p-2 pr-4`,children:[(0,p.jsxs)(t.Button,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,color:`muted`,size:`icon`,className:(0,d.cn)(`size-10 rounded-full`,i),onClick:e=>{h(),e.preventDefault(),e.stopPropagation()},children:[(0,p.jsx)(l.MenuIcon,{className:`size-6!`}),(0,p.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]}),(0,p.jsx)(`div`,{className:`ml-2 flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground`,children:(0,p.jsx)(l.ShoppingCartIcon,{size:20})}),(0,p.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,p.jsx)(`span`,{className:`truncate font-medium`,children:`Lunas Store`}),(0,p.jsx)(`span`,{className:`truncate text-xs`,children:`Established 2023`})]})]}),(0,p.jsx)(`div`,{className:`flex flex-1 flex-col p-2`,children:a})]})]})}):(0,p.jsxs)(`aside`,{className:`group peer hidden bg-card text-sidebar-foreground md:block`,"data-state":u,"data-collapsible":u===`collapsed`?r:``,"data-variant":n,"data-side":e,"data-slot":`sidebar`,children:[(0,p.jsx)(`div`,{"data-slot":`sidebar-gap`,className:(0,d.cn)(`relative`,`bg-transparent`,`transition-[width] duration-200 ease-linear`,`h-(--header-height) w-(--sidebar-width)`,`sm:h-[calc(var(--header-height)+0.5rem)]`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,n===`floating`||n===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,p.jsx)(`div`,{"data-slot":`sidebar-container`,className:(0,d.cn)(`hidden md:flex`,`fixed inset-y-0 top-14 z-10 shadow-nav`,`h-[calc(100dvh-3.5rem)] w-(--sidebar-width)`,`transition-[left,right,width] duration-200 ease-linear`,e===`left`&&`left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]`,e===`right`&&`right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,n===`floating`||n===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,i),...o,children:(0,p.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:(0,d.cn)(`flex size-full flex-col`,`group-data-[variant=floating]:rounded-lg`,`group-data-[variant=floating]:border`,`group-data-[variant=floating]:border-sidebar-border`,`group-data-[variant=floating]:shadow-sm`),children:a})})]})}function b({className:e,children:t,...n}){return(0,p.jsxs)(`main`,{"data-slot":`sidebar-inset`,className:(0,d.cn)(`relative flex w-full flex-1 flex-col`,e),...n,children:[(0,p.jsx)(`div`,{className:`h-(--header-height) w-full sm:h-[calc(var(--header-height)+0.5rem)]`}),(0,p.jsx)(`div`,{className:`inset-shadow-sm flex-1`,children:t})]})}function x({className:e,...t}){return(0,p.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:(0,d.cn)(`flex flex-col gap-2 p-2`,e),...t})}function S({className:e,...t}){return(0,p.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:(0,d.cn)(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function C({className:e,...t}){return(0,p.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:(0,d.cn)(`relative flex w-full min-w-0 flex-col`,e),...t})}function w({className:t,asChild:n=!1,...r}){return(0,p.jsx)(n?e.t:`div`,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:(0,d.cn)(`flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 text-xs outline-hidden ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0`,t),...r})}function T({className:e,...t}){return(0,p.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:(0,d.cn)(`w-full text-sm`,e),...t})}function E({className:e,...t}){return(0,p.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:(0,d.cn)(`flex w-full min-w-0 flex-col gap-1`,e),...t})}function D({className:e,...t}){return(0,p.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:(0,d.cn)(`group/menu-item relative`,e),...t})}const O=(0,f.cva)([`peer/menu-button`,`cursor-pointer`,`flex w-full items-center gap-2`,`overflow-hidden rounded-md p-2 outline-hidden`,`truncate text-left font-normal`,`transition-[color,width,height,padding]`,`hover:bg-sidebar-accent`,`hover:text-sidebar-accent-foreground`,`active:bg-sidebar-accent`,`active:text-sidebar-accent-foreground`,`disabled:pointer-events-none`,`disabled:opacity-50`,`group-has-data-[sidebar=menu-action]/menu-item:pr-8`,`aria-disabled:pointer-events-none`,`aria-disabled:opacity-50`,`data-[active=true]:bg-sidebar-primary-muted`,`data-[active=true]:text-sidebar-primary`,`data-[state=open]:hover:bg-sidebar-accent`,`data-[state=open]:hover:text-sidebar-accent-foreground`,`group-data-[collapsible=icon]:size-12!`,`group-data-[collapsible=icon]:p-3!`,`group-data-[collapsible=icon]:gap-3!`,`[&>svg]:size-6`,`[&>svg]:shrink-0`,`[&>span:last-child]:truncate`],{variants:{variant:{default:`hover:bg-sidebar-accent/60 hover:text-sidebar-accent-foreground/80`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-10 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function k({asChild:t=!1,isActive:n=!1,variant:r=`default`,size:a=`default`,tooltip:o,className:s,...c}){let l=t?e.t:`button`,{isMobile:u,state:f}=_(),m=(0,p.jsx)(l,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":a,"data-active":n,className:(0,d.cn)(O({variant:r,size:a}),s),...c});return o?(typeof o==`string`&&(o={children:o}),(0,p.jsxs)(i.Tooltip,{children:[(0,p.jsx)(i.TooltipTrigger,{asChild:!0,children:m}),(0,p.jsx)(i.TooltipContent,{side:`right`,align:`center`,hidden:f!==`collapsed`||u,...o})]})):m}const A=({uuid:e,username:t,email:i})=>(0,p.jsxs)(r.Flex,{"data-slot":`user-display`,wrap:!1,gap:`sm`,padding:`none`,children:[(0,p.jsx)(a.Avatar,{className:`size-9 shadow-card`,children:(0,p.jsx)(a.AvatarFallback,{style:{backgroundColor:m.colorHashLight.hex(e)},children:(0,p.jsx)(l.UserRoundIcon,{size:28,className:`text-white`})})}),(0,p.jsxs)(r.Flex,{vertical:!0,padding:`none`,gap:`none`,align:`start`,className:`hidden sm:flex`,children:[(0,p.jsx)(n.Paragraph,{className:`text-sm font-medium text-text-positive`,children:t}),(0,p.jsx)(n.Paragraph,{variant:`sm`,className:`mt-0! text-xs text-text-positive-weak`,children:i})]})]}),j=({user:e,isLogin:n=!0,onLogin:r,onLogout:i,logo:a})=>{let{toggleSidebar:s}=_(),f=(0,u.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),s()},[s]),m=(0,u.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),i?.()},[i]),h=(0,u.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),r?.()},[r]);return(0,p.jsxs)(`header`,{"data-slot":`payment-layout-header`,className:(0,d.cn)(`bg-card`,`h-[calc(var(--header-height)+0.5rem)] sm:px-4 sm:pr-6`,`absolute inset-x-0 top-0 z-20 gap-2 px-2 pr-2.5`,`flex items-center shadow-nav`,`transition-[width,height] ease-linear`),children:[n&&(0,p.jsxs)(t.Button,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,color:`muted`,size:`icon`,className:`hidden size-10 rounded-full transition-all hover:text-text-positive md:flex`,onClick:f,children:[(0,p.jsx)(l.MenuIcon,{className:`size-6!`}),(0,p.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]}),(0,p.jsx)(`div`,{className:`flex flex-1 items-center sm:ml-2.5`,children:a??(0,p.jsx)(o.LunasLogo,{variant:`horizontal`,size:`xs`})}),e?(0,p.jsxs)(c.DropdownMenu,{children:[(0,p.jsx)(c.DropdownMenuTrigger,{asChild:!0,children:(0,p.jsx)(t.Button,{variant:`ghost`,color:`muted`,className:`gap-x-2 rounded-full px-2 transition-all hover:text-text-positive`,children:(0,p.jsx)(A,{uuid:e?.uuid??``,username:e.fullname,email:e.email})})}),(0,p.jsxs)(c.DropdownMenuContent,{align:`end`,className:`w-56`,children:[(0,p.jsxs)(c.DropdownMenuLabel,{className:`font-normal`,children:[(0,p.jsx)(`p`,{className:`font-medium`,children:e.fullname}),(0,p.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.email})]}),(0,p.jsx)(c.DropdownMenuSeparator,{}),(0,p.jsx)(c.DropdownMenuGroup,{children:(0,p.jsxs)(c.DropdownMenuItem,{onClick:m,children:[(0,p.jsx)(l.LogOutIcon,{size:14}),`Đăng xuất`]})})]})]}):(0,p.jsx)(t.Button,{size:`sm`,onClick:h,children:`Đăng nhập`})]})},M=({items:e,activeNavItemId:t})=>{let{isMobile:n}=_();return!n||e.length===0?null:(0,p.jsx)(`nav`,{"data-slot":`mobile-bottom-nav`,className:`fixed inset-x-0 bottom-0 z-20 flex h-16 items-stretch border-border border-t bg-card md:hidden`,children:e.slice(0,5).map(e=>(0,p.jsxs)(`button`,{type:`button`,onClick:e.onClick,"data-active":e.id===t,className:(0,d.cn)(`flex flex-1 flex-col items-center justify-center gap-0.5`,`text-muted-foreground transition-colors`,`data-[active=true]:text-sidebar-primary`,`[&>svg]:size-5 [&>svg]:shrink-0`),children:[e.icon,(0,p.jsx)(`span`,{className:`max-w-16 truncate text-[10px] leading-3`,children:e.label})]},e.id))})},N=({activeNavItemId:e,sidebar:t,user:n,isLogin:r=!0,onLogin:i,onLogout:a,children:o})=>{let s=(0,u.useMemo)(()=>t?.groupcontent||[],[t]),c=(0,u.useMemo)(()=>s.flatMap(e=>e.items),[s]);return(0,p.jsxs)(v,{children:[(0,p.jsx)(j,{user:n,isLogin:r,onLogin:i,onLogout:a}),r&&(0,p.jsxs)(y,{variant:`inset`,collapsible:`icon`,children:[(0,p.jsx)(S,{children:s.map(t=>(0,p.jsxs)(C,{children:[(0,p.jsx)(w,{children:t.label}),(0,p.jsx)(T,{children:(0,p.jsx)(E,{children:t.items.map(t=>(0,p.jsx)(D,{children:(0,p.jsxs)(k,{isActive:t.id===e,onClick:e=>{t.onClick?.(),e.preventDefault(),e.stopPropagation()},children:[t.icon,t.label]})},t.id))})})]},t.id))}),(0,p.jsx)(x,{children:(0,p.jsx)(E,{children:(0,p.jsx)(D,{className:`mt-2 border-t border-t-border`,children:(0,p.jsx)(`p`,{className:`pt-2 text-center text-muted-foreground text-xs`,children:`Copyright © 2025, Lunas.`})})})})]}),(0,p.jsx)(b,{children:(0,p.jsx)(`section`,{className:`relative size-full`,children:(0,p.jsx)(`div`,{className:(0,d.cn)(`absolute inset-0 overflow-y-auto`,r&&`pb-16 md:pb-0`),children:o})})}),r&&(0,p.jsx)(M,{items:c,activeNavItemId:e})]})};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return N}});
2
+ //# sourceMappingURL=payment-layout-BLrXT-oc.cjs.map