@govuk-react/primitives 0.0.0-stage → 0.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 (121) hide show
  1. package/README.md +271 -2
  2. package/dist/accordion/element.d.ts +14 -0
  3. package/dist/accordion/element.js +302 -0
  4. package/dist/accordion/element.js.map +1 -0
  5. package/dist/accordion/index.d.ts +74 -0
  6. package/dist/accordion/index.js +138 -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 +297 -0
  12. package/dist/auto-focus/index.js +29 -0
  13. package/dist/auto-focus/index.js.map +1 -0
  14. package/dist/autocomplete/element.d.ts +27 -0
  15. package/dist/autocomplete/element.js +597 -0
  16. package/dist/autocomplete/element.js.map +1 -0
  17. package/dist/autocomplete/index.d.ts +350 -0
  18. package/dist/autocomplete/index.js +108 -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 +7 -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 +5 -0
  36. package/dist/choices/element.js +202 -0
  37. package/dist/choices/element.js.map +1 -0
  38. package/dist/choices/index.d.ts +309 -0
  39. package/dist/choices/index.js +37 -0
  40. package/dist/choices/index.js.map +1 -0
  41. package/dist/disclosure/element.d.ts +14 -0
  42. package/dist/disclosure/element.js +123 -0
  43. package/dist/disclosure/element.js.map +1 -0
  44. package/dist/disclosure/index.d.ts +307 -0
  45. package/dist/disclosure/index.js +66 -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 +201 -0
  49. package/dist/exit-this-page/element.js.map +1 -0
  50. package/dist/exit-this-page/index.d.ts +330 -0
  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 +23 -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/focus-links/index.d.ts +288 -0
  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 -0
  66. package/dist/index.js +14 -0
  67. package/dist/index.js.map +1 -0
  68. package/dist/inline/accordion-element.js +1 -0
  69. package/dist/inline/auto-focus-element.js +1 -0
  70. package/dist/inline/autocomplete-element.js +2 -0
  71. package/dist/inline/button-element.js +1 -0
  72. package/dist/inline/character-count-element.js +1 -0
  73. package/dist/inline/choices-element.js +1 -0
  74. package/dist/inline/disclosure-element.js +1 -0
  75. package/dist/inline/exit-this-page-element.js +1 -0
  76. package/dist/inline/file-upload-element.js +1 -0
  77. package/dist/inline/focus-links-element.js +1 -0
  78. package/dist/inline/modal-element.js +1 -0
  79. package/dist/inline/password-input-element.js +1 -0
  80. package/dist/inline/tabs-element.js +1 -0
  81. package/dist/inline-script/index.d.ts +26 -0
  82. package/dist/inline-script/index.js +31 -0
  83. package/dist/inline-script/index.js.map +1 -0
  84. package/dist/modal/element.d.ts +10 -0
  85. package/dist/modal/element.js +114 -0
  86. package/dist/modal/element.js.map +1 -0
  87. package/dist/modal/index.d.ts +36 -0
  88. package/dist/modal/index.js +109 -0
  89. package/dist/modal/index.js.map +1 -0
  90. package/dist/password-input/element.d.ts +1 -0
  91. package/dist/password-input/element.js +134 -0
  92. package/dist/password-input/element.js.map +1 -0
  93. package/dist/password-input/index.d.ts +318 -0
  94. package/dist/password-input/index.js +35 -0
  95. package/dist/password-input/index.js.map +1 -0
  96. package/dist/tabs/element.d.ts +19 -0
  97. package/dist/tabs/element.js +416 -0
  98. package/dist/tabs/element.js.map +1 -0
  99. package/dist/tabs/index.d.ts +83 -0
  100. package/dist/tabs/index.js +138 -0
  101. package/dist/tabs/index.js.map +1 -0
  102. package/dist/utils/dom.d.ts +9 -0
  103. package/dist/utils/dom.js +27 -0
  104. package/dist/utils/dom.js.map +1 -0
  105. package/dist/utils/on-property-set.d.ts +9 -0
  106. package/dist/utils/on-property-set.js +38 -0
  107. package/dist/utils/on-property-set.js.map +1 -0
  108. package/dist/utils/set-focus.d.ts +11 -0
  109. package/dist/utils/set-focus.js +38 -0
  110. package/dist/utils/set-focus.js.map +1 -0
  111. package/dist/utils/set-up-when-ready.d.ts +6 -0
  112. package/dist/utils/set-up-when-ready.js +16 -0
  113. package/dist/utils/set-up-when-ready.js.map +1 -0
  114. package/dist/utils/slot.d.ts +13 -0
  115. package/dist/utils/slot.js +40 -0
  116. package/dist/utils/slot.js.map +1 -0
  117. package/dist/utils/translation.d.ts +13 -0
  118. package/dist/utils/translation.js +57 -0
  119. package/dist/utils/translation.js.map +1 -0
  120. package/licences/accessible-autocomplete.txt +20 -0
  121. package/package.json +49 -4
