@govuk-react/primitives 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -2
- package/dist/accordion/element.d.ts +14 -0
- 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/auto-focus/index.d.ts +297 -0
- package/dist/auto-focus/index.js +29 -0
- package/dist/auto-focus/index.js.map +1 -0
- package/dist/autocomplete/element.d.ts +27 -0
- package/dist/autocomplete/element.js +597 -0
- package/dist/autocomplete/element.js.map +1 -0
- package/dist/autocomplete/index.d.ts +350 -0
- 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 +7 -0
- 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/choices/index.d.ts +309 -0
- package/dist/choices/index.js +37 -0
- package/dist/choices/index.js.map +1 -0
- package/dist/disclosure/element.d.ts +14 -0
- package/dist/disclosure/element.js +123 -0
- package/dist/disclosure/element.js.map +1 -0
- package/dist/disclosure/index.d.ts +307 -0
- 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/exit-this-page/index.d.ts +330 -0
- 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 +23 -0
- 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/focus-links/index.d.ts +288 -0
- package/dist/focus-links/index.js +7 -0
- package/dist/focus-links/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/inline/accordion-element.js +1 -0
- package/dist/inline/auto-focus-element.js +1 -0
- package/dist/inline/autocomplete-element.js +2 -0
- package/dist/inline/button-element.js +1 -0
- package/dist/inline/character-count-element.js +1 -0
- package/dist/inline/choices-element.js +1 -0
- package/dist/inline/disclosure-element.js +1 -0
- package/dist/inline/exit-this-page-element.js +1 -0
- package/dist/inline/file-upload-element.js +1 -0
- package/dist/inline/focus-links-element.js +1 -0
- package/dist/inline/modal-element.js +1 -0
- package/dist/inline/password-input-element.js +1 -0
- package/dist/inline/tabs-element.js +1 -0
- 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 +10 -0
- 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/password-input/index.d.ts +318 -0
- package/dist/password-input/index.js +35 -0
- package/dist/password-input/index.js.map +1 -0
- package/dist/tabs/element.d.ts +19 -0
- 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/licences/accessible-autocomplete.txt +20 -0
- package/package.json +49 -4
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Hides the parts the element hides, over styles that set their `display`. Root renders it
|
|
5
|
+
* inline; under a strict CSP, add it to a stylesheet instead.
|
|
6
|
+
*/
|
|
7
|
+
export declare const accordionCss = "govuk-react-accordion :is([data-accordion-fallback],[data-accordion-trigger],[data-accordion-controls])[hidden]{display:none!important}";
|
|
8
|
+
export type RootProps = Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange'> & {
|
|
9
|
+
/** The open sections' values, to control them once hydrated. */
|
|
10
|
+
value?: string[];
|
|
11
|
+
/** The sections open at first. */
|
|
12
|
+
defaultValue?: string[];
|
|
13
|
+
/** Called with the open sections' values when the user opens or closes a section. */
|
|
14
|
+
onValueChange?: (value: string[]) => void;
|
|
15
|
+
/** Whether to remember the open sections for the rest of the session, keyed by content id. Defaults to `true`, as in govuk-frontend. */
|
|
16
|
+
rememberExpanded?: boolean;
|
|
17
|
+
/** Each button's text while its section is closed. Defaults to "Show". */
|
|
18
|
+
showSectionText?: string;
|
|
19
|
+
/** Each button's text while its section is open. Defaults to "Hide". */
|
|
20
|
+
hideSectionText?: string;
|
|
21
|
+
/** The end of each button's accessible name while its section is closed. Defaults to "Show this section". */
|
|
22
|
+
showSectionLabel?: string;
|
|
23
|
+
/** The end of each button's accessible name while its section is open. Defaults to "Hide this section". */
|
|
24
|
+
hideSectionLabel?: string;
|
|
25
|
+
/** The "show all" button's text while a section is closed. Defaults to "Show all sections". */
|
|
26
|
+
showAllSectionsText?: string;
|
|
27
|
+
/** The "show all" button's text while every section is open. Defaults to "Hide all sections". */
|
|
28
|
+
hideAllSectionsText?: string;
|
|
29
|
+
/** Classes added to the element when it upgrades. */
|
|
30
|
+
upgradedClass?: string;
|
|
31
|
+
/** Classes added to open sections. */
|
|
32
|
+
expandedSectionClass?: string;
|
|
33
|
+
/** Classes added to the icons of closed sections, and the "show all" icon while a section is closed. */
|
|
34
|
+
collapsedIconClass?: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function Root({ value, defaultValue, onValueChange, rememberExpanded, showSectionText, hideSectionText, showSectionLabel, hideSectionLabel, showAllSectionsText, hideAllSectionsText, upgradedClass, expandedSectionClass, collapsedIconClass, children, ...props }: RootProps): React.JSX.Element;
|
|
37
|
+
type PartProps<E extends keyof React.JSX.IntrinsicElements> = ComponentProps<E> & {
|
|
38
|
+
/** Render the only child instead, with this part's props merged onto it. */
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
};
|
|
41
|
+
export type ControlsProps = PartProps<'div'>;
|
|
42
|
+
/** Holds the "show all" button. Hidden until the element upgrades. */
|
|
43
|
+
export declare function Controls({ asChild, ...props }: ControlsProps): React.JSX.Element;
|
|
44
|
+
export type ShowAllProps = PartProps<'button'>;
|
|
45
|
+
/** Shows every section, or hides every section when all are open. */
|
|
46
|
+
export declare function ShowAll({ asChild, ...props }: ShowAllProps): React.JSX.Element;
|
|
47
|
+
export type ShowAllTextProps = PartProps<'span'>;
|
|
48
|
+
/** The "show all" button's text, which the element sets. */
|
|
49
|
+
export declare function ShowAllText({ asChild, children, ...props }: ShowAllTextProps): React.JSX.Element;
|
|
50
|
+
export type SectionProps = PartProps<'div'> & {
|
|
51
|
+
value: string;
|
|
52
|
+
/** Whether it's open at first. Defaults to whether Root's value includes it. */
|
|
53
|
+
defaultExpanded?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare function Section({ asChild, value, defaultExpanded, ...props }: SectionProps): React.JSX.Element;
|
|
56
|
+
export type FallbackProps = PartProps<'span'>;
|
|
57
|
+
/** What shows without JavaScript in place of the trigger, such as the plain heading. Hidden on upgrade. */
|
|
58
|
+
export declare function Fallback({ asChild, ...props }: FallbackProps): React.JSX.Element;
|
|
59
|
+
export type TriggerProps = PartProps<'button'>;
|
|
60
|
+
/** The button that shows and hides its section. Hidden until the element upgrades. */
|
|
61
|
+
export declare function Trigger({ asChild, ...props }: TriggerProps): React.JSX.Element;
|
|
62
|
+
export type LabelProps = PartProps<'span'>;
|
|
63
|
+
/** Text in the trigger that names it, such as the heading or summary. */
|
|
64
|
+
export declare function Label({ asChild, ...props }: LabelProps): React.JSX.Element;
|
|
65
|
+
export type ToggleTextProps = PartProps<'span'>;
|
|
66
|
+
/** The trigger's show or hide text, which the element sets. */
|
|
67
|
+
export declare function ToggleText({ asChild, children, ...props }: ToggleTextProps): React.JSX.Element;
|
|
68
|
+
export type IconProps = PartProps<'span'>;
|
|
69
|
+
/** An icon in a trigger or the "show all" button, given `collapsedIconClass` while closed. */
|
|
70
|
+
export declare function Icon({ asChild, ...props }: IconProps): React.JSX.Element;
|
|
71
|
+
export type ContentProps = PartProps<'div'>;
|
|
72
|
+
/** The section's content. Give it an id, which the trigger's `aria-controls` names. */
|
|
73
|
+
export declare function Content({ asChild, ...props }: ContentProps): React.JSX.Element;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createContext, useContext, useEffect, useRef } from 'react';
|
|
4
|
+
import { Slot } from '../utils/slot.js';
|
|
5
|
+
import { tagName } from './element.js';
|
|
6
|
+
const AccordionContext = createContext({ texts: {} });
|
|
7
|
+
const SectionContext = createContext({});
|
|
8
|
+
/**
|
|
9
|
+
* Hides the parts the element hides, over styles that set their `display`. Root renders it
|
|
10
|
+
* inline; under a strict CSP, add it to a stylesheet instead.
|
|
11
|
+
*/
|
|
12
|
+
export const accordionCss = `${tagName} :is([data-accordion-fallback],[data-accordion-trigger],[data-accordion-controls])[hidden]{display:none!important}`;
|
|
13
|
+
const isAccordion = (element) => 'pickedValue' in element;
|
|
14
|
+
export function Root({ value, defaultValue, onValueChange, rememberExpanded, showSectionText, hideSectionText, showSectionLabel, hideSectionLabel, showAllSectionsText, hideAllSectionsText, upgradedClass, expandedSectionClass, collapsedIconClass, children, ...props }) {
|
|
15
|
+
const element = useRef(null);
|
|
16
|
+
const onValueChangeRef = useRef(onValueChange);
|
|
17
|
+
const synced = useRef(false);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
onValueChangeRef.current = onValueChange;
|
|
20
|
+
});
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const node = element.current;
|
|
23
|
+
if (!node)
|
|
24
|
+
return undefined;
|
|
25
|
+
// A nested accordion's change bubbles through this one.
|
|
26
|
+
const onChange = (event) => {
|
|
27
|
+
var _a;
|
|
28
|
+
if (event.target === node)
|
|
29
|
+
(_a = onValueChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onValueChangeRef, event.detail.value);
|
|
30
|
+
};
|
|
31
|
+
node.addEventListener('govuk-react-accordion:change', onChange);
|
|
32
|
+
return () => node.removeEventListener('govuk-react-accordion:change', onChange);
|
|
33
|
+
}, []);
|
|
34
|
+
// `value` is set once hydrated, so the server markup is uncontrolled and a click before
|
|
35
|
+
// hydration still works. That click is then reported, rather than undone.
|
|
36
|
+
const controlled = value === null || value === void 0 ? void 0 : value.join(' ');
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const node = element.current;
|
|
39
|
+
if (!node || controlled === undefined) {
|
|
40
|
+
node === null || node === void 0 ? void 0 : node.removeAttribute('value');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!synced.current) {
|
|
44
|
+
synced.current = true;
|
|
45
|
+
const picked = isAccordion(node) ? node.pickedValue : undefined;
|
|
46
|
+
if (picked !== undefined && picked.join(' ') !== controlled && onValueChangeRef.current) {
|
|
47
|
+
onValueChangeRef.current(picked);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
node.setAttribute('value', controlled);
|
|
52
|
+
});
|
|
53
|
+
const initial = value !== null && value !== void 0 ? value : defaultValue;
|
|
54
|
+
return (React.createElement(AccordionContext.Provider, { value: { open: initial, texts: { showSectionText, hideSectionText, showAllSectionsText, hideAllSectionsText } } },
|
|
55
|
+
React.createElement("style", { href: `${tagName}-css`, precedence: "default" }, accordionCss),
|
|
56
|
+
React.createElement(tagName, {
|
|
57
|
+
...props,
|
|
58
|
+
ref: element,
|
|
59
|
+
'default-value': initial === null || initial === void 0 ? void 0 : initial.join(' '),
|
|
60
|
+
'remember-expanded': rememberExpanded === undefined ? undefined : String(rememberExpanded),
|
|
61
|
+
'show-section-text': showSectionText,
|
|
62
|
+
'hide-section-text': hideSectionText,
|
|
63
|
+
'show-section-label': showSectionLabel,
|
|
64
|
+
'hide-section-label': hideSectionLabel,
|
|
65
|
+
'show-all-sections-text': showAllSectionsText,
|
|
66
|
+
'hide-all-sections-text': hideAllSectionsText,
|
|
67
|
+
'upgraded-class': upgradedClass,
|
|
68
|
+
'expanded-section-class': expandedSectionClass,
|
|
69
|
+
'collapsed-icon-class': collapsedIconClass,
|
|
70
|
+
// The element adds attributes on upgrade, so they can differ from the server's.
|
|
71
|
+
suppressHydrationWarning: true,
|
|
72
|
+
}, children)));
|
|
73
|
+
}
|
|
74
|
+
/** Holds the "show all" button. Hidden until the element upgrades. */
|
|
75
|
+
export function Controls({ asChild, ...props }) {
|
|
76
|
+
const Element = asChild ? Slot : 'div';
|
|
77
|
+
return React.createElement(Element, { "data-accordion-controls": "", hidden: true, suppressHydrationWarning: true, ...props });
|
|
78
|
+
}
|
|
79
|
+
/** Shows every section, or hides every section when all are open. */
|
|
80
|
+
export function ShowAll({ asChild, ...props }) {
|
|
81
|
+
if (asChild)
|
|
82
|
+
return React.createElement(Slot, { "data-accordion-show-all": "", suppressHydrationWarning: true, ...props });
|
|
83
|
+
return React.createElement("button", { type: "button", "data-accordion-show-all": "", suppressHydrationWarning: true, ...props });
|
|
84
|
+
}
|
|
85
|
+
/** The "show all" button's text, which the element sets. */
|
|
86
|
+
export function ShowAllText({ asChild, children, ...props }) {
|
|
87
|
+
var _a;
|
|
88
|
+
const { texts } = useContext(AccordionContext);
|
|
89
|
+
const Element = asChild ? Slot : 'span';
|
|
90
|
+
// Rendered as the server would, so the element's text replaces it rather than adding to it.
|
|
91
|
+
return (React.createElement(Element, { "data-accordion-show-all-text": "", suppressHydrationWarning: true, ...props }, (_a = children !== null && children !== void 0 ? children : texts.showAllSectionsText) !== null && _a !== void 0 ? _a : 'Show all sections'));
|
|
92
|
+
}
|
|
93
|
+
export function Section({ asChild, value, defaultExpanded, ...props }) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
const context = useContext(AccordionContext);
|
|
96
|
+
const expanded = (_b = defaultExpanded !== null && defaultExpanded !== void 0 ? defaultExpanded : (_a = context.open) === null || _a === void 0 ? void 0 : _a.includes(value)) !== null && _b !== void 0 ? _b : false;
|
|
97
|
+
const Element = asChild ? Slot : 'div';
|
|
98
|
+
return (React.createElement(SectionContext.Provider, { value: { expanded } },
|
|
99
|
+
React.createElement(Element, { "data-accordion-section": "", "data-value": value, "data-expanded": expanded ? '' : undefined, suppressHydrationWarning: true, ...props })));
|
|
100
|
+
}
|
|
101
|
+
/** What shows without JavaScript in place of the trigger, such as the plain heading. Hidden on upgrade. */
|
|
102
|
+
export function Fallback({ asChild, ...props }) {
|
|
103
|
+
const Element = asChild ? Slot : 'span';
|
|
104
|
+
return React.createElement(Element, { "data-accordion-fallback": "", suppressHydrationWarning: true, ...props });
|
|
105
|
+
}
|
|
106
|
+
/** The button that shows and hides its section. Hidden until the element upgrades. */
|
|
107
|
+
export function Trigger({ asChild, ...props }) {
|
|
108
|
+
const shared = { 'data-accordion-trigger': '', hidden: true, suppressHydrationWarning: true };
|
|
109
|
+
if (asChild)
|
|
110
|
+
return React.createElement(Slot, { ...shared, ...props });
|
|
111
|
+
return React.createElement("button", { type: "button", ...shared, ...props });
|
|
112
|
+
}
|
|
113
|
+
/** Text in the trigger that names it, such as the heading or summary. */
|
|
114
|
+
export function Label({ asChild, ...props }) {
|
|
115
|
+
const Element = asChild ? Slot : 'span';
|
|
116
|
+
return React.createElement(Element, { "data-accordion-label": "", ...props });
|
|
117
|
+
}
|
|
118
|
+
/** The trigger's show or hide text, which the element sets. */
|
|
119
|
+
export function ToggleText({ asChild, children, ...props }) {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
const { texts } = useContext(AccordionContext);
|
|
122
|
+
const { expanded } = useContext(SectionContext);
|
|
123
|
+
const Element = asChild ? Slot : 'span';
|
|
124
|
+
// Rendered as the server would, so the element's text replaces it rather than adding to it.
|
|
125
|
+
return (React.createElement(Element, { "data-accordion-toggle-text": "", suppressHydrationWarning: true, ...props }, children !== null && children !== void 0 ? children : (expanded ? ((_a = texts.hideSectionText) !== null && _a !== void 0 ? _a : 'Hide') : ((_b = texts.showSectionText) !== null && _b !== void 0 ? _b : 'Show'))));
|
|
126
|
+
}
|
|
127
|
+
/** An icon in a trigger or the "show all" button, given `collapsedIconClass` while closed. */
|
|
128
|
+
export function Icon({ asChild, ...props }) {
|
|
129
|
+
const Element = asChild ? Slot : 'span';
|
|
130
|
+
return React.createElement(Element, { "data-accordion-icon": "", suppressHydrationWarning: true, ...props });
|
|
131
|
+
}
|
|
132
|
+
/** The section's content. Give it an id, which the trigger's `aria-controls` names. */
|
|
133
|
+
export function Content({ asChild, ...props }) {
|
|
134
|
+
const Element = asChild ? Slot : 'div';
|
|
135
|
+
// The element hides it after upgrade.
|
|
136
|
+
return React.createElement(Element, { "data-accordion-content": "", suppressHydrationWarning: true, ...props });
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accordion/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAyB,MAAM,cAAc,CAAC;AAoB9D,MAAM,gBAAgB,GAAG,aAAa,CAAoC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAEzF,MAAM,cAAc,GAAG,aAAa,CAAyB,EAAE,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,OAAO,oHAAoH,CAAC;AAE3J,MAAM,WAAW,GAAG,CAAC,OAAoB,EAA+B,EAAE,CAAC,aAAa,IAAI,OAAO,CAAC;AA+BpG,MAAM,UAAU,IAAI,CAAC,EACnB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ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,CAAC,KAAK,CAAC;IACvC,sCAAsC;IACtC,OAAO,oBAAC,OAAO,8BAAwB,EAAE,EAAC,wBAAwB,WAAK,KAAK,GAAI,CAAC;AACnF,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createContext, useContext, useEffect, useRef } from 'react';\nimport type { ComponentProps } from 'react';\nimport { Slot } from '../utils/slot.js';\nimport { tagName, type AccordionElement } from './element.js';\n\n/*\n * Headless accordion: unstyled parts over the <govuk-react-accordion> element (./element.ts).\n * Every part except Root takes `asChild`.\n *\n * Without JavaScript every section is shown under its `Fallback` heading. Each section also\n * holds a hidden `Trigger` with the same heading, which the element shows on upgrade. Put the\n * heading text in a `Label` inside the trigger, so the element can name the button.\n *\n * Context only fills in defaults: in an island without a Root, pass `defaultExpanded` to Section.\n */\n\ntype Texts = {\n showSectionText?: string;\n hideSectionText?: string;\n showAllSectionsText?: string;\n hideAllSectionsText?: string;\n};\n\nconst AccordionContext = createContext<{ open?: string[]; texts: Texts }>({ texts: {} });\n\nconst SectionContext = createContext<{ expanded?: boolean }>({});\n\n/**\n * Hides the parts the element hides, over styles that set their `display`. Root renders it\n * inline; under a strict CSP, add it to a stylesheet instead.\n */\nexport const accordionCss = `${tagName} :is([data-accordion-fallback],[data-accordion-trigger],[data-accordion-controls])[hidden]{display:none!important}`;\n\nconst isAccordion = (element: HTMLElement): element is AccordionElement => 'pickedValue' in element;\n\nexport type RootProps = Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange'> & {\n /** The open sections' values, to control them once hydrated. */\n value?: string[];\n /** The sections open at first. */\n defaultValue?: string[];\n /** Called with the open sections' values when the user opens or closes a section. */\n onValueChange?: (value: string[]) => void;\n /** Whether to remember the open sections for the rest of the session, keyed by content id. Defaults to `true`, as in govuk-frontend. */\n rememberExpanded?: boolean;\n /** Each button's text while its section is closed. Defaults to \"Show\". */\n showSectionText?: string;\n /** Each button's text while its section is open. Defaults to \"Hide\". */\n hideSectionText?: string;\n /** The end of each button's accessible name while its section is closed. Defaults to \"Show this section\". */\n showSectionLabel?: string;\n /** The end of each button's accessible name while its section is open. Defaults to \"Hide this section\". */\n hideSectionLabel?: string;\n /** The \"show all\" button's text while a section is closed. Defaults to \"Show all sections\". */\n showAllSectionsText?: string;\n /** The \"show all\" button's text while every section is open. Defaults to \"Hide all sections\". */\n hideAllSectionsText?: string;\n /** Classes added to the element when it upgrades. */\n upgradedClass?: string;\n /** Classes added to open sections. */\n expandedSectionClass?: string;\n /** Classes added to the icons of closed sections, and the \"show all\" icon while a section is closed. */\n collapsedIconClass?: string;\n};\n\nexport function Root({\n value,\n defaultValue,\n onValueChange,\n rememberExpanded,\n showSectionText,\n hideSectionText,\n showSectionLabel,\n hideSectionLabel,\n showAllSectionsText,\n hideAllSectionsText,\n upgradedClass,\n expandedSectionClass,\n collapsedIconClass,\n children,\n ...props\n}: RootProps) {\n const element = useRef<HTMLElement>(null);\n const onValueChangeRef = useRef(onValueChange);\n const synced = useRef(false);\n\n useEffect(() => {\n onValueChangeRef.current = onValueChange;\n });\n\n useEffect(() => {\n const node = element.current;\n if (!node) return undefined;\n // A nested accordion's change bubbles through this one.\n const onChange = (event: CustomEvent<{ value: string[] }>) => {\n if (event.target === node) onValueChangeRef.current?.(event.detail.value);\n };\n node.addEventListener('govuk-react-accordion:change', onChange);\n return () => node.removeEventListener('govuk-react-accordion:change', onChange);\n }, []);\n\n // `value` is set once hydrated, so the server markup is uncontrolled and a click before\n // hydration still works. That click is then reported, rather than undone.\n const controlled = value?.join(' ');\n useEffect(() => {\n const node = element.current;\n if (!node || controlled === undefined) {\n node?.removeAttribute('value');\n return;\n }\n if (!synced.current) {\n synced.current = true;\n const picked = isAccordion(node) ? node.pickedValue : undefined;\n if (picked !== undefined && picked.join(' ') !== controlled && onValueChangeRef.current) {\n onValueChangeRef.current(picked);\n return;\n }\n }\n node.setAttribute('value', controlled);\n });\n\n const initial = value ?? defaultValue;\n return (\n <AccordionContext.Provider\n value={{ open: initial, texts: { showSectionText, hideSectionText, showAllSectionsText, hideAllSectionsText } }}\n >\n <style href={`${tagName}-css`} precedence=\"default\">\n {accordionCss}\n </style>\n {React.createElement(\n tagName,\n {\n ...props,\n ref: element,\n 'default-value': initial?.join(' '),\n 'remember-expanded': rememberExpanded === undefined ? undefined : String(rememberExpanded),\n 'show-section-text': showSectionText,\n 'hide-section-text': hideSectionText,\n 'show-section-label': showSectionLabel,\n 'hide-section-label': hideSectionLabel,\n 'show-all-sections-text': showAllSectionsText,\n 'hide-all-sections-text': hideAllSectionsText,\n 'upgraded-class': upgradedClass,\n 'expanded-section-class': expandedSectionClass,\n 'collapsed-icon-class': collapsedIconClass,\n // The element adds attributes on upgrade, so they can differ from the server's.\n suppressHydrationWarning: true,\n },\n children\n )}\n </AccordionContext.Provider>\n );\n}\n\ntype PartProps<E extends keyof React.JSX.IntrinsicElements> = ComponentProps<E> & {\n /** Render the only child instead, with this part's props merged onto it. */\n asChild?: boolean;\n};\n\nexport type ControlsProps = PartProps<'div'>;\n\n/** Holds the \"show all\" button. Hidden until the element upgrades. */\nexport function Controls({ asChild, ...props }: ControlsProps) {\n const Element = asChild ? Slot : 'div';\n return <Element data-accordion-controls=\"\" hidden suppressHydrationWarning {...props} />;\n}\n\nexport type ShowAllProps = PartProps<'button'>;\n\n/** Shows every section, or hides every section when all are open. */\nexport function ShowAll({ asChild, ...props }: ShowAllProps) {\n if (asChild) return <Slot data-accordion-show-all=\"\" suppressHydrationWarning {...props} />;\n return <button type=\"button\" data-accordion-show-all=\"\" suppressHydrationWarning {...props} />;\n}\n\nexport type ShowAllTextProps = PartProps<'span'>;\n\n/** The \"show all\" button's text, which the element sets. */\nexport function ShowAllText({ asChild, children, ...props }: ShowAllTextProps) {\n const { texts } = useContext(AccordionContext);\n const Element = asChild ? Slot : 'span';\n // Rendered as the server would, so the element's text replaces it rather than adding to it.\n return (\n <Element data-accordion-show-all-text=\"\" suppressHydrationWarning {...props}>\n {children ?? texts.showAllSectionsText ?? 'Show all sections'}\n </Element>\n );\n}\n\nexport type SectionProps = PartProps<'div'> & {\n value: string;\n /** Whether it's open at first. Defaults to whether Root's value includes it. */\n defaultExpanded?: boolean;\n};\n\nexport function Section({ asChild, value, defaultExpanded, ...props }: SectionProps) {\n const context = useContext(AccordionContext);\n const expanded = defaultExpanded ?? context.open?.includes(value) ?? false;\n const Element = asChild ? Slot : 'div';\n return (\n <SectionContext.Provider value={{ expanded }}>\n <Element\n data-accordion-section=\"\"\n data-value={value}\n data-expanded={expanded ? '' : undefined}\n suppressHydrationWarning\n {...props}\n />\n </SectionContext.Provider>\n );\n}\n\nexport type FallbackProps = PartProps<'span'>;\n\n/** What shows without JavaScript in place of the trigger, such as the plain heading. Hidden on upgrade. */\nexport function Fallback({ asChild, ...props }: FallbackProps) {\n const Element = asChild ? Slot : 'span';\n return <Element data-accordion-fallback=\"\" suppressHydrationWarning {...props} />;\n}\n\nexport type TriggerProps = PartProps<'button'>;\n\n/** The button that shows and hides its section. Hidden until the element upgrades. */\nexport function Trigger({ asChild, ...props }: TriggerProps) {\n const shared = { 'data-accordion-trigger': '', hidden: true, suppressHydrationWarning: true };\n if (asChild) return <Slot {...shared} {...props} />;\n return <button type=\"button\" {...shared} {...props} />;\n}\n\nexport type LabelProps = PartProps<'span'>;\n\n/** Text in the trigger that names it, such as the heading or summary. */\nexport function Label({ asChild, ...props }: LabelProps) {\n const Element = asChild ? Slot : 'span';\n return <Element data-accordion-label=\"\" {...props} />;\n}\n\nexport type ToggleTextProps = PartProps<'span'>;\n\n/** The trigger's show or hide text, which the element sets. */\nexport function ToggleText({ asChild, children, ...props }: ToggleTextProps) {\n const { texts } = useContext(AccordionContext);\n const { expanded } = useContext(SectionContext);\n const Element = asChild ? Slot : 'span';\n // Rendered as the server would, so the element's text replaces it rather than adding to it.\n return (\n <Element data-accordion-toggle-text=\"\" suppressHydrationWarning {...props}>\n {children ?? (expanded ? (texts.hideSectionText ?? 'Hide') : (texts.showSectionText ?? 'Show'))}\n </Element>\n );\n}\n\nexport type IconProps = PartProps<'span'>;\n\n/** An icon in a trigger or the \"show all\" button, given `collapsedIconClass` while closed. */\nexport function Icon({ asChild, ...props }: IconProps) {\n const Element = asChild ? Slot : 'span';\n return <Element data-accordion-icon=\"\" suppressHydrationWarning {...props} />;\n}\n\nexport type ContentProps = PartProps<'div'>;\n\n/** The section's content. Give it an id, which the trigger's `aria-controls` names. */\nexport function Content({ asChild, ...props }: ContentProps) {\n const Element = asChild ? Slot : 'div';\n // The element hides it after upgrade.\n return <Element data-accordion-content=\"\" suppressHydrationWarning {...props} />;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tagName = "govuk-react-auto-focus";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* <govuk-react-auto-focus>: a headless, light-DOM custom element that moves focus to its target
|
|
3
|
+
* when it appears, such as an error summary or a success banner, with or without React. It moves
|
|
4
|
+
* focus once: give the element a new `key` in React to move it again, such as after each submit.
|
|
5
|
+
*
|
|
6
|
+
* The target is server-rendered with `tabindex="-1"` and `autofocus`, so the browser focuses it
|
|
7
|
+
* when the page loads, even without JavaScript. When the element connects later, such as when React
|
|
8
|
+
* renders the target after a form is submitted, the element focuses it. As in govuk-frontend, the
|
|
9
|
+
* target loses its `tabindex` when it loses focus. If the user has moved focus on before the script
|
|
10
|
+
* runs, it leaves them there. Without JavaScript the target keeps its `tabindex`.
|
|
11
|
+
*
|
|
12
|
+
* Markup inside the element:
|
|
13
|
+
* - `[data-auto-focus]`: the target. Without one, the element's first child.
|
|
14
|
+
*
|
|
15
|
+
* Attributes:
|
|
16
|
+
* - `disabled`: don't move focus.
|
|
17
|
+
*/
|
|
18
|
+
import { dropAutoFocus, setFocus } from '../utils/set-focus.js';
|
|
19
|
+
import { setUpWhenReady } from '../utils/set-up-when-ready.js';
|
|
20
|
+
export const tagName = 'govuk-react-auto-focus';
|
|
21
|
+
if (typeof HTMLElement !== 'undefined' && typeof customElements !== 'undefined') {
|
|
22
|
+
class GovukReactAutoFocus extends HTMLElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.focused = false;
|
|
26
|
+
}
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
// The target may not be parsed or rendered yet.
|
|
29
|
+
this.observer = setUpWhenReady(this, () => this.focusTarget());
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
var _a;
|
|
33
|
+
(_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
34
|
+
}
|
|
35
|
+
get target() {
|
|
36
|
+
var _a;
|
|
37
|
+
const target = (_a = Array.from(this.querySelectorAll('[data-auto-focus]')).find((found) => found.closest(tagName) === this)) !== null && _a !== void 0 ? _a : this.firstElementChild;
|
|
38
|
+
return target instanceof HTMLElement ? target : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** Focuses the target once, and says whether there was one to focus. */
|
|
41
|
+
focusTarget() {
|
|
42
|
+
if (this.focused)
|
|
43
|
+
return true;
|
|
44
|
+
const { target } = this;
|
|
45
|
+
if (!target)
|
|
46
|
+
return false;
|
|
47
|
+
this.focused = true;
|
|
48
|
+
if (this.hasAttribute('disabled'))
|
|
49
|
+
return true;
|
|
50
|
+
// Rendered by the server with `autofocus`, which React never sets on the client.
|
|
51
|
+
if (target.hasAttribute('autofocus')) {
|
|
52
|
+
const active = document.activeElement;
|
|
53
|
+
if (active === target) {
|
|
54
|
+
setFocus(target, { preventScroll: true });
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (active && active !== document.body) {
|
|
58
|
+
// The user moved on before this script ran: leave them there.
|
|
59
|
+
dropAutoFocus(target);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// React puts focus back where it was at the end of a commit, which can connect the element.
|
|
64
|
+
queueMicrotask(() => {
|
|
65
|
+
// Not in place yet, such as in a streamed boundary: try again when it moves.
|
|
66
|
+
if (!target.isConnected || !setFocus(target))
|
|
67
|
+
this.focused = false;
|
|
68
|
+
});
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!customElements.get(tagName))
|
|
73
|
+
customElements.define(tagName, GovukReactAutoFocus);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/auto-focus/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAEhD,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE,CAAC;IAChF,MAAM,mBAAoB,SAAQ,WAAW;QAA7C;;YACU,YAAO,GAAG,KAAK,CAAC;QA+C1B,CAAC;QA3CC,iBAAiB;YACf,gDAAgD;YAChD,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACjE,CAAC;QAED,oBAAoB;;YAClB,MAAA,IAAI,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAC;QAC9B,CAAC;QAED,IAAY,MAAM;;YAChB,MAAM,MAAM,GACV,MAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,mCACvG,IAAI,CAAC,iBAAiB,CAAC;YACzB,OAAO,MAAM,YAAY,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5D,CAAC;QAED,wEAAwE;QAChE,WAAW;YACjB,IAAI,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YAC9B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,MAAM;gBAAE,OAAO,KAAK,CAAC;YAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC/C,iFAAiF;YACjF,IAAI,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;gBACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC;gBACtC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;oBACtB,QAAQ,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC1C,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,IAAI,MAAM,IAAI,MAAM,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;oBACvC,8DAA8D;oBAC9D,aAAa,CAAC,MAAM,CAAC,CAAC;oBACtB,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YACD,4FAA4F;YAC5F,cAAc,CAAC,GAAG,EAAE;gBAClB,6EAA6E;gBAC7E,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;oBAAE,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrE,CAAC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;KACF;IAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AACxF,CAAC","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.js';\nimport { setUpWhenReady } from '../utils/set-up-when-ready.js';\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 // The target may not be parsed or rendered yet.\n this.observer = setUpWhenReady(this, () => this.focusTarget());\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"]}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
export type RootProps = React.HTMLAttributes<HTMLElement> & {
|
|
4
|
+
/** Don't move focus. */
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function Root({ disabled, ...props }: RootProps): React.DOMElement<{
|
|
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>;
|
|
290
|
+
export type TargetProps = ComponentProps<'div'> & {
|
|
291
|
+
/** Render the only child instead, with this part's props merged onto it. */
|
|
292
|
+
asChild?: boolean;
|
|
293
|
+
/** Don't move focus. Pass the same as to `Root`. */
|
|
294
|
+
disabled?: boolean;
|
|
295
|
+
};
|
|
296
|
+
/** What gets focus. */
|
|
297
|
+
export declare function Target({ asChild, disabled, ...props }: TargetProps): React.JSX.Element;
|