@govuk-react/primitives 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -25
- package/dist/accordion/element.d.ts +3 -0
- package/dist/accordion/element.js.map +1 -1
- package/dist/accordion/index.d.ts +3 -7
- package/dist/accordion/index.js +35 -33
- package/dist/accordion/index.js.map +1 -1
- package/dist/auto-focus/index.d.ts +3 -285
- package/dist/auto-focus/index.js +13 -3
- package/dist/auto-focus/index.js.map +1 -1
- package/dist/autocomplete/element.d.ts +7 -4
- package/dist/autocomplete/element.js +11 -11
- package/dist/autocomplete/element.js.map +1 -1
- package/dist/autocomplete/index.d.ts +7 -7
- package/dist/autocomplete/index.js +17 -25
- package/dist/autocomplete/index.js.map +1 -1
- package/dist/character-count/element.d.ts +5 -0
- package/dist/character-count/element.js +5 -5
- package/dist/character-count/element.js.map +1 -1
- package/dist/character-count/index.d.ts +7 -7
- package/dist/character-count/index.js +13 -13
- package/dist/character-count/index.js.map +1 -1
- package/dist/character-count/messages.d.ts +1 -1
- package/dist/character-count/messages.js +13 -13
- package/dist/character-count/messages.js.map +1 -1
- package/dist/choices/element.d.ts +5 -0
- package/dist/choices/element.js +6 -31
- package/dist/choices/element.js.map +1 -1
- package/dist/disclosure/element.d.ts +3 -0
- package/dist/disclosure/element.js +21 -12
- package/dist/disclosure/element.js.map +1 -1
- package/dist/disclosure/index.d.ts +6 -5
- package/dist/disclosure/index.js +21 -11
- package/dist/disclosure/index.js.map +1 -1
- package/dist/exit-this-page/element.d.ts +1 -1
- package/dist/exit-this-page/element.js +20 -21
- package/dist/exit-this-page/element.js.map +1 -1
- package/dist/exit-this-page/index.d.ts +11 -11
- package/dist/exit-this-page/index.js +7 -7
- package/dist/exit-this-page/index.js.map +1 -1
- package/dist/file-upload/element.d.ts +11 -6
- package/dist/file-upload/element.js +15 -15
- package/dist/file-upload/element.js.map +1 -1
- package/dist/file-upload/index.d.ts +9 -9
- package/dist/file-upload/index.js +11 -11
- package/dist/file-upload/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.js +12 -12
- package/dist/modal/element.js +126 -11
- package/dist/modal/element.js.map +1 -1
- package/dist/modal/index.d.ts +8 -3
- package/dist/modal/index.js +56 -20
- package/dist/modal/index.js.map +1 -1
- package/dist/password-input/element.js +27 -11
- package/dist/password-input/element.js.map +1 -1
- package/dist/password-input/index.d.ts +3 -3
- package/dist/password-input/index.js +4 -2
- package/dist/password-input/index.js.map +1 -1
- package/dist/styles.css +11 -0
- package/dist/tabs/element.d.ts +3 -0
- package/dist/tabs/element.js +17 -10
- package/dist/tabs/element.js.map +1 -1
- package/dist/tabs/index.d.ts +9 -18
- package/dist/tabs/index.js +48 -44
- package/dist/tabs/index.js.map +1 -1
- package/dist/utils/change-details.d.ts +11 -0
- package/dist/utils/change-details.js +3 -0
- package/dist/utils/change-details.js.map +1 -0
- package/dist/utils/on-property-change.d.ts +7 -0
- package/dist/utils/on-property-change.js +19 -0
- package/dist/utils/on-property-change.js.map +1 -0
- package/dist/utils/set-focus.js.map +1 -1
- package/dist/utils/slot.d.ts +5 -3
- package/dist/utils/slot.js +24 -2
- package/dist/utils/slot.js.map +1 -1
- package/package.json +8 -2
- package/dist/utils/on-property-set.d.ts +0 -9
- package/dist/utils/on-property-set.js +0 -38
- package/dist/utils/on-property-set.js.map +0 -1
|
@@ -4,294 +4,12 @@ export type RootProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
4
4
|
/** Don't move focus. */
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
};
|
|
7
|
-
export declare function Root({ disabled, ...props }: RootProps): React.
|
|
8
|
-
disabled: string;
|
|
9
|
-
defaultChecked?: boolean;
|
|
10
|
-
defaultValue?: string | number | readonly string[];
|
|
11
|
-
suppressContentEditableWarning?: boolean;
|
|
12
|
-
suppressHydrationWarning?: boolean;
|
|
13
|
-
accessKey?: string;
|
|
14
|
-
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {});
|
|
15
|
-
autoFocus?: boolean;
|
|
16
|
-
className?: string;
|
|
17
|
-
contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only";
|
|
18
|
-
contextMenu?: string;
|
|
19
|
-
dir?: string;
|
|
20
|
-
draggable?: boolean | "false" | "true";
|
|
21
|
-
enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send";
|
|
22
|
-
hidden?: boolean;
|
|
23
|
-
id?: string;
|
|
24
|
-
lang?: string;
|
|
25
|
-
nonce?: string;
|
|
26
|
-
slot?: string;
|
|
27
|
-
spellCheck?: boolean | "false" | "true";
|
|
28
|
-
style?: React.CSSProperties;
|
|
29
|
-
tabIndex?: number;
|
|
30
|
-
title?: string;
|
|
31
|
-
translate?: "yes" | "no";
|
|
32
|
-
radioGroup?: string;
|
|
33
|
-
role?: React.AriaRole;
|
|
34
|
-
about?: string;
|
|
35
|
-
content?: string;
|
|
36
|
-
datatype?: string;
|
|
37
|
-
inlist?: any;
|
|
38
|
-
prefix?: string;
|
|
39
|
-
property?: string;
|
|
40
|
-
rel?: string;
|
|
41
|
-
resource?: string;
|
|
42
|
-
rev?: string;
|
|
43
|
-
typeof?: string;
|
|
44
|
-
vocab?: string;
|
|
45
|
-
autoCorrect?: string;
|
|
46
|
-
autoSave?: string;
|
|
47
|
-
color?: string;
|
|
48
|
-
itemProp?: string;
|
|
49
|
-
itemScope?: boolean;
|
|
50
|
-
itemType?: string;
|
|
51
|
-
itemID?: string;
|
|
52
|
-
itemRef?: string;
|
|
53
|
-
results?: number;
|
|
54
|
-
security?: string;
|
|
55
|
-
unselectable?: "off" | "on";
|
|
56
|
-
popover?: "" | "auto" | "manual" | "hint";
|
|
57
|
-
popoverTargetAction?: "toggle" | "show" | "hide";
|
|
58
|
-
popoverTarget?: string;
|
|
59
|
-
inert?: boolean;
|
|
60
|
-
inputMode?: "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal";
|
|
61
|
-
is?: string;
|
|
62
|
-
exportparts?: string;
|
|
63
|
-
part?: string;
|
|
64
|
-
"aria-activedescendant"?: string;
|
|
65
|
-
"aria-atomic"?: boolean | "false" | "true";
|
|
66
|
-
"aria-autocomplete"?: "none" | "list" | "inline" | "both";
|
|
67
|
-
"aria-braillelabel"?: string;
|
|
68
|
-
"aria-brailleroledescription"?: string;
|
|
69
|
-
"aria-busy"?: boolean | "false" | "true";
|
|
70
|
-
"aria-checked"?: boolean | "false" | "true" | "mixed";
|
|
71
|
-
"aria-colcount"?: number;
|
|
72
|
-
"aria-colindex"?: number;
|
|
73
|
-
"aria-colindextext"?: string;
|
|
74
|
-
"aria-colspan"?: number;
|
|
75
|
-
"aria-controls"?: string;
|
|
76
|
-
"aria-current"?: boolean | "time" | "false" | "true" | "page" | "step" | "location" | "date";
|
|
77
|
-
"aria-describedby"?: string;
|
|
78
|
-
"aria-description"?: string;
|
|
79
|
-
"aria-details"?: string;
|
|
80
|
-
"aria-disabled"?: boolean | "false" | "true";
|
|
81
|
-
"aria-dropeffect"?: "link" | "copy" | "none" | "execute" | "move" | "popup";
|
|
82
|
-
"aria-errormessage"?: string;
|
|
83
|
-
"aria-expanded"?: boolean | "false" | "true";
|
|
84
|
-
"aria-flowto"?: string;
|
|
85
|
-
"aria-grabbed"?: boolean | "false" | "true";
|
|
86
|
-
"aria-haspopup"?: boolean | "dialog" | "menu" | "false" | "true" | "grid" | "listbox" | "tree";
|
|
87
|
-
"aria-hidden"?: boolean | "false" | "true";
|
|
88
|
-
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling";
|
|
89
|
-
"aria-keyshortcuts"?: string;
|
|
90
|
-
"aria-label"?: string;
|
|
91
|
-
"aria-labelledby"?: string;
|
|
92
|
-
"aria-level"?: number;
|
|
93
|
-
"aria-live"?: "off" | "assertive" | "polite";
|
|
94
|
-
"aria-modal"?: boolean | "false" | "true";
|
|
95
|
-
"aria-multiline"?: boolean | "false" | "true";
|
|
96
|
-
"aria-multiselectable"?: boolean | "false" | "true";
|
|
97
|
-
"aria-orientation"?: "horizontal" | "vertical";
|
|
98
|
-
"aria-owns"?: string;
|
|
99
|
-
"aria-placeholder"?: string;
|
|
100
|
-
"aria-posinset"?: number;
|
|
101
|
-
"aria-pressed"?: boolean | "false" | "true" | "mixed";
|
|
102
|
-
"aria-readonly"?: boolean | "false" | "true";
|
|
103
|
-
"aria-relevant"?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
|
|
104
|
-
"aria-required"?: boolean | "false" | "true";
|
|
105
|
-
"aria-roledescription"?: string;
|
|
106
|
-
"aria-rowcount"?: number;
|
|
107
|
-
"aria-rowindex"?: number;
|
|
108
|
-
"aria-rowindextext"?: string;
|
|
109
|
-
"aria-rowspan"?: number;
|
|
110
|
-
"aria-selected"?: boolean | "false" | "true";
|
|
111
|
-
"aria-setsize"?: number;
|
|
112
|
-
"aria-sort"?: "none" | "ascending" | "descending" | "other";
|
|
113
|
-
"aria-valuemax"?: number;
|
|
114
|
-
"aria-valuemin"?: number;
|
|
115
|
-
"aria-valuenow"?: number;
|
|
116
|
-
"aria-valuetext"?: string;
|
|
117
|
-
children?: React.ReactNode;
|
|
118
|
-
dangerouslySetInnerHTML?: {
|
|
119
|
-
__html: string | TrustedHTML;
|
|
120
|
-
};
|
|
121
|
-
onCopy?: React.ClipboardEventHandler<HTMLElement>;
|
|
122
|
-
onCopyCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
123
|
-
onCut?: React.ClipboardEventHandler<HTMLElement>;
|
|
124
|
-
onCutCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
125
|
-
onPaste?: React.ClipboardEventHandler<HTMLElement>;
|
|
126
|
-
onPasteCapture?: React.ClipboardEventHandler<HTMLElement>;
|
|
127
|
-
onCompositionEnd?: React.CompositionEventHandler<HTMLElement>;
|
|
128
|
-
onCompositionEndCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
129
|
-
onCompositionStart?: React.CompositionEventHandler<HTMLElement>;
|
|
130
|
-
onCompositionStartCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
131
|
-
onCompositionUpdate?: React.CompositionEventHandler<HTMLElement>;
|
|
132
|
-
onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLElement>;
|
|
133
|
-
onFocus?: React.FocusEventHandler<HTMLElement>;
|
|
134
|
-
onFocusCapture?: React.FocusEventHandler<HTMLElement>;
|
|
135
|
-
onBlur?: React.FocusEventHandler<HTMLElement>;
|
|
136
|
-
onBlurCapture?: React.FocusEventHandler<HTMLElement>;
|
|
137
|
-
onChange?: React.ChangeEventHandler<HTMLElement, Element>;
|
|
138
|
-
onChangeCapture?: React.ChangeEventHandler<HTMLElement, Element>;
|
|
139
|
-
onBeforeInput?: React.InputEventHandler<HTMLElement>;
|
|
140
|
-
onBeforeInputCapture?: React.InputEventHandler<HTMLElement>;
|
|
141
|
-
onInput?: React.InputEventHandler<HTMLElement>;
|
|
142
|
-
onInputCapture?: React.InputEventHandler<HTMLElement>;
|
|
143
|
-
onReset?: React.ReactEventHandler<HTMLElement>;
|
|
144
|
-
onResetCapture?: React.ReactEventHandler<HTMLElement>;
|
|
145
|
-
onSubmit?: React.SubmitEventHandler<HTMLElement>;
|
|
146
|
-
onSubmitCapture?: React.SubmitEventHandler<HTMLElement>;
|
|
147
|
-
onInvalid?: React.ReactEventHandler<HTMLElement>;
|
|
148
|
-
onInvalidCapture?: React.ReactEventHandler<HTMLElement>;
|
|
149
|
-
onLoad?: React.ReactEventHandler<HTMLElement>;
|
|
150
|
-
onLoadCapture?: React.ReactEventHandler<HTMLElement>;
|
|
151
|
-
onError?: React.ReactEventHandler<HTMLElement>;
|
|
152
|
-
onErrorCapture?: React.ReactEventHandler<HTMLElement>;
|
|
153
|
-
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
154
|
-
onKeyDownCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
155
|
-
onKeyPress?: React.KeyboardEventHandler<HTMLElement>;
|
|
156
|
-
onKeyPressCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
157
|
-
onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
|
|
158
|
-
onKeyUpCapture?: React.KeyboardEventHandler<HTMLElement>;
|
|
159
|
-
onAbort?: React.ReactEventHandler<HTMLElement>;
|
|
160
|
-
onAbortCapture?: React.ReactEventHandler<HTMLElement>;
|
|
161
|
-
onCanPlay?: React.ReactEventHandler<HTMLElement>;
|
|
162
|
-
onCanPlayCapture?: React.ReactEventHandler<HTMLElement>;
|
|
163
|
-
onCanPlayThrough?: React.ReactEventHandler<HTMLElement>;
|
|
164
|
-
onCanPlayThroughCapture?: React.ReactEventHandler<HTMLElement>;
|
|
165
|
-
onDurationChange?: React.ReactEventHandler<HTMLElement>;
|
|
166
|
-
onDurationChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
167
|
-
onEmptied?: React.ReactEventHandler<HTMLElement>;
|
|
168
|
-
onEmptiedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
169
|
-
onEncrypted?: React.ReactEventHandler<HTMLElement>;
|
|
170
|
-
onEncryptedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
171
|
-
onEnded?: React.ReactEventHandler<HTMLElement>;
|
|
172
|
-
onEndedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
173
|
-
onLoadedData?: React.ReactEventHandler<HTMLElement>;
|
|
174
|
-
onLoadedDataCapture?: React.ReactEventHandler<HTMLElement>;
|
|
175
|
-
onLoadedMetadata?: React.ReactEventHandler<HTMLElement>;
|
|
176
|
-
onLoadedMetadataCapture?: React.ReactEventHandler<HTMLElement>;
|
|
177
|
-
onLoadStart?: React.ReactEventHandler<HTMLElement>;
|
|
178
|
-
onLoadStartCapture?: React.ReactEventHandler<HTMLElement>;
|
|
179
|
-
onPause?: React.ReactEventHandler<HTMLElement>;
|
|
180
|
-
onPauseCapture?: React.ReactEventHandler<HTMLElement>;
|
|
181
|
-
onPlay?: React.ReactEventHandler<HTMLElement>;
|
|
182
|
-
onPlayCapture?: React.ReactEventHandler<HTMLElement>;
|
|
183
|
-
onPlaying?: React.ReactEventHandler<HTMLElement>;
|
|
184
|
-
onPlayingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
185
|
-
onProgress?: React.ReactEventHandler<HTMLElement>;
|
|
186
|
-
onProgressCapture?: React.ReactEventHandler<HTMLElement>;
|
|
187
|
-
onRateChange?: React.ReactEventHandler<HTMLElement>;
|
|
188
|
-
onRateChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
189
|
-
onSeeked?: React.ReactEventHandler<HTMLElement>;
|
|
190
|
-
onSeekedCapture?: React.ReactEventHandler<HTMLElement>;
|
|
191
|
-
onSeeking?: React.ReactEventHandler<HTMLElement>;
|
|
192
|
-
onSeekingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
193
|
-
onStalled?: React.ReactEventHandler<HTMLElement>;
|
|
194
|
-
onStalledCapture?: React.ReactEventHandler<HTMLElement>;
|
|
195
|
-
onSuspend?: React.ReactEventHandler<HTMLElement>;
|
|
196
|
-
onSuspendCapture?: React.ReactEventHandler<HTMLElement>;
|
|
197
|
-
onTimeUpdate?: React.ReactEventHandler<HTMLElement>;
|
|
198
|
-
onTimeUpdateCapture?: React.ReactEventHandler<HTMLElement>;
|
|
199
|
-
onVolumeChange?: React.ReactEventHandler<HTMLElement>;
|
|
200
|
-
onVolumeChangeCapture?: React.ReactEventHandler<HTMLElement>;
|
|
201
|
-
onWaiting?: React.ReactEventHandler<HTMLElement>;
|
|
202
|
-
onWaitingCapture?: React.ReactEventHandler<HTMLElement>;
|
|
203
|
-
onAuxClick?: React.MouseEventHandler<HTMLElement>;
|
|
204
|
-
onAuxClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
205
|
-
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
206
|
-
onClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
207
|
-
onContextMenu?: React.MouseEventHandler<HTMLElement>;
|
|
208
|
-
onContextMenuCapture?: React.MouseEventHandler<HTMLElement>;
|
|
209
|
-
onDoubleClick?: React.MouseEventHandler<HTMLElement>;
|
|
210
|
-
onDoubleClickCapture?: React.MouseEventHandler<HTMLElement>;
|
|
211
|
-
onDrag?: React.DragEventHandler<HTMLElement>;
|
|
212
|
-
onDragCapture?: React.DragEventHandler<HTMLElement>;
|
|
213
|
-
onDragEnd?: React.DragEventHandler<HTMLElement>;
|
|
214
|
-
onDragEndCapture?: React.DragEventHandler<HTMLElement>;
|
|
215
|
-
onDragEnter?: React.DragEventHandler<HTMLElement>;
|
|
216
|
-
onDragEnterCapture?: React.DragEventHandler<HTMLElement>;
|
|
217
|
-
onDragExit?: React.DragEventHandler<HTMLElement>;
|
|
218
|
-
onDragExitCapture?: React.DragEventHandler<HTMLElement>;
|
|
219
|
-
onDragLeave?: React.DragEventHandler<HTMLElement>;
|
|
220
|
-
onDragLeaveCapture?: React.DragEventHandler<HTMLElement>;
|
|
221
|
-
onDragOver?: React.DragEventHandler<HTMLElement>;
|
|
222
|
-
onDragOverCapture?: React.DragEventHandler<HTMLElement>;
|
|
223
|
-
onDragStart?: React.DragEventHandler<HTMLElement>;
|
|
224
|
-
onDragStartCapture?: React.DragEventHandler<HTMLElement>;
|
|
225
|
-
onDrop?: React.DragEventHandler<HTMLElement>;
|
|
226
|
-
onDropCapture?: React.DragEventHandler<HTMLElement>;
|
|
227
|
-
onMouseDown?: React.MouseEventHandler<HTMLElement>;
|
|
228
|
-
onMouseDownCapture?: React.MouseEventHandler<HTMLElement>;
|
|
229
|
-
onMouseEnter?: React.MouseEventHandler<HTMLElement>;
|
|
230
|
-
onMouseLeave?: React.MouseEventHandler<HTMLElement>;
|
|
231
|
-
onMouseMove?: React.MouseEventHandler<HTMLElement>;
|
|
232
|
-
onMouseMoveCapture?: React.MouseEventHandler<HTMLElement>;
|
|
233
|
-
onMouseOut?: React.MouseEventHandler<HTMLElement>;
|
|
234
|
-
onMouseOutCapture?: React.MouseEventHandler<HTMLElement>;
|
|
235
|
-
onMouseOver?: React.MouseEventHandler<HTMLElement>;
|
|
236
|
-
onMouseOverCapture?: React.MouseEventHandler<HTMLElement>;
|
|
237
|
-
onMouseUp?: React.MouseEventHandler<HTMLElement>;
|
|
238
|
-
onMouseUpCapture?: React.MouseEventHandler<HTMLElement>;
|
|
239
|
-
onSelect?: React.ReactEventHandler<HTMLElement>;
|
|
240
|
-
onSelectCapture?: React.ReactEventHandler<HTMLElement>;
|
|
241
|
-
onTouchCancel?: React.TouchEventHandler<HTMLElement>;
|
|
242
|
-
onTouchCancelCapture?: React.TouchEventHandler<HTMLElement>;
|
|
243
|
-
onTouchEnd?: React.TouchEventHandler<HTMLElement>;
|
|
244
|
-
onTouchEndCapture?: React.TouchEventHandler<HTMLElement>;
|
|
245
|
-
onTouchMove?: React.TouchEventHandler<HTMLElement>;
|
|
246
|
-
onTouchMoveCapture?: React.TouchEventHandler<HTMLElement>;
|
|
247
|
-
onTouchStart?: React.TouchEventHandler<HTMLElement>;
|
|
248
|
-
onTouchStartCapture?: React.TouchEventHandler<HTMLElement>;
|
|
249
|
-
onPointerDown?: React.PointerEventHandler<HTMLElement>;
|
|
250
|
-
onPointerDownCapture?: React.PointerEventHandler<HTMLElement>;
|
|
251
|
-
onPointerMove?: React.PointerEventHandler<HTMLElement>;
|
|
252
|
-
onPointerMoveCapture?: React.PointerEventHandler<HTMLElement>;
|
|
253
|
-
onPointerUp?: React.PointerEventHandler<HTMLElement>;
|
|
254
|
-
onPointerUpCapture?: React.PointerEventHandler<HTMLElement>;
|
|
255
|
-
onPointerCancel?: React.PointerEventHandler<HTMLElement>;
|
|
256
|
-
onPointerCancelCapture?: React.PointerEventHandler<HTMLElement>;
|
|
257
|
-
onPointerEnter?: React.PointerEventHandler<HTMLElement>;
|
|
258
|
-
onPointerLeave?: React.PointerEventHandler<HTMLElement>;
|
|
259
|
-
onPointerOver?: React.PointerEventHandler<HTMLElement>;
|
|
260
|
-
onPointerOverCapture?: React.PointerEventHandler<HTMLElement>;
|
|
261
|
-
onPointerOut?: React.PointerEventHandler<HTMLElement>;
|
|
262
|
-
onPointerOutCapture?: React.PointerEventHandler<HTMLElement>;
|
|
263
|
-
onGotPointerCapture?: React.PointerEventHandler<HTMLElement>;
|
|
264
|
-
onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
|
|
265
|
-
onLostPointerCapture?: React.PointerEventHandler<HTMLElement>;
|
|
266
|
-
onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>;
|
|
267
|
-
onScroll?: React.UIEventHandler<HTMLElement>;
|
|
268
|
-
onScrollCapture?: React.UIEventHandler<HTMLElement>;
|
|
269
|
-
onScrollEnd?: React.UIEventHandler<HTMLElement>;
|
|
270
|
-
onScrollEndCapture?: React.UIEventHandler<HTMLElement>;
|
|
271
|
-
onWheel?: React.WheelEventHandler<HTMLElement>;
|
|
272
|
-
onWheelCapture?: React.WheelEventHandler<HTMLElement>;
|
|
273
|
-
onAnimationStart?: React.AnimationEventHandler<HTMLElement>;
|
|
274
|
-
onAnimationStartCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
275
|
-
onAnimationEnd?: React.AnimationEventHandler<HTMLElement>;
|
|
276
|
-
onAnimationEndCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
277
|
-
onAnimationIteration?: React.AnimationEventHandler<HTMLElement>;
|
|
278
|
-
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement>;
|
|
279
|
-
onToggle?: React.ToggleEventHandler<HTMLElement>;
|
|
280
|
-
onBeforeToggle?: React.ToggleEventHandler<HTMLElement>;
|
|
281
|
-
onTransitionCancel?: React.TransitionEventHandler<HTMLElement>;
|
|
282
|
-
onTransitionCancelCapture?: React.TransitionEventHandler<HTMLElement>;
|
|
283
|
-
onTransitionEnd?: React.TransitionEventHandler<HTMLElement>;
|
|
284
|
-
onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement>;
|
|
285
|
-
onTransitionRun?: React.TransitionEventHandler<HTMLElement>;
|
|
286
|
-
onTransitionRunCapture?: React.TransitionEventHandler<HTMLElement>;
|
|
287
|
-
onTransitionStart?: React.TransitionEventHandler<HTMLElement>;
|
|
288
|
-
onTransitionStartCapture?: React.TransitionEventHandler<HTMLElement>;
|
|
289
|
-
}, Element>;
|
|
7
|
+
export declare function Root({ disabled, ...props }: RootProps): React.JSX.Element;
|
|
290
8
|
export type TargetProps = ComponentProps<'div'> & {
|
|
291
9
|
/** Render the only child instead, with this part's props merged onto it. */
|
|
292
10
|
asChild?: boolean;
|
|
293
|
-
/** Don't move focus.
|
|
11
|
+
/** Don't move focus. Defaults to Root's. */
|
|
294
12
|
disabled?: boolean;
|
|
295
13
|
};
|
|
296
14
|
/** What gets focus. */
|
|
297
|
-
export declare function Target({ asChild, disabled, ...props }: TargetProps): React.JSX.Element;
|
|
15
|
+
export declare function Target({ asChild, disabled: disabledProp, ...props }: TargetProps): React.JSX.Element;
|
package/dist/auto-focus/index.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { isValidElement } from 'react';
|
|
3
|
+
import { createContext, isValidElement, useContext } from 'react';
|
|
4
4
|
import { Slot } from '../utils/slot.js';
|
|
5
5
|
import { tagName } from './element.js';
|
|
6
|
+
/*
|
|
7
|
+
* Headless auto focus: the <govuk-react-auto-focus> element (./element.ts) moves focus to its
|
|
8
|
+
* `Target` when it appears. The server renders the target with `autofocus`, so the browser focuses
|
|
9
|
+
* it when the page loads, even without JavaScript.
|
|
10
|
+
*
|
|
11
|
+
* Context only fills in a default: in an island without a Root, pass `disabled` to Target.
|
|
12
|
+
*/
|
|
13
|
+
const AutoFocusContext = createContext({});
|
|
6
14
|
export function Root({ disabled, ...props }) {
|
|
7
|
-
return React.createElement(tagName, { ...props, disabled: disabled ? '' : undefined });
|
|
15
|
+
return (React.createElement(AutoFocusContext.Provider, { value: { disabled } }, React.createElement(tagName, { ...props, disabled: disabled ? '' : undefined })));
|
|
8
16
|
}
|
|
9
17
|
/** The tabindex of the target, or with `asChild`, of its child. */
|
|
10
18
|
function tabIndexOf({ asChild, tabIndex, children }) {
|
|
@@ -13,7 +21,9 @@ function tabIndexOf({ asChild, tabIndex, children }) {
|
|
|
13
21
|
return isValidElement(children) ? children.props.tabIndex : undefined;
|
|
14
22
|
}
|
|
15
23
|
/** What gets focus. */
|
|
16
|
-
export function Target({ asChild, disabled, ...props }) {
|
|
24
|
+
export function Target({ asChild, disabled: disabledProp, ...props }) {
|
|
25
|
+
const context = useContext(AutoFocusContext);
|
|
26
|
+
const disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : context.disabled;
|
|
17
27
|
const Element = asChild ? Slot : 'div';
|
|
18
28
|
let focus = {};
|
|
19
29
|
if (!disabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auto-focus/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auto-focus/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;GAMG;AAEH,MAAM,gBAAgB,GAAG,aAAa,CAAyB,EAAE,CAAC,CAAC;AAOnE,MAAM,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAa;IACpD,OAAO,CACL,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAC3C,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CACtD,CAC7B,CAAC;AACJ,CAAC;AASD,mEAAmE;AACnE,SAAS,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAe;IAC9D,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,OAAO;QAAE,OAAO,QAAQ,CAAC;IACxD,OAAO,cAAc,CAAwB,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CAAC;AAED,uBAAuB;AACvB,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,KAAK,EAAe;IAC/E,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,OAAO,CAAC,QAAQ,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACvC,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,4FAA4F;QAC5F,KAAK;YACH,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,KAAK,SAAS;gBAC7C,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,EAAE;gBAC9D,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;IACD,wEAAwE;IACxE,OAAO,oBAAC,OAAO,uBAAiB,EAAE,EAAC,wBAAwB,WAAK,KAAK,KAAM,KAAK,GAAI,CAAC;AACvF,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createContext, isValidElement, useContext } from 'react';\nimport type { ComponentProps } from 'react';\nimport { Slot } from '../utils/slot.js';\nimport { tagName } from './element.js';\n\n/*\n * Headless auto focus: the <govuk-react-auto-focus> element (./element.ts) moves focus to its\n * `Target` when it appears. The server renders the target with `autofocus`, so the browser focuses\n * it when the page loads, even without JavaScript.\n *\n * Context only fills in a default: in an island without a Root, pass `disabled` to Target.\n */\n\nconst AutoFocusContext = createContext<{ disabled?: boolean }>({});\n\nexport type RootProps = React.HTMLAttributes<HTMLElement> & {\n /** Don't move focus. */\n disabled?: boolean;\n};\n\nexport function Root({ disabled, ...props }: RootProps) {\n return (\n <AutoFocusContext.Provider value={{ disabled }}>\n {React.createElement(tagName, { ...props, disabled: disabled ? '' : undefined })}\n </AutoFocusContext.Provider>\n );\n}\n\nexport type TargetProps = ComponentProps<'div'> & {\n /** Render the only child instead, with this part's props merged onto it. */\n asChild?: boolean;\n /** Don't move focus. Defaults to Root's. */\n disabled?: boolean;\n};\n\n/** The tabindex of the target, or with `asChild`, of its child. */\nfunction tabIndexOf({ asChild, tabIndex, children }: TargetProps) {\n if (tabIndex !== undefined || !asChild) return tabIndex;\n return isValidElement<{ tabIndex?: number }>(children) ? children.props.tabIndex : undefined;\n}\n\n/** What gets focus. */\nexport function Target({ asChild, disabled: disabledProp, ...props }: TargetProps) {\n const context = useContext(AutoFocusContext);\n const disabled = disabledProp ?? context.disabled;\n const Element = asChild ? Slot : 'div';\n let focus = {};\n if (!disabled) {\n // `data-focus-tabindex` says the tabindex is only for this, so it goes when focus moves on.\n focus =\n tabIndexOf({ asChild, ...props }) === undefined\n ? { tabIndex: -1, autoFocus: true, 'data-focus-tabindex': '' }\n : { autoFocus: true };\n }\n // The element owns `tabindex` and `autofocus` after it has moved focus.\n return <Element data-auto-focus=\"\" suppressHydrationWarning {...focus} {...props} />;\n}\n"]}
|
|
@@ -6,6 +6,9 @@ export interface AutocompleteElement extends HTMLElement {
|
|
|
6
6
|
readonly query: string | undefined;
|
|
7
7
|
}
|
|
8
8
|
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'govuk-react-autocomplete': AutocompleteElement;
|
|
11
|
+
}
|
|
9
12
|
interface HTMLElementEventMap {
|
|
10
13
|
'govuk-react-autocomplete:query': CustomEvent<{
|
|
11
14
|
query: string;
|
|
@@ -17,10 +20,10 @@ declare global {
|
|
|
17
20
|
}
|
|
18
21
|
/** accessible-autocomplete's English text. */
|
|
19
22
|
export declare const defaults: {
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
23
|
+
'query-too-short-announcement': string;
|
|
24
|
+
'no-results-announcement': string;
|
|
25
|
+
'selected-option-announcement': string;
|
|
26
|
+
'results-announcement': {
|
|
24
27
|
one: string;
|
|
25
28
|
other: string;
|
|
26
29
|
};
|
|
@@ -37,10 +37,10 @@ var _a;
|
|
|
37
37
|
* as in accessible-autocomplete, the highlighted option is confirmed.
|
|
38
38
|
* - `submit-on-confirm`: submit the input's form when the user confirms an option, and let Enter
|
|
39
39
|
* submit it while the menu is open with no option highlighted.
|
|
40
|
-
* - `
|
|
40
|
+
* - `query-too-short-announcement`, `no-results-announcement`, `selected-option-announcement`, `results-announcement`:
|
|
41
41
|
* what screen readers hear, English by default, with `%{count}` for the number and, in
|
|
42
|
-
* `
|
|
43
|
-
* as `
|
|
42
|
+
* `selected-option-announcement`, `%{option}` and `%{position}`. Add a plural form to the name, such
|
|
43
|
+
* as `results-announcement-one`, for a message for each form.
|
|
44
44
|
*
|
|
45
45
|
* Events, which bubble:
|
|
46
46
|
* - `govuk-react-autocomplete:query`, when the user changes the query and options are due.
|
|
@@ -52,10 +52,10 @@ import { setText, setAttribute } from '../utils/dom.js';
|
|
|
52
52
|
export const tagName = 'govuk-react-autocomplete';
|
|
53
53
|
/** accessible-autocomplete's English text. */
|
|
54
54
|
export const defaults = {
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
55
|
+
'query-too-short-announcement': 'Type in %{count} or more characters for results',
|
|
56
|
+
'no-results-announcement': 'No search results',
|
|
57
|
+
'selected-option-announcement': '%{option} %{position} of %{count} is highlighted',
|
|
58
|
+
'results-announcement': { one: '%{count} result is available.', other: '%{count} results are available.' },
|
|
59
59
|
};
|
|
60
60
|
/** As accessible-autocomplete, which waits this long after the last change before announcing. */
|
|
61
61
|
const statusDelay = 1400;
|
|
@@ -561,15 +561,15 @@ if (typeof HTMLElement !== 'undefined' && typeof customElements !== 'undefined')
|
|
|
561
561
|
statusText() {
|
|
562
562
|
const { locale, options } = this;
|
|
563
563
|
if (!this.queryLongEnough)
|
|
564
|
-
return translate(this.message('
|
|
564
|
+
return translate(this.message('query-too-short-announcement'), this.minLength, locale);
|
|
565
565
|
if (options.length === 0)
|
|
566
|
-
return translate(this.message('
|
|
567
|
-
const results = translate(this.message('
|
|
566
|
+
return translate(this.message('no-results-announcement'), 0, locale);
|
|
567
|
+
const results = translate(this.message('results-announcement'), options.length, locale);
|
|
568
568
|
const option = this.valueOf(this.selectedOption);
|
|
569
569
|
if (option === undefined || this.selected === null)
|
|
570
570
|
return results;
|
|
571
571
|
const position = withLocale(locale, (l) => new Intl.NumberFormat(l)).format(this.selected + 1);
|
|
572
|
-
const highlighted = translate(this.message('
|
|
572
|
+
const highlighted = translate(this.message('selected-option-announcement'), options.length, locale)
|
|
573
573
|
.replaceAll('%{option}', () => option)
|
|
574
574
|
.replaceAll('%{position}', () => position);
|
|
575
575
|
return `${results} ${highlighted}`;
|