tempest-react-sdk 0.79.0 → 0.81.0

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 (131) hide show
  1. package/README.md +35 -4
  2. package/bin/lib/component/generate.test.mjs +13 -1
  3. package/bin/lib/openapi/generate.hostile.test.mjs +58 -5
  4. package/bin/lib/openapi/generate.mjs +145 -34
  5. package/bin/lib/openapi/generate.test.mjs +216 -5
  6. package/bin/lib/openapi/schema-to-zod.mjs +4 -3
  7. package/dist/auth/create-tempest-auth.cjs +1 -1
  8. package/dist/auth/create-tempest-auth.cjs.map +1 -1
  9. package/dist/auth/create-tempest-auth.js +172 -103
  10. package/dist/auth/create-tempest-auth.js.map +1 -1
  11. package/dist/br/boleto.cjs +1 -1
  12. package/dist/br/boleto.cjs.map +1 -1
  13. package/dist/br/boleto.js +2 -1
  14. package/dist/br/boleto.js.map +1 -1
  15. package/dist/br.d.ts +22 -3
  16. package/dist/components/AuthForm/AuthFieldControl.cjs +2 -0
  17. package/dist/components/AuthForm/AuthFieldControl.cjs.map +1 -0
  18. package/dist/components/AuthForm/AuthFieldControl.js +85 -0
  19. package/dist/components/AuthForm/AuthFieldControl.js.map +1 -0
  20. package/dist/components/AuthForm/AuthForm.cjs +2 -0
  21. package/dist/components/AuthForm/AuthForm.cjs.map +1 -0
  22. package/dist/components/AuthForm/AuthForm.js +83 -0
  23. package/dist/components/AuthForm/AuthForm.js.map +1 -0
  24. package/dist/components/AuthForm/AuthForm.module.cjs +3 -0
  25. package/dist/components/AuthForm/AuthForm.module.cjs.map +1 -0
  26. package/dist/components/AuthForm/AuthForm.module.js +14 -0
  27. package/dist/components/AuthForm/AuthForm.module.js.map +1 -0
  28. package/dist/components/AuthForm/AuthLinks.cjs +2 -0
  29. package/dist/components/AuthForm/AuthLinks.cjs.map +1 -0
  30. package/dist/components/AuthForm/AuthLinks.js +29 -0
  31. package/dist/components/AuthForm/AuthLinks.js.map +1 -0
  32. package/dist/components/AuthForm/ForgotPasswordForm.cjs +2 -0
  33. package/dist/components/AuthForm/ForgotPasswordForm.cjs.map +1 -0
  34. package/dist/components/AuthForm/ForgotPasswordForm.js +32 -0
  35. package/dist/components/AuthForm/ForgotPasswordForm.js.map +1 -0
  36. package/dist/components/AuthForm/LoginForm.cjs +2 -0
  37. package/dist/components/AuthForm/LoginForm.cjs.map +1 -0
  38. package/dist/components/AuthForm/LoginForm.js +39 -0
  39. package/dist/components/AuthForm/LoginForm.js.map +1 -0
  40. package/dist/components/AuthForm/ResetPasswordForm.cjs +2 -0
  41. package/dist/components/AuthForm/ResetPasswordForm.cjs.map +1 -0
  42. package/dist/components/AuthForm/ResetPasswordForm.js +39 -0
  43. package/dist/components/AuthForm/ResetPasswordForm.js.map +1 -0
  44. package/dist/components/AuthForm/SignUpForm.cjs +2 -0
  45. package/dist/components/AuthForm/SignUpForm.cjs.map +1 -0
  46. package/dist/components/AuthForm/SignUpForm.js +32 -0
  47. package/dist/components/AuthForm/SignUpForm.js.map +1 -0
  48. package/dist/components/AuthForm/auth-defaults.cjs +2 -0
  49. package/dist/components/AuthForm/auth-defaults.cjs.map +1 -0
  50. package/dist/components/AuthForm/auth-defaults.js +54 -0
  51. package/dist/components/AuthForm/auth-defaults.js.map +1 -0
  52. package/dist/components/AuthForm/auth-schemas.cjs +2 -0
  53. package/dist/components/AuthForm/auth-schemas.cjs.map +1 -0
  54. package/dist/components/AuthForm/auth-schemas.js +26 -0
  55. package/dist/components/AuthForm/auth-schemas.js.map +1 -0
  56. package/dist/components/AuthPage/AuthPage.cjs +2 -0
  57. package/dist/components/AuthPage/AuthPage.cjs.map +1 -0
  58. package/dist/components/AuthPage/AuthPage.js +91 -0
  59. package/dist/components/AuthPage/AuthPage.js.map +1 -0
  60. package/dist/components/AuthPage/AuthPage.module.cjs +3 -0
  61. package/dist/components/AuthPage/AuthPage.module.cjs.map +1 -0
  62. package/dist/components/AuthPage/AuthPage.module.js +24 -0
  63. package/dist/components/AuthPage/AuthPage.module.js.map +1 -0
  64. package/dist/components/FilterBar/filter-apply.cjs +1 -1
  65. package/dist/components/FilterBar/filter-apply.cjs.map +1 -1
  66. package/dist/components/FilterBar/filter-apply.js +7 -7
  67. package/dist/forms/index.js +7 -7
  68. package/dist/forms/masked-inputs.cjs +1 -1
  69. package/dist/forms/masked-inputs.cjs.map +1 -1
  70. package/dist/forms/masked-inputs.js +15 -15
  71. package/dist/http/api-client.cjs +1 -1
  72. package/dist/http/api-client.cjs.map +1 -1
  73. package/dist/http/api-client.js +104 -97
  74. package/dist/http/api-client.js.map +1 -1
  75. package/dist/http/build-url.cjs +1 -1
  76. package/dist/http/build-url.cjs.map +1 -1
  77. package/dist/http/build-url.js +3 -1
  78. package/dist/http/build-url.js.map +1 -1
  79. package/dist/http/presigned-post.cjs +2 -0
  80. package/dist/http/presigned-post.cjs.map +1 -0
  81. package/dist/http/presigned-post.js +73 -0
  82. package/dist/http/presigned-post.js.map +1 -0
  83. package/dist/http/resumable-upload.cjs +1 -1
  84. package/dist/http/resumable-upload.cjs.map +1 -1
  85. package/dist/http/resumable-upload.js +97 -97
  86. package/dist/http/resumable-upload.js.map +1 -1
  87. package/dist/http/upload-with-progress.cjs +1 -1
  88. package/dist/http/upload-with-progress.cjs.map +1 -1
  89. package/dist/http/upload-with-progress.js +12 -12
  90. package/dist/http/use-describe-api-error.cjs +1 -1
  91. package/dist/http/use-describe-api-error.cjs.map +1 -1
  92. package/dist/http/use-describe-api-error.js +9 -9
  93. package/dist/offline/create-offline-sync.cjs +1 -1
  94. package/dist/offline/create-offline-sync.cjs.map +1 -1
  95. package/dist/offline/create-offline-sync.js +78 -56
  96. package/dist/offline/create-offline-sync.js.map +1 -1
  97. package/dist/sse/create-event-stream.cjs +1 -1
  98. package/dist/sse/create-event-stream.cjs.map +1 -1
  99. package/dist/sse/create-event-stream.js +44 -30
  100. package/dist/sse/create-event-stream.js.map +1 -1
  101. package/dist/sse/ticket-event-stream.cjs +2 -0
  102. package/dist/sse/ticket-event-stream.cjs.map +1 -0
  103. package/dist/sse/ticket-event-stream.js +41 -0
  104. package/dist/sse/ticket-event-stream.js.map +1 -0
  105. package/dist/sse/use-event-stream.cjs +1 -1
  106. package/dist/sse/use-event-stream.cjs.map +1 -1
  107. package/dist/sse/use-event-stream.js +7 -4
  108. package/dist/sse/use-event-stream.js.map +1 -1
  109. package/dist/styles/AuthForm.css +2 -0
  110. package/dist/styles/AuthPage.css +2 -0
  111. package/dist/styles/component/AuthForm.css +9 -0
  112. package/dist/styles/component/AuthPage.css +29 -0
  113. package/dist/styles/forms.css +36 -0
  114. package/dist/styles/manifest.json +63 -0
  115. package/dist/styles.css +1 -1
  116. package/dist/sw/background-sync.cjs +1 -1
  117. package/dist/sw/background-sync.cjs.map +1 -1
  118. package/dist/sw/background-sync.js +124 -106
  119. package/dist/sw/background-sync.js.map +1 -1
  120. package/dist/sw.d.ts +49 -15
  121. package/dist/tempest-react-sdk.cjs +1 -1
  122. package/dist/tempest-react-sdk.d.ts +809 -22
  123. package/dist/tempest-react-sdk.js +373 -363
  124. package/dist/utils/format.cjs +1 -1
  125. package/dist/utils/format.cjs.map +1 -1
  126. package/dist/utils/format.js +25 -25
  127. package/dist/utils/numbers.cjs +1 -1
  128. package/dist/utils/numbers.cjs.map +1 -1
  129. package/dist/utils/numbers.js +7 -7
  130. package/package.json +1 -1
  131. package/template-pwa/src/sw.ts +10 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthForm.cjs","names":["DEFAULT_AUTH_FORM_LABELS","useDescribeApiError","useState","useZodForm","isApiError","FormProvider","Form","cn","styles","Alert","AuthFieldControl","Button","_Fragment","Divider","require_cn","require_Alert","require_Button","require_Divider","require_Form","require_use_zod_form","require_errors","require_use_describe_api_error","require_AuthFieldControl","require_auth_defaults","require_AuthForm_module","react","react_jsx_runtime","react_hook_form","initialValues","base","field","fields","overrides","markServerFields","names","unmatched","marked","name","message","messages","form","AuthForm","text","labels","describe","failure","setFailure","schema","defaultValues","submit","onSubmit","values","error","errorOptions","onError","className","beforeSubmit","submitLabel","social","afterSubmit"],"sources":["../../../src/components/AuthForm/AuthForm.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { FormProvider } from \"react-hook-form\";\nimport type { DefaultValues, Path, UseFormReturn } from \"react-hook-form\";\nimport type { z } from \"zod\";\nimport { Alert } from \"@/components/Alert\";\nimport { Button } from \"@/components/Button\";\nimport { Divider } from \"@/components/Divider\";\nimport { Form } from \"@/components/Form\";\nimport { useZodForm } from \"@/forms/use-zod-form\";\nimport { isApiError } from \"@/http/errors\";\nimport { useDescribeApiError } from \"@/http/use-describe-api-error\";\nimport { cn } from \"@/utils/cn\";\nimport { AuthFieldControl } from \"./AuthFieldControl\";\nimport { DEFAULT_AUTH_FORM_LABELS } from \"./auth-defaults\";\nimport type { AuthField, AuthFormLabels, AuthFormProps, AuthFormValues } from \"./types\";\nimport styles from \"./AuthForm.module.css\";\n\n/**\n * Initial values for every declared field.\n *\n * react-hook-form needs a defined value per field, or the controlled inputs\n * start uncontrolled and React warns on the first keystroke — and a missing\n * checkbox would submit `undefined`, which a `z.boolean()` rejects with a\n * message about types rather than about the terms.\n *\n * @param fields - The declared fields.\n * @param overrides - The caller's `defaultValues`, which win.\n * @returns One value per field.\n */\nfunction initialValues(\n fields: readonly AuthField[],\n overrides: object | undefined,\n): Record<string, unknown> {\n const base: Record<string, unknown> = {};\n for (const field of fields) base[field.name] = field.type === \"checkbox\" ? false : \"\";\n return { ...base, ...overrides };\n}\n\n/**\n * Attach the server's per-field messages to the fields this form shows.\n *\n * Only names present in `fields` are marked: the API can name a field the screen\n * does not render, and marking an input that does not exist leaves an error the\n * user can never clear. The first marked field takes focus.\n *\n * @param form - The form to mark.\n * @param fields - The declared fields.\n * @param messages - `error.fields`, keyed by field name.\n * @returns The messages that matched no declared field.\n */\nfunction markServerFields<TValues extends AuthFormValues<z.ZodTypeAny>>(\n form: UseFormReturn<TValues>,\n fields: readonly AuthField[],\n messages: Record<string, string>,\n): { marked: number; unmatched: string[] } {\n const names = new Set(fields.map((field) => field.name));\n const unmatched: string[] = [];\n let marked = 0;\n for (const [name, message] of Object.entries(messages)) {\n if (!names.has(name)) {\n unmatched.push(message);\n continue;\n }\n form.setError(\n name as Path<TValues>,\n { type: \"server\", message },\n {\n shouldFocus: marked === 0,\n },\n );\n marked += 1;\n }\n return { marked, unmatched };\n}\n\n/**\n * A complete auth form generated from a list of field configs and a zod schema.\n *\n * Every hand-built login and sign-up screen repeated the same wiring: a\n * `useZodForm`, one labelled input per field with its error slot, a password eye,\n * a submit button disabled while the request runs, and a `catch` that copied the\n * 422's field messages back onto the inputs. The app now declares *which* fields\n * and *what happens on submit*; the rest is here, built on the SDK's own controls\n * and its forms layer (`useZodForm` + `FormProvider` + `FormField`).\n *\n * Errors thrown by `onSubmit` are shown, never rethrown — a rethrow from a submit\n * handler is an unhandled rejection with nowhere to go. A `TempestApiError` whose\n * `fields` name fields of this form marks them; anything else, and any field\n * message that matched no declared field, goes to an `Alert` above the fields,\n * worded by `describeApiError`. Pass `onError` to log.\n *\n * @example\n * const schema = z.object({ email: z.email(\"E-mail inválido\") });\n * <AuthForm\n * schema={schema}\n * fields={[{ name: \"email\", type: \"email\", label: \"E-mail\" }]}\n * submitLabel=\"Continuar\"\n * onSubmit={async (values) => { await api.post(\"/auth/magic-link\", { body: values }); }}\n * />\n */\nexport function AuthForm<TSchema extends z.ZodTypeAny>({\n schema,\n fields,\n onSubmit,\n submitLabel = \"Enviar\",\n defaultValues,\n beforeSubmit,\n afterSubmit,\n social,\n labels,\n errorOptions,\n onError,\n className,\n}: AuthFormProps<TSchema>): ReactNode {\n const text: AuthFormLabels = { ...DEFAULT_AUTH_FORM_LABELS, ...labels };\n const describe = useDescribeApiError();\n const [failure, setFailure] = useState<string | null>(null);\n const form = useZodForm(schema, {\n defaultValues: initialValues(fields, defaultValues) as DefaultValues<\n AuthFormValues<TSchema>\n >,\n });\n\n const submit = form.handleSubmit(async (values) => {\n setFailure(null);\n try {\n await onSubmit(values);\n } catch (error) {\n const messages = isApiError(error) ? error.fields : undefined;\n const { marked, unmatched } = messages\n ? markServerFields(form, fields, messages)\n : { marked: 0, unmatched: [] };\n if (marked === 0) setFailure(describe(error, text.error, errorOptions));\n else if (unmatched.length > 0) setFailure(unmatched.join(\" \"));\n onError?.(error);\n }\n });\n\n return (\n <FormProvider {...form}>\n <Form noValidate onSubmit={submit} className={cn(styles.form, className)}>\n {failure !== null && <Alert variant=\"danger\" description={failure} />}\n {fields.map((field) => (\n <AuthFieldControl key={field.name} config={field} />\n ))}\n {beforeSubmit}\n <Button type=\"submit\" fullWidth size=\"lg\" loading={form.formState.isSubmitting}>\n {submitLabel}\n </Button>\n {social !== undefined && (\n <>\n <Divider label={text.divider} />\n <div className={styles.social}>{social}</div>\n </>\n )}\n {afterSubmit}\n </Form>\n </FormProvider>\n );\n}\n"],"mappings":"A,qeA8BA,SAAS4B,EACL,EACA,EACuB,CACvB,IAAMC,EAAgC,CAAC,EACvC,IAAK,IAAMC,KAASC,EAAQ,EAAKD,EAAM,MAAQA,EAAM,OAAS,YAAqB,GACnF,MAAO,CAAE,GAAGD,EAAM,GAAGG,CAAU,CACnC,CAcA,SAASC,EACL,EACA,EACA,EACuC,CACvC,IAAMC,EAAQ,IAAI,IAAIH,EAAO,IAAK,GAAUD,EAAM,IAAI,CAAC,EACjDK,EAAsB,CAAC,EACzBC,EAAS,EACb,IAAK,GAAM,CAACC,EAAMC,KAAY,OAAO,QAAQC,CAAQ,EAC5CL,EAAM,IAAIG,CAAI,GAInBG,EAAK,SACDH,EACA,CAAE,KAAM,SAAU,SAAQ,EAC1B,CACI,YAAaD,IAAW,CAC5B,CACJ,EACA,GAAU,GAVND,EAAU,KAAKG,CAAO,EAY9B,MAAO,CAAE,SAAQ,WAAU,CAC/B,CA2BA,SAAgBG,EAAuC,CACnD,SACA,SACA,WACA,cAAc,SACd,gBACA,eACA,cACA,SACA,SACA,eACA,UACA,aACkC,CAClC,IAAMC,EAAuB,CAAE,GAAG1C,EAAAA,yBAA0B,GAAG2C,CAAO,EAChEC,EAAW3C,EAAAA,oBAAoB,EAC/B,CAAC4C,EAASC,IAAA,EAAc5C,EAAAA,SAAAA,CAAwB,IAAI,EACpDsC,EAAOrC,EAAAA,WAAW4C,EAAQ,CAC5B,cAAenB,EAAcG,EAAQiB,CAAa,CAGtD,CAAC,EAEKC,EAAST,EAAK,aAAa,KAAO,IAAW,CAC/CM,EAAW,IAAI,EACf,GAAI,CACA,MAAMI,EAASC,CAAM,CACzB,OAASC,EAAO,CACZ,IAAMb,EAAWnC,EAAAA,WAAWgD,CAAK,EAAIA,EAAM,OAAS,IAAA,GAC9C,CAAE,SAAQ,aAAcb,EACxBN,EAAiBO,EAAMT,EAAQQ,CAAQ,EACvC,CAAE,OAAQ,EAAG,UAAW,CAAC,CAAE,EAC7BH,IAAW,EAAGU,EAAWF,EAASQ,EAAOV,EAAK,MAAOW,CAAY,CAAC,EAC7DlB,EAAU,OAAS,GAAGW,EAAWX,EAAU,KAAK,GAAG,CAAC,EAC7DmB,IAAUF,CAAK,CACnB,CACJ,CAAC,EAED,OACI,EAAA1B,EAAA,IAAA,CAACrB,EAAAA,aAAD,CAAc,GAAImC,EACd,UAAA,EAAAd,EAAA,KAAA,CAACpB,EAAAA,KAAD,CAAM,WAAA,GAAW,SAAU2C,EAAQ,UAAW1C,EAAAA,GAAGC,EAAAA,QAAO,KAAM+C,CAAS,EAAvE,SAAA,CACKV,IAAY,OAAQ,EAAAnB,EAAA,IAAA,CAACjB,EAAAA,MAAD,CAAO,QAAQ,SAAS,YAAaoC,CAAU,CAAA,EACnEd,EAAO,IAAK,IACT,EAAAL,EAAA,IAAA,CAAChB,EAAAA,iBAAD,CAAmC,OAAQoB,CAAQ,EAA5BA,EAAM,IAAsB,CACtD,EACA0B,GACD,EAAA9B,EAAA,IAAA,CAACf,EAAAA,OAAD,CAAQ,KAAK,SAAS,UAAA,GAAU,KAAK,KAAK,QAAS6B,EAAK,UAAU,aAC7D,SAAAiB,CACG,CAAA,EACPC,IAAW,IAAA,KACR,EAAAhC,EAAA,KAAA,CAAAd,EAAAA,SAAA,CAAA,SAAA,EACI,EAAAc,EAAA,IAAA,CAACb,EAAAA,QAAD,CAAS,MAAO6B,EAAK,OAAU,CAAA,GAC/B,EAAAhB,EAAA,IAAA,CAAC,MAAD,CAAK,UAAWlB,EAAAA,QAAO,OAAS,SAAAkD,CAAY,CAAA,CAC9C,CAAA,CAAA,EAELC,CACC,C,EACI,CAAA,CAEtB,C"}
