@alfadocs/ui-kit-debug 1.54.1 → 1.54.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{address-fields-1pD-8hML.js → address-fields-BaClzQLM.js} +5 -5
- package/dist/_chunks/{address-fields-1pD-8hML.js.map → address-fields-BaClzQLM.js.map} +1 -1
- package/dist/_chunks/{anamnesis-summary-rows-BMjSBqhS.js → anamnesis-summary-rows-Brru7JrH.js} +3 -3
- package/dist/_chunks/{anamnesis-summary-rows-BMjSBqhS.js.map → anamnesis-summary-rows-Brru7JrH.js.map} +1 -1
- package/dist/_chunks/{balance-badge-cell-BDX1Krdv.js → balance-badge-cell-C5hmahoB.js} +2 -2
- package/dist/_chunks/{balance-badge-cell-BDX1Krdv.js.map → balance-badge-cell-C5hmahoB.js.map} +1 -1
- package/dist/_chunks/{bishop-score-CGAVpIWL.js → bishop-score-BzvVol-u.js} +2 -2
- package/dist/_chunks/{bishop-score-CGAVpIWL.js.map → bishop-score-BzvVol-u.js.map} +1 -1
- package/dist/_chunks/{bmi-calculator-g_wjo4nq.js → bmi-calculator-CDmQk0b5.js} +2 -2
- package/dist/_chunks/{bmi-calculator-g_wjo4nq.js.map → bmi-calculator-CDmQk0b5.js.map} +1 -1
- package/dist/_chunks/{booking-BN7TXe27.js → booking-BGY3LUi8.js} +5 -5
- package/dist/_chunks/{booking-BN7TXe27.js.map → booking-BGY3LUi8.js.map} +1 -1
- package/dist/_chunks/{calendar-workspace-BbZIx2PT.js → calendar-workspace-BJPhMb2c.js} +8 -8
- package/dist/_chunks/{calendar-workspace-BbZIx2PT.js.map → calendar-workspace-BJPhMb2c.js.map} +1 -1
- package/dist/_chunks/{city-input-DyxVWSRQ.js → city-input-BL5WsGJ3.js} +2 -2
- package/dist/_chunks/{city-input-DyxVWSRQ.js.map → city-input-BL5WsGJ3.js.map} +1 -1
- package/dist/_chunks/{cycle-calculator-CwDEdmda.js → cycle-calculator-LjsQd9Gl.js} +2 -2
- package/dist/_chunks/{cycle-calculator-CwDEdmda.js.map → cycle-calculator-LjsQd9Gl.js.map} +1 -1
- package/dist/_chunks/{data-table-DeUoJzNn.js → data-table-BErtJzaT.js} +2 -2
- package/dist/_chunks/{data-table-DeUoJzNn.js.map → data-table-BErtJzaT.js.map} +1 -1
- package/dist/_chunks/{data-table-tabs-BfEmXvUk.js → data-table-tabs-D5nFZKxg.js} +2 -2
- package/dist/_chunks/{data-table-tabs-BfEmXvUk.js.map → data-table-tabs-D5nFZKxg.js.map} +1 -1
- package/dist/_chunks/{due-date-calculator-_0Dz_d7n.js → due-date-calculator-mDvGKmRV.js} +2 -2
- package/dist/_chunks/{due-date-calculator-_0Dz_d7n.js.map → due-date-calculator-mDvGKmRV.js.map} +1 -1
- package/dist/_chunks/{email-input-Cmeo4zdT.js → email-input-DQixfopu.js} +2 -2
- package/dist/_chunks/{email-input-Cmeo4zdT.js.map → email-input-DQixfopu.js.map} +1 -1
- package/dist/_chunks/error-page-C15GfNEj.js +312 -0
- package/dist/_chunks/error-page-C15GfNEj.js.map +1 -0
- package/dist/_chunks/{error-page-illustration-QGJAvuFB.js → error-page-illustration-bFti0VEc.js} +73 -56
- package/dist/_chunks/error-page-illustration-bFti0VEc.js.map +1 -0
- package/dist/_chunks/{face-scheme-pZgT26gB.js → face-scheme-Doodi6A6.js} +2 -2
- package/dist/_chunks/{face-scheme-pZgT26gB.js.map → face-scheme-Doodi6A6.js.map} +1 -1
- package/dist/_chunks/{fetal-weight-CbE61Uyk.js → fetal-weight-DBgEaMoJ.js} +2 -2
- package/dist/_chunks/{fetal-weight-CbE61Uyk.js.map → fetal-weight-DBgEaMoJ.js.map} +1 -1
- package/dist/_chunks/{file-manager-DdsAd4TQ.js → file-manager-BDNSnr7f.js} +3 -3
- package/dist/_chunks/{file-manager-DdsAd4TQ.js.map → file-manager-BDNSnr7f.js.map} +1 -1
- package/dist/_chunks/{forgot-password-form-DVVOBEGj.js → forgot-password-form-Duu3pZDU.js} +3 -3
- package/dist/_chunks/{forgot-password-form-DVVOBEGj.js.map → forgot-password-form-Duu3pZDU.js.map} +1 -1
- package/dist/_chunks/{form-field-D9WfDpYB.js → form-field-Db0liyI8.js} +72 -63
- package/dist/_chunks/form-field-Db0liyI8.js.map +1 -0
- package/dist/_chunks/form-field-context-DtiROUJV.js.map +1 -1
- package/dist/_chunks/{gestational-age-calculator-BMkoLJGR.js → gestational-age-calculator-BVBz_5dm.js} +2 -2
- package/dist/_chunks/{gestational-age-calculator-BMkoLJGR.js.map → gestational-age-calculator-BVBz_5dm.js.map} +1 -1
- package/dist/_chunks/{hcg-doubling-BtW2pBJX.js → hcg-doubling-BECrAUu3.js} +2 -2
- package/dist/_chunks/{hcg-doubling-BtW2pBJX.js.map → hcg-doubling-BECrAUu3.js.map} +1 -1
- package/dist/_chunks/{help-me-write-templates-Cy-iO5AU.js → help-me-write-templates-B4Y8dBv1.js} +3 -3
- package/dist/_chunks/{help-me-write-templates-Cy-iO5AU.js.map → help-me-write-templates-B4Y8dBv1.js.map} +1 -1
- package/dist/_chunks/{icon-picker-CSViTQL9.js → icon-picker-JZzs1ol_.js} +2 -2
- package/dist/_chunks/{icon-picker-CSViTQL9.js.map → icon-picker-JZzs1ol_.js.map} +1 -1
- package/dist/_chunks/{kit-extensions-Kca1tkfP.js → kit-extensions-GQHKTLWI.js} +6 -6
- package/dist/_chunks/{kit-extensions-Kca1tkfP.js.map → kit-extensions-GQHKTLWI.js.map} +1 -1
- package/dist/_chunks/{login-dev-card-C7wo-Hv1.js → login-dev-card-DletSsX3.js} +5 -5
- package/dist/_chunks/{login-dev-card-C7wo-Hv1.js.map → login-dev-card-DletSsX3.js.map} +1 -1
- package/dist/_chunks/{notes-panel-BPb-2ZnJ.js → notes-panel-DWJY3WV8.js} +2 -2
- package/dist/_chunks/{notes-panel-BPb-2ZnJ.js.map → notes-panel-DWJY3WV8.js.map} +1 -1
- package/dist/_chunks/{password-input-B7pQTk7l.js → password-input-6Yl6x1IO.js} +2 -2
- package/dist/_chunks/{password-input-B7pQTk7l.js.map → password-input-6Yl6x1IO.js.map} +1 -1
- package/dist/_chunks/{patient-details-BP9r_lNS.js → patient-details-D7QlsGK1.js} +2 -2
- package/dist/_chunks/{patient-details-BP9r_lNS.js.map → patient-details-D7QlsGK1.js.map} +1 -1
- package/dist/_chunks/{patient-field-row-BK9JjbzA.js → patient-field-row-Dr-ndtG8.js} +5 -5
- package/dist/_chunks/{patient-field-row-BK9JjbzA.js.map → patient-field-row-Dr-ndtG8.js.map} +1 -1
- package/dist/_chunks/{patient-summary-card-DGbRLzF1.js → patient-summary-card-A3WhxFwp.js} +2 -2
- package/dist/_chunks/{patient-summary-card-DGbRLzF1.js.map → patient-summary-card-A3WhxFwp.js.map} +1 -1
- package/dist/_chunks/{postal-code-input-BmbqjkfD.js → postal-code-input-lCk8me6K.js} +2 -2
- package/dist/_chunks/{postal-code-input-BmbqjkfD.js.map → postal-code-input-lCk8me6K.js.map} +1 -1
- package/dist/_chunks/{pregnancy-dating-DV3o2PPl.js → pregnancy-dating-BEmsMys4.js} +2 -2
- package/dist/_chunks/{pregnancy-dating-DV3o2PPl.js.map → pregnancy-dating-BEmsMys4.js.map} +1 -1
- package/dist/_chunks/{pregnancy-weight-gain-BLjWgtS9.js → pregnancy-weight-gain-DMVPvM3a.js} +2 -2
- package/dist/_chunks/{pregnancy-weight-gain-BLjWgtS9.js.map → pregnancy-weight-gain-DMVPvM3a.js.map} +1 -1
- package/dist/_chunks/{radiograph-panel.agent-C4j6eoQn.js → radiograph-panel.agent-rS3Tegx6.js} +2 -2
- package/dist/_chunks/{radiograph-panel.agent-C4j6eoQn.js.map → radiograph-panel.agent-rS3Tegx6.js.map} +1 -1
- package/dist/_chunks/{registration-form-CBDeXzlk.js → registration-form-Lz9iKrKo.js} +246 -235
- package/dist/_chunks/registration-form-Lz9iKrKo.js.map +1 -0
- package/dist/_chunks/{rich-text-editor-CCCSEPlG.js → rich-text-editor-DmnWavgl.js} +2 -2
- package/dist/_chunks/{rich-text-editor-CCCSEPlG.js.map → rich-text-editor-DmnWavgl.js.map} +1 -1
- package/dist/_chunks/{search-bar-D695TCDH.js → search-bar-ORcfuK9A.js} +2 -2
- package/dist/_chunks/{search-bar-D695TCDH.js.map → search-bar-ORcfuK9A.js.map} +1 -1
- package/dist/_chunks/{search-input-Tl-RkS5x.js → search-input-6SoR2Rf4.js} +2 -2
- package/dist/_chunks/{search-input-Tl-RkS5x.js.map → search-input-6SoR2Rf4.js.map} +1 -1
- package/dist/_chunks/{task-editor-Dl27rI3J.js → task-editor-i-juLk76.js} +3 -3
- package/dist/_chunks/{task-editor-Dl27rI3J.js.map → task-editor-i-juLk76.js.map} +1 -1
- package/dist/_chunks/{text-input-lZ2-t-p2.js → text-input-rzLEKhRU.js} +145 -97
- package/dist/_chunks/text-input-rzLEKhRU.js.map +1 -0
- package/dist/_chunks/{transcript-panel-CLgtyVbR.js → transcript-panel-jOCW4Ycl.js} +2 -2
- package/dist/_chunks/{transcript-panel-CLgtyVbR.js.map → transcript-panel-jOCW4Ycl.js.map} +1 -1
- package/dist/_chunks/{unit-converter-CXNr5P4J.js → unit-converter-Bvhj9r3m.js} +2 -2
- package/dist/_chunks/{unit-converter-CXNr5P4J.js.map → unit-converter-Bvhj9r3m.js.map} +1 -1
- package/dist/_chunks/{use-appointment-details-read-BEbLseXW.js → use-appointment-details-read-B6dBBgDa.js} +3 -3
- package/dist/_chunks/{use-appointment-details-read-BEbLseXW.js.map → use-appointment-details-read-B6dBBgDa.js.map} +1 -1
- package/dist/_chunks/use-field-match-pdbEnKvO.js.map +1 -1
- package/dist/_chunks/{widget-picker-BCbwD5Z1.js → widget-picker-Ck8HTsil.js} +2 -2
- package/dist/_chunks/{widget-picker-BCbwD5Z1.js.map → widget-picker-Ck8HTsil.js.map} +1 -1
- package/dist/agent-catalog.json +5 -1
- package/dist/components/address-fields/index.js +1 -1
- package/dist/components/appointment-details-panel/index.js +1 -1
- package/dist/components/bishop-score/index.js +1 -1
- package/dist/components/bmi-calculator/index.js +1 -1
- package/dist/components/booking/index.js +1 -1
- package/dist/components/city-input/index.js +1 -1
- package/dist/components/cycle-calculator/index.js +1 -1
- package/dist/components/data-table/index.js +1 -1
- package/dist/components/data-table-tabs/index.js +1 -1
- package/dist/components/due-date-calculator/index.js +1 -1
- package/dist/components/email-input/index.js +1 -1
- package/dist/components/face-scheme/index.js +1 -1
- package/dist/components/fetal-weight/index.js +1 -1
- package/dist/components/file-manager/index.js +1 -1
- package/dist/components/form-field/form-field-context.d.ts +5 -0
- package/dist/components/form-field/form-field-context.d.ts.map +1 -1
- package/dist/components/form-field/form-field.d.ts.map +1 -1
- package/dist/components/form-field/index.js +1 -1
- package/dist/components/gestational-age-calculator/index.js +1 -1
- package/dist/components/hcg-doubling/index.js +1 -1
- package/dist/components/icon-picker/index.js +1 -1
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/password-input/index.js +1 -1
- package/dist/components/patient-details/index.js +1 -1
- package/dist/components/patient-summary-card/index.js +1 -1
- package/dist/components/patient-table/index.js +1 -1
- package/dist/components/postal-code-input/index.js +1 -1
- package/dist/components/pregnancy-dating/index.js +1 -1
- package/dist/components/pregnancy-weight-gain/index.js +1 -1
- package/dist/components/radiograph-panel/index.js +1 -1
- package/dist/components/rich-text-editor/index.js +2 -2
- package/dist/components/search-bar/index.js +1 -1
- package/dist/components/search-input/index.js +1 -1
- package/dist/components/task-editor/index.js +1 -1
- package/dist/components/text-input/index.js +1 -1
- package/dist/components/text-input/text-input.d.ts +13 -0
- package/dist/components/text-input/text-input.d.ts.map +1 -1
- package/dist/components/transcript-panel/index.js +1 -1
- package/dist/components/unit-converter/index.js +1 -1
- package/dist/components/widget-picker/index.js +1 -1
- package/dist/hooks/use-field-match.d.ts +3 -2
- package/dist/hooks/use-field-match.d.ts.map +1 -1
- package/dist/i18n/locales/ar.d.ts +4 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +4 -0
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +4 -0
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +4 -0
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +4 -0
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +4 -0
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +4 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +4 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +4 -0
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +4 -0
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +4 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +4 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +4 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +4 -0
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +4 -0
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +4 -0
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +4 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +4 -0
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +4 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +4 -0
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +4 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +4 -0
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +4 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +4 -0
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +4 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +4 -0
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +4 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +4 -0
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +4 -0
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +4 -0
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +4 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +4 -0
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +4 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +4 -0
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +4 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +4 -0
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +167 -165
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.json +4 -0
- package/dist/locales/de.json +4 -0
- package/dist/locales/el.json +4 -0
- package/dist/locales/en.json +4 -0
- package/dist/locales/es.json +4 -0
- package/dist/locales/fr.json +4 -0
- package/dist/locales/hi.json +4 -0
- package/dist/locales/it.json +4 -0
- package/dist/locales/ja.json +4 -0
- package/dist/locales/nl.json +4 -0
- package/dist/locales/pl.json +4 -0
- package/dist/locales/pt.json +4 -0
- package/dist/locales/ro.json +4 -0
- package/dist/locales/ru.json +4 -0
- package/dist/locales/sq.json +4 -0
- package/dist/locales/sv.json +4 -0
- package/dist/locales/tr.json +4 -0
- package/dist/locales/zh.json +4 -0
- package/dist/patterns/anamnesis/index.js +1 -1
- package/dist/patterns/calendar/index.js +1 -1
- package/dist/patterns/error-page/error-page-illustration.d.ts +3 -1
- package/dist/patterns/error-page/error-page-illustration.d.ts.map +1 -1
- package/dist/patterns/error-page/error-page.d.ts +34 -2
- package/dist/patterns/error-page/error-page.d.ts.map +1 -1
- package/dist/patterns/error-page/index.d.ts +2 -1
- package/dist/patterns/error-page/index.d.ts.map +1 -1
- package/dist/patterns/error-page/index.js +7 -5
- package/dist/patterns/error-page/index.js.map +1 -1
- package/dist/patterns/forgot-password-form/index.js +1 -1
- package/dist/patterns/help-me-write-templates/index.js +1 -1
- package/dist/patterns/login-form/index.js +1 -1
- package/dist/patterns/registration-form/index.d.ts +1 -1
- package/dist/patterns/registration-form/index.d.ts.map +1 -1
- package/dist/patterns/registration-form/index.js +1 -1
- package/dist/patterns/registration-form/registration-form.d.ts +16 -0
- package/dist/patterns/registration-form/registration-form.d.ts.map +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/error-page-CKFJlekz.js +0 -275
- package/dist/_chunks/error-page-CKFJlekz.js.map +0 -1
- package/dist/_chunks/error-page-illustration-QGJAvuFB.js.map +0 -1
- package/dist/_chunks/form-field-D9WfDpYB.js.map +0 -1
- package/dist/_chunks/registration-form-CBDeXzlk.js.map +0 -1
- package/dist/_chunks/text-input-lZ2-t-p2.js.map +0 -1
|
@@ -2,11 +2,11 @@ import { jsx as s, jsxs as c, Fragment as no } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef as lo, useId as x, useState as l, useRef as m, useEffect as _ } from "react";
|
|
3
3
|
import { useTranslation as co } from "react-i18next";
|
|
4
4
|
import { c as z } from "./index-D2ZczOXr.js";
|
|
5
|
-
import { i as j, E as mo } from "./email-input-
|
|
5
|
+
import { i as j, E as mo } from "./email-input-DQixfopu.js";
|
|
6
6
|
import { A as P } from "./alert-BhCstf2h.js";
|
|
7
7
|
import { B as fo } from "./button-CYPx2xFq.js";
|
|
8
8
|
import { C as G } from "./card-DPmk26CL.js";
|
|
9
|
-
import { F as uo } from "./form-field-
|
|
9
|
+
import { F as uo } from "./form-field-Db0liyI8.js";
|
|
10
10
|
import { i as go } from "./safe-href-5dbsfbQn.js";
|
|
11
11
|
import { u as vo, a as Fo, A as po, b as ho, E as bo, c as wo, d as xo } from "./auth-form-parts-Celi-TLV.js";
|
|
12
12
|
import { u as Po } from "./use-registration-submit-DxCWic5_.js";
|
|
@@ -200,4 +200,4 @@ export {
|
|
|
200
200
|
Go as F,
|
|
201
201
|
To as a
|
|
202
202
|
};
|
|
203
|
-
//# sourceMappingURL=forgot-password-form-
|
|
203
|
+
//# sourceMappingURL=forgot-password-form-Duu3pZDU.js.map
|
package/dist/_chunks/{forgot-password-form-DVVOBEGj.js.map → forgot-password-form-Duu3pZDU.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgot-password-form-DVVOBEGj.js","sources":["../../src/patterns/forgot-password-form/forgot-password-form.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* ForgotPasswordForm — the card that asks for a password reset link. */\n/* */\n/* One email field and a button, then a confirmation. The confirmation */\n/* is vague on purpose: it never says whether an account exists for the */\n/* address, and never repeats the address. The host sends the email and */\n/* owns every server rule; the card checks what a browser can check, */\n/* then hands the email to `onSubmit` or posts a real form. */\n/* -------------------------------------------------------------------- */\n\nimport {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { cva } from 'class-variance-authority';\n// The validator EmailInput itself uses, so the two never disagree.\nimport isEmail from 'validator/lib/isEmail';\nimport { Alert } from '../../components/alert';\nimport { Button } from '../../components/button';\nimport { Card } from '../../components/card';\nimport { EmailInput } from '../../components/email-input';\nimport { FormField } from '../../components/form-field';\nimport { isSafeHref } from '../../components/_shared/safe-href';\nimport {\n AuthCardHeading,\n AuthFormMessage,\n AuthFormStatus,\n AuthTextLink,\n ExtraFields,\n useExtraFields,\n useFormAction,\n} from '../_shared/auth-form-parts';\nimport type { BrandMarkMotion } from '../_shared/brand-mark';\nimport { useRegistrationSubmit } from '../registration-form/use-registration-submit';\n\n/* -------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------- */\n\n/** The form's one field. */\nexport const FORGOT_PASSWORD_FORM_FIELDS = ['email'] as const;\n\nexport type ForgotPasswordFormField =\n (typeof FORGOT_PASSWORD_FORM_FIELDS)[number];\n\n/** What `onSubmit` receives once the email has passed its check. */\nexport interface ForgotPasswordFormValues {\n email: string;\n}\n\n/** The email to show when the form opens. */\nexport type ForgotPasswordFormInitialValues = Partial<ForgotPasswordFormValues>;\n\n/** Messages from the server, already translated: one for the email,\n * plus `form` for a message about the whole form, such as \"too many\n * requests, try again later\". */\nexport type ForgotPasswordFormErrors = Partial<\n Record<ForgotPasswordFormField | 'form', string>\n>;\n\n/** The host's own form field name, for a native form post. It is needed:\n * a field without a name is not posted. */\nexport type ForgotPasswordFormFieldNames = Record<\n ForgotPasswordFormField,\n string\n>;\n\nexport interface ForgotPasswordFormProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'title' | 'onSubmit'\n> {\n /** Replaces the heading \"Reset your password\". Pass it translated. */\n title?: string;\n /**\n * Replaces the line under the heading (\"Enter the email linked to your\n * account and we will send a reset link.\"). Pass it translated.\n */\n description?: string;\n /**\n * The heading's level. Default 1: this page usually has no other\n * heading. Pass 2 on a page that has its own `h1`.\n */\n headingLevel?: 1 | 2 | 3;\n /**\n * Shows the Alfadocs mark above the heading, with the heading and its\n * line centred under it. Default true.\n */\n showLogo?: boolean;\n /** How the mark arrives when the card opens. Default `assemble`. It\n * plays once and rests. */\n logoMotion?: BrandMarkMotion;\n /**\n * Host content between the heading and the field, such as a notice. It\n * sits outside the form, so nothing in it is posted.\n */\n children?: ReactNode;\n /** The email to show when the form opens. Read once. */\n initialValues?: ForgotPasswordFormInitialValues;\n /**\n * Messages from the server, already translated. The email's message\n * shows on the field until the user changes it; `form` shows above the\n * field. When messages arrive, focus moves to the email, or to the\n * message above it when only that says something.\n *\n * Do not use a message to say that no account has the address: that\n * tells a stranger who has an account. Show `sent` for every address.\n */\n errors?: ForgotPasswordFormErrors;\n /**\n * Shows the confirmation in place of the form: \"Check your inbox\". Set\n * it once the request has been accepted, whether or not an account\n * exists for the address. The confirmation says \"if an account exists\"\n * and never shows the address.\n */\n sent?: boolean;\n /**\n * Adds \"Back to sign in\" under the card's content. A path on the same\n * site, or an address written in full. Anything else shows no link.\n */\n loginHref?: string;\n /** Replaces the button's \"Send reset link\". Pass it translated. */\n submitLabel?: string;\n /**\n * True while the host sends the email: the button shows a spinner and\n * a second submit is ignored. Set it inside `onSubmit`, before anything\n * is awaited: until it is true, a second press sends a second request.\n */\n submitting?: boolean;\n /** For React hosts: called with the email once it has passed its\n * check. Not called when `fieldNames` is set. */\n onSubmit?: (values: ForgotPasswordFormValues) => void;\n /**\n * For a native form post: the host's own field name, e.g.\n * `{ email: 'email' }`. When set, the input carries that name and the\n * browser posts the form.\n */\n fieldNames?: ForgotPasswordFormFieldNames;\n /**\n * Where a native form post goes. Default: the current address. Only a\n * path, or an address on the page's own origin, is accepted: another\n * origin is never sent what the user typed, and the post then goes to\n * the current address. Does nothing without `fieldNames`.\n */\n action?: string;\n /**\n * Extra hidden inputs posted with a native form, by name: a CSRF\n * token. Not used with `onSubmit`. A name that is also the one in\n * `fieldNames` is left out: the form's own field wins.\n */\n hiddenFields?: Readonly<Record<string, string>>;\n}\n\n/* -------------------------------------------------------------------- */\n/* Styles */\n/* -------------------------------------------------------------------- */\n\n// 400px at most, in px: a host whose root font size is not 16px would\n// stretch or squeeze a width in rem.\nconst forgotPasswordFormVariants = cva(\n 'ds:mx-auto ds:w-full ds:max-w-[400px] ds:text-start ds:text-[var(--foreground)]',\n);\n\n// The confirmation takes focus when it appears, so it shows a ring.\nconst confirmationVariants = cva(\n 'ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)] ds:forced-colors:focus-visible:outline-[CanvasText]',\n);\n\n/* -------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------- */\n\ntype FocusTarget = 'email' | 'form';\n\n/** The confirmation's heading, by the level of the card's own. */\nconst CONFIRMATION_HEADING = { 1: 'h2', 2: 'h3', 3: 'h4' } as const;\n\nconst hasMessage = (errors: ForgotPasswordFormErrors): boolean =>\n Object.values(errors).some(Boolean);\n\nconst focusTargetFor = (\n messages: ForgotPasswordFormErrors,\n): FocusTarget | undefined =>\n messages.email ? 'email' : messages.form ? 'form' : undefined;\n\n/* -------------------------------------------------------------------- */\n/* Component */\n/* -------------------------------------------------------------------- */\n\n/**\n * The card that asks for a password reset link. Mount it on the\n * forgot-password page, inside `SignedOutFrame` or the host's own chrome.\n */\nexport const ForgotPasswordForm = forwardRef<\n HTMLDivElement,\n ForgotPasswordFormProps\n>(\n (\n {\n title,\n description,\n headingLevel = 1,\n showLogo = true,\n logoMotion = 'assemble',\n children,\n initialValues,\n errors,\n sent = false,\n loginHref,\n submitLabel,\n submitting = false,\n onSubmit,\n fieldNames,\n action,\n hiddenFields,\n className,\n ...rest\n },\n ref,\n ) => {\n const { t } = useTranslation('ui');\n const titleId = useId();\n const sentTitleId = useId();\n const sentDescriptionId = useId();\n const native = fieldNames !== undefined;\n\n /* ------------------------------ State ----------------------------- */\n\n const [email, setEmail] = useState(() => initialValues?.email ?? '');\n // True once the user has filled in the field and left it. An email\n // that arrives filled in counts: a bad one is then flagged at once,\n // with its message. An empty field is not flagged for being passed\n // through; its message waits for a submit.\n const [touched, setTouched] = useState(() => Boolean(initialValues?.email));\n const [submitted, setSubmitted] = useState(false);\n const [serverErrors, setServerErrors] = useState<ForgotPasswordFormErrors>(\n () => errors ?? {},\n );\n\n const emailInput = useRef<HTMLInputElement>(null);\n /**\n * What the input holds now. Read from the input, not from state: a\n * browser can fill the field without telling React, and the form must\n * not refuse a field that is visibly filled.\n */\n const held = (): string => {\n const value = emailInput.current?.value ?? email;\n if (value !== email) setEmail(value);\n return value;\n };\n\n /* ---------------------------- Validation -------------------------- */\n\n const invalid = !isEmail(email);\n // The message shows once the user has left the field or tried to\n // submit.\n const ownError =\n (submitted || touched) && invalid\n ? email === ''\n ? t('forgotPasswordForm.emailRequired')\n : t('inputs.email.invalid')\n : undefined;\n const emailError = serverErrors.email ?? ownError;\n\n /* ------------------------------ Focus ----------------------------- */\n\n const formMessage = useRef<HTMLDivElement>(null);\n const confirmation = useRef<HTMLDivElement>(null);\n\n // A new object for each request, so asking twice for the same place\n // moves focus twice. It starts with the messages the form opened\n // with: a page the server rendered after a failed post announces\n // nothing itself.\n const [focusRequest, setFocusRequest] = useState<{\n target: FocusTarget;\n } | null>(() => {\n const target = focusTargetFor(errors ?? {});\n return target ? { target } : null;\n });\n useEffect(() => {\n if (!focusRequest) return;\n (focusRequest.target === 'email'\n ? emailInput\n : formMessage\n ).current?.focus();\n }, [focusRequest]);\n\n // The form, and the button that had focus, are gone once the\n // confirmation shows. Move focus to it, so a keyboard or screen\n // reader user lands on what happened. Not on a page that opens\n // already sent: that one is read from the top like any other.\n const wasSent = useRef(sent);\n useEffect(() => {\n if (sent && !wasSent.current) confirmation.current?.focus();\n wasSent.current = sent;\n }, [sent]);\n\n /* ------------------------------ Submit ---------------------------- */\n\n const submit = useRegistrationSubmit<'email'>({\n errors,\n submitting,\n native,\n captcha: false,\n firstProblem: () => (isEmail(held()) ? undefined : 'email'),\n onRefused: () => {\n setSubmitted(true);\n setFocusRequest({ target: 'email' });\n },\n // Only a React host gets here: a native post is the browser's own.\n deliver: () => onSubmit?.({ email: held() }),\n onAnswer: (answer) => {\n const next: ForgotPasswordFormErrors = answer;\n setServerErrors(next);\n if (!hasMessage(next)) return;\n setSubmitted(false);\n const target = focusTargetFor(next);\n if (target) setFocusRequest({ target });\n },\n });\n const { busy } = submit;\n\n /* ------------------------------ Render ---------------------------- */\n\n const formAction = useFormAction('ForgotPasswordForm', native, action);\n const loginLink =\n loginHref && isSafeHref(loginHref) ? loginHref : undefined;\n const extraFields = useExtraFields(\n 'ForgotPasswordForm',\n native,\n fieldNames,\n hiddenFields,\n );\n\n return (\n <div\n ref={ref}\n {...rest}\n data-component=\"forgot-password-form\"\n data-state={sent ? 'sent' : 'asking'}\n className={forgotPasswordFormVariants({ className })}\n >\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]\">\n <AuthCardHeading\n id={titleId}\n title={title ?? t('forgotPasswordForm.title')}\n // The instruction belongs to the form: once it is sent there\n // is nothing left to enter.\n description={\n sent\n ? undefined\n : (description ?? t('forgotPasswordForm.description'))\n }\n level={headingLevel}\n showLogo={showLogo}\n logoMotion={logoMotion}\n />\n\n {children ? (\n <div\n data-slot=\"host-content\"\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n >\n {children}\n </div>\n ) : null}\n\n {sent ? (\n // Named and described, so a screen reader that lands here\n // reads the whole confirmation, not only \"status\".\n <Alert\n ref={confirmation}\n variant=\"success\"\n tabIndex={-1}\n aria-labelledby={sentTitleId}\n aria-describedby={sentDescriptionId}\n data-slot=\"confirmation\"\n className={confirmationVariants()}\n >\n {/* One level under the card's own heading. */}\n <Alert.Title\n id={sentTitleId}\n as={CONFIRMATION_HEADING[headingLevel]}\n >\n {t('forgotPasswordForm.sentTitle')}\n </Alert.Title>\n <Alert.Description id={sentDescriptionId}>\n {t('forgotPasswordForm.sentDescription')}\n </Alert.Description>\n </Alert>\n ) : (\n <>\n <form\n noValidate\n method=\"post\"\n action={formAction}\n aria-labelledby={titleId}\n aria-busy={busy || undefined}\n onSubmit={submit.handleSubmit}\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n >\n {serverErrors.form && (\n <AuthFormMessage ref={formMessage}>\n {serverErrors.form}\n </AuthFormMessage>\n )}\n\n <FormField\n label={t('forgotPasswordForm.email')}\n required\n error={emailError}\n data-field=\"email\"\n >\n {/* One check, above, drives the message, the red mark and\n aria-invalid through FormField. EmailInput's own check\n is off so the two cannot disagree. */}\n <EmailInput\n ref={emailInput}\n name={native ? fieldNames.email : 'email'}\n disableBuiltInValidation\n value={email}\n onChange={(event) => {\n setEmail(event.target.value);\n // The server's message was about the old value.\n setServerErrors((previous) =>\n previous.email\n ? { ...previous, email: undefined }\n : previous,\n );\n }}\n onBlur={(event) => {\n // Whatever a browser filled in without saying so.\n setEmail(event.target.value);\n if (event.target.value !== '') setTouched(true);\n }}\n />\n </FormField>\n\n <ExtraFields fields={extraFields} />\n\n <Button\n type=\"submit\"\n intent=\"primary\"\n size=\"lg\"\n loading={busy}\n className=\"ds:w-full\"\n data-action=\"submit\"\n >\n {submitLabel ?? t('forgotPasswordForm.submit')}\n </Button>\n </form>\n {/* Outside the form: a screen reader may hold back what\n changes inside a busy region. */}\n <AuthFormStatus busy={busy} />\n </>\n )}\n\n {loginLink && (\n <AuthTextLink href={loginLink} action=\"login\">\n {t('forgotPasswordForm.back')}\n </AuthTextLink>\n )}\n </Card.Body>\n </Card>\n </div>\n );\n },\n);\nForgotPasswordForm.displayName = 'ForgotPasswordForm';\n"],"names":["FORGOT_PASSWORD_FORM_FIELDS","forgotPasswordFormVariants","cva","confirmationVariants","CONFIRMATION_HEADING","hasMessage","errors","focusTargetFor","messages","ForgotPasswordForm","forwardRef","title","description","headingLevel","showLogo","logoMotion","children","initialValues","sent","loginHref","submitLabel","submitting","onSubmit","fieldNames","action","hiddenFields","className","rest","ref","t","useTranslation","titleId","useId","sentTitleId","sentDescriptionId","native","email","setEmail","useState","touched","setTouched","submitted","setSubmitted","serverErrors","setServerErrors","emailInput","useRef","held","value","_a","invalid","isEmail","ownError","emailError","formMessage","confirmation","focusRequest","setFocusRequest","target","useEffect","wasSent","submit","useRegistrationSubmit","answer","next","busy","formAction","useFormAction","loginLink","isSafeHref","extraFields","useExtraFields","jsx","Card","AuthCardHeading","jsxs","Alert","Fragment","AuthFormMessage","FormField","EmailInput","event","previous","ExtraFields","Button","AuthFormStatus","AuthTextLink"],"mappings":";;;;;;;;;;;;AA8CO,MAAMA,KAA8B,CAAC,OAAO,GAsH7CC,KAA6BC;AAAA,EACjC;AACF,GAGMC,KAAuBD;AAAA,EAC3B;AACF,GASME,KAAuB,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,KAAA,GAE9CC,KAAa,CAACC,MAClB,OAAO,OAAOA,CAAM,EAAE,KAAK,OAAO,GAE9BC,IAAiB,CACrBC,MAEAA,EAAS,QAAQ,UAAUA,EAAS,OAAO,SAAS,QAUzCC,KAAqBC;AAAA,EAIhC,CACE;AAAA,IACE,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,UAAAC,IAAW;AAAA,IACX,YAAAC,IAAa;AAAA,IACb,UAAAC;AAAA,IACA,eAAAC;AAAA,IACA,QAAAX;AAAA,IACA,MAAAY,IAAO;AAAA,IACP,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,QAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAM,EAAE,GAAAC,EAAA,IAAMC,GAAe,IAAI,GAC3BC,IAAUC,EAAA,GACVC,IAAcD,EAAA,GACdE,IAAoBF,EAAA,GACpBG,IAASZ,MAAe,QAIxB,CAACa,GAAOC,CAAQ,IAAIC,EAAS,OAAMrB,KAAA,gBAAAA,EAAe,UAAS,EAAE,GAK7D,CAACsB,GAASC,EAAU,IAAIF,EAAS,MAAM,GAAQrB,KAAA,QAAAA,EAAe,MAAM,GACpE,CAACwB,IAAWC,CAAY,IAAIJ,EAAS,EAAK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O,WACtBA;AAAA,4BAAA;AAAA,0BAER;AAAA,0BACA,QAAQ,CAACD,MAAU;AAEjB,4BAAA5C,EAAS4C,EAAM,OAAO,KAAK,GACvBA,EAAM,OAAO,UAAU,SAAe,EAAI;AAAA,0BAChD;AAAA,wBAAA;AAAA,sBAAA;AAAA,oBACF;AAAA,kBAAA;AAAA,kBAGF,gBAAAT,EAACW,IAAA,EAAY,QAAQb,GAAA,CAAa;AAAA,kBAElC,gBAAAE;AAAA,oBAACY;AAAA,oBAAA;AAAA,sBACC,MAAK;AAAA,sBACL,QAAO;AAAA,sBACP,MAAK;AAAA,sBACL,SAASnB;AAAA,sBACT,WAAU;AAAA,sBACV,eAAY;AAAA,sBAEX,UAAA7C,KAAeS,EAAE,2BAA2B;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAC/C;AAAA,cAAA;AAAA,YAAA;AAAA,YAIF,gBAAA2C,EAACa,MAAe,MAAApB,EAAA,CAAY;AAAA,UAAA,GAC9B;AAAA,UAGDG,uBACEkB,IAAA,EAAa,MAAMlB,GAAW,QAAO,SACnC,UAAAvC,EAAE,yBAAyB,EAAA,CAC9B;AAAA,QAAA,EAAA,CAEJ,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AACApB,GAAmB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"forgot-password-form-Duu3pZDU.js","sources":["../../src/patterns/forgot-password-form/forgot-password-form.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* ForgotPasswordForm — the card that asks for a password reset link. */\n/* */\n/* One email field and a button, then a confirmation. The confirmation */\n/* is vague on purpose: it never says whether an account exists for the */\n/* address, and never repeats the address. The host sends the email and */\n/* owns every server rule; the card checks what a browser can check, */\n/* then hands the email to `onSubmit` or posts a real form. */\n/* -------------------------------------------------------------------- */\n\nimport {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { cva } from 'class-variance-authority';\n// The validator EmailInput itself uses, so the two never disagree.\nimport isEmail from 'validator/lib/isEmail';\nimport { Alert } from '../../components/alert';\nimport { Button } from '../../components/button';\nimport { Card } from '../../components/card';\nimport { EmailInput } from '../../components/email-input';\nimport { FormField } from '../../components/form-field';\nimport { isSafeHref } from '../../components/_shared/safe-href';\nimport {\n AuthCardHeading,\n AuthFormMessage,\n AuthFormStatus,\n AuthTextLink,\n ExtraFields,\n useExtraFields,\n useFormAction,\n} from '../_shared/auth-form-parts';\nimport type { BrandMarkMotion } from '../_shared/brand-mark';\nimport { useRegistrationSubmit } from '../registration-form/use-registration-submit';\n\n/* -------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------- */\n\n/** The form's one field. */\nexport const FORGOT_PASSWORD_FORM_FIELDS = ['email'] as const;\n\nexport type ForgotPasswordFormField =\n (typeof FORGOT_PASSWORD_FORM_FIELDS)[number];\n\n/** What `onSubmit` receives once the email has passed its check. */\nexport interface ForgotPasswordFormValues {\n email: string;\n}\n\n/** The email to show when the form opens. */\nexport type ForgotPasswordFormInitialValues = Partial<ForgotPasswordFormValues>;\n\n/** Messages from the server, already translated: one for the email,\n * plus `form` for a message about the whole form, such as \"too many\n * requests, try again later\". */\nexport type ForgotPasswordFormErrors = Partial<\n Record<ForgotPasswordFormField | 'form', string>\n>;\n\n/** The host's own form field name, for a native form post. It is needed:\n * a field without a name is not posted. */\nexport type ForgotPasswordFormFieldNames = Record<\n ForgotPasswordFormField,\n string\n>;\n\nexport interface ForgotPasswordFormProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'title' | 'onSubmit'\n> {\n /** Replaces the heading \"Reset your password\". Pass it translated. */\n title?: string;\n /**\n * Replaces the line under the heading (\"Enter the email linked to your\n * account and we will send a reset link.\"). Pass it translated.\n */\n description?: string;\n /**\n * The heading's level. Default 1: this page usually has no other\n * heading. Pass 2 on a page that has its own `h1`.\n */\n headingLevel?: 1 | 2 | 3;\n /**\n * Shows the Alfadocs mark above the heading, with the heading and its\n * line centred under it. Default true.\n */\n showLogo?: boolean;\n /** How the mark arrives when the card opens. Default `assemble`. It\n * plays once and rests. */\n logoMotion?: BrandMarkMotion;\n /**\n * Host content between the heading and the field, such as a notice. It\n * sits outside the form, so nothing in it is posted.\n */\n children?: ReactNode;\n /** The email to show when the form opens. Read once. */\n initialValues?: ForgotPasswordFormInitialValues;\n /**\n * Messages from the server, already translated. The email's message\n * shows on the field until the user changes it; `form` shows above the\n * field. When messages arrive, focus moves to the email, or to the\n * message above it when only that says something.\n *\n * Do not use a message to say that no account has the address: that\n * tells a stranger who has an account. Show `sent` for every address.\n */\n errors?: ForgotPasswordFormErrors;\n /**\n * Shows the confirmation in place of the form: \"Check your inbox\". Set\n * it once the request has been accepted, whether or not an account\n * exists for the address. The confirmation says \"if an account exists\"\n * and never shows the address.\n */\n sent?: boolean;\n /**\n * Adds \"Back to sign in\" under the card's content. A path on the same\n * site, or an address written in full. Anything else shows no link.\n */\n loginHref?: string;\n /** Replaces the button's \"Send reset link\". Pass it translated. */\n submitLabel?: string;\n /**\n * True while the host sends the email: the button shows a spinner and\n * a second submit is ignored. Set it inside `onSubmit`, before anything\n * is awaited: until it is true, a second press sends a second request.\n */\n submitting?: boolean;\n /** For React hosts: called with the email once it has passed its\n * check. Not called when `fieldNames` is set. */\n onSubmit?: (values: ForgotPasswordFormValues) => void;\n /**\n * For a native form post: the host's own field name, e.g.\n * `{ email: 'email' }`. When set, the input carries that name and the\n * browser posts the form.\n */\n fieldNames?: ForgotPasswordFormFieldNames;\n /**\n * Where a native form post goes. Default: the current address. Only a\n * path, or an address on the page's own origin, is accepted: another\n * origin is never sent what the user typed, and the post then goes to\n * the current address. Does nothing without `fieldNames`.\n */\n action?: string;\n /**\n * Extra hidden inputs posted with a native form, by name: a CSRF\n * token. Not used with `onSubmit`. A name that is also the one in\n * `fieldNames` is left out: the form's own field wins.\n */\n hiddenFields?: Readonly<Record<string, string>>;\n}\n\n/* -------------------------------------------------------------------- */\n/* Styles */\n/* -------------------------------------------------------------------- */\n\n// 400px at most, in px: a host whose root font size is not 16px would\n// stretch or squeeze a width in rem.\nconst forgotPasswordFormVariants = cva(\n 'ds:mx-auto ds:w-full ds:max-w-[400px] ds:text-start ds:text-[var(--foreground)]',\n);\n\n// The confirmation takes focus when it appears, so it shows a ring.\nconst confirmationVariants = cva(\n 'ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)] ds:forced-colors:focus-visible:outline-[CanvasText]',\n);\n\n/* -------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------- */\n\ntype FocusTarget = 'email' | 'form';\n\n/** The confirmation's heading, by the level of the card's own. */\nconst CONFIRMATION_HEADING = { 1: 'h2', 2: 'h3', 3: 'h4' } as const;\n\nconst hasMessage = (errors: ForgotPasswordFormErrors): boolean =>\n Object.values(errors).some(Boolean);\n\nconst focusTargetFor = (\n messages: ForgotPasswordFormErrors,\n): FocusTarget | undefined =>\n messages.email ? 'email' : messages.form ? 'form' : undefined;\n\n/* -------------------------------------------------------------------- */\n/* Component */\n/* -------------------------------------------------------------------- */\n\n/**\n * The card that asks for a password reset link. Mount it on the\n * forgot-password page, inside `SignedOutFrame` or the host's own chrome.\n */\nexport const ForgotPasswordForm = forwardRef<\n HTMLDivElement,\n ForgotPasswordFormProps\n>(\n (\n {\n title,\n description,\n headingLevel = 1,\n showLogo = true,\n logoMotion = 'assemble',\n children,\n initialValues,\n errors,\n sent = false,\n loginHref,\n submitLabel,\n submitting = false,\n onSubmit,\n fieldNames,\n action,\n hiddenFields,\n className,\n ...rest\n },\n ref,\n ) => {\n const { t } = useTranslation('ui');\n const titleId = useId();\n const sentTitleId = useId();\n const sentDescriptionId = useId();\n const native = fieldNames !== undefined;\n\n /* ------------------------------ State ----------------------------- */\n\n const [email, setEmail] = useState(() => initialValues?.email ?? '');\n // True once the user has filled in the field and left it. An email\n // that arrives filled in counts: a bad one is then flagged at once,\n // with its message. An empty field is not flagged for being passed\n // through; its message waits for a submit.\n const [touched, setTouched] = useState(() => Boolean(initialValues?.email));\n const [submitted, setSubmitted] = useState(false);\n const [serverErrors, setServerErrors] = useState<ForgotPasswordFormErrors>(\n () => errors ?? {},\n );\n\n const emailInput = useRef<HTMLInputElement>(null);\n /**\n * What the input holds now. Read from the input, not from state: a\n * browser can fill the field without telling React, and the form must\n * not refuse a field that is visibly filled.\n */\n const held = (): string => {\n const value = emailInput.current?.value ?? email;\n if (value !== email) setEmail(value);\n return value;\n };\n\n /* ---------------------------- Validation -------------------------- */\n\n const invalid = !isEmail(email);\n // The message shows once the user has left the field or tried to\n // submit.\n const ownError =\n (submitted || touched) && invalid\n ? email === ''\n ? t('forgotPasswordForm.emailRequired')\n : t('inputs.email.invalid')\n : undefined;\n const emailError = serverErrors.email ?? ownError;\n\n /* ------------------------------ Focus ----------------------------- */\n\n const formMessage = useRef<HTMLDivElement>(null);\n const confirmation = useRef<HTMLDivElement>(null);\n\n // A new object for each request, so asking twice for the same place\n // moves focus twice. It starts with the messages the form opened\n // with: a page the server rendered after a failed post announces\n // nothing itself.\n const [focusRequest, setFocusRequest] = useState<{\n target: FocusTarget;\n } | null>(() => {\n const target = focusTargetFor(errors ?? {});\n return target ? { target } : null;\n });\n useEffect(() => {\n if (!focusRequest) return;\n (focusRequest.target === 'email'\n ? emailInput\n : formMessage\n ).current?.focus();\n }, [focusRequest]);\n\n // The form, and the button that had focus, are gone once the\n // confirmation shows. Move focus to it, so a keyboard or screen\n // reader user lands on what happened. Not on a page that opens\n // already sent: that one is read from the top like any other.\n const wasSent = useRef(sent);\n useEffect(() => {\n if (sent && !wasSent.current) confirmation.current?.focus();\n wasSent.current = sent;\n }, [sent]);\n\n /* ------------------------------ Submit ---------------------------- */\n\n const submit = useRegistrationSubmit<'email'>({\n errors,\n submitting,\n native,\n captcha: false,\n firstProblem: () => (isEmail(held()) ? undefined : 'email'),\n onRefused: () => {\n setSubmitted(true);\n setFocusRequest({ target: 'email' });\n },\n // Only a React host gets here: a native post is the browser's own.\n deliver: () => onSubmit?.({ email: held() }),\n onAnswer: (answer) => {\n const next: ForgotPasswordFormErrors = answer;\n setServerErrors(next);\n if (!hasMessage(next)) return;\n setSubmitted(false);\n const target = focusTargetFor(next);\n if (target) setFocusRequest({ target });\n },\n });\n const { busy } = submit;\n\n /* ------------------------------ Render ---------------------------- */\n\n const formAction = useFormAction('ForgotPasswordForm', native, action);\n const loginLink =\n loginHref && isSafeHref(loginHref) ? loginHref : undefined;\n const extraFields = useExtraFields(\n 'ForgotPasswordForm',\n native,\n fieldNames,\n hiddenFields,\n );\n\n return (\n <div\n ref={ref}\n {...rest}\n data-component=\"forgot-password-form\"\n data-state={sent ? 'sent' : 'asking'}\n className={forgotPasswordFormVariants({ className })}\n >\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]\">\n <AuthCardHeading\n id={titleId}\n title={title ?? t('forgotPasswordForm.title')}\n // The instruction belongs to the form: once it is sent there\n // is nothing left to enter.\n description={\n sent\n ? undefined\n : (description ?? t('forgotPasswordForm.description'))\n }\n level={headingLevel}\n showLogo={showLogo}\n logoMotion={logoMotion}\n />\n\n {children ? (\n <div\n data-slot=\"host-content\"\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n >\n {children}\n </div>\n ) : null}\n\n {sent ? (\n // Named and described, so a screen reader that lands here\n // reads the whole confirmation, not only \"status\".\n <Alert\n ref={confirmation}\n variant=\"success\"\n tabIndex={-1}\n aria-labelledby={sentTitleId}\n aria-describedby={sentDescriptionId}\n data-slot=\"confirmation\"\n className={confirmationVariants()}\n >\n {/* One level under the card's own heading. */}\n <Alert.Title\n id={sentTitleId}\n as={CONFIRMATION_HEADING[headingLevel]}\n >\n {t('forgotPasswordForm.sentTitle')}\n </Alert.Title>\n <Alert.Description id={sentDescriptionId}>\n {t('forgotPasswordForm.sentDescription')}\n </Alert.Description>\n </Alert>\n ) : (\n <>\n <form\n noValidate\n method=\"post\"\n action={formAction}\n aria-labelledby={titleId}\n aria-busy={busy || undefined}\n onSubmit={submit.handleSubmit}\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n >\n {serverErrors.form && (\n <AuthFormMessage ref={formMessage}>\n {serverErrors.form}\n </AuthFormMessage>\n )}\n\n <FormField\n label={t('forgotPasswordForm.email')}\n required\n error={emailError}\n data-field=\"email\"\n >\n {/* One check, above, drives the message, the red mark and\n aria-invalid through FormField. EmailInput's own check\n is off so the two cannot disagree. */}\n <EmailInput\n ref={emailInput}\n name={native ? fieldNames.email : 'email'}\n disableBuiltInValidation\n value={email}\n onChange={(event) => {\n setEmail(event.target.value);\n // The server's message was about the old value.\n setServerErrors((previous) =>\n previous.email\n ? { ...previous, email: undefined }\n : previous,\n );\n }}\n onBlur={(event) => {\n // Whatever a browser filled in without saying so.\n setEmail(event.target.value);\n if (event.target.value !== '') setTouched(true);\n }}\n />\n </FormField>\n\n <ExtraFields fields={extraFields} />\n\n <Button\n type=\"submit\"\n intent=\"primary\"\n size=\"lg\"\n loading={busy}\n className=\"ds:w-full\"\n data-action=\"submit\"\n >\n {submitLabel ?? t('forgotPasswordForm.submit')}\n </Button>\n </form>\n {/* Outside the form: a screen reader may hold back what\n changes inside a busy region. */}\n <AuthFormStatus busy={busy} />\n </>\n )}\n\n {loginLink && (\n <AuthTextLink href={loginLink} action=\"login\">\n {t('forgotPasswordForm.back')}\n </AuthTextLink>\n )}\n </Card.Body>\n </Card>\n </div>\n );\n },\n);\nForgotPasswordForm.displayName = 'ForgotPasswordForm';\n"],"names":["FORGOT_PASSWORD_FORM_FIELDS","forgotPasswordFormVariants","cva","confirmationVariants","CONFIRMATION_HEADING","hasMessage","errors","focusTargetFor","messages","ForgotPasswordForm","forwardRef","title","description","headingLevel","showLogo","logoMotion","children","initialValues","sent","loginHref","submitLabel","submitting","onSubmit","fieldNames","action","hiddenFields","className","rest","ref","t","useTranslation","titleId","useId","sentTitleId","sentDescriptionId","native","email","setEmail","useState","touched","setTouched","submitted","setSubmitted","serverErrors","setServerErrors","emailInput","useRef","held","value","_a","invalid","isEmail","ownError","emailError","formMessage","confirmation","focusRequest","setFocusRequest","target","useEffect","wasSent","submit","useRegistrationSubmit","answer","next","busy","formAction","useFormAction","loginLink","isSafeHref","extraFields","useExtraFields","jsx","Card","AuthCardHeading","jsxs","Alert","Fragment","AuthFormMessage","FormField","EmailInput","event","previous","ExtraFields","Button","AuthFormStatus","AuthTextLink"],"mappings":";;;;;;;;;;;;AA8CO,MAAMA,KAA8B,CAAC,OAAO,GAsH7CC,KAA6BC;AAAA,EACjC;AACF,GAGMC,KAAuBD;AAAA,EAC3B;AACF,GASME,KAAuB,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,KAAA,GAE9CC,KAAa,CAACC,MAClB,OAAO,OAAOA,CAAM,EAAE,KAAK,OAAO,GAE9BC,IAAiB,CACrBC,MAEAA,EAAS,QAAQ,UAAUA,EAAS,OAAO,SAAS,QAUzCC,KAAqBC;AAAA,EAIhC,CACE;AAAA,IACE,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,UAAAC,IAAW;AAAA,IACX,YAAAC,IAAa;AAAA,IACb,UAAAC;AAAA,IACA,eAAAC;AAAA,IACA,QAAAX;AAAA,IACA,MAAAY,IAAO;AAAA,IACP,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,QAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAM,EAAE,GAAAC,EAAA,IAAMC,GAAe,IAAI,GAC3BC,IAAUC,EAAA,GACVC,IAAcD,EAAA,GACdE,IAAoBF,EAAA,GACpBG,IAASZ,MAAe,QAIxB,CAACa,GAAOC,C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AA,0BAClC,0BAAwB;AAAA,0BACxB,OAAOa;AAAA,0BACP,UAAU,CAAC6C,MAAU;AACnB,4BAAA5C,EAAS4C,EAAM,OAAO,KAAK,GAE3BrC;AAAA,8BAAgB,CAACsC,MACfA,EAAS,QACL,EAAE,GAAGA,GAAU,OAAO,WACtBA;AAAA,4BAAA;AAAA,0BAER;AAAA,0BACA,QAAQ,CAACD,MAAU;AAEjB,4BAAA5C,EAAS4C,EAAM,OAAO,KAAK,GACvBA,EAAM,OAAO,UAAU,SAAe,EAAI;AAAA,0BAChD;AAAA,wBAAA;AAAA,sBAAA;AAAA,oBACF;AAAA,kBAAA;AAAA,kBAGF,gBAAAT,EAACW,IAAA,EAAY,QAAQb,GAAA,CAAa;AAAA,kBAElC,gBAAAE;AAAA,oBAACY;AAAA,oBAAA;AAAA,sBACC,MAAK;AAAA,sBACL,QAAO;AAAA,sBACP,MAAK;AAAA,sBACL,SAASnB;AAAA,sBACT,WAAU;AAAA,sBACV,eAAY;AAAA,sBAEX,UAAA7C,KAAeS,EAAE,2BAA2B;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAC/C;AAAA,cAAA;AAAA,YAAA;AAAA,YAIF,gBAAA2C,EAACa,MAAe,MAAApB,EAAA,CAAY;AAAA,UAAA,GAC9B;AAAA,UAGDG,uBACEkB,IAAA,EAAa,MAAMlB,GAAW,QAAO,SACnC,UAAAvC,EAAE,yBAAyB,EAAA,CAC9B;AAAA,QAAA,EAAA,CAEJ,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AACApB,GAAmB,cAAc;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as n, Fragment as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { c as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { F as
|
|
6
|
-
import { C as
|
|
7
|
-
const
|
|
1
|
+
import { jsxs as n, Fragment as K, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Q, useId as X, useState as z, useMemo as D, useRef as T, useCallback as Y } from "react";
|
|
3
|
+
import { c as V } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as Z } from "react-i18next";
|
|
5
|
+
import { F as ee } from "./form-field-context-DtiROUJV.js";
|
|
6
|
+
import { C as se } from "./circle-alert-rGDZ73Wh.js";
|
|
7
|
+
const te = V("ds:text-start", {
|
|
8
8
|
variants: {
|
|
9
9
|
orientation: {
|
|
10
10
|
vertical: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
|
|
@@ -19,7 +19,7 @@ const Z = D("ds:text-start", {
|
|
|
19
19
|
orientation: "vertical",
|
|
20
20
|
disabled: !1
|
|
21
21
|
}
|
|
22
|
-
}),
|
|
22
|
+
}), ne = V("ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", {
|
|
23
23
|
variants: {
|
|
24
24
|
orientation: {
|
|
25
25
|
vertical: "",
|
|
@@ -29,69 +29,70 @@ const Z = D("ds:text-start", {
|
|
|
29
29
|
defaultVariants: {
|
|
30
30
|
orientation: "vertical"
|
|
31
31
|
}
|
|
32
|
-
}),
|
|
33
|
-
(
|
|
32
|
+
}), oe = Q(
|
|
33
|
+
($, j) => {
|
|
34
34
|
const {
|
|
35
35
|
label: m,
|
|
36
36
|
labelStart: i,
|
|
37
37
|
labelEnd: d,
|
|
38
38
|
description: c,
|
|
39
|
-
error:
|
|
39
|
+
error: o,
|
|
40
40
|
required: u = !1,
|
|
41
|
-
optional:
|
|
41
|
+
optional: E = !1,
|
|
42
42
|
orientation: v = "vertical",
|
|
43
43
|
disabled: f = !1,
|
|
44
|
-
className:
|
|
45
|
-
children:
|
|
46
|
-
...
|
|
47
|
-
} =
|
|
48
|
-
() => [c ?
|
|
49
|
-
[c, r, a
|
|
50
|
-
),
|
|
51
|
-
(
|
|
52
|
-
const
|
|
53
|
-
var
|
|
54
|
-
const t = (
|
|
55
|
-
if (
|
|
56
|
-
|
|
44
|
+
className: L,
|
|
45
|
+
children: P,
|
|
46
|
+
..._
|
|
47
|
+
} = $, { t: M } = Z("ui"), e = X(), r = `${e}-help`, a = `${e}-error`, q = `${e}-notice`, b = !!o, [N, A] = z(void 0), y = D(
|
|
48
|
+
() => [c ? r : null, o ? a : null].filter(Boolean).join(" "),
|
|
49
|
+
[c, o, r, a]
|
|
50
|
+
), F = T(null), G = T([]), [U, I] = z(null), C = Y(
|
|
51
|
+
(B) => {
|
|
52
|
+
const l = G.current, k = () => {
|
|
53
|
+
var w;
|
|
54
|
+
const t = (w = F.current) == null ? void 0 : w.getRootNode(), p = (x) => t instanceof Document || t instanceof ShadowRoot ? t.getElementById(x) : null;
|
|
55
|
+
if (l.includes(e) || p(e)) {
|
|
56
|
+
I(null);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
const h = p(x), g = p(
|
|
59
|
+
const H = [...l].sort((x, J) => {
|
|
60
|
+
const h = p(x), g = p(J);
|
|
61
61
|
return !h || !g || h === g ? 0 : h.compareDocumentPosition(g) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
I(H[0] ?? null);
|
|
64
64
|
};
|
|
65
|
-
return
|
|
66
|
-
const t =
|
|
67
|
-
t !== -1 &&
|
|
65
|
+
return l.push(B), k(), () => {
|
|
66
|
+
const t = l.indexOf(B);
|
|
67
|
+
t !== -1 && l.splice(t, 1), k();
|
|
68
68
|
};
|
|
69
69
|
},
|
|
70
70
|
[e]
|
|
71
|
-
),
|
|
71
|
+
), O = typeof m == "string" ? m : void 0, W = D(
|
|
72
72
|
() => ({
|
|
73
73
|
id: e,
|
|
74
|
-
helpId:
|
|
75
|
-
errorId:
|
|
76
|
-
describedBy:
|
|
74
|
+
helpId: r,
|
|
75
|
+
errorId: a,
|
|
76
|
+
describedBy: y,
|
|
77
77
|
invalid: b,
|
|
78
78
|
required: u,
|
|
79
79
|
disabled: f,
|
|
80
|
-
label:
|
|
81
|
-
registerControlId:
|
|
80
|
+
label: O,
|
|
81
|
+
registerControlId: C,
|
|
82
|
+
setNotice: A
|
|
82
83
|
}),
|
|
83
84
|
[
|
|
84
85
|
e,
|
|
86
|
+
r,
|
|
85
87
|
a,
|
|
86
|
-
|
|
87
|
-
N,
|
|
88
|
+
y,
|
|
88
89
|
b,
|
|
89
90
|
u,
|
|
90
91
|
f,
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
O,
|
|
93
|
+
C
|
|
93
94
|
]
|
|
94
|
-
),
|
|
95
|
+
), R = /* @__PURE__ */ n(K, { children: [
|
|
95
96
|
m,
|
|
96
97
|
u && /* @__PURE__ */ s(
|
|
97
98
|
"span",
|
|
@@ -101,54 +102,62 @@ const Z = D("ds:text-start", {
|
|
|
101
102
|
children: "*"
|
|
102
103
|
}
|
|
103
104
|
),
|
|
104
|
-
|
|
105
|
+
E && /* @__PURE__ */ n("span", { className: "ds:text-muted-foreground ds:ms-[var(--spacing-xs)] ds:font-normal", children: [
|
|
105
106
|
"(",
|
|
106
|
-
|
|
107
|
+
M("common.optional", "optional"),
|
|
107
108
|
")"
|
|
108
109
|
] })
|
|
109
|
-
] }),
|
|
110
|
-
return /* @__PURE__ */ s(
|
|
110
|
+
] }), S = !!(i || d);
|
|
111
|
+
return /* @__PURE__ */ s(ee.Provider, { value: W, children: /* @__PURE__ */ n(
|
|
111
112
|
"div",
|
|
112
113
|
{
|
|
113
|
-
ref:
|
|
114
|
-
className:
|
|
114
|
+
ref: j,
|
|
115
|
+
className: te({ orientation: v, disabled: f, className: L }),
|
|
115
116
|
"data-component": "form-field",
|
|
116
|
-
...
|
|
117
|
+
..._,
|
|
117
118
|
children: [
|
|
118
119
|
/* @__PURE__ */ n(
|
|
119
120
|
"label",
|
|
120
121
|
{
|
|
121
|
-
ref:
|
|
122
|
+
ref: F,
|
|
122
123
|
id: `${e}-label`,
|
|
123
|
-
htmlFor:
|
|
124
|
-
className:
|
|
124
|
+
htmlFor: U ?? e,
|
|
125
|
+
className: S ? "type-label ds:text-foreground ds:flex ds:items-start ds:gap-[var(--spacing-xs)]" : "type-label ds:text-foreground",
|
|
125
126
|
children: [
|
|
126
127
|
i ? /* @__PURE__ */ s("span", { className: "ds:inline-flex ds:shrink-0 ds:items-center", children: i }) : null,
|
|
127
128
|
i ? " " : null,
|
|
128
|
-
|
|
129
|
+
S ? /* @__PURE__ */ s("span", { children: R }) : R,
|
|
129
130
|
d ? " " : null,
|
|
130
131
|
d ? /* @__PURE__ */ s("span", { className: "ds:ms-auto ds:inline-flex ds:shrink-0 ds:items-center", children: d }) : null
|
|
131
132
|
]
|
|
132
133
|
}
|
|
133
134
|
),
|
|
134
|
-
/* @__PURE__ */ n("div", { className:
|
|
135
|
-
|
|
136
|
-
c && /* @__PURE__ */ s("p", { id:
|
|
137
|
-
|
|
135
|
+
/* @__PURE__ */ n("div", { className: ne({ orientation: v }), children: [
|
|
136
|
+
P,
|
|
137
|
+
c && /* @__PURE__ */ s("p", { id: r, className: "type-body-sm ds:text-muted-foreground", children: c }),
|
|
138
|
+
N && /* @__PURE__ */ s(
|
|
138
139
|
"p",
|
|
139
140
|
{
|
|
140
|
-
id:
|
|
141
|
+
id: q,
|
|
142
|
+
className: "type-body-sm ds:text-muted-foreground",
|
|
143
|
+
children: N
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
o && /* @__PURE__ */ n(
|
|
147
|
+
"p",
|
|
148
|
+
{
|
|
149
|
+
id: a,
|
|
141
150
|
role: "alert",
|
|
142
151
|
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-body-sm ds:text-destructive",
|
|
143
152
|
children: [
|
|
144
153
|
/* @__PURE__ */ s(
|
|
145
|
-
|
|
154
|
+
se,
|
|
146
155
|
{
|
|
147
156
|
"aria-hidden": "true",
|
|
148
157
|
className: "ds:size-4 ds:shrink-0"
|
|
149
158
|
}
|
|
150
159
|
),
|
|
151
|
-
/* @__PURE__ */ s("span", { children:
|
|
160
|
+
/* @__PURE__ */ s("span", { children: o })
|
|
152
161
|
]
|
|
153
162
|
}
|
|
154
163
|
)
|
|
@@ -158,8 +167,8 @@ const Z = D("ds:text-start", {
|
|
|
158
167
|
) });
|
|
159
168
|
}
|
|
160
169
|
);
|
|
161
|
-
|
|
170
|
+
oe.displayName = "FormField";
|
|
162
171
|
export {
|
|
163
|
-
|
|
172
|
+
oe as F
|
|
164
173
|
};
|
|
165
|
-
//# sourceMappingURL=form-field-
|
|
174
|
+
//# sourceMappingURL=form-field-Db0liyI8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-field-Db0liyI8.js","sources":["../../src/components/form-field/form-field.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { CircleAlert } from 'lucide-react';\nimport {\n FormFieldContext,\n type FormFieldContextShape,\n} from './form-field-context';\n\nconst fieldVariants = cva('ds:text-start', {\n variants: {\n orientation: {\n vertical: 'ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]',\n horizontal:\n 'ds:grid ds:grid-cols-[minmax(0,var(--form-label-inline-size))_minmax(0,1fr)] ds:items-start ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-xs)]',\n },\n disabled: {\n true: 'ds:opacity-50 ds:cursor-not-allowed',\n false: '',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n disabled: false,\n },\n});\n\nconst slotsVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]', {\n variants: {\n orientation: {\n vertical: '',\n horizontal: 'ds:min-w-0',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n});\n\ntype RequiredIndicator =\n | { required?: boolean; optional?: never }\n | { required?: never; optional?: boolean };\n\ninterface BaseFormFieldProps\n extends\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>,\n Omit<VariantProps<typeof fieldVariants>, 'disabled'> {\n label: string;\n /**\n * Rendered at the inline START of the label line, `--spacing-xs` before\n * the text — a status chip or a marker, never a control. Part of the\n * label, so its text joins the field's accessible name (\"Highlighted,\n * Allergies\"). Use it when the mark qualifies the question itself; a\n * reader should not have to cross the line to learn what it refers to.\n */\n labelStart?: React.ReactNode;\n /**\n * Rendered at the inline end of the label line — a status chip or a\n * marker, never a control. Part of the label, so its text joins the\n * field's accessible name (\"Allergies, Highlighted\").\n */\n labelEnd?: React.ReactNode;\n description?: string;\n error?: string;\n disabled?: boolean;\n children: React.ReactNode;\n}\n\nexport type FormFieldProps = BaseFormFieldProps & RequiredIndicator;\n\nexport const FormField = forwardRef<HTMLDivElement, FormFieldProps>(\n (props, ref) => {\n const {\n label,\n labelStart,\n labelEnd,\n description,\n error,\n required = false,\n optional = false,\n orientation = 'vertical',\n disabled = false,\n className,\n children,\n ...rest\n } = props as BaseFormFieldProps & {\n required?: boolean;\n optional?: boolean;\n };\n\n const { t } = useTranslation('ui');\n const id = useId();\n const helpId = `${id}-help`;\n const errorId = `${id}-error`;\n const noticeId = `${id}-notice`;\n const invalid = Boolean(error);\n const [notice, setNotice] = useState<string | undefined>(undefined);\n\n const describedBy = useMemo(\n () =>\n [description ? helpId : null, error ? errorId : null]\n .filter(Boolean)\n .join(' '),\n [description, error, helpId, errorId],\n );\n\n /* The ids the controls inside really render. The label follows one of\n them only while nothing uses the field's own id: a control that reads\n `useFormField().id` itself never registers, so the DOM is asked too.\n Of several host ids, the first in the document wins. */\n const labelRef = useRef<HTMLLabelElement>(null);\n const controlIdsRef = useRef<string[]>([]);\n const [customControlId, setCustomControlId] = useState<string | null>(null);\n const registerControlId = useCallback(\n (controlId: string) => {\n const ids = controlIdsRef.current;\n const sync = () => {\n const root = labelRef.current?.getRootNode();\n const find = (elementId: string) =>\n root instanceof Document || root instanceof ShadowRoot\n ? root.getElementById(elementId)\n : null;\n if (ids.includes(id) || find(id)) {\n setCustomControlId(null);\n return;\n }\n const inDocumentOrder = [...ids].sort((a, b) => {\n const first = find(a);\n const second = find(b);\n if (!first || !second || first === second) return 0;\n return first.compareDocumentPosition(second) &\n Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1;\n });\n setCustomControlId(inDocumentOrder[0] ?? null);\n };\n ids.push(controlId);\n sync();\n return () => {\n const index = ids.indexOf(controlId);\n if (index !== -1) ids.splice(index, 1);\n sync();\n };\n },\n [id],\n );\n\n const labelString = typeof label === 'string' ? label : undefined;\n\n const ctx: FormFieldContextShape = useMemo(\n () => ({\n id,\n helpId,\n errorId,\n describedBy,\n invalid,\n required,\n disabled,\n label: labelString,\n registerControlId,\n setNotice,\n }),\n [\n id,\n helpId,\n errorId,\n describedBy,\n invalid,\n required,\n disabled,\n labelString,\n registerControlId,\n ],\n );\n\n const labelText = (\n <>\n {label}\n {required && (\n <span\n aria-hidden=\"true\"\n className=\"ds:text-destructive ds:ms-[var(--spacing-xs)]\"\n >\n *\n </span>\n )}\n {optional && (\n <span className=\"ds:text-muted-foreground ds:ms-[var(--spacing-xs)] ds:font-normal\">\n ({t('common.optional', 'optional')})\n </span>\n )}\n </>\n );\n\n const hasLabelSlot = Boolean(labelStart || labelEnd);\n\n return (\n <FormFieldContext.Provider value={ctx}>\n <div\n ref={ref}\n className={fieldVariants({ orientation, disabled, className })}\n data-component=\"form-field\"\n {...rest}\n >\n <label\n ref={labelRef}\n id={`${id}-label`}\n htmlFor={customControlId ?? id}\n className={\n hasLabelSlot\n ? 'type-label ds:text-foreground ds:flex ds:items-start ds:gap-[var(--spacing-xs)]'\n : 'type-label ds:text-foreground'\n }\n >\n {labelStart ? (\n <span className=\"ds:inline-flex ds:shrink-0 ds:items-center\">\n {labelStart}\n </span>\n ) : null}\n {/* An explicit separator, so the accessible name reads\n \"Highlighted, Allergies\" and not one run-on word. The label\n row is a flex box, which drops a whitespace-only text node —\n it costs nothing on screen. */}\n {labelStart ? ' ' : null}\n {/* Wrapped only when a slot sits beside it: the plain label\n keeps its text as a direct child, as consumers assert. */}\n {hasLabelSlot ? <span>{labelText}</span> : labelText}\n {labelEnd ? ' ' : null}\n {labelEnd ? (\n <span className=\"ds:ms-auto ds:inline-flex ds:shrink-0 ds:items-center\">\n {labelEnd}\n </span>\n ) : null}\n </label>\n <div className={slotsVariants({ orientation })}>\n {children}\n {description && (\n <p id={helpId} className=\"type-body-sm ds:text-muted-foreground\">\n {description}\n </p>\n )}\n {/* Neither live nor in the field's description: the control\n announces it, and a description that changes while the\n field has focus is read again by NVDA. */}\n {notice && (\n <p\n id={noticeId}\n className=\"type-body-sm ds:text-muted-foreground\"\n >\n {notice}\n </p>\n )}\n {error && (\n <p\n id={errorId}\n role=\"alert\"\n className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-body-sm ds:text-destructive\"\n >\n <CircleAlert\n aria-hidden=\"true\"\n className=\"ds:size-4 ds:shrink-0\"\n />\n <span>{error}</span>\n </p>\n )}\n </div>\n </div>\n </FormFieldContext.Provider>\n );\n },\n);\n\nFormField.displayName = 'FormField';\n"],"names":["fieldVariants","cva","slotsVariants","FormField","forwardRef","props","ref","label","labelStart","labelEnd","description","error","required","optional","orientation","disabled","className","children","rest","t","useTranslation","id","useId","helpId","errorId","noticeId","invalid","notice","setNotice","useState","describedBy","useMemo","labelRef","useRef","controlIdsRef","customControlId","setCustomControlId","registerControlId","useCallback","controlId","ids","sync","root","_a","find","elementId","inDocumentOrder","a","b","first","second","index","labelString","ctx","labelText","jsxs","Fragment","jsx","hasLabelSlot","FormFieldContext","CircleAlert"],"mappings":";;;;;;AAiBA,MAAMA,KAAgBC,EAAI,iBAAiB;AAAA,EACzC,UAAU;AAAA,IACR,aAAa;AAAA,MACX,UAAU;AAAA,MACV,YACE;AAAA,IAAA;AAAA,IAEJ,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,IAAA;AAAA,EACT;AAAA,EAEF,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,UAAU;AAAA,EAAA;AAEd,CA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AAA;AAAA,YAGJhB,KACC,gBAAA4C;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,IAAI/B;AAAA,gBACJ,MAAK;AAAA,gBACL,WAAU;AAAA,gBAEV,UAAA;AAAA,kBAAA,gBAAAiC;AAAA,oBAACG;AAAA,oBAAA;AAAA,sBACC,eAAY;AAAA,sBACZ,WAAU;AAAA,oBAAA;AAAA,kBAAA;AAAA,kBAEZ,gBAAAH,EAAC,UAAM,UAAA9C,EAAA,CAAM;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACf,EAAA,CAEJ;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEAR,GAAU,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-field-context-DtiROUJV.js","sources":["../../src/components/form-field/form-field-context.ts"],"sourcesContent":["import { createContext, useContext, useId, type RefObject } from 'react';\nimport { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';\n\nexport interface FormFieldContextShape {\n id: string;\n helpId: string;\n errorId: string;\n describedBy: string;\n invalid: boolean;\n required: boolean;\n disabled: boolean;\n /** The field's label text, for a control that cannot be named by `for`. */\n label?: string;\n /**\n * A control reports the id it really renders, so the label's `for`\n * follows it. Returns the release. Call it from an effect; prefer\n * `useFormFieldControlId`.\n */\n registerControlId?: (controlId: string) => () => void;\n}\n\nexport const FormFieldContext = createContext<FormFieldContextShape | null>(\n null,\n);\n\nexport function useFormField(): FormFieldContextShape {\n const ctx = useContext(FormFieldContext);\n const fallbackId = useId();\n\n if (ctx) {\n return ctx;\n }\n\n return {\n id: fallbackId,\n helpId: `${fallbackId}-help`,\n errorId: `${fallbackId}-error`,\n describedBy: '',\n invalid: false,\n required: false,\n disabled: false,\n };\n}\n\n/**\n * The id a control renders: its own `id`, else the field's. Inside a\n * `<FormField>` the id is reported to the field, so the label's `for`\n * points at the control even when the host chose the id.\n */\nexport function useFormFieldControlId(\n ctx: FormFieldContextShape,\n id?: string,\n): string {\n const controlId = id ?? ctx.id;\n const register = ctx.registerControlId;\n useIsomorphicLayoutEffect(() => register?.(controlId), [register, controlId]);\n return controlId;\n}\n\n/**\n * For a control whose id is written by a library (cmdk): reports the id the\n * element really has, read from the DOM after mount.\n */\nexport function useFormFieldControlRef(\n ctx: FormFieldContextShape,\n ref: RefObject<HTMLElement | null>,\n): void {\n const register = ctx.registerControlId;\n useIsomorphicLayoutEffect(() => {\n const controlId = ref.current?.id;\n if (register && controlId) return register(controlId);\n }, [register, ref]);\n}\n"],"names":["FormFieldContext","createContext","useFormField","ctx","useContext","fallbackId","useId","useFormFieldControlId","id","controlId","register","useIsomorphicLayoutEffect","useFormFieldControlRef","ref","_a"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"form-field-context-DtiROUJV.js","sources":["../../src/components/form-field/form-field-context.ts"],"sourcesContent":["import { createContext, useContext, useId, type RefObject } from 'react';\nimport { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';\n\nexport interface FormFieldContextShape {\n id: string;\n helpId: string;\n errorId: string;\n describedBy: string;\n invalid: boolean;\n required: boolean;\n disabled: boolean;\n /** The field's label text, for a control that cannot be named by `for`. */\n label?: string;\n /**\n * A control reports the id it really renders, so the label's `for`\n * follows it. Returns the release. Call it from an effect; prefer\n * `useFormFieldControlId`.\n */\n registerControlId?: (controlId: string) => () => void;\n /**\n * A control shows a short note under the field, e.g. that a paste was\n * refused; `undefined` removes it. The control announces it itself.\n */\n setNotice?: (notice: string | undefined) => void;\n}\n\nexport const FormFieldContext = createContext<FormFieldContextShape | null>(\n null,\n);\n\nexport function useFormField(): FormFieldContextShape {\n const ctx = useContext(FormFieldContext);\n const fallbackId = useId();\n\n if (ctx) {\n return ctx;\n }\n\n return {\n id: fallbackId,\n helpId: `${fallbackId}-help`,\n errorId: `${fallbackId}-error`,\n describedBy: '',\n invalid: false,\n required: false,\n disabled: false,\n };\n}\n\n/**\n * The id a control renders: its own `id`, else the field's. Inside a\n * `<FormField>` the id is reported to the field, so the label's `for`\n * points at the control even when the host chose the id.\n */\nexport function useFormFieldControlId(\n ctx: FormFieldContextShape,\n id?: string,\n): string {\n const controlId = id ?? ctx.id;\n const register = ctx.registerControlId;\n useIsomorphicLayoutEffect(() => register?.(controlId), [register, controlId]);\n return controlId;\n}\n\n/**\n * For a control whose id is written by a library (cmdk): reports the id the\n * element really has, read from the DOM after mount.\n */\nexport function useFormFieldControlRef(\n ctx: FormFieldContextShape,\n ref: RefObject<HTMLElement | null>,\n): void {\n const register = ctx.registerControlId;\n useIsomorphicLayoutEffect(() => {\n const controlId = ref.current?.id;\n if (register && controlId) return register(controlId);\n }, [register, ref]);\n}\n"],"names":["FormFieldContext","createContext","useFormField","ctx","useContext","fallbackId","useId","useFormFieldControlId","id","controlId","register","useIsomorphicLayoutEffect","useFormFieldControlRef","ref","_a"],"mappings":";;AA0BO,MAAMA,IAAmBC;AAAA,EAC9B;AACF;AAEO,SAASC,IAAsC;AACpD,QAAMC,IAAMC,EAAWJ,CAAgB,GACjCK,IAAaC,EAAA;AAEnB,SAAIH,KAIG;AAAA,IACL,IAAIE;AAAA,IACJ,QAAQ,GAAGA,CAAU;AAAA,IACrB,SAAS,GAAGA,CAAU;AAAA,IACtB,aAAa;AAAA,IACb,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAEd;AAOO,SAASE,EACdJ,GACAK,GACQ;AACR,QAAMC,IAAYD,KAAML,EAAI,IACtBO,IAAWP,EAAI;AACrB,SAAAQ,EAA0B,MAAMD,KAAA,gBAAAA,EAAWD,IAAY,CAACC,GAAUD,CAAS,CAAC,GACrEA;AACT;AAMO,SAASG,EACdT,GACAU,GACM;AACN,QAAMH,IAAWP,EAAI;AACrB,EAAAQ,EAA0B,MAAM;;AAC9B,UAAMF,KAAYK,IAAAD,EAAI,YAAJ,gBAAAC,EAAa;AAC/B,QAAIJ,KAAYD,EAAW,QAAOC,EAASD,CAAS;AAAA,EACtD,GAAG,CAACC,GAAUG,CAAG,CAAC;AACpB;"}
|
|
@@ -5,7 +5,7 @@ import { useTranslation as ce } from "react-i18next";
|
|
|
5
5
|
import { u as ue } from "./registry-DvAUVLHh.js";
|
|
6
6
|
import { R as d } from "./radio-BBbMdbE_.js";
|
|
7
7
|
import { R as S } from "./radio-group-BT97ty7o.js";
|
|
8
|
-
import { F as k } from "./form-field-
|
|
8
|
+
import { F as k } from "./form-field-Db0liyI8.js";
|
|
9
9
|
import { D as _ } from "./date-picker-BnhBmcH6.js";
|
|
10
10
|
import { S as me } from "./select-DHPmASkG.js";
|
|
11
11
|
import { S as ge } from "./switch-D--x7n6h.js";
|
|
@@ -485,4 +485,4 @@ Re.displayName = "GestationalAgeCalculator";
|
|
|
485
485
|
export {
|
|
486
486
|
Re as G
|
|
487
487
|
};
|
|
488
|
-
//# sourceMappingURL=gestational-age-calculator-
|
|
488
|
+
//# sourceMappingURL=gestational-age-calculator-BVBz_5dm.js.map
|