@trackunit/react-components 7.0.10 → 8.0.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/index.cjs.js +297 -128
- package/index.esm.js +297 -128
- package/migrations/assets/react-router-components/package.json +6 -6
- package/migrations/utils/jsx-utils.js +7 -1
- package/migrations/v7-0-0/collapse-native-details.js +593 -0
- package/migrations.json +5 -0
- package/package.json +6 -6
- package/src/components/Collapse/Collapse.d.ts +76 -8
- package/src/components/Collapse/Collapse.variants.d.ts +121 -87
- package/src/components/Collapse/utils/getInteractiveDescendant/getInteractiveDescendant.d.ts +5 -0
- package/src/components/Collapse/utils/isNativelyActivatable/isNativelyActivatable.d.ts +5 -0
- package/src/components/Tag/Tag.d.ts +9 -1
- package/src/components/buttons/Button/Button.d.ts +1 -1
- package/src/components/buttons/shared/ButtonProps.d.ts +11 -0
|
@@ -1,25 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement, ReactNode, SyntheticEvent } from "react";
|
|
2
2
|
import { CommonProps } from "../../common/CommonProps";
|
|
3
|
-
import type { Styleable } from "../../common/Styleable";
|
|
4
3
|
import { Refable } from "../../common/Refable";
|
|
4
|
+
import type { Styleable } from "../../common/Styleable";
|
|
5
5
|
export interface CollapseProps extends CommonProps, Styleable, Refable<HTMLDivElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Id of the content wrapper.
|
|
8
|
+
*/
|
|
6
9
|
id: string;
|
|
7
10
|
/**
|
|
8
11
|
* Visual variant of the collapse component.
|
|
9
12
|
*/
|
|
10
13
|
variant?: "primary" | "secondary";
|
|
11
14
|
/**
|
|
12
|
-
* Expands the collapse component during initialization.
|
|
15
|
+
* Expands the collapse component during initialization. Ignored when `expanded` is set.
|
|
13
16
|
*/
|
|
14
17
|
initialExpanded?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Controls the expanded state. When set, clicking the header (or pressing Enter or Space on it) calls
|
|
20
|
+
* `onToggle` with the requested state but doesn't change the section; update `expanded` to apply it.
|
|
21
|
+
*
|
|
22
|
+
* Controlled mode can't block toggles the browser makes itself: find-in-page opening the section, or a
|
|
23
|
+
* `name` group closing it. Those call `onToggle`, and the section follows the browser until `expanded`
|
|
24
|
+
* changes or the header is clicked. A header click always toggles from what is on screen.
|
|
25
|
+
*/
|
|
26
|
+
expanded?: boolean;
|
|
15
27
|
/**
|
|
16
28
|
* Class name for the header.
|
|
17
29
|
*/
|
|
18
30
|
headerClassName?: string;
|
|
19
31
|
/**
|
|
20
|
-
*
|
|
32
|
+
* Called when the user opens or closes the section, with the new expanded state.
|
|
33
|
+
*
|
|
34
|
+
* In uncontrolled mode the event is the native `toggle` event of the underlying `<details>` element, so it
|
|
35
|
+
* fires asynchronously, after the click (or key press) that caused it. In controlled mode (`expanded` set) a
|
|
36
|
+
* header click calls it synchronously with the click event; toggles the browser makes itself, such as
|
|
37
|
+
* find-in-page, still use the `toggle` event. It is not called for state the component sets itself, such as
|
|
38
|
+
* mounting with `initialExpanded` or a parent updating `expanded`.
|
|
21
39
|
*/
|
|
22
|
-
onToggle?: (event:
|
|
40
|
+
onToggle?: (event: SyntheticEvent<HTMLElement>, expanded: boolean) => void;
|
|
23
41
|
/**
|
|
24
42
|
* Child nodes.
|
|
25
43
|
*/
|
|
@@ -30,18 +48,43 @@ export interface CollapseProps extends CommonProps, Styleable, Refable<HTMLDivEl
|
|
|
30
48
|
label: ReactNode;
|
|
31
49
|
/**
|
|
32
50
|
* An addon to add to the header. This can be used for a status indicator or similar.
|
|
51
|
+
* It is rendered inside the header, which is interactive itself, so keep it non-interactive. Put controls
|
|
52
|
+
* in the content instead, for example in a toolbar row at the top.
|
|
33
53
|
*/
|
|
34
54
|
headerAddon?: ReactNode;
|
|
35
55
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
56
|
+
* Animates opening and closing. With `animate={false}` the section opens and closes instantly.
|
|
57
|
+
* It doesn't change when children are rendered; use `lazy` for that.
|
|
38
58
|
*/
|
|
39
59
|
animate?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Renders children only while the section is open, which improves performance for high volume data and
|
|
62
|
+
* resets the children's state every time the section closes. By default children stay mounted while closed.
|
|
63
|
+
*
|
|
64
|
+
* Content that isn't rendered can't be found with the browser's find-in-page, and because the children
|
|
65
|
+
* unmount as soon as the section closes, it closes without animation.
|
|
66
|
+
*/
|
|
67
|
+
lazy?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Adds padding around the header and content.
|
|
70
|
+
*/
|
|
40
71
|
extraPadding?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Groups Collapses into an exclusive accordion: Collapses that share a `name` close the others when
|
|
74
|
+
* one of them opens. This uses the native `name` attribute of `<details>`.
|
|
75
|
+
*
|
|
76
|
+
* If several Collapses with the same `name` start open, the browser keeps only one of them open, and
|
|
77
|
+
* `onToggle` is called on mount for the ones it closes.
|
|
78
|
+
*/
|
|
79
|
+
name?: string;
|
|
41
80
|
}
|
|
42
81
|
/**
|
|
43
82
|
* The Collapse component is a container for additional information that adds context to various flows. It is used for displaying non-essential information that can be hidden away.
|
|
44
83
|
*
|
|
84
|
+
* It is built on the native `<details>` and `<summary>` elements, so keyboard support, screen reader state and
|
|
85
|
+
* find-in-page come from the browser. Opening and closing animate in CSS; in Firefox closing doesn't animate, and
|
|
86
|
+
* nothing animates when the user prefers reduced motion.
|
|
87
|
+
*
|
|
45
88
|
* ### When to use
|
|
46
89
|
* - To keep content off the screen to shorten pages and reduce scrolling, while it's still only a tap away. Remember that the users might choose not to interact with the component and won't see the information within.
|
|
47
90
|
* - To display additional details that are not essential or necessary in the main flow/page.
|
|
@@ -82,7 +125,32 @@ export interface CollapseProps extends CommonProps, Styleable, Refable<HTMLDivEl
|
|
|
82
125
|
* </Collapse>
|
|
83
126
|
* );
|
|
84
127
|
* ```
|
|
128
|
+
* @example Accordion group where opening one section closes the others
|
|
129
|
+
* ```tsx
|
|
130
|
+
* import { Collapse } from "@trackunit/react-components";
|
|
131
|
+
*
|
|
132
|
+
* const Faq = () => (
|
|
133
|
+
* <>
|
|
134
|
+
* <Collapse id="faq-billing" label="Billing" name="faq">Billing answers</Collapse>
|
|
135
|
+
* <Collapse id="faq-access" label="Access" name="faq">Access answers</Collapse>
|
|
136
|
+
* </>
|
|
137
|
+
* );
|
|
138
|
+
* ```
|
|
139
|
+
* @example Controlled collapse
|
|
140
|
+
* ```tsx
|
|
141
|
+
* import { Collapse } from "@trackunit/react-components";
|
|
142
|
+
* import { useState } from "react";
|
|
143
|
+
*
|
|
144
|
+
* const ControlledSection = () => {
|
|
145
|
+
* const [expanded, setExpanded] = useState(false);
|
|
146
|
+
* return (
|
|
147
|
+
* <Collapse expanded={expanded} id="controlled" label="Details" onToggle={(_e, next) => setExpanded(next)}>
|
|
148
|
+
* Details content
|
|
149
|
+
* </Collapse>
|
|
150
|
+
* );
|
|
151
|
+
* };
|
|
152
|
+
* ```
|
|
85
153
|
* @param {CollapseProps} props - The props for the Collapse component
|
|
86
154
|
* @returns {ReactElement} Collapse component
|
|
87
155
|
*/
|
|
88
|
-
export declare const Collapse: ({ id, variant, initialExpanded, onToggle, label, children, className, headerClassName, headerAddon, "data-testid": dataTestId, animate, extraPadding, style, ref, }: CollapseProps) => ReactElement;
|
|
156
|
+
export declare const Collapse: ({ id, variant, initialExpanded, onToggle, label, children, className, headerClassName, headerAddon, "data-testid": dataTestId, animate, lazy, extraPadding, style, ref, name, expanded, }: CollapseProps) => ReactElement;
|
|
@@ -1,32 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The container doesn't clip its content: the header's focus ring is the browser's own, drawn outside the
|
|
3
|
+
* header like a button's, and clipping would cut it off. The header and the content round their own corners
|
|
4
|
+
* to the container's inner radius instead: `rounded-md` minus the 1px border, taken from the theme's
|
|
5
|
+
* `--radius-md` so it follows the token.
|
|
6
|
+
*/
|
|
1
7
|
export declare const cvaCollapse: import("cva").CVAComponent<Omit<{
|
|
2
8
|
base: string[];
|
|
3
9
|
variants: {
|
|
4
10
|
variant: {
|
|
5
11
|
primary: string[];
|
|
6
|
-
secondary:
|
|
12
|
+
secondary: never[];
|
|
7
13
|
};
|
|
8
14
|
};
|
|
9
15
|
}, "defaultVariants"> & {
|
|
10
16
|
variants: {
|
|
11
17
|
variant: {
|
|
12
18
|
primary: string[];
|
|
13
|
-
secondary:
|
|
19
|
+
secondary: never[];
|
|
14
20
|
};
|
|
15
21
|
};
|
|
16
22
|
defaultVariants: Omit<{}, never>;
|
|
17
23
|
}, {
|
|
18
24
|
variant: {
|
|
19
25
|
primary: string[];
|
|
20
|
-
secondary:
|
|
26
|
+
secondary: never[];
|
|
21
27
|
};
|
|
22
28
|
}>;
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The `::details-content` box is a one-row grid whose row animates from `0fr` to `1fr`, so the content
|
|
31
|
+
* height is never measured in JavaScript. `content-visibility` is transitioned discretely so the content
|
|
32
|
+
* stays visible until the closing animation ends. Browsers without `::details-content` support, users
|
|
33
|
+
* who prefer reduced motion, and `animate={false}` get an instant open and close.
|
|
34
|
+
*/
|
|
35
|
+
export declare const cvaCollapseDetails: import("cva").CVAComponent<Omit<{
|
|
25
36
|
variants: {
|
|
26
|
-
|
|
27
|
-
true:
|
|
37
|
+
animate: {
|
|
38
|
+
true: string[];
|
|
39
|
+
false: never[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
animate: true;
|
|
44
|
+
};
|
|
45
|
+
}, "defaultVariants"> & {
|
|
46
|
+
variants: {
|
|
47
|
+
animate: {
|
|
48
|
+
true: string[];
|
|
28
49
|
false: never[];
|
|
29
50
|
};
|
|
51
|
+
};
|
|
52
|
+
defaultVariants: Omit<{}, "animate"> & {
|
|
53
|
+
animate: true;
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
animate: {
|
|
57
|
+
true: string[];
|
|
58
|
+
false: never[];
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* A closed primary header rounds its bottom corners. The `open` attribute is removed as soon as closing
|
|
63
|
+
* starts, so when the closing is animated the rounding waits for the animation to end: until then the
|
|
64
|
+
* content is still visible below a header that should stay square.
|
|
65
|
+
*/
|
|
66
|
+
export declare const cvaCollapseHeader: import("cva").CVAComponent<Omit<{
|
|
67
|
+
base: string[];
|
|
68
|
+
variants: {
|
|
30
69
|
variant: {
|
|
31
70
|
primary: string[];
|
|
32
71
|
secondary: string[];
|
|
@@ -35,44 +74,42 @@ export declare const cvaCollapseHeader: import("cva").CVAComponent<Omit<{
|
|
|
35
74
|
true: never[];
|
|
36
75
|
false: never[];
|
|
37
76
|
};
|
|
77
|
+
animate: {
|
|
78
|
+
true: never[];
|
|
79
|
+
false: never[];
|
|
80
|
+
};
|
|
38
81
|
};
|
|
39
82
|
compoundVariants: ({
|
|
40
|
-
variant: "primary";
|
|
41
|
-
expanded: true;
|
|
42
|
-
class: ("border-b" | "border-solid" | "border-neutral-200")[];
|
|
43
|
-
extraPadding?: undefined;
|
|
44
|
-
} | {
|
|
45
|
-
variant: "primary";
|
|
46
|
-
expanded: false;
|
|
47
|
-
class: never[];
|
|
48
|
-
extraPadding?: undefined;
|
|
49
|
-
} | {
|
|
50
83
|
variant: "primary";
|
|
51
84
|
extraPadding: true;
|
|
52
85
|
class: ("py-1.5" | "px-4")[];
|
|
53
|
-
|
|
86
|
+
animate?: undefined;
|
|
54
87
|
} | {
|
|
55
88
|
variant: "primary";
|
|
56
89
|
extraPadding: false;
|
|
57
90
|
class: ("py-1.5" | "px-3")[];
|
|
58
|
-
|
|
91
|
+
animate?: undefined;
|
|
59
92
|
} | {
|
|
60
93
|
variant: "secondary";
|
|
61
94
|
extraPadding: true;
|
|
62
95
|
class: ("py-1.5" | "px-4")[];
|
|
63
|
-
|
|
96
|
+
animate?: undefined;
|
|
64
97
|
} | {
|
|
65
98
|
variant: "secondary";
|
|
66
99
|
extraPadding: false;
|
|
67
100
|
class: never[];
|
|
68
|
-
|
|
101
|
+
animate?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
variant: "primary";
|
|
104
|
+
animate: true;
|
|
105
|
+
class: "motion-safe:supports-[selector(::details-content)]:[details:not([open])>&]:[transition:background-color_150ms,border-radius_0s_200ms]"[];
|
|
106
|
+
extraPadding?: undefined;
|
|
69
107
|
})[];
|
|
108
|
+
defaultVariants: {
|
|
109
|
+
animate: true;
|
|
110
|
+
};
|
|
70
111
|
}, "defaultVariants"> & {
|
|
71
112
|
variants: {
|
|
72
|
-
expanded: {
|
|
73
|
-
true: never[];
|
|
74
|
-
false: never[];
|
|
75
|
-
};
|
|
76
113
|
variant: {
|
|
77
114
|
primary: string[];
|
|
78
115
|
secondary: string[];
|
|
@@ -81,13 +118,15 @@ export declare const cvaCollapseHeader: import("cva").CVAComponent<Omit<{
|
|
|
81
118
|
true: never[];
|
|
82
119
|
false: never[];
|
|
83
120
|
};
|
|
121
|
+
animate: {
|
|
122
|
+
true: never[];
|
|
123
|
+
false: never[];
|
|
124
|
+
};
|
|
84
125
|
};
|
|
85
|
-
defaultVariants: Omit<{},
|
|
86
|
-
|
|
87
|
-
expanded: {
|
|
88
|
-
true: never[];
|
|
89
|
-
false: never[];
|
|
126
|
+
defaultVariants: Omit<{}, "animate"> & {
|
|
127
|
+
animate: true;
|
|
90
128
|
};
|
|
129
|
+
}, {
|
|
91
130
|
variant: {
|
|
92
131
|
primary: string[];
|
|
93
132
|
secondary: string[];
|
|
@@ -96,6 +135,10 @@ export declare const cvaCollapseHeader: import("cva").CVAComponent<Omit<{
|
|
|
96
135
|
true: never[];
|
|
97
136
|
false: never[];
|
|
98
137
|
};
|
|
138
|
+
animate: {
|
|
139
|
+
true: never[];
|
|
140
|
+
false: never[];
|
|
141
|
+
};
|
|
99
142
|
}>;
|
|
100
143
|
export declare const cvaCollapseLabelContainer: import("cva").CVAComponent<Omit<{
|
|
101
144
|
base: string[];
|
|
@@ -141,13 +184,48 @@ export declare const cvaCollapseLabel: import("cva").CVAComponent<Omit<{
|
|
|
141
184
|
secondary: string[];
|
|
142
185
|
};
|
|
143
186
|
}>;
|
|
144
|
-
|
|
187
|
+
/**
|
|
188
|
+
* The single grid item inside `::details-content`. It must not carry padding, because padding would
|
|
189
|
+
* stay visible while the row is collapsed to `0fr`. `min-w-0` keeps wide content (a code block, a table)
|
|
190
|
+
* from stretching the grid column past the Collapse: a grid item is otherwise at least as wide as its content.
|
|
191
|
+
*/
|
|
192
|
+
export declare const cvaCollapseContent: import("cva").CVAComponent<Omit<{
|
|
145
193
|
base: string[];
|
|
146
194
|
variants: {
|
|
147
195
|
variant: {
|
|
148
|
-
primary:
|
|
196
|
+
primary: string[];
|
|
197
|
+
secondary: never[];
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
}, "defaultVariants"> & {
|
|
201
|
+
variants: {
|
|
202
|
+
variant: {
|
|
203
|
+
primary: string[];
|
|
149
204
|
secondary: never[];
|
|
150
205
|
};
|
|
206
|
+
};
|
|
207
|
+
defaultVariants: Omit<{}, never>;
|
|
208
|
+
}, {
|
|
209
|
+
variant: {
|
|
210
|
+
primary: string[];
|
|
211
|
+
secondary: never[];
|
|
212
|
+
};
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* Hidden while it has no children, so its padding doesn't show as an empty box. A `lazy` Collapse renders
|
|
216
|
+
* its children a moment after the section opens, when the browser's `toggle` event arrives.
|
|
217
|
+
*
|
|
218
|
+
* The line between the header and the content is this element's top border, not the header's bottom border.
|
|
219
|
+
* It is clipped away with the content, and it fades out over the closing animation so it doesn't end in a
|
|
220
|
+
* hard cut when the content reaches zero height.
|
|
221
|
+
*/
|
|
222
|
+
export declare const cvaCollapsible: import("cva").CVAComponent<Omit<{
|
|
223
|
+
base: string[];
|
|
224
|
+
variants: {
|
|
225
|
+
variant: {
|
|
226
|
+
primary: string[];
|
|
227
|
+
secondary: string[];
|
|
228
|
+
};
|
|
151
229
|
extraPadding: {
|
|
152
230
|
true: never[];
|
|
153
231
|
false: never[];
|
|
@@ -173,8 +251,8 @@ export declare const cvaCollapsible: import("cva").CVAComponent<Omit<{
|
|
|
173
251
|
}, "defaultVariants"> & {
|
|
174
252
|
variants: {
|
|
175
253
|
variant: {
|
|
176
|
-
primary:
|
|
177
|
-
secondary:
|
|
254
|
+
primary: string[];
|
|
255
|
+
secondary: string[];
|
|
178
256
|
};
|
|
179
257
|
extraPadding: {
|
|
180
258
|
true: never[];
|
|
@@ -184,65 +262,21 @@ export declare const cvaCollapsible: import("cva").CVAComponent<Omit<{
|
|
|
184
262
|
defaultVariants: Omit<{}, never>;
|
|
185
263
|
}, {
|
|
186
264
|
variant: {
|
|
187
|
-
primary:
|
|
188
|
-
secondary:
|
|
265
|
+
primary: string[];
|
|
266
|
+
secondary: string[];
|
|
189
267
|
};
|
|
190
268
|
extraPadding: {
|
|
191
269
|
true: never[];
|
|
192
270
|
false: never[];
|
|
193
271
|
};
|
|
194
272
|
}>;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
true: string;
|
|
200
|
-
false: string;
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
defaultVariants: {
|
|
204
|
-
expanded: false;
|
|
205
|
-
};
|
|
206
|
-
}, "defaultVariants"> & {
|
|
207
|
-
variants: {
|
|
208
|
-
expanded: {
|
|
209
|
-
true: string;
|
|
210
|
-
false: string;
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
defaultVariants: Omit<{}, "expanded"> & {
|
|
214
|
-
expanded: false;
|
|
215
|
-
};
|
|
216
|
-
}, {
|
|
217
|
-
expanded: {
|
|
218
|
-
true: string;
|
|
219
|
-
false: string;
|
|
220
|
-
};
|
|
221
|
-
}>;
|
|
273
|
+
/**
|
|
274
|
+
* Rotates when this Collapse's own `<details>` is open, with the same timing as the height animation.
|
|
275
|
+
* The child combinator keeps a nested Collapse's chevron from rotating when only its parent is open.
|
|
276
|
+
*/
|
|
222
277
|
export declare const cvaChevronIcon: import("cva").CVAComponent<Omit<{
|
|
223
278
|
base: string[];
|
|
224
|
-
variants: {
|
|
225
|
-
expanded: {
|
|
226
|
-
true: string;
|
|
227
|
-
false: string;
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
defaultVariants: {
|
|
231
|
-
expanded: false;
|
|
232
|
-
};
|
|
233
279
|
}, "defaultVariants"> & {
|
|
234
|
-
variants:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
false: string;
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
defaultVariants: Omit<{}, "expanded"> & {
|
|
241
|
-
expanded: false;
|
|
242
|
-
};
|
|
243
|
-
}, {
|
|
244
|
-
expanded: {
|
|
245
|
-
true: string;
|
|
246
|
-
false: string;
|
|
247
|
-
};
|
|
248
|
-
}>;
|
|
280
|
+
variants: unknown;
|
|
281
|
+
defaultVariants: Omit<{}, never>;
|
|
282
|
+
}, unknown>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an interactive element's own activation behaviour takes the click, so a `<summary>` around it doesn't
|
|
3
|
+
* toggle natively. Calling preventDefault on such an element would cancel its action (e.g. a checkbox change).
|
|
4
|
+
*/
|
|
5
|
+
export declare const isNativelyActivatable: (element: Element) => boolean;
|
|
@@ -49,6 +49,7 @@ interface NonDismissibleTagProps extends TagBaseProps {
|
|
|
49
49
|
*/
|
|
50
50
|
removeTagLabel?: string;
|
|
51
51
|
removeButtonInTabOrder?: undefined;
|
|
52
|
+
keepFocus?: undefined;
|
|
52
53
|
}
|
|
53
54
|
interface DismissibleTagProps extends TagBaseProps {
|
|
54
55
|
/**
|
|
@@ -68,6 +69,13 @@ interface DismissibleTagProps extends TagBaseProps {
|
|
|
68
69
|
* so the remove button adds no Tab stop. Defaults to true.
|
|
69
70
|
*/
|
|
70
71
|
removeButtonInTabOrder?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Set `keepFocus` when the tag belongs to an input, like a removable scope chip in a search field,
|
|
74
|
+
* so clicking the remove button doesn't move focus away. Keyboard focus and Tab order are unaffected.
|
|
75
|
+
*
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
keepFocus?: boolean;
|
|
71
79
|
}
|
|
72
80
|
export type TagProps = DismissibleTagProps | NonDismissibleTagProps;
|
|
73
81
|
/**
|
|
@@ -118,5 +126,5 @@ export type TagProps = DismissibleTagProps | NonDismissibleTagProps;
|
|
|
118
126
|
* @param {TagProps} props - The props for the Tag component.
|
|
119
127
|
* @returns {ReactElement} The rendered Tag component.
|
|
120
128
|
*/
|
|
121
|
-
export declare const Tag: ({ className, "data-testid": dataTestId, children, size, onClickClose, color, disabled, ref, icon, onMouseEnter, style, removeTagLabel, removeButtonInTabOrder, }: TagProps) => ReactElement;
|
|
129
|
+
export declare const Tag: ({ className, "data-testid": dataTestId, children, size, onClickClose, color, disabled, ref, icon, onMouseEnter, style, removeTagLabel, removeButtonInTabOrder, keepFocus, }: TagProps) => ReactElement;
|
|
122
130
|
export {};
|
|
@@ -85,6 +85,6 @@ export interface ButtonProps extends MappedOmit<ButtonCommonProps, "size">, Refa
|
|
|
85
85
|
* @returns {ReactElement} Button component
|
|
86
86
|
*/
|
|
87
87
|
export declare const Button: {
|
|
88
|
-
({ onClick, children, loading, disabled, className, fullWidth, prefix, suffix, variant, type, size, square, "data-testid": dataTestId, title, ariaLabel, ariaLabelledBy, ariaDescribedBy, ariaHidden, role, tabIndex, asChild, ref, ...rest }: ButtonProps): ReactElement;
|
|
88
|
+
({ onClick, children, loading, disabled, className, fullWidth, prefix, suffix, variant, type, size, square, "data-testid": dataTestId, title, ariaLabel, ariaLabelledBy, ariaDescribedBy, ariaHidden, role, tabIndex, asChild, keepFocus, onMouseDown, ref, ...rest }: ButtonProps): ReactElement;
|
|
89
89
|
displayName: string;
|
|
90
90
|
};
|
|
@@ -10,6 +10,10 @@ export interface ButtonCommonProps extends CommonProps, Styleable, AriaProps {
|
|
|
10
10
|
* An onClick handler
|
|
11
11
|
*/
|
|
12
12
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
13
|
+
/**
|
|
14
|
+
* A MouseDown handler function
|
|
15
|
+
*/
|
|
16
|
+
onMouseDown?: MouseEventHandler<HTMLButtonElement>;
|
|
13
17
|
/**
|
|
14
18
|
* A MouseEnter handler function
|
|
15
19
|
*/
|
|
@@ -22,6 +26,13 @@ export interface ButtonCommonProps extends CommonProps, Styleable, AriaProps {
|
|
|
22
26
|
* A Blur handler function
|
|
23
27
|
*/
|
|
24
28
|
onBlur?: FocusEventHandler<HTMLButtonElement>;
|
|
29
|
+
/**
|
|
30
|
+
* Set `keepFocus` when the button belongs to an input, like a clear button in a search field,
|
|
31
|
+
* so clicking it doesn't move focus away. Keyboard focus and Tab order are unaffected.
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
keepFocus?: boolean;
|
|
25
36
|
/**
|
|
26
37
|
* Whether the button is loading.
|
|
27
38
|
*/
|