@govuk-react/primitives 0.2.0 → 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.
- package/dist/{accordion-element.d.ts → accordion/element.d.ts} +2 -5
- package/dist/accordion/element.js +302 -0
- package/dist/accordion/element.js.map +1 -0
- package/dist/accordion/index.d.ts +74 -0
- package/dist/accordion/index.js +138 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/auto-focus/element.d.ts +1 -0
- package/dist/auto-focus/element.js +75 -0
- package/dist/auto-focus/element.js.map +1 -0
- package/dist/{index-Bul0NJh_.d.ts → auto-focus/index.d.ts} +27 -40
- package/dist/auto-focus/index.js +29 -0
- package/dist/{chunk-6ZFU4VYW.js.map → auto-focus/index.js.map} +1 -1
- package/dist/{autocomplete-element.d.ts → autocomplete/element.d.ts} +4 -7
- package/dist/autocomplete/element.js +597 -0
- package/dist/autocomplete/element.js.map +1 -0
- package/dist/{index-D7lMYMUR.d.ts → autocomplete/index.d.ts} +34 -57
- package/dist/autocomplete/index.js +108 -0
- package/dist/autocomplete/index.js.map +1 -0
- package/dist/button/element.d.ts +1 -0
- package/dist/button/element.js +59 -0
- package/dist/button/element.js.map +1 -0
- package/dist/button/index.d.ts +10 -0
- package/dist/button/index.js +9 -0
- package/dist/button/index.js.map +1 -0
- package/dist/{character-count-element.d.ts → character-count/element.d.ts} +2 -5
- package/dist/character-count/element.js +287 -0
- package/dist/character-count/element.js.map +1 -0
- package/dist/character-count/index.d.ts +57 -0
- package/dist/character-count/index.js +79 -0
- package/dist/character-count/index.js.map +1 -0
- package/dist/character-count/messages.d.ts +20 -0
- package/dist/character-count/messages.js +54 -0
- package/dist/character-count/messages.js.map +1 -0
- package/dist/choices/element.d.ts +5 -0
- package/dist/choices/element.js +202 -0
- package/dist/choices/element.js.map +1 -0
- package/dist/{index-WuGvkTxu.d.ts → choices/index.d.ts} +30 -44
- package/dist/choices/index.js +37 -0
- package/dist/choices/index.js.map +1 -0
- package/dist/{disclosure-element.d.ts → disclosure/element.d.ts} +2 -5
- package/dist/disclosure/element.js +123 -0
- package/dist/disclosure/element.js.map +1 -0
- package/dist/{index-D4Gzyvfu.d.ts → disclosure/index.d.ts} +40 -54
- package/dist/disclosure/index.js +66 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/exit-this-page/element.d.ts +19 -0
- package/dist/exit-this-page/element.js +201 -0
- package/dist/exit-this-page/element.js.map +1 -0
- package/dist/{index-qF0jIQCW.d.ts → exit-this-page/index.d.ts} +36 -60
- package/dist/exit-this-page/index.js +54 -0
- package/dist/exit-this-page/index.js.map +1 -0
- package/dist/{file-upload-element.d.ts → file-upload/element.d.ts} +5 -9
- package/dist/file-upload/element.js +270 -0
- package/dist/file-upload/element.js.map +1 -0
- package/dist/file-upload/index.d.ts +46 -0
- package/dist/file-upload/index.js +65 -0
- package/dist/file-upload/index.js.map +1 -0
- package/dist/focus-links/element.d.ts +1 -0
- package/dist/focus-links/element.js +90 -0
- package/dist/focus-links/element.js.map +1 -0
- package/dist/{index-BR3MAGF8.d.ts → focus-links/index.d.ts} +24 -35
- package/dist/focus-links/index.js +7 -0
- package/dist/focus-links/index.js.map +1 -0
- package/dist/index.d.ts +13 -17
- package/dist/index.js +13 -72
- package/dist/index.js.map +1 -1
- package/dist/inline/accordion-element.js +1 -1
- package/dist/inline/auto-focus-element.js +1 -1
- package/dist/inline/autocomplete-element.js +1 -1
- package/dist/inline/character-count-element.js +1 -1
- package/dist/inline/choices-element.js +1 -1
- package/dist/inline/disclosure-element.js +1 -1
- package/dist/inline/exit-this-page-element.js +1 -1
- package/dist/inline/file-upload-element.js +1 -1
- package/dist/inline/focus-links-element.js +1 -1
- package/dist/inline/modal-element.js +1 -1
- package/dist/inline/password-input-element.js +1 -1
- package/dist/inline/tabs-element.js +1 -1
- package/dist/inline-script/index.d.ts +26 -0
- package/dist/inline-script/index.js +31 -0
- package/dist/inline-script/index.js.map +1 -0
- package/dist/{modal-element.d.ts → modal/element.d.ts} +2 -4
- package/dist/modal/element.js +114 -0
- package/dist/modal/element.js.map +1 -0
- package/dist/modal/index.d.ts +36 -0
- package/dist/modal/index.js +109 -0
- package/dist/modal/index.js.map +1 -0
- package/dist/password-input/element.d.ts +1 -0
- package/dist/password-input/element.js +134 -0
- package/dist/password-input/element.js.map +1 -0
- package/dist/{index-sEHnx4-M.d.ts → password-input/index.d.ts} +32 -48
- package/dist/password-input/index.js +35 -0
- package/dist/password-input/index.js.map +1 -0
- package/dist/{tabs-element.d.ts → tabs/element.d.ts} +2 -5
- package/dist/tabs/element.js +416 -0
- package/dist/tabs/element.js.map +1 -0
- package/dist/tabs/index.d.ts +83 -0
- package/dist/tabs/index.js +138 -0
- package/dist/tabs/index.js.map +1 -0
- package/dist/utils/dom.d.ts +9 -0
- package/dist/utils/dom.js +27 -0
- package/dist/utils/dom.js.map +1 -0
- package/dist/utils/on-property-set.d.ts +9 -0
- package/dist/utils/on-property-set.js +38 -0
- package/dist/utils/on-property-set.js.map +1 -0
- package/dist/utils/set-focus.d.ts +11 -0
- package/dist/utils/set-focus.js +38 -0
- package/dist/utils/set-focus.js.map +1 -0
- package/dist/utils/set-up-when-ready.d.ts +6 -0
- package/dist/utils/set-up-when-ready.js +16 -0
- package/dist/utils/set-up-when-ready.js.map +1 -0
- package/dist/utils/slot.d.ts +13 -0
- package/dist/utils/slot.js +40 -0
- package/dist/utils/slot.js.map +1 -0
- package/dist/utils/translation.d.ts +13 -0
- package/dist/utils/translation.js +57 -0
- package/dist/utils/translation.js.map +1 -0
- package/package.json +11 -4
- package/dist/accordion-element.js +0 -9
- package/dist/accordion-element.js.map +0 -1
- package/dist/accordion.d.ts +0 -2
- package/dist/accordion.js +0 -34
- package/dist/accordion.js.map +0 -1
- package/dist/auto-focus-element.d.ts +0 -3
- package/dist/auto-focus-element.js +0 -10
- package/dist/auto-focus-element.js.map +0 -1
- package/dist/auto-focus.d.ts +0 -2
- package/dist/auto-focus.js +0 -15
- package/dist/auto-focus.js.map +0 -1
- package/dist/autocomplete-element.js +0 -12
- package/dist/autocomplete-element.js.map +0 -1
- package/dist/autocomplete.d.ts +0 -4
- package/dist/autocomplete.js +0 -25
- package/dist/autocomplete.js.map +0 -1
- package/dist/button-element.d.ts +0 -2
- package/dist/button-element.js +0 -3
- package/dist/button-element.js.map +0 -1
- package/dist/button.d.ts +0 -2
- package/dist/button.js +0 -12
- package/dist/button.js.map +0 -1
- package/dist/character-count-element.js +0 -10
- package/dist/character-count-element.js.map +0 -1
- package/dist/character-count.d.ts +0 -3
- package/dist/character-count.js +0 -26
- package/dist/character-count.js.map +0 -1
- package/dist/choices-element.d.ts +0 -8
- package/dist/choices-element.js +0 -9
- package/dist/choices-element.js.map +0 -1
- package/dist/choices.d.ts +0 -2
- package/dist/choices.js +0 -16
- package/dist/choices.js.map +0 -1
- package/dist/chunk-2IHAQAYF.js +0 -23
- package/dist/chunk-2IHAQAYF.js.map +0 -1
- package/dist/chunk-2ZJVSNC2.js +0 -31
- package/dist/chunk-2ZJVSNC2.js.map +0 -1
- package/dist/chunk-47NMY4SS.js +0 -108
- package/dist/chunk-47NMY4SS.js.map +0 -1
- package/dist/chunk-4XAR4FFG.js +0 -83
- package/dist/chunk-4XAR4FFG.js.map +0 -1
- package/dist/chunk-5HWRMQK2.js +0 -91
- package/dist/chunk-5HWRMQK2.js.map +0 -1
- package/dist/chunk-6ZFU4VYW.js +0 -41
- package/dist/chunk-B2I4J5NL.js +0 -264
- package/dist/chunk-B2I4J5NL.js.map +0 -1
- package/dist/chunk-DPERPCUH.js +0 -188
- package/dist/chunk-DPERPCUH.js.map +0 -1
- package/dist/chunk-ECYGKE4D.js +0 -168
- package/dist/chunk-ECYGKE4D.js.map +0 -1
- package/dist/chunk-ESBMTI25.js +0 -11
- package/dist/chunk-ESBMTI25.js.map +0 -1
- package/dist/chunk-ET7DCQM7.js +0 -133
- package/dist/chunk-ET7DCQM7.js.map +0 -1
- package/dist/chunk-F5XFC4QJ.js +0 -177
- package/dist/chunk-F5XFC4QJ.js.map +0 -1
- package/dist/chunk-GVGBDSDN.js +0 -78
- package/dist/chunk-GVGBDSDN.js.map +0 -1
- package/dist/chunk-IZQ2C4BC.js +0 -351
- package/dist/chunk-IZQ2C4BC.js.map +0 -1
- package/dist/chunk-L7E6GN2D.js +0 -87
- package/dist/chunk-L7E6GN2D.js.map +0 -1
- package/dist/chunk-LWIA644X.js +0 -34
- package/dist/chunk-LWIA644X.js.map +0 -1
- package/dist/chunk-NX4B3NKM.js +0 -35
- package/dist/chunk-NX4B3NKM.js.map +0 -1
- package/dist/chunk-PNWPGD7B.js +0 -68
- package/dist/chunk-PNWPGD7B.js.map +0 -1
- package/dist/chunk-QLQ6O7OW.js +0 -111
- package/dist/chunk-QLQ6O7OW.js.map +0 -1
- package/dist/chunk-RDUPELOK.js +0 -55
- package/dist/chunk-RDUPELOK.js.map +0 -1
- package/dist/chunk-RPMHI67T.js +0 -104
- package/dist/chunk-RPMHI67T.js.map +0 -1
- package/dist/chunk-TE4RUYVK.js +0 -97
- package/dist/chunk-TE4RUYVK.js.map +0 -1
- package/dist/chunk-TJVBFRIE.js +0 -60
- package/dist/chunk-TJVBFRIE.js.map +0 -1
- package/dist/chunk-U5OKNKYC.js +0 -510
- package/dist/chunk-U5OKNKYC.js.map +0 -1
- package/dist/chunk-UXJO4AJP.js +0 -290
- package/dist/chunk-UXJO4AJP.js.map +0 -1
- package/dist/chunk-VNXXENCU.js +0 -39
- package/dist/chunk-VNXXENCU.js.map +0 -1
- package/dist/chunk-XGK73UCD.js +0 -62
- package/dist/chunk-XGK73UCD.js.map +0 -1
- package/dist/chunk-XJYLFTYE.js +0 -157
- package/dist/chunk-XJYLFTYE.js.map +0 -1
- package/dist/chunk-YCESNTXQ.js +0 -241
- package/dist/chunk-YCESNTXQ.js.map +0 -1
- package/dist/chunk-ZTJLVNR4.js +0 -62
- package/dist/chunk-ZTJLVNR4.js.map +0 -1
- package/dist/disclosure-element.js +0 -9
- package/dist/disclosure-element.js.map +0 -1
- package/dist/disclosure.d.ts +0 -2
- package/dist/disclosure.js +0 -16
- package/dist/disclosure.js.map +0 -1
- package/dist/exit-this-page-element.d.ts +0 -22
- package/dist/exit-this-page-element.js +0 -13
- package/dist/exit-this-page-element.js.map +0 -1
- package/dist/exit-this-page.d.ts +0 -3
- package/dist/exit-this-page.js +0 -25
- package/dist/exit-this-page.js.map +0 -1
- package/dist/file-upload-element.js +0 -14
- package/dist/file-upload-element.js.map +0 -1
- package/dist/file-upload.d.ts +0 -3
- package/dist/file-upload.js +0 -25
- package/dist/file-upload.js.map +0 -1
- package/dist/focus-links-element.d.ts +0 -3
- package/dist/focus-links-element.js +0 -10
- package/dist/focus-links-element.js.map +0 -1
- package/dist/focus-links.d.ts +0 -2
- package/dist/focus-links.js +0 -12
- package/dist/focus-links.js.map +0 -1
- package/dist/index--FxJgSOS.d.ts +0 -108
- package/dist/index-CikOyFud.d.ts +0 -54
- package/dist/index-D8N5vxTL.d.ts +0 -90
- package/dist/index-DMWpkC_d.d.ts +0 -105
- package/dist/index-DN7fGMc3.d.ts +0 -20
- package/dist/index-DPXR1Yua.d.ts +0 -69
- package/dist/inline-script.d.ts +0 -29
- package/dist/inline-script.js +0 -63
- package/dist/inline-script.js.map +0 -1
- package/dist/modal-element.js +0 -11
- package/dist/modal-element.js.map +0 -1
- package/dist/modal.d.ts +0 -2
- package/dist/modal.js +0 -20
- package/dist/modal.js.map +0 -1
- package/dist/password-input-element.d.ts +0 -3
- package/dist/password-input-element.js +0 -9
- package/dist/password-input-element.js.map +0 -1
- package/dist/password-input.d.ts +0 -2
- package/dist/password-input.js +0 -18
- package/dist/password-input.js.map +0 -1
- package/dist/tabs-element.js +0 -9
- package/dist/tabs-element.js.map +0 -1
- package/dist/tabs.d.ts +0 -2
- package/dist/tabs.js +0 -28
- package/dist/tabs.js.map +0 -1
- package/dist/translation-BnpO2mN2.d.ts +0 -4
package/dist/chunk-UXJO4AJP.js
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import {
|
|
3
|
-
translate,
|
|
4
|
-
translationAttributeNames,
|
|
5
|
-
translationAttributes,
|
|
6
|
-
translationFromAttributes,
|
|
7
|
-
withLocale
|
|
8
|
-
} from "./chunk-RDUPELOK.js";
|
|
9
|
-
|
|
10
|
-
// src/character-count/messages.ts
|
|
11
|
-
var messageNames = [
|
|
12
|
-
"characters-under-limit",
|
|
13
|
-
"characters-at-limit",
|
|
14
|
-
"characters-over-limit",
|
|
15
|
-
"words-under-limit",
|
|
16
|
-
"words-at-limit",
|
|
17
|
-
"words-over-limit"
|
|
18
|
-
];
|
|
19
|
-
var defaultMessages = {
|
|
20
|
-
"characters-under-limit": {
|
|
21
|
-
one: "You have %{count} character remaining",
|
|
22
|
-
other: "You have %{count} characters remaining"
|
|
23
|
-
},
|
|
24
|
-
"characters-at-limit": "You have 0 characters remaining",
|
|
25
|
-
"characters-over-limit": {
|
|
26
|
-
one: "You have %{count} character too many",
|
|
27
|
-
other: "You have %{count} characters too many"
|
|
28
|
-
},
|
|
29
|
-
"words-under-limit": { one: "You have %{count} word remaining", other: "You have %{count} words remaining" },
|
|
30
|
-
"words-at-limit": "You have 0 words remaining",
|
|
31
|
-
"words-over-limit": { one: "You have %{count} word too many", other: "You have %{count} words too many" }
|
|
32
|
-
};
|
|
33
|
-
var messageAttributes = (name, message) => translationAttributes(name, message);
|
|
34
|
-
var messageFromAttributes = (element, name) => translationFromAttributes(element, name);
|
|
35
|
-
function countOf(text, countType, locale) {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
if (countType === "length") return text.length;
|
|
38
|
-
if (typeof Intl.Segmenter !== "function") {
|
|
39
|
-
return countType === "words" ? (_b = (_a = text.match(/\S+/g)) == null ? void 0 : _a.length) != null ? _b : 0 : Array.from(text).length;
|
|
40
|
-
}
|
|
41
|
-
const segmenter = withLocale(
|
|
42
|
-
locale,
|
|
43
|
-
(l) => new Intl.Segmenter(l, { granularity: countType === "words" ? "word" : "grapheme" })
|
|
44
|
-
);
|
|
45
|
-
const segments = Array.from(segmenter.segment(text));
|
|
46
|
-
return countType === "words" ? segments.filter((segment) => segment.isWordLike).length : segments.length;
|
|
47
|
-
}
|
|
48
|
-
function countMessage(remaining, countType, messages, locale) {
|
|
49
|
-
var _a;
|
|
50
|
-
const state = remaining < 0 ? "over" : remaining === 0 ? "at" : "under";
|
|
51
|
-
const name = `${countType === "words" ? "words" : "characters"}-${state}-limit`;
|
|
52
|
-
const message = (_a = messages[name]) != null ? _a : defaultMessages[name];
|
|
53
|
-
return { state, text: translate(message, Math.abs(remaining), locale) };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/character-count/element.ts
|
|
57
|
-
var tagName = "govuk-react-character-count";
|
|
58
|
-
var visuallyHidden = {
|
|
59
|
-
position: "absolute",
|
|
60
|
-
width: "1px",
|
|
61
|
-
height: "1px",
|
|
62
|
-
margin: "0",
|
|
63
|
-
padding: "0",
|
|
64
|
-
overflow: "hidden",
|
|
65
|
-
clip: "rect(0 0 0 0)",
|
|
66
|
-
"clip-path": "inset(50%)",
|
|
67
|
-
border: "0",
|
|
68
|
-
"white-space": "nowrap"
|
|
69
|
-
};
|
|
70
|
-
var classesOf = (attribute) => {
|
|
71
|
-
var _a;
|
|
72
|
-
return (_a = attribute == null ? void 0 : attribute.split(/\s+/).filter(Boolean)) != null ? _a : [];
|
|
73
|
-
};
|
|
74
|
-
var setText = (element, text) => {
|
|
75
|
-
if (element.textContent === text) return;
|
|
76
|
-
const { firstChild } = element;
|
|
77
|
-
if (firstChild instanceof Text && element.childNodes.length === 1) firstChild.nodeValue = text;
|
|
78
|
-
else element.textContent = text;
|
|
79
|
-
};
|
|
80
|
-
var isField = (element) => element instanceof HTMLTextAreaElement || element instanceof HTMLInputElement;
|
|
81
|
-
if (typeof HTMLElement !== "undefined" && typeof customElements !== "undefined") {
|
|
82
|
-
class GovukReactCharacterCount extends HTMLElement {
|
|
83
|
-
constructor() {
|
|
84
|
-
super(...arguments);
|
|
85
|
-
this.currentCount = 0;
|
|
86
|
-
this.onInput = () => {
|
|
87
|
-
this.update();
|
|
88
|
-
this.lastInputTime = Date.now();
|
|
89
|
-
};
|
|
90
|
-
// As in govuk-frontend: while focused, announce the count once the user pauses typing.
|
|
91
|
-
this.onFocus = () => {
|
|
92
|
-
window.clearInterval(this.checker);
|
|
93
|
-
this.checker = window.setInterval(() => {
|
|
94
|
-
if (!this.lastInputTime || Date.now() - 500 >= this.lastInputTime) this.announceIfChanged();
|
|
95
|
-
}, 1e3);
|
|
96
|
-
};
|
|
97
|
-
this.onBlur = () => window.clearInterval(this.checker);
|
|
98
|
-
// A page restored from the back-forward cache, or a browser that restores the field's value.
|
|
99
|
-
this.onPageShow = () => {
|
|
100
|
-
if (!this.input) return;
|
|
101
|
-
this.update();
|
|
102
|
-
this.announceIfChanged();
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
static get observedAttributes() {
|
|
106
|
-
return [
|
|
107
|
-
"maxlength",
|
|
108
|
-
"count-type",
|
|
109
|
-
"threshold",
|
|
110
|
-
"within-limit-class",
|
|
111
|
-
"over-limit-class",
|
|
112
|
-
"below-threshold-class",
|
|
113
|
-
"input-over-limit-class",
|
|
114
|
-
...messageNames.flatMap(translationAttributeNames)
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
get count() {
|
|
118
|
-
return this.input ? this.currentCount : void 0;
|
|
119
|
-
}
|
|
120
|
-
connectedCallback() {
|
|
121
|
-
this.observer = new MutationObserver((records) => {
|
|
122
|
-
if (records.some((record) => record.type === "childList")) this.setup();
|
|
123
|
-
else this.update();
|
|
124
|
-
});
|
|
125
|
-
this.observer.observe(this, {
|
|
126
|
-
childList: true,
|
|
127
|
-
subtree: true,
|
|
128
|
-
attributes: true,
|
|
129
|
-
attributeFilter: ["class", "maxlength"]
|
|
130
|
-
});
|
|
131
|
-
window.addEventListener("pageshow", this.onPageShow);
|
|
132
|
-
this.setup();
|
|
133
|
-
}
|
|
134
|
-
disconnectedCallback() {
|
|
135
|
-
var _a;
|
|
136
|
-
(_a = this.observer) == null ? void 0 : _a.disconnect();
|
|
137
|
-
window.removeEventListener("pageshow", this.onPageShow);
|
|
138
|
-
window.clearInterval(this.checker);
|
|
139
|
-
this.unbind();
|
|
140
|
-
}
|
|
141
|
-
attributeChangedCallback() {
|
|
142
|
-
if (!this.isConnected) return;
|
|
143
|
-
if (!this.input) {
|
|
144
|
-
this.setup();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (this.maxLength === void 0) {
|
|
148
|
-
this.downgrade();
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
this.lastAnnouncedValue = void 0;
|
|
152
|
-
this.update();
|
|
153
|
-
}
|
|
154
|
-
own(selector) {
|
|
155
|
-
return Array.from(this.querySelectorAll(selector)).find(
|
|
156
|
-
(element) => element.closest(tagName) === this
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
get maxLength() {
|
|
160
|
-
const value = Number(this.getAttribute("maxlength"));
|
|
161
|
-
return this.hasAttribute("maxlength") && Number.isFinite(value) ? value : void 0;
|
|
162
|
-
}
|
|
163
|
-
get countType() {
|
|
164
|
-
const type = this.getAttribute("count-type");
|
|
165
|
-
return type === "characters" || type === "words" ? type : "length";
|
|
166
|
-
}
|
|
167
|
-
// As govuk-frontend: the field's closest `lang`, which can be inside the element, or English.
|
|
168
|
-
get locale() {
|
|
169
|
-
var _a, _b;
|
|
170
|
-
return ((_b = ((_a = this.input) != null ? _a : this).closest("[lang]")) == null ? void 0 : _b.getAttribute("lang")) || "en";
|
|
171
|
-
}
|
|
172
|
-
setup() {
|
|
173
|
-
const input = this.own("[data-character-count-input]");
|
|
174
|
-
if (!isField(input) || this.maxLength === void 0) return;
|
|
175
|
-
const fresh = input !== this.input;
|
|
176
|
-
if (fresh) {
|
|
177
|
-
this.unbind();
|
|
178
|
-
this.input = input;
|
|
179
|
-
input.addEventListener("input", this.onInput);
|
|
180
|
-
input.addEventListener("focus", this.onFocus);
|
|
181
|
-
input.addEventListener("blur", this.onBlur);
|
|
182
|
-
input.removeAttribute("maxlength");
|
|
183
|
-
this.lastAnnouncedValue = void 0;
|
|
184
|
-
}
|
|
185
|
-
this.dataset.upgraded = "";
|
|
186
|
-
const description = this.own("[data-character-count-description]");
|
|
187
|
-
if (description && !this.hasAttribute("hidden-description-class")) {
|
|
188
|
-
Object.entries(visuallyHidden).forEach(([name, value]) => description.style.setProperty(name, value));
|
|
189
|
-
}
|
|
190
|
-
[this.own("[data-character-count-status]"), this.own("[data-character-count-sr-status]")].forEach((status) => {
|
|
191
|
-
if (status) status.hidden = false;
|
|
192
|
-
});
|
|
193
|
-
this.update();
|
|
194
|
-
if (fresh) this.announceIfChanged();
|
|
195
|
-
}
|
|
196
|
-
unbind() {
|
|
197
|
-
const { input } = this;
|
|
198
|
-
if (!input) return;
|
|
199
|
-
input.removeEventListener("input", this.onInput);
|
|
200
|
-
input.removeEventListener("focus", this.onFocus);
|
|
201
|
-
input.removeEventListener("blur", this.onBlur);
|
|
202
|
-
window.clearInterval(this.checker);
|
|
203
|
-
this.input = void 0;
|
|
204
|
-
}
|
|
205
|
-
/** Back to the markup without JavaScript, when the limit is removed. */
|
|
206
|
-
downgrade() {
|
|
207
|
-
const { input } = this;
|
|
208
|
-
if (!input) return;
|
|
209
|
-
classesOf(this.getAttribute("input-over-limit-class")).forEach((name) => input.classList.toggle(name, false));
|
|
210
|
-
this.unbind();
|
|
211
|
-
delete this.dataset.upgraded;
|
|
212
|
-
const description = this.own("[data-character-count-description]");
|
|
213
|
-
if (description) {
|
|
214
|
-
if (this.hasAttribute("hidden-description-class")) {
|
|
215
|
-
classesOf(this.getAttribute("hidden-description-class")).forEach(
|
|
216
|
-
(name) => description.classList.toggle(name, false)
|
|
217
|
-
);
|
|
218
|
-
} else {
|
|
219
|
-
Object.keys(visuallyHidden).forEach((name) => description.style.removeProperty(name));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
[this.own("[data-character-count-status]"), this.own("[data-character-count-sr-status]")].forEach((status) => {
|
|
223
|
-
if (status) status.hidden = true;
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
update() {
|
|
227
|
-
if (!this.input) return;
|
|
228
|
-
this.input.removeAttribute("maxlength");
|
|
229
|
-
this.currentCount = countOf(this.input.value, this.countType, this.locale);
|
|
230
|
-
this.render();
|
|
231
|
-
}
|
|
232
|
-
message() {
|
|
233
|
-
var _a;
|
|
234
|
-
const messages = Object.fromEntries(messageNames.map((name) => [name, messageFromAttributes(this, name)]));
|
|
235
|
-
return countMessage(((_a = this.maxLength) != null ? _a : Infinity) - this.currentCount, this.countType, messages, this.locale);
|
|
236
|
-
}
|
|
237
|
-
get belowThreshold() {
|
|
238
|
-
var _a;
|
|
239
|
-
const threshold = Number(this.getAttribute("threshold"));
|
|
240
|
-
if (!threshold) return false;
|
|
241
|
-
return this.currentCount < ((_a = this.maxLength) != null ? _a : Infinity) * threshold / 100;
|
|
242
|
-
}
|
|
243
|
-
/** The visible count and the classes, from the current count. */
|
|
244
|
-
render() {
|
|
245
|
-
const { input } = this;
|
|
246
|
-
if (!input) return;
|
|
247
|
-
const { state, text } = this.message();
|
|
248
|
-
const over = state === "over";
|
|
249
|
-
const description = this.own("[data-character-count-description]");
|
|
250
|
-
classesOf(this.getAttribute("hidden-description-class")).forEach(
|
|
251
|
-
(name) => description == null ? void 0 : description.classList.toggle(name, true)
|
|
252
|
-
);
|
|
253
|
-
classesOf(this.getAttribute("input-over-limit-class")).forEach((name) => input.classList.toggle(name, over));
|
|
254
|
-
const belowThreshold = this.belowThreshold;
|
|
255
|
-
const srStatus = this.own("[data-character-count-sr-status]");
|
|
256
|
-
if (belowThreshold) srStatus == null ? void 0 : srStatus.setAttribute("aria-hidden", "true");
|
|
257
|
-
else srStatus == null ? void 0 : srStatus.removeAttribute("aria-hidden");
|
|
258
|
-
const status = this.own("[data-character-count-status]");
|
|
259
|
-
if (!status) return;
|
|
260
|
-
status.dataset.state = state;
|
|
261
|
-
status.toggleAttribute("data-below-threshold", belowThreshold);
|
|
262
|
-
classesOf(this.getAttribute("below-threshold-class")).forEach(
|
|
263
|
-
(name) => status.classList.toggle(name, belowThreshold)
|
|
264
|
-
);
|
|
265
|
-
classesOf(this.getAttribute("within-limit-class")).forEach((name) => status.classList.toggle(name, !over));
|
|
266
|
-
classesOf(this.getAttribute("over-limit-class")).forEach((name) => status.classList.toggle(name, over));
|
|
267
|
-
setText(status, text);
|
|
268
|
-
}
|
|
269
|
-
/** Updates the count for screen readers, if the field changed since it last did. */
|
|
270
|
-
announceIfChanged() {
|
|
271
|
-
const { input } = this;
|
|
272
|
-
const status = this.own("[data-character-count-sr-status]");
|
|
273
|
-
if (!input || !status) return;
|
|
274
|
-
if (input.value === this.lastAnnouncedValue) return;
|
|
275
|
-
this.lastAnnouncedValue = input.value;
|
|
276
|
-
const { state, text } = this.message();
|
|
277
|
-
status.dataset.state = state;
|
|
278
|
-
setText(status, text);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (!customElements.get(tagName)) customElements.define(tagName, GovukReactCharacterCount);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export {
|
|
285
|
-
messageAttributes,
|
|
286
|
-
countOf,
|
|
287
|
-
countMessage,
|
|
288
|
-
tagName
|
|
289
|
-
};
|
|
290
|
-
//# sourceMappingURL=chunk-UXJO4AJP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/character-count/messages.ts","../src/character-count/element.ts"],"sourcesContent":["/*\n * Counting and count messages, shared by the <govuk-react-character-count> element and its React\n * parts, so the server can render the message the element starts with.\n */\n\nimport {\n translate,\n translationAttributes,\n translationFromAttributes,\n withLocale,\n type Translation,\n} from '../utils/translation';\n\nexport type { Translation };\n\nexport type CountType = 'length' | 'characters' | 'words';\n\nexport const messageNames = [\n 'characters-under-limit',\n 'characters-at-limit',\n 'characters-over-limit',\n 'words-under-limit',\n 'words-at-limit',\n 'words-over-limit',\n] as const;\n\nexport type MessageName = (typeof messageNames)[number];\n\n/** govuk-frontend's English messages. `%{count}` is replaced with the number. */\nexport const defaultMessages: Record<MessageName, Translation> = {\n 'characters-under-limit': {\n one: 'You have %{count} character remaining',\n other: 'You have %{count} characters remaining',\n },\n 'characters-at-limit': 'You have 0 characters remaining',\n 'characters-over-limit': {\n one: 'You have %{count} character too many',\n other: 'You have %{count} characters too many',\n },\n 'words-under-limit': { one: 'You have %{count} word remaining', other: 'You have %{count} words remaining' },\n 'words-at-limit': 'You have 0 words remaining',\n 'words-over-limit': { one: 'You have %{count} word too many', other: 'You have %{count} words too many' },\n};\n\n/** The attributes for a message: the message itself, or one attribute for each plural form. */\nexport const messageAttributes = (name: MessageName, message: Translation | undefined) =>\n translationAttributes(name, message);\n\n/** Reads a message back from attributes written by `messageAttributes`. */\nexport const messageFromAttributes = (element: Element, name: MessageName) => translationFromAttributes(element, name);\n\n/** Counts the text as govuk-frontend does: UTF-16 code units, characters as users see them, or words. */\nexport function countOf(text: string, countType: CountType, locale?: string) {\n if (countType === 'length') return text.length;\n if (typeof Intl.Segmenter !== 'function') {\n // Older browsers: close enough, rather than no count at all.\n return countType === 'words' ? (text.match(/\\S+/g)?.length ?? 0) : Array.from(text).length;\n }\n const segmenter = withLocale(\n locale,\n (l) => new Intl.Segmenter(l, { granularity: countType === 'words' ? 'word' : 'grapheme' })\n );\n const segments = Array.from(segmenter.segment(text));\n return countType === 'words' ? segments.filter((segment) => segment.isWordLike).length : segments.length;\n}\n\n/** The message for the number of characters or words left, with its state. */\nexport function countMessage(\n remaining: number,\n countType: CountType,\n messages: Partial<Record<MessageName, Translation>>,\n locale?: string\n) {\n const state = remaining < 0 ? 'over' : remaining === 0 ? 'at' : 'under';\n const name: MessageName = `${countType === 'words' ? 'words' : 'characters'}-${state}-limit`;\n const message = messages[name] ?? defaultMessages[name];\n return { state, text: translate(message, Math.abs(remaining), locale) };\n}\n","/*\n * <govuk-react-character-count>: a headless, light-DOM custom element that tells users how many\n * characters or words they can still enter, with or without React.\n *\n * Without JavaScript the field shows its description, such as \"You can enter up to 200\n * characters\". On upgrade the element visually hides the description, shows the count, and keeps\n * it up to date as the user types. As in govuk-frontend, screen readers hear the count once the\n * user pauses, rather than on every key.\n *\n * Markup inside the element:\n * - `[data-character-count-input]`: a `textarea` or `input`. Its `maxlength` is removed on\n * upgrade, so users can type past the limit and see by how much.\n * - `[data-character-count-description]`: the description, for `aria-describedby`.\n * - `[data-character-count-status]`: the visible count, rendered `hidden` with `aria-hidden`.\n * - `[data-character-count-sr-status]`: the count for screen readers, rendered `hidden` with\n * `aria-live=\"polite\"`. Make it visually hidden.\n *\n * The statuses get `data-state`, \"under\", \"at\" or \"over\" the limit. The visible one gets\n * `data-below-threshold` while the count is below `threshold`, and the one for screen readers gets\n * `aria-hidden` then.\n *\n * Attributes:\n * - `maxlength`: the limit. Without it, the element doesn't upgrade.\n * - `count-type`: \"length\" (the default) counts UTF-16 code units, as `maxlength` does;\n * \"characters\" counts characters as users see them; \"words\" counts words.\n * - `threshold`: the percentage of the limit from which the count is shown.\n * - `characters-under-limit`, `characters-at-limit`, `characters-over-limit`, `words-under-limit`,\n * `words-at-limit`, `words-over-limit`: the messages, English by default, with `%{count}` for\n * the number. Add a plural form to the name, such as `characters-under-limit-one`, for a\n * message for each form.\n * - `hidden-description-class`: classes that visually hide the description. Without them, the\n * element visually hides it with inline styles.\n * - `within-limit-class`, `over-limit-class`, `below-threshold-class`: classes for the visible\n * count.\n * - `input-over-limit-class`: classes for the field while over the limit.\n */\n\nimport { translationAttributeNames } from '../utils/translation';\nimport { countMessage, countOf, messageFromAttributes, messageNames, type CountType } from './messages';\n\nexport const tagName = 'govuk-react-character-count';\n\nexport interface CharacterCountElement extends HTMLElement {\n /** The count, once upgraded. */\n readonly count: number | undefined;\n /** Counts the field again and updates the visible count, such as after setting its value. */\n update(): void;\n}\n\n// The same visually hidden styles as govuk-frontend's.\nconst visuallyHidden: Record<string, string> = {\n position: 'absolute',\n width: '1px',\n height: '1px',\n margin: '0',\n padding: '0',\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n 'clip-path': 'inset(50%)',\n border: '0',\n 'white-space': 'nowrap',\n};\n\nconst classesOf = (attribute: string | null) => attribute?.split(/\\s+/).filter(Boolean) ?? [];\n\n// Keeps the text node React rendered, so React can still update it.\nconst setText = (element: Element, text: string) => {\n if (element.textContent === text) return;\n const { firstChild } = element;\n if (firstChild instanceof Text && element.childNodes.length === 1) firstChild.nodeValue = text;\n else element.textContent = text;\n};\n\nconst isField = (element: Element | undefined): element is HTMLTextAreaElement | HTMLInputElement =>\n element instanceof HTMLTextAreaElement || element instanceof HTMLInputElement;\n\nif (typeof HTMLElement !== 'undefined' && typeof customElements !== 'undefined') {\n class GovukReactCharacterCount extends HTMLElement implements CharacterCountElement {\n static get observedAttributes() {\n return [\n 'maxlength',\n 'count-type',\n 'threshold',\n 'within-limit-class',\n 'over-limit-class',\n 'below-threshold-class',\n 'input-over-limit-class',\n ...messageNames.flatMap(translationAttributeNames),\n ];\n }\n\n private input?: HTMLTextAreaElement | HTMLInputElement;\n\n private currentCount = 0;\n\n private lastInputTime?: number;\n\n private lastAnnouncedValue?: string;\n\n private checker?: number;\n\n private observer?: MutationObserver;\n\n private readonly onInput = () => {\n this.update();\n this.lastInputTime = Date.now();\n };\n\n // As in govuk-frontend: while focused, announce the count once the user pauses typing.\n private readonly onFocus = () => {\n window.clearInterval(this.checker);\n this.checker = window.setInterval(() => {\n if (!this.lastInputTime || Date.now() - 500 >= this.lastInputTime) this.announceIfChanged();\n }, 1000);\n };\n\n private readonly onBlur = () => window.clearInterval(this.checker);\n\n // A page restored from the back-forward cache, or a browser that restores the field's value.\n private readonly onPageShow = () => {\n if (!this.input) return;\n this.update();\n this.announceIfChanged();\n };\n\n get count() {\n return this.input ? this.currentCount : undefined;\n }\n\n connectedCallback() {\n // The parts may be parsed or rendered later, and React can rewrite a class attribute.\n this.observer = new MutationObserver((records) => {\n if (records.some((record) => record.type === 'childList')) this.setup();\n else this.update();\n });\n // React can rewrite a class, or put back the field's `maxlength`.\n this.observer.observe(this, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['class', 'maxlength'],\n });\n window.addEventListener('pageshow', this.onPageShow);\n this.setup();\n }\n\n disconnectedCallback() {\n this.observer?.disconnect();\n window.removeEventListener('pageshow', this.onPageShow);\n window.clearInterval(this.checker);\n this.unbind();\n }\n\n attributeChangedCallback() {\n // Wait for every attribute: React sets them one by one before connecting the element.\n if (!this.isConnected) return;\n if (!this.input) {\n this.setup();\n return;\n }\n if (this.maxLength === undefined) {\n this.downgrade();\n return;\n }\n // Screen readers hear the new count when the user next pauses.\n this.lastAnnouncedValue = undefined;\n this.update();\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 get maxLength() {\n const value = Number(this.getAttribute('maxlength'));\n return this.hasAttribute('maxlength') && Number.isFinite(value) ? value : undefined;\n }\n\n private get countType(): CountType {\n const type = this.getAttribute('count-type');\n return type === 'characters' || type === 'words' ? type : 'length';\n }\n\n // As govuk-frontend: the field's closest `lang`, which can be inside the element, or English.\n private get locale() {\n return (this.input ?? this).closest('[lang]')?.getAttribute('lang') || 'en';\n }\n\n private setup() {\n const input = this.own('[data-character-count-input]');\n if (!isField(input) || this.maxLength === undefined) return;\n const fresh = input !== this.input;\n if (fresh) {\n this.unbind();\n this.input = input;\n input.addEventListener('input', this.onInput);\n input.addEventListener('focus', this.onFocus);\n input.addEventListener('blur', this.onBlur);\n input.removeAttribute('maxlength');\n this.lastAnnouncedValue = undefined;\n }\n this.dataset.upgraded = '';\n const description = this.own('[data-character-count-description]');\n if (description && !this.hasAttribute('hidden-description-class')) {\n Object.entries(visuallyHidden).forEach(([name, value]) => description.style.setProperty(name, value));\n }\n [this.own('[data-character-count-status]'), this.own('[data-character-count-sr-status]')].forEach((status) => {\n if (status) status.hidden = false;\n });\n this.update();\n if (fresh) this.announceIfChanged();\n }\n\n private unbind() {\n const { input } = this;\n if (!input) return;\n input.removeEventListener('input', this.onInput);\n input.removeEventListener('focus', this.onFocus);\n input.removeEventListener('blur', this.onBlur);\n window.clearInterval(this.checker);\n this.input = undefined;\n }\n\n /** Back to the markup without JavaScript, when the limit is removed. */\n private downgrade() {\n const { input } = this;\n if (!input) return;\n classesOf(this.getAttribute('input-over-limit-class')).forEach((name) => input.classList.toggle(name, false));\n this.unbind();\n delete this.dataset.upgraded;\n const description = this.own('[data-character-count-description]');\n if (description) {\n if (this.hasAttribute('hidden-description-class')) {\n classesOf(this.getAttribute('hidden-description-class')).forEach((name) =>\n description.classList.toggle(name, false)\n );\n } else {\n Object.keys(visuallyHidden).forEach((name) => description.style.removeProperty(name));\n }\n }\n [this.own('[data-character-count-status]'), this.own('[data-character-count-sr-status]')].forEach((status) => {\n if (status) status.hidden = true;\n });\n }\n\n update() {\n if (!this.input) return;\n this.input.removeAttribute('maxlength');\n this.currentCount = countOf(this.input.value, this.countType, this.locale);\n this.render();\n }\n\n private message() {\n const messages = Object.fromEntries(messageNames.map((name) => [name, messageFromAttributes(this, name)]));\n return countMessage((this.maxLength ?? Infinity) - this.currentCount, this.countType, messages, this.locale);\n }\n\n private get belowThreshold() {\n const threshold = Number(this.getAttribute('threshold'));\n if (!threshold) return false;\n return this.currentCount < ((this.maxLength ?? Infinity) * threshold) / 100;\n }\n\n /** The visible count and the classes, from the current count. */\n private render() {\n const { input } = this;\n if (!input) return;\n const { state, text } = this.message();\n const over = state === 'over';\n const description = this.own('[data-character-count-description]');\n // `toggle` with force leaves a class that's already there alone, so the observer isn't woken.\n classesOf(this.getAttribute('hidden-description-class')).forEach((name) =>\n description?.classList.toggle(name, true)\n );\n classesOf(this.getAttribute('input-over-limit-class')).forEach((name) => input.classList.toggle(name, over));\n const belowThreshold = this.belowThreshold;\n const srStatus = this.own('[data-character-count-sr-status]');\n if (belowThreshold) srStatus?.setAttribute('aria-hidden', 'true');\n else srStatus?.removeAttribute('aria-hidden');\n const status = this.own('[data-character-count-status]');\n if (!status) return;\n status.dataset.state = state;\n status.toggleAttribute('data-below-threshold', belowThreshold);\n classesOf(this.getAttribute('below-threshold-class')).forEach((name) =>\n status.classList.toggle(name, belowThreshold)\n );\n classesOf(this.getAttribute('within-limit-class')).forEach((name) => status.classList.toggle(name, !over));\n classesOf(this.getAttribute('over-limit-class')).forEach((name) => status.classList.toggle(name, over));\n setText(status, text);\n }\n\n /** Updates the count for screen readers, if the field changed since it last did. */\n private announceIfChanged() {\n const { input } = this;\n const status = this.own('[data-character-count-sr-status]');\n if (!input || !status) return;\n if (input.value === this.lastAnnouncedValue) return;\n this.lastAnnouncedValue = input.value;\n const { state, text } = this.message();\n status.dataset.state = state;\n setText(status, text);\n }\n }\n\n if (!customElements.get(tagName)) customElements.define(tagName, GovukReactCharacterCount);\n}\n"],"mappings":";;;;;;;;;;AAiBO,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,kBAAoD;AAAA,EAC/D,0BAA0B;AAAA,IACxB,KAAK;AAAA,IACL,OAAO;AAAA,EACT;AAAA,EACA,uBAAuB;AAAA,EACvB,yBAAyB;AAAA,IACvB,KAAK;AAAA,IACL,OAAO;AAAA,EACT;AAAA,EACA,qBAAqB,EAAE,KAAK,oCAAoC,OAAO,oCAAoC;AAAA,EAC3G,kBAAkB;AAAA,EAClB,oBAAoB,EAAE,KAAK,mCAAmC,OAAO,mCAAmC;AAC1G;AAGO,IAAM,oBAAoB,CAAC,MAAmB,YACnD,sBAAsB,MAAM,OAAO;AAG9B,IAAM,wBAAwB,CAAC,SAAkB,SAAsB,0BAA0B,SAAS,IAAI;AAG9G,SAAS,QAAQ,MAAc,WAAsB,QAAiB;AApD7E;AAqDE,MAAI,cAAc,SAAU,QAAO,KAAK;AACxC,MAAI,OAAO,KAAK,cAAc,YAAY;AAExC,WAAO,cAAc,WAAW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URE__ */ Symbol.for("govuk-react-button");
|
|
6
|
-
var lastClicks = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
var buttonOf = (event) => {
|
|
8
|
-
for (const target of event.composedPath()) {
|
|
9
|
-
if (target instanceof HTMLElement && target.hasAttribute("data-button")) return target;
|
|
10
|
-
}
|
|
11
|
-
return null;
|
|
12
|
-
};
|
|
13
|
-
function onClick(event) {
|
|
14
|
-
const button = buttonOf(event);
|
|
15
|
-
if (!button || button.getAttribute("data-prevent-double-click") !== "true") return;
|
|
16
|
-
const last = lastClicks.get(button);
|
|
17
|
-
if (last !== void 0 && event.timeStamp - last < debounceMs) {
|
|
18
|
-
event.preventDefault();
|
|
19
|
-
event.stopImmediatePropagation();
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
lastClicks.set(button, event.timeStamp);
|
|
23
|
-
}
|
|
24
|
-
function onKeyDown(event) {
|
|
25
|
-
if (event.key !== " " || event.repeat || event.defaultPrevented) return;
|
|
26
|
-
const button = buttonOf(event);
|
|
27
|
-
if (!button || button !== event.composedPath()[0] || button.getAttribute("role") !== "button") return;
|
|
28
|
-
if (button instanceof HTMLButtonElement) return;
|
|
29
|
-
event.preventDefault();
|
|
30
|
-
button.click();
|
|
31
|
-
}
|
|
32
|
-
if (typeof document !== "undefined") {
|
|
33
|
-
if (!Reflect.get(globalThis, installed)) {
|
|
34
|
-
Reflect.set(globalThis, installed, true);
|
|
35
|
-
document.addEventListener("click", onClick, true);
|
|
36
|
-
document.addEventListener("keydown", onKeyDown);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=chunk-VNXXENCU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/button/element.ts"],"sourcesContent":["/*\n * Headless button behaviour, with or without React, as govuk-frontend's button script has. Importing\n * this module adds two listeners to the document, once, for any element with `data-button`:\n *\n * - With `data-prevent-double-click=\"true\"`, a second click within a second of the first is\n * cancelled, so a form isn't submitted twice. Unlike govuk-frontend, the click is also stopped\n * before it reaches React, so an `onClick` doesn't run twice either.\n * - A link with `role=\"button\"` is activated with the Space key, as a button is.\n *\n * Unlike a custom element, the listeners need no wrapper, which would change a button group's\n * layout.\n */\n\nconst debounceMs = 1000;\n\n// Shared by every copy of this module on the page.\nconst installed = Symbol.for('govuk-react-button');\n\nconst lastClicks = new WeakMap<Element, number>();\n\n// The path, rather than the target, reaches into shadow roots.\nconst buttonOf = (event: Event) => {\n for (const target of event.composedPath()) {\n if (target instanceof HTMLElement && target.hasAttribute('data-button')) return target;\n }\n return null;\n};\n\nfunction onClick(event: MouseEvent) {\n const button = buttonOf(event);\n if (!button || button.getAttribute('data-prevent-double-click') !== 'true') return;\n const last = lastClicks.get(button);\n if (last !== undefined && event.timeStamp - last < debounceMs) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n lastClicks.set(button, event.timeStamp);\n}\n\nfunction onKeyDown(event: KeyboardEvent) {\n // Held down, Space activates once, as on a button. A handler that took the key keeps it.\n if (event.key !== ' ' || event.repeat || event.defaultPrevented) return;\n const button = buttonOf(event);\n if (!button || button !== event.composedPath()[0] || button.getAttribute('role') !== 'button') return;\n if (button instanceof HTMLButtonElement) return;\n // Space would scroll the page.\n event.preventDefault();\n button.click();\n}\n\nif (typeof document !== 'undefined') {\n if (!Reflect.get(globalThis, installed)) {\n Reflect.set(globalThis, installed, true);\n // Capture, to cancel a second click before anything else hears it.\n document.addEventListener('click', onClick, true);\n document.addEventListener('keydown', onKeyDown);\n }\n}\n\nexport {};\n"],"mappings":";;;AAaA,IAAM,aAAa;AAGnB,IAAM,YAAY,uBAAO,IAAI,oBAAoB;AAEjD,IAAM,aAAa,oBAAI,QAAyB;AAGhD,IAAM,WAAW,CAAC,UAAiB;AACjC,aAAW,UAAU,MAAM,aAAa,GAAG;AACzC,QAAI,kBAAkB,eAAe,OAAO,aAAa,aAAa,EAAG,QAAO;AAAA,EAClF;AACA,SAAO;AACT;AAEA,SAAS,QAAQ,OAAmB;AAClC,QAAM,SAAS,SAAS,KAAK;AAC7B,MAAI,CAAC,UAAU,OAAO,aAAa,2BAA2B,MAAM,OAAQ;AAC5E,QAAM,OAAO,WAAW,IAAI,MAAM;AAClC,MAAI,SAAS,UAAa,MAAM,YAAY,OAAO,YAAY;AAC7D,UAAM,eAAe;AACrB,UAAM,yBAAyB;AAC/B;AAAA,EACF;AACA,aAAW,IAAI,QAAQ,MAAM,SAAS;AACxC;AAEA,SAAS,UAAU,OAAsB;AAEvC,MAAI,MAAM,QAAQ,OAAO,MAAM,UAAU,MAAM,iBAAkB;AACjE,QAAM,SAAS,SAAS,KAAK;AAC7B,MAAI,CAAC,UAAU,WAAW,MAAM,aAAa,EAAE,CAAC,KAAK,OAAO,aAAa,MAAM,MAAM,SAAU;AAC/F,MAAI,kBAAkB,kBAAmB;AAEzC,QAAM,eAAe;AACrB,SAAO,MAAM;AACf;AAEA,IAAI,OAAO,aAAa,aAAa;AACnC,MAAI,CAAC,QAAQ,IAAI,YAAY,SAAS,GAAG;AACvC,YAAQ,IAAI,YAAY,WAAW,IAAI;AAEvC,aAAS,iBAAiB,SAAS,SAAS,IAAI;AAChD,aAAS,iBAAiB,WAAW,SAAS;AAAA,EAChD;AACF;","names":[]}
|
package/dist/chunk-XGK73UCD.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import {
|
|
3
|
-
dropAutoFocus,
|
|
4
|
-
setFocus
|
|
5
|
-
} from "./chunk-LWIA644X.js";
|
|
6
|
-
|
|
7
|
-
// src/auto-focus/element.ts
|
|
8
|
-
var tagName = "govuk-react-auto-focus";
|
|
9
|
-
if (typeof HTMLElement !== "undefined" && typeof customElements !== "undefined") {
|
|
10
|
-
class GovukReactAutoFocus extends HTMLElement {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments);
|
|
13
|
-
this.focused = false;
|
|
14
|
-
}
|
|
15
|
-
connectedCallback() {
|
|
16
|
-
if (this.focusTarget()) return;
|
|
17
|
-
this.observer = new MutationObserver(() => {
|
|
18
|
-
var _a;
|
|
19
|
-
if (this.focusTarget()) (_a = this.observer) == null ? void 0 : _a.disconnect();
|
|
20
|
-
});
|
|
21
|
-
this.observer.observe(this, { childList: true, subtree: true });
|
|
22
|
-
}
|
|
23
|
-
disconnectedCallback() {
|
|
24
|
-
var _a;
|
|
25
|
-
(_a = this.observer) == null ? void 0 : _a.disconnect();
|
|
26
|
-
}
|
|
27
|
-
get target() {
|
|
28
|
-
var _a;
|
|
29
|
-
const target = (_a = Array.from(this.querySelectorAll("[data-auto-focus]")).find((found) => found.closest(tagName) === this)) != null ? _a : this.firstElementChild;
|
|
30
|
-
return target instanceof HTMLElement ? target : void 0;
|
|
31
|
-
}
|
|
32
|
-
/** Focuses the target once, and says whether there was one to focus. */
|
|
33
|
-
focusTarget() {
|
|
34
|
-
if (this.focused) return true;
|
|
35
|
-
const { target } = this;
|
|
36
|
-
if (!target) return false;
|
|
37
|
-
this.focused = true;
|
|
38
|
-
if (this.hasAttribute("disabled")) return true;
|
|
39
|
-
if (target.hasAttribute("autofocus")) {
|
|
40
|
-
const active = document.activeElement;
|
|
41
|
-
if (active === target) {
|
|
42
|
-
setFocus(target, { preventScroll: true });
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
if (active && active !== document.body) {
|
|
46
|
-
dropAutoFocus(target);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
queueMicrotask(() => {
|
|
51
|
-
if (!target.isConnected || !setFocus(target)) this.focused = false;
|
|
52
|
-
});
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (!customElements.get(tagName)) customElements.define(tagName, GovukReactAutoFocus);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export {
|
|
60
|
-
tagName
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=chunk-XGK73UCD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auto-focus/element.ts"],"sourcesContent":["/*\n * <govuk-react-auto-focus>: a headless, light-DOM custom element that moves focus to its target\n * when it appears, such as an error summary or a success banner, with or without React. It moves\n * focus once: give the element a new `key` in React to move it again, such as after each submit.\n *\n * The target is server-rendered with `tabindex=\"-1\"` and `autofocus`, so the browser focuses it\n * when the page loads, even without JavaScript. When the element connects later, such as when React\n * renders the target after a form is submitted, the element focuses it. As in govuk-frontend, the\n * target loses its `tabindex` when it loses focus. If the user has moved focus on before the script\n * runs, it leaves them there. Without JavaScript the target keeps its `tabindex`.\n *\n * Markup inside the element:\n * - `[data-auto-focus]`: the target. Without one, the element's first child.\n *\n * Attributes:\n * - `disabled`: don't move focus.\n */\n\nimport { dropAutoFocus, setFocus } from '../utils/set-focus';\n\nexport const tagName = 'govuk-react-auto-focus';\n\nif (typeof HTMLElement !== 'undefined' && typeof customElements !== 'undefined') {\n class GovukReactAutoFocus extends HTMLElement {\n private focused = false;\n\n private observer?: MutationObserver;\n\n connectedCallback() {\n if (this.focusTarget()) return;\n // The target may not be parsed or rendered yet.\n this.observer = new MutationObserver(() => {\n if (this.focusTarget()) this.observer?.disconnect();\n });\n this.observer.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n this.observer?.disconnect();\n }\n\n private get target() {\n const target =\n Array.from(this.querySelectorAll('[data-auto-focus]')).find((found) => found.closest(tagName) === this) ??\n this.firstElementChild;\n return target instanceof HTMLElement ? target : undefined;\n }\n\n /** Focuses the target once, and says whether there was one to focus. */\n private focusTarget() {\n if (this.focused) return true;\n const { target } = this;\n if (!target) return false;\n this.focused = true;\n if (this.hasAttribute('disabled')) return true;\n // Rendered by the server with `autofocus`, which React never sets on the client.\n if (target.hasAttribute('autofocus')) {\n const active = document.activeElement;\n if (active === target) {\n setFocus(target, { preventScroll: true });\n return true;\n }\n if (active && active !== document.body) {\n // The user moved on before this script ran: leave them there.\n dropAutoFocus(target);\n return true;\n }\n }\n // React puts focus back where it was at the end of a commit, which can connect the element.\n queueMicrotask(() => {\n // Not in place yet, such as in a streamed boundary: try again when it moves.\n if (!target.isConnected || !setFocus(target)) this.focused = false;\n });\n return true;\n }\n }\n\n if (!customElements.get(tagName)) customElements.define(tagName, GovukReactAutoFocus);\n}\n"],"mappings":";;;;;;;AAoBO,IAAM,UAAU;AAEvB,IAAI,OAAO,gBAAgB,eAAe,OAAO,mBAAmB,aAAa;AAAA,EAC/E,MAAM,4BAA4B,YAAY;AAAA,IAA9C;AAAA;AACE,WAAQ,UAAU;AAAA;AAAA,IAIlB,oBAAoB;AAClB,UAAI,KAAK,YAAY,EAAG;AAExB,WAAK,WAAW,IAAI,iBAAiB,MAAM;AA/BjD;AAgCQ,YAAI,KAAK,YAAY,EAAG,YAAK,aAAL,mBAAe;AAAA,MACzC,CAAC;AACD,WAAK,SAAS,QAAQ,MAAM,EAAE,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,IAChE;AAAA,IAEA,uBAAuB;AArC3B;AAsCM,iBAAK,aAAL,mBAAe;AAAA,IACjB;AAAA,IAEA,IAAY,SAAS;AAzCzB;AA0CM,YAAM,UACJ,WAAM,KAAK,KAAK,iBAAiB,mBAAmB,CAAC,EAAE,KAAK,CAAC,UAAU,MAAM,QAAQ,OAAO,MAAM,IAAI,MAAtG,YACA,KAAK;AACP,aAAO,kBAAkB,cAAc,SAAS;AAAA,IAClD;AAAA;AAAA,IAGQ,cAAc;AACpB,UAAI,KAAK,QAAS,QAAO;AACzB,YAAM,EAAE,OAAO,IAAI;AACnB,UAAI,CAAC,OAAQ,QAAO;AACpB,WAAK,UAAU;AACf,UAAI,KAAK,aAAa,UAAU,EAAG,QAAO;AAE1C,UAAI,OAAO,aAAa,WAAW,GAAG;AACpC,cAAM,SAAS,SAAS;AACxB,YAAI,WAAW,QAAQ;AACrB,mBAAS,QAAQ,EAAE,eAAe,KAAK,CAAC;AACxC,iBAAO;AAAA,QACT;AACA,YAAI,UAAU,WAAW,SAAS,MAAM;AAEtC,wBAAc,MAAM;AACpB,iBAAO;AAAA,QACT;AAAA,MACF;AAEA,qBAAe,MAAM;AAEnB,YAAI,CAAC,OAAO,eAAe,CAAC,SAAS,MAAM,EAAG,MAAK,UAAU;AAAA,MAC/D,CAAC;AACD,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,CAAC,eAAe,IAAI,OAAO,EAAG,gBAAe,OAAO,SAAS,mBAAmB;AACtF;","names":[]}
|
package/dist/chunk-XJYLFTYE.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import {
|
|
3
|
-
tagName
|
|
4
|
-
} from "./chunk-U5OKNKYC.js";
|
|
5
|
-
import {
|
|
6
|
-
translationAttributes
|
|
7
|
-
} from "./chunk-RDUPELOK.js";
|
|
8
|
-
import {
|
|
9
|
-
Slot
|
|
10
|
-
} from "./chunk-NX4B3NKM.js";
|
|
11
|
-
import {
|
|
12
|
-
__export
|
|
13
|
-
} from "./chunk-ESBMTI25.js";
|
|
14
|
-
|
|
15
|
-
// src/autocomplete/index.tsx
|
|
16
|
-
var autocomplete_exports = {};
|
|
17
|
-
__export(autocomplete_exports, {
|
|
18
|
-
AssistiveHint: () => AssistiveHint,
|
|
19
|
-
Input: () => Input,
|
|
20
|
-
Listbox: () => Listbox,
|
|
21
|
-
NoResults: () => NoResults,
|
|
22
|
-
Option: () => Option,
|
|
23
|
-
Root: () => Root,
|
|
24
|
-
Status: () => Status
|
|
25
|
-
});
|
|
26
|
-
import * as React from "react";
|
|
27
|
-
import { useEffect, useRef } from "react";
|
|
28
|
-
var isAutocomplete = (element) => "query" in element;
|
|
29
|
-
function Root({
|
|
30
|
-
minLength,
|
|
31
|
-
filter,
|
|
32
|
-
confirmOnBlur,
|
|
33
|
-
submitOnConfirm,
|
|
34
|
-
onQueryChange,
|
|
35
|
-
onConfirm,
|
|
36
|
-
statusQueryTooShort,
|
|
37
|
-
statusNoResults,
|
|
38
|
-
statusSelectedOption,
|
|
39
|
-
statusResults,
|
|
40
|
-
...props
|
|
41
|
-
}) {
|
|
42
|
-
const element = useRef(null);
|
|
43
|
-
const callbacks = useRef({ onQueryChange, onConfirm });
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
callbacks.current = { onQueryChange, onConfirm };
|
|
46
|
-
});
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
const node = element.current;
|
|
50
|
-
if (!node) return void 0;
|
|
51
|
-
const onQuery = (event) => {
|
|
52
|
-
var _a2, _b2;
|
|
53
|
-
if (event.target === node) (_b2 = (_a2 = callbacks.current).onQueryChange) == null ? void 0 : _b2.call(_a2, event.detail.query);
|
|
54
|
-
};
|
|
55
|
-
const onConfirmed = (event) => {
|
|
56
|
-
var _a2, _b2;
|
|
57
|
-
if (event.target === node) (_b2 = (_a2 = callbacks.current).onConfirm) == null ? void 0 : _b2.call(_a2, event.detail.value, event);
|
|
58
|
-
};
|
|
59
|
-
node.addEventListener("govuk-react-autocomplete:query", onQuery);
|
|
60
|
-
node.addEventListener("govuk-react-autocomplete:confirm", onConfirmed);
|
|
61
|
-
const input = node.querySelector("input[data-autocomplete-input]");
|
|
62
|
-
const query = isAutocomplete(node) ? node.query : void 0;
|
|
63
|
-
if (query && input instanceof HTMLInputElement && query !== input.defaultValue) {
|
|
64
|
-
(_b = (_a = callbacks.current).onQueryChange) == null ? void 0 : _b.call(_a, query);
|
|
65
|
-
}
|
|
66
|
-
return () => {
|
|
67
|
-
node.removeEventListener("govuk-react-autocomplete:query", onQuery);
|
|
68
|
-
node.removeEventListener("govuk-react-autocomplete:confirm", onConfirmed);
|
|
69
|
-
};
|
|
70
|
-
}, []);
|
|
71
|
-
return React.createElement(tagName, {
|
|
72
|
-
...props,
|
|
73
|
-
ref: element,
|
|
74
|
-
// The element owns `data-upgraded` and `data-focused`.
|
|
75
|
-
suppressHydrationWarning: true,
|
|
76
|
-
"min-length": minLength,
|
|
77
|
-
filter,
|
|
78
|
-
"confirm-on-blur": confirmOnBlur === false ? "false" : void 0,
|
|
79
|
-
"submit-on-confirm": submitOnConfirm ? "" : void 0,
|
|
80
|
-
...translationAttributes("status-query-too-short", statusQueryTooShort),
|
|
81
|
-
...translationAttributes("status-no-results", statusNoResults),
|
|
82
|
-
...translationAttributes("status-selected-option", statusSelectedOption),
|
|
83
|
-
...translationAttributes("status-results", statusResults)
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function Input({ asChild, ...props }) {
|
|
87
|
-
const Element = asChild ? Slot : "input";
|
|
88
|
-
return /* @__PURE__ */ React.createElement(Element, { "data-autocomplete-input": "", suppressHydrationWarning: true, ...props });
|
|
89
|
-
}
|
|
90
|
-
function Listbox({ asChild, ...props }) {
|
|
91
|
-
const Element = asChild ? Slot : "ul";
|
|
92
|
-
return /* @__PURE__ */ React.createElement(Element, { "data-autocomplete-listbox": "", hidden: true, suppressHydrationWarning: true, ...props });
|
|
93
|
-
}
|
|
94
|
-
function Option({ asChild, value, ...props }) {
|
|
95
|
-
const Element = asChild ? Slot : "li";
|
|
96
|
-
return /* @__PURE__ */ React.createElement(Element, { "data-autocomplete-option": "", "data-value": value, suppressHydrationWarning: true, ...props });
|
|
97
|
-
}
|
|
98
|
-
function NoResults({ asChild, children = "No results found", ...props }) {
|
|
99
|
-
const Element = asChild ? Slot : "li";
|
|
100
|
-
return /* @__PURE__ */ React.createElement(Element, { "data-autocomplete-no-results": "", hidden: true, suppressHydrationWarning: true, ...props }, children);
|
|
101
|
-
}
|
|
102
|
-
var visuallyHidden = {
|
|
103
|
-
border: 0,
|
|
104
|
-
clip: "rect(0 0 0 0)",
|
|
105
|
-
height: 1,
|
|
106
|
-
marginBottom: -1,
|
|
107
|
-
marginRight: -1,
|
|
108
|
-
overflow: "hidden",
|
|
109
|
-
padding: 0,
|
|
110
|
-
position: "absolute",
|
|
111
|
-
whiteSpace: "nowrap",
|
|
112
|
-
width: 1
|
|
113
|
-
};
|
|
114
|
-
function Status({ asChild, style, ...props }) {
|
|
115
|
-
const Element = asChild ? Slot : "div";
|
|
116
|
-
return /* @__PURE__ */ React.createElement(Element, { "data-autocomplete-status": "", style: { ...visuallyHidden, ...style }, ...props }, /* @__PURE__ */ React.createElement(
|
|
117
|
-
"div",
|
|
118
|
-
{
|
|
119
|
-
"data-autocomplete-status-region": "",
|
|
120
|
-
role: "status",
|
|
121
|
-
"aria-atomic": "true",
|
|
122
|
-
"aria-live": "polite",
|
|
123
|
-
suppressHydrationWarning: true
|
|
124
|
-
},
|
|
125
|
-
""
|
|
126
|
-
), /* @__PURE__ */ React.createElement(
|
|
127
|
-
"div",
|
|
128
|
-
{
|
|
129
|
-
"data-autocomplete-status-region": "",
|
|
130
|
-
role: "status",
|
|
131
|
-
"aria-atomic": "true",
|
|
132
|
-
"aria-live": "polite",
|
|
133
|
-
suppressHydrationWarning: true
|
|
134
|
-
},
|
|
135
|
-
""
|
|
136
|
-
));
|
|
137
|
-
}
|
|
138
|
-
function AssistiveHint({
|
|
139
|
-
asChild,
|
|
140
|
-
children = "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.",
|
|
141
|
-
...props
|
|
142
|
-
}) {
|
|
143
|
-
const Element = asChild ? Slot : "span";
|
|
144
|
-
return /* @__PURE__ */ React.createElement(Element, { "data-autocomplete-hint": "", hidden: true, suppressHydrationWarning: true, ...props }, children);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export {
|
|
148
|
-
Root,
|
|
149
|
-
Input,
|
|
150
|
-
Listbox,
|
|
151
|
-
Option,
|
|
152
|
-
NoResults,
|
|
153
|
-
Status,
|
|
154
|
-
AssistiveHint,
|
|
155
|
-
autocomplete_exports
|
|
156
|
-
};
|
|
157
|
-
//# sourceMappingURL=chunk-XJYLFTYE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/autocomplete/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useEffect, useRef } from 'react';\nimport type { ComponentProps, CSSProperties } from 'react';\nimport { Slot } from '../utils/slot';\nimport { translationAttributes, type Translation } from '../utils/translation';\nimport { tagName, type AutocompleteElement, type Filter } from './element';\n\nexport type { Filter } from './element';\nexport type { Translation } from '../utils/translation';\n\n/*\n * Headless autocomplete: unstyled parts over the <govuk-react-autocomplete> element\n * (./element.ts), a port of accessible-autocomplete. Every part except Root takes `asChild`.\n *\n * The input's value is the query, and the options are whatever you render in `Listbox`, so there\n * is nothing else to control. Without JavaScript it's a plain input.\n */\n\nexport type RootProps = Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {\n /** The length the query needs before options show. 0 by default. */\n minLength?: number;\n /**\n * Which options match the query: \"contains\" (the default), \"starts-with\", or \"none\" for\n * options that already match, such as results from a server.\n */\n filter?: Filter;\n /** Confirm the highlighted option when focus leaves it. `true` by default. */\n confirmOnBlur?: boolean;\n /**\n * Submit the input's form when the user confirms an option, and let Enter submit it while the\n * menu is open with no option highlighted.\n */\n submitOnConfirm?: boolean;\n /**\n * Called when the user changes the query and options are due, such as to fetch them. Also\n * called once hydrated, with a query the user typed before hydration.\n */\n onQueryChange?: (query: string) => void;\n /** Called when the user confirms an option. Call `preventDefault` on the event to stop `submitOnConfirm`. */\n onConfirm?: (value: string, event: CustomEvent<{ value: string }>) => void;\n /** Heard while the query is too short. `%{count}` is `minLength`. */\n statusQueryTooShort?: Translation;\n /** Heard when no option matches. */\n statusNoResults?: Translation;\n /** Heard after the results while an option is highlighted. `%{option}`, `%{position}` and `%{count}`. */\n statusSelectedOption?: Translation;\n /** Heard when options match. `%{count}` is the number of options. */\n statusResults?: Translation;\n};\n\nconst isAutocomplete = (element: HTMLElement): element is AutocompleteElement => 'query' in element;\n\nexport function Root({\n minLength,\n filter,\n confirmOnBlur,\n submitOnConfirm,\n onQueryChange,\n onConfirm,\n statusQueryTooShort,\n statusNoResults,\n statusSelectedOption,\n statusResults,\n ...props\n}: RootProps) {\n const element = useRef<HTMLElement>(null);\n const callbacks = useRef({ onQueryChange, onConfirm });\n useEffect(() => {\n callbacks.current = { onQueryChange, onConfirm };\n });\n\n useEffect(() => {\n const node = element.current;\n if (!node) return undefined;\n // A nested autocomplete's events bubble through this one.\n const onQuery = (event: CustomEvent<{ query: string }>) => {\n if (event.target === node) callbacks.current.onQueryChange?.(event.detail.query);\n };\n const onConfirmed = (event: CustomEvent<{ value: string }>) => {\n if (event.target === node) callbacks.current.onConfirm?.(event.detail.value, event);\n };\n node.addEventListener('govuk-react-autocomplete:query', onQuery);\n node.addEventListener('govuk-react-autocomplete:confirm', onConfirmed);\n\n // A query typed before hydration fired no event React heard, so report it once.\n const input = node.querySelector('input[data-autocomplete-input]');\n const query = isAutocomplete(node) ? node.query : undefined;\n if (query && input instanceof HTMLInputElement && query !== input.defaultValue) {\n callbacks.current.onQueryChange?.(query);\n }\n return () => {\n node.removeEventListener('govuk-react-autocomplete:query', onQuery);\n node.removeEventListener('govuk-react-autocomplete:confirm', onConfirmed);\n };\n }, []);\n\n return React.createElement(tagName, {\n ...props,\n ref: element,\n // The element owns `data-upgraded` and `data-focused`.\n suppressHydrationWarning: true,\n 'min-length': minLength,\n filter,\n 'confirm-on-blur': confirmOnBlur === false ? 'false' : undefined,\n 'submit-on-confirm': submitOnConfirm ? '' : undefined,\n ...translationAttributes('status-query-too-short', statusQueryTooShort),\n ...translationAttributes('status-no-results', statusNoResults),\n ...translationAttributes('status-selected-option', statusSelectedOption),\n ...translationAttributes('status-results', statusResults),\n });\n}\n\ntype PartProps<E extends keyof React.JSX.IntrinsicElements> = ComponentProps<E> & {\n /** Render the only child instead, with this part's props merged onto it. */\n asChild?: boolean;\n};\n\nexport type InputProps = PartProps<'input'>;\n\n/** The input, with an `id` and a label. A combobox once upgraded. */\nexport function Input({ asChild, ...props }: InputProps) {\n const Element = asChild ? Slot : 'input';\n // The element owns `role`, `autocomplete` and the ARIA after upgrade.\n return <Element data-autocomplete-input=\"\" suppressHydrationWarning {...props} />;\n}\n\nexport type ListboxProps = PartProps<'ul'>;\n\n/** Holds the options. Hidden until there are options to show. */\nexport function Listbox({ asChild, ...props }: ListboxProps) {\n const Element = asChild ? Slot : 'ul';\n // The element owns `id`, `role`, `aria-labelledby` and `hidden` after upgrade.\n return <Element data-autocomplete-listbox=\"\" hidden suppressHydrationWarning {...props} />;\n}\n\nexport type OptionProps = PartProps<'li'> & {\n /** What the input gets when the option is confirmed, and what the query is matched against. Its text by default. */\n value?: string;\n};\n\n/** An option, in `Listbox`. Shown while it matches the query. */\nexport function Option({ asChild, value, ...props }: OptionProps) {\n const Element = asChild ? Slot : 'li';\n // The element owns `id`, `role`, `hidden`, `tabindex`, its ARIA and `data-focused` after upgrade.\n return <Element data-autocomplete-option=\"\" data-value={value} suppressHydrationWarning {...props} />;\n}\n\nexport type NoResultsProps = PartProps<'li'>;\n\n/** Shown in `Listbox` when no option matches the query. Leave it out to show nothing. */\nexport function NoResults({ asChild, children = 'No results found', ...props }: NoResultsProps) {\n const Element = asChild ? Slot : 'li';\n // The element owns `hidden`, `role` and `aria-disabled` after upgrade.\n return (\n <Element data-autocomplete-no-results=\"\" hidden suppressHydrationWarning {...props}>\n {children}\n </Element>\n );\n}\n\n// The same visually hidden styles as accessible-autocomplete's.\nconst visuallyHidden: CSSProperties = {\n border: 0,\n clip: 'rect(0 0 0 0)',\n height: 1,\n marginBottom: -1,\n marginRight: -1,\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n whiteSpace: 'nowrap',\n width: 1,\n};\n\nexport type StatusProps = PartProps<'div'>;\n\n/** What screen readers hear about the options, once the user pauses. Visually hidden. */\nexport function Status({ asChild, style, ...props }: StatusProps) {\n const Element = asChild ? Slot : 'div';\n return (\n <Element data-autocomplete-status=\"\" style={{ ...visuallyHidden, ...style }} {...props}>\n {/* An empty string, rather than no children, lets the element set the text before hydration. */}\n <div\n data-autocomplete-status-region=\"\"\n role=\"status\"\n aria-atomic=\"true\"\n aria-live=\"polite\"\n suppressHydrationWarning\n >\n {''}\n </div>\n <div\n data-autocomplete-status-region=\"\"\n role=\"status\"\n aria-atomic=\"true\"\n aria-live=\"polite\"\n suppressHydrationWarning\n >\n {''}\n </div>\n </Element>\n );\n}\n\nexport type AssistiveHintProps = PartProps<'span'>;\n\n/** How to use the options, which describes the input while the query is empty. Never shown. */\nexport function AssistiveHint({\n asChild,\n children = 'When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.',\n ...props\n}: AssistiveHintProps) {\n const Element = asChild ? Slot : 'span';\n // The element owns `id` after upgrade.\n return (\n <Element data-autocomplete-hint=\"\" hidden suppressHydrationWarning {...props}>\n {children}\n </Element>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAY,WAAW;AACvB,SAAS,WAAW,cAAc;AAiDlC,IAAM,iBAAiB,CAAC,YAAyD,WAAW;AAErF,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAc;AACZ,QAAM,UAAU,OAAoB,IAAI;AACxC,QAAM,YAAY,OAAO,EAAE,eAAe,UAAU,CAAC;AACrD,YAAU,MAAM;AACd,cAAU,UAAU,EAAE,eAAe,UAAU;AAAA,EACjD,CAAC;AAED,YAAU,MAAM;AAzElB;AA0EI,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,KAAM,QAAO;AAElB,UAAM,UAAU,CAAC,UAA0C;AA7E/D,UAAAA,KAAAC;AA8EM,UAAI,MAAM,WAAW,KAAM,EAAAA,OAAAD,MAAA,UAAU,SAAQ,kBAAlB,gBAAAC,IAAA,KAAAD,KAAkC,MAAM,OAAO;AAAA,IAC5E;AACA,UAAM,cAAc,CAAC,UAA0C;AAhFnE,UAAAA,KAAAC;AAiFM,UAAI,MAAM,WAAW,KAAM,EAAAA,OAAAD,M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