@@ -0,0 +1,83 @@
1
+ import { cn as e } from "../../utils/cn.js";
2
+ import { Alert as t } from "../Alert/Alert.js";
3
+ import { Button as n } from "../Button/Button.js";
4
+ import { Divider as r } from "../Divider/Divider.js";
5
+ import { Form as i } from "../Form/Form.js";
6
+ import { useZodForm as a } from "../../forms/use-zod-form.js";
7
+ import { isApiError as o } from "../../http/errors.js";
8
+ import { useDescribeApiError as s } from "../../http/use-describe-api-error.js";
9
+ import { AuthFieldControl as c } from "./AuthFieldControl.js";
10
+ import { DEFAULT_AUTH_FORM_LABELS as l } from "./auth-defaults.js";
11
+ import u from "./AuthForm.module.js";
12
+ import { useState as d } from "react";
13
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
14
+ import { FormProvider as h } from "react-hook-form";
15
+ //#region src/components/AuthForm/AuthForm.tsx
16
+ function g(e, t) {
17
+ let n = {};
18
+ for (let t of e) n[t.name] = t.type !== "checkbox" && "";
19
+ return {
20
+ ...n,
21
+ ...t
22
+ };
23
+ }
24
+ function _(e, t, n) {
25
+ let r = new Set(t.map((e) => e.name)), i = [], a = 0;
26
+ for (let [t, o] of Object.entries(n)) r.has(t) ? (e.setError(t, {
27
+ type: "server",
28
+ message: o
29
+ }, { shouldFocus: a === 0 }), a += 1) : i.push(o);
30
+ return {
31
+ marked: a,
32
+ unmatched: i
33
+ };
34
+ }
35
+ function v({ schema: v, fields: y, onSubmit: b, submitLabel: x = "Enviar", defaultValues: S, beforeSubmit: C, afterSubmit: w, social: T, labels: E, errorOptions: D, onError: O, className: k }) {
36
+ let A = {
37
+ ...l,
38
+ ...E
39
+ }, j = s(), [M, N] = d(null), P = a(v, { defaultValues: g(y, S) }), F = P.handleSubmit(async (e) => {
40
+ N(null);
41
+ try {
42
+ await b(e);
43
+ } catch (e) {
44
+ let t = o(e) ? e.fields : void 0, { marked: n, unmatched: r } = t ? _(P, y, t) : {
45
+ marked: 0,
46
+ unmatched: []
47
+ };
48
+ n === 0 ? N(j(e, A.error, D)) : r.length > 0 && N(r.join(" ")), O?.(e);
49
+ }
50
+ });
51
+ return /* @__PURE__ */ p(h, {
52
+ ...P,
53
+ children: /* @__PURE__ */ m(i, {
54
+ noValidate: !0,
55
+ onSubmit: F,
56
+ className: e(u.form, k),
57
+ children: [
58
+ M !== null && /* @__PURE__ */ p(t, {
59
+ variant: "danger",
60
+ description: M
61
+ }),
62
+ y.map((e) => /* @__PURE__ */ p(c, { config: e }, e.name)),
63
+ C,
64
+ /* @__PURE__ */ p(n, {
65
+ type: "submit",
66
+ fullWidth: !0,
67
+ size: "lg",
68
+ loading: P.formState.isSubmitting,
69
+ children: x
70
+ }),
71
+ T !== void 0 && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(r, { label: A.divider }), /* @__PURE__ */ p("div", {
72
+ className: u.social,
73
+ children: T
74
+ })] }),
75
+ w
76
+ ]
77
+ })
78
+ });
79
+ }
80
+ //#endregion
81
+ export { v as AuthForm };
82
+
83
+ //# sourceMappingURL=AuthForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthForm.js","names":["styles","_Fragment","AuthForm_module_default","Fragment$1","initialValues","base","field","fields","overrides","markServerFields","names","unmatched","marked","name","message","messages","form","AuthForm","text","DEFAULT_AUTH_FORM_LABELS","labels","describe","useDescribeApiError","failure","setFailure","useState","useZodForm","schema","defaultValues","submit","onSubmit","values","error","isApiError","errorOptions","onError","FormProvider","Form","cn","className","Alert","AuthFieldControl","beforeSubmit","Button","submitLabel","social","Divider","afterSubmit"],"sources":["../../../src/components/AuthForm/AuthForm.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { FormProvider } from \"react-hook-form\";\nimport type { DefaultValues, Path, UseFormReturn } from \"react-hook-form\";\nimport type { z } from \"zod\";\nimport { Alert } from \"@/components/Alert\";\nimport { Button } from \"@/components/Button\";\nimport { Divider } from \"@/components/Divider\";\nimport { Form } from \"@/components/Form\";\nimport { useZodForm } from \"@/forms/use-zod-form\";\nimport { isApiError } from \"@/http/errors\";\nimport { useDescribeApiError } from \"@/http/use-describe-api-error\";\nimport { cn } from \"@/utils/cn\";\nimport { AuthFieldControl } from \"./AuthFieldControl\";\nimport { DEFAULT_AUTH_FORM_LABELS } from \"./auth-defaults\";\nimport type { AuthField, AuthFormLabels, AuthFormProps, AuthFormValues } from \"./types\";\nimport styles from \"./AuthForm.module.css\";\n\n/**\n * Initial values for every declared field.\n *\n * react-hook-form needs a defined value per field, or the controlled inputs\n * start uncontrolled and React warns on the first keystroke — and a missing\n * checkbox would submit `undefined`, which a `z.boolean()` rejects with a\n * message about types rather than about the terms.\n *\n * @param fields - The declared fields.\n * @param overrides - The caller's `defaultValues`, which win.\n * @returns One value per field.\n */\nfunction initialValues(\n fields: readonly AuthField[],\n overrides: object | undefined,\n): Record<string, unknown> {\n const base: Record<string, unknown> = {};\n for (const field of fields) base[field.name] = field.type === \"checkbox\" ? false : \"\";\n return { ...base, ...overrides };\n}\n\n/**\n * Attach the server's per-field messages to the fields this form shows.\n *\n * Only names present in `fields` are marked: the API can name a field the screen\n * does not render, and marking an input that does not exist leaves an error the\n * user can never clear. The first marked field takes focus.\n *\n * @param form - The form to mark.\n * @param fields - The declared fields.\n * @param messages - `error.fields`, keyed by field name.\n * @returns The messages that matched no declared field.\n */\nfunction markServerFields<TValues extends AuthFormValues<z.ZodTypeAny>>(\n form: UseFormReturn<TValues>,\n fields: readonly AuthField[],\n messages: Record<string, string>,\n): { marked: number; unmatched: string[] } {\n const names = new Set(fields.map((field) => field.name));\n const unmatched: string[] = [];\n let marked = 0;\n for (const [name, message] of Object.entries(messages)) {\n if (!names.has(name)) {\n unmatched.push(message);\n continue;\n }\n form.setError(\n name as Path<TValues>,\n { type: \"server\", message },\n {\n shouldFocus: marked === 0,\n },\n );\n marked += 1;\n }\n return { marked, unmatched };\n}\n\n/**\n * A complete auth form generated from a list of field configs and a zod schema.\n *\n * Every hand-built login and sign-up screen repeated the same wiring: a\n * `useZodForm`, one labelled input per field with its error slot, a password eye,\n * a submit button disabled while the request runs, and a `catch` that copied the\n * 422's field messages back onto the inputs. The app now declares *which* fields\n * and *what happens on submit*; the rest is here, built on the SDK's own controls\n * and its forms layer (`useZodForm` + `FormProvider` + `FormField`).\n *\n * Errors thrown by `onSubmit` are shown, never rethrown — a rethrow from a submit\n * handler is an unhandled rejection with nowhere to go. A `TempestApiError` whose\n * `fields` name fields of this form marks them; anything else, and any field\n * message that matched no declared field, goes to an `Alert` above the fields,\n * worded by `describeApiError`. Pass `onError` to log.\n *\n * @example\n * const schema = z.object({ email: z.email(\"E-mail inválido\") });\n * <AuthForm\n * schema={schema}\n * fields={[{ name: \"email\", type: \"email\", label: \"E-mail\" }]}\n * submitLabel=\"Continuar\"\n * onSubmit={async (values) => { await api.post(\"/auth/magic-link\", { body: values }); }}\n * />\n */\nexport function AuthForm<TSchema extends z.ZodTypeAny>({\n schema,\n fields,\n onSubmit,\n submitLabel = \"Enviar\",\n defaultValues,\n beforeSubmit,\n afterSubmit,\n social,\n labels,\n errorOptions,\n onError,\n className,\n}: AuthFormProps<TSchema>): ReactNode {\n const text: AuthFormLabels = { ...DEFAULT_AUTH_FORM_LABELS, ...labels };\n const describe = useDescribeApiError();\n const [failure, setFailure] = useState<string | null>(null);\n const form = useZodForm(schema, {\n defaultValues: initialValues(fields, defaultValues) as DefaultValues<\n AuthFormValues<TSchema>\n >,\n });\n\n const submit = form.handleSubmit(async (values) => {\n setFailure(null);\n try {\n await onSubmit(values);\n } catch (error) {\n const messages = isApiError(error) ? error.fields : undefined;\n const { marked, unmatched } = messages\n ? markServerFields(form, fields, messages)\n : { marked: 0, unmatched: [] };\n if (marked === 0) setFailure(describe(error, text.error, errorOptions));\n else if (unmatched.length > 0) setFailure(unmatched.join(\" \"));\n onError?.(error);\n }\n });\n\n return (\n <FormProvider {...form}>\n <Form noValidate onSubmit={submit} className={cn(styles.form, className)}>\n {failure !== null && <Alert variant=\"danger\" description={failure} />}\n {fields.map((field) => (\n <AuthFieldControl key={field.name} config={field} />\n ))}\n {beforeSubmit}\n <Button type=\"submit\" fullWidth size=\"lg\" loading={form.formState.isSubmitting}>\n {submitLabel}\n </Button>\n {social !== undefined && (\n <>\n <Divider label={text.divider} />\n <div className={styles.social}>{social}</div>\n </>\n )}\n {afterSubmit}\n </Form>\n </FormProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,SAASI,EACL,GACA,GACuB;CACvB,IAAMC,IAAgC,CAAC;CACvC,KAAK,IAAMC,KAASC,GAAQ,EAAKD,EAAM,QAAQA,EAAM,SAAS,cAAqB;CACnF,OAAO;EAAE,GAAGD;EAAM,GAAGG;CAAU;AACnC;AAcA,SAASC,EACL,GACA,GACA,GACuC;CACvC,IAAMC,IAAQ,IAAI,IAAIH,EAAO,KAAK,MAAUD,EAAM,IAAI,CAAC,GACjDK,IAAsB,CAAC,GACzBC,IAAS;CACb,KAAK,IAAM,CAACC,GAAMC,MAAY,OAAO,QAAQC,CAAQ,GACjD,AAAKL,EAAM,IAAIG,CAAI,KAInBG,EAAK,SACDH,GACA;EAAE,MAAM;EAAU;CAAQ,GAC1B,EACI,aAAaD,MAAW,EAC5B,CACJ,GACA,KAAU,KAVND,EAAU,KAAKG,CAAO;CAY9B,OAAO;EAAE;EAAQ;CAAU;AAC/B;AA2BA,SAAgBG,EAAuC,EACnD,WACA,WACA,aACA,iBAAc,UACd,kBACA,iBACA,gBACA,WACA,WACA,iBACA,YACA,gBACkC;CAClC,IAAMC,IAAuB;EAAE,GAAGC;EAA0B,GAAGC;CAAO,GAChEC,IAAWC,EAAoB,GAC/B,CAACC,GAASC,KAAcC,EAAwB,IAAI,GACpDT,IAAOU,EAAWC,GAAQ,EAC5B,eAAevB,EAAcG,GAAQqB,CAAa,EAGtD,CAAC,GAEKC,IAASb,EAAK,aAAa,OAAO,MAAW;EAC/C,EAAW,IAAI;EACf,IAAI;GACA,MAAMc,EAASC,CAAM;EACzB,SAASC,GAAO;GACZ,IAAMjB,IAAWkB,EAAWD,CAAK,IAAIA,EAAM,SAAS,KAAA,GAC9C,EAAE,WAAQ,iBAAcjB,IACxBN,EAAiBO,GAAMT,GAAQQ,CAAQ,IACvC;IAAE,QAAQ;IAAG,WAAW,CAAC;GAAE;GAGjC,AAFIH,MAAW,IAAGY,EAAWH,EAASW,GAAOd,EAAK,OAAOgB,CAAY,CAAC,IAC7DvB,EAAU,SAAS,KAAGa,EAAWb,EAAU,KAAK,GAAG,CAAC,GAC7DwB,IAAUH,CAAK;EACnB;CACJ,CAAC;CAED,OACI,kBAACI,GAAD;EAAc,GAAIpB;EACd,UAAA,kBAACqB,GAAD;GAAM,YAAA;GAAW,UAAUR;GAAQ,WAAWS,EAAGtC,EAAO,MAAMuC,CAAS;GAAvE,UAAA;IACKhB,MAAY,QAAQ,kBAACiB,GAAD;KAAO,SAAQ;KAAS,aAAajB;IAAU,CAAA;IACnEhB,EAAO,KAAK,MACT,kBAACkC,GAAD,EAAmC,QAAQnC,EAAQ,GAA5BA,EAAM,IAAsB,CACtD;IACAoC;IACD,kBAACC,GAAD;KAAQ,MAAK;KAAS,WAAA;KAAU,MAAK;KAAK,SAAS3B,EAAK,UAAU;KAC7D,UAAA4B;IACG,CAAA;IACPC,MAAW,KAAA,KACR,kBAAA5C,GAAA,EAAA,UAAA,CACI,kBAAC6C,GAAD,EAAS,OAAO5B,EAAK,QAAU,CAAA,GAC/B,kBAAC,OAAD;KAAK,WAAWlB,EAAO;KAAS,UAAA6C;IAAY,CAAA,CAC9C,EAAA,CAAA;IAELE;GACC;;CACI,CAAA;AAEtB"}
@@ -0,0 +1,3 @@
1
+ require("../../styles/component/AuthForm.css");
2
+ var e=`tempest_form_Ry1iO`,t=`tempest_social_ZiYgW`,n=`tempest_link_iisLJ`,r=`tempest_forgot_kjNlS`,i=`tempest_prompt_cuJKg`,a=`tempest_hints_AYoGY`,o={form:e,social:t,link:n,forgot:r,prompt:i,hints:a};exports.default=o,exports.forgot=r,exports.form=e,exports.hints=a,exports.link=n,exports.prompt=i,exports.social=t;
3
+ //# sourceMappingURL=AuthForm.module.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthForm.module.cjs","names":["form","social","link","forgot","prompt","hints","AuthForm_module_default"],"sources":["../../../src/components/AuthForm/AuthForm.module.css"],"sourcesContent":["/* ============================================================\n * AuthForm — the generated form and the links its presets add.\n * ============================================================ */\n.form {\n width: 100%;\n}\n\n.social {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n gap: var(--tempest-space-2);\n}\n\n.link {\n color: var(--tempest-primary);\n font-weight: var(--tempest-weight-semibold);\n text-decoration: none;\n border-radius: var(--tempest-radius-xs);\n}\n\n.link:hover {\n text-decoration: underline;\n}\n\n.link:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: var(--tempest-focus-ring-offset);\n}\n\n.forgot {\n align-self: flex-end;\n font-size: var(--tempest-text-sm);\n}\n\n.prompt {\n margin: 0;\n color: var(--tempest-text-muted);\n font-size: var(--tempest-text-sm);\n text-align: center;\n}\n\n.hints {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-1);\n margin: 0;\n padding-left: var(--tempest-space-5);\n color: var(--tempest-text-muted);\n font-size: var(--tempest-text-sm);\n}\n"],"mappings":";"}
@@ -0,0 +1,14 @@
1
+ import "../../styles/component/AuthForm.css";
2
+ //#region src/components/AuthForm/AuthForm.module.css
3
+ var e = "tempest_form_Ry1iO", t = "tempest_social_ZiYgW", n = "tempest_link_iisLJ", r = "tempest_forgot_kjNlS", i = "tempest_prompt_cuJKg", a = "tempest_hints_AYoGY", o = {
4
+ form: e,
5
+ social: t,
6
+ link: n,
7
+ forgot: r,
8
+ prompt: i,
9
+ hints: a
10
+ };
11
+ //#endregion
12
+ export { o as default, r as forgot, e as form, a as hints, n as link, i as prompt, t as social };
13
+
14
+ //# sourceMappingURL=AuthForm.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthForm.module.js","names":["form","social","link","forgot","prompt","hints","AuthForm_module_default"],"sources":["../../../src/components/AuthForm/AuthForm.module.css"],"sourcesContent":["/* ============================================================\n * AuthForm — the generated form and the links its presets add.\n * ============================================================ */\n.form {\n width: 100%;\n}\n\n.social {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n gap: var(--tempest-space-2);\n}\n\n.link {\n color: var(--tempest-primary);\n font-weight: var(--tempest-weight-semibold);\n text-decoration: none;\n border-radius: var(--tempest-radius-xs);\n}\n\n.link:hover {\n text-decoration: underline;\n}\n\n.link:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: var(--tempest-focus-ring-offset);\n}\n\n.forgot {\n align-self: flex-end;\n font-size: var(--tempest-text-sm);\n}\n\n.prompt {\n margin: 0;\n color: var(--tempest-text-muted);\n font-size: var(--tempest-text-sm);\n text-align: center;\n}\n\n.hints {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-1);\n margin: 0;\n padding-left: var(--tempest-space-5);\n color: var(--tempest-text-muted);\n font-size: var(--tempest-text-sm);\n}\n"],"mappings":";"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../utils/cn.cjs"),t=require("./AuthForm.module.cjs");let n=require("react/jsx-runtime"),r=require("react-router");function i({to:i,children:a,className:o}){return(0,n.jsx)(r.Link,{to:i,className:e.cn(t.default.link,o),children:a})}function a({prompt:e,label:r,to:a}){return a===void 0?null:(0,n.jsxs)(`p`,{className:t.default.prompt,children:[e,` `,(0,n.jsx)(i,{to:a,children:r})]})}exports.AuthLink=i,exports.AuthPrompt=a;
2
+ //# sourceMappingURL=AuthLinks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthLinks.cjs","names":["Link","cn","styles","require_cn","require_AuthForm_module","react_jsx_runtime","react_router","AuthLink","className","AuthPrompt","to","prompt","label"],"sources":["../../../src/components/AuthForm/AuthLinks.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Link } from \"react-router\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./AuthForm.module.css\";\n\n/**\n * A router link styled as the auth screens' inline action.\n *\n * Router `Link`, not `<a>`: the screens it connects are routes of the same app,\n * and a full reload between login and sign-up throws away the query cache and\n * any form state the user typed.\n *\n * @param props - Destination, content and an extra class.\n * @returns The link.\n */\nexport function AuthLink({\n to,\n children,\n className,\n}: {\n to: string;\n children: ReactNode;\n className?: string;\n}): ReactNode {\n return (\n <Link to={to} className={cn(styles.link, className)}>\n {children}\n </Link>\n );\n}\n\n/**\n * The \"Não tem uma conta? Cadastre-se\" line under a form.\n *\n * @param props - The leading sentence, the link text and its destination.\n * @returns The paragraph, or `null` when there is no destination.\n */\nexport function AuthPrompt({\n prompt,\n label,\n to,\n}: {\n prompt: ReactNode;\n label: ReactNode;\n to: string | undefined;\n}): ReactNode {\n if (to === undefined) return null;\n return (\n <p className={styles.prompt}>\n {prompt} <AuthLink to={to}>{label}</AuthLink>\n </p>\n );\n}\n"],"mappings":"A,sIAeA,SAAgBO,EAAS,CACrB,KACA,WACA,aAKU,CACV,OACI,EAAAF,EAAA,IAAA,CAACL,EAAAA,KAAD,CAAU,KAAI,UAAWC,EAAAA,GAAGC,EAAAA,QAAO,KAAMM,CAAS,EAC7C,UACC,CAAA,CAEd,CAQA,SAAgBC,EAAW,CACvB,SACA,QACA,MAKU,CAEV,OADIC,IAAO,IAAA,GAAkB,MAEzB,EAAAL,EAAA,KAAA,CAAC,IAAD,CAAG,UAAWH,EAAAA,QAAO,OAArB,SAAA,CACKS,EAAO,KAAC,EAAAN,EAAA,IAAA,CAACE,EAAD,CAAc,KAAK,SAAAK,CAAgB,CAAA,CAC7C,C,EAEX,C"}
@@ -0,0 +1,29 @@
1
+ import { cn as e } from "../../utils/cn.js";
2
+ import t from "./AuthForm.module.js";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ import { Link as i } from "react-router";
5
+ //#region src/components/AuthForm/AuthLinks.tsx
6
+ function a({ to: r, children: a, className: o }) {
7
+ return /* @__PURE__ */ n(i, {
8
+ to: r,
9
+ className: e(t.link, o),
10
+ children: a
11
+ });
12
+ }
13
+ function o({ prompt: e, label: i, to: o }) {
14
+ return o === void 0 ? null : /* @__PURE__ */ r("p", {
15
+ className: t.prompt,
16
+ children: [
17
+ e,
18
+ " ",
19
+ /* @__PURE__ */ n(a, {
20
+ to: o,
21
+ children: i
22
+ })
23
+ ]
24
+ });
25
+ }
26
+ //#endregion
27
+ export { a as AuthLink, o as AuthPrompt };
28
+
29
+ //# sourceMappingURL=AuthLinks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthLinks.js","names":["styles","AuthForm_module_default","AuthLink","Link","cn","className","AuthPrompt","to","prompt","label"],"sources":["../../../src/components/AuthForm/AuthLinks.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Link } from \"react-router\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./AuthForm.module.css\";\n\n/**\n * A router link styled as the auth screens' inline action.\n *\n * Router `Link`, not `<a>`: the screens it connects are routes of the same app,\n * and a full reload between login and sign-up throws away the query cache and\n * any form state the user typed.\n *\n * @param props - Destination, content and an extra class.\n * @returns The link.\n */\nexport function AuthLink({\n to,\n children,\n className,\n}: {\n to: string;\n children: ReactNode;\n className?: string;\n}): ReactNode {\n return (\n <Link to={to} className={cn(styles.link, className)}>\n {children}\n </Link>\n );\n}\n\n/**\n * The \"Não tem uma conta? Cadastre-se\" line under a form.\n *\n * @param props - The leading sentence, the link text and its destination.\n * @returns The paragraph, or `null` when there is no destination.\n */\nexport function AuthPrompt({\n prompt,\n label,\n to,\n}: {\n prompt: ReactNode;\n label: ReactNode;\n to: string | undefined;\n}): ReactNode {\n if (to === undefined) return null;\n return (\n <p className={styles.prompt}>\n {prompt} <AuthLink to={to}>{label}</AuthLink>\n </p>\n );\n}\n"],"mappings":";;;;;AAeA,SAAgBE,EAAS,EACrB,OACA,aACA,gBAKU;CACV,OACI,kBAACC,GAAD;EAAU;EAAI,WAAWC,EAAGJ,EAAO,MAAMK,CAAS;EAC7C;CACC,CAAA;AAEd;AAQA,SAAgBC,EAAW,EACvB,WACA,UACA,SAKU;CAEV,OADIC,MAAO,KAAA,IAAkB,OAEzB,kBAAC,KAAD;EAAG,WAAWP,EAAO;EAArB,UAAA;GACKQ;GAAO;GAAC,kBAACN,GAAD;IAAc;IAAK,UAAAO;GAAgB,CAAA;EAC7C;;AAEX"}
@@ -0,0 +1,2 @@
1
+ const e=require("./auth-defaults.cjs"),t=require("./AuthForm.cjs"),n=require("./AuthLinks.cjs"),r=require("./auth-schemas.cjs");let i=require("react/jsx-runtime");var a={signInPrompt:`Lembrou a senha?`,signIn:`Entrar`};function o({schema:o,fields:s,links:c,labels:l,submitLabel:u=`Enviar link`,...d}){let f={...a,...l};return(0,i.jsx)(t.AuthForm,{...d,schema:o??r.forgotPasswordSchema,fields:s??e.FORGOT_PASSWORD_FIELDS,labels:l,submitLabel:u,afterSubmit:(0,i.jsx)(n.AuthPrompt,{prompt:f.signInPrompt,label:f.signIn,to:c?.signIn})})}exports.ForgotPasswordForm=o;
2
+ //# sourceMappingURL=ForgotPasswordForm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgotPasswordForm.cjs","names":["AuthForm","forgotPasswordSchema","FORGOT_PASSWORD_FIELDS","AuthPrompt","require_auth_defaults","require_AuthForm","require_AuthLinks","require_auth_schemas","react_jsx_runtime","DEFAULT_LABELS","ForgotPasswordForm","props","text","labels","schema","fields","links"],"sources":["../../../src/components/AuthForm/ForgotPasswordForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { FORGOT_PASSWORD_FIELDS } from \"./auth-defaults\";\nimport { AuthPrompt } from \"./AuthLinks\";\nimport { forgotPasswordSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\n\n/** Sentences of {@link ForgotPasswordForm}, PT-BR by default. */\nexport interface ForgotPasswordFormLabels extends AuthFormLabels {\n /** Default `\"Lembrou a senha?\"`. */\n signInPrompt: string;\n /** Default `\"Entrar\"`. */\n signIn: string;\n}\n\n/** Routes the forgot-password form links to. */\nexport interface ForgotPasswordFormLinks {\n /** \"Entrar\" link, under the form. */\n signIn?: string;\n}\n\nexport interface ForgotPasswordFormProps<\n TSchema extends z.ZodTypeAny = typeof forgotPasswordSchema,\n> extends AuthPresetProps<TSchema> {\n /** Where the links go. */\n links?: ForgotPasswordFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<ForgotPasswordFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<ForgotPasswordFormLabels, keyof AuthFormLabels> = {\n signInPrompt: \"Lembrou a senha?\",\n signIn: \"Entrar\",\n};\n\n/**\n * \"Forgot password\" form: the e-mail the reset link goes to.\n *\n * The confirmation screen after a successful submit is the app's call — most\n * backends answer the same whether or not the address exists, so the copy\n * belongs next to the backend's policy, not here.\n *\n * @example\n * const [sent, setSent] = useState(false);\n * <ForgotPasswordForm\n * onSubmit={async (values) => { await api.post(\"/auth/forgot-password\", { body: values }); setSent(true); }}\n * links={{ signIn: \"/login\" }}\n * />\n */\nexport function ForgotPasswordForm<TSchema extends z.ZodTypeAny = typeof forgotPasswordSchema>({\n schema,\n fields,\n links,\n labels,\n submitLabel = \"Enviar link\",\n ...props\n}: ForgotPasswordFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (forgotPasswordSchema as unknown as TSchema)}\n fields={\n fields ?? (FORGOT_PASSWORD_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])\n }\n labels={labels}\n submitLabel={submitLabel}\n afterSubmit={\n <AuthPrompt prompt={text.signInPrompt} label={text.signIn} to={links?.signIn} />\n }\n />\n );\n}\n"],"mappings":"A,mKA+BA,IAAMS,EAAuE,CACzE,aAAc,mBACd,OAAQ,QACZ,EAgBA,SAAgBC,EAA+E,CAC3F,SACA,SACA,QACA,SACA,cAAc,cACd,GAAGC,GACyC,CAC5C,IAAMC,EAAO,CAAE,GAAGH,EAAgB,GAAGI,CAAO,EAC5C,OACI,EAAAL,EAAA,IAAA,CAACR,EAAAA,SAAD,CACI,GAAIW,EACJ,OAAQG,GAAWb,EAAAA,qBACnB,OACIc,GAAWb,EAAAA,uBAEP,SACK,cACb,aACI,EAAAM,EAAA,IAAA,CAACL,EAAAA,WAAD,CAAY,OAAQS,EAAK,aAAc,MAAOA,EAAK,OAAQ,GAAII,GAAO,MAAS,CAAA,CAEtF,CAAA,CAET,C"}
@@ -0,0 +1,32 @@
1
+ import { FORGOT_PASSWORD_FIELDS as e } from "./auth-defaults.js";
2
+ import { AuthForm as t } from "./AuthForm.js";
3
+ import { AuthPrompt as n } from "./AuthLinks.js";
4
+ import { forgotPasswordSchema as r } from "./auth-schemas.js";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ //#region src/components/AuthForm/ForgotPasswordForm.tsx
7
+ var a = {
8
+ signInPrompt: "Lembrou a senha?",
9
+ signIn: "Entrar"
10
+ };
11
+ function o({ schema: o, fields: s, links: c, labels: l, submitLabel: u = "Enviar link", ...d }) {
12
+ let f = {
13
+ ...a,
14
+ ...l
15
+ };
16
+ return /* @__PURE__ */ i(t, {
17
+ ...d,
18
+ schema: o ?? r,
19
+ fields: s ?? e,
20
+ labels: l,
21
+ submitLabel: u,
22
+ afterSubmit: /* @__PURE__ */ i(n, {
23
+ prompt: f.signInPrompt,
24
+ label: f.signIn,
25
+ to: c?.signIn
26
+ })
27
+ });
28
+ }
29
+ //#endregion
30
+ export { o as ForgotPasswordForm };
31
+
32
+ //# sourceMappingURL=ForgotPasswordForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgotPasswordForm.js","names":["DEFAULT_LABELS","ForgotPasswordForm","props","text","labels","AuthForm","schema","forgotPasswordSchema","fields","FORGOT_PASSWORD_FIELDS","AuthPrompt","links"],"sources":["../../../src/components/AuthForm/ForgotPasswordForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { FORGOT_PASSWORD_FIELDS } from \"./auth-defaults\";\nimport { AuthPrompt } from \"./AuthLinks\";\nimport { forgotPasswordSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\n\n/** Sentences of {@link ForgotPasswordForm}, PT-BR by default. */\nexport interface ForgotPasswordFormLabels extends AuthFormLabels {\n /** Default `\"Lembrou a senha?\"`. */\n signInPrompt: string;\n /** Default `\"Entrar\"`. */\n signIn: string;\n}\n\n/** Routes the forgot-password form links to. */\nexport interface ForgotPasswordFormLinks {\n /** \"Entrar\" link, under the form. */\n signIn?: string;\n}\n\nexport interface ForgotPasswordFormProps<\n TSchema extends z.ZodTypeAny = typeof forgotPasswordSchema,\n> extends AuthPresetProps<TSchema> {\n /** Where the links go. */\n links?: ForgotPasswordFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<ForgotPasswordFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<ForgotPasswordFormLabels, keyof AuthFormLabels> = {\n signInPrompt: \"Lembrou a senha?\",\n signIn: \"Entrar\",\n};\n\n/**\n * \"Forgot password\" form: the e-mail the reset link goes to.\n *\n * The confirmation screen after a successful submit is the app's call — most\n * backends answer the same whether or not the address exists, so the copy\n * belongs next to the backend's policy, not here.\n *\n * @example\n * const [sent, setSent] = useState(false);\n * <ForgotPasswordForm\n * onSubmit={async (values) => { await api.post(\"/auth/forgot-password\", { body: values }); setSent(true); }}\n * links={{ signIn: \"/login\" }}\n * />\n */\nexport function ForgotPasswordForm<TSchema extends z.ZodTypeAny = typeof forgotPasswordSchema>({\n schema,\n fields,\n links,\n labels,\n submitLabel = \"Enviar link\",\n ...props\n}: ForgotPasswordFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (forgotPasswordSchema as unknown as TSchema)}\n fields={\n fields ?? (FORGOT_PASSWORD_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])\n }\n labels={labels}\n submitLabel={submitLabel}\n afterSubmit={\n <AuthPrompt prompt={text.signInPrompt} label={text.signIn} to={links?.signIn} />\n }\n />\n );\n}\n"],"mappings":";;;;;;AA+BA,IAAMA,IAAuE;CACzE,cAAc;CACd,QAAQ;AACZ;AAgBA,SAAgBC,EAA+E,EAC3F,WACA,WACA,UACA,WACA,iBAAc,eACd,GAAGC,KACyC;CAC5C,IAAMC,IAAO;EAAE,GAAGH;EAAgB,GAAGI;CAAO;CAC5C,OACI,kBAACC,GAAD;EACI,GAAIH;EACJ,QAAQI,KAAWC;EACnB,QACIC,KAAWC;EAEP;EACK;EACb,aACI,kBAACC,GAAD;GAAY,QAAQP,EAAK;GAAc,OAAOA,EAAK;GAAQ,IAAIQ,GAAO;EAAS,CAAA;CAEtF,CAAA;AAET"}
@@ -0,0 +1,2 @@
1
+ const e=require("./auth-defaults.cjs"),t=require("./AuthForm.module.cjs"),n=require("./AuthForm.cjs"),r=require("./AuthLinks.cjs"),i=require("./auth-schemas.cjs");let a=require("react/jsx-runtime");var o={forgotPassword:`Esqueceu a senha?`,signUpPrompt:`Não tem uma conta?`,signUp:`Cadastre-se`};function s({schema:s,fields:c,links:l,labels:u,submitLabel:d=`Entrar`,...f}){let p={...o,...u};return(0,a.jsx)(n.AuthForm,{...f,schema:s??i.loginSchema,fields:c??e.LOGIN_FIELDS,labels:u,submitLabel:d,beforeSubmit:l?.forgotPassword!==void 0&&(0,a.jsx)(r.AuthLink,{to:l.forgotPassword,className:t.default.forgot,children:p.forgotPassword}),afterSubmit:(0,a.jsx)(r.AuthPrompt,{prompt:p.signUpPrompt,label:p.signUp,to:l?.signUp})})}exports.LoginForm=s;
2
+ //# sourceMappingURL=LoginForm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginForm.cjs","names":["AuthForm","loginSchema","LOGIN_FIELDS","AuthLink","styles","AuthPrompt","require_auth_defaults","require_AuthForm_module","require_AuthForm","require_AuthLinks","require_auth_schemas","react_jsx_runtime","DEFAULT_LABELS","LoginForm","props","text","labels","schema","fields","links"],"sources":["../../../src/components/AuthForm/LoginForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { LOGIN_FIELDS } from \"./auth-defaults\";\nimport { AuthLink, AuthPrompt } from \"./AuthLinks\";\nimport { loginSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\nimport styles from \"./AuthForm.module.css\";\n\n/** Sentences of {@link LoginForm}, PT-BR by default. */\nexport interface LoginFormLabels extends AuthFormLabels {\n /** Default `\"Esqueceu a senha?\"`. */\n forgotPassword: string;\n /** Default `\"Não tem uma conta?\"`. */\n signUpPrompt: string;\n /** Default `\"Cadastre-se\"`. */\n signUp: string;\n}\n\n/** Routes the login form links to. Each link is rendered only when its route is set. */\nexport interface LoginFormLinks {\n /** \"Esqueceu a senha?\" link, above the submit button. */\n forgotPassword?: string;\n /** \"Cadastre-se\" link, under the form. */\n signUp?: string;\n}\n\nexport interface LoginFormProps<\n TSchema extends z.ZodTypeAny = typeof loginSchema,\n> extends AuthPresetProps<TSchema> {\n /** Where the links go. */\n links?: LoginFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<LoginFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<LoginFormLabels, keyof AuthFormLabels> = {\n forgotPassword: \"Esqueceu a senha?\",\n signUpPrompt: \"Não tem uma conta?\",\n signUp: \"Cadastre-se\",\n};\n\n/**\n * Sign-in form: e-mail and password, \"forgot password\" link, sign-up line and a\n * slot for social buttons.\n *\n * `AuthForm` with the defaults every app wrote by hand: the e-mail trimmed and\n * lower-cased before validation, `current-password` autocomplete so the saved\n * password is offered, and the two links in the place users look for them. What\n * happens on success — storing the session, redirecting — stays in `onSubmit`.\n *\n * @example\n * <LoginForm\n * onSubmit={async (values) => { await auth.login(values); navigate(\"/\"); }}\n * links={{ forgotPassword: \"/recuperar-senha\", signUp: \"/cadastro\" }}\n * social={<GoogleSignIn component={GoogleLogin} onSuccess={signInWithGoogle} />}\n * />\n */\nexport function LoginForm<TSchema extends z.ZodTypeAny = typeof loginSchema>({\n schema,\n fields,\n links,\n labels,\n submitLabel = \"Entrar\",\n ...props\n}: LoginFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (loginSchema as unknown as TSchema)}\n fields={fields ?? (LOGIN_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])}\n labels={labels}\n submitLabel={submitLabel}\n beforeSubmit={\n links?.forgotPassword !== undefined && (\n <AuthLink to={links.forgotPassword} className={styles.forgot}>\n {text.forgotPassword}\n </AuthLink>\n )\n }\n afterSubmit={\n <AuthPrompt prompt={text.signUpPrompt} label={text.signUp} to={links?.signUp} />\n }\n />\n );\n}\n"],"mappings":"A,sMAoCA,IAAMY,EAA8D,CAChE,eAAgB,oBAChB,aAAc,qBACd,OAAQ,aACZ,EAkBA,SAAgBC,EAA6D,CACzE,SACA,SACA,QACA,SACA,cAAc,SACd,GAAGC,GACgC,CACnC,IAAMC,EAAO,CAAE,GAAGH,EAAgB,GAAGI,CAAO,EAC5C,OACI,EAAAL,EAAA,IAAA,CAACX,EAAAA,SAAD,CACI,GAAIc,EACJ,OAAQG,GAAWhB,EAAAA,YACnB,OAAQiB,GAAWhB,EAAAA,aACX,SACK,cACb,aACIiB,GAAO,iBAAmB,IAAA,KACtB,EAAAR,EAAA,IAAA,CAACR,EAAAA,SAAD,CAAU,GAAIgB,EAAM,eAAgB,UAAWf,EAAAA,QAAO,OACjD,SAAAW,EAAK,cACA,CAAA,EAGlB,aACI,EAAAJ,EAAA,IAAA,CAACN,EAAAA,WAAD,CAAY,OAAQU,EAAK,aAAc,MAAOA,EAAK,OAAQ,GAAII,GAAO,MAAS,CAAA,CAEtF,CAAA,CAET,C"}
@@ -0,0 +1,39 @@
1
+ import { LOGIN_FIELDS as e } from "./auth-defaults.js";
2
+ import t from "./AuthForm.module.js";
3
+ import { AuthForm as n } from "./AuthForm.js";
4
+ import { AuthLink as r, AuthPrompt as i } from "./AuthLinks.js";
5
+ import { loginSchema as a } from "./auth-schemas.js";
6
+ import { jsx as o } from "react/jsx-runtime";
7
+ //#region src/components/AuthForm/LoginForm.tsx
8
+ var s = {
9
+ forgotPassword: "Esqueceu a senha?",
10
+ signUpPrompt: "Não tem uma conta?",
11
+ signUp: "Cadastre-se"
12
+ };
13
+ function c({ schema: c, fields: l, links: u, labels: d, submitLabel: f = "Entrar", ...p }) {
14
+ let m = {
15
+ ...s,
16
+ ...d
17
+ };
18
+ return /* @__PURE__ */ o(n, {
19
+ ...p,
20
+ schema: c ?? a,
21
+ fields: l ?? e,
22
+ labels: d,
23
+ submitLabel: f,
24
+ beforeSubmit: u?.forgotPassword !== void 0 && /* @__PURE__ */ o(r, {
25
+ to: u.forgotPassword,
26
+ className: t.forgot,
27
+ children: m.forgotPassword
28
+ }),
29
+ afterSubmit: /* @__PURE__ */ o(i, {
30
+ prompt: m.signUpPrompt,
31
+ label: m.signUp,
32
+ to: u?.signUp
33
+ })
34
+ });
35
+ }
36
+ //#endregion
37
+ export { c as LoginForm };
38
+
39
+ //# sourceMappingURL=LoginForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginForm.js","names":["styles","AuthForm_module_default","DEFAULT_LABELS","LoginForm","props","text","labels","AuthForm","schema","loginSchema","fields","LOGIN_FIELDS","links","AuthLink","AuthPrompt"],"sources":["../../../src/components/AuthForm/LoginForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { LOGIN_FIELDS } from \"./auth-defaults\";\nimport { AuthLink, AuthPrompt } from \"./AuthLinks\";\nimport { loginSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\nimport styles from \"./AuthForm.module.css\";\n\n/** Sentences of {@link LoginForm}, PT-BR by default. */\nexport interface LoginFormLabels extends AuthFormLabels {\n /** Default `\"Esqueceu a senha?\"`. */\n forgotPassword: string;\n /** Default `\"Não tem uma conta?\"`. */\n signUpPrompt: string;\n /** Default `\"Cadastre-se\"`. */\n signUp: string;\n}\n\n/** Routes the login form links to. Each link is rendered only when its route is set. */\nexport interface LoginFormLinks {\n /** \"Esqueceu a senha?\" link, above the submit button. */\n forgotPassword?: string;\n /** \"Cadastre-se\" link, under the form. */\n signUp?: string;\n}\n\nexport interface LoginFormProps<\n TSchema extends z.ZodTypeAny = typeof loginSchema,\n> extends AuthPresetProps<TSchema> {\n /** Where the links go. */\n links?: LoginFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<LoginFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<LoginFormLabels, keyof AuthFormLabels> = {\n forgotPassword: \"Esqueceu a senha?\",\n signUpPrompt: \"Não tem uma conta?\",\n signUp: \"Cadastre-se\",\n};\n\n/**\n * Sign-in form: e-mail and password, \"forgot password\" link, sign-up line and a\n * slot for social buttons.\n *\n * `AuthForm` with the defaults every app wrote by hand: the e-mail trimmed and\n * lower-cased before validation, `current-password` autocomplete so the saved\n * password is offered, and the two links in the place users look for them. What\n * happens on success — storing the session, redirecting — stays in `onSubmit`.\n *\n * @example\n * <LoginForm\n * onSubmit={async (values) => { await auth.login(values); navigate(\"/\"); }}\n * links={{ forgotPassword: \"/recuperar-senha\", signUp: \"/cadastro\" }}\n * social={<GoogleSignIn component={GoogleLogin} onSuccess={signInWithGoogle} />}\n * />\n */\nexport function LoginForm<TSchema extends z.ZodTypeAny = typeof loginSchema>({\n schema,\n fields,\n links,\n labels,\n submitLabel = \"Entrar\",\n ...props\n}: LoginFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (loginSchema as unknown as TSchema)}\n fields={fields ?? (LOGIN_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])}\n labels={labels}\n submitLabel={submitLabel}\n beforeSubmit={\n links?.forgotPassword !== undefined && (\n <AuthLink to={links.forgotPassword} className={styles.forgot}>\n {text.forgotPassword}\n </AuthLink>\n )\n }\n afterSubmit={\n <AuthPrompt prompt={text.signUpPrompt} label={text.signUp} to={links?.signUp} />\n }\n />\n );\n}\n"],"mappings":";;;;;;;AAoCA,IAAME,IAA8D;CAChE,gBAAgB;CAChB,cAAc;CACd,QAAQ;AACZ;AAkBA,SAAgBC,EAA6D,EACzE,WACA,WACA,UACA,WACA,iBAAc,UACd,GAAGC,KACgC;CACnC,IAAMC,IAAO;EAAE,GAAGH;EAAgB,GAAGI;CAAO;CAC5C,OACI,kBAACC,GAAD;EACI,GAAIH;EACJ,QAAQI,KAAWC;EACnB,QAAQC,KAAWC;EACX;EACK;EACb,cACIC,GAAO,mBAAmB,KAAA,KACtB,kBAACC,GAAD;GAAU,IAAID,EAAM;GAAgB,WAAWZ,EAAO;GACjD,UAAAK,EAAK;EACA,CAAA;EAGlB,aACI,kBAACS,GAAD;GAAY,QAAQT,EAAK;GAAc,OAAOA,EAAK;GAAQ,IAAIO,GAAO;EAAS,CAAA;CAEtF,CAAA;AAET"}
@@ -0,0 +1,2 @@
1
+ const e=require("./auth-defaults.cjs"),t=require("./AuthForm.module.cjs"),n=require("./AuthForm.cjs"),r=require("./AuthLinks.cjs"),i=require("./auth-schemas.cjs");let a=require("react/jsx-runtime");var o={signInPrompt:`Lembrou a senha?`,signIn:`Entrar`,hints:`Requisitos da senha`};function s({schema:s,fields:c,hints:l,links:u,labels:d,submitLabel:f=`Redefinir senha`,...p}){let m={...o,...d};return(0,a.jsx)(n.AuthForm,{...p,schema:s??i.resetPasswordSchema,fields:c??e.RESET_PASSWORD_FIELDS,labels:d,submitLabel:f,beforeSubmit:l!==void 0&&l.length>0&&(0,a.jsx)(`ul`,{className:t.default.hints,"aria-label":m.hints,children:l.map((e,t)=>(0,a.jsx)(`li`,{children:e},t))}),afterSubmit:(0,a.jsx)(r.AuthPrompt,{prompt:m.signInPrompt,label:m.signIn,to:u?.signIn})})}exports.ResetPasswordForm=s;
2
+ //# sourceMappingURL=ResetPasswordForm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResetPasswordForm.cjs","names":["AuthForm","resetPasswordSchema","RESET_PASSWORD_FIELDS","styles","AuthPrompt","require_auth_defaults","require_AuthForm_module","require_AuthForm","require_AuthLinks","require_auth_schemas","react_jsx_runtime","DEFAULT_LABELS","ResetPasswordForm","props","text","labels","schema","fields","hints","hint","index","links"],"sources":["../../../src/components/AuthForm/ResetPasswordForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { RESET_PASSWORD_FIELDS } from \"./auth-defaults\";\nimport { AuthPrompt } from \"./AuthLinks\";\nimport { resetPasswordSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\nimport styles from \"./AuthForm.module.css\";\n\n/** Sentences of {@link ResetPasswordForm}, PT-BR by default. */\nexport interface ResetPasswordFormLabels extends AuthFormLabels {\n /** Default `\"Lembrou a senha?\"`. */\n signInPrompt: string;\n /** Default `\"Entrar\"`. */\n signIn: string;\n /** Accessible name of the hints list. Default `\"Requisitos da senha\"`. */\n hints: string;\n}\n\n/** Routes the reset-password form links to. */\nexport interface ResetPasswordFormLinks {\n /** \"Entrar\" link, under the form. */\n signIn?: string;\n}\n\nexport interface ResetPasswordFormProps<\n TSchema extends z.ZodTypeAny = typeof resetPasswordSchema,\n> extends AuthPresetProps<TSchema> {\n /**\n * Password requirements listed above the submit button (\"Pelo menos 8\n * caracteres\", \"Uma letra maiúscula\"). Kept as text the app writes, because\n * only the backend knows its rules.\n */\n hints?: ReactNode[];\n /** Where the links go. */\n links?: ResetPasswordFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<ResetPasswordFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<ResetPasswordFormLabels, keyof AuthFormLabels> = {\n signInPrompt: \"Lembrou a senha?\",\n signIn: \"Entrar\",\n hints: \"Requisitos da senha\",\n};\n\n/**\n * \"Choose a new password\" form: password and confirmation, with the mismatch\n * reported under the confirmation field.\n *\n * The reset token stays out of the fields: it comes from the URL, and the app\n * adds it in `onSubmit` — `{ ...values, token }` — where it also decides what an\n * expired token looks like.\n *\n * @example\n * const [params] = useSearchParams();\n * <ResetPasswordForm\n * hints={[\"Pelo menos 8 caracteres\"]}\n * onSubmit={async (values) => {\n * await api.post(\"/auth/reset-password\", { body: { ...values, token: params.get(\"token\") } });\n * }}\n * />\n */\nexport function ResetPasswordForm<TSchema extends z.ZodTypeAny = typeof resetPasswordSchema>({\n schema,\n fields,\n hints,\n links,\n labels,\n submitLabel = \"Redefinir senha\",\n ...props\n}: ResetPasswordFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (resetPasswordSchema as unknown as TSchema)}\n fields={\n fields ?? (RESET_PASSWORD_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])\n }\n labels={labels}\n submitLabel={submitLabel}\n beforeSubmit={\n hints !== undefined &&\n hints.length > 0 && (\n <ul className={styles.hints} aria-label={text.hints}>\n {hints.map((hint, index) => (\n <li key={index}>{hint}</li>\n ))}\n </ul>\n )\n }\n afterSubmit={\n <AuthPrompt prompt={text.signInPrompt} label={text.signIn} to={links?.signIn} />\n }\n />\n );\n}\n"],"mappings":"A,sMAwCA,IAAMW,EAAsE,CACxE,aAAc,mBACd,OAAQ,SACR,MAAO,qBACX,EAmBA,SAAgBC,EAA6E,CACzF,SACA,SACA,QACA,QACA,SACA,cAAc,kBACd,GAAGC,GACwC,CAC3C,IAAMC,EAAO,CAAE,GAAGH,EAAgB,GAAGI,CAAO,EAC5C,OACI,EAAAL,EAAA,IAAA,CAACV,EAAAA,SAAD,CACI,GAAIa,EACJ,OAAQG,GAAWf,EAAAA,oBACnB,OACIgB,GAAWf,EAAAA,sBAEP,SACK,cACb,aACIgB,IAAU,IAAA,IACVA,EAAM,OAAS,IACX,EAAAR,EAAA,IAAA,CAAC,KAAD,CAAI,UAAWP,EAAAA,QAAO,MAAO,aAAYW,EAAK,MACzC,SAAAI,EAAM,KAAK,EAAM,KACd,EAAAR,EAAA,IAAA,CAAC,KAAD,CAAA,SAAiBS,CAAS,EAAjBC,CAAiB,CAC7B,CACD,CAAA,EAGZ,aACI,EAAAV,EAAA,IAAA,CAACN,EAAAA,WAAD,CAAY,OAAQU,EAAK,aAAc,MAAOA,EAAK,OAAQ,GAAIO,GAAO,MAAS,CAAA,CAEtF,CAAA,CAET,C"}
@@ -0,0 +1,39 @@
1
+ import { RESET_PASSWORD_FIELDS as e } from "./auth-defaults.js";
2
+ import t from "./AuthForm.module.js";
3
+ import { AuthForm as n } from "./AuthForm.js";
4
+ import { AuthPrompt as r } from "./AuthLinks.js";
5
+ import { resetPasswordSchema as i } from "./auth-schemas.js";
6
+ import { jsx as a } from "react/jsx-runtime";
7
+ //#region src/components/AuthForm/ResetPasswordForm.tsx
8
+ var o = {
9
+ signInPrompt: "Lembrou a senha?",
10
+ signIn: "Entrar",
11
+ hints: "Requisitos da senha"
12
+ };
13
+ function s({ schema: s, fields: c, hints: l, links: u, labels: d, submitLabel: f = "Redefinir senha", ...p }) {
14
+ let m = {
15
+ ...o,
16
+ ...d
17
+ };
18
+ return /* @__PURE__ */ a(n, {
19
+ ...p,
20
+ schema: s ?? i,
21
+ fields: c ?? e,
22
+ labels: d,
23
+ submitLabel: f,
24
+ beforeSubmit: l !== void 0 && l.length > 0 && /* @__PURE__ */ a("ul", {
25
+ className: t.hints,
26
+ "aria-label": m.hints,
27
+ children: l.map((e, t) => /* @__PURE__ */ a("li", { children: e }, t))
28
+ }),
29
+ afterSubmit: /* @__PURE__ */ a(r, {
30
+ prompt: m.signInPrompt,
31
+ label: m.signIn,
32
+ to: u?.signIn
33
+ })
34
+ });
35
+ }
36
+ //#endregion
37
+ export { s as ResetPasswordForm };
38
+
39
+ //# sourceMappingURL=ResetPasswordForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResetPasswordForm.js","names":["styles","AuthForm_module_default","DEFAULT_LABELS","ResetPasswordForm","props","text","labels","AuthForm","schema","resetPasswordSchema","fields","RESET_PASSWORD_FIELDS","hints","hint","index","AuthPrompt","links"],"sources":["../../../src/components/AuthForm/ResetPasswordForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { RESET_PASSWORD_FIELDS } from \"./auth-defaults\";\nimport { AuthPrompt } from \"./AuthLinks\";\nimport { resetPasswordSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\nimport styles from \"./AuthForm.module.css\";\n\n/** Sentences of {@link ResetPasswordForm}, PT-BR by default. */\nexport interface ResetPasswordFormLabels extends AuthFormLabels {\n /** Default `\"Lembrou a senha?\"`. */\n signInPrompt: string;\n /** Default `\"Entrar\"`. */\n signIn: string;\n /** Accessible name of the hints list. Default `\"Requisitos da senha\"`. */\n hints: string;\n}\n\n/** Routes the reset-password form links to. */\nexport interface ResetPasswordFormLinks {\n /** \"Entrar\" link, under the form. */\n signIn?: string;\n}\n\nexport interface ResetPasswordFormProps<\n TSchema extends z.ZodTypeAny = typeof resetPasswordSchema,\n> extends AuthPresetProps<TSchema> {\n /**\n * Password requirements listed above the submit button (\"Pelo menos 8\n * caracteres\", \"Uma letra maiúscula\"). Kept as text the app writes, because\n * only the backend knows its rules.\n */\n hints?: ReactNode[];\n /** Where the links go. */\n links?: ResetPasswordFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<ResetPasswordFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<ResetPasswordFormLabels, keyof AuthFormLabels> = {\n signInPrompt: \"Lembrou a senha?\",\n signIn: \"Entrar\",\n hints: \"Requisitos da senha\",\n};\n\n/**\n * \"Choose a new password\" form: password and confirmation, with the mismatch\n * reported under the confirmation field.\n *\n * The reset token stays out of the fields: it comes from the URL, and the app\n * adds it in `onSubmit` — `{ ...values, token }` — where it also decides what an\n * expired token looks like.\n *\n * @example\n * const [params] = useSearchParams();\n * <ResetPasswordForm\n * hints={[\"Pelo menos 8 caracteres\"]}\n * onSubmit={async (values) => {\n * await api.post(\"/auth/reset-password\", { body: { ...values, token: params.get(\"token\") } });\n * }}\n * />\n */\nexport function ResetPasswordForm<TSchema extends z.ZodTypeAny = typeof resetPasswordSchema>({\n schema,\n fields,\n hints,\n links,\n labels,\n submitLabel = \"Redefinir senha\",\n ...props\n}: ResetPasswordFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (resetPasswordSchema as unknown as TSchema)}\n fields={\n fields ?? (RESET_PASSWORD_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])\n }\n labels={labels}\n submitLabel={submitLabel}\n beforeSubmit={\n hints !== undefined &&\n hints.length > 0 && (\n <ul className={styles.hints} aria-label={text.hints}>\n {hints.map((hint, index) => (\n <li key={index}>{hint}</li>\n ))}\n </ul>\n )\n }\n afterSubmit={\n <AuthPrompt prompt={text.signInPrompt} label={text.signIn} to={links?.signIn} />\n }\n />\n );\n}\n"],"mappings":";;;;;;;AAwCA,IAAME,IAAsE;CACxE,cAAc;CACd,QAAQ;CACR,OAAO;AACX;AAmBA,SAAgBC,EAA6E,EACzF,WACA,WACA,UACA,UACA,WACA,iBAAc,mBACd,GAAGC,KACwC;CAC3C,IAAMC,IAAO;EAAE,GAAGH;EAAgB,GAAGI;CAAO;CAC5C,OACI,kBAACC,GAAD;EACI,GAAIH;EACJ,QAAQI,KAAWC;EACnB,QACIC,KAAWC;EAEP;EACK;EACb,cACIC,MAAU,KAAA,KACVA,EAAM,SAAS,KACX,kBAAC,MAAD;GAAI,WAAWZ,EAAO;GAAO,cAAYK,EAAK;GACzC,UAAAO,EAAM,KAAK,GAAM,MACd,kBAAC,MAAD,EAAA,UAAiBC,EAAS,GAAjBC,CAAiB,CAC7B;EACD,CAAA;EAGZ,aACI,kBAACC,GAAD;GAAY,QAAQV,EAAK;GAAc,OAAOA,EAAK;GAAQ,IAAIW,GAAO;EAAS,CAAA;CAEtF,CAAA;AAET"}
@@ -0,0 +1,2 @@
1
+ const e=require("./auth-defaults.cjs"),t=require("./AuthForm.cjs"),n=require("./AuthLinks.cjs"),r=require("./auth-schemas.cjs");let i=require("react/jsx-runtime");var a={signInPrompt:`Já tem uma conta?`,signIn:`Entrar`};function o({schema:o,fields:s,links:c,labels:l,submitLabel:u=`Criar conta`,...d}){let f={...a,...l};return(0,i.jsx)(t.AuthForm,{...d,schema:o??r.signUpSchema,fields:s??e.SIGN_UP_FIELDS,labels:l,submitLabel:u,afterSubmit:(0,i.jsx)(n.AuthPrompt,{prompt:f.signInPrompt,label:f.signIn,to:c?.signIn})})}exports.SignUpForm=o;
2
+ //# sourceMappingURL=SignUpForm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignUpForm.cjs","names":["AuthForm","signUpSchema","SIGN_UP_FIELDS","AuthPrompt","require_auth_defaults","require_AuthForm","require_AuthLinks","require_auth_schemas","react_jsx_runtime","DEFAULT_LABELS","SignUpForm","props","text","labels","schema","fields","links"],"sources":["../../../src/components/AuthForm/SignUpForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { SIGN_UP_FIELDS } from \"./auth-defaults\";\nimport { AuthPrompt } from \"./AuthLinks\";\nimport { signUpSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\n\n/** Sentences of {@link SignUpForm}, PT-BR by default. */\nexport interface SignUpFormLabels extends AuthFormLabels {\n /** Default `\"Já tem uma conta?\"`. */\n signInPrompt: string;\n /** Default `\"Entrar\"`. */\n signIn: string;\n}\n\n/** Routes the sign-up form links to. */\nexport interface SignUpFormLinks {\n /** \"Entrar\" link, under the form. */\n signIn?: string;\n}\n\nexport interface SignUpFormProps<\n TSchema extends z.ZodTypeAny = typeof signUpSchema,\n> extends AuthPresetProps<TSchema> {\n /** Where the links go. */\n links?: SignUpFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<SignUpFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<SignUpFormLabels, keyof AuthFormLabels> = {\n signInPrompt: \"Já tem uma conta?\",\n signIn: \"Entrar\",\n};\n\n/**\n * Sign-up form: name, e-mail and password by default, plus the \"Já tem uma conta?\"\n * line.\n *\n * Apps differ most here — a phone, a CPF, a terms checkbox — so the usual call\n * passes `fields` and a `schema` built with `signUpSchema.extend({...})`. The\n * password defaults to `new-password` autocomplete, which is what makes a\n * password manager offer to generate one.\n *\n * @example\n * <SignUpForm\n * schema={signUpSchema.extend({ terms: z.literal(true, \"Aceite os termos\") })}\n * fields={[...SIGN_UP_FIELDS, { name: \"terms\", type: \"checkbox\", label: \"Aceito os termos\" }]}\n * onSubmit={async (values) => { await api.post(\"/auth/register\", { body: values }); }}\n * links={{ signIn: \"/login\" }}\n * />\n */\nexport function SignUpForm<TSchema extends z.ZodTypeAny = typeof signUpSchema>({\n schema,\n fields,\n links,\n labels,\n submitLabel = \"Criar conta\",\n ...props\n}: SignUpFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (signUpSchema as unknown as TSchema)}\n fields={fields ?? (SIGN_UP_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])}\n labels={labels}\n submitLabel={submitLabel}\n afterSubmit={\n <AuthPrompt prompt={text.signInPrompt} label={text.signIn} to={links?.signIn} />\n }\n />\n );\n}\n"],"mappings":"A,mKA+BA,IAAMS,EAA+D,CACjE,aAAc,oBACd,OAAQ,QACZ,EAmBA,SAAgBC,EAA+D,CAC3E,SACA,SACA,QACA,SACA,cAAc,cACd,GAAGC,GACiC,CACpC,IAAMC,EAAO,CAAE,GAAGH,EAAgB,GAAGI,CAAO,EAC5C,OACI,EAAAL,EAAA,IAAA,CAACR,EAAAA,SAAD,CACI,GAAIW,EACJ,OAAQG,GAAWb,EAAAA,aACnB,OAAQc,GAAWb,EAAAA,eACX,SACK,cACb,aACI,EAAAM,EAAA,IAAA,CAACL,EAAAA,WAAD,CAAY,OAAQS,EAAK,aAAc,MAAOA,EAAK,OAAQ,GAAII,GAAO,MAAS,CAAA,CAEtF,CAAA,CAET,C"}
@@ -0,0 +1,32 @@
1
+ import { SIGN_UP_FIELDS as e } from "./auth-defaults.js";
2
+ import { AuthForm as t } from "./AuthForm.js";
3
+ import { AuthPrompt as n } from "./AuthLinks.js";
4
+ import { signUpSchema as r } from "./auth-schemas.js";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ //#region src/components/AuthForm/SignUpForm.tsx
7
+ var a = {
8
+ signInPrompt: "Já tem uma conta?",
9
+ signIn: "Entrar"
10
+ };
11
+ function o({ schema: o, fields: s, links: c, labels: l, submitLabel: u = "Criar conta", ...d }) {
12
+ let f = {
13
+ ...a,
14
+ ...l
15
+ };
16
+ return /* @__PURE__ */ i(t, {
17
+ ...d,
18
+ schema: o ?? r,
19
+ fields: s ?? e,
20
+ labels: l,
21
+ submitLabel: u,
22
+ afterSubmit: /* @__PURE__ */ i(n, {
23
+ prompt: f.signInPrompt,
24
+ label: f.signIn,
25
+ to: c?.signIn
26
+ })
27
+ });
28
+ }
29
+ //#endregion
30
+ export { o as SignUpForm };
31
+
32
+ //# sourceMappingURL=SignUpForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignUpForm.js","names":["DEFAULT_LABELS","SignUpForm","props","text","labels","AuthForm","schema","signUpSchema","fields","SIGN_UP_FIELDS","AuthPrompt","links"],"sources":["../../../src/components/AuthForm/SignUpForm.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport { AuthForm } from \"./AuthForm\";\nimport { SIGN_UP_FIELDS } from \"./auth-defaults\";\nimport { AuthPrompt } from \"./AuthLinks\";\nimport { signUpSchema } from \"./auth-schemas\";\nimport type { AuthField, AuthFieldName, AuthFormLabels, AuthPresetProps } from \"./types\";\n\n/** Sentences of {@link SignUpForm}, PT-BR by default. */\nexport interface SignUpFormLabels extends AuthFormLabels {\n /** Default `\"Já tem uma conta?\"`. */\n signInPrompt: string;\n /** Default `\"Entrar\"`. */\n signIn: string;\n}\n\n/** Routes the sign-up form links to. */\nexport interface SignUpFormLinks {\n /** \"Entrar\" link, under the form. */\n signIn?: string;\n}\n\nexport interface SignUpFormProps<\n TSchema extends z.ZodTypeAny = typeof signUpSchema,\n> extends AuthPresetProps<TSchema> {\n /** Where the links go. */\n links?: SignUpFormLinks;\n /** Overrides for the fixed sentences. */\n labels?: Partial<SignUpFormLabels>;\n}\n\nconst DEFAULT_LABELS: Omit<SignUpFormLabels, keyof AuthFormLabels> = {\n signInPrompt: \"Já tem uma conta?\",\n signIn: \"Entrar\",\n};\n\n/**\n * Sign-up form: name, e-mail and password by default, plus the \"Já tem uma conta?\"\n * line.\n *\n * Apps differ most here — a phone, a CPF, a terms checkbox — so the usual call\n * passes `fields` and a `schema` built with `signUpSchema.extend({...})`. The\n * password defaults to `new-password` autocomplete, which is what makes a\n * password manager offer to generate one.\n *\n * @example\n * <SignUpForm\n * schema={signUpSchema.extend({ terms: z.literal(true, \"Aceite os termos\") })}\n * fields={[...SIGN_UP_FIELDS, { name: \"terms\", type: \"checkbox\", label: \"Aceito os termos\" }]}\n * onSubmit={async (values) => { await api.post(\"/auth/register\", { body: values }); }}\n * links={{ signIn: \"/login\" }}\n * />\n */\nexport function SignUpForm<TSchema extends z.ZodTypeAny = typeof signUpSchema>({\n schema,\n fields,\n links,\n labels,\n submitLabel = \"Criar conta\",\n ...props\n}: SignUpFormProps<TSchema>): ReactNode {\n const text = { ...DEFAULT_LABELS, ...labels };\n return (\n <AuthForm<TSchema>\n {...props}\n schema={schema ?? (signUpSchema as unknown as TSchema)}\n fields={fields ?? (SIGN_UP_FIELDS as readonly AuthField<AuthFieldName<TSchema>>[])}\n labels={labels}\n submitLabel={submitLabel}\n afterSubmit={\n <AuthPrompt prompt={text.signInPrompt} label={text.signIn} to={links?.signIn} />\n }\n />\n );\n}\n"],"mappings":";;;;;;AA+BA,IAAMA,IAA+D;CACjE,cAAc;CACd,QAAQ;AACZ;AAmBA,SAAgBC,EAA+D,EAC3E,WACA,WACA,UACA,WACA,iBAAc,eACd,GAAGC,KACiC;CACpC,IAAMC,IAAO;EAAE,GAAGH;EAAgB,GAAGI;CAAO;CAC5C,OACI,kBAACC,GAAD;EACI,GAAIH;EACJ,QAAQI,KAAWC;EACnB,QAAQC,KAAWC;EACX;EACK;EACb,aACI,kBAACC,GAAD;GAAY,QAAQP,EAAK;GAAc,OAAOA,EAAK;GAAQ,IAAIQ,GAAO;EAAS,CAAA;CAEtF,CAAA;AAET"}
@@ -0,0 +1,2 @@
1
+ var e={divider:`ou`,error:`Não foi possível concluir agora. Tente de novo.`},t=[{name:`email`,type:`email`,label:`E-mail`,placeholder:`voce@exemplo.com`},{name:`password`,type:`password`,label:`Senha`}],n=[{name:`name`,label:`Nome`,autoComplete:`name`},{name:`email`,type:`email`,label:`E-mail`,placeholder:`voce@exemplo.com`},{name:`password`,type:`password`,label:`Senha`,autoComplete:`new-password`,showStrength:!0}],r=[{name:`email`,type:`email`,label:`E-mail`,placeholder:`voce@exemplo.com`,helperText:`Enviaremos um link para você criar uma nova senha.`}],i=[{name:`password`,type:`password`,label:`Nova senha`,autoComplete:`new-password`,showStrength:!0},{name:`confirmPassword`,type:`password`,label:`Confirme a nova senha`,autoComplete:`new-password`}];exports.DEFAULT_AUTH_FORM_LABELS=e,exports.FORGOT_PASSWORD_FIELDS=r,exports.LOGIN_FIELDS=t,exports.RESET_PASSWORD_FIELDS=i,exports.SIGN_UP_FIELDS=n;
2
+ //# sourceMappingURL=auth-defaults.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-defaults.cjs","names":["DEFAULT_AUTH_FORM_LABELS","LOGIN_FIELDS","SIGN_UP_FIELDS","FORGOT_PASSWORD_FIELDS","RESET_PASSWORD_FIELDS"],"sources":["../../../src/components/AuthForm/auth-defaults.ts"],"sourcesContent":["import type { AuthField, AuthFormLabels } from \"./types\";\n\n/** PT-BR defaults of {@link AuthFormLabels}. */\nexport const DEFAULT_AUTH_FORM_LABELS: AuthFormLabels = {\n divider: \"ou\",\n error: \"Não foi possível concluir agora. Tente de novo.\",\n};\n\n/**\n * Default fields of `LoginForm`: e-mail and password.\n *\n * Exported, like the other presets' lists, so an app extends the defaults\n * (`[...LOGIN_FIELDS, { name: \"remember\", type: \"checkbox\", … }]`) instead of\n * retyping them.\n */\nexport const LOGIN_FIELDS: readonly AuthField<\"email\" | \"password\">[] = [\n { name: \"email\", type: \"email\", label: \"E-mail\", placeholder: \"voce@exemplo.com\" },\n { name: \"password\", type: \"password\", label: \"Senha\" },\n];\n\n/** Default fields of `SignUpForm`: name, e-mail and a password with strength meter. */\nexport const SIGN_UP_FIELDS: readonly AuthField<\"name\" | \"email\" | \"password\">[] = [\n { name: \"name\", label: \"Nome\", autoComplete: \"name\" },\n { name: \"email\", type: \"email\", label: \"E-mail\", placeholder: \"voce@exemplo.com\" },\n {\n name: \"password\",\n type: \"password\",\n label: \"Senha\",\n autoComplete: \"new-password\",\n showStrength: true,\n },\n];\n\n/** Default fields of `ForgotPasswordForm`: the e-mail, with a line saying what happens next. */\nexport const FORGOT_PASSWORD_FIELDS: readonly AuthField<\"email\">[] = [\n {\n name: \"email\",\n type: \"email\",\n label: \"E-mail\",\n placeholder: \"voce@exemplo.com\",\n helperText: \"Enviaremos um link para você criar uma nova senha.\",\n },\n];\n\n/** Default fields of `ResetPasswordForm`: new password (with strength meter) and confirmation. */\nexport const RESET_PASSWORD_FIELDS: readonly AuthField<\"password\" | \"confirmPassword\">[] = [\n {\n name: \"password\",\n type: \"password\",\n label: \"Nova senha\",\n autoComplete: \"new-password\",\n showStrength: true,\n },\n {\n name: \"confirmPassword\",\n type: \"password\",\n label: \"Confirme a nova senha\",\n autoComplete: \"new-password\",\n },\n];\n"],"mappings":"AAGA,IAAaA,EAA2C,CACpD,QAAS,KACT,MAAO,iDACX,EASaC,EAA2D,CACpE,CAAE,KAAM,QAAS,KAAM,QAAS,MAAO,SAAU,YAAa,kBAAmB,EACjF,CAAE,KAAM,WAAY,KAAM,WAAY,MAAO,OAAQ,CACzD,EAGaC,EAAsE,CAC/E,CAAE,KAAM,OAAQ,MAAO,OAAQ,aAAc,MAAO,EACpD,CAAE,KAAM,QAAS,KAAM,QAAS,MAAO,SAAU,YAAa,kBAAmB,EACjF,CACI,KAAM,WACN,KAAM,WACN,MAAO,QACP,aAAc,eACd,aAAc,EAClB,CACJ,EAGaC,EAAwD,CACjE,CACI,KAAM,QACN,KAAM,QACN,MAAO,SACP,YAAa,mBACb,WAAY,oDAChB,CACJ,EAGaC,EAA8E,CACvF,CACI,KAAM,WACN,KAAM,WACN,MAAO,aACP,aAAc,eACd,aAAc,EAClB,EACA,CACI,KAAM,kBACN,KAAM,WACN,MAAO,wBACP,aAAc,cAClB,CACJ,E"}
@@ -0,0 +1,54 @@
1
+ //#region src/components/AuthForm/auth-defaults.ts
2
+ var e = {
3
+ divider: "ou",
4
+ error: "Não foi possível concluir agora. Tente de novo."
5
+ }, t = [{
6
+ name: "email",
7
+ type: "email",
8
+ label: "E-mail",
9
+ placeholder: "voce@exemplo.com"
10
+ }, {
11
+ name: "password",
12
+ type: "password",
13
+ label: "Senha"
14
+ }], n = [
15
+ {
16
+ name: "name",
17
+ label: "Nome",
18
+ autoComplete: "name"
19
+ },
20
+ {
21
+ name: "email",
22
+ type: "email",
23
+ label: "E-mail",
24
+ placeholder: "voce@exemplo.com"
25
+ },
26
+ {
27
+ name: "password",
28
+ type: "password",
29
+ label: "Senha",
30
+ autoComplete: "new-password",
31
+ showStrength: !0
32
+ }
33
+ ], r = [{
34
+ name: "email",
35
+ type: "email",
36
+ label: "E-mail",
37
+ placeholder: "voce@exemplo.com",
38
+ helperText: "Enviaremos um link para você criar uma nova senha."
39
+ }], i = [{
40
+ name: "password",
41
+ type: "password",
42
+ label: "Nova senha",
43
+ autoComplete: "new-password",
44
+ showStrength: !0
45
+ }, {
46
+ name: "confirmPassword",
47
+ type: "password",
48
+ label: "Confirme a nova senha",
49
+ autoComplete: "new-password"
50
+ }];
51
+ //#endregion
52
+ export { e as DEFAULT_AUTH_FORM_LABELS, r as FORGOT_PASSWORD_FIELDS, t as LOGIN_FIELDS, i as RESET_PASSWORD_FIELDS, n as SIGN_UP_FIELDS };
53
+
54
+ //# sourceMappingURL=auth-defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-defaults.js","names":["DEFAULT_AUTH_FORM_LABELS","LOGIN_FIELDS","SIGN_UP_FIELDS","FORGOT_PASSWORD_FIELDS","RESET_PASSWORD_FIELDS"],"sources":["../../../src/components/AuthForm/auth-defaults.ts"],"sourcesContent":["import type { AuthField, AuthFormLabels } from \"./types\";\n\n/** PT-BR defaults of {@link AuthFormLabels}. */\nexport const DEFAULT_AUTH_FORM_LABELS: AuthFormLabels = {\n divider: \"ou\",\n error: \"Não foi possível concluir agora. Tente de novo.\",\n};\n\n/**\n * Default fields of `LoginForm`: e-mail and password.\n *\n * Exported, like the other presets' lists, so an app extends the defaults\n * (`[...LOGIN_FIELDS, { name: \"remember\", type: \"checkbox\", … }]`) instead of\n * retyping them.\n */\nexport const LOGIN_FIELDS: readonly AuthField<\"email\" | \"password\">[] = [\n { name: \"email\", type: \"email\", label: \"E-mail\", placeholder: \"voce@exemplo.com\" },\n { name: \"password\", type: \"password\", label: \"Senha\" },\n];\n\n/** Default fields of `SignUpForm`: name, e-mail and a password with strength meter. */\nexport const SIGN_UP_FIELDS: readonly AuthField<\"name\" | \"email\" | \"password\">[] = [\n { name: \"name\", label: \"Nome\", autoComplete: \"name\" },\n { name: \"email\", type: \"email\", label: \"E-mail\", placeholder: \"voce@exemplo.com\" },\n {\n name: \"password\",\n type: \"password\",\n label: \"Senha\",\n autoComplete: \"new-password\",\n showStrength: true,\n },\n];\n\n/** Default fields of `ForgotPasswordForm`: the e-mail, with a line saying what happens next. */\nexport const FORGOT_PASSWORD_FIELDS: readonly AuthField<\"email\">[] = [\n {\n name: \"email\",\n type: \"email\",\n label: \"E-mail\",\n placeholder: \"voce@exemplo.com\",\n helperText: \"Enviaremos um link para você criar uma nova senha.\",\n },\n];\n\n/** Default fields of `ResetPasswordForm`: new password (with strength meter) and confirmation. */\nexport const RESET_PASSWORD_FIELDS: readonly AuthField<\"password\" | \"confirmPassword\">[] = [\n {\n name: \"password\",\n type: \"password\",\n label: \"Nova senha\",\n autoComplete: \"new-password\",\n showStrength: true,\n },\n {\n name: \"confirmPassword\",\n type: \"password\",\n label: \"Confirme a nova senha\",\n autoComplete: \"new-password\",\n },\n];\n"],"mappings":";AAGA,IAAaA,IAA2C;CACpD,SAAS;CACT,OAAO;AACX,GASaC,IAA2D,CACpE;CAAE,MAAM;CAAS,MAAM;CAAS,OAAO;CAAU,aAAa;AAAmB,GACjF;CAAE,MAAM;CAAY,MAAM;CAAY,OAAO;AAAQ,CACzD,GAGaC,IAAsE;CAC/E;EAAE,MAAM;EAAQ,OAAO;EAAQ,cAAc;CAAO;CACpD;EAAE,MAAM;EAAS,MAAM;EAAS,OAAO;EAAU,aAAa;CAAmB;CACjF;EACI,MAAM;EACN,MAAM;EACN,OAAO;EACP,cAAc;EACd,cAAc;CAClB;AACJ,GAGaC,IAAwD,CACjE;CACI,MAAM;CACN,MAAM;CACN,OAAO;CACP,aAAa;CACb,YAAY;AAChB,CACJ,GAGaC,IAA8E,CACvF;CACI,MAAM;CACN,MAAM;CACN,OAAO;CACP,cAAc;CACd,cAAc;AAClB,GACA;CACI,MAAM;CACN,MAAM;CACN,OAAO;CACP,cAAc;AAClB,CACJ"}
@@ -0,0 +1,2 @@
1
+ let e=require("zod");function t(){return e.z.string().trim().toLowerCase().min(1,`Informe seu e-mail`).pipe(e.z.email(`Informe um e-mail válido`))}function n(t=`A senha deve ter no mínimo 8 caracteres`){return e.z.string().min(8,t)}var r=e.z.object({email:t(),password:n()}),i=e.z.object({name:e.z.string().trim().min(3,`Informe seu nome completo`),email:t(),password:n()}),a=e.z.object({email:t()}),o=e.z.object({password:n(),confirmPassword:e.z.string().min(1,`Confirme a nova senha`)}).refine(e=>e.password===e.confirmPassword,{message:`As senhas não coincidem`,path:[`confirmPassword`]});exports.authEmail=t,exports.authPassword=n,exports.forgotPasswordSchema=a,exports.loginSchema=r,exports.resetPasswordSchema=o,exports.signUpSchema=i;
2
+ //# sourceMappingURL=auth-schemas.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-schemas.cjs","names":["z","zod","authEmail","authPassword","message","loginSchema","signUpSchema","forgotPasswordSchema","resetPasswordSchema","values"],"sources":["../../../src/components/AuthForm/auth-schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * An e-mail field: trimmed and lower-cased *before* it is validated.\n *\n * The order is the point. Validating first rejects `\" ana@x.com\"` pasted with a\n * trailing space from a password manager, and a backend that compares e-mails\n * case-sensitively creates a second account for `Ana@x.com`. An empty value gets\n * its own sentence instead of \"e-mail inválido\", which reads like an accusation\n * on a field the user simply has not reached yet.\n *\n * @returns A schema producing the normalized address.\n */\nexport function authEmail(): z.ZodPipe<z.ZodString, z.ZodEmail> {\n return z\n .string()\n .trim()\n .toLowerCase()\n .min(1, \"Informe seu e-mail\")\n .pipe(z.email(\"Informe um e-mail válido\"));\n}\n\n/**\n * A password field with the minimum length every Tempest backend enforces.\n *\n * @param message - Sentence shown below 8 characters.\n * @returns The password schema.\n */\nexport function authPassword(\n message: string = \"A senha deve ter no mínimo 8 caracteres\",\n): z.ZodString {\n return z.string().min(8, message);\n}\n\n/** Default schema of `LoginForm`: normalized e-mail + password of at least 8 characters. */\nexport const loginSchema = z.object({\n email: authEmail(),\n password: authPassword(),\n});\n\n/**\n * Default schema of `SignUpForm`: name, e-mail and password.\n *\n * Exported so an app adds its own fields with `.extend()` instead of rewriting\n * the three it shares with every other app — see the phone and terms example in\n * the docs.\n */\nexport const signUpSchema = z.object({\n name: z.string().trim().min(3, \"Informe seu nome completo\"),\n email: authEmail(),\n password: authPassword(),\n});\n\n/** Default schema of `ForgotPasswordForm`: the e-mail the reset link goes to. */\nexport const forgotPasswordSchema = z.object({\n email: authEmail(),\n});\n\n/**\n * Default schema of `ResetPasswordForm`: new password and its confirmation.\n *\n * The mismatch is reported on `confirmPassword` (`path`), so the message lands\n * under the field the user has to fix rather than in a form-level alert.\n */\nexport const resetPasswordSchema = z\n .object({\n password: authPassword(),\n confirmPassword: z.string().min(1, \"Confirme a nova senha\"),\n })\n .refine((values) => values.password === values.confirmPassword, {\n message: \"As senhas não coincidem\",\n path: [\"confirmPassword\"],\n });\n"],"mappings":"A,qBAaA,SAAgBE,GAAgD,CAC5D,OAAOF,EAAAA,EACF,OAAO,CAAC,CACR,KAAK,CAAC,CACN,YAAY,CAAC,CACb,IAAI,EAAG,oBAAoB,CAAC,CAC5B,KAAKA,EAAAA,EAAE,MAAM,0BAA0B,CAAC,CACjD,CAQA,SAAgBG,EACZ,EAAkB,0CACP,CACX,OAAOH,EAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,EAAGI,CAAO,CACpC,CAGA,IAAaC,EAAcL,EAAAA,EAAE,OAAO,CAChC,MAAOE,EAAU,EACjB,SAAUC,EAAa,CAC3B,CAAC,EASYG,EAAeN,EAAAA,EAAE,OAAO,CACjC,KAAMA,EAAAA,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAG,2BAA2B,EAC1D,MAAOE,EAAU,EACjB,SAAUC,EAAa,CAC3B,CAAC,EAGYI,EAAuBP,EAAAA,EAAE,OAAO,CACzC,MAAOE,EAAU,CACrB,CAAC,EAQYM,EAAsBR,EAAAA,EAC9B,OAAO,CACJ,SAAUG,EAAa,EACvB,gBAAiBH,EAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,EAAG,uBAAuB,CAC9D,CAAC,CAAC,CACD,OAAQ,GAAWS,EAAO,WAAaA,EAAO,gBAAiB,CAC5D,QAAS,0BACT,KAAM,CAAC,iBAAiB,CAC5B,CAAC,E"}
@@ -0,0 +1,26 @@
1
+ import { z as e } from "zod";
2
+ //#region src/components/AuthForm/auth-schemas.ts
3
+ function t() {
4
+ return e.string().trim().toLowerCase().min(1, "Informe seu e-mail").pipe(e.email("Informe um e-mail válido"));
5
+ }
6
+ function n(t = "A senha deve ter no mínimo 8 caracteres") {
7
+ return e.string().min(8, t);
8
+ }
9
+ var r = e.object({
10
+ email: t(),
11
+ password: n()
12
+ }), i = e.object({
13
+ name: e.string().trim().min(3, "Informe seu nome completo"),
14
+ email: t(),
15
+ password: n()
16
+ }), a = e.object({ email: t() }), o = e.object({
17
+ password: n(),
18
+ confirmPassword: e.string().min(1, "Confirme a nova senha")
19
+ }).refine((e) => e.password === e.confirmPassword, {
20
+ message: "As senhas não coincidem",
21
+ path: ["confirmPassword"]
22
+ });
23
+ //#endregion
24
+ export { t as authEmail, n as authPassword, a as forgotPasswordSchema, r as loginSchema, o as resetPasswordSchema, i as signUpSchema };
25
+
26
+ //# sourceMappingURL=auth-schemas.js.map