@fluentui/react-aria 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10
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 +354 -17
- package/CHANGELOG.md +173 -54
- package/dist/index.d.ts +25 -0
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useARIAButton.js +25 -20
- package/lib/hooks/useARIAButton.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeARIADisabled.js +1 -1
- package/lib/utils/mergeARIADisabled.js.map +1 -1
- package/lib-commonjs/hooks/index.js +1 -1
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useARIAButton.js +27 -22
- package/lib-commonjs/hooks/useARIAButton.js.map +1 -1
- package/lib-commonjs/index.js +16 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/index.js +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeARIADisabled.js +1 -1
- package/lib-commonjs/utils/mergeARIADisabled.js.map +1 -1
- package/package.json +16 -21
- package/dist/react-aria.d.ts +0 -28
- package/lib/hooks/index.d.ts +0 -1
- package/lib/hooks/useARIAButton.d.ts +0 -11
- package/lib/index.d.ts +0 -2
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/mergeARIADisabled.d.ts +0 -10
- package/lib-commonjs/hooks/index.d.ts +0 -1
- package/lib-commonjs/hooks/useARIAButton.d.ts +0 -11
- package/lib-commonjs/index.d.ts +0 -2
- package/lib-commonjs/utils/index.d.ts +0 -1
- package/lib-commonjs/utils/mergeARIADisabled.d.ts +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["hooks/useARIAButton.ts"],"names":[],"mappings":"AAAA,SAAS,KA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,CAAd,GAAkC,QAAQ,IAAI,iBAA9C;AACC,MAAA,cAA6C,CAAC,IAA9C,GAAqD,QAAQ,GAC1D,SAD0D,GAEzD,cAA6C,CAAC,IAFlD;AAGD,MAAA,cAAc,CAAC,OAAf,GAAyB,cAAzB;AACA,MAAA,cAAc,CAAC,SAAf,GAA2B,gBAA3B;AACA,MAAA,cAAc,CAAC,OAAf,GAAyB,cAAzB;AACA,MAAA,cAAc,CAAC,IAAf,GAAsB,CAAA,EAAA,GAAA,cAAc,CAAC,IAAf,MAAmB,IAAnB,IAAmB,EAAA,KAAA,KAAA,CAAnB,GAAmB,EAAnB,GAAuB,QAA7C;AACA,MAAA,cAAc,CAAC,QAAf,GAA0B,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,CAAnF;AACD,KA1BiB,CA4BlB;;;AACA,WAAO,cAAc,CAAC,iBAAtB;AACD;;AAED,SAAO,cAAP;AACD,CAhGM","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { resolveShorthand, useEventCallback } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, ResolveShorthandFunction, Slot } from '@fluentui/react-utilities';\n\nexport type ARIAButtonSlotProps = ExtractSlotProps<Slot<'button', 'a'>> & {\n disabled?: boolean;\n disabledFocusable?: boolean;\n};\n\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 useARIAButton: ResolveShorthandFunction<ARIAButtonSlotProps> = (shorthand, options) => {\n const shorthandProps = resolveShorthand(shorthand, options);\n\n const { disabled, disabledFocusable, onClick, onKeyDown, onKeyUp, tabIndex } = (shorthandProps ||\n {}) as ARIAButtonSlotProps;\n\n const onClickHandler: ARIAButtonSlotProps['onClick'] = useEventCallback(ev => {\n if (disabled || disabledFocusable) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const onKeyDownHandler: ARIAButtonSlotProps['onKeyDown'] = useEventCallback(ev => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 onKeyupHandler: ARIAButtonSlotProps['onKeyUp'] = useEventCallback(ev => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 (shorthandProps) {\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (shorthandProps.as === 'button' || shorthandProps.as === undefined) {\n shorthandProps.disabled = disabled && !disabledFocusable;\n shorthandProps['aria-disabled'] = disabledFocusable ? true : undefined;\n\n // Undefine events if disabledFocusable is passed in\n if (disabledFocusable) {\n shorthandProps.onClick = undefined;\n shorthandProps.onKeyDown = undefined;\n shorthandProps.onKeyUp = undefined;\n }\n }\n\n // If an <a> tag is to be rendered we have to remove disabled and type, and set aria-disabled, role and tabIndex.\n else {\n delete shorthandProps.disabled;\n shorthandProps['aria-disabled'] = disabled || disabledFocusable;\n (shorthandProps as JSX.IntrinsicElements['a']).href = disabled\n ? undefined\n : (shorthandProps as JSX.IntrinsicElements['a']).href;\n shorthandProps.onClick = onClickHandler;\n shorthandProps.onKeyDown = onKeyDownHandler;\n shorthandProps.onKeyUp = onKeyupHandler;\n shorthandProps.role = shorthandProps.role ?? 'button';\n shorthandProps.tabIndex = disabled && !disabledFocusable ? undefined : tabIndex ?? 0;\n }\n\n // Remove non-DOM disabledFocusable prop\n delete shorthandProps.disabledFocusable;\n }\n\n return shorthandProps;\n};\n"],"sourceRoot":"../src/"}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { useARIAButton } from './hooks/index';
|
|
2
|
+
export { mergeARIADisabled } from './utils/index';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { useARIAButton } from './hooks/index';\nexport type { ARIAButtonSlotProps } from './hooks/index';\nexport { mergeARIADisabled } from './utils/index';\n"]}
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './mergeARIADisabled';\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export function mergeARIADisabled(shorthand) {
|
|
5
5
|
var _a;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const disabled = (_a = shorthand.disabled) !== null && _a !== void 0 ? _a : shorthand['aria-disabled'];
|
|
8
8
|
|
|
9
9
|
if (typeof disabled === 'string') {
|
|
10
10
|
return disabled === 'false' ? false : true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["utils/mergeARIADisabled.ts"],"names":[],"mappings":"AAAA;;AAEG;AACH,OAAM,SAAU,iBAAV,CAA4B,SAA5B,EAAiG;;;AACrG,QAAM,QAAQ,GAAG,CAAA,EAAA,GAAA,SAAS,CAAC,QAAV,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,EAAlB,GAAsB,SAAS,CAAC,eAAD,CAAhD;;AACA,MAAI,OAAO,QAAP,KAAoB,QAAxB,EAAkC;AAChC,WAAO,QAAQ,KAAK,OAAb,GAAuB,KAAvB,GAA+B,IAAtC;AACD;;AACD,SAAO,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,KAAnB;AACD","sourcesContent":["/**\n * Merges disabled declaration with `aria-disabled`\n */\nexport function mergeARIADisabled(shorthand: { 'aria-disabled'?: string | boolean; disabled?: boolean }) {\n const disabled = shorthand.disabled ?? shorthand['aria-disabled'];\n if (typeof disabled === 'string') {\n return disabled === 'false' ? false : true;\n }\n return disabled ?? false;\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './useARIAButton';\n"],"sourceRoot":"../src/"}
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useARIAButton = void 0;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
11
|
/**
|
|
12
12
|
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
13
13
|
* for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
|
|
@@ -15,20 +15,19 @@ var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const useARIAButton = (shorthand, options) => {
|
|
19
19
|
var _a;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var onClickHandler = react_utilities_1.useEventCallback(function (ev) {
|
|
21
|
+
const shorthandProps = react_utilities_1.resolveShorthand(shorthand, options);
|
|
22
|
+
const {
|
|
23
|
+
disabled,
|
|
24
|
+
disabledFocusable,
|
|
25
|
+
onClick,
|
|
26
|
+
onKeyDown,
|
|
27
|
+
onKeyUp,
|
|
28
|
+
tabIndex
|
|
29
|
+
} = shorthandProps || {};
|
|
30
|
+
const onClickHandler = react_utilities_1.useEventCallback(ev => {
|
|
32
31
|
if (disabled || disabledFocusable) {
|
|
33
32
|
ev.preventDefault();
|
|
34
33
|
ev.stopPropagation();
|
|
@@ -36,14 +35,14 @@ function useARIAButton(shorthand, options) {
|
|
|
36
35
|
onClick === null || onClick === void 0 ? void 0 : onClick(ev);
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
|
-
|
|
38
|
+
const onKeyDownHandler = react_utilities_1.useEventCallback(ev => {
|
|
40
39
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
|
|
41
40
|
|
|
42
41
|
if (ev.isDefaultPrevented()) {
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
const key = ev.key;
|
|
47
46
|
|
|
48
47
|
if ((disabled || disabledFocusable) && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
|
|
49
48
|
ev.preventDefault();
|
|
@@ -60,14 +59,14 @@ function useARIAButton(shorthand, options) {
|
|
|
60
59
|
ev.currentTarget.click();
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
|
-
|
|
62
|
+
const onKeyupHandler = react_utilities_1.useEventCallback(ev => {
|
|
64
63
|
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
|
|
65
64
|
|
|
66
65
|
if (ev.isDefaultPrevented()) {
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
const key = ev.key;
|
|
71
70
|
|
|
72
71
|
if ((disabled || disabledFocusable) && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
|
|
73
72
|
ev.preventDefault();
|
|
@@ -85,12 +84,18 @@ function useARIAButton(shorthand, options) {
|
|
|
85
84
|
// If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
|
|
86
85
|
if (shorthandProps.as === 'button' || shorthandProps.as === undefined) {
|
|
87
86
|
shorthandProps.disabled = disabled && !disabledFocusable;
|
|
88
|
-
shorthandProps['aria-disabled'] = disabledFocusable;
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
shorthandProps['aria-disabled'] = disabledFocusable ? true : undefined; // Undefine events if disabledFocusable is passed in
|
|
88
|
+
|
|
89
|
+
if (disabledFocusable) {
|
|
90
|
+
shorthandProps.onClick = undefined;
|
|
91
|
+
shorthandProps.onKeyDown = undefined;
|
|
92
|
+
shorthandProps.onKeyUp = undefined;
|
|
93
|
+
}
|
|
94
|
+
} // If an <a> tag is to be rendered we have to remove disabled and type, and set aria-disabled, role and tabIndex.
|
|
91
95
|
else {
|
|
92
96
|
delete shorthandProps.disabled;
|
|
93
97
|
shorthandProps['aria-disabled'] = disabled || disabledFocusable;
|
|
98
|
+
shorthandProps.href = disabled ? undefined : shorthandProps.href;
|
|
94
99
|
shorthandProps.onClick = onClickHandler;
|
|
95
100
|
shorthandProps.onKeyDown = onKeyDownHandler;
|
|
96
101
|
shorthandProps.onKeyUp = onKeyupHandler;
|
|
@@ -103,7 +108,7 @@ function useARIAButton(shorthand, options) {
|
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
return shorthandProps;
|
|
106
|
-
}
|
|
111
|
+
};
|
|
107
112
|
|
|
108
113
|
exports.useARIAButton = useARIAButton;
|
|
109
114
|
//# sourceMappingURL=useARIAButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["hooks/useARIAButton.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAQA;;;;AAIG;;;AACI,MAAM,aAAa,GAAkD,CAAC,SAAD,EAAY,OAAZ,KAAuB;;;AACjG,QAAM,cAAc,GAAG,iBAAA,CAAA,gBAAA,CAAiB,SAAjB,EAA4B,OAA5B,CAAvB;AAEA,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA,iBAAZ;AAA+B,IAAA,OAA/B;AAAwC,IAAA,SAAxC;AAAmD,IAAA,OAAnD;AAA4D,IAAA;AAA5D,MAA0E,cAAc,IAC5F,EADF;AAGA,QAAM,cAAc,GAAmC,iBAAA,CAAA,gBAAA,CAAiB,EAAE,IAAG;AAC3E,QAAI,QAAQ,IAAI,iBAAhB,EAAmC;AACjC,MAAA,EAAE,CAAC,cAAH;AACA,MAAA,EAAE,CAAC,eAAH;AACD,KAHD,MAGO;AACL,MAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAG,EAAH,CAAP;AACD;AACF,GAPsD,CAAvD;AASA,QAAM,gBAAgB,GAAqC,iBAAA,CAAA,gBAAA,CAAiB,EAAE,IAAG;AAC/E,IAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAG,EAAH,CAAT;;AAEA,QAAI,EAAE,CAAC,kBA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AkC,cAAc,CAAC,EAAf,KAAsB,SAA5D,EAAuE;AACrE,MAAA,cAAc,CAAC,QAAf,GAA0B,QAAQ,IAAI,CAAC,iBAAvC;AACA,MAAA,cAAc,CAAC,eAAD,CAAd,GAAkC,iBAAiB,GAAG,IAAH,GAAU,SAA7D,CAFqE,CAIrE;;AACA,UAAI,iBAAJ,EAAuB;AACrB,QAAA,cAAc,CAAC,OAAf,GAAyB,SAAzB;AACA,QAAA,cAAc,CAAC,SAAf,GAA2B,SAA3B;AACA,QAAA,cAAc,CAAC,OAAf,GAAyB,SAAzB;AACD;AACF,KAVD,CAYA;AAZA,SAaK;AACH,aAAO,cAAc,CAAC,QAAtB;AACA,MAAA,cAAc,CAAC,eAAD,CAAd,GAAkC,QAAQ,IAAI,iBAA9C;AACC,MAAA,cAA6C,CAAC,IAA9C,GAAqD,QAAQ,GAC1D,SAD0D,GAEzD,cAA6C,CAAC,IAFlD;AAGD,MAAA,cAAc,CAAC,OAAf,GAAyB,cAAzB;AACA,MAAA,cAAc,CAAC,SAAf,GAA2B,gBAA3B;AACA,MAAA,cAAc,CAAC,OAAf,GAAyB,cAAzB;AACA,MAAA,cAAc,CAAC,IAAf,GAAsB,CAAA,EAAA,GAAA,cAAc,CAAC,IAAf,MAAmB,IAAnB,IAAmB,EAAA,KAAA,KAAA,CAAnB,GAAmB,EAAnB,GAAuB,QAA7C;AACA,MAAA,cAAc,CAAC,QAAf,GAA0B,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,CAAnF;AACD,KA1BiB,CA4BlB;;;AACA,WAAO,cAAc,CAAC,iBAAtB;AACD;;AAED,SAAO,cAAP;AACD,CAhGM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { resolveShorthand, useEventCallback } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, ResolveShorthandFunction, Slot } from '@fluentui/react-utilities';\n\nexport type ARIAButtonSlotProps = ExtractSlotProps<Slot<'button', 'a'>> & {\n disabled?: boolean;\n disabledFocusable?: boolean;\n};\n\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 useARIAButton: ResolveShorthandFunction<ARIAButtonSlotProps> = (shorthand, options) => {\n const shorthandProps = resolveShorthand(shorthand, options);\n\n const { disabled, disabledFocusable, onClick, onKeyDown, onKeyUp, tabIndex } = (shorthandProps ||\n {}) as ARIAButtonSlotProps;\n\n const onClickHandler: ARIAButtonSlotProps['onClick'] = useEventCallback(ev => {\n if (disabled || disabledFocusable) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const onKeyDownHandler: ARIAButtonSlotProps['onKeyDown'] = useEventCallback(ev => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 onKeyupHandler: ARIAButtonSlotProps['onKeyUp'] = useEventCallback(ev => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 (shorthandProps) {\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (shorthandProps.as === 'button' || shorthandProps.as === undefined) {\n shorthandProps.disabled = disabled && !disabledFocusable;\n shorthandProps['aria-disabled'] = disabledFocusable ? true : undefined;\n\n // Undefine events if disabledFocusable is passed in\n if (disabledFocusable) {\n shorthandProps.onClick = undefined;\n shorthandProps.onKeyDown = undefined;\n shorthandProps.onKeyUp = undefined;\n }\n }\n\n // If an <a> tag is to be rendered we have to remove disabled and type, and set aria-disabled, role and tabIndex.\n else {\n delete shorthandProps.disabled;\n shorthandProps['aria-disabled'] = disabled || disabledFocusable;\n (shorthandProps as JSX.IntrinsicElements['a']).href = disabled\n ? undefined\n : (shorthandProps as JSX.IntrinsicElements['a']).href;\n shorthandProps.onClick = onClickHandler;\n shorthandProps.onKeyDown = onKeyDownHandler;\n shorthandProps.onKeyUp = onKeyupHandler;\n shorthandProps.role = shorthandProps.role ?? 'button';\n shorthandProps.tabIndex = disabled && !disabledFocusable ? undefined : tabIndex ?? 0;\n }\n\n // Remove non-DOM disabledFocusable prop\n delete shorthandProps.disabledFocusable;\n }\n\n return shorthandProps;\n};\n"],"sourceRoot":"../src/"}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.mergeARIADisabled = exports.useARIAButton = void 0;
|
|
6
7
|
|
|
7
|
-
var
|
|
8
|
+
var index_1 = /*#__PURE__*/require("./hooks/index");
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
Object.defineProperty(exports, "useARIAButton", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return index_1.useARIAButton;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
var index_2 = /*#__PURE__*/require("./utils/index");
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
Object.defineProperty(exports, "mergeARIADisabled", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return index_2.mergeARIADisabled;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
12
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,eAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,aAAA;AAAa;AAAb,CAAA;;AAET,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mBAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,iBAAA;AAAiB;AAAjB,CAAA","sourcesContent":["export { useARIAButton } from './hooks/index';\nexport type { ARIAButtonSlotProps } from './hooks/index';\nexport { mergeARIADisabled } from './utils/index';\n"],"sourceRoot":"../src/"}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
8
|
|
|
9
9
|
tslib_1.__exportStar(require("./mergeARIADisabled"), exports);
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './mergeARIADisabled';\n"],"sourceRoot":"../src/"}
|
|
@@ -11,7 +11,7 @@ exports.mergeARIADisabled = void 0;
|
|
|
11
11
|
function mergeARIADisabled(shorthand) {
|
|
12
12
|
var _a;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const disabled = (_a = shorthand.disabled) !== null && _a !== void 0 ? _a : shorthand['aria-disabled'];
|
|
15
15
|
|
|
16
16
|
if (typeof disabled === 'string') {
|
|
17
17
|
return disabled === 'false' ? false : true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["utils/mergeARIADisabled.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACH,SAAgB,iBAAhB,CAAkC,SAAlC,EAAuG;;;AACrG,QAAM,QAAQ,GAAG,CAAA,EAAA,GAAA,SAAS,CAAC,QAAV,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,EAAlB,GAAsB,SAAS,CAAC,eAAD,CAAhD;;AACA,MAAI,OAAO,QAAP,KAAoB,QAAxB,EAAkC;AAChC,WAAO,QAAQ,KAAK,OAAb,GAAuB,KAAvB,GAA+B,IAAtC;AACD;;AACD,SAAO,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,KAAnB;AACD;;AAND,OAAA,CAAA,iBAAA,GAAA,iBAAA","sourcesContent":["/**\n * Merges disabled declaration with `aria-disabled`\n */\nexport function mergeARIADisabled(shorthand: { 'aria-disabled'?: string | boolean; disabled?: boolean }) {\n const disabled = shorthand.disabled ?? shorthand['aria-disabled'];\n if (typeof disabled === 'string') {\n return disabled === 'false' ? false : true;\n }\n return disabled ?? false;\n}\n"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-aria",
|
|
3
|
-
"version": "9.0.0-
|
|
3
|
+
"version": "9.0.0-rc.10",
|
|
4
4
|
"description": "React helper to ensure ARIA",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
7
|
-
"typings": "
|
|
7
|
+
"typings": "dist/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -18,31 +18,20 @@
|
|
|
18
18
|
"just": "just-scripts",
|
|
19
19
|
"lint": "just-scripts lint",
|
|
20
20
|
"start": "yarn storybook",
|
|
21
|
-
"test": "jest",
|
|
21
|
+
"test": "jest --passWithNoTests",
|
|
22
22
|
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
|
|
23
|
-
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node
|
|
24
|
-
"storybook": "
|
|
23
|
+
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/packages/react-components/react-aria/src && yarn docs",
|
|
24
|
+
"storybook": "node ../../../scripts/storybook/runner",
|
|
25
|
+
"type-check": "tsc -b tsconfig.json"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@fluentui/eslint-plugin": "*",
|
|
28
|
-
"@fluentui/jest-serializer-make-styles": "9.0.0-nightly.d730088d7f.0",
|
|
29
29
|
"@fluentui/react-conformance": "*",
|
|
30
|
-
"@fluentui/scripts": "^1.0.0"
|
|
31
|
-
"@types/enzyme": "3.10.3",
|
|
32
|
-
"@types/enzyme-adapter-react-16": "1.0.3",
|
|
33
|
-
"@types/react": "16.9.42",
|
|
34
|
-
"@types/react-dom": "16.9.10",
|
|
35
|
-
"@types/react-test-renderer": "^16.0.0",
|
|
36
|
-
"enzyme": "~3.10.0",
|
|
37
|
-
"enzyme-adapter-react-16": "^1.15.0",
|
|
38
|
-
"react": "16.8.6",
|
|
39
|
-
"react-dom": "16.8.6",
|
|
40
|
-
"react-test-renderer": "^16.3.0"
|
|
30
|
+
"@fluentui/scripts": "^1.0.0"
|
|
41
31
|
},
|
|
42
32
|
"dependencies": {
|
|
43
|
-
"@fluentui/keyboard-keys": "9.0.0-
|
|
44
|
-
"@fluentui/react-
|
|
45
|
-
"@fluentui/react-utilities": "9.0.0-nightly.d730088d7f.0",
|
|
33
|
+
"@fluentui/keyboard-keys": "9.0.0-rc.6",
|
|
34
|
+
"@fluentui/react-utilities": "9.0.0-rc.10",
|
|
46
35
|
"tslib": "^2.1.0"
|
|
47
36
|
},
|
|
48
37
|
"peerDependencies": {
|
|
@@ -52,11 +41,17 @@
|
|
|
52
41
|
"react-dom": ">=16.8.0 <18.0.0"
|
|
53
42
|
},
|
|
54
43
|
"beachball": {
|
|
55
|
-
"tag": "beta",
|
|
56
44
|
"disallowedChangeTypes": [
|
|
57
45
|
"major",
|
|
58
46
|
"minor",
|
|
59
47
|
"patch"
|
|
60
48
|
]
|
|
49
|
+
},
|
|
50
|
+
"exports": {
|
|
51
|
+
".": {
|
|
52
|
+
"types": "./lib/index.d.ts",
|
|
53
|
+
"import": "./lib/index.js",
|
|
54
|
+
"require": "./lib-commonjs/index.js"
|
|
55
|
+
}
|
|
61
56
|
}
|
|
62
57
|
}
|
package/dist/react-aria.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
|
2
|
-
import { ObjectShorthandProps } from '@fluentui/react-utilities';
|
|
3
|
-
import * as React_2 from 'react';
|
|
4
|
-
import type { ResolveShorthandOptions } from '@fluentui/react-utilities';
|
|
5
|
-
import type { ShorthandProps } from '@fluentui/react-utilities';
|
|
6
|
-
|
|
7
|
-
export declare type ARIAButtonShorthandProps = IntrinsicShorthandProps<'button', 'a'> & {
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
disabledFocusable?: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Merges disabled declaration with `aria-disabled`
|
|
14
|
-
*/
|
|
15
|
-
export declare function mergeARIADisabled(shorthand: ObjectShorthandProps<{
|
|
16
|
-
'aria-disabled'?: string | boolean;
|
|
17
|
-
children?: React_2.ReactNode;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
}>): boolean;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
23
|
-
* for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
|
|
24
|
-
* where no attribute addition is required.
|
|
25
|
-
*/
|
|
26
|
-
export declare function useARIAButton<Required extends boolean = false>(shorthand: ShorthandProps<ARIAButtonShorthandProps>, options?: ResolveShorthandOptions<ARIAButtonShorthandProps, Required>): Required extends false ? ARIAButtonShorthandProps | undefined : ARIAButtonShorthandProps;
|
|
27
|
-
|
|
28
|
-
export { }
|
package/lib/hooks/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useARIAButton';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { IntrinsicShorthandProps, ResolveShorthandOptions, ShorthandProps } from '@fluentui/react-utilities';
|
|
2
|
-
export declare type ARIAButtonShorthandProps = IntrinsicShorthandProps<'button', 'a'> & {
|
|
3
|
-
disabled?: boolean;
|
|
4
|
-
disabledFocusable?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
8
|
-
* for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
|
|
9
|
-
* where no attribute addition is required.
|
|
10
|
-
*/
|
|
11
|
-
export declare function useARIAButton<Required extends boolean = false>(shorthand: ShorthandProps<ARIAButtonShorthandProps>, options?: ResolveShorthandOptions<ARIAButtonShorthandProps, Required>): Required extends false ? ARIAButtonShorthandProps | undefined : ARIAButtonShorthandProps;
|
package/lib/index.d.ts
DELETED
package/lib/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './mergeARIADisabled';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ObjectShorthandProps } from '@fluentui/react-utilities';
|
|
3
|
-
/**
|
|
4
|
-
* Merges disabled declaration with `aria-disabled`
|
|
5
|
-
*/
|
|
6
|
-
export declare function mergeARIADisabled(shorthand: ObjectShorthandProps<{
|
|
7
|
-
'aria-disabled'?: string | boolean;
|
|
8
|
-
children?: React.ReactNode;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}>): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useARIAButton';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { IntrinsicShorthandProps, ResolveShorthandOptions, ShorthandProps } from '@fluentui/react-utilities';
|
|
2
|
-
export declare type ARIAButtonShorthandProps = IntrinsicShorthandProps<'button', 'a'> & {
|
|
3
|
-
disabled?: boolean;
|
|
4
|
-
disabledFocusable?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
|
|
8
|
-
* for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
|
|
9
|
-
* where no attribute addition is required.
|
|
10
|
-
*/
|
|
11
|
-
export declare function useARIAButton<Required extends boolean = false>(shorthand: ShorthandProps<ARIAButtonShorthandProps>, options?: ResolveShorthandOptions<ARIAButtonShorthandProps, Required>): Required extends false ? ARIAButtonShorthandProps | undefined : ARIAButtonShorthandProps;
|
package/lib-commonjs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './mergeARIADisabled';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ObjectShorthandProps } from '@fluentui/react-utilities';
|
|
3
|
-
/**
|
|
4
|
-
* Merges disabled declaration with `aria-disabled`
|
|
5
|
-
*/
|
|
6
|
-
export declare function mergeARIADisabled(shorthand: ObjectShorthandProps<{
|
|
7
|
-
'aria-disabled'?: string | boolean;
|
|
8
|
-
children?: React.ReactNode;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}>): boolean;
|