@orbitcommerce/constellation-docs 1.0.0 → 1.2.1

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 (235) hide show
  1. package/dist/docs.css +14764 -2237
  2. package/dist/index.js +2 -2
  3. package/dist/pages/{Playground-CNbBbErC.js → Playground-Mk1yIWXb.js} +2 -2
  4. package/dist/pages/_address-data-L9BR499w.js +161 -0
  5. package/dist/pages/_builder-demo-C0eJUmPU.js +282 -0
  6. package/dist/pages/_card-art-0be5ncyV.js +18 -0
  7. package/dist/pages/_conversation-samples-Bq7cn-4d.js +70 -0
  8. package/dist/pages/{_figures-data-BDmScEny.js → _figures-data-DaDvB7Nm.js} +5 -5
  9. package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
  10. package/dist/pages/{_overlays-specimens-Dpn6oiyH.js → _overlays-specimens-bawR331Z.js} +33 -23
  11. package/dist/pages/_preview-specimens-DKQC9HAo.js +153 -0
  12. package/dist/pages/accordion-Sg0TUqxB.js +1036 -0
  13. package/dist/pages/address-autocomplete-DP0PUOlK.js +360 -0
  14. package/dist/pages/address-block-BvxQWBTy.js +403 -0
  15. package/dist/pages/address-fields-CwSqro3W.js +277 -0
  16. package/dist/pages/ai-highlight-D3x2vD83.js +642 -0
  17. package/dist/pages/{alert-BD4e6QTh.js → alert-D3i7xZTU.js} +195 -50
  18. package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
  19. package/dist/pages/{app-shell-KbA-nRqZ.js → app-shell-D4hdlHps.js} +133 -54
  20. package/dist/pages/{area-chart-B91dLcGo.js → area-chart-BEWFwiB2.js} +183 -27
  21. package/dist/pages/{avatar-DPPHXJAu.js → avatar-BFEqQViw.js} +194 -12
  22. package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
  23. package/dist/pages/{badge-C9JR0thI.js → badge-0-PyMrih.js} +441 -135
  24. package/dist/pages/bar-chart-DkLogYlt.js +1060 -0
  25. package/dist/pages/bar-fold-B-3XeIDZ.js +360 -0
  26. package/dist/pages/board-card-D2tZY_mU.js +415 -0
  27. package/dist/pages/brand-mark-BqiLvFSR.js +417 -0
  28. package/dist/pages/{button-D3V912P4.js → button-DAyfssDY.js} +276 -79
  29. package/dist/pages/{calendar-DSDZ9nRH.js → calendar-Ds7KsgSI.js} +69 -17
  30. package/dist/pages/canvas-stage-1KiPspkX.js +472 -0
  31. package/dist/pages/card-CXZ3V1d4.js +1612 -0
  32. package/dist/pages/caret-suggestions-oHI6QvqW.js +526 -0
  33. package/dist/pages/chart-legend-B20AbakD.js +724 -0
  34. package/dist/pages/chat-composer-CwzUJYIa.js +437 -0
  35. package/dist/pages/checkbox-BG9Zkb6j.js +1581 -0
  36. package/dist/pages/checklist-card-DEyykVFS.js +783 -0
  37. package/dist/pages/chip-Ck-o3Ui6.js +839 -0
  38. package/dist/pages/chip-list-k1LxXuCi.js +414 -0
  39. package/dist/pages/clamp-text-n-iE8RDR.js +203 -0
  40. package/dist/pages/coachmark-Be2ghobT.js +366 -0
  41. package/dist/pages/code-block-Dv_Y5GYq.js +622 -0
  42. package/dist/pages/collab-field-CfqqK7d2.js +696 -0
  43. package/dist/pages/color-field-CZpfcA-A.js +1127 -0
  44. package/dist/pages/{colour-BwuO8xAv.js → colour-q2ntvI0w.js} +496 -20
  45. package/dist/pages/column-mapper-TsTG39cl.js +502 -0
  46. package/dist/pages/combobox-DvK2j5tI.js +1334 -0
  47. package/dist/pages/{command-palette-xAD7fOg6.js → command-palette-CJ7uBA04.js} +201 -58
  48. package/dist/pages/comment-box-CDSGYhr5.js +346 -0
  49. package/dist/pages/composer-D4B0NgpA.js +689 -0
  50. package/dist/pages/condition-builder-BZy2ZGXe.js +715 -0
  51. package/dist/pages/conflict-chooser-C--_9UIS.js +210 -0
  52. package/dist/pages/context-menu-F9DV30ia.js +487 -0
  53. package/dist/pages/copy-button-Cn7WiKRF.js +568 -0
  54. package/dist/pages/copy-field-D3Xt3Jq6.js +511 -0
  55. package/dist/pages/danger-zone-Db_UUeiP.js +564 -0
  56. package/dist/pages/date-input-GOW067EB.js +956 -0
  57. package/dist/pages/{date-picker-BYSa816m.js → date-picker-GdBciR99.js} +186 -38
  58. package/dist/pages/date-time-BLKCXtVZ.js +678 -0
  59. package/dist/pages/{delta-CtAo0eIM.js → delta-CNAGv8JY.js} +266 -61
  60. package/dist/pages/description-list-BPeXn1eW.js +1268 -0
  61. package/dist/pages/device-switcher-BCaN99c1.js +554 -0
  62. package/dist/pages/dialog-CRpkRC98.js +3164 -0
  63. package/dist/pages/{docs-BNOb7AqR.js → docs-lM2UBSir.js} +20 -15
  64. package/dist/pages/doodle-nzkqi2UI.js +201 -0
  65. package/dist/pages/drag-ghost-B6kpzC3O.js +426 -0
  66. package/dist/pages/drill-menu-cskH5mol.js +490 -0
  67. package/dist/pages/dropzone-DOY_Rhw0.js +1069 -0
  68. package/dist/pages/element-toolbar-DZIhXlCJ.js +498 -0
  69. package/dist/pages/emoji-picker-CqaWaffD.js +235 -0
  70. package/dist/pages/empty-state-4U2txFpI.js +1113 -0
  71. package/dist/pages/facet-filters-McbBeY9e.js +353 -0
  72. package/dist/pages/figure-D-HF5vCj.js +563 -0
  73. package/dist/pages/figure-strip-hg7txTc3.js +1381 -0
  74. package/dist/pages/{figure-tabs-CoPFzzKz.js → figure-tabs-QOeQMY6N.js} +153 -35
  75. package/dist/pages/file-chip-DMDjtlqQ.js +738 -0
  76. package/dist/pages/filter-pill-DzqNOsD4.js +1295 -0
  77. package/dist/pages/font-picker-Bqhu0QMh.js +416 -0
  78. package/dist/pages/form-grid-BfWCVlie.js +692 -0
  79. package/dist/pages/gallery-BBk2EOri.js +453 -0
  80. package/dist/pages/gif-picker-CnoDTCaL.js +270 -0
  81. package/dist/pages/gradient-editor-Bqxp7Fxj.js +378 -0
  82. package/dist/pages/grouped-checklist-gNZ0tBKU.js +477 -0
  83. package/dist/pages/heatmap-BohgIcNk.js +507 -0
  84. package/dist/pages/highlight-text-BfxzfmvS.js +287 -0
  85. package/dist/pages/{home-dashboard-CFQwDtC9.js → home-dashboard-CxPmvduE.js} +21 -18
  86. package/dist/pages/hosted-embed-Jef3aIMP.js +163 -0
  87. package/dist/pages/hosted-field-BLh-53AE.js +208 -0
  88. package/dist/pages/hosted-field-DEpI4lVS.js +514 -0
  89. package/dist/pages/{icon-button-C9eSVPPW.js → icon-button-Bu4Gj5sy.js} +370 -31
  90. package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
  91. package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
  92. package/dist/pages/{icons-sxkTs5Ob.js → icons-CJ9Aar3d.js} +315 -52
  93. package/dist/pages/image-cropper-NyougqLH.js +466 -0
  94. package/dist/pages/image-field-7knBv4mJ.js +567 -0
  95. package/dist/pages/import-result-CmTtGXW_.js +486 -0
  96. package/dist/pages/inline-confirm-CEcI5Lxo.js +327 -0
  97. package/dist/pages/inline-edit-Ba39SzhM.js +1125 -0
  98. package/dist/pages/input-CzLCzfyx.js +2372 -0
  99. package/dist/pages/{installation-DpsX8G_n.js → installation-DRUWNVHP.js} +112 -29
  100. package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
  101. package/dist/pages/kanban-Dy9sPAI0.js +740 -0
  102. package/dist/pages/{kbd-cNfDoikz.js → kbd-UNj4zqxn.js} +15 -14
  103. package/dist/pages/layout-primitives-CPRaZeyt.js +483 -0
  104. package/dist/pages/line-chart-CntWxeMF.js +1117 -0
  105. package/dist/pages/link-CXqvAg9z.js +689 -0
  106. package/dist/pages/link-picker-BMFGCC67.js +478 -0
  107. package/dist/pages/link-row-x8yaUuWc.js +595 -0
  108. package/dist/pages/{live-globe-ClvLn9Lb.js → live-globe-95ROMhGQ.js} +191 -47
  109. package/dist/pages/loading-overlay-BeGuXM9G.js +456 -0
  110. package/dist/pages/loading-state-BNbCo51C.js +556 -0
  111. package/dist/pages/log-viewer-BQz8I_a2.js +503 -0
  112. package/dist/pages/{logo-BfGF1Pq9.js → logo-D3a3QGKJ.js} +13 -13
  113. package/dist/pages/lottie_light-CxEH8eiR.js +9116 -0
  114. package/dist/pages/markdown-Ied72vMT.js +237 -0
  115. package/dist/pages/markdown-field-BfnIEKZH.js +193 -0
  116. package/dist/pages/media-banner-DkStCia0.js +233 -0
  117. package/dist/pages/{menu-by2sgQ09.js → menu-NrLYKqKp.js} +623 -109
  118. package/dist/pages/message-thread-Bo4zbxqu.js +731 -0
  119. package/dist/pages/meta-line-D5p2TycR.js +371 -0
  120. package/dist/pages/model-viewer-BfokvHoc.js +60288 -0
  121. package/dist/pages/model-viewer-C8PFO8wk.js +577 -0
  122. package/dist/pages/month-calendar-T1vw9Rup.js +457 -0
  123. package/dist/pages/{motion-BvTGc2Dk.js → motion-CrXtiBvA.js} +20 -10
  124. package/dist/pages/number-input-CuyMZg18.js +968 -0
  125. package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
  126. package/dist/pages/{orbit-spinner-Dil1Z3Oy.js → orbit-spinner-Dxv5qAhr.js} +30 -14
  127. package/dist/pages/otp-input-CVRoX1mw.js +591 -0
  128. package/dist/pages/{overview-BPEbZQ6g.js → overview-BSfEqHY8.js} +4 -4
  129. package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
  130. package/dist/pages/{pagination-BBUnGvv5.js → pagination-C1EgVtW4.js} +74 -29
  131. package/dist/pages/palette-tile-X9ZXu2Z0.js +414 -0
  132. package/dist/pages/password-field-DHEQKyUC.js +912 -0
  133. package/dist/pages/person-cell-BmjbADBz.js +564 -0
  134. package/dist/pages/phone-input-B3G7Qpb2.js +747 -0
  135. package/dist/pages/plan-card-DRaA6RuB.js +621 -0
  136. package/dist/pages/plan-card-DtloWvMh.js +258 -0
  137. package/dist/pages/plan-comparison-BVIGTtbd.js +559 -0
  138. package/dist/pages/plan-grid-BCPvtP8J.js +251 -0
  139. package/dist/pages/point-list-BbPmZjsm.js +222 -0
  140. package/dist/pages/{popover-Db1gLDpb.js → popover-C3Oar9D5.js} +76 -14
  141. package/dist/pages/presence-avatars-CRZIk8n9.js +328 -0
  142. package/dist/pages/preview-frame-Bcwk0y_Q.js +1631 -0
  143. package/dist/pages/price-CRBLoa9h.js +604 -0
  144. package/dist/pages/{principles-CeAIOIdt.js → principles-pnDyfHpK.js} +9 -9
  145. package/dist/pages/print-page-BkLv6bW8.js +513 -0
  146. package/dist/pages/profile-hero-CC9dUzuN.js +498 -0
  147. package/dist/pages/progress-CP_awmo4.js +904 -0
  148. package/dist/pages/progress-ring-JuOAwk2T.js +576 -0
  149. package/dist/pages/{radio-group-CkdBWWfG.js → radio-group-CbiibLwn.js} +581 -18
  150. package/dist/pages/radius-control-B2kRA2Ch.js +441 -0
  151. package/dist/pages/rating-CweKN2SX.js +471 -0
  152. package/dist/pages/record-layout-DUP_X0RL.js +719 -0
  153. package/dist/pages/record-pager-y9D7JFgb.js +278 -0
  154. package/dist/pages/registry-CNR7zpf7.js +594 -0
  155. package/dist/pages/{release-Dvo684UJ.js → release-DYBCY7jm.js} +4 -1
  156. package/dist/pages/repeater-BRZYKRQa.js +1351 -0
  157. package/dist/pages/reply-feedback-BDnHprla.js +192 -0
  158. package/dist/pages/reveal-BygENBbL.js +460 -0
  159. package/dist/pages/rich-text-DOFQZEpT.js +156 -0
  160. package/dist/pages/rich-text-editor-BhIM20JI.js +1265 -0
  161. package/dist/pages/rolldown-runtime-CbKu08Hx.js +25 -0
  162. package/dist/pages/{rolling-number-qmvH84Mq.js → rolling-number-GR3Cyfpz.js} +12 -12
  163. package/dist/pages/row-list-Dl6CYhC-.js +1565 -0
  164. package/dist/pages/rule-list-DTCmIMpT.js +648 -0
  165. package/dist/pages/save-status-B5KkyMZP.js +378 -0
  166. package/dist/pages/schedule-YycI95O1.js +243 -0
  167. package/dist/pages/scroll-area-B2sGm23Q.js +423 -0
  168. package/dist/pages/{search-field-BN7MWGQ4.js → search-field-D1uG7R6A.js} +15 -15
  169. package/dist/pages/search-menu-DMuXyUUW.js +580 -0
  170. package/dist/pages/secret-field-Dj9x3LL8.js +337 -0
  171. package/dist/pages/section-rail-BtTCETS5.js +637 -0
  172. package/dist/pages/section-v2Pubup9.js +639 -0
  173. package/dist/pages/{segmented-control-CTbIpRBW.js → segmented-control-D-FB1K1T.js} +450 -37
  174. package/dist/pages/{select-DguELoRR.js → select-DZ43NpOm.js} +22 -17
  175. package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
  176. package/dist/pages/{separator-CPZub9pv.js → separator-CFwqRvfO.js} +99 -22
  177. package/dist/pages/serp-preview-BGwORjmo.js +346 -0
  178. package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
  179. package/dist/pages/{shape-DKvA0YKr.js → shape-DzniHAVT.js} +10 -10
  180. package/dist/pages/share-list-D4wgBxKN.js +926 -0
  181. package/dist/pages/side-panel-CCtkrZjs.js +811 -0
  182. package/dist/pages/site-preview-Dj1hM2Yo.js +353 -0
  183. package/dist/pages/skeleton-C1F5HkAu.js +1325 -0
  184. package/dist/pages/skip-link-BxznhSkz.js +252 -0
  185. package/dist/pages/slider-CAoPURKD.js +774 -0
  186. package/dist/pages/sortable-card-Sr44uCpI.js +424 -0
  187. package/dist/pages/sortable-list-DUAleYE1.js +1298 -0
  188. package/dist/pages/sortable-tree-BLzK-hTE.js +737 -0
  189. package/dist/pages/spacing-box-CtuvzxQu.js +550 -0
  190. package/dist/pages/{sparkline-DMMYGbHn.js → sparkline-D3aavCly.js} +301 -22
  191. package/dist/pages/split-bar-DYgZnFID.js +414 -0
  192. package/dist/pages/split-button-Be08-VI-.js +335 -0
  193. package/dist/pages/split-pane-lSNZgTKt.js +523 -0
  194. package/dist/pages/status-badge-DOdNhmzn.js +1074 -0
  195. package/dist/pages/status-checklist-CWkjCZIC.js +1152 -0
  196. package/dist/pages/status-dot-D99gAGsV.js +567 -0
  197. package/dist/pages/stepper-CxKTbEA-.js +1093 -0
  198. package/dist/pages/success-mark-CqFTOBEu.js +142 -0
  199. package/dist/pages/swatch-H_kNvHuC.js +565 -0
  200. package/dist/pages/{switch-B-Qe4kcT.js → switch-C93K6j9h.js} +151 -51
  201. package/dist/pages/table-mq_pNXza.js +3232 -0
  202. package/dist/pages/{tabs-B4M-usCV.js → tabs-Cf4MZ8Fq.js} +257 -21
  203. package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
  204. package/dist/pages/task-card-Dv0sR1-w.js +295 -0
  205. package/dist/pages/{textarea-fTuUZRQb.js → textarea-CCM-SnGN.js} +271 -15
  206. package/dist/pages/thumbnail-DwFJL_k1.js +1147 -0
  207. package/dist/pages/time-input-CA9-uZAa.js +442 -0
  208. package/dist/pages/time-zone-select-CEtMXVYO.js +296 -0
  209. package/dist/pages/timeline-BsMUTlpR.js +1798 -0
  210. package/dist/pages/{toast-CKP03zjy.js → toast-zXLRiMRT.js} +240 -25
  211. package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
  212. package/dist/pages/toolbar-B9l_fHKy.js +754 -0
  213. package/dist/pages/{tooltip-CBYil3kt.js → tooltip-LHtCUkF-.js} +162 -33
  214. package/dist/pages/translation-field-CTRXiF2N.js +251 -0
  215. package/dist/pages/tree-checklist-CJj3OcLg.js +451 -0
  216. package/dist/pages/tree-select-DU1qXHy_.js +492 -0
  217. package/dist/pages/tree-view-g_RjLtAb.js +739 -0
  218. package/dist/pages/{typography-PCbg8Bhg.js → typography-BSijtiRl.js} +153 -12
  219. package/dist/pages/unit-input-Dml4fjmK.js +659 -0
  220. package/dist/pages/upload-rules-yozEzSah.js +419 -0
  221. package/dist/pages/url-upload-input-SSnMgfpA.js +307 -0
  222. package/dist/pages/value-change-CnubDKyO.js +489 -0
  223. package/dist/pages/weekly-hours-i2EpsmTx.js +287 -0
  224. package/dist/pages/widget-preview-CUJMyZ_k.js +625 -0
  225. package/dist/pages/working-status-CENemSsw.js +389 -0
  226. package/manifest.json +10989 -1108
  227. package/package.json +3 -3
  228. package/dist/pages/card-DUggbis3.js +0 -659
  229. package/dist/pages/checkbox-DwimQaK3.js +0 -365
  230. package/dist/pages/dialog-BRAf4LMh.js +0 -1451
  231. package/dist/pages/empty-state-C-mLrXW2.js +0 -417
  232. package/dist/pages/input-KF9Gkawf.js +0 -1093
  233. package/dist/pages/registry-CroHzK9I.js +0 -244
  234. package/dist/pages/skeleton-DLuBhP46.js +0 -561
  235. package/dist/pages/table-AMoODng4.js +0 -607