@@ -0,0 +1,201 @@
1
+ /*
2
+ * <govuk-react-exit-this-page>: a headless, light-DOM custom element that lets users leave a page
3
+ * quickly, with or without React, as govuk-frontend's exit this page does.
4
+ *
5
+ * Without JavaScript the button is a link to a safe page. On upgrade, the button, a skip link, or
6
+ * pressing Shift 3 times within 5 seconds hides the page, shows an overlay that says it's loading,
7
+ * and goes to the button's `href`. A status tells screen readers how many more presses are needed.
8
+ *
9
+ * Markup inside the element:
10
+ * - `[data-exit-this-page-button]`: the link to the safe page.
11
+ * - `[data-exit-this-page-indicator]`: shows how many times Shift has been pressed, with
12
+ * `[data-exit-this-page-light]` children. It gets `data-visible` while counting, and each light
13
+ * `data-on` once pressed.
14
+ * - `[data-exit-this-page-status]`: an empty status for screen readers. Make it visually hidden.
15
+ *
16
+ * Anywhere on the page, a link with `data-exit-this-page-skiplink` exits too. Only the page's
17
+ * first element listens for Shift and the skip link.
18
+ *
19
+ * Before leaving, the element fires a cancelable, bubbling `govuk-react-exit-this-page:exit`
20
+ * event. Cancel it to stay on the page.
21
+ *
22
+ * Attributes:
23
+ * - `activated`, `timed-out`, `press-two-more-times`, `press-one-more-time`: the messages,
24
+ * English by default.
25
+ * - `indicator-visible-class`, `light-on-class`: classes for the indicator and its lights.
26
+ * - `hide-content-class`: classes for `body` that hide the page behind the overlay.
27
+ * - `overlay-class`: classes for the overlay. Without them, the overlay covers the page with
28
+ * inline styles.
29
+ */
30
+ import { classesOf } from '../utils/dom.js';
31
+ export const tagName = 'govuk-react-exit-this-page';
32
+ export const messageNames = ['activated', 'timed-out', 'press-two-more-times', 'press-one-more-time'];
33
+ /** govuk-frontend's English messages. */
34
+ export const defaultMessages = {
35
+ activated: 'Loading.',
36
+ 'timed-out': 'Exit this page expired.',
37
+ 'press-two-more-times': 'Shift, press 2 more times to exit.',
38
+ 'press-one-more-time': 'Shift, press 1 more time to exit.',
39
+ };
40
+ const timeoutMs = 5000;
41
+ const overlayStyles = {
42
+ position: 'fixed',
43
+ inset: '0',
44
+ 'z-index': '2147483647',
45
+ background: 'white',
46
+ };
47
+ if (typeof HTMLElement !== 'undefined' && typeof customElements !== 'undefined') {
48
+ class GovukReactExitThisPage extends HTMLElement {
49
+ constructor() {
50
+ super(...arguments);
51
+ this.presses = 0;
52
+ this.lastKeyWasModified = false;
53
+ this.onClick = (event) => {
54
+ if (event.defaultPrevented || event.button !== 0)
55
+ return;
56
+ const link = event.target instanceof Element ? event.target.closest('a') : null;
57
+ if (!link)
58
+ return;
59
+ const own = link.matches('[data-exit-this-page-button]') && link.closest(tagName) === this;
60
+ const skipLink = link.matches('[data-exit-this-page-skiplink]') && this.listening;
61
+ if (!own && !skipLink)
62
+ return;
63
+ event.preventDefault();
64
+ this.exit();
65
+ };
66
+ this.onKeyup = (event) => {
67
+ if (!this.listening)
68
+ return;
69
+ if (event.key === 'Shift' && !this.lastKeyWasModified) {
70
+ this.presses += 1;
71
+ this.updateIndicator();
72
+ window.clearTimeout(this.messageTimeout);
73
+ if (this.presses >= 3) {
74
+ this.presses = 0;
75
+ window.clearTimeout(this.pressTimeout);
76
+ this.pressTimeout = undefined;
77
+ this.exit();
78
+ }
79
+ else {
80
+ this.setStatus(this.message(this.presses === 1 ? 'press-two-more-times' : 'press-one-more-time'));
81
+ window.clearTimeout(this.pressTimeout);
82
+ this.pressTimeout = window.setTimeout(this.timeOut, timeoutMs);
83
+ }
84
+ }
85
+ else if (this.pressTimeout !== undefined) {
86
+ this.timeOut();
87
+ }
88
+ this.lastKeyWasModified = event.shiftKey;
89
+ };
90
+ this.timeOut = () => {
91
+ window.clearTimeout(this.pressTimeout);
92
+ this.pressTimeout = undefined;
93
+ this.presses = 0;
94
+ this.setStatus(this.message('timed-out'));
95
+ this.messageTimeout = window.setTimeout(() => this.setStatus(''), timeoutMs);
96
+ this.updateIndicator();
97
+ };
98
+ /** Shows the page again when the browser brings it back from its cache. */
99
+ this.reset = (event) => {
100
+ var _a;
101
+ // `pageshow` fires on every load too, which mustn't lose presses made before it.
102
+ if (!event.persisted)
103
+ return;
104
+ classesOf(this.getAttribute('hide-content-class')).forEach((name) => document.body.classList.remove(name));
105
+ (_a = this.overlay) === null || _a === void 0 ? void 0 : _a.remove();
106
+ this.overlay = undefined;
107
+ this.presses = 0;
108
+ this.setStatus('');
109
+ this.updateIndicator();
110
+ this.clearTimers();
111
+ };
112
+ }
113
+ connectedCallback() {
114
+ this.dataset.upgraded = '';
115
+ document.addEventListener('keyup', this.onKeyup, true);
116
+ document.addEventListener('click', this.onClick);
117
+ window.addEventListener('pageshow', this.reset);
118
+ }
119
+ disconnectedCallback() {
120
+ document.removeEventListener('keyup', this.onKeyup, true);
121
+ document.removeEventListener('click', this.onClick);
122
+ window.removeEventListener('pageshow', this.reset);
123
+ this.clearTimers();
124
+ // Moved elements start counting again.
125
+ this.presses = 0;
126
+ this.setStatus('');
127
+ this.updateIndicator();
128
+ }
129
+ exit() {
130
+ var _a;
131
+ const button = this.own('[data-exit-this-page-button]');
132
+ const href = button instanceof HTMLAnchorElement ? button.href : undefined;
133
+ const proceed = href !== undefined &&
134
+ this.dispatchEvent(new CustomEvent('govuk-react-exit-this-page:exit', { detail: { href }, bubbles: true, cancelable: true }));
135
+ if (!href || !proceed) {
136
+ // Staying on the page: clear the presses.
137
+ this.setStatus('');
138
+ this.updateIndicator();
139
+ return;
140
+ }
141
+ this.setStatus('');
142
+ classesOf(this.getAttribute('hide-content-class')).forEach((name) => document.body.classList.add(name));
143
+ (_a = this.overlay) === null || _a === void 0 ? void 0 : _a.remove();
144
+ const overlay = document.createElement('div');
145
+ overlay.setAttribute('role', 'alert');
146
+ const overlayClasses = classesOf(this.getAttribute('overlay-class'));
147
+ if (overlayClasses.length)
148
+ overlay.classList.add(...overlayClasses);
149
+ else
150
+ Object.entries(overlayStyles).forEach(([name, value]) => overlay.style.setProperty(name, value));
151
+ document.body.appendChild(overlay);
152
+ overlay.textContent = this.message('activated');
153
+ this.overlay = overlay;
154
+ window.location.href = href;
155
+ }
156
+ /** Only the page's first element listens to the page, as govuk-frontend's first instance does. */
157
+ get listening() {
158
+ return document.querySelector(tagName) === this;
159
+ }
160
+ own(selector) {
161
+ return Array.from(this.querySelectorAll(selector)).find((element) => element.closest(tagName) === this);
162
+ }
163
+ message(name) {
164
+ var _a;
165
+ return (_a = this.getAttribute(name)) !== null && _a !== void 0 ? _a : defaultMessages[name];
166
+ }
167
+ // Keeps the text node React rendered, if any, so React can still update it.
168
+ setStatus(text) {
169
+ const status = this.own('[data-exit-this-page-status]');
170
+ if (!status || status.textContent === text)
171
+ return;
172
+ const { firstChild } = status;
173
+ if (firstChild instanceof Text && status.childNodes.length === 1)
174
+ firstChild.nodeValue = text;
175
+ else
176
+ status.textContent = text;
177
+ }
178
+ clearTimers() {
179
+ window.clearTimeout(this.pressTimeout);
180
+ window.clearTimeout(this.messageTimeout);
181
+ this.pressTimeout = undefined;
182
+ this.messageTimeout = undefined;
183
+ }
184
+ updateIndicator() {
185
+ const indicator = this.own('[data-exit-this-page-indicator]');
186
+ if (!indicator)
187
+ return;
188
+ const visible = this.presses > 0;
189
+ indicator.toggleAttribute('data-visible', visible);
190
+ classesOf(this.getAttribute('indicator-visible-class')).forEach((name) => indicator.classList.toggle(name, visible));
191
+ indicator.querySelectorAll('[data-exit-this-page-light]').forEach((light, index) => {
192
+ const on = index < this.presses;
193
+ light.toggleAttribute('data-on', on);
194
+ classesOf(this.getAttribute('light-on-class')).forEach((name) => light.classList.toggle(name, on));
195
+ });
196
+ }
197
+ }
198
+ if (!customElements.get(tagName))
199
+ customElements.define(tagName, GovukReactExitThisPage);
200
+ }
201
+ //# sourceMappingURL=element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/exit-this-page/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AAEpD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,qBAAqB,CAAU,CAAC;AAI/G,yCAAyC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAgC;IAC1D,SAAS,EAAE,UAAU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AAO,CAAC;gBAChC,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;gBACrC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACrG,CAAC,CAAC,CAAC;QACL,CAAC;KACF;IAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["/*\n * <govuk-react-exit-this-page>: a headless, light-DOM custom element that lets users leave a page\n * quickly, with or without React, as govuk-frontend's exit this page does.\n *\n * Without JavaScript the button is a link to a safe page. On upgrade, the button, a skip link, or\n * pressing Shift 3 times within 5 seconds hides the page, shows an overlay that says it's loading,\n * and goes to the button's `href`. A status tells screen readers how many more presses are needed.\n *\n * Markup inside the element:\n * - `[data-exit-this-page-button]`: the link to the safe page.\n * - `[data-exit-this-page-indicator]`: shows how many times Shift has been pressed, with\n * `[data-exit-this-page-light]` children. It gets `data-visible` while counting, and each light\n * `data-on` once pressed.\n * - `[data-exit-this-page-status]`: an empty status for screen readers. Make it visually hidden.\n *\n * Anywhere on the page, a link with `data-exit-this-page-skiplink` exits too. Only the page's\n * first element listens for Shift and the skip link.\n *\n * Before leaving, the element fires a cancelable, bubbling `govuk-react-exit-this-page:exit`\n * event. Cancel it to stay on the page.\n *\n * Attributes:\n * - `activated`, `timed-out`, `press-two-more-times`, `press-one-more-time`: the messages,\n * English by default.\n * - `indicator-visible-class`, `light-on-class`: classes for the indicator and its lights.\n * - `hide-content-class`: classes for `body` that hide the page behind the overlay.\n * - `overlay-class`: classes for the overlay. Without them, the overlay covers the page with\n * inline styles.\n */\n\nimport { classesOf } from '../utils/dom.js';\n\nexport const tagName = 'govuk-react-exit-this-page';\n\nexport const messageNames = ['activated', 'timed-out', 'press-two-more-times', 'press-one-more-time'] as const;\n\nexport type MessageName = (typeof messageNames)[number];\n\n/** govuk-frontend's English messages. */\nexport const defaultMessages: Record<MessageName, string> = {\n activated: 'Loading.',\n 'timed-out': 'Exit this page expired.',\n 'press-two-more-times': 'Shift, press 2 more times to exit.',\n 'press-one-more-time': 'Shift, press 1 more time to exit.',\n};\n\nexport interface ExitThisPageElement extends HTMLElement {\n /** Hides the page and goes to the button's `href`, unless the exit event is cancelled. */\n exit(): void;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'govuk-react-exit-this-page': ExitThisPageElement;\n }\n interface HTMLElementEventMap {\n 'govuk-react-exit-this-page:exit': CustomEvent<{ href: string }>;\n }\n}\n\nconst timeoutMs = 5000;\n\nconst overlayStyles: Record<string, string> = {\n position: 'fixed',\n inset: '0',\n 'z-index': '2147483647',\n background: 'white',\n};\n\nif (typeof HTMLElement !== 'undefined' && typeof customElements !== 'undefined') {\n class GovukReactExitThisPage extends HTMLElement implements ExitThisPageElement {\n private presses = 0;\n private lastKeyWasModified = false;\n private pressTimeout?: number;\n private messageTimeout?: number;\n private overlay?: HTMLElement;\n\n connectedCallback() {\n this.dataset.upgraded = '';\n document.addEventListener('keyup', this.onKeyup, true);\n document.addEventListener('click', this.onClick);\n window.addEventListener('pageshow', this.reset);\n }\n\n disconnectedCallback() {\n document.removeEventListener('keyup', this.onKeyup, true);\n document.removeEventListener('click', this.onClick);\n window.removeEventListener('pageshow', this.reset);\n this.clearTimers();\n // Moved elements start counting again.\n this.presses = 0;\n this.setStatus('');\n this.updateIndicator();\n }\n\n exit() {\n const button = this.own('[data-exit-this-page-button]');\n const href = button instanceof HTMLAnchorElement ? button.href : undefined;\n const proceed =\n href !== undefined &&\n this.dispatchEvent(\n new CustomEvent('govuk-react-exit-this-page:exit', { detail: { href }, bubbles: true, cancelable: true })\n );\n if (!href || !proceed) {\n // Staying on the page: clear the presses.\n this.setStatus('');\n this.updateIndicator();\n return;\n }\n this.setStatus('');\n classesOf(this.getAttribute('hide-content-class')).forEach((name) => document.body.classList.add(name));\n this.overlay?.remove();\n const overlay = document.createElement('div');\n overlay.setAttribute('role', 'alert');\n const overlayClasses = classesOf(this.getAttribute('overlay-class'));\n if (overlayClasses.length) overlay.classList.add(...overlayClasses);\n else Object.entries(overlayStyles).forEach(([name, value]) => overlay.style.setProperty(name, value));\n document.body.appendChild(overlay);\n overlay.textContent = this.message('activated');\n this.overlay = overlay;\n window.location.href = href;\n }\n\n /** Only the page's first element listens to the page, as govuk-frontend's first instance does. */\n private get listening() {\n return document.querySelector(tagName) === this;\n }\n\n private own(selector: string) {\n return Array.from(this.querySelectorAll<HTMLElement>(selector)).find(\n (element) => element.closest(tagName) === this\n );\n }\n\n private message(name: MessageName) {\n return this.getAttribute(name) ?? defaultMessages[name];\n }\n\n // Keeps the text node React rendered, if any, so React can still update it.\n private setStatus(text: string) {\n const status = this.own('[data-exit-this-page-status]');\n if (!status || status.textContent === text) return;\n const { firstChild } = status;\n if (firstChild instanceof Text && status.childNodes.length === 1) firstChild.nodeValue = text;\n else status.textContent = text;\n }\n\n private readonly onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || event.button !== 0) return;\n const link = event.target instanceof Element ? event.target.closest('a') : null;\n if (!link) return;\n const own = link.matches('[data-exit-this-page-button]') && link.closest(tagName) === this;\n const skipLink = link.matches('[data-exit-this-page-skiplink]') && this.listening;\n if (!own && !skipLink) return;\n event.preventDefault();\n this.exit();\n };\n\n private readonly onKeyup = (event: KeyboardEvent) => {\n if (!this.listening) return;\n if (event.key === 'Shift' && !this.lastKeyWasModified) {\n this.presses += 1;\n this.updateIndicator();\n window.clearTimeout(this.messageTimeout);\n if (this.presses >= 3) {\n this.presses = 0;\n window.clearTimeout(this.pressTimeout);\n this.pressTimeout = undefined;\n this.exit();\n } else {\n this.setStatus(this.message(this.presses === 1 ? 'press-two-more-times' : 'press-one-more-time'));\n window.clearTimeout(this.pressTimeout);\n this.pressTimeout = window.setTimeout(this.timeOut, timeoutMs);\n }\n } else if (this.pressTimeout !== undefined) {\n this.timeOut();\n }\n this.lastKeyWasModified = event.shiftKey;\n };\n\n private readonly timeOut = () => {\n window.clearTimeout(this.pressTimeout);\n this.pressTimeout = undefined;\n this.presses = 0;\n this.setStatus(this.message('timed-out'));\n this.messageTimeout = window.setTimeout(() => this.setStatus(''), timeoutMs);\n this.updateIndicator();\n };\n\n /** Shows the page again when the browser brings it back from its cache. */\n private readonly reset = (event: PageTransitionEvent) => {\n // `pageshow` fires on every load too, which mustn't lose presses made before it.\n if (!event.persisted) return;\n classesOf(this.getAttribute('hide-content-class')).forEach((name) => document.body.classList.remove(name));\n this.overlay?.remove();\n this.overlay = undefined;\n this.presses = 0;\n this.setStatus('');\n this.updateIndicator();\n this.clearTimers();\n };\n\n private clearTimers() {\n window.clearTimeout(this.pressTimeout);\n window.clearTimeout(this.messageTimeout);\n this.pressTimeout = undefined;\n this.messageTimeout = undefined;\n }\n\n private updateIndicator() {\n const indicator = this.own('[data-exit-this-page-indicator]');\n if (!indicator) return;\n const visible = this.presses > 0;\n indicator.toggleAttribute('data-visible', visible);\n classesOf(this.getAttribute('indicator-visible-class')).forEach((name) =>\n indicator.classList.toggle(name, visible)\n );\n indicator.querySelectorAll('[data-exit-this-page-light]').forEach((light, index) => {\n const on = index < this.presses;\n light.toggleAttribute('data-on', on);\n classesOf(this.getAttribute('light-on-class')).forEach((name) => light.classList.toggle(name, on));\n });\n }\n }\n\n if (!customElements.get(tagName)) customElements.define(tagName, GovukReactExitThisPage);\n}\n"]}
@@ -0,0 +1,330 @@
1
+ import * as React from 'react';
2
+ import type { ComponentProps } from 'react';
3
+ export { defaultMessages, type ExitThisPageElement, type MessageName } from './element.js';
4
+ export type RootProps = React.HTMLAttributes<HTMLElement> & {
5
+ /** Announced once activated. Defaults to "Loading.". */
6
+ activatedText?: string;
7
+ /** Announced when the Shift presses time out. Defaults to "Exit this page expired.". */
8
+ timedOutText?: string;
9
+ /** Announced after one press of Shift. Defaults to "Shift, press 2 more times to exit.". */
10
+ pressTwoMoreTimesText?: string;
11
+ /** Announced after two presses of Shift. Defaults to "Shift, press 1 more time to exit.". */
12
+ pressOneMoreTimeText?: string;
13
+ /** Classes for the indicator while counting presses. */
14
+ indicatorVisibleClass?: string;
15
+ /** Classes for each light of the indicator once pressed. */
16
+ lightOnClass?: string;
17
+ /** Classes for `body` that hide the page behind the overlay. */
18
+ hideContentClass?: string;
19
+ /** Classes for the overlay. Without them, inline styles cover the page. */
20
+ overlayClass?: string;
21
+ };
22
+ export declare function Root({ activatedText, timedOutText, pressTwoMoreTimesText, pressOneMoreTimeText, indicatorVisibleClass, lightOnClass, hideContentClass, overlayClass, ...props }: RootProps): React.DOMElement<{
23
+ activated: string;
24
+ 'timed-out': string;
25
+ 'press-two-more-times': string;
26
+ 'press-one-more-time': string;
27
+ 'indicator-visible-class': string;
28
+ 'light-on-class': string;
29
+ 'hide-content-class': string;
30
+ 'overlay-class': string;
31
+ suppressHydrationWarning: boolean;
32
+ defaultChecked?: boolean;
33
+ defaultValue?: string | number | readonly string[];
34
+ suppressContentEditableWarning?: boolean;
35
+ accessKey?: string;
36
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {});
37
+ autoFocus?: boolean;
38
+ className?: string;
39
+ contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only";
40
+ contextMenu?: string;
41
+ dir?: string;
42
+ draggable?: boolean | "false" | "true";
43
+ enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send";
44
+ hidden?: boolean;
45
+ id?: string;
46
+ lang?: string;
47
+ nonce?: string;
48
+ slot?: string;
49
+ spellCheck?: boolean | "false" | "true";
50
+ style?: React.CSSProperties;
51
+ tabIndex?: number;
52
+ title?: string;
53
+ translate?: "yes" | "no";
54
+ radioGroup?: string;
55
+ role?: React.AriaRole;
56
+ about?: string;
57
+ content?: string;
58
+ datatype?: string;
59
+ inlist?: any;
60
+ prefix?: string;
61
+ property?: string;
62
+ rel?: string;
63
+ resource?: string;
64
+ rev?: string;
65
+ typeof?: string;
66
+ vocab?: string;
67
+ autoCorrect?: string;
68
+ autoSave?: string;
69
+ color?: string;
70
+ itemProp?: string;
71
+ itemScope?: boolean;
72
+ itemType?: string;
73
+ itemID?: string;
74
+ itemRef?: string;
75
+ results?: number;
76
+ security?: string;
77
+ unselectable?: "off" | "on";
78
+ popover?: "" | "auto" | "manual" | "hint";
79
+ popoverTargetAction?: "toggle" | "show" | "hide";
80
+ popoverTarget?: string;
81
+ inert?: boolean;
82
+ inputMode?: "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal";
83
+ is?: string;
84
+ exportparts?: string;
85
+ part?: string;
86
+ "aria-activedescendant"?: string;
87
+ "aria-atomic"?: boolean | "false" | "true";
88
+ "aria-autocomplete"?: "none" | "list" | "inline" | "both";
89
+ "aria-braillelabel"?: string;
90
+ "aria-brailleroledescription"?: string;
91
+ "aria-busy"?: boolean | "false" | "true";
92
+ "aria-checked"?: boolean | "false" | "true" | "mixed";
93
+ "aria-colcount"?: number;
94
+ "aria-colindex"?: number;
95
+ "aria-colindextext"?: string;
96
+ "aria-colspan"?: number;
97
+ "aria-controls"?: string;
98
+ "aria-current"?: boolean | "time" | "false" | "true" | "page" | "step" | "location" | "date";
99
+ "aria-describedby"?: string;
100
+ "aria-description"?: string;
101
+ "aria-details"?: string;
102
+ "aria-disabled"?: boolean | "false" | "true";
103
+ "aria-dropeffect"?: "link" | "copy" | "none" | "execute" | "move" | "popup";
104
+ "aria-errormessage"?: string;
105
+ "aria-expanded"?: boolean | "false" | "true";
106
+ "aria-flowto"?: string;
107
+ "aria-grabbed"?: boolean | "false" | "true";
108
+ "aria-haspopup"?: boolean | "dialog" | "menu" | "false" | "true" | "grid" | "listbox" | "tree";
109
+ "aria-hidden"?: boolean | "false" | "true";
110
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling";
111
+ "aria-keyshortcuts"?: string;
112
+ "aria-label"?: string;
113
+ "aria-labelledby"?: string;
114
+ "aria-level"?: number;
115
+ "aria-live"?: "off" | "assertive" | "polite";
116
+ "aria-modal"?: boolean | "false" | "true";
117
+ "aria-multiline"?: boolean | "false" | "true";
118
+ "aria-multiselectable"?: boolean | "false" | "true";
119
+ "aria-orientation"?: "horizontal" | "vertical";
120
+ "aria-owns"?: string;
121
+ "aria-placeholder"?: string;
122
+ "aria-posinset"?: number;
123
+ "aria-pressed"?: boolean | "false" | "true" | "mixed";
124
+ "aria-readonly"?: boolean | "false" | "true";
125
+ "aria-relevant"?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
126
+ "aria-required"?: boolean | "false" | "true";
127
+ "aria-roledescription"?: string;
128
+ "aria-rowcount"?: number;
129
+ "aria-rowindex"?: number;
130
+ "aria-rowindextext"?: string;
131
+ "aria-rowspan"?: number;
132
+ "aria-selected"?: boolean | "false" | "true";
133
+ "aria-setsize"?: number;
134
+ "aria-sort"?: "none" | "ascending" | "descending" | "other";
135
+ "aria-valuemax"?: number;
136
+ "aria-valuemin"?: number;
137
+ "aria-valuenow"?: number;
138
+ "aria-valuetext"?: string;
139
+ children?: React.ReactNode;
140
+ dangerouslySetInnerHTML?: {
141
+ __html: string | TrustedHTML;
142
+ };
143
+ onCopy?: React.ClipboardEventHandler<HTMLElement>;
144
+ onCopyCapture?: React.ClipboardEventHandler<HTMLElement>;
145
+ onCut?: React.ClipboardEventHandler<HTMLElement>;
146
+ onCutCapture?: React.ClipboardEventHandler<HTMLElement>;
147
+ onPaste?: React.ClipboardEventHandler<HTMLElement>;
148
+ onPasteCapture?: React.ClipboardEventHandler<HTMLElement>;
149
+ onCompositionEnd?: React.CompositionEventHandler<HTMLElement>;
150
+ onCompositionEndCapture?: React.CompositionEventHandler<HTMLElement>;
151
+ onCompositionStart?: React.CompositionEventHandler<HTMLElement>;
152
+ onCompositionStartCapture?: React.CompositionEventHandler<HTMLElement>;
153
+ onCompositionUpdate?: React.CompositionEventHandler<HTMLElement>;
154
+ onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLElement>;
155
+ onFocus?: React.FocusEventHandler<HTMLElement>;
156
+ onFocusCapture?: React.FocusEventHandler<HTMLElement>;
157
+ onBlur?: React.FocusEventHandler<HTMLElement>;
158
+ onBlurCapture?: React.FocusEventHandler<HTMLElement>;
159
+ onChange?: React.ChangeEventHandler<HTMLElement, Element>;
160
+ onChangeCapture?: React.ChangeEventHandler<HTMLElement, Element>;
161
+ onBeforeInput?: React.InputEventHandler<HTMLElement>;
162
+ onBeforeInputCapture?: React.InputEventHandler<HTMLElement>;
163
+ onInput?: React.InputEventHandler<HTMLElement>;
164
+ onInputCapture?: React.InputEventHandler<HTMLElement>;
165
+ onReset?: React.ReactEventHandler<HTMLElement>;
166
+ onResetCapture?: React.ReactEventHandler<HTMLElement>;
167
+ onSubmit?: React.SubmitEventHandler<HTMLElement>;
168
+ onSubmitCapture?: React.SubmitEventHandler<HTMLElement>;
169
+ onInvalid?: React.ReactEventHandler<HTMLElement>;
170
+ onInvalidCapture?: React.ReactEventHandler<HTMLElement>;
171
+ onLoad?: React.ReactEventHandler<HTMLElement>;
172
+ onLoadCapture?: React.ReactEventHandler<HTMLElement>;
173
+ onError?: React.ReactEventHandler<HTMLElement>;
174
+ onErrorCapture?: React.ReactEventHandler<HTMLElement>;
175
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
176
+ onKeyDownCapture?: React.KeyboardEventHandler<HTMLElement>;
177
+ onKeyPress?: React.KeyboardEventHandler<HTMLElement>;
178
+ onKeyPressCapture?: React.KeyboardEventHandler<HTMLElement>;
179
+ onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
180
+ onKeyUpCapture?: React.KeyboardEventHandler<HTMLElement>;
181
+ onAbort?: React.ReactEventHandler<HTMLElement>;
182
+ onAbortCapture?: React.ReactEventHandler<HTMLElement>;
183
+ onCanPlay?: React.ReactEventHandler<HTMLElement>;
184
+ onCanPlayCapture?: React.ReactEventHandler<HTMLElement>;
185
+ onCanPlayThrough?: React.ReactEventHandler<HTMLElement>;
186
+ onCanPlayThroughCapture?: React.ReactEventHandler<HTMLElement>;
187
+ onDurationChange?: React.ReactEventHandler<HTMLElement>;
188
+ onDurationChangeCapture?: React.ReactEventHandler<HTMLElement>;
189
+ onEmptied?: React.ReactEventHandler<HTMLElement>;
190
+ onEmptiedCapture?: React.ReactEventHandler<HTMLElement>;
191
+ onEncrypted?: React.ReactEventHandler<HTMLElement>;
192
+ onEncryptedCapture?: React.ReactEventHandler<HTMLElement>;
193
+ onEnded?: React.ReactEventHandler<HTMLElement>;
194
+ onEndedCapture?: React.ReactEventHandler<HTMLElement>;
195
+ onLoadedData?: React.ReactEventHandler<HTMLElement>;
196
+ onLoadedDataCapture?: React.ReactEventHandler<HTMLElement>;
197
+ onLoadedMetadata?: React.ReactEventHandler<HTMLElement>;
198
+ onLoadedMetadataCapture?: React.ReactEventHandler<HTMLElement>;
199
+ onLoadStart?: React.ReactEventHandler<HTMLElement>;
200
+ onLoadStartCapture?: React.ReactEventHandler<HTMLElement>;
201
+ onPause?: React.ReactEventHandler<HTMLElement>;
202
+ onPauseCapture?: React.ReactEventHandler<HTMLElement>;
203
+ onPlay?: React.ReactEventHandler<HTMLElement>;
204
+ onPlayCapture?: React.ReactEventHandler<HTMLElement>;
205
+ onPlaying?: React.ReactEventHandler<HTMLElement>;
206
+ onPlayingCapture?: React.ReactEventHandler<HTMLElement>;
207
+ onProgress?: React.ReactEventHandler<HTMLElement>;
208
+ onProgressCapture?: React.ReactEventHandler<HTMLElement>;
209
+ onRateChange?: React.ReactEventHandler<HTMLElement>;
210
+ onRateChangeCapture?: React.ReactEventHandler<HTMLElement>;
211
+ onSeeked?: React.ReactEventHandler<HTMLElement>;
212
+ onSeekedCapture?: React.ReactEventHandler<HTMLElement>;
213
+ onSeeking?: React.ReactEventHandler<HTMLElement>;
214
+ onSeekingCapture?: React.ReactEventHandler<HTMLElement>;
215
+ onStalled?: React.ReactEventHandler<HTMLElement>;
216
+ onStalledCapture?: React.ReactEventHandler<HTMLElement>;
217
+ onSuspend?: React.ReactEventHandler<HTMLElement>;
218
+ onSuspendCapture?: React.ReactEventHandler<HTMLElement>;
219
+ onTimeUpdate?: React.ReactEventHandler<HTMLElement>;
220
+ onTimeUpdateCapture?: React.ReactEventHandler<HTMLElement>;
221
+ onVolumeChange?: React.ReactEventHandler<HTMLElement>;
222
+ onVolumeChangeCapture?: React.ReactEventHandler<HTMLElement>;
223
+ onWaiting?: React.ReactEventHandler<HTMLElement>;
224
+ onWaitingCapture?: React.ReactEventHandler<HTMLElement>;
225
+ onAuxClick?: React.MouseEventHandler<HTMLElement>;
226
+ onAuxClickCapture?: React.MouseEventHandler<HTMLElement>;
227
+ onClick?: React.MouseEventHandler<HTMLElement>;
228
+ onClickCapture?: React.MouseEventHandler<HTMLElement>;
229
+ onContextMenu?: React.MouseEventHandler<HTMLElement>;
230
+ onContextMenuCapture?: React.MouseEventHandler<HTMLElement>;
231
+ onDoubleClick?: React.MouseEventHandler<HTMLElement>;
232
+ onDoubleClickCapture?: React.MouseEventHandler<HTMLElement>;
233
+ onDrag?: React.DragEventHandler<HTMLElement>;
234
+ onDragCapture?: React.DragEventHandler<HTMLElement>;
235
+ onDragEnd?: React.DragEventHandler<HTMLElement>;
236
+ onDragEndCapture?: React.DragEventHandler<HTMLElement>;
237
+ onDragEnter?: React.DragEventHandler<HTMLElement>;
238
+ onDragEnterCapture?: React.DragEventHandler<HTMLElement>;
239
+ onDragExit?: React.DragEventHandler<HTMLElement>;
240
+ onDragExitCapture?: React.DragEventHandler<HTMLElement>;
241
+ onDragLeave?: React.DragEventHandler<HTMLElement>;
242
+ onDragLeaveCapture?: React.DragEventHandler<HTMLElement>;
243
+ onDragOver?: React.DragEventHandler<HTMLElement>;
244
+ onDragOverCapture?: React.DragEventHandler<HTMLElement>;
245
+ onDragStart?: React.DragEventHandler<HTMLElement>;
246
+ onDragStartCapture?: React.DragEventHandler<HTMLElement>;
247
+ onDrop?: React.DragEventHandler<HTMLElement>;
248
+ onDropCapture?: React.DragEventHandler<HTMLElement>;
249
+ onMouseDown?: React.MouseEventHandler<HTMLElement>;
250
+ onMouseDownCapture?: React.MouseEventHandler<HTMLElement>;
251
+ onMouseEnter?: React.MouseEventHandler<HTMLElement>;
252
+ onMouseLeave?: React.MouseEventHandler<HTMLElement>;
253
+ onMouseMove?: React.MouseEventHandler<HTMLElement>;
254
+ onMouseMoveCapture?: React.MouseEventHandler<HTMLElement>;
255
+ onMouseOut?: React.MouseEventHandler<HTMLElement>;
256
+ onMouseOutCapture?: React.MouseEventHandler<HTMLElement>;
257
+ onMouseOver?: React.MouseEventHandler<HTMLElement>;
258
+ onMouseOverCapture?: React.MouseEventHandler<HTMLElement>;
259
+ onMouseUp?: React.MouseEventHandler<HTMLElement>;
260
+ onMouseUpCapture?: React.MouseEventHandler<HTMLElement>;
261
+ onSelect?: React.ReactEventHandler<HTMLElement>;
262
+ onSelectCapture?: React.ReactEventHandler<HTMLElement>;
263
+ onTouchCancel?: React.TouchEventHandler<HTMLElement>;
264
+ onTouchCancelCapture?: React.TouchEventHandler<HTMLElement>;
265
+ onTouchEnd?: React.TouchEventHandler<HTMLElement>;
266
+ onTouchEndCapture?: React.TouchEventHandler<HTMLElement>;
267
+ onTouchMove?: React.TouchEventHandler<HTMLElement>;
268
+ onTouchMoveCapture?: React.TouchEventHandler<HTMLElement>;
269
+ onTouchStart?: React.TouchEventHandler<HTMLElement>;
270
+ onTouchStartCapture?: React.TouchEventHandler<HTMLElement>;
271
+ onPointerDown?: React.PointerEventHandler<HTMLElement>;
272
+ onPointerDownCapture?: React.PointerEventHandler<HTMLElement>;
273
+ onPointerMove?: React.PointerEventHandler<HTMLElement>;
274
+ onPointerMoveCapture?: React.PointerEventHandler<HTMLElement>;
275
+ onPointerUp?: React.PointerEventHandler<HTMLElement>;
276
+ onPointerUpCapture?: React.PointerEventHandler<HTMLElement>;
277
+ onPointerCancel?: React.PointerEventHandler<HTMLElement>;
278
+ onPointerCancelCapture?: React.PointerEventHandler<HTMLElement>;
279
+ onPointerEnter?: React.PointerEventHandler<HTMLElement>;
280
+ onPointerLeave?: React.PointerEventHandler<HTMLElement>;
281
+ onPointerOver?: React.PointerEventHandler<HTMLElement>;
282
+ onPointerOverCapture?: React.PointerEventHandler<HTMLElement>;
283
+ onPointerOut?: React.PointerEventHandler<HTMLElement>;
284
+ onPointerOutCapture?: React.PointerEventHandler<HTMLElement>;
285
+ onGotPointerCapture?: React.PointerEventHandler<HTMLElement>;
286
+ onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
287
+ onLostPointerCapture?: React.PointerEventHandler<HTMLElement>;
288
+ onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
289
+ onScroll?: React.UIEventHandler<HTMLElement>;
290
+ onScrollCapture?: React.UIEventHandler<HTMLElement>;
291
+ onScrollEnd?: React.UIEventHandler<HTMLElement>;
292
+ onScrollEndCapture?: React.UIEventHandler<HTMLElement>;
293
+ onWheel?: React.WheelEventHandler<HTMLElement>;
294
+ onWheelCapture?: React.WheelEventHandler<HTMLElement>;
295
+ onAnimationStart?: React.AnimationEventHandler<HTMLElement>;
296
+ onAnimationStartCapture?: React.AnimationEventHandler<HTMLElement>;
297
+ onAnimationEnd?: React.AnimationEventHandler<HTMLElement>;
298
+ onAnimationEndCapture?: React.AnimationEventHandler<HTMLElement>;
299
+ onAnimationIteration?: React.AnimationEventHandler<HTMLElement>;
300
+ onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement>;
301
+ onToggle?: React.ToggleEventHandler<HTMLElement>;
302
+ onBeforeToggle?: React.ToggleEventHandler<HTMLElement>;
303
+ onTransitionCancel?: React.TransitionEventHandler<HTMLElement>;
304
+ onTransitionCancelCapture?: React.TransitionEventHandler<HTMLElement>;
305
+ onTransitionEnd?: React.TransitionEventHandler<HTMLElement>;
306
+ onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement>;
307
+ onTransitionRun?: React.TransitionEventHandler<HTMLElement>;
308
+ onTransitionRunCapture?: React.TransitionEventHandler<HTMLElement>;
309
+ onTransitionStart?: React.TransitionEventHandler<HTMLElement>;
310
+ onTransitionStartCapture?: React.TransitionEventHandler<HTMLElement>;
311
+ }, Element>;
312
+ type PartProps<E extends keyof React.JSX.IntrinsicElements> = ComponentProps<E> & {
313
+ /** Render the only child instead, with this part's props merged onto it. */
314
+ asChild?: boolean;
315
+ };
316
+ export type ButtonProps = PartProps<'a'>;
317
+ /** The link to a safe page, which the element follows once it has hidden the page. */
318
+ export declare function Button({ asChild, ...props }: ButtonProps): React.JSX.Element;
319
+ export type SkipLinkProps = PartProps<'a'>;
320
+ /** A link anywhere on the page, such as in the skip links, that exits too. */
321
+ export declare function SkipLink({ asChild, ...props }: SkipLinkProps): React.JSX.Element;
322
+ export type IndicatorProps = PartProps<'div'>;
323
+ /** Shows how many times Shift has been pressed. Has three Lights unless given children. */
324
+ export declare function Indicator({ asChild, children, ...props }: IndicatorProps): React.JSX.Element;
325
+ export type LightProps = PartProps<'div'>;
326
+ /** One press of Shift. */
327
+ export declare function Light({ asChild, ...props }: LightProps): React.JSX.Element;
328
+ export type StatusProps = PartProps<'span'>;
329
+ /** Tells screen readers how many more presses are needed. Make it visually hidden. */
330
+ export declare function Status({ asChild, children, ...props }: StatusProps): React.JSX.Element;
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+ import { Slot } from '../utils/slot.js';
4
+ import { tagName } from './element.js';
5
+ export { defaultMessages } from './element.js';
6
+ export function Root({ activatedText, timedOutText, pressTwoMoreTimesText, pressOneMoreTimeText, indicatorVisibleClass, lightOnClass, hideContentClass, overlayClass, ...props }) {
7
+ return React.createElement(tagName, {
8
+ ...props,
9
+ activated: activatedText,
10
+ 'timed-out': timedOutText,
11
+ 'press-two-more-times': pressTwoMoreTimesText,
12
+ 'press-one-more-time': pressOneMoreTimeText,
13
+ 'indicator-visible-class': indicatorVisibleClass,
14
+ 'light-on-class': lightOnClass,
15
+ 'hide-content-class': hideContentClass,
16
+ 'overlay-class': overlayClass,
17
+ // The element owns `data-upgraded`.
18
+ suppressHydrationWarning: true,
19
+ });
20
+ }
21
+ /** The link to a safe page, which the element follows once it has hidden the page. */
22
+ export function Button({ asChild, ...props }) {
23
+ const Element = asChild ? Slot : 'a';
24
+ return React.createElement(Element, { "data-exit-this-page-button": "", ...props });
25
+ }
26
+ /** A link anywhere on the page, such as in the skip links, that exits too. */
27
+ export function SkipLink({ asChild, ...props }) {
28
+ const Element = asChild ? Slot : 'a';
29
+ return React.createElement(Element, { "data-exit-this-page-skiplink": "", ...props });
30
+ }
31
+ /** Shows how many times Shift has been pressed. Has three Lights unless given children. */
32
+ export function Indicator({ asChild, children, ...props }) {
33
+ const Element = asChild ? Slot : 'div';
34
+ return (
35
+ // The element owns `data-visible` and its classes.
36
+ React.createElement(Element, { "data-exit-this-page-indicator": "", "aria-hidden": "true", suppressHydrationWarning: true, ...props }, children !== null && children !== void 0 ? children : (React.createElement(React.Fragment, null,
37
+ React.createElement(Light, null),
38
+ React.createElement(Light, null),
39
+ React.createElement(Light, null)))));
40
+ }
41
+ /** One press of Shift. */
42
+ export function Light({ asChild, ...props }) {
43
+ const Element = asChild ? Slot : 'div';
44
+ // The element owns `data-on` and its classes.
45
+ return React.createElement(Element, { "data-exit-this-page-light": "", suppressHydrationWarning: true, ...props });
46
+ }
47
+ /** Tells screen readers how many more presses are needed. Make it visually hidden. */
48
+ export function Status({ asChild, children, ...props }) {
49
+ const Element = asChild ? Slot : 'span';
50
+ // The element owns its text. A string child, even an empty one, is hydrated as text, so text the
51
+ // element set before hydration is kept rather than being a mismatch.
52
+ return (React.createElement(Element, { "data-exit-this-page-status": "", role: "status", suppressHydrationWarning: true, ...props }, children !== null && children !== void 0 ? children : ''));
53
+ }
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js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AAK,GAAI,CAAC;AAChE,CAAC;AAID,2FAA2F;AAC3F,MAAM,UAAU,SAAS,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IACvE,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACvC,OAAO;IACL,mDAAmD;IACnD,oBAAC,OAAO,qCAA+B,EAAE,iBAAa,MAAM,EAAC,wBAAwB,WAAK,KAAK,IAC5F,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,CACX;QACE,oBAAC,KAAK,OAAG;QACT,oBAAC,KAAK,OAAG;QACT,oBAAC,KAAK,OAAG,CACR,CACJ,CACO,CACX,CAAC;AACJ,CAAC;AAID,0BAA0B;AAC1B,MAAM,UAAU,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAc;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACvC,8CAA8C;IAC9C,OAAO,oBAAC,OAAO,iCAA2B,EAAE,EAAC,wBAAwB,WAAK,KAAK,GAAI,CAAC;AACtF,CAAC;AAID,sFAAsF;AACtF,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAe;IACjE,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACxC,iGAAiG;IACjG,qEAAqE;IACrE,OAAO,CACL,oBAAC,OAAO,kCAA4B,EAAE,EAAC,IAAI,EAAC,QAAQ,EAAC,wBAAwB,WAAK,KAAK,IACpF,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CACP,CACX,CAAC;AACJ,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\nexport { defaultMessages, type ExitThisPageElement, type MessageName } from './element.js';\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"]}