@govuk-react/primitives 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/README.md +100 -25
  2. package/dist/{accordion-element.d.ts → accordion/element.d.ts} +5 -5
  3. package/dist/accordion/element.js +302 -0
  4. package/dist/accordion/element.js.map +1 -0
  5. package/dist/accordion/index.d.ts +70 -0
  6. package/dist/accordion/index.js +140 -0
  7. package/dist/accordion/index.js.map +1 -0
  8. package/dist/auto-focus/element.d.ts +1 -0
  9. package/dist/auto-focus/element.js +75 -0
  10. package/dist/auto-focus/element.js.map +1 -0
  11. package/dist/auto-focus/index.d.ts +15 -0
  12. package/dist/auto-focus/index.js +39 -0
  13. package/dist/auto-focus/index.js.map +1 -0
  14. package/dist/{autocomplete-element.d.ts → autocomplete/element.d.ts} +11 -11
  15. package/dist/autocomplete/element.js +597 -0
  16. package/dist/autocomplete/element.js.map +1 -0
  17. package/dist/{index-D7lMYMUR.d.ts → autocomplete/index.d.ts} +39 -62
  18. package/dist/autocomplete/index.js +100 -0
  19. package/dist/autocomplete/index.js.map +1 -0
  20. package/dist/button/element.d.ts +1 -0
  21. package/dist/button/element.js +59 -0
  22. package/dist/button/element.js.map +1 -0
  23. package/dist/button/index.d.ts +10 -0
  24. package/dist/button/index.js +9 -0
  25. package/dist/button/index.js.map +1 -0
  26. package/dist/character-count/element.d.ts +12 -0
  27. package/dist/character-count/element.js +287 -0
  28. package/dist/character-count/element.js.map +1 -0
  29. package/dist/character-count/index.d.ts +57 -0
  30. package/dist/character-count/index.js +79 -0
  31. package/dist/character-count/index.js.map +1 -0
  32. package/dist/character-count/messages.d.ts +20 -0
  33. package/dist/character-count/messages.js +54 -0
  34. package/dist/character-count/messages.js.map +1 -0
  35. package/dist/choices/element.d.ts +10 -0
  36. package/dist/choices/element.js +177 -0
  37. package/dist/choices/element.js.map +1 -0
  38. package/dist/{index-WuGvkTxu.d.ts → choices/index.d.ts} +30 -44
  39. package/dist/choices/index.js +37 -0
  40. package/dist/choices/index.js.map +1 -0
  41. package/dist/{disclosure-element.d.ts → disclosure/element.d.ts} +5 -5
  42. package/dist/disclosure/element.js +132 -0
  43. package/dist/disclosure/element.js.map +1 -0
  44. package/dist/{index-D4Gzyvfu.d.ts → disclosure/index.d.ts} +43 -56
  45. package/dist/disclosure/index.js +76 -0
  46. package/dist/disclosure/index.js.map +1 -0
  47. package/dist/exit-this-page/element.d.ts +19 -0
  48. package/dist/exit-this-page/element.js +200 -0
  49. package/dist/exit-this-page/element.js.map +1 -0
  50. package/dist/{index-qF0jIQCW.d.ts → exit-this-page/index.d.ts} +44 -68
  51. package/dist/exit-this-page/index.js +54 -0
  52. package/dist/exit-this-page/index.js.map +1 -0
  53. package/dist/file-upload/element.d.ts +28 -0
  54. package/dist/file-upload/element.js +270 -0
  55. package/dist/file-upload/element.js.map +1 -0
  56. package/dist/file-upload/index.d.ts +46 -0
  57. package/dist/file-upload/index.js +65 -0
  58. package/dist/file-upload/index.js.map +1 -0
  59. package/dist/focus-links/element.d.ts +1 -0
  60. package/dist/focus-links/element.js +90 -0
  61. package/dist/focus-links/element.js.map +1 -0
  62. package/dist/{index-BR3MAGF8.d.ts → focus-links/index.d.ts} +24 -35
  63. package/dist/focus-links/index.js +7 -0
  64. package/dist/focus-links/index.js.map +1 -0
  65. package/dist/index.d.ts +13 -17
  66. package/dist/index.js +13 -72
  67. package/dist/index.js.map +1 -1
  68. package/dist/inline/accordion-element.js +1 -1
  69. package/dist/inline/auto-focus-element.js +1 -1
  70. package/dist/inline/autocomplete-element.js +1 -1
  71. package/dist/inline/character-count-element.js +1 -1
  72. package/dist/inline/choices-element.js +1 -1
  73. package/dist/inline/disclosure-element.js +1 -1
  74. package/dist/inline/exit-this-page-element.js +1 -1
  75. package/dist/inline/file-upload-element.js +1 -1
  76. package/dist/inline/focus-links-element.js +1 -1
  77. package/dist/inline/modal-element.js +1 -1
  78. package/dist/inline/password-input-element.js +1 -1
  79. package/dist/inline/tabs-element.js +1 -1
  80. package/dist/inline-script/index.d.ts +26 -0
  81. package/dist/inline-script/index.js +31 -0
  82. package/dist/inline-script/index.js.map +1 -0
  83. package/dist/{modal-element.d.ts → modal/element.d.ts} +2 -4
  84. package/dist/modal/element.js +229 -0
  85. package/dist/modal/element.js.map +1 -0
  86. package/dist/modal/index.d.ts +41 -0
  87. package/dist/modal/index.js +145 -0
  88. package/dist/modal/index.js.map +1 -0
  89. package/dist/password-input/element.d.ts +1 -0
  90. package/dist/password-input/element.js +150 -0
  91. package/dist/password-input/element.js.map +1 -0
  92. package/dist/{index-sEHnx4-M.d.ts → password-input/index.d.ts} +33 -49
  93. package/dist/password-input/index.js +37 -0
  94. package/dist/password-input/index.js.map +1 -0
  95. package/dist/styles.css +11 -0
  96. package/dist/{tabs-element.d.ts → tabs/element.d.ts} +5 -5
  97. package/dist/tabs/element.js +423 -0
  98. package/dist/tabs/element.js.map +1 -0
  99. package/dist/tabs/index.d.ts +74 -0
  100. package/dist/tabs/index.js +142 -0
  101. package/dist/tabs/index.js.map +1 -0
  102. package/dist/utils/change-details.d.ts +11 -0
  103. package/dist/utils/change-details.js +3 -0
  104. package/dist/utils/change-details.js.map +1 -0
  105. package/dist/utils/dom.d.ts +9 -0
  106. package/dist/utils/dom.js +27 -0
  107. package/dist/utils/dom.js.map +1 -0
  108. package/dist/utils/on-property-change.d.ts +7 -0
  109. package/dist/utils/on-property-change.js +19 -0
  110. package/dist/utils/on-property-change.js.map +1 -0
  111. package/dist/utils/set-focus.d.ts +11 -0
  112. package/dist/utils/set-focus.js +38 -0
  113. package/dist/utils/set-focus.js.map +1 -0
  114. package/dist/utils/set-up-when-ready.d.ts +6 -0
  115. package/dist/utils/set-up-when-ready.js +16 -0
  116. package/dist/utils/set-up-when-ready.js.map +1 -0
  117. package/dist/utils/slot.d.ts +15 -0
  118. package/dist/utils/slot.js +62 -0
  119. package/dist/utils/slot.js.map +1 -0
  120. package/dist/utils/translation.d.ts +13 -0
  121. package/dist/utils/translation.js +57 -0
  122. package/dist/utils/translation.js.map +1 -0
  123. package/package.json +17 -4
  124. package/dist/accordion-element.js +0 -9
  125. package/dist/accordion-element.js.map +0 -1
  126. package/dist/accordion.d.ts +0 -2
  127. package/dist/accordion.js +0 -34
  128. package/dist/accordion.js.map +0 -1
  129. package/dist/auto-focus-element.d.ts +0 -3
  130. package/dist/auto-focus-element.js +0 -10
  131. package/dist/auto-focus-element.js.map +0 -1
  132. package/dist/auto-focus.d.ts +0 -2
  133. package/dist/auto-focus.js +0 -15
  134. package/dist/auto-focus.js.map +0 -1
  135. package/dist/autocomplete-element.js +0 -12
  136. package/dist/autocomplete-element.js.map +0 -1
  137. package/dist/autocomplete.d.ts +0 -4
  138. package/dist/autocomplete.js +0 -25
  139. package/dist/autocomplete.js.map +0 -1
  140. package/dist/button-element.d.ts +0 -2
  141. package/dist/button-element.js +0 -3
  142. package/dist/button-element.js.map +0 -1
  143. package/dist/button.d.ts +0 -2
  144. package/dist/button.js +0 -12
  145. package/dist/button.js.map +0 -1
  146. package/dist/character-count-element.d.ts +0 -10
  147. package/dist/character-count-element.js +0 -10
  148. package/dist/character-count-element.js.map +0 -1
  149. package/dist/character-count.d.ts +0 -3
  150. package/dist/character-count.js +0 -26
  151. package/dist/character-count.js.map +0 -1
  152. package/dist/choices-element.d.ts +0 -8
  153. package/dist/choices-element.js +0 -9
  154. package/dist/choices-element.js.map +0 -1
  155. package/dist/choices.d.ts +0 -2
  156. package/dist/choices.js +0 -16
  157. package/dist/choices.js.map +0 -1
  158. package/dist/chunk-2IHAQAYF.js +0 -23
  159. package/dist/chunk-2IHAQAYF.js.map +0 -1
  160. package/dist/chunk-2ZJVSNC2.js +0 -31
  161. package/dist/chunk-2ZJVSNC2.js.map +0 -1
  162. package/dist/chunk-47NMY4SS.js +0 -108
  163. package/dist/chunk-47NMY4SS.js.map +0 -1
  164. package/dist/chunk-4XAR4FFG.js +0 -83
  165. package/dist/chunk-4XAR4FFG.js.map +0 -1
  166. package/dist/chunk-5HWRMQK2.js +0 -91
  167. package/dist/chunk-5HWRMQK2.js.map +0 -1
  168. package/dist/chunk-6ZFU4VYW.js +0 -41
  169. package/dist/chunk-6ZFU4VYW.js.map +0 -1
  170. package/dist/chunk-B2I4J5NL.js +0 -264
  171. package/dist/chunk-B2I4J5NL.js.map +0 -1
  172. package/dist/chunk-DPERPCUH.js +0 -188
  173. package/dist/chunk-DPERPCUH.js.map +0 -1
  174. package/dist/chunk-ECYGKE4D.js +0 -168
  175. package/dist/chunk-ECYGKE4D.js.map +0 -1
  176. package/dist/chunk-ESBMTI25.js +0 -11
  177. package/dist/chunk-ESBMTI25.js.map +0 -1
  178. package/dist/chunk-ET7DCQM7.js +0 -133
  179. package/dist/chunk-ET7DCQM7.js.map +0 -1
  180. package/dist/chunk-F5XFC4QJ.js +0 -177
  181. package/dist/chunk-F5XFC4QJ.js.map +0 -1
  182. package/dist/chunk-GVGBDSDN.js +0 -78
  183. package/dist/chunk-GVGBDSDN.js.map +0 -1
  184. package/dist/chunk-IZQ2C4BC.js +0 -351
  185. package/dist/chunk-IZQ2C4BC.js.map +0 -1
  186. package/dist/chunk-L7E6GN2D.js +0 -87
  187. package/dist/chunk-L7E6GN2D.js.map +0 -1
  188. package/dist/chunk-LWIA644X.js +0 -34
  189. package/dist/chunk-LWIA644X.js.map +0 -1
  190. package/dist/chunk-NX4B3NKM.js +0 -35
  191. package/dist/chunk-NX4B3NKM.js.map +0 -1
  192. package/dist/chunk-PNWPGD7B.js +0 -68
  193. package/dist/chunk-PNWPGD7B.js.map +0 -1
  194. package/dist/chunk-QLQ6O7OW.js +0 -111
  195. package/dist/chunk-QLQ6O7OW.js.map +0 -1
  196. package/dist/chunk-RDUPELOK.js +0 -55
  197. package/dist/chunk-RDUPELOK.js.map +0 -1
  198. package/dist/chunk-RPMHI67T.js +0 -104
  199. package/dist/chunk-RPMHI67T.js.map +0 -1
  200. package/dist/chunk-TE4RUYVK.js +0 -97
  201. package/dist/chunk-TE4RUYVK.js.map +0 -1
  202. package/dist/chunk-TJVBFRIE.js +0 -60
  203. package/dist/chunk-TJVBFRIE.js.map +0 -1
  204. package/dist/chunk-U5OKNKYC.js +0 -510
  205. package/dist/chunk-U5OKNKYC.js.map +0 -1
  206. package/dist/chunk-UXJO4AJP.js +0 -290
  207. package/dist/chunk-UXJO4AJP.js.map +0 -1
  208. package/dist/chunk-VNXXENCU.js +0 -39
  209. package/dist/chunk-VNXXENCU.js.map +0 -1
  210. package/dist/chunk-XGK73UCD.js +0 -62
  211. package/dist/chunk-XGK73UCD.js.map +0 -1
  212. package/dist/chunk-XJYLFTYE.js +0 -157
  213. package/dist/chunk-XJYLFTYE.js.map +0 -1
  214. package/dist/chunk-YCESNTXQ.js +0 -241
  215. package/dist/chunk-YCESNTXQ.js.map +0 -1
  216. package/dist/chunk-ZTJLVNR4.js +0 -62
  217. package/dist/chunk-ZTJLVNR4.js.map +0 -1
  218. package/dist/disclosure-element.js +0 -9
  219. package/dist/disclosure-element.js.map +0 -1
  220. package/dist/disclosure.d.ts +0 -2
  221. package/dist/disclosure.js +0 -16
  222. package/dist/disclosure.js.map +0 -1
  223. package/dist/exit-this-page-element.d.ts +0 -22
  224. package/dist/exit-this-page-element.js +0 -13
  225. package/dist/exit-this-page-element.js.map +0 -1
  226. package/dist/exit-this-page.d.ts +0 -3
  227. package/dist/exit-this-page.js +0 -25
  228. package/dist/exit-this-page.js.map +0 -1
  229. package/dist/file-upload-element.d.ts +0 -27
  230. package/dist/file-upload-element.js +0 -14
  231. package/dist/file-upload-element.js.map +0 -1
  232. package/dist/file-upload.d.ts +0 -3
  233. package/dist/file-upload.js +0 -25
  234. package/dist/file-upload.js.map +0 -1
  235. package/dist/focus-links-element.d.ts +0 -3
  236. package/dist/focus-links-element.js +0 -10
  237. package/dist/focus-links-element.js.map +0 -1
  238. package/dist/focus-links.d.ts +0 -2
  239. package/dist/focus-links.js +0 -12
  240. package/dist/focus-links.js.map +0 -1
  241. package/dist/index--FxJgSOS.d.ts +0 -108
  242. package/dist/index-Bul0NJh_.d.ts +0 -310
  243. package/dist/index-CikOyFud.d.ts +0 -54
  244. package/dist/index-D8N5vxTL.d.ts +0 -90
  245. package/dist/index-DMWpkC_d.d.ts +0 -105
  246. package/dist/index-DN7fGMc3.d.ts +0 -20
  247. package/dist/index-DPXR1Yua.d.ts +0 -69
  248. package/dist/inline-script.d.ts +0 -29
  249. package/dist/inline-script.js +0 -63
  250. package/dist/inline-script.js.map +0 -1
  251. package/dist/modal-element.js +0 -11
  252. package/dist/modal-element.js.map +0 -1
  253. package/dist/modal.d.ts +0 -2
  254. package/dist/modal.js +0 -20
  255. package/dist/modal.js.map +0 -1
  256. package/dist/password-input-element.d.ts +0 -3
  257. package/dist/password-input-element.js +0 -9
  258. package/dist/password-input-element.js.map +0 -1
  259. package/dist/password-input.d.ts +0 -2
  260. package/dist/password-input.js +0 -18
  261. package/dist/password-input.js.map +0 -1
  262. package/dist/tabs-element.js +0 -9
  263. package/dist/tabs-element.js.map +0 -1
  264. package/dist/tabs.d.ts +0 -2
  265. package/dist/tabs.js +0 -28
  266. package/dist/tabs.js.map +0 -1
  267. package/dist/translation-BnpO2mN2.d.ts +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/password-input/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AAEpD,MAAM,QAAQ,GAAG;IACf,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,MAAM;IACnB,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAC7B,oBAAoB,EAAE,0BAA0B;IAChD,qBAAqB,EAAE,yBAAyB;CACjD,CAAC;AAEF,k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CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;QAC3F,CAAC;KACF;IAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["/*\n * <govuk-react-password-input>: a headless, light-DOM custom element that adds a show and hide\n * button to a password field, with or without React.\n *\n * The input's `type` is the state, kept when React sets it again. Without JavaScript the field\n * stays a password field and the button stays hidden. On upgrade the element shows the button, which switches the input between\n * \"password\" and \"text\", updates its own text and label, and announces the change.\n *\n * Markup inside the element:\n * - `[data-password-input]`: an `input` of type \"password\".\n * - `[data-password-trigger]`: a `button` of type \"button\", rendered `hidden`.\n * - `[data-password-status]` (optional): a visually hidden live region for the announcements.\n * Without one, the element adds one after the input.\n *\n * While upgraded it sets `data-upgraded`.\n *\n * Attributes, for the text (English by default):\n * - `show-text`, `hide-text`: the button's text.\n * - `show-label`, `hide-label`: the button's accessible name.\n * - `shown-announcement`, `hidden-announcement`: announced when the password is shown or hidden.\n *\n * As in govuk-frontend, the password is hidden again when its form is submitted, unless by a hidden\n * submit button such as a form library's, and when the page is restored from the back-forward cache.\n */\n\nimport { setText } from '../utils/dom.js';\nimport { setUpWhenReady } from '../utils/set-up-when-ready.js';\n\nexport const tagName = 'govuk-react-password-input';\n\nconst defaults = {\n 'show-text': 'Show',\n 'hide-text': 'Hide',\n 'show-label': 'Show password',\n 'hide-label': 'Hide password',\n 'shown-announcement': 'Your password is visible',\n 'hidden-announcement': 'Your password is hidden',\n};\n\n// The same visually hidden styles as govuk-frontend's, for a live region the element adds itself.\nconst visuallyHidden: Record<string, string> = {\n position: 'absolute',\n width: '1px',\n height: '1px',\n margin: '0',\n padding: '0',\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n 'clip-path': 'inset(50%)',\n border: '0',\n 'white-space': 'nowrap',\n};\n\nif (typeof HTMLElement !== 'undefined' && typeof customElements !== 'undefined') {\n class GovukReactPasswordInput extends HTMLElement {\n private input?: HTMLInputElement;\n\n private toggle?: HTMLButtonElement;\n\n private status?: HTMLElement;\n\n private observer?: MutationObserver;\n\n private visible = false;\n\n // React sets `type` again whenever it updates a controlled input.\n private readonly typeObserver = new MutationObserver(() => {\n const type = this.visible ? 'text' : 'password';\n if (this.input && this.input.type !== type) this.input.type = type;\n });\n\n private readonly onToggle = (event: MouseEvent) => {\n event.preventDefault();\n this.setVisible(!this.visible);\n };\n\n // A hidden submitter isn't the user submitting, but a script, such as Conform validating as the\n // user types.\n private readonly onSubmit = (event: Event) => {\n const submitter = event instanceof SubmitEvent ? event.submitter : null;\n if (event.target === this.input?.form && !(submitter instanceof HTMLElement && submitter.hidden)) {\n this.setVisible(false);\n }\n };\n\n private readonly onPageShow = (event: PageTransitionEvent) => {\n if (event.persisted) this.setVisible(false);\n };\n\n connectedCallback() {\n this.observer = setUpWhenReady(this, () => this.setup());\n }\n\n disconnectedCallback() {\n this.observer?.disconnect();\n this.toggle?.removeEventListener('click', this.onToggle);\n document.removeEventListener('submit', this.onSubmit);\n window.removeEventListener('pageshow', this.onPageShow);\n this.typeObserver.disconnect();\n this.input = undefined;\n this.toggle = undefined;\n }\n\n private text(name: keyof typeof defaults) {\n return this.getAttribute(name) ?? defaults[name];\n }\n\n private own<E extends Element>(selector: string, type: new () => E): E | undefined {\n const element = this.querySelector(selector);\n return element instanceof type && element.closest(tagName) === this ? element : undefined;\n }\n\n private setup() {\n if (this.input) return true;\n const input = this.own('[data-password-input]', HTMLInputElement);\n const toggle = this.own('[data-password-trigger]', HTMLButtonElement);\n if (!input || !toggle) return false;\n this.input = input;\n this.toggle = toggle;\n this.status = this.own('[data-password-status]', HTMLElement);\n if (!this.status) {\n this.status = document.createElement('div');\n this.status.dataset.passwordStatus = '';\n this.status.setAttribute('aria-live', 'polite');\n // Set one by one: a Content Security Policy can block a whole `style` attribute.\n const { style } = this.status;\n Object.entries(visuallyHidden).forEach(([name, value]) => style.setProperty(name, value));\n input.insertAdjacentElement('afterend', this.status);\n }\n this.dataset.upgraded = '';\n toggle.hidden = false;\n toggle.addEventListener('click', this.onToggle);\n document.addEventListener('submit', this.onSubmit);\n window.addEventListener('pageshow', this.onPageShow);\n // Start hidden, with the text set but nothing announced.\n this.visible = false;\n input.type = 'password';\n this.typeObserver.observe(input, { attributes: true, attributeFilter: ['type'] });\n this.label(false);\n return true;\n }\n\n private setVisible(visible: boolean) {\n const { input } = this;\n if (!input || visible === this.visible) return;\n this.visible = visible;\n input.type = visible ? 'text' : 'password';\n this.label(visible);\n if (this.status) this.status.textContent = this.text(visible ? 'shown-announcement' : 'hidden-announcement');\n }\n\n private label(visible: boolean) {\n if (!this.toggle) return;\n setText(this.toggle, this.text(visible ? 'hide-text' : 'show-text'));\n this.toggle.setAttribute('aria-label', this.text(visible ? 'hide-label' : 'show-label'));\n }\n }\n\n if (!customElements.get(tagName)) customElements.define(tagName, GovukReactPasswordInput);\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
- import { ComponentProps } from 'react';
3
-
4
- type RootProps = React.HTMLAttributes<HTMLElement> & {
2
+ import type { ComponentProps } from 'react';
3
+ export type RootProps = React.HTMLAttributes<HTMLElement> & {
5
4
  /** The button's text when the password is hidden. Defaults to "Show". */
6
5
  showText?: string;
7
6
  /** The button's text when the password is visible. Defaults to "Hide". */
@@ -15,7 +14,8 @@ type RootProps = React.HTMLAttributes<HTMLElement> & {
15
14
  /** Announced when the password is hidden. Defaults to "Your password is hidden". */
16
15
  hiddenAnnouncement?: string;
17
16
  };
18
- declare function Root({ showText, hideText, showLabel, hideLabel, shownAnnouncement, hiddenAnnouncement, ...props }: RootProps): React.DOMElement<{
17
+ export declare function Root({ showText, hideText, showLabel, hideLabel, shownAnnouncement, hiddenAnnouncement, ...props }: RootProps): React.DOMElement<{
18
+ suppressHydrationWarning: boolean;
19
19
  'show-text': string;
20
20
  'hide-text': string;
21
21
  'show-label': string;
@@ -25,22 +25,21 @@ declare function Root({ showText, hideText, showLabel, hideLabel, shownAnnouncem
25
25
  defaultChecked?: boolean;
26
26
  defaultValue?: string | number | readonly string[];
27
27
  suppressContentEditableWarning?: boolean;
28
- suppressHydrationWarning?: boolean;
29
28
  accessKey?: string;
30
29
  autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {});
31
30
  autoFocus?: boolean;
32
31
  className?: string;
33
- contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only";
32
+ contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only";
34
33
  contextMenu?: string;
35
34
  dir?: string;
36
- draggable?: boolean | "true" | "false";
35
+ draggable?: boolean | "false" | "true";
37
36
  enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send";
38
37
  hidden?: boolean;
39
38
  id?: string;
40
39
  lang?: string;
41
40
  nonce?: string;
42
41
  slot?: string;
43
- spellCheck?: boolean | "true" | "false";
42
+ spellCheck?: boolean | "false" | "true";
44
43
  style?: React.CSSProperties;
45
44
  tabIndex?: number;
46
45
  title?: string;
@@ -73,57 +72,57 @@ declare function Root({ showText, hideText, showLabel, hideLabel, shownAnnouncem
73
72
  popoverTargetAction?: "toggle" | "show" | "hide";
74
73
  popoverTarget?: string;
75
74
  inert?: boolean;
76
- inputMode?: "search" | "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal";
75
+ inputMode?: "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal";
77
76
  is?: string;
78
77
  exportparts?: string;
79
78
  part?: string;
80
79
  "aria-activedescendant"?: string;
81
- "aria-atomic"?: boolean | "true" | "false";
80
+ "aria-atomic"?: boolean | "false" | "true";
82
81
  "aria-autocomplete"?: "none" | "list" | "inline" | "both";
83
82
  "aria-braillelabel"?: string;
84
83
  "aria-brailleroledescription"?: string;
85
- "aria-busy"?: boolean | "true" | "false";
86
- "aria-checked"?: boolean | "true" | "false" | "mixed";
84
+ "aria-busy"?: boolean | "false" | "true";
85
+ "aria-checked"?: boolean | "false" | "true" | "mixed";
87
86
  "aria-colcount"?: number;
88
87
  "aria-colindex"?: number;
89
88
  "aria-colindextext"?: string;
90
89
  "aria-colspan"?: number;
91
90
  "aria-controls"?: string;
92
- "aria-current"?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date";
91
+ "aria-current"?: boolean | "time" | "false" | "true" | "page" | "step" | "location" | "date";
93
92
  "aria-describedby"?: string;
94
93
  "aria-description"?: string;
95
94
  "aria-details"?: string;
96
- "aria-disabled"?: boolean | "true" | "false";
97
- "aria-dropeffect"?: "link" | "none" | "copy" | "execute" | "move" | "popup";
95
+ "aria-disabled"?: boolean | "false" | "true";
96
+ "aria-dropeffect"?: "link" | "copy" | "none" | "execute" | "move" | "popup";
98
97
  "aria-errormessage"?: string;
99
- "aria-expanded"?: boolean | "true" | "false";
98
+ "aria-expanded"?: boolean | "false" | "true";
100
99
  "aria-flowto"?: string;
101
- "aria-grabbed"?: boolean | "true" | "false";
102
- "aria-haspopup"?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree";
103
- "aria-hidden"?: boolean | "true" | "false";
104
- "aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling";
100
+ "aria-grabbed"?: boolean | "false" | "true";
101
+ "aria-haspopup"?: boolean | "dialog" | "menu" | "false" | "true" | "grid" | "listbox" | "tree";
102
+ "aria-hidden"?: boolean | "false" | "true";
103
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling";
105
104
  "aria-keyshortcuts"?: string;
106
105
  "aria-label"?: string;
107
106
  "aria-labelledby"?: string;
108
107
  "aria-level"?: number;
109
108
  "aria-live"?: "off" | "assertive" | "polite";
110
- "aria-modal"?: boolean | "true" | "false";
111
- "aria-multiline"?: boolean | "true" | "false";
112
- "aria-multiselectable"?: boolean | "true" | "false";
109
+ "aria-modal"?: boolean | "false" | "true";
110
+ "aria-multiline"?: boolean | "false" | "true";
111
+ "aria-multiselectable"?: boolean | "false" | "true";
113
112
  "aria-orientation"?: "horizontal" | "vertical";
114
113
  "aria-owns"?: string;
115
114
  "aria-placeholder"?: string;
116
115
  "aria-posinset"?: number;
117
- "aria-pressed"?: boolean | "true" | "false" | "mixed";
118
- "aria-readonly"?: boolean | "true" | "false";
116
+ "aria-pressed"?: boolean | "false" | "true" | "mixed";
117
+ "aria-readonly"?: boolean | "false" | "true";
119
118
  "aria-relevant"?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
120
- "aria-required"?: boolean | "true" | "false";
119
+ "aria-required"?: boolean | "false" | "true";
121
120
  "aria-roledescription"?: string;
122
121
  "aria-rowcount"?: number;
123
122
  "aria-rowindex"?: number;
124
123
  "aria-rowindextext"?: string;
125
124
  "aria-rowspan"?: number;
126
- "aria-selected"?: boolean | "true" | "false";
125
+ "aria-selected"?: boolean | "false" | "true";
127
126
  "aria-setsize"?: number;
128
127
  "aria-sort"?: "none" | "ascending" | "descending" | "other";
129
128
  "aria-valuemax"?: number;
@@ -307,28 +306,13 @@ type PartProps<E extends keyof React.JSX.IntrinsicElements> = ComponentProps<E>
307
306
  /** Render the only child instead, with this part's props merged onto it. */
308
307
  asChild?: boolean;
309
308
  };
310
- type InputProps = PartProps<'input'>;
309
+ export type InputProps = PartProps<'input'>;
311
310
  /** The password field. Its `type` starts as "password" and the element switches it. */
312
- declare function Input({ asChild, ...props }: InputProps): React.JSX.Element;
313
- type ToggleProps = PartProps<'button'>;
311
+ export declare function Input({ asChild, ...props }: InputProps): React.JSX.Element;
312
+ export type TriggerProps = PartProps<'button'>;
314
313
  /** The show and hide button. Hidden until the element upgrades, which then sets its text and label. */
315
- declare function Toggle({ asChild, children, ...props }: ToggleProps): React.JSX.Element;
316
- type StatusProps = PartProps<'div'>;
314
+ export declare function Trigger({ asChild, children, ...props }: TriggerProps): React.JSX.Element;
315
+ export type StatusProps = PartProps<'div'>;
317
316
  /** A live region for the announcements. Make it visually hidden. */
318
- declare function Status({ asChild, ...props }: StatusProps): React.JSX.Element;
319
-
320
- declare const index_Input: typeof Input;
321
- type index_InputProps = InputProps;
322
- declare const index_Root: typeof Root;
323
- type index_RootProps = RootProps;
324
- declare const index_Status: typeof Status;
325
- type index_StatusProps = StatusProps;
326
- declare const index_Toggle: typeof Toggle;
327
- type index_ToggleProps = ToggleProps;
328
- declare namespace index {
329
- export { index_Input as Input, index_Root as Root, index_Status as Status, index_Toggle as Toggle };
330
- export type { index_InputProps as InputProps, index_RootProps as RootProps, index_StatusProps as StatusProps, index_ToggleProps as ToggleProps };
331
- }
332
-
333
- export { Input as I, Root as R, Status as S, Toggle as T, index as i };
334
- export type { InputProps as a, RootProps as b, StatusProps as c, ToggleProps as d };
317
+ export declare function Status({ asChild, ...props }: StatusProps): React.JSX.Element;
318
+ export {};
@@ -0,0 +1,37 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+ import { Slot } from '../utils/slot.js';
4
+ import { tagName } from './element.js';
5
+ export function Root({ showText, hideText, showLabel, hideLabel, shownAnnouncement, hiddenAnnouncement, ...props }) {
6
+ return React.createElement(tagName, {
7
+ ...props,
8
+ // The element owns `data-upgraded`.
9
+ suppressHydrationWarning: true,
10
+ 'show-text': showText,
11
+ 'hide-text': hideText,
12
+ 'show-label': showLabel,
13
+ 'hide-label': hideLabel,
14
+ 'shown-announcement': shownAnnouncement,
15
+ 'hidden-announcement': hiddenAnnouncement,
16
+ });
17
+ }
18
+ /** The password field. Its `type` starts as "password" and the element switches it. */
19
+ export function Input({ asChild, ...props }) {
20
+ if (asChild)
21
+ return React.createElement(Slot, { "data-password-input": "", suppressHydrationWarning: true, ...props });
22
+ // The element sets `type` after upgrade, so it can differ from the server's.
23
+ return React.createElement("input", { type: "password", "data-password-input": "", suppressHydrationWarning: true, ...props });
24
+ }
25
+ /** The show and hide button. Hidden until the element upgrades, which then sets its text and label. */
26
+ export function Trigger({ asChild, children = 'Show', ...props }) {
27
+ const shared = { 'data-password-trigger': '', hidden: true, suppressHydrationWarning: true };
28
+ if (asChild)
29
+ return (React.createElement(Slot, { ...shared, ...props }, children));
30
+ return (React.createElement("button", { type: "button", "aria-label": "Show password", ...shared, ...props }, children));
31
+ }
32
+ /** A live region for the announcements. Make it visually hidden. */
33
+ export function Status({ asChild, ...props }) {
34
+ const Element = asChild ? Slot : 'div';
35
+ return React.createElement(Element, { "data-password-status": "", "aria-live": "polite", suppressHydrationWarning: true, ...props });
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/password-input/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAyBvC,MAAM,UAAU,IAAI,CAAC,EACnB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,GAAG,KAAK,EACE;IACV,OAAO,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE;QAClC,GAAG,KAAK;QACR,oCAAoC;QACpC,wBAAwB,EAAE,IAAI;QAC9B,WAAW,EAAE,QAAQ;QACrB,WAAW,EAAE,QAAQ;QACrB,YAAY,EAAE,SAAS;QACvB,YAAY,EAAE,SAAS;QACvB,oBAAoB,EAAE,iBAAiB;QACvC,qBAAqB,EAAE,kBAAkB;KAC1C,CAAC,CAAC;AACL,CAAC;AASD,uFAAuF;AACvF,MAAM,UAAU,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAc;IACrD,IAAI,OAAO;QAAE,OAAO,oBAAC,IAAI,2BAAqB,EAAE,EAAC,wBAAwB,WAAK,KAAK,GAAI,CAAC;IACxF,6EAA6E;IAC7E,OAAO,+BAAO,IAAI,EAAC,UAAU,yBAAqB,EAAE,EAAC,wBAAwB,WAAK,KAAK,GAAI,CAAC;AAC9F,CAAC;AAID,uGAAuG;AACvG,MAAM,UAAU,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,KAAK,EAAgB;IAC5E,MAAM,MAAM,GAAG,EAAE,uBAAuB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,CAAC;IAC7F,IAAI,OAAO;QACT,OAAO,CACL,oBAAC,IAAI,OAAK,MAAM,KAAM,KAAK,IACxB,QAAQ,CACJ,CACR,CAAC;IACJ,OAAO,CACL,gCAAQ,IAAI,EAAC,QAAQ,gBAAY,eAAe,KAAK,MAAM,KAAM,KAAK,IACnE,QAAQ,CACF,CACV,CAAC;AACJ,CAAC;AAID,oEAAoE;AACpE,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAe;IACvD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACvC,OAAO,oBAAC,OAAO,4BAAsB,EAAE,eAAW,QAAQ,EAAC,wBAAwB,WAAK,KAAK,GAAI,CAAC;AACpG,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { ComponentProps } from 'react';\nimport { Slot } from '../utils/slot.js';\nimport { tagName } from './element.js';\n\n/*\n * Headless password input: unstyled parts over the <govuk-react-password-input> element\n * (./element.ts), which adds the show and hide button on upgrade. Every part except Root takes\n * `asChild`.\n *\n * The input's `type` is the state, owned by the element, so there is no React state to control.\n */\n\nexport type RootProps = React.HTMLAttributes<HTMLElement> & {\n /** The button's text when the password is hidden. Defaults to \"Show\". */\n showText?: string;\n /** The button's text when the password is visible. Defaults to \"Hide\". */\n hideText?: string;\n /** The button's accessible name when the password is hidden. Defaults to \"Show password\". */\n showLabel?: string;\n /** The button's accessible name when the password is visible. Defaults to \"Hide password\". */\n hideLabel?: string;\n /** Announced when the password becomes visible. Defaults to \"Your password is visible\". */\n shownAnnouncement?: string;\n /** Announced when the password is hidden. Defaults to \"Your password is hidden\". */\n hiddenAnnouncement?: string;\n};\n\nexport function Root({\n showText,\n hideText,\n showLabel,\n hideLabel,\n shownAnnouncement,\n hiddenAnnouncement,\n ...props\n}: RootProps) {\n return React.createElement(tagName, {\n ...props,\n // The element owns `data-upgraded`.\n suppressHydrationWarning: true,\n 'show-text': showText,\n 'hide-text': hideText,\n 'show-label': showLabel,\n 'hide-label': hideLabel,\n 'shown-announcement': shownAnnouncement,\n 'hidden-announcement': hiddenAnnouncement,\n });\n}\n\ntype PartProps<E extends keyof React.JSX.IntrinsicElements> = ComponentProps<E> & {\n /** Render the only child instead, with this part's props merged onto it. */\n asChild?: boolean;\n};\n\nexport type InputProps = PartProps<'input'>;\n\n/** The password field. Its `type` starts as \"password\" and the element switches it. */\nexport function Input({ asChild, ...props }: InputProps) {\n if (asChild) return <Slot data-password-input=\"\" suppressHydrationWarning {...props} />;\n // The element sets `type` after upgrade, so it can differ from the server's.\n return <input type=\"password\" data-password-input=\"\" suppressHydrationWarning {...props} />;\n}\n\nexport type TriggerProps = PartProps<'button'>;\n\n/** The show and hide button. Hidden until the element upgrades, which then sets its text and label. */\nexport function Trigger({ asChild, children = 'Show', ...props }: TriggerProps) {\n const shared = { 'data-password-trigger': '', hidden: true, suppressHydrationWarning: true };\n if (asChild)\n return (\n <Slot {...shared} {...props}>\n {children}\n </Slot>\n );\n return (\n <button type=\"button\" aria-label=\"Show password\" {...shared} {...props}>\n {children}\n </button>\n );\n}\n\nexport type StatusProps = PartProps<'div'>;\n\n/** A live region for the announcements. Make it visually hidden. */\nexport function Status({ asChild, ...props }: StatusProps) {\n const Element = asChild ? Slot : 'div';\n return <Element data-password-status=\"\" aria-live=\"polite\" suppressHydrationWarning {...props} />;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /* Rules the primitives' fallbacks need. They set no look, only `display`. */
2
+
3
+ /* Tabs: the radios fallback shows only the checked tab's panel, until the element upgrades. */
4
+ govuk-react-tabs:not([data-upgraded]) [data-tabs-content]:has(> input[data-tabs-fallback]):not(:has(> input:checked)) {
5
+ display: none;
6
+ }
7
+
8
+ /* Accordion: `hidden` wins over a display set on a fallback heading, trigger or controls. */
9
+ govuk-react-accordion :is([data-accordion-fallback], [data-accordion-trigger], [data-accordion-controls])[hidden] {
10
+ display: none !important;
11
+ }
@@ -1,12 +1,15 @@
1
1
  declare global {
2
+ interface HTMLElementTagNameMap {
3
+ 'govuk-react-tabs': TabsElement;
4
+ }
2
5
  interface HTMLElementEventMap {
3
6
  'govuk-react-tabs:change': CustomEvent<{
4
7
  value: string;
5
8
  }>;
6
9
  }
7
10
  }
8
- declare const tagName = "govuk-react-tabs";
9
- interface TabsElement extends HTMLElement {
11
+ export declare const tagName = "govuk-react-tabs";
12
+ export interface TabsElement extends HTMLElement {
10
13
  /** The selected tab's value, once upgraded. */
11
14
  readonly selectedValue: string | undefined;
12
15
  /**
@@ -17,6 +20,3 @@ interface TabsElement extends HTMLElement {
17
20
  /** Select a tab without reporting a change, such as to apply a controlled value. */
18
21
  select(value: string): void;
19
22
  }
20
-
21
- export { tagName };
22
- export type { TabsElement };