@govuk-react/primitives 0.0.0-stage → 0.2.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 (174) hide show
  1. package/README.md +271 -2
  2. package/dist/accordion-element.d.ts +17 -0
  3. package/dist/accordion-element.js +9 -0
  4. package/dist/accordion-element.js.map +1 -0
  5. package/dist/accordion.d.ts +2 -0
  6. package/dist/accordion.js +34 -0
  7. package/dist/accordion.js.map +1 -0
  8. package/dist/auto-focus-element.d.ts +3 -0
  9. package/dist/auto-focus-element.js +10 -0
  10. package/dist/auto-focus-element.js.map +1 -0
  11. package/dist/auto-focus.d.ts +2 -0
  12. package/dist/auto-focus.js +15 -0
  13. package/dist/auto-focus.js.map +1 -0
  14. package/dist/autocomplete-element.d.ts +30 -0
  15. package/dist/autocomplete-element.js +12 -0
  16. package/dist/autocomplete-element.js.map +1 -0
  17. package/dist/autocomplete.d.ts +4 -0
  18. package/dist/autocomplete.js +25 -0
  19. package/dist/autocomplete.js.map +1 -0
  20. package/dist/button-element.d.ts +2 -0
  21. package/dist/button-element.js +3 -0
  22. package/dist/button-element.js.map +1 -0
  23. package/dist/button.d.ts +2 -0
  24. package/dist/button.js +12 -0
  25. package/dist/button.js.map +1 -0
  26. package/dist/character-count-element.d.ts +10 -0
  27. package/dist/character-count-element.js +10 -0
  28. package/dist/character-count-element.js.map +1 -0
  29. package/dist/character-count.d.ts +3 -0
  30. package/dist/character-count.js +26 -0
  31. package/dist/character-count.js.map +1 -0
  32. package/dist/choices-element.d.ts +8 -0
  33. package/dist/choices-element.js +9 -0
  34. package/dist/choices-element.js.map +1 -0
  35. package/dist/choices.d.ts +2 -0
  36. package/dist/choices.js +16 -0
  37. package/dist/choices.js.map +1 -0
  38. package/dist/chunk-2IHAQAYF.js +23 -0
  39. package/dist/chunk-2IHAQAYF.js.map +1 -0
  40. package/dist/chunk-2ZJVSNC2.js +31 -0
  41. package/dist/chunk-2ZJVSNC2.js.map +1 -0
  42. package/dist/chunk-47NMY4SS.js +108 -0
  43. package/dist/chunk-47NMY4SS.js.map +1 -0
  44. package/dist/chunk-4XAR4FFG.js +83 -0
  45. package/dist/chunk-4XAR4FFG.js.map +1 -0
  46. package/dist/chunk-5HWRMQK2.js +91 -0
  47. package/dist/chunk-5HWRMQK2.js.map +1 -0
  48. package/dist/chunk-6ZFU4VYW.js +41 -0
  49. package/dist/chunk-6ZFU4VYW.js.map +1 -0
  50. package/dist/chunk-B2I4J5NL.js +264 -0
  51. package/dist/chunk-B2I4J5NL.js.map +1 -0
  52. package/dist/chunk-DPERPCUH.js +188 -0
  53. package/dist/chunk-DPERPCUH.js.map +1 -0
  54. package/dist/chunk-ECYGKE4D.js +168 -0
  55. package/dist/chunk-ECYGKE4D.js.map +1 -0
  56. package/dist/chunk-ESBMTI25.js +11 -0
  57. package/dist/chunk-ESBMTI25.js.map +1 -0
  58. package/dist/chunk-ET7DCQM7.js +133 -0
  59. package/dist/chunk-ET7DCQM7.js.map +1 -0
  60. package/dist/chunk-F5XFC4QJ.js +177 -0
  61. package/dist/chunk-F5XFC4QJ.js.map +1 -0
  62. package/dist/chunk-GVGBDSDN.js +78 -0
  63. package/dist/chunk-GVGBDSDN.js.map +1 -0
  64. package/dist/chunk-IZQ2C4BC.js +351 -0
  65. package/dist/chunk-IZQ2C4BC.js.map +1 -0
  66. package/dist/chunk-L7E6GN2D.js +87 -0
  67. package/dist/chunk-L7E6GN2D.js.map +1 -0
  68. package/dist/chunk-LWIA644X.js +34 -0
  69. package/dist/chunk-LWIA644X.js.map +1 -0
  70. package/dist/chunk-NX4B3NKM.js +35 -0
  71. package/dist/chunk-NX4B3NKM.js.map +1 -0
  72. package/dist/chunk-PNWPGD7B.js +68 -0
  73. package/dist/chunk-PNWPGD7B.js.map +1 -0
  74. package/dist/chunk-QLQ6O7OW.js +111 -0
  75. package/dist/chunk-QLQ6O7OW.js.map +1 -0
  76. package/dist/chunk-RDUPELOK.js +55 -0
  77. package/dist/chunk-RDUPELOK.js.map +1 -0
  78. package/dist/chunk-RPMHI67T.js +104 -0
  79. package/dist/chunk-RPMHI67T.js.map +1 -0
  80. package/dist/chunk-TE4RUYVK.js +97 -0
  81. package/dist/chunk-TE4RUYVK.js.map +1 -0
  82. package/dist/chunk-TJVBFRIE.js +60 -0
  83. package/dist/chunk-TJVBFRIE.js.map +1 -0
  84. package/dist/chunk-U5OKNKYC.js +510 -0
  85. package/dist/chunk-U5OKNKYC.js.map +1 -0
  86. package/dist/chunk-UXJO4AJP.js +290 -0
  87. package/dist/chunk-UXJO4AJP.js.map +1 -0
  88. package/dist/chunk-VNXXENCU.js +39 -0
  89. package/dist/chunk-VNXXENCU.js.map +1 -0
  90. package/dist/chunk-XGK73UCD.js +62 -0
  91. package/dist/chunk-XGK73UCD.js.map +1 -0
  92. package/dist/chunk-XJYLFTYE.js +157 -0
  93. package/dist/chunk-XJYLFTYE.js.map +1 -0
  94. package/dist/chunk-YCESNTXQ.js +241 -0
  95. package/dist/chunk-YCESNTXQ.js.map +1 -0
  96. package/dist/chunk-ZTJLVNR4.js +62 -0
  97. package/dist/chunk-ZTJLVNR4.js.map +1 -0
  98. package/dist/disclosure-element.d.ts +17 -0
  99. package/dist/disclosure-element.js +9 -0
  100. package/dist/disclosure-element.js.map +1 -0
  101. package/dist/disclosure.d.ts +2 -0
  102. package/dist/disclosure.js +16 -0
  103. package/dist/disclosure.js.map +1 -0
  104. package/dist/exit-this-page-element.d.ts +22 -0
  105. package/dist/exit-this-page-element.js +13 -0
  106. package/dist/exit-this-page-element.js.map +1 -0
  107. package/dist/exit-this-page.d.ts +3 -0
  108. package/dist/exit-this-page.js +25 -0
  109. package/dist/exit-this-page.js.map +1 -0
  110. package/dist/file-upload-element.d.ts +27 -0
  111. package/dist/file-upload-element.js +14 -0
  112. package/dist/file-upload-element.js.map +1 -0
  113. package/dist/file-upload.d.ts +3 -0
  114. package/dist/file-upload.js +25 -0
  115. package/dist/file-upload.js.map +1 -0
  116. package/dist/focus-links-element.d.ts +3 -0
  117. package/dist/focus-links-element.js +10 -0
  118. package/dist/focus-links-element.js.map +1 -0
  119. package/dist/focus-links.d.ts +2 -0
  120. package/dist/focus-links.js +12 -0
  121. package/dist/focus-links.js.map +1 -0
  122. package/dist/index--FxJgSOS.d.ts +108 -0
  123. package/dist/index-BR3MAGF8.d.ts +299 -0
  124. package/dist/index-Bul0NJh_.d.ts +310 -0
  125. package/dist/index-CikOyFud.d.ts +54 -0
  126. package/dist/index-D4Gzyvfu.d.ts +321 -0
  127. package/dist/index-D7lMYMUR.d.ts +373 -0
  128. package/dist/index-D8N5vxTL.d.ts +90 -0
  129. package/dist/index-DMWpkC_d.d.ts +105 -0
  130. package/dist/index-DN7fGMc3.d.ts +20 -0
  131. package/dist/index-DPXR1Yua.d.ts +69 -0
  132. package/dist/index-WuGvkTxu.d.ts +323 -0
  133. package/dist/index-qF0jIQCW.d.ts +354 -0
  134. package/dist/index-sEHnx4-M.d.ts +334 -0
  135. package/dist/index.d.ts +17 -0
  136. package/dist/index.js +73 -0
  137. package/dist/index.js.map +1 -0
  138. package/dist/inline/accordion-element.js +1 -0
  139. package/dist/inline/auto-focus-element.js +1 -0
  140. package/dist/inline/autocomplete-element.js +2 -0
  141. package/dist/inline/button-element.js +1 -0
  142. package/dist/inline/character-count-element.js +1 -0
  143. package/dist/inline/choices-element.js +1 -0
  144. package/dist/inline/disclosure-element.js +1 -0
  145. package/dist/inline/exit-this-page-element.js +1 -0
  146. package/dist/inline/file-upload-element.js +1 -0
  147. package/dist/inline/focus-links-element.js +1 -0
  148. package/dist/inline/modal-element.js +1 -0
  149. package/dist/inline/password-input-element.js +1 -0
  150. package/dist/inline/tabs-element.js +1 -0
  151. package/dist/inline-script.d.ts +29 -0
  152. package/dist/inline-script.js +63 -0
  153. package/dist/inline-script.js.map +1 -0
  154. package/dist/modal-element.d.ts +12 -0
  155. package/dist/modal-element.js +11 -0
  156. package/dist/modal-element.js.map +1 -0
  157. package/dist/modal.d.ts +2 -0
  158. package/dist/modal.js +20 -0
  159. package/dist/modal.js.map +1 -0
  160. package/dist/password-input-element.d.ts +3 -0
  161. package/dist/password-input-element.js +9 -0
  162. package/dist/password-input-element.js.map +1 -0
  163. package/dist/password-input.d.ts +2 -0
  164. package/dist/password-input.js +18 -0
  165. package/dist/password-input.js.map +1 -0
  166. package/dist/tabs-element.d.ts +22 -0
  167. package/dist/tabs-element.js +9 -0
  168. package/dist/tabs-element.js.map +1 -0
  169. package/dist/tabs.d.ts +2 -0
  170. package/dist/tabs.js +28 -0
  171. package/dist/tabs.js.map +1 -0
  172. package/dist/translation-BnpO2mN2.d.ts +4 -0
  173. package/licences/accessible-autocomplete.txt +20 -0
  174. package/package.json +42 -4
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/focus-links/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { tagName } from './element';\n\n/*\n * Headless focus links: the <govuk-react-focus-links> element (./element.ts) makes links to a part\n * of the same page, inside it, move focus there. Links to a form field also scroll its label or\n * legend into view.\n */\n\nexport type RootProps = React.HTMLAttributes<HTMLElement> & {\n /** Classes for a target that isn't a form field while it has focus. */\n focusedClass?: string;\n};\n\nexport function Root({ focusedClass, ...props }: RootProps) {\n return React.createElement(tagName, { ...props, 'focused-class': focusedClass });\n}\n"],"mappings":";;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAEA,YAAY,WAAW;AAchB,SAAS,KAAK,EAAE,cAAc,GAAG,MAAM,GAAc;AAC1D,SAAa,oBAAc,SAAS,EAAE,GAAG,OAAO,iBAAiB,aAAa,CAAC;AACjF;","names":[]}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import {
3
+ Slot
4
+ } from "./chunk-NX4B3NKM.js";
5
+ import {
6
+ __export
7
+ } from "./chunk-ESBMTI25.js";
8
+
9
+ // src/button/index.tsx
10
+ var button_exports = {};
11
+ __export(button_exports, {
12
+ Root: () => Root
13
+ });
14
+ import * as React from "react";
15
+ function Root({ asChild, preventDoubleClick, ...props }) {
16
+ const Element = asChild ? Slot : "button";
17
+ return /* @__PURE__ */ React.createElement(
18
+ Element,
19
+ {
20
+ "data-button": "",
21
+ "data-prevent-double-click": preventDoubleClick === void 0 ? void 0 : String(preventDoubleClick),
22
+ ...props
23
+ }
24
+ );
25
+ }
26
+
27
+ export {
28
+ Root,
29
+ button_exports
30
+ };
31
+ //# sourceMappingURL=chunk-2ZJVSNC2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/button/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { ComponentProps } from 'react';\nimport { Slot } from '../utils/slot';\nimport './element';\n\n/*\n * Headless button behaviour (./element.ts): `Root` marks a button or link button for it. Prevents\n * double clicks with `preventDoubleClick`, and makes Space activate a link with `role=\"button\"`.\n */\n\nexport type RootProps = ComponentProps<'button'> & {\n /** Render the only child instead, such as a link with `role=\"button\"`, with this part's props merged onto it. */\n asChild?: boolean;\n /** Cancel a second click within a second of the first, so a form isn't submitted twice. */\n preventDoubleClick?: boolean;\n};\n\nexport function Root({ asChild, preventDoubleClick, ...props }: RootProps) {\n const Element = asChild ? Slot : 'button';\n return (\n <Element\n data-button=\"\"\n data-prevent-double-click={preventDoubleClick === undefined ? undefined : String(preventDoubleClick)}\n {...props}\n />\n );\n}\n"],"mappings":";;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAEA,YAAY,WAAW;AAiBhB,SAAS,KAAK,EAAE,SAAS,oBAAoB,GAAG,MAAM,GAAc;AACzE,QAAM,UAAU,UAAU,OAAO;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,6BAA2B,uBAAuB,SAAY,SAAY,OAAO,kBAAkB;AAAA,MAClG,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
@@ -0,0 +1,108 @@
1
+ 'use client';
2
+ import {
3
+ tagName
4
+ } from "./chunk-L7E6GN2D.js";
5
+ import {
6
+ Slot
7
+ } from "./chunk-NX4B3NKM.js";
8
+ import {
9
+ __export
10
+ } from "./chunk-ESBMTI25.js";
11
+
12
+ // src/modal/index.tsx
13
+ var modal_exports = {};
14
+ __export(modal_exports, {
15
+ Close: () => Close,
16
+ Content: () => Content,
17
+ Root: () => Root,
18
+ Title: () => Title,
19
+ Trigger: () => Trigger
20
+ });
21
+ import * as React from "react";
22
+ import { createContext, useContext, useEffect, useId, useRef } from "react";
23
+ var ModalContext = createContext({});
24
+ function Root({ children, open, onOpenChange, dialogId: dialogIdProp, ...props }) {
25
+ const generatedId = useId();
26
+ const dialogId = dialogIdProp != null ? dialogIdProp : generatedId;
27
+ return /* @__PURE__ */ React.createElement(ModalContext.Provider, { value: { dialogId, titleId: `${dialogId}-title`, onOpenChange } }, React.createElement(
28
+ tagName,
29
+ {
30
+ ...props,
31
+ open: open === void 0 ? void 0 : String(open),
32
+ suppressHydrationWarning: true
33
+ },
34
+ children
35
+ ));
36
+ }
37
+ function Command({ command, asChild, dialogId, ...props }) {
38
+ const context = useContext(ModalContext);
39
+ const invoker = { command, commandfor: dialogId != null ? dialogId : context.dialogId };
40
+ if (asChild) return /* @__PURE__ */ React.createElement(Slot, { ...invoker, ...props });
41
+ return /* @__PURE__ */ React.createElement("button", { type: "button", ...invoker, ...props });
42
+ }
43
+ function Trigger(props) {
44
+ return /* @__PURE__ */ React.createElement(Command, { command: "show-modal", ...props });
45
+ }
46
+ function Close(props) {
47
+ return /* @__PURE__ */ React.createElement(Command, { command: "close", ...props });
48
+ }
49
+ function Content({ asChild, id, onClose, ref, ...props }) {
50
+ const context = useContext(ModalContext);
51
+ const reported = useRef(void 0);
52
+ const onOpenChange = useRef(context.onOpenChange);
53
+ useEffect(() => {
54
+ onOpenChange.current = context.onOpenChange;
55
+ });
56
+ const report = (dialog) => {
57
+ var _a;
58
+ if (reported.current === dialog.open) return;
59
+ reported.current = dialog.open;
60
+ (_a = onOpenChange.current) == null ? void 0 : _a.call(onOpenChange, dialog.open);
61
+ };
62
+ const dialogRef = useRef(null);
63
+ useEffect(() => {
64
+ var _a;
65
+ const dialog = dialogRef.current;
66
+ if ((dialog == null ? void 0 : dialog.open) && reported.current === void 0) {
67
+ reported.current = true;
68
+ (_a = onOpenChange.current) == null ? void 0 : _a.call(onOpenChange, true);
69
+ }
70
+ }, []);
71
+ const listen = (dialog) => {
72
+ dialogRef.current = dialog;
73
+ if (typeof ref === "function") ref(dialog);
74
+ else if (ref) ref.current = dialog;
75
+ if (!dialog) return void 0;
76
+ const onToggle = () => report(dialog);
77
+ dialog.addEventListener("toggle", onToggle);
78
+ return () => dialog.removeEventListener("toggle", onToggle);
79
+ };
80
+ const shared = {
81
+ id: id != null ? id : context.dialogId,
82
+ "aria-labelledby": props["aria-label"] ? void 0 : context.titleId,
83
+ ref: listen,
84
+ onClose: (event) => {
85
+ onClose == null ? void 0 : onClose(event);
86
+ report(event.currentTarget);
87
+ },
88
+ // The dialog's open state belongs to the browser.
89
+ suppressHydrationWarning: true
90
+ };
91
+ if (asChild) return /* @__PURE__ */ React.createElement(Slot, { ...shared, ...props });
92
+ return /* @__PURE__ */ React.createElement("dialog", { ...shared, ...props });
93
+ }
94
+ function Title({ asChild, ...props }) {
95
+ const context = useContext(ModalContext);
96
+ const Element = asChild ? Slot : "h2";
97
+ return /* @__PURE__ */ React.createElement(Element, { id: context.titleId, ...props });
98
+ }
99
+
100
+ export {
101
+ Root,
102
+ Trigger,
103
+ Close,
104
+ Content,
105
+ Title,
106
+ modal_exports
107
+ };
108
+ //# sourceMappingURL=chunk-47NMY4SS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/modal/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createContext, useContext, useEffect, useId, useRef } from 'react';\nimport type { ComponentProps, ReactNode, SyntheticEvent } from 'react';\nimport { Slot } from '../utils/slot';\nimport { tagName } from './element';\n\n/*\n * Headless modal dialog: unstyled parts over a native `dialog` and the <govuk-react-modal>\n * element (./element.ts). Every part except Root takes `asChild`.\n *\n * Trigger and Close are buttons with invoker commands (`command` and `commandfor`), so where\n * the browser supports them the dialog opens as a true modal with no JavaScript: the page behind\n * is inert, focus moves into the dialog, and Escape closes it. The element runs the commands in\n * browsers without them, and applies `open` when controlled.\n *\n * Context only fills in ids: in an island without a Root, pass `dialogId` to Trigger and Close,\n * and `id` to Content.\n */\n\nconst ModalContext = createContext<{\n dialogId?: string;\n titleId?: string;\n onOpenChange?: (open: boolean) => void;\n}>({});\n\nexport type RootProps = Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {\n children?: ReactNode;\n /** Whether the dialog is open, to control it. Without it, the buttons alone open and close it. */\n open?: boolean;\n /** Called when the dialog opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /** The dialog's id, which the buttons' `commandfor` names. Defaults to a generated one. */\n dialogId?: string;\n};\n\nexport function Root({ children, open, onOpenChange, dialogId: dialogIdProp, ...props }: RootProps) {\n const generatedId = useId();\n const dialogId = dialogIdProp ?? generatedId;\n return (\n <ModalContext.Provider value={{ dialogId, titleId: `${dialogId}-title`, onOpenChange }}>\n {React.createElement(\n tagName,\n {\n ...props,\n open: open === undefined ? undefined : String(open),\n suppressHydrationWarning: true,\n },\n children\n )}\n </ModalContext.Provider>\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\ntype CommandProps = PartProps<'button'> & {\n /** The dialog's id. Set by Root. */\n dialogId?: string;\n};\n\nfunction Command({ command, asChild, dialogId, ...props }: CommandProps & { command: string }) {\n const context = useContext(ModalContext);\n // `command` and `commandfor` aren't in React's types yet, so they go in as a spread.\n const invoker = { command, commandfor: dialogId ?? context.dialogId };\n if (asChild) return <Slot {...invoker} {...props} />;\n return <button type=\"button\" {...invoker} {...props} />;\n}\n\nexport type TriggerProps = CommandProps;\n\n/** A button that opens the dialog as a modal. */\nexport function Trigger(props: TriggerProps) {\n return <Command command=\"show-modal\" {...props} />;\n}\n\nexport type CloseProps = CommandProps;\n\n/** A button that closes the dialog. */\nexport function Close(props: CloseProps) {\n return <Command command=\"close\" {...props} />;\n}\n\nexport type ContentProps = PartProps<'dialog'>;\n\n/**\n * The dialog. It's named by Title, unless you pass `aria-labelledby` or `aria-label`. Pass\n * `closedby=\"any\"` to also close it when the user clicks outside it.\n */\nexport function Content({ asChild, id, onClose, ref, ...props }: ContentProps) {\n const context = useContext(ModalContext);\n const reported = useRef<boolean | undefined>(undefined);\n const onOpenChange = useRef(context.onOpenChange);\n useEffect(() => {\n onOpenChange.current = context.onOpenChange;\n });\n // Report each change once: `toggle` fires on opening and closing where the browser fires it on\n // dialogs, and `close` on closing everywhere.\n const report = (dialog: HTMLDialogElement) => {\n if (reported.current === dialog.open) return;\n reported.current = dialog.open;\n onOpenChange.current?.(dialog.open);\n };\n // A dialog the user opened before hydration, through its invoker command or the element, fired\n // nothing React heard, so report it once.\n const dialogRef = useRef<HTMLDialogElement | null>(null);\n useEffect(() => {\n const dialog = dialogRef.current;\n if (dialog?.open && reported.current === undefined) {\n reported.current = true;\n onOpenChange.current?.(true);\n }\n }, []);\n // React doesn't listen for `toggle` on a dialog, so listen natively.\n const listen = (dialog: HTMLDialogElement | null) => {\n dialogRef.current = dialog;\n if (typeof ref === 'function') ref(dialog);\n else if (ref) ref.current = dialog;\n if (!dialog) return undefined;\n const onToggle = () => report(dialog);\n dialog.addEventListener('toggle', onToggle);\n return () => dialog.removeEventListener('toggle', onToggle);\n };\n const shared = {\n id: id ?? context.dialogId,\n 'aria-labelledby': props['aria-label'] ? undefined : context.titleId,\n ref: listen,\n onClose: (event: SyntheticEvent<HTMLDialogElement>) => {\n onClose?.(event);\n report(event.currentTarget);\n },\n // The dialog's open state belongs to the browser.\n suppressHydrationWarning: true,\n };\n if (asChild) return <Slot {...shared} {...props} />;\n return <dialog {...shared} {...props} />;\n}\n\nexport type TitleProps = PartProps<'h2'>;\n\n/** The dialog's heading, which names it. */\nexport function Title({ asChild, ...props }: TitleProps) {\n const context = useContext(ModalContext);\n const Element = asChild ? Slot : 'h2';\n return <Element id={context.titleId} {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAY,WAAW;AACvB,SAAS,eAAe,YAAY,WAAW,OAAO,cAAc;AAkBpE,IAAM,eAAe,cAIlB,CAAC,CAAC;AAYE,SAAS,KAAK,EAAE,UAAU,MAAM,cAAc,UAAU,cAAc,GAAG,MAAM,GAAc;AAClG,QAAM,cAAc,MAAM;AAC1B,QAAM,WAAW,sCAAgB;AACjC,SACE,oCAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,UAAU,SAAS,GAAG,QAAQ,UAAU,aAAa,KAC5E;AAAA,IACL;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,MAAM,SAAS,SAAY,SAAY,OAAO,IAAI;AAAA,MAClD,0BAA0B;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,CACF;AAEJ;AAYA,SAAS,QAAQ,EAAE,SAAS,SAAS,UAAU,GAAG,MAAM,GAAuC;AAC7F,QAAM,UAAU,WAAW,YAAY;AAEvC,QAAM,UAAU,EAAE,SAAS,YAAY,8BAAY,QAAQ,SAAS;AACpE,MAAI,QAAS,QAAO,oCAAC,QAAM,GAAG,SAAU,GAAG,OAAO;AAClD,SAAO,oCAAC,YAAO,MAAK,UAAU,GAAG,SAAU,GAAG,OAAO;AACvD;AAKO,SAAS,QAAQ,OAAqB;AAC3C,SAAO,oCAAC,WAAQ,SAAQ,cAAc,GAAG,OAAO;AAClD;AAKO,SAAS,MAAM,OAAmB;AACvC,SAAO,oCAAC,WAAQ,SAAQ,SAAS,GAAG,OAAO;AAC7C;AAQO,SAAS,QAAQ,EAAE,SAAS,IAAI,SAAS,KAAK,GAAG,MAAM,GAAiB;AAC7E,QAAM,UAAU,WAAW,YAAY;AACvC,QAAM,WAAW,OAA4B,MAAS;AACtD,QAAM,eAAe,OAAO,QAAQ,YAAY;AAChD,YAAU,MAAM;AACd,iBAAa,UAAU,QAAQ;AAAA,EACjC,CAAC;AAGD,QAAM,SAAS,CAAC,WAA8B;AAtGhD;AAuGI,QAAI,SAAS,YAAY,OAAO,KAAM;AACtC,aAAS,UAAU,OAAO;AAC1B,uBAAa,YAAb,sCAAuB,OAAO;AAAA,EAChC;AAGA,QAAM,YAAY,OAAiC,IAAI;AACvD,YAAU,MAAM;AA9GlB;AA+GI,UAAM,SAAS,UAAU;AACzB,SAAI,iCAAQ,SAAQ,SAAS,YAAY,QAAW;AAClD,eAAS,UAAU;AACnB,yBAAa,YAAb,sCAAuB;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,SAAS,CAAC,WAAqC;AACnD,cAAU,UAAU;AACpB,QAAI,OAAO,QAAQ,WAAY,KAAI,MAAM;AAAA,aAChC,IAAK,KAAI,UAAU;AAC5B,QAAI,CAAC,OAAQ,QAAO;AACpB,UAAM,WAAW,MAAM,OAAO,MAAM;AACpC,WAAO,iBAAiB,UAAU,QAAQ;AAC1C,WAAO,MAAM,OAAO,oBAAoB,UAAU,QAAQ;AAAA,EAC5D;AACA,QAAM,SAAS;AAAA,IACb,IAAI,kBAAM,QAAQ;AAAA,IAClB,mBAAmB,MAAM,YAAY,IAAI,SAAY,QAAQ;AAAA,IAC7D,KAAK;AAAA,IACL,SAAS,CAAC,UAA6C;AACrD,yCAAU;AACV,aAAO,MAAM,aAAa;AAAA,IAC5B;AAAA;AAAA,IAEA,0BAA0B;AAAA,EAC5B;AACA,MAAI,QAAS,QAAO,oCAAC,QAAM,GAAG,QAAS,GAAG,OAAO;AACjD,SAAO,oCAAC,YAAQ,GAAG,QAAS,GAAG,OAAO;AACxC;AAKO,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,GAAe;AACvD,QAAM,UAAU,WAAW,YAAY;AACvC,QAAM,UAAU,UAAU,OAAO;AACjC,SAAO,oCAAC,WAAQ,IAAI,QAAQ,SAAU,GAAG,OAAO;AAClD;","names":[]}
@@ -0,0 +1,83 @@
1
+ 'use client';
2
+ import {
3
+ defaultMessages,
4
+ tagName
5
+ } from "./chunk-ECYGKE4D.js";
6
+ import {
7
+ Slot
8
+ } from "./chunk-NX4B3NKM.js";
9
+ import {
10
+ __export
11
+ } from "./chunk-ESBMTI25.js";
12
+
13
+ // src/exit-this-page/index.tsx
14
+ var exit_this_page_exports = {};
15
+ __export(exit_this_page_exports, {
16
+ Button: () => Button,
17
+ Indicator: () => Indicator,
18
+ Light: () => Light,
19
+ Root: () => Root,
20
+ SkipLink: () => SkipLink,
21
+ Status: () => Status,
22
+ defaultMessages: () => defaultMessages
23
+ });
24
+ import * as React from "react";
25
+ function Root({
26
+ activatedText,
27
+ timedOutText,
28
+ pressTwoMoreTimesText,
29
+ pressOneMoreTimeText,
30
+ indicatorVisibleClass,
31
+ lightOnClass,
32
+ hideContentClass,
33
+ overlayClass,
34
+ ...props
35
+ }) {
36
+ return React.createElement(tagName, {
37
+ ...props,
38
+ activated: activatedText,
39
+ "timed-out": timedOutText,
40
+ "press-two-more-times": pressTwoMoreTimesText,
41
+ "press-one-more-time": pressOneMoreTimeText,
42
+ "indicator-visible-class": indicatorVisibleClass,
43
+ "light-on-class": lightOnClass,
44
+ "hide-content-class": hideContentClass,
45
+ "overlay-class": overlayClass,
46
+ // The element owns `data-upgraded`.
47
+ suppressHydrationWarning: true
48
+ });
49
+ }
50
+ function Button({ asChild, ...props }) {
51
+ const Element = asChild ? Slot : "a";
52
+ return /* @__PURE__ */ React.createElement(Element, { "data-exit-this-page-button": "", ...props });
53
+ }
54
+ function SkipLink({ asChild, ...props }) {
55
+ const Element = asChild ? Slot : "a";
56
+ return /* @__PURE__ */ React.createElement(Element, { "data-exit-this-page-skiplink": "", ...props });
57
+ }
58
+ function Indicator({ asChild, children, ...props }) {
59
+ const Element = asChild ? Slot : "div";
60
+ return (
61
+ // The element owns `data-visible` and its classes.
62
+ /* @__PURE__ */ React.createElement(Element, { "data-exit-this-page-indicator": "", "aria-hidden": "true", suppressHydrationWarning: true, ...props }, children != null ? children : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Light, null), /* @__PURE__ */ React.createElement(Light, null), /* @__PURE__ */ React.createElement(Light, null)))
63
+ );
64
+ }
65
+ function Light({ asChild, ...props }) {
66
+ const Element = asChild ? Slot : "div";
67
+ return /* @__PURE__ */ React.createElement(Element, { "data-exit-this-page-light": "", suppressHydrationWarning: true, ...props });
68
+ }
69
+ function Status({ asChild, children, ...props }) {
70
+ const Element = asChild ? Slot : "span";
71
+ return /* @__PURE__ */ React.createElement(Element, { "data-exit-this-page-status": "", role: "status", suppressHydrationWarning: true, ...props }, children != null ? children : "");
72
+ }
73
+
74
+ export {
75
+ Root,
76
+ Button,
77
+ SkipLink,
78
+ Indicator,
79
+ Light,
80
+ Status,
81
+ exit_this_page_exports
82
+ };
83
+ //# sourceMappingURL=chunk-4XAR4FFG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/exit-this-page/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { ComponentProps } from 'react';\nimport { Slot } from '../utils/slot';\nimport { tagName } from './element';\n\nexport { defaultMessages, type ExitThisPageElement, type MessageName } from './element';\n\n/*\n * Headless exit this page: unstyled parts over the <govuk-react-exit-this-page> element\n * (./element.ts). The button, a SkipLink, or pressing Shift 3 times hides the page and goes to\n * the button's `href`. Every part except Root takes `asChild`.\n *\n * Without JavaScript the button is a plain link. To stay on the page, such as in a test, listen for\n * `govuk-react-exit-this-page:exit` and cancel it.\n */\n\nexport type RootProps = React.HTMLAttributes<HTMLElement> & {\n /** Announced once activated. Defaults to \"Loading.\". */\n activatedText?: string;\n /** Announced when the Shift presses time out. Defaults to \"Exit this page expired.\". */\n timedOutText?: string;\n /** Announced after one press of Shift. Defaults to \"Shift, press 2 more times to exit.\". */\n pressTwoMoreTimesText?: string;\n /** Announced after two presses of Shift. Defaults to \"Shift, press 1 more time to exit.\". */\n pressOneMoreTimeText?: string;\n /** Classes for the indicator while counting presses. */\n indicatorVisibleClass?: string;\n /** Classes for each light of the indicator once pressed. */\n lightOnClass?: string;\n /** Classes for `body` that hide the page behind the overlay. */\n hideContentClass?: string;\n /** Classes for the overlay. Without them, inline styles cover the page. */\n overlayClass?: string;\n};\n\nexport function Root({\n activatedText,\n timedOutText,\n pressTwoMoreTimesText,\n pressOneMoreTimeText,\n indicatorVisibleClass,\n lightOnClass,\n hideContentClass,\n overlayClass,\n ...props\n}: RootProps) {\n return React.createElement(tagName, {\n ...props,\n activated: activatedText,\n 'timed-out': timedOutText,\n 'press-two-more-times': pressTwoMoreTimesText,\n 'press-one-more-time': pressOneMoreTimeText,\n 'indicator-visible-class': indicatorVisibleClass,\n 'light-on-class': lightOnClass,\n 'hide-content-class': hideContentClass,\n 'overlay-class': overlayClass,\n // The element owns `data-upgraded`.\n suppressHydrationWarning: true,\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 ButtonProps = PartProps<'a'>;\n\n/** The link to a safe page, which the element follows once it has hidden the page. */\nexport function Button({ asChild, ...props }: ButtonProps) {\n const Element = asChild ? Slot : 'a';\n return <Element data-exit-this-page-button=\"\" {...props} />;\n}\n\nexport type SkipLinkProps = PartProps<'a'>;\n\n/** A link anywhere on the page, such as in the skip links, that exits too. */\nexport function SkipLink({ asChild, ...props }: SkipLinkProps) {\n const Element = asChild ? Slot : 'a';\n return <Element data-exit-this-page-skiplink=\"\" {...props} />;\n}\n\nexport type IndicatorProps = PartProps<'div'>;\n\n/** Shows how many times Shift has been pressed. Has three Lights unless given children. */\nexport function Indicator({ asChild, children, ...props }: IndicatorProps) {\n const Element = asChild ? Slot : 'div';\n return (\n // The element owns `data-visible` and its classes.\n <Element data-exit-this-page-indicator=\"\" aria-hidden=\"true\" suppressHydrationWarning {...props}>\n {children ?? (\n <>\n <Light />\n <Light />\n <Light />\n </>\n )}\n </Element>\n );\n}\n\nexport type LightProps = PartProps<'div'>;\n\n/** One press of Shift. */\nexport function Light({ asChild, ...props }: LightProps) {\n const Element = asChild ? Slot : 'div';\n // The element owns `data-on` and its classes.\n return <Element data-exit-this-page-light=\"\" suppressHydrationWarning {...props} />;\n}\n\nexport type StatusProps = PartProps<'span'>;\n\n/** Tells screen readers how many more presses are needed. Make it visually hidden. */\nexport function Status({ asChild, children, ...props }: StatusProps) {\n const Element = asChild ? Slot : 'span';\n // The element owns its text. A string child, even an empty one, is hydrated as text, so text the\n // element set before hydration is kept rather than being a mismatch.\n return (\n <Element data-exit-this-page-status=\"\" role=\"status\" suppressHydrationWarning {...props}>\n {children ?? ''}\n </Element>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAY,WAAW;AAmChB,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAc;AACZ,SAAa,oBAAc,SAAS;AAAA,IAClC,GAAG;AAAA,IACH,WAAW;AAAA,IACX,aAAa;AAAA,IACb,wBAAwB;AAAA,IACxB,uBAAuB;AAAA,IACvB,2BAA2B;AAAA,IAC3B,kBAAkB;AAAA,IAClB,sBAAsB;AAAA,IACtB,iBAAiB;AAAA;AAAA,IAEjB,0BAA0B;AAAA,EAC5B,CAAC;AACH;AAUO,SAAS,OAAO,EAAE,SAAS,GAAG,MAAM,GAAgB;AACzD,QAAM,UAAU,UAAU,OAAO;AACjC,SAAO,oCAAC,WAAQ,8BAA2B,IAAI,GAAG,OAAO;AAC3D;AAKO,SAAS,SAAS,EAAE,SAAS,GAAG,MAAM,GAAkB;AAC7D,QAAM,UAAU,UAAU,OAAO;AACjC,SAAO,oCAAC,WAAQ,gCAA6B,IAAI,GAAG,OAAO;AAC7D;AAKO,SAAS,UAAU,EAAE,SAAS,UAAU,GAAG,MAAM,GAAmB;AACzE,QAAM,UAAU,UAAU,OAAO;AACjC;AAAA;AAAA,IAEE,oCAAC,WAAQ,iCAA8B,IAAG,eAAY,QAAO,0BAAwB,MAAE,GAAG,SACvF,8BACC,0DACE,oCAAC,WAAM,GACP,oCAAC,WAAM,GACP,oCAAC,WAAM,CACT,CAEJ;AAAA;AAEJ;AAKO,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,GAAe;AACvD,QAAM,UAAU,UAAU,OAAO;AAEjC,SAAO,oCAAC,WAAQ,6BAA0B,IAAG,0BAAwB,MAAE,GAAG,OAAO;AACnF;AAKO,SAAS,OAAO,EAAE,SAAS,UAAU,GAAG,MAAM,GAAgB;AACnE,QAAM,UAAU,UAAU,OAAO;AAGjC,SACE,oCAAC,WAAQ,8BAA2B,IAAG,MAAK,UAAS,0BAAwB,MAAE,GAAG,SAC/E,8BAAY,EACf;AAEJ;","names":[]}
@@ -0,0 +1,91 @@
1
+ 'use client';
2
+ import {
3
+ defaults,
4
+ statusText,
5
+ tagName
6
+ } from "./chunk-YCESNTXQ.js";
7
+ import {
8
+ translationAttributes
9
+ } from "./chunk-RDUPELOK.js";
10
+ import {
11
+ Slot
12
+ } from "./chunk-NX4B3NKM.js";
13
+ import {
14
+ __export
15
+ } from "./chunk-ESBMTI25.js";
16
+
17
+ // src/file-upload/index.tsx
18
+ var file_upload_exports = {};
19
+ __export(file_upload_exports, {
20
+ Announcements: () => Announcements,
21
+ Button: () => Button,
22
+ DropZone: () => DropZone,
23
+ Input: () => Input,
24
+ Root: () => Root,
25
+ Separator: () => Separator,
26
+ Status: () => Status
27
+ });
28
+ import * as React from "react";
29
+ import { createContext, useContext, useState } from "react";
30
+ var InitialStatus = createContext(defaults["no-file-chosen"]);
31
+ function Root({
32
+ noFileChosen,
33
+ multipleFilesChosen,
34
+ enteredDropZone,
35
+ leftDropZone,
36
+ emptyClass,
37
+ draggingClass,
38
+ disabledClass,
39
+ ...props
40
+ }) {
41
+ const [initial] = useState(() => statusText([], { "no-file-chosen": noFileChosen }, props.lang || "en"));
42
+ return /* @__PURE__ */ React.createElement(InitialStatus.Provider, { value: initial }, React.createElement(tagName, {
43
+ ...props,
44
+ // The element owns `data-upgraded`.
45
+ suppressHydrationWarning: true,
46
+ "no-file-chosen": noFileChosen,
47
+ ...translationAttributes("multiple-files-chosen", multipleFilesChosen),
48
+ "entered-drop-zone": enteredDropZone,
49
+ "left-drop-zone": leftDropZone,
50
+ "empty-class": emptyClass,
51
+ "dragging-class": draggingClass,
52
+ "disabled-class": disabledClass
53
+ }));
54
+ }
55
+ function DropZone({ asChild, ...props }) {
56
+ const Element = asChild ? Slot : "div";
57
+ return /* @__PURE__ */ React.createElement(Element, { "data-file-upload-drop-zone": "", suppressHydrationWarning: true, ...props });
58
+ }
59
+ function Input({ asChild, ...props }) {
60
+ const Element = asChild ? Slot : "input";
61
+ return /* @__PURE__ */ React.createElement(Element, { type: "file", suppressHydrationWarning: true, ...props });
62
+ }
63
+ function Button({ asChild, ...props }) {
64
+ const Element = asChild ? Slot : "button";
65
+ return /* @__PURE__ */ React.createElement(Element, { "data-file-upload-button": "", type: "button", hidden: true, suppressHydrationWarning: true, ...props });
66
+ }
67
+ function Status({ asChild, children, ...props }) {
68
+ const initial = useContext(InitialStatus);
69
+ const Element = asChild ? Slot : "span";
70
+ return /* @__PURE__ */ React.createElement(Element, { "data-file-upload-status": "", "aria-live": "polite", suppressHydrationWarning: true, ...props }, children != null ? children : initial);
71
+ }
72
+ function Separator({ asChild, children = ", ", ...props }) {
73
+ const Element = asChild ? Slot : "span";
74
+ return /* @__PURE__ */ React.createElement(Element, { "data-file-upload-separator": "", suppressHydrationWarning: true, ...props }, children);
75
+ }
76
+ function Announcements({ asChild, ...props }) {
77
+ const Element = asChild ? Slot : "span";
78
+ return /* @__PURE__ */ React.createElement(Element, { "data-file-upload-announcements": "", "aria-live": "assertive", suppressHydrationWarning: true, ...props });
79
+ }
80
+
81
+ export {
82
+ Root,
83
+ DropZone,
84
+ Input,
85
+ Button,
86
+ Status,
87
+ Separator,
88
+ Announcements,
89
+ file_upload_exports
90
+ };
91
+ //# sourceMappingURL=chunk-5HWRMQK2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/file-upload/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createContext, useContext, useState } from 'react';\nimport type { ComponentProps } from 'react';\nimport { Slot } from '../utils/slot';\nimport { translationAttributes, type Translation } from '../utils/translation';\nimport { defaults, statusText, tagName } from './element';\n\nexport type { Translation } from '../utils/translation';\n\n/*\n * Headless file upload: unstyled parts over the <govuk-react-file-upload> element (./element.ts),\n * which shows the button on upgrade, hides the input and handles dropped files. Every part except\n * Root takes `asChild`.\n *\n * The input's files are the state, owned by the browser, so there is nothing to control. Without\n * JavaScript the native file input shows and the button stays hidden.\n */\n\nexport type RootProps = React.HTMLAttributes<HTMLElement> & {\n /** Shown while no file is chosen. Defaults to \"No file chosen\". */\n noFileChosen?: string;\n /** Shown when more than one file is chosen. `%{count}` is the number. Defaults to \"%{count} files chosen\". */\n multipleFilesChosen?: Translation;\n /** Announced when the user drags files into the drop zone. Defaults to \"Entered drop zone\". */\n enteredDropZone?: string;\n /** Announced when the user drags files out of the drop zone. Defaults to \"Left drop zone\". */\n leftDropZone?: string;\n /** Classes for the button while no file is chosen. */\n emptyClass?: string;\n /** Classes for the button while files are dragged over the drop zone. */\n draggingClass?: string;\n /** Classes for the drop zone while the input is disabled. */\n disabledClass?: string;\n};\n\n// What the status starts with, so the element only changes text React rendered.\nconst InitialStatus = createContext<string>(defaults['no-file-chosen']);\n\nexport function Root({\n noFileChosen,\n multipleFilesChosen,\n enteredDropZone,\n leftDropZone,\n emptyClass,\n draggingClass,\n disabledClass,\n ...props\n}: RootProps) {\n // Rendered once and then left to the element, so a re-render never puts back a stale status.\n const [initial] = useState(() => statusText([], { 'no-file-chosen': noFileChosen }, props.lang || 'en'));\n return (\n <InitialStatus.Provider value={initial}>\n {React.createElement(tagName, {\n ...props,\n // The element owns `data-upgraded`.\n suppressHydrationWarning: true,\n 'no-file-chosen': noFileChosen,\n ...translationAttributes('multiple-files-chosen', multipleFilesChosen),\n 'entered-drop-zone': enteredDropZone,\n 'left-drop-zone': leftDropZone,\n 'empty-class': emptyClass,\n 'dragging-class': draggingClass,\n 'disabled-class': disabledClass,\n })}\n </InitialStatus.Provider>\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 DropZoneProps = PartProps<'div'>;\n\n/** The area that shows files are being dragged over it. Holds the button and the input. */\nexport function DropZone({ asChild, ...props }: DropZoneProps) {\n const Element = asChild ? Slot : 'div';\n // The element owns its disabled classes after upgrade.\n return <Element data-file-upload-drop-zone=\"\" suppressHydrationWarning {...props} />;\n}\n\nexport type InputProps = Omit<PartProps<'input'>, 'type'>;\n\n/** The file input, with an `id` and a `label`. Shown without JavaScript, and hidden on upgrade. */\nexport function Input({ asChild, ...props }: InputProps) {\n const Element = asChild ? Slot : 'input';\n // The element owns `id` and `hidden` after upgrade.\n return <Element type=\"file\" suppressHydrationWarning {...props} />;\n}\n\nexport type ButtonProps = PartProps<'button'>;\n\n/**\n * Opens the file picker, and takes dropped files. Hidden until the element upgrades, when it\n * takes the input's id, so the input's label names it. Holds `Status`.\n */\nexport function Button({ asChild, ...props }: ButtonProps) {\n const Element = asChild ? Slot : 'button';\n // The element owns `id`, `hidden`, `disabled`, its ARIA and its classes after upgrade.\n return <Element data-file-upload-button=\"\" type=\"button\" hidden suppressHydrationWarning {...props} />;\n}\n\nexport type StatusProps = PartProps<'span'>;\n\n/** Which files are chosen: \"No file chosen\", the file's name, or how many files. In `Button`. */\nexport function Status({ asChild, children, ...props }: StatusProps) {\n const initial = useContext(InitialStatus);\n const Element = asChild ? Slot : 'span';\n // The element owns its text after upgrade.\n return (\n <Element data-file-upload-status=\"\" aria-live=\"polite\" suppressHydrationWarning {...props}>\n {children ?? initial}\n </Element>\n );\n}\n\nexport type SeparatorProps = PartProps<'span'>;\n\n/** Between the label and the button's text in the button's accessible name. Defaults to \", \". In `Button`. */\nexport function Separator({ asChild, children = ', ', ...props }: SeparatorProps) {\n const Element = asChild ? Slot : 'span';\n // The element owns its `id` after upgrade.\n return (\n <Element data-file-upload-separator=\"\" suppressHydrationWarning {...props}>\n {children}\n </Element>\n );\n}\n\nexport type AnnouncementsProps = PartProps<'span'>;\n\n/** Announces entering and leaving the drop zone. Make it visually hidden. */\nexport function Announcements({ asChild, ...props }: AnnouncementsProps) {\n const Element = asChild ? Slot : 'span';\n // The element owns its text after upgrade.\n return <Element data-file-upload-announcements=\"\" aria-live=\"assertive\" suppressHydrationWarning {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAY,WAAW;AACvB,SAAS,eAAe,YAAY,gBAAgB;AAmCpD,IAAM,gBAAgB,cAAsB,SAAS,gBAAgB,CAAC;AAE/D,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAc;AAEZ,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,WAAW,CAAC,GAAG,EAAE,kBAAkB,aAAa,GAAG,MAAM,QAAQ,IAAI,CAAC;AACvG,SACE,oCAAC,cAAc,UAAd,EAAuB,OAAO,WACtB,oBAAc,SAAS;AAAA,IAC5B,GAAG;AAAA;AAAA,IAEH,0BAA0B;AAAA,IAC1B,kBAAkB;AAAA,IAClB,GAAG,sBAAsB,yBAAyB,mBAAmB;AAAA,IACrE,qBAAqB;AAAA,IACrB,kBAAkB;AAAA,IAClB,eAAe;AAAA,IACf,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,EACpB,CAAC,CACH;AAEJ;AAUO,SAAS,SAAS,EAAE,SAAS,GAAG,MAAM,GAAkB;AAC7D,QAAM,UAAU,UAAU,OAAO;AAEjC,SAAO,oCAAC,WAAQ,8BAA2B,IAAG,0BAAwB,MAAE,GAAG,OAAO;AACpF;AAKO,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,GAAe;AACvD,QAAM,UAAU,UAAU,OAAO;AAEjC,SAAO,oCAAC,WAAQ,MAAK,QAAO,0BAAwB,MAAE,GAAG,OAAO;AAClE;AAQO,SAAS,OAAO,EAAE,SAAS,GAAG,MAAM,GAAgB;AACzD,QAAM,UAAU,UAAU,OAAO;AAEjC,SAAO,oCAAC,WAAQ,2BAAwB,IAAG,MAAK,UAAS,QAAM,MAAC,0BAAwB,MAAE,GAAG,OAAO;AACtG;AAKO,SAAS,OAAO,EAAE,SAAS,UAAU,GAAG,MAAM,GAAgB;AACnE,QAAM,UAAU,WAAW,aAAa;AACxC,QAAM,UAAU,UAAU,OAAO;AAEjC,SACE,oCAAC,WAAQ,2BAAwB,IAAG,aAAU,UAAS,0BAAwB,MAAE,GAAG,SACjF,8BAAY,OACf;AAEJ;AAKO,SAAS,UAAU,EAAE,SAAS,WAAW,MAAM,GAAG,MAAM,GAAmB;AAChF,QAAM,UAAU,UAAU,OAAO;AAEjC,SACE,oCAAC,WAAQ,8BAA2B,IAAG,0BAAwB,MAAE,GAAG,SACjE,QACH;AAEJ;AAKO,SAAS,cAAc,EAAE,SAAS,GAAG,MAAM,GAAuB;AACvE,QAAM,UAAU,UAAU,OAAO;AAEjC,SAAO,oCAAC,WAAQ,kCAA+B,IAAG,aAAU,aAAY,0BAAwB,MAAE,GAAG,OAAO;AAC9G;","names":[]}
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import {
3
+ tagName
4
+ } from "./chunk-XGK73UCD.js";
5
+ import {
6
+ Slot
7
+ } from "./chunk-NX4B3NKM.js";
8
+ import {
9
+ __export
10
+ } from "./chunk-ESBMTI25.js";
11
+
12
+ // src/auto-focus/index.tsx
13
+ var auto_focus_exports = {};
14
+ __export(auto_focus_exports, {
15
+ Root: () => Root,
16
+ Target: () => Target
17
+ });
18
+ import * as React from "react";
19
+ import { isValidElement } from "react";
20
+ function Root({ disabled, ...props }) {
21
+ return React.createElement(tagName, { ...props, disabled: disabled ? "" : void 0 });
22
+ }
23
+ function tabIndexOf({ asChild, tabIndex, children }) {
24
+ if (tabIndex !== void 0 || !asChild) return tabIndex;
25
+ return isValidElement(children) ? children.props.tabIndex : void 0;
26
+ }
27
+ function Target({ asChild, disabled, ...props }) {
28
+ const Element = asChild ? Slot : "div";
29
+ let focus = {};
30
+ if (!disabled) {
31
+ focus = tabIndexOf({ asChild, ...props }) === void 0 ? { tabIndex: -1, autoFocus: true, "data-focus-tabindex": "" } : { autoFocus: true };
32
+ }
33
+ return /* @__PURE__ */ React.createElement(Element, { "data-auto-focus": "", suppressHydrationWarning: true, ...focus, ...props });
34
+ }
35
+
36
+ export {
37
+ Root,
38
+ Target,
39
+ auto_focus_exports
40
+ };
41
+ //# sourceMappingURL=chunk-6ZFU4VYW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/auto-focus/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { isValidElement } from 'react';\nimport type { ComponentProps } from 'react';\nimport { Slot } from '../utils/slot';\nimport { tagName } from './element';\n\n/*\n * Headless auto focus: the <govuk-react-auto-focus> element (./element.ts) moves focus to its\n * `Target` when it appears. The server renders the target with `autofocus`, so the browser focuses\n * it when the page loads, even without JavaScript.\n */\n\nexport type RootProps = React.HTMLAttributes<HTMLElement> & {\n /** Don't move focus. */\n disabled?: boolean;\n};\n\nexport function Root({ disabled, ...props }: RootProps) {\n return React.createElement(tagName, { ...props, disabled: disabled ? '' : undefined });\n}\n\nexport type TargetProps = ComponentProps<'div'> & {\n /** Render the only child instead, with this part's props merged onto it. */\n asChild?: boolean;\n /** Don't move focus. Pass the same as to `Root`. */\n disabled?: boolean;\n};\n\n/** The tabindex of the target, or with `asChild`, of its child. */\nfunction tabIndexOf({ asChild, tabIndex, children }: TargetProps) {\n if (tabIndex !== undefined || !asChild) return tabIndex;\n return isValidElement<{ tabIndex?: number }>(children) ? children.props.tabIndex : undefined;\n}\n\n/** What gets focus. */\nexport function Target({ asChild, disabled, ...props }: TargetProps) {\n const Element = asChild ? Slot : 'div';\n let focus = {};\n if (!disabled) {\n // `data-focus-tabindex` says the tabindex is only for this, so it goes when focus moves on.\n focus =\n tabIndexOf({ asChild, ...props }) === undefined\n ? { tabIndex: -1, autoFocus: true, 'data-focus-tabindex': '' }\n : { autoFocus: true };\n }\n // The element owns `tabindex` and `autofocus` after it has moved focus.\n return <Element data-auto-focus=\"\" suppressHydrationWarning {...focus} {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAY,WAAW;AACvB,SAAS,sBAAsB;AAgBxB,SAAS,KAAK,EAAE,UAAU,GAAG,MAAM,GAAc;AACtD,SAAa,oBAAc,SAAS,EAAE,GAAG,OAAO,UAAU,WAAW,KAAK,OAAU,CAAC;AACvF;AAUA,SAAS,WAAW,EAAE,SAAS,UAAU,SAAS,GAAgB;AAChE,MAAI,aAAa,UAAa,CAAC,QAAS,QAAO;AAC/C,SAAO,eAAsC,QAAQ,IAAI,SAAS,MAAM,WAAW;AACrF;AAGO,SAAS,OAAO,EAAE,SAAS,UAAU,GAAG,MAAM,GAAgB;AACnE,QAAM,UAAU,UAAU,OAAO;AACjC,MAAI,QAAQ,CAAC;AACb,MAAI,CAAC,UAAU;AAEb,YACE,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,SAClC,EAAE,UAAU,IAAI,WAAW,MAAM,uBAAuB,GAAG,IAC3D,EAAE,WAAW,KAAK;AAAA,EAC1B;AAEA,SAAO,oCAAC,WAAQ,mBAAgB,IAAG,0BAAwB,MAAE,GAAG,OAAQ,GAAG,OAAO;AACpF;","names":[]}