@@ -0,0 +1,912 @@
1
+ "use client";
2
+ import { t as DocLink } from "./host-B6znjEgQ.js";
3
+ import { a as DocTable, d as Section$1, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
4
+ import { t as Playground } from "./Playground-Mk1yIWXb.js";
5
+ import { useEffect, useRef, useState } from "react";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ import { Button, Field, Link, PasswordField } from "@orbitcommerce/constellation";
8
+ import { CheckCircleIcon } from "@orbitcommerce/constellation/icons";
9
+ //#region src/pages/components/password-field.tsx
10
+ var RULES = [
11
+ {
12
+ id: "length",
13
+ label: "At least 8 characters",
14
+ test: (v) => v.length >= 8
15
+ },
16
+ {
17
+ id: "upper",
18
+ label: "One uppercase letter (A-Z)",
19
+ test: (v) => /[A-Z]/.test(v)
20
+ },
21
+ {
22
+ id: "lower",
23
+ label: "One lowercase letter (a-z)",
24
+ test: (v) => /[a-z]/.test(v)
25
+ },
26
+ {
27
+ id: "digit",
28
+ label: "One number (0-9)",
29
+ test: (v) => /[0-9]/.test(v)
30
+ },
31
+ {
32
+ id: "symbol",
33
+ label: "One special character (!@#$%^&*)",
34
+ test: (v) => /[^a-zA-Z0-9]/.test(v)
35
+ }
36
+ ];
37
+ function Preview() {
38
+ return /* @__PURE__ */ jsx("div", {
39
+ style: { width: 224 },
40
+ children: /* @__PURE__ */ jsx(PasswordField, {
41
+ "aria-label": "Password",
42
+ defaultValue: "Abcdefg1!",
43
+ showStrength: true,
44
+ showRules: false,
45
+ rules: RULES
46
+ })
47
+ });
48
+ }
49
+ var PLAYGROUND = [
50
+ {
51
+ prop: "showStrength",
52
+ type: "boolean",
53
+ default: true,
54
+ toAttr: (v) => v ? "showStrength" : null
55
+ },
56
+ {
57
+ prop: "showRules",
58
+ type: "boolean",
59
+ default: true,
60
+ toAttr: (v) => v ? null : "showRules={false}"
61
+ },
62
+ {
63
+ prop: "flagUnmet",
64
+ type: "boolean",
65
+ default: false
66
+ },
67
+ {
68
+ prop: "size",
69
+ type: "select",
70
+ options: [
71
+ "sm",
72
+ "md",
73
+ "lg"
74
+ ],
75
+ default: "md"
76
+ },
77
+ {
78
+ prop: "disabled",
79
+ type: "boolean",
80
+ default: false
81
+ }
82
+ ];
83
+ function SignIn() {
84
+ return /* @__PURE__ */ jsx("div", {
85
+ className: "pwf-stack",
86
+ children: /* @__PURE__ */ jsx(Field, {
87
+ label: "Password",
88
+ labelAside: /* @__PURE__ */ jsx(Link, {
89
+ href: "#sign-in",
90
+ size: "sm",
91
+ onClick: (event) => event.preventDefault(),
92
+ children: "Forgot password?"
93
+ }),
94
+ children: /* @__PURE__ */ jsx(PasswordField, {
95
+ autoComplete: "current-password",
96
+ placeholder: "Enter your password"
97
+ })
98
+ })
99
+ });
100
+ }
101
+ /** A new password and its confirmation, shown and hidden together from the first field's eye. */
102
+ function NewPasswordPair() {
103
+ const [shown, setShown] = useState(false);
104
+ return /* @__PURE__ */ jsxs("div", {
105
+ className: "pwf-stack",
106
+ children: [/* @__PURE__ */ jsx(Field, {
107
+ label: "New password",
108
+ children: /* @__PURE__ */ jsx(PasswordField, {
109
+ autoComplete: "new-password",
110
+ revealed: shown,
111
+ onRevealedChange: setShown,
112
+ labels: {
113
+ show: "Show both passwords",
114
+ hide: "Hide both passwords"
115
+ }
116
+ })
117
+ }), /* @__PURE__ */ jsx(Field, {
118
+ label: "Confirm password",
119
+ children: /* @__PURE__ */ jsx(PasswordField, {
120
+ autoComplete: "new-password",
121
+ revealed: shown,
122
+ revealToggle: false
123
+ })
124
+ })]
125
+ });
126
+ }
127
+ function ChoosePassword() {
128
+ const [password, setPassword] = useState("");
129
+ const [validation, setValidation] = useState();
130
+ const [flag, setFlag] = useState(false);
131
+ const [done, setDone] = useState(false);
132
+ const field = useRef(null);
133
+ const create = (event) => {
134
+ event.preventDefault();
135
+ if (!validation?.valid) {
136
+ setFlag(true);
137
+ setDone(false);
138
+ field.current?.focus();
139
+ return;
140
+ }
141
+ setDone(true);
142
+ };
143
+ return /* @__PURE__ */ jsxs("form", {
144
+ noValidate: true,
145
+ onSubmit: create,
146
+ className: "pwf-stack",
147
+ children: [/* @__PURE__ */ jsx(Field, {
148
+ label: "New password",
149
+ required: true,
150
+ children: /* @__PURE__ */ jsx(PasswordField, {
151
+ ref: field,
152
+ rules: RULES,
153
+ showStrength: true,
154
+ flagUnmet: flag,
155
+ value: password,
156
+ onChange: (event) => {
157
+ setPassword(event.target.value);
158
+ setDone(false);
159
+ },
160
+ onValidationChange: setValidation
161
+ })
162
+ }), /* @__PURE__ */ jsxs("div", {
163
+ className: "pwf-actions",
164
+ children: [/* @__PURE__ */ jsx("span", {
165
+ role: "status",
166
+ className: "pwf-status",
167
+ children: done ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CheckCircleIcon, {
168
+ weight: "fill",
169
+ "aria-hidden": "true"
170
+ }), "Password set"] }) : null
171
+ }), /* @__PURE__ */ jsx(Button, {
172
+ type: "submit",
173
+ variant: "primary",
174
+ children: "Set password"
175
+ })]
176
+ })]
177
+ });
178
+ }
179
+ /** A field with its eye pressed, to show the revealed look. Docs only: the press happens in the browser, after the first render. */
180
+ function Revealed() {
181
+ const input = useRef(null);
182
+ const pressed = useRef(false);
183
+ useEffect(() => {
184
+ if (pressed.current) return;
185
+ pressed.current = true;
186
+ input.current?.closest(".o-input")?.querySelector("button")?.click();
187
+ }, []);
188
+ return /* @__PURE__ */ jsx(PasswordField, {
189
+ ref: input,
190
+ defaultValue: "Abcdefg1!"
191
+ });
192
+ }
193
+ var COMMON = [
194
+ "welcome1!",
195
+ "password1!",
196
+ "qwerty123!"
197
+ ];
198
+ function TooCommon() {
199
+ const [password, setPassword] = useState("Welcome1!");
200
+ return /* @__PURE__ */ jsx("div", {
201
+ className: "pwf-stack",
202
+ children: /* @__PURE__ */ jsx(Field, {
203
+ label: "New password",
204
+ required: true,
205
+ children: /* @__PURE__ */ jsx(PasswordField, {
206
+ rules: RULES,
207
+ showStrength: true,
208
+ value: password,
209
+ onChange: (event) => setPassword(event.target.value),
210
+ flagUnmet: true,
211
+ extraErrors: COMMON.includes(password.toLowerCase()) ? ["This password is too common. Choose a stronger one"] : []
212
+ })
213
+ })
214
+ });
215
+ }
216
+ var GERMAN = [
217
+ {
218
+ id: "length",
219
+ label: "Mindestens 8 Zeichen",
220
+ test: (v) => v.length >= 8
221
+ },
222
+ {
223
+ id: "upper",
224
+ label: "Ein Grossbuchstabe (A-Z)",
225
+ test: (v) => /[A-Z]/.test(v)
226
+ },
227
+ {
228
+ id: "digit",
229
+ label: "Eine Zahl (0-9)",
230
+ test: (v) => /[0-9]/.test(v)
231
+ }
232
+ ];
233
+ function Page() {
234
+ return /* @__PURE__ */ jsxs(DocPage, {
235
+ title: "Password field",
236
+ status: "new",
237
+ importNames: ["PasswordField"],
238
+ lead: "A password input with an eye to show what was typed. Where someone chooses a password, add a strength meter and the list of rules it has to meet: each ticks off as it is met, and the ones still missing turn red once the field has been left.",
239
+ children: [
240
+ /* @__PURE__ */ jsx(Section$1, {
241
+ id: "playground",
242
+ title: "Playground",
243
+ description: /* @__PURE__ */ jsx("p", { children: "Type a password and watch the meter and the list. Leave the field to see what is missing turn red." }),
244
+ children: /* @__PURE__ */ jsx(Playground, {
245
+ component: "PasswordField",
246
+ controls: PLAYGROUND,
247
+ extraCode: () => ["rules={rules}"],
248
+ render: (v) => /* @__PURE__ */ jsx("div", {
249
+ className: "pwf-stage",
250
+ children: /* @__PURE__ */ jsx(Field, {
251
+ label: "Password",
252
+ required: true,
253
+ children: /* @__PURE__ */ jsx(PasswordField, {
254
+ rules: RULES,
255
+ showStrength: Boolean(v.showStrength),
256
+ showRules: Boolean(v.showRules),
257
+ flagUnmet: Boolean(v.flagUnmet),
258
+ size: v.size,
259
+ disabled: Boolean(v.disabled)
260
+ })
261
+ })
262
+ })
263
+ })
264
+ }),
265
+ /* @__PURE__ */ jsx(Section$1, {
266
+ id: "sign-in",
267
+ title: "Signing in",
268
+ description: /* @__PURE__ */ jsxs("p", { children: [
269
+ "With no rules it is the eye and nothing else: a sign-in field, or a current-password field in a settings form. Press the eye to see what is typed; press it again to hide it. The caret stays where it was and the field keeps the focus, so nothing is \"left\" by pressing it. In a Field, put the link for a forgotten password in ",
270
+ /* @__PURE__ */ jsx("code", { children: "labelAside" }),
271
+ "."
272
+ ] }),
273
+ children: /* @__PURE__ */ jsx(Example, {
274
+ code: `
275
+ <Field label="Password" labelAside={<Link href="/forgot" size="sm">Forgot password?</Link>}>
276
+ <PasswordField autoComplete="current-password" placeholder="Enter your password" />
277
+ </Field>`,
278
+ children: /* @__PURE__ */ jsx(SignIn, {})
279
+ })
280
+ }),
281
+ /* @__PURE__ */ jsxs(Section$1, {
282
+ id: "choosing",
283
+ title: "Choosing a password",
284
+ description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
285
+ "Give it ",
286
+ /* @__PURE__ */ jsx("code", { children: "rules" }),
287
+ " and ",
288
+ /* @__PURE__ */ jsx("code", { children: "showStrength" }),
289
+ ". A rule is an id, a label and a test; the list always shows every one, so nothing moves while someone types. ",
290
+ /* @__PURE__ */ jsx("code", { children: "onValidationChange" }),
291
+ " tells your form the result: whether the password may be used, its score and level, and which rules it misses."
292
+ ] }), /* @__PURE__ */ jsxs("p", { children: [
293
+ "Press Set password with a weak password: ",
294
+ /* @__PURE__ */ jsx("code", { children: "flagUnmet" }),
295
+ " turns the missing rules red at once and the field takes the error look, without waiting for it to be left."
296
+ ] })] }),
297
+ children: [/* @__PURE__ */ jsx(Example, {
298
+ minHeight: 420,
299
+ code: `
300
+ const rules: PasswordRule[] = [
301
+ { id: 'length', label: 'At least 8 characters', test: (v) => v.length >= 8 },
302
+ { id: 'upper', label: 'One uppercase letter (A-Z)', test: (v) => /[A-Z]/.test(v) },
303
+ { id: 'lower', label: 'One lowercase letter (a-z)', test: (v) => /[a-z]/.test(v) },
304
+ { id: 'digit', label: 'One number (0-9)', test: (v) => /[0-9]/.test(v) },
305
+ { id: 'symbol', label: 'One special character (!@#$%^&*)', test: (v) => /[^a-zA-Z0-9]/.test(v) },
306
+ ]
307
+
308
+ const [validation, setValidation] = useState<PasswordValidation>()
309
+ const [flag, setFlag] = useState(false)
310
+
311
+ <form noValidate onSubmit={(event) => { event.preventDefault(); if (!validation?.valid) return setFlag(true); save() }}>
312
+ <Field label="New password" required>
313
+ <PasswordField
314
+ rules={rules}
315
+ showStrength
316
+ flagUnmet={flag}
317
+ value={password}
318
+ onChange={(event) => setPassword(event.target.value)}
319
+ onValidationChange={setValidation}
320
+ />
321
+ </Field>
322
+ <Button type="submit" variant="primary">Set password</Button>
323
+ </form>`,
324
+ children: /* @__PURE__ */ jsx(ChoosePassword, {})
325
+ }), /* @__PURE__ */ jsx(Note, {
326
+ title: "The rules are yours",
327
+ children: "The kit knows how long and varied a password is, not what the platform accepts, so it never decides the rules. Pass the same ones your API enforces, and no more: a form stricter than the server refuses passwords the server would have taken."
328
+ })]
329
+ }),
330
+ /* @__PURE__ */ jsx(Section$1, {
331
+ id: "shared-reveal",
332
+ title: "One eye for a password and its confirmation",
333
+ description: /* @__PURE__ */ jsxs("p", { children: [
334
+ "A reset or a new-password form asks for the password twice. Give both fields the same ",
335
+ /* @__PURE__ */ jsx("code", { children: "revealed" }),
336
+ ", the first an ",
337
+ /* @__PURE__ */ jsx("code", { children: "onRevealedChange" }),
338
+ " and the words for the pair, and the second",
339
+ " ",
340
+ /* @__PURE__ */ jsxs("code", { children: ["revealToggle=", "{false}"] }),
341
+ ": one eye then shows and hides both, and the pair has one control. Without",
342
+ " ",
343
+ /* @__PURE__ */ jsx("code", { children: "revealed" }),
344
+ " each field keeps its own (",
345
+ /* @__PURE__ */ jsx("code", { children: "defaultRevealed" }),
346
+ " starts it shown), and",
347
+ " ",
348
+ /* @__PURE__ */ jsx("code", { children: "onRevealedChange" }),
349
+ " still hears every press."
350
+ ] }),
351
+ children: /* @__PURE__ */ jsx(Example, {
352
+ minHeight: 220,
353
+ code: `
354
+ const [shown, setShown] = useState(false)
355
+
356
+ <Field label="New password">
357
+ <PasswordField
358
+ autoComplete="new-password"
359
+ revealed={shown}
360
+ onRevealedChange={setShown}
361
+ labels={{ show: 'Show both passwords', hide: 'Hide both passwords' }}
362
+ />
363
+ </Field>
364
+ <Field label="Confirm password">
365
+ <PasswordField autoComplete="new-password" revealed={shown} revealToggle={false} />
366
+ </Field>`,
367
+ children: /* @__PURE__ */ jsx(NewPasswordPair, {})
368
+ })
369
+ }),
370
+ /* @__PURE__ */ jsxs(Section$1, {
371
+ id: "rules",
372
+ title: "The rules",
373
+ description: /* @__PURE__ */ jsxs("p", { children: [
374
+ "Every rule is always in the list, in one of three states. A rule waiting is slate with a dot; a rule met is ink with a teal tick; a rule still missing, once the field has been left with something in it (or when you pass",
375
+ " ",
376
+ /* @__PURE__ */ jsx("code", { children: "flagUnmet" }),
377
+ "), is red with a cross. The input and its eye are one field: Tab from the input to the eye is not leaving, and Tab on from the eye is, so the rules turn red for a keyboard as they do for a click away. Leaving the field empty flags nothing, and a press on the eye with the mouse keeps the focus where it was."
378
+ ] }),
379
+ children: [/* @__PURE__ */ jsx(ThemePair, {
380
+ align: "fill",
381
+ children: /* @__PURE__ */ jsxs("div", {
382
+ className: "pwf-states",
383
+ children: [
384
+ /* @__PURE__ */ jsx(Field, {
385
+ label: "Waiting",
386
+ children: /* @__PURE__ */ jsx(PasswordField, { rules: RULES.slice(0, 3) })
387
+ }),
388
+ /* @__PURE__ */ jsx(Field, {
389
+ label: "Some met",
390
+ children: /* @__PURE__ */ jsx(PasswordField, {
391
+ rules: RULES.slice(0, 3),
392
+ defaultValue: "abc"
393
+ })
394
+ }),
395
+ /* @__PURE__ */ jsx(Field, {
396
+ label: "Flagged",
397
+ children: /* @__PURE__ */ jsx(PasswordField, {
398
+ rules: RULES.slice(0, 3),
399
+ defaultValue: "abc",
400
+ flagUnmet: true
401
+ })
402
+ }),
403
+ /* @__PURE__ */ jsx(Field, {
404
+ label: "All met",
405
+ children: /* @__PURE__ */ jsx(PasswordField, {
406
+ rules: RULES.slice(0, 3),
407
+ defaultValue: "Abcdefg1",
408
+ flagUnmet: true
409
+ })
410
+ })
411
+ ]
412
+ })
413
+ }), /* @__PURE__ */ jsx(DocTable, {
414
+ columns: [
415
+ "State",
416
+ "Words",
417
+ "Mark",
418
+ "Read out"
419
+ ],
420
+ rows: [
421
+ [
422
+ "Waiting",
423
+ "Slate",
424
+ "A 4px dot",
425
+ "\"not done yet\""
426
+ ],
427
+ [
428
+ "Met",
429
+ "Ink",
430
+ "A teal tick",
431
+ "\"done\""
432
+ ],
433
+ [
434
+ "Missing, flagged",
435
+ "Red",
436
+ "A red cross",
437
+ "\"not done yet\""
438
+ ]
439
+ ]
440
+ })]
441
+ }),
442
+ /* @__PURE__ */ jsxs(Section$1, {
443
+ id: "strength",
444
+ title: "Strength",
445
+ description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
446
+ /* @__PURE__ */ jsx("p", { children: "The meter appears once something is typed: \"Password strength\" and the word on one row, then a 6px bar that slides to the score. The score is 0 to 100 from the password's length, variety and entropy, less 20 for a common password and 10 each for a run of three (abc, 123) and for a character three times over. It is the estimate the vendor dashboard has always drawn." }),
447
+ /* @__PURE__ */ jsxs("p", { children: [
448
+ "A password that breaks a rule never reads better than \"fair\", so the meter cannot say Good while the list says no. Pass ",
449
+ /* @__PURE__ */ jsx("code", { children: "strength" }),
450
+ " to score with your own code (zxcvbn, say) instead."
451
+ ] }),
452
+ /* @__PURE__ */ jsx("p", { children: "Beside the eye, the bar and the words are drawn for the eye. A screen reader gets them once, in a polite status that also says how many rules are met: \"Password strength Fair. 3 of 5 requirements met\"." })
453
+ ] }),
454
+ children: [/* @__PURE__ */ jsx(ThemePair, {
455
+ align: "fill",
456
+ children: /* @__PURE__ */ jsxs("div", {
457
+ className: "pwf-states",
458
+ children: [
459
+ /* @__PURE__ */ jsx(Field, {
460
+ label: "Weak",
461
+ children: /* @__PURE__ */ jsx(PasswordField, {
462
+ rules: RULES,
463
+ showStrength: true,
464
+ showRules: false,
465
+ defaultValue: "abc"
466
+ })
467
+ }),
468
+ /* @__PURE__ */ jsx(Field, {
469
+ label: "Fair",
470
+ children: /* @__PURE__ */ jsx(PasswordField, {
471
+ rules: RULES,
472
+ showStrength: true,
473
+ showRules: false,
474
+ defaultValue: "Abcdefg1"
475
+ })
476
+ }),
477
+ /* @__PURE__ */ jsx(Field, {
478
+ label: "Good",
479
+ children: /* @__PURE__ */ jsx(PasswordField, {
480
+ showStrength: true,
481
+ defaultValue: "summer2024"
482
+ })
483
+ }),
484
+ /* @__PURE__ */ jsx(Field, {
485
+ label: "Strong",
486
+ children: /* @__PURE__ */ jsx(PasswordField, {
487
+ rules: RULES,
488
+ showStrength: true,
489
+ showRules: false,
490
+ defaultValue: "Abcdefg1!"
491
+ })
492
+ }),
493
+ /* @__PURE__ */ jsx(Field, {
494
+ label: "Very strong",
495
+ children: /* @__PURE__ */ jsx(PasswordField, {
496
+ rules: RULES,
497
+ showStrength: true,
498
+ showRules: false,
499
+ defaultValue: "Xk9#mQ2$vLp4!zT"
500
+ })
501
+ })
502
+ ]
503
+ })
504
+ }), /* @__PURE__ */ jsx(DocTable, {
505
+ columns: [
506
+ "Score",
507
+ "Word",
508
+ "Bar",
509
+ "Word colour"
510
+ ],
511
+ rows: [
512
+ [
513
+ "0 to 19",
514
+ "Weak",
515
+ "Red",
516
+ "Red"
517
+ ],
518
+ [
519
+ "20 to 39",
520
+ "Fair",
521
+ "Orange",
522
+ "Orange, deepened with ink"
523
+ ],
524
+ [
525
+ "40 to 59",
526
+ "Good",
527
+ "Amber",
528
+ "Amber, deepened with ink"
529
+ ],
530
+ [
531
+ "60 to 79",
532
+ "Strong",
533
+ "Orbit teal",
534
+ "Orbit teal"
535
+ ],
536
+ [
537
+ "80 to 100",
538
+ "Very strong",
539
+ "Deeper Orbit teal",
540
+ "Orbit teal"
541
+ ]
542
+ ]
543
+ })]
544
+ }),
545
+ /* @__PURE__ */ jsx(Section$1, {
546
+ id: "extra-errors",
547
+ title: "Errors the rules cannot show",
548
+ description: /* @__PURE__ */ jsxs("p", { children: [
549
+ "Some refusals are not a rule you can list: too long, a password in a breach, one the person used before. Find them in your own code and pass them as ",
550
+ /* @__PURE__ */ jsx("code", { children: "extraErrors" }),
551
+ ". They show under the list once the field has been left or flagged, each as a Field's error line with its mark, they keep the password from being valid, and the meter holds at \"fair\". They land in a polite live region, so pass ",
552
+ /* @__PURE__ */ jsx("code", { children: "[]" }),
553
+ ", not ",
554
+ /* @__PURE__ */ jsx("code", { children: "undefined" }),
555
+ ", while there are none: the region is then in the page before the first one, and a screen reader announces it."
556
+ ] }),
557
+ children: /* @__PURE__ */ jsx(Example, {
558
+ minHeight: 420,
559
+ code: `
560
+ <PasswordField
561
+ rules={rules}
562
+ showStrength
563
+ flagUnmet
564
+ value={password}
565
+ onChange={(event) => setPassword(event.target.value)}
566
+ extraErrors={common.includes(password.toLowerCase()) ? ['This password is too common. Choose a stronger one'] : []}
567
+ />`,
568
+ children: /* @__PURE__ */ jsx(TooCommon, {})
569
+ })
570
+ }),
571
+ /* @__PURE__ */ jsx(Section$1, {
572
+ id: "labels",
573
+ title: "In another language",
574
+ description: /* @__PURE__ */ jsxs("p", { children: [
575
+ "The kit's words are English. Pass ",
576
+ /* @__PURE__ */ jsx("code", { children: "labels" }),
577
+ " for the eye, the meter and the list, a few at a time: anything you leave out stays English. ",
578
+ /* @__PURE__ */ jsx("code", { children: "progress" }),
579
+ " is a function, since a count does not fit every language's word order. The rules' own words are yours already."
580
+ ] }),
581
+ children: /* @__PURE__ */ jsx(Example, {
582
+ code: `
583
+ <PasswordField
584
+ rules={rules}
585
+ showStrength
586
+ labels={{
587
+ show: 'Passwort anzeigen',
588
+ hide: 'Passwort verbergen',
589
+ strength: 'Passwortstärke',
590
+ levels: { weak: 'Schwach', fair: 'Mittel', good: 'Gut', strong: 'Stark', 'very-strong': 'Sehr stark' },
591
+ rules: 'Das Passwort muss enthalten:',
592
+ met: 'erledigt',
593
+ notMet: 'noch nicht erledigt',
594
+ progress: (met, total) => \`\${met} von \${total} erfüllt\`,
595
+ }}
596
+ />`,
597
+ children: /* @__PURE__ */ jsx("div", {
598
+ className: "pwf-stack",
599
+ children: /* @__PURE__ */ jsx(Field, {
600
+ label: "Passwort",
601
+ required: true,
602
+ children: /* @__PURE__ */ jsx(PasswordField, {
603
+ rules: GERMAN,
604
+ showStrength: true,
605
+ defaultValue: "Abcdefg",
606
+ labels: {
607
+ show: "Passwort anzeigen",
608
+ hide: "Passwort verbergen",
609
+ strength: "Passwortstärke",
610
+ levels: {
611
+ weak: "Schwach",
612
+ fair: "Mittel",
613
+ good: "Gut",
614
+ strong: "Stark",
615
+ "very-strong": "Sehr stark"
616
+ },
617
+ rules: "Das Passwort muss enthalten:",
618
+ met: "erledigt",
619
+ notMet: "noch nicht erledigt",
620
+ progress: (met, total) => `${met} von ${total} erfüllt`
621
+ }
622
+ })
623
+ })
624
+ })
625
+ })
626
+ }),
627
+ /* @__PURE__ */ jsxs(Section$1, {
628
+ id: "states",
629
+ title: "States",
630
+ description: /* @__PURE__ */ jsx("p", { children: "Empty, filled, revealed, in error and disabled, in both themes. The field is an Input, so hover firms the hairline, focus turns it teal with a halo, and an error from a Field turns it red. A disabled field turns its eye off with it." }),
631
+ children: [/* @__PURE__ */ jsx(ThemePair, {
632
+ align: "fill",
633
+ children: /* @__PURE__ */ jsxs("div", {
634
+ className: "pwf-states",
635
+ children: [
636
+ /* @__PURE__ */ jsx(Field, {
637
+ label: "Empty",
638
+ children: /* @__PURE__ */ jsx(PasswordField, { placeholder: "Enter your password" })
639
+ }),
640
+ /* @__PURE__ */ jsx(Field, {
641
+ label: "Filled",
642
+ children: /* @__PURE__ */ jsx(PasswordField, { defaultValue: "Abcdefg1!" })
643
+ }),
644
+ /* @__PURE__ */ jsx(Field, {
645
+ label: "Revealed",
646
+ children: /* @__PURE__ */ jsx(Revealed, {})
647
+ }),
648
+ /* @__PURE__ */ jsx(Field, {
649
+ label: "Error",
650
+ error: "That password is not right",
651
+ children: /* @__PURE__ */ jsx(PasswordField, { defaultValue: "Abcdefg1!" })
652
+ }),
653
+ /* @__PURE__ */ jsx(Field, {
654
+ label: "Disabled",
655
+ children: /* @__PURE__ */ jsx(PasswordField, {
656
+ defaultValue: "Abcdefg1!",
657
+ disabled: true
658
+ })
659
+ })
660
+ ]
661
+ })
662
+ }), /* @__PURE__ */ jsx(SubSection, {
663
+ title: "Sizes",
664
+ children: /* @__PURE__ */ jsx(ThemePair, {
665
+ align: "fill",
666
+ children: /* @__PURE__ */ jsxs("div", {
667
+ className: "pwf-states",
668
+ children: [
669
+ /* @__PURE__ */ jsx(Field, {
670
+ label: "Small",
671
+ children: /* @__PURE__ */ jsx(PasswordField, {
672
+ size: "sm",
673
+ defaultValue: "Abcdefg1!"
674
+ })
675
+ }),
676
+ /* @__PURE__ */ jsx(Field, {
677
+ label: "Default",
678
+ children: /* @__PURE__ */ jsx(PasswordField, { defaultValue: "Abcdefg1!" })
679
+ }),
680
+ /* @__PURE__ */ jsx(Field, {
681
+ label: "Large",
682
+ children: /* @__PURE__ */ jsx(PasswordField, {
683
+ size: "lg",
684
+ defaultValue: "Abcdefg1!"
685
+ })
686
+ })
687
+ ]
688
+ })
689
+ })
690
+ })]
691
+ }),
692
+ /* @__PURE__ */ jsxs(Section$1, {
693
+ id: "guidelines",
694
+ title: "Guidelines",
695
+ children: [/* @__PURE__ */ jsx(DoDont, {
696
+ do: {
697
+ children: /* @__PURE__ */ jsx("div", {
698
+ className: "pwf-narrow",
699
+ children: /* @__PURE__ */ jsx(Field, {
700
+ label: "New password",
701
+ required: true,
702
+ children: /* @__PURE__ */ jsx(PasswordField, {
703
+ rules: RULES.slice(0, 3),
704
+ defaultValue: "abc"
705
+ })
706
+ })
707
+ }),
708
+ caption: "List the rules before the person breaks one, and keep every rule in view as it is met."
709
+ },
710
+ dont: {
711
+ children: /* @__PURE__ */ jsx("div", {
712
+ className: "pwf-narrow",
713
+ children: /* @__PURE__ */ jsx(Field, {
714
+ label: "New password",
715
+ required: true,
716
+ error: "Password must be at least 8 characters, with an uppercase letter and a number",
717
+ children: /* @__PURE__ */ jsx(PasswordField, { defaultValue: "abc" })
718
+ })
719
+ }),
720
+ caption: "One sentence of rules appears only after the mistake, and does not say which are already met."
721
+ }
722
+ }), /* @__PURE__ */ jsx(Guidelines, { items: [
723
+ /* @__PURE__ */ jsx(Fragment$1, { children: "Show the eye on every password field, sign-in included. People mistype on phones, and it costs nothing." }),
724
+ /* @__PURE__ */ jsx(Fragment$1, { children: "Ask only for what the server enforces. Do not add a rule here that the API does not have, and do not leave one out that it does." }),
725
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
726
+ "Say what a password manager should do. With rules the field asks it to save a new password (",
727
+ /* @__PURE__ */ jsx("code", { children: "new-password" }),
728
+ "); without, it says nothing, because it cannot tell a sign-in from the old password of a change from a \"confirm\" field. Pass ",
729
+ /* @__PURE__ */ jsx("code", { children: "current-password" }),
730
+ " where a saved password is entered, and ",
731
+ /* @__PURE__ */ jsx("code", { children: "new-password" }),
732
+ " on the confirmation field of a form that chooses one."
733
+ ] }),
734
+ "Flag missing rules when the field is left or the form is sent, never on the first key press.",
735
+ /* @__PURE__ */ jsx(Fragment$1, { children: "Let people paste. A password manager fills both a new and a current password; do not block paste on a confirmation field." })
736
+ ] })]
737
+ }),
738
+ /* @__PURE__ */ jsx(Section$1, {
739
+ id: "accessibility",
740
+ title: "Accessibility",
741
+ children: /* @__PURE__ */ jsx(Guidelines, { items: [
742
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
743
+ "The eye is a real button named \"Show password\" or \"Hide password\" (change them with ",
744
+ /* @__PURE__ */ jsx("code", { children: "labels" }),
745
+ "), reached by Tab like any control. A mouse or touch press does not move focus, so the keyboard stays up on a phone and the caret stays put; the field is never \"left\" by it."
746
+ ] }),
747
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
748
+ "The list describes the field (",
749
+ /* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
750
+ "), so a screen reader is told the rules on arrival. Each rule ends with a hidden \"done\" or \"not done yet\", so the state is not carried by the tick and the colour alone."
751
+ ] }),
752
+ /* @__PURE__ */ jsx(Fragment$1, { children: "One polite status, in the page from the start, tells a screen reader how a password is going: the strength word and how many rules are met (\"Password strength Fair. 3 of 5 requirements met\"). It changes only when the level or the count does, not for every letter typed, and is not announced when it first appears. The drawn meter and its words are hidden from assistive tech so it is not read twice. Without a meter it says the count alone." }),
753
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
754
+ "The list has ",
755
+ /* @__PURE__ */ jsx("code", { children: "role=\"list\"" }),
756
+ ", so Safari still says \"list, 5 items\" with the bullets removed. The errors from ",
757
+ /* @__PURE__ */ jsx("code", { children: "extraErrors" }),
758
+ " land in their own polite status, which is why it is in the page empty."
759
+ ] }),
760
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
761
+ "A flagged field is ",
762
+ /* @__PURE__ */ jsx("code", { children: "aria-invalid" }),
763
+ " only when your form asks for it with ",
764
+ /* @__PURE__ */ jsx("code", { children: "flagUnmet" }),
765
+ " and the password is not valid, as a failed submit is; leaving the field flags the list, not the field."
766
+ ] }),
767
+ "On the canvas, the strength words hold 5.7:1 or more in light and 7.4:1 or more in dark; the bar holds 3.7:1 against the canvas and 3.2:1 against its track in light (Good is the lowest), and 6.5:1 or more in dark.",
768
+ "Under reduced motion the bar jumps to its length without sliding and the ticks fade in rather than pop; colours still change."
769
+ ] })
770
+ }),
771
+ /* @__PURE__ */ jsxs(Section$1, {
772
+ id: "props",
773
+ title: "Props",
774
+ children: [
775
+ /* @__PURE__ */ jsx(PropsTable, { rows: [
776
+ {
777
+ name: "rules",
778
+ type: "PasswordRule[]",
779
+ description: "The rules a new password must meet: { id, label, test(value) }. Leave out for a sign-in field."
780
+ },
781
+ {
782
+ name: "showRules",
783
+ type: "boolean",
784
+ default: "true with rules",
785
+ description: "The list of rules under the field."
786
+ },
787
+ {
788
+ name: "showStrength",
789
+ type: "boolean",
790
+ default: "false",
791
+ description: "The strength meter, once something is typed."
792
+ },
793
+ {
794
+ name: "flagUnmet",
795
+ type: "boolean",
796
+ default: "false",
797
+ description: "Flags the rules still missing now (a pressed Next), and gives the field the error look while the password is not valid."
798
+ },
799
+ {
800
+ name: "extraErrors",
801
+ type: "ReactNode[]",
802
+ description: "Errors the rules cannot show. Under the list as a Field's error lines once the field is left or flagged, in a polite live region (pass [] while there are none); they keep the password from being valid."
803
+ },
804
+ {
805
+ name: "strength",
806
+ type: "(value: string) => number",
807
+ description: "Your own score, 0 to 100, instead of the kit's."
808
+ },
809
+ {
810
+ name: "onValidationChange",
811
+ type: "(validation: PasswordValidation) => void",
812
+ description: "Called when the result changes, and once on mount: { valid, score, level, unmet }."
813
+ },
814
+ {
815
+ name: "labels",
816
+ type: "Partial<PasswordFieldLabels>",
817
+ description: "Words for the eye, the meter, the list and the count of rules met (progress, a function). Anything left out stays English."
818
+ },
819
+ {
820
+ name: "value, defaultValue, onChange",
821
+ type: "as an input",
822
+ description: "Controlled or not, as an Input. The meter and the list follow either."
823
+ },
824
+ {
825
+ name: "revealed",
826
+ type: "boolean",
827
+ description: "Whether what was typed shows (controlled): give two fields the same one for a shared eye."
828
+ },
829
+ {
830
+ name: "defaultRevealed",
831
+ type: "boolean",
832
+ default: "false",
833
+ description: "Whether it starts shown, when the field keeps its own reveal."
834
+ },
835
+ {
836
+ name: "onRevealedChange",
837
+ type: "(revealed: boolean) => void",
838
+ description: "Called with the new state when the eye is pressed, controlled or not."
839
+ },
840
+ {
841
+ name: "revealToggle",
842
+ type: "boolean",
843
+ default: "true",
844
+ description: "Draws the eye. false leaves it out, for a field that follows another's reveal."
845
+ },
846
+ {
847
+ name: "autoComplete",
848
+ type: "string",
849
+ default: "'new-password' with rules, else unset",
850
+ description: "What a password manager should do with the field: current-password to fill a saved one, new-password to save a new one."
851
+ },
852
+ {
853
+ name: "size, invalid, disabled, icon, prefix",
854
+ type: "as Input",
855
+ description: "The field itself is an Input."
856
+ }
857
+ ] }),
858
+ /* @__PURE__ */ jsxs("p", {
859
+ className: "doc-section__description",
860
+ children: [
861
+ "Every other input attribute, and the ",
862
+ /* @__PURE__ */ jsx("code", { children: "ref" }),
863
+ ", go to the ",
864
+ /* @__PURE__ */ jsx("code", { children: "input" }),
865
+ ". ",
866
+ /* @__PURE__ */ jsx("code", { children: "className" }),
867
+ " and",
868
+ " ",
869
+ /* @__PURE__ */ jsx("code", { children: "style" }),
870
+ " go to the wrapper around the field, the meter and the list. A field that keeps its own value follows a form reset (a reset button, or the reset after a form action); a controlled one is put back by its host. A reset fires no ",
871
+ /* @__PURE__ */ jsx("code", { children: "onChange" }),
872
+ ", as for a native input, but a result that changes with it (an emptied field, say) is reported to ",
873
+ /* @__PURE__ */ jsx("code", { children: "onValidationChange" }),
874
+ ". A form that cancels the reset keeps the field as it is, like its other controls."
875
+ ]
876
+ }),
877
+ /* @__PURE__ */ jsx(SubSection, {
878
+ title: "PasswordValidation",
879
+ children: /* @__PURE__ */ jsx(DocTable, {
880
+ columns: ["Field", "Meaning"],
881
+ rows: [
882
+ [/* @__PURE__ */ jsx("code", { children: "valid" }, "1"), "The password is not empty, meets every rule and has no extra error."],
883
+ [/* @__PURE__ */ jsx("code", { children: "score" }, "2"), "0 to 100."],
884
+ [/* @__PURE__ */ jsx("code", { children: "level" }, "3"), "'weak' | 'fair' | 'good' | 'strong' | 'very-strong'"],
885
+ [/* @__PURE__ */ jsx("code", { children: "unmet" }, "4"), "The ids of the rules not met yet."]
886
+ ]
887
+ })
888
+ }),
889
+ /* @__PURE__ */ jsxs("p", {
890
+ className: "doc-section__description",
891
+ children: [
892
+ /* @__PURE__ */ jsx("code", { children: "passwordFieldLabels" }),
893
+ " is the English set, to spread when you change a few:",
894
+ " ",
895
+ /* @__PURE__ */ jsx("code", { children: "labels={{ ...passwordFieldLabels, show: \"Show\" }}" }),
896
+ ". Put the field in a",
897
+ " ",
898
+ /* @__PURE__ */ jsx(DocLink, {
899
+ to: "/components/input#field",
900
+ children: "Field"
901
+ }),
902
+ " for its label, hint and error."
903
+ ]
904
+ })
905
+ ]
906
+ }),
907
+ /* @__PURE__ */ jsx(Fragment$1, {})
908
+ ]
909
+ });
910
+ }
911
+ //#endregion
912
+ export { Page, Preview };