@fluentui/react-aria 0.0.0-nightly-20220714-0418.1 → 0.0.0-nightly-20221007-1237.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/CHANGELOG.json +160 -8
- package/CHANGELOG.md +64 -7
- package/dist/index.d.ts +71 -7
- package/lib/button/index.js +4 -0
- package/lib/button/index.js.map +1 -0
- package/lib/button/types.js +2 -0
- package/lib/button/types.js.map +1 -0
- package/lib/button/useARIAButtonProps.js +129 -0
- package/lib/button/useARIAButtonProps.js.map +1 -0
- package/lib/button/useARIAButtonShorthand.js +20 -0
- package/lib/button/useARIAButtonShorthand.js.map +1 -0
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib-commonjs/button/index.js +14 -0
- package/lib-commonjs/button/index.js.map +1 -0
- package/lib-commonjs/button/types.js +6 -0
- package/lib-commonjs/button/types.js.map +1 -0
- package/lib-commonjs/button/useARIAButtonProps.js +140 -0
- package/lib-commonjs/button/useARIAButtonProps.js.map +1 -0
- package/lib-commonjs/button/useARIAButtonShorthand.js +31 -0
- package/lib-commonjs/button/useARIAButtonShorthand.js.map +1 -0
- package/lib-commonjs/index.js +6 -9
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +6 -10
- package/dist/tsdoc-metadata.json +0 -11
- package/lib/hooks/index.js +0 -2
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useARIAButton.js +0 -103
- package/lib/hooks/useARIAButton.js.map +0 -1
- package/lib/utils/index.js +0 -2
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/mergeARIADisabled.js +0 -16
- package/lib/utils/mergeARIADisabled.js.map +0 -1
- package/lib-commonjs/hooks/index.js +0 -10
- package/lib-commonjs/hooks/index.js.map +0 -1
- package/lib-commonjs/hooks/useARIAButton.js +0 -114
- package/lib-commonjs/hooks/useARIAButton.js.map +0 -1
- package/lib-commonjs/utils/index.js +0 -10
- package/lib-commonjs/utils/index.js.map +0 -1
- package/lib-commonjs/utils/mergeARIADisabled.js +0 -25
- package/lib-commonjs/utils/mergeARIADisabled.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"name": "@fluentui/react-aria",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
6
|
-
"tag": "@fluentui/react-aria_v0.0.0-nightly-
|
|
7
|
-
"version": "0.0.0-nightly-
|
|
5
|
+
"date": "Fri, 07 Oct 2022 12:44:16 GMT",
|
|
6
|
+
"tag": "@fluentui/react-aria_v0.0.0-nightly-20221007-1237.1",
|
|
7
|
+
"version": "0.0.0-nightly-20221007-1237.1",
|
|
8
8
|
"comments": {
|
|
9
9
|
"prerelease": [
|
|
10
10
|
{
|
|
11
|
-
"author": "
|
|
11
|
+
"author": "fluentui-internal@service.microsoft.com",
|
|
12
12
|
"package": "@fluentui/react-aria",
|
|
13
13
|
"commit": "not available",
|
|
14
14
|
"comment": "Release nightly v9"
|
|
@@ -16,14 +16,166 @@
|
|
|
16
16
|
{
|
|
17
17
|
"author": "beachball",
|
|
18
18
|
"package": "@fluentui/react-aria",
|
|
19
|
-
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
|
20
|
-
"commit": "
|
|
19
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221007-1237.1",
|
|
20
|
+
"commit": "cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"author": "beachball",
|
|
24
24
|
"package": "@fluentui/react-aria",
|
|
25
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-
|
|
26
|
-
"commit": "
|
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20221007-1237.1",
|
|
26
|
+
"commit": "cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"date": "Mon, 03 Oct 2022 22:24:33 GMT",
|
|
33
|
+
"tag": "@fluentui/react-aria_v9.2.1",
|
|
34
|
+
"version": "9.2.1",
|
|
35
|
+
"comments": {
|
|
36
|
+
"patch": [
|
|
37
|
+
{
|
|
38
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
39
|
+
"package": "@fluentui/react-aria",
|
|
40
|
+
"commit": "3b48ff5d92433635997aa69a59b138ec273172ea",
|
|
41
|
+
"comment": "chore: user defined tabIndex should prevail aria-button defined"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"date": "Fri, 23 Sep 2022 10:32:29 GMT",
|
|
48
|
+
"tag": "@fluentui/react-aria_v9.2.0",
|
|
49
|
+
"version": "9.2.0",
|
|
50
|
+
"comments": {
|
|
51
|
+
"none": [
|
|
52
|
+
{
|
|
53
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
54
|
+
"package": "@fluentui/react-aria",
|
|
55
|
+
"commit": "ce5f1ec6a0c0f766679ea708c40538fc2d56c6d9",
|
|
56
|
+
"comment": "chore: restructure folder organization"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"date": "Thu, 15 Sep 2022 09:49:48 GMT",
|
|
63
|
+
"tag": "@fluentui/react-aria_v9.2.0",
|
|
64
|
+
"version": "9.2.0",
|
|
65
|
+
"comments": {
|
|
66
|
+
"none": [
|
|
67
|
+
{
|
|
68
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
69
|
+
"package": "@fluentui/react-aria",
|
|
70
|
+
"commit": "bf151e71e0ffa5de5c44cc722e629cdeb7abdbb2",
|
|
71
|
+
"comment": "chore: re-organize useARIAButton into its own folder"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"author": "martinhochel@microsoft.com",
|
|
75
|
+
"package": "@fluentui/react-aria",
|
|
76
|
+
"commit": "e6cf183695d6d67a24e038c49a876224e5ed35e5",
|
|
77
|
+
"comment": "chore: update package scaffold"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"patch": [
|
|
81
|
+
{
|
|
82
|
+
"author": "martinhochel@microsoft.com",
|
|
83
|
+
"package": "@fluentui/react-aria",
|
|
84
|
+
"commit": "16aa65dcae8f75c6a221225fd0eb43800650ac66",
|
|
85
|
+
"comment": "docs(react-aria): re-generate api.md"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
89
|
+
"package": "@fluentui/react-aria",
|
|
90
|
+
"commit": "de08c96226ec5d425f705c22c5d94dbac5811eb6",
|
|
91
|
+
"comment": "chore(react-aria): improve internal typings"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
95
|
+
"package": "@fluentui/react-aria",
|
|
96
|
+
"commit": "0547583ebcebe746110e5ef8d0599b0972b1f4c6",
|
|
97
|
+
"comment": "feat: upgrade typings on useARIAButtonProps to be more specific"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"minor": [
|
|
101
|
+
{
|
|
102
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
103
|
+
"package": "@fluentui/react-aria",
|
|
104
|
+
"commit": "81191d9a45e629126a416e7202af3e241cd5e0fc",
|
|
105
|
+
"comment": "feat: add helper types to assist DOM element handling"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"author": "beachball",
|
|
109
|
+
"package": "@fluentui/react-aria",
|
|
110
|
+
"comment": "Bump @fluentui/react-utilities to v9.1.0",
|
|
111
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"date": "Wed, 03 Aug 2022 16:03:37 GMT",
|
|
118
|
+
"tag": "@fluentui/react-aria_v9.1.0",
|
|
119
|
+
"version": "9.1.0",
|
|
120
|
+
"comments": {
|
|
121
|
+
"none": [
|
|
122
|
+
{
|
|
123
|
+
"author": "lingfangao@hotmail.com",
|
|
124
|
+
"package": "@fluentui/react-aria",
|
|
125
|
+
"commit": "99cc385631d04a76ee10ebc143cb9fecd99640b6",
|
|
126
|
+
"comment": "chore: Add `prerelease` as disallowed changetype for 9.0.0 packages"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"patch": [
|
|
130
|
+
{
|
|
131
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
132
|
+
"package": "@fluentui/react-aria",
|
|
133
|
+
"commit": "a0e1e0c2780ad6ba73aaeee1aa1525168a4d4045",
|
|
134
|
+
"comment": "feat: treats aria-disabled as disabled state on useARIAButtonProps"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"minor": [
|
|
138
|
+
{
|
|
139
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
140
|
+
"package": "@fluentui/react-aria",
|
|
141
|
+
"commit": "1293f53f79ea1dc7429f77e174b2dfdaffa99558",
|
|
142
|
+
"comment": "chore: Splits useARIAButton into useARIAButtonProps and useARIAButtonShorthand."
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"date": "Thu, 14 Jul 2022 21:21:08 GMT",
|
|
149
|
+
"tag": "@fluentui/react-aria_v9.0.2",
|
|
150
|
+
"version": "9.0.2",
|
|
151
|
+
"comments": {
|
|
152
|
+
"patch": [
|
|
153
|
+
{
|
|
154
|
+
"author": "Humberto.Morimoto@microsoft.com",
|
|
155
|
+
"package": "@fluentui/react-aria",
|
|
156
|
+
"commit": "802bc4e3730a88b0fc61b5bf42ef7fc6b6543fe2",
|
|
157
|
+
"comment": "fix: Fixing bad version bump of @fluentui/react-utilities."
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"author": "beachball",
|
|
161
|
+
"package": "@fluentui/react-aria",
|
|
162
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.2",
|
|
163
|
+
"commit": "79b513146194367544160f364b0a7dd749ed93e4"
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"date": "Thu, 14 Jul 2022 17:06:26 GMT",
|
|
170
|
+
"tag": "@fluentui/react-aria_v9.0.1",
|
|
171
|
+
"version": "9.0.1",
|
|
172
|
+
"comments": {
|
|
173
|
+
"patch": [
|
|
174
|
+
{
|
|
175
|
+
"author": "beachball",
|
|
176
|
+
"package": "@fluentui/react-aria",
|
|
177
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.1-0",
|
|
178
|
+
"commit": "35237381e941c8935b1892c9217096cea3e5601f"
|
|
27
179
|
}
|
|
28
180
|
]
|
|
29
181
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,76 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-aria
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 07 Oct 2022 12:44:16 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## [0.0.0-nightly-
|
|
7
|
+
## [0.0.0-nightly-20221007-1237.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v0.0.0-nightly-20221007-1237.1)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.
|
|
9
|
+
Fri, 07 Oct 2022 12:44:16 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.2.1..@fluentui/react-aria_v0.0.0-nightly-20221007-1237.1)
|
|
11
11
|
|
|
12
12
|
### Changes
|
|
13
13
|
|
|
14
|
-
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by
|
|
15
|
-
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
|
16
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
|
15
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221007-1237.1 ([commit](https://github.com/microsoft/fluentui/commit/cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec) by beachball)
|
|
16
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20221007-1237.1 ([commit](https://github.com/microsoft/fluentui/commit/cb80d71825ddb9ebe5d06bb14b1c970f8633c4ec) by beachball)
|
|
17
|
+
|
|
18
|
+
## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.2.1)
|
|
19
|
+
|
|
20
|
+
Mon, 03 Oct 2022 22:24:33 GMT
|
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.2.0..@fluentui/react-aria_v9.2.1)
|
|
22
|
+
|
|
23
|
+
### Patches
|
|
24
|
+
|
|
25
|
+
- chore: user defined tabIndex should prevail aria-button defined ([PR #24962](https://github.com/microsoft/fluentui/pull/24962) by bernardo.sunderhus@gmail.com)
|
|
26
|
+
|
|
27
|
+
## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.2.0)
|
|
28
|
+
|
|
29
|
+
Thu, 15 Sep 2022 09:49:48 GMT
|
|
30
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.1.0..@fluentui/react-aria_v9.2.0)
|
|
31
|
+
|
|
32
|
+
### Minor changes
|
|
33
|
+
|
|
34
|
+
- feat: add helper types to assist DOM element handling ([PR #24722](https://github.com/microsoft/fluentui/pull/24722) by bernardo.sunderhus@gmail.com)
|
|
35
|
+
- Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
36
|
+
|
|
37
|
+
### Patches
|
|
38
|
+
|
|
39
|
+
- docs(react-aria): re-generate api.md ([PR #23369](https://github.com/microsoft/fluentui/pull/23369) by martinhochel@microsoft.com)
|
|
40
|
+
- chore(react-aria): improve internal typings ([PR #24742](https://github.com/microsoft/fluentui/pull/24742) by bernardo.sunderhus@gmail.com)
|
|
41
|
+
- feat: upgrade typings on useARIAButtonProps to be more specific ([PR #24177](https://github.com/microsoft/fluentui/pull/24177) by bernardo.sunderhus@gmail.com)
|
|
42
|
+
|
|
43
|
+
## [9.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.1.0)
|
|
44
|
+
|
|
45
|
+
Wed, 03 Aug 2022 16:03:37 GMT
|
|
46
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.0.2..@fluentui/react-aria_v9.1.0)
|
|
47
|
+
|
|
48
|
+
### Minor changes
|
|
49
|
+
|
|
50
|
+
- chore: Splits useARIAButton into useARIAButtonProps and useARIAButtonShorthand. ([PR #24032](https://github.com/microsoft/fluentui/pull/24032) by bernardo.sunderhus@gmail.com)
|
|
51
|
+
|
|
52
|
+
### Patches
|
|
53
|
+
|
|
54
|
+
- feat: treats aria-disabled as disabled state on useARIAButtonProps ([PR #24197](https://github.com/microsoft/fluentui/pull/24197) by bernardo.sunderhus@gmail.com)
|
|
55
|
+
|
|
56
|
+
## [9.0.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.0.2)
|
|
57
|
+
|
|
58
|
+
Thu, 14 Jul 2022 21:21:08 GMT
|
|
59
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.0.1..@fluentui/react-aria_v9.0.2)
|
|
60
|
+
|
|
61
|
+
### Patches
|
|
62
|
+
|
|
63
|
+
- fix: Fixing bad version bump of @fluentui/react-utilities. ([PR #23920](https://github.com/microsoft/fluentui/pull/23920) by Humberto.Morimoto@microsoft.com)
|
|
64
|
+
- Bump @fluentui/react-utilities to v9.0.2 ([PR #23918](https://github.com/microsoft/fluentui/pull/23918) by beachball)
|
|
65
|
+
|
|
66
|
+
## [9.0.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.0.1)
|
|
67
|
+
|
|
68
|
+
Thu, 14 Jul 2022 17:06:26 GMT
|
|
69
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.0.0..@fluentui/react-aria_v9.0.1)
|
|
70
|
+
|
|
71
|
+
### Patches
|
|
72
|
+
|
|
73
|
+
- Bump @fluentui/react-utilities to v9.0.1-0 ([PR #23897](https://github.com/microsoft/fluentui/pull/23897) by beachball)
|
|
17
74
|
|
|
18
75
|
## [9.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.0.0)
|
|
19
76
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,90 @@
|
|
|
1
1
|
import type { ExtractSlotProps } from '@fluentui/react-utilities';
|
|
2
|
+
import * as React_2 from 'react';
|
|
2
3
|
import type { ResolveShorthandFunction } from '@fluentui/react-utilities';
|
|
3
4
|
import type { Slot } from '@fluentui/react-utilities';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* Props that will be modified internally by `useARIAButtonProps` by each case.
|
|
9
|
+
* This typing is to ensure a well specified return value for `useARIAbButtonProps`
|
|
10
|
+
*/
|
|
11
|
+
declare type ARIAButtonAlteredProps<Type extends ARIAButtonType> = (Type extends 'button' ? Pick<JSX.IntrinsicElements['button'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'disabled' | 'aria-disabled' | 'tabIndex'> : never) | (Type extends 'a' ? Pick<JSX.IntrinsicElements['a'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role' | 'href'> : never) | (Type extends 'div' ? Pick<JSX.IntrinsicElements['div'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role'> : never);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare type ARIAButtonElement<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = HTMLButtonElement | (AlternateAs extends 'a' ? HTMLAnchorElement : never) | (AlternateAs extends 'div' ? HTMLDivElement : never);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare type ARIAButtonElementIntersection<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = UnionToIntersection<ARIAButtonElement<AlternateAs>>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Props expected by `useARIAButtonProps` hooks
|
|
25
|
+
*/
|
|
26
|
+
export declare type ARIAButtonProps<Type extends ARIAButtonType = ARIAButtonType> = React_2.PropsWithRef<JSX.IntrinsicElements[Type]> & {
|
|
6
27
|
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* When set, allows the button to be focusable even when it has been disabled.
|
|
30
|
+
* This is used in scenarios where it is important to keep a consistent tab order
|
|
31
|
+
* for screen reader and keyboard users. The primary example of this
|
|
32
|
+
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
7
36
|
disabledFocusable?: boolean;
|
|
8
37
|
};
|
|
9
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Merge of props provided by the user and props provided internally.
|
|
41
|
+
*/
|
|
42
|
+
export declare type ARIAButtonResultProps<Type extends ARIAButtonType, Props> = Props & UnionToIntersection<ARIAButtonAlteredProps<Type>>;
|
|
43
|
+
|
|
44
|
+
export declare type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<Slot<'button', AlternateAs>> & Pick<ARIAButtonProps<ARIAButtonType>, 'disabled' | 'disabledFocusable'>;
|
|
45
|
+
|
|
46
|
+
export declare type ARIAButtonType = 'button' | 'a' | 'div';
|
|
47
|
+
|
|
48
|
+
declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
|
|
49
|
+
|
|
10
50
|
/**
|
|
11
51
|
* @internal
|
|
12
|
-
*
|
|
52
|
+
*
|
|
53
|
+
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
54
|
+
* for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases
|
|
55
|
+
* where no attribute addition is required.
|
|
56
|
+
*
|
|
57
|
+
* @param type - the proper scenario to be interpreted by the hook.
|
|
58
|
+
* 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states
|
|
59
|
+
* 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior
|
|
60
|
+
* @param props - the props to be passed down the line to the desired element.
|
|
61
|
+
* This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* const buttonProps = useARIAButtonProps('a', {
|
|
66
|
+
* href: './some-route'
|
|
67
|
+
* onClick: () => console.log('this should run both on click and Space and Enter')
|
|
68
|
+
* })
|
|
69
|
+
*
|
|
70
|
+
* // ...
|
|
71
|
+
*
|
|
72
|
+
* return (
|
|
73
|
+
* <a {...buttonProps}>This anchor will behave as a proper button</a>
|
|
74
|
+
* )
|
|
75
|
+
* ```
|
|
13
76
|
*/
|
|
14
|
-
export declare function
|
|
15
|
-
'aria-disabled'?: string | boolean;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
}): boolean;
|
|
77
|
+
export declare function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(type?: Type, props?: Props): ARIAButtonResultProps<Type, Props>;
|
|
18
78
|
|
|
19
79
|
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*
|
|
82
|
+
* This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead
|
|
83
|
+
*
|
|
20
84
|
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
21
85
|
* for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
|
|
22
86
|
* where no attribute addition is required.
|
|
23
87
|
*/
|
|
24
|
-
export declare const
|
|
88
|
+
export declare const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps>;
|
|
25
89
|
|
|
26
90
|
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/button/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/button/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\n/**\n * @internal\n */\nexport type ARIAButtonElement<AlternateAs extends 'a' | 'div' = 'a' | 'div'> =\n | HTMLButtonElement\n | (AlternateAs extends 'a' ? HTMLAnchorElement : never)\n | (AlternateAs extends 'div' ? HTMLDivElement : never);\n\n/**\n * @internal\n */\nexport type ARIAButtonElementIntersection<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = UnionToIntersection<\n ARIAButtonElement<AlternateAs>\n>;\n\n/**\n * Props expected by `useARIAButtonProps` hooks\n */\nexport type ARIAButtonProps<Type extends ARIAButtonType = ARIAButtonType> = React.PropsWithRef<\n JSX.IntrinsicElements[Type]\n> & {\n disabled?: boolean;\n /**\n * When set, allows the button to be focusable even when it has been disabled.\n * This is used in scenarios where it is important to keep a consistent tab order\n * for screen reader and keyboard users. The primary example of this\n * pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.\n *\n * @default false\n */\n disabledFocusable?: boolean;\n};\n\nexport type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<\n Slot<'button', AlternateAs>\n> &\n Pick<ARIAButtonProps<ARIAButtonType>, 'disabled' | 'disabledFocusable'>;\n\n/**\n * @internal\n * Props that will be modified internally by `useARIAButtonProps` by each case.\n * This typing is to ensure a well specified return value for `useARIAbButtonProps`\n */\nexport type ARIAButtonAlteredProps<Type extends ARIAButtonType> =\n | (Type extends 'button'\n ? Pick<\n JSX.IntrinsicElements['button'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'disabled' | 'aria-disabled' | 'tabIndex'\n >\n : never)\n | (Type extends 'a'\n ? Pick<\n JSX.IntrinsicElements['a'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role' | 'href'\n >\n : never)\n | (Type extends 'div'\n ? Pick<JSX.IntrinsicElements['div'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role'>\n : never);\n\n/**\n * Merge of props provided by the user and props provided internally.\n */\nexport type ARIAButtonResultProps<Type extends ARIAButtonType, Props> = Props &\n UnionToIntersection<ARIAButtonAlteredProps<Type>>;\n"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Enter, Space } from '@fluentui/keyboard-keys';
|
|
2
|
+
import { useEventCallback } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
7
|
+
* for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases
|
|
8
|
+
* where no attribute addition is required.
|
|
9
|
+
*
|
|
10
|
+
* @param type - the proper scenario to be interpreted by the hook.
|
|
11
|
+
* 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states
|
|
12
|
+
* 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior
|
|
13
|
+
* @param props - the props to be passed down the line to the desired element.
|
|
14
|
+
* This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const buttonProps = useARIAButtonProps('a', {
|
|
19
|
+
* href: './some-route'
|
|
20
|
+
* onClick: () => console.log('this should run both on click and Space and Enter')
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* // ...
|
|
24
|
+
*
|
|
25
|
+
* return (
|
|
26
|
+
* <a {...buttonProps}>This anchor will behave as a proper button</a>
|
|
27
|
+
* )
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export function useARIAButtonProps(type, props) {
|
|
32
|
+
const {
|
|
33
|
+
disabled,
|
|
34
|
+
disabledFocusable = false,
|
|
35
|
+
['aria-disabled']: ariaDisabled,
|
|
36
|
+
onClick,
|
|
37
|
+
onKeyDown,
|
|
38
|
+
onKeyUp,
|
|
39
|
+
...rest
|
|
40
|
+
} = props !== null && props !== void 0 ? props : {};
|
|
41
|
+
const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
|
|
42
|
+
const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
|
|
43
|
+
const handleClick = useEventCallback(ev => {
|
|
44
|
+
if (isDisabled) {
|
|
45
|
+
ev.preventDefault();
|
|
46
|
+
ev.stopPropagation();
|
|
47
|
+
} else {
|
|
48
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(ev);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const handleKeyDown = useEventCallback(ev => {
|
|
52
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
|
|
53
|
+
|
|
54
|
+
if (ev.isDefaultPrevented()) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const key = ev.key;
|
|
59
|
+
|
|
60
|
+
if (isDisabled && (key === Enter || key === Space)) {
|
|
61
|
+
ev.preventDefault();
|
|
62
|
+
ev.stopPropagation();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (key === Space) {
|
|
67
|
+
ev.preventDefault();
|
|
68
|
+
return;
|
|
69
|
+
} // If enter is pressed, activate the button
|
|
70
|
+
else if (key === Enter) {
|
|
71
|
+
ev.preventDefault();
|
|
72
|
+
ev.currentTarget.click();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const handleKeyUp = useEventCallback(ev => {
|
|
76
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
|
|
77
|
+
|
|
78
|
+
if (ev.isDefaultPrevented()) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const key = ev.key;
|
|
83
|
+
|
|
84
|
+
if (isDisabled && (key === Enter || key === Space)) {
|
|
85
|
+
ev.preventDefault();
|
|
86
|
+
ev.stopPropagation();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (key === Space) {
|
|
91
|
+
ev.preventDefault();
|
|
92
|
+
ev.currentTarget.click();
|
|
93
|
+
}
|
|
94
|
+
}); // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
|
|
95
|
+
|
|
96
|
+
if (type === 'button' || type === undefined) {
|
|
97
|
+
return { ...rest,
|
|
98
|
+
disabled: disabled && !disabledFocusable,
|
|
99
|
+
'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
|
|
100
|
+
// onclick should still use internal handler to ensure prevention if disabled
|
|
101
|
+
// if disabledFocusable then there's no requirement for handlers as those events should not be propagated
|
|
102
|
+
onClick: disabledFocusable ? undefined : handleClick,
|
|
103
|
+
onKeyUp: disabledFocusable ? undefined : onKeyUp,
|
|
104
|
+
onKeyDown: disabledFocusable ? undefined : onKeyDown
|
|
105
|
+
};
|
|
106
|
+
} // If an <a> or <div> tag is to be rendered we have to remove disabled and type,
|
|
107
|
+
// and set aria-disabled, role and tabIndex.
|
|
108
|
+
else {
|
|
109
|
+
const resultProps = {
|
|
110
|
+
role: 'button',
|
|
111
|
+
tabIndex: disabled && !disabledFocusable ? undefined : 0,
|
|
112
|
+
...rest,
|
|
113
|
+
// If it's not a <button> than listeners are required even with disabledFocusable
|
|
114
|
+
// Since you cannot assure the default behavior of the element
|
|
115
|
+
// E.g: <a> will redirect on click
|
|
116
|
+
onClick: handleClick,
|
|
117
|
+
onKeyUp: handleKeyUp,
|
|
118
|
+
onKeyDown: handleKeyDown,
|
|
119
|
+
'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (type === 'a' && isDisabled) {
|
|
123
|
+
resultProps.href = undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return resultProps;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=useARIAButtonProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/button/useARIAButtonProps.ts"],"names":[],"mappings":"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","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { resolveShorthand } from '@fluentui/react-utilities';
|
|
2
|
+
import { useARIAButtonProps } from './useARIAButtonProps';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead
|
|
7
|
+
*
|
|
8
|
+
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
9
|
+
* for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
|
|
10
|
+
* where no attribute addition is required.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const useARIAButtonShorthand = (slot, options) => {
|
|
14
|
+
var _a;
|
|
15
|
+
|
|
16
|
+
const shorthand = resolveShorthand(slot, options);
|
|
17
|
+
const shorthandARIAButton = useARIAButtonProps((_a = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _a !== void 0 ? _a : 'button', shorthand);
|
|
18
|
+
return shorthand && shorthandARIAButton;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useARIAButtonShorthand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/button/useARIAButtonShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AAIA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAD,EAAO,OAAP,CAAlC;EACA,MAAM,mBAAmB,GAAG,kBAAkB,CAAkC,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAAnD,EAA6D,SAA7D,CAA9C;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":""}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n} from './button/index';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
|
+
|
|
9
|
+
tslib_1.__exportStar(require("./useARIAButtonProps"), exports);
|
|
10
|
+
|
|
11
|
+
tslib_1.__exportStar(require("./useARIAButtonShorthand"), exports);
|
|
12
|
+
|
|
13
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/button/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"sourceRoot":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
|