@react-aria/actiongroup 3.3.2-nightly.3358 → 3.3.2-nightly.3363
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/dist/main.js +2 -23
- package/dist/main.js.map +1 -1
- package/dist/module.js +0 -9
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +6 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/index.ts +3 -3
- package/src/useActionGroup.ts +4 -3
- package/src/useActionGroupItem.ts +4 -3
package/dist/main.js
CHANGED
|
@@ -3,28 +3,12 @@ var $hjKwo$reactariautils = require("@react-aria/utils");
|
|
|
3
3
|
var $hjKwo$reactariai18n = require("@react-aria/i18n");
|
|
4
4
|
var $hjKwo$react = require("react");
|
|
5
5
|
|
|
6
|
-
function $parcel$exportWildcard(dest, source) {
|
|
7
|
-
Object.keys(source).forEach(function(key) {
|
|
8
|
-
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(dest, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return source[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return dest;
|
|
21
|
-
}
|
|
22
6
|
function $parcel$export(e, n, v, s) {
|
|
23
7
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
24
8
|
}
|
|
25
|
-
var $ceb684449a137553$exports = {};
|
|
26
9
|
|
|
27
|
-
$parcel$export(
|
|
10
|
+
$parcel$export(module.exports, "useActionGroup", () => $ceb684449a137553$export$f4bf8d43c16de704);
|
|
11
|
+
$parcel$export(module.exports, "useActionGroupItem", () => $44b92e5de834b44e$export$9597202bd3099a29);
|
|
28
12
|
|
|
29
13
|
|
|
30
14
|
|
|
@@ -85,9 +69,6 @@ function $ceb684449a137553$export$f4bf8d43c16de704(props, state, ref) {
|
|
|
85
69
|
}
|
|
86
70
|
|
|
87
71
|
|
|
88
|
-
var $44b92e5de834b44e$exports = {};
|
|
89
|
-
|
|
90
|
-
$parcel$export($44b92e5de834b44e$exports, "useActionGroupItem", () => $44b92e5de834b44e$export$9597202bd3099a29);
|
|
91
72
|
|
|
92
73
|
|
|
93
74
|
const $44b92e5de834b44e$var$BUTTON_ROLES = {
|
|
@@ -134,8 +115,6 @@ function $44b92e5de834b44e$export$9597202bd3099a29(props, state, ref) {
|
|
|
134
115
|
}
|
|
135
116
|
|
|
136
117
|
|
|
137
|
-
$parcel$exportWildcard(module.exports, $ceb684449a137553$exports);
|
|
138
|
-
$parcel$exportWildcard(module.exports, $44b92e5de834b44e$exports);
|
|
139
118
|
|
|
140
119
|
|
|
141
120
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;ACqBA,KAAK,CAAC,wCAAkB,GAAG,CAAC;IAC1B,CAAM,OAAE,CAAS;IACjB,CAAQ,SAAE,CAAY;IACtB,CAAU,WAAE,CAAS;AACvB,CAAC;SAMe,yCAAc,CAAI,KAA8B,EAAE,KAAmB,EAAE,GAAgC,EAAmB,CAAC;IACzI,GAAG,CAAC,CAAC,aACH,UAAU,gBACV,WAAW,GAAG,CAAY,aAC5B,CAAC,GAAG,KAAK;IACT,GAAG,CAAC,OAAO,GAAG,CAAC;WAAG,KAAK,CAAC,UAAU,CAAC,OAAO;IAAE,CAAC;IAC7C,EAAE,GAAG,OAAO,CAAC,IAAI,EAAC,GAAG,IAAK,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG;OAClD,UAAU,GAAG,IAAI;IAGnB,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,8BAAS;IAC3B,GAAG,CAAC,YAAY,GAAG,wCAAkB,CAAC,GAAG;IACzC,GAAG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AE;YACzE,OAAO,IAAG,CAAC;gBACT,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG;YAChD,CAAC;YACD,OAAO,IAAG,CAAC;gBACT,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG;YACzC,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/actiongroup/src/index.ts","packages/@react-aria/actiongroup/src/useActionGroup.ts","packages/@react-aria/actiongroup/src/useActionGroupItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaActionGroupProps} from '@react-types/actiongroup';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\ninterface ActionGroupItemProps {\n key: Key\n}\n\ninterface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {\n let selectionMode = state.selectionManager.selectionMode;\n let buttonProps = {\n role: BUTTON_ROLES[selectionMode]\n };\n\n if (selectionMode !== 'none') {\n let isSelected = state.selectionManager.isSelected(props.key);\n buttonProps['aria-checked'] = isSelected;\n }\n\n let isFocused = props.key === state.selectionManager.focusedKey;\n let lastRender = useRef({isFocused, state});\n lastRender.current = {isFocused, state};\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (lastRender.current.isFocused) {\n lastRender.current.state.selectionManager.setFocusedKey(null);\n }\n };\n }, []);\n\n return {\n buttonProps: mergeProps(buttonProps, {\n tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,\n onFocus() {\n state.selectionManager.setFocusedKey(props.key);\n },\n onPress() {\n state.selectionManager.select(props.key);\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -3,12 +3,6 @@ import {filterDOMProps as $1oG4F$filterDOMProps, mergeProps as $1oG4F$mergeProps
|
|
|
3
3
|
import {useLocale as $1oG4F$useLocale} from "@react-aria/i18n";
|
|
4
4
|
import {useRef as $1oG4F$useRef, useEffect as $1oG4F$useEffect} from "react";
|
|
5
5
|
|
|
6
|
-
function $parcel$export(e, n, v, s) {
|
|
7
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
-
}
|
|
9
|
-
var $304ac34015d4535d$exports = {};
|
|
10
|
-
|
|
11
|
-
$parcel$export($304ac34015d4535d$exports, "useActionGroup", () => $304ac34015d4535d$export$f4bf8d43c16de704);
|
|
12
6
|
|
|
13
7
|
|
|
14
8
|
|
|
@@ -69,9 +63,6 @@ function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
|
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
|
|
72
|
-
var $f0ac0fb73c3ec062$exports = {};
|
|
73
|
-
|
|
74
|
-
$parcel$export($f0ac0fb73c3ec062$exports, "useActionGroupItem", () => $f0ac0fb73c3ec062$export$9597202bd3099a29);
|
|
75
66
|
|
|
76
67
|
|
|
77
68
|
const $f0ac0fb73c3ec062$var$BUTTON_ROLES = {
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;ACqBA,KAAK,CAAC,wCAAkB,GAAG,CAAC;IAC1B,CAAM,OAAE,CAAS;IACjB,CAAQ,SAAE,CAAY;IACtB,CAAU,WAAE,CAAS;AACvB,CAAC;SAMe,yCAAc,CAAI,KAA8B,EAAE,KAAmB,EAAE,GAAgC,EAAmB,CAAC;IACzI,GAAG,CAAC,CAAC,aACH,UAAU,gBACV,WAAW,GAAG,CAAY,aAC5B,CAAC,GAAG,KAAK;IACT,GAAG,CAAC,OAAO,GAAG,CAAC;WAAG,KAAK,CAAC,UAAU,CAAC,OAAO;IAAE,CAAC;IAC7C,EAAE,GAAG,OAAO,CAAC,IAAI,EAAC,GAAG,IAAK,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG;OAClD,UAAU,GAAG,IAAI;IAGnB,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,gBAAS;IAC3B,GAAG,CAAC,YAAY,GAAG,yBAAkB,CAAC,GAAG;IACzC,GAAG,CAAC,a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OAAO,IAAG,CAAC;gBACT,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG;YAChD,CAAC;YACD,OAAO,IAAG,CAAC;gBACT,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG;YACzC,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/actiongroup/src/index.ts","packages/@react-aria/actiongroup/src/useActionGroup.ts","packages/@react-aria/actiongroup/src/useActionGroupItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaActionGroupProps} from '@react-types/actiongroup';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\ninterface ActionGroupItemProps {\n key: Key\n}\n\ninterface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {\n let selectionMode = state.selectionManager.selectionMode;\n let buttonProps = {\n role: BUTTON_ROLES[selectionMode]\n };\n\n if (selectionMode !== 'none') {\n let isSelected = state.selectionManager.isSelected(props.key);\n buttonProps['aria-checked'] = isSelected;\n }\n\n let isFocused = props.key === state.selectionManager.focusedKey;\n let lastRender = useRef({isFocused, state});\n lastRender.current = {isFocused, state};\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (lastRender.current.isFocused) {\n lastRender.current.state.selectionManager.setFocusedKey(null);\n }\n };\n }, []);\n\n return {\n buttonProps: mergeProps(buttonProps, {\n tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,\n onFocus() {\n state.selectionManager.setFocusedKey(props.key);\n },\n onPress() {\n state.selectionManager.select(props.key);\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { AriaActionGroupProps } from "@react-types/actiongroup";
|
|
2
|
-
import {
|
|
2
|
+
import { DOMAttributes, FocusableElement } from "@react-types/shared";
|
|
3
3
|
import { ListState } from "@react-stately/list";
|
|
4
|
+
import { RefObject, Key } from "react";
|
|
4
5
|
import { PressProps } from "@react-aria/interactions";
|
|
5
6
|
export interface ActionGroupAria {
|
|
6
|
-
actionGroupProps:
|
|
7
|
+
actionGroupProps: DOMAttributes;
|
|
7
8
|
}
|
|
8
|
-
export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<
|
|
9
|
+
export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria;
|
|
9
10
|
interface ActionGroupItemProps {
|
|
10
11
|
key: Key;
|
|
11
12
|
}
|
|
12
13
|
interface ActionGroupItemAria {
|
|
13
|
-
buttonProps:
|
|
14
|
+
buttonProps: DOMAttributes & PressProps;
|
|
14
15
|
}
|
|
15
|
-
export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<
|
|
16
|
+
export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria;
|
|
16
17
|
|
|
17
18
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;AA2BA;IACE,gBAAgB,EAAE,aAAa,CAAA;CAChC;AAED,+BAA+B,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,eAAe,CAoDxI;ACjED;IACE,GAAG,EAAE,GAAG,CAAA;CACT;AAED;IACE,WAAW,EAAE,aAAa,GAAG,UAAU,CAAA;CACxC;AASD,mCAAmC,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,gBAAgB,CAAC,GAAG,mBAAmB,CAoC9I","sources":["packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/useActionGroup.ts","packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/useActionGroupItem.ts","packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/index.ts","packages/@react-aria/actiongroup/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/actiongroup",
|
|
3
|
-
"version": "3.3.2-nightly.
|
|
3
|
+
"version": "3.3.2-nightly.3363+2a6c48eb0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/focus": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
24
|
-
"@react-aria/selection": "3.0.0-nightly.
|
|
25
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
26
|
-
"@react-stately/collections": "3.0.0-nightly.
|
|
27
|
-
"@react-stately/list": "3.5.2-nightly.
|
|
28
|
-
"@react-types/actiongroup": "3.3.2-nightly.
|
|
29
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
21
|
+
"@react-aria/focus": "3.0.0-nightly.1663+2a6c48eb0",
|
|
22
|
+
"@react-aria/i18n": "3.0.0-nightly.1663+2a6c48eb0",
|
|
23
|
+
"@react-aria/interactions": "3.0.0-nightly.1663+2a6c48eb0",
|
|
24
|
+
"@react-aria/selection": "3.0.0-nightly.1663+2a6c48eb0",
|
|
25
|
+
"@react-aria/utils": "3.0.0-nightly.1663+2a6c48eb0",
|
|
26
|
+
"@react-stately/collections": "3.0.0-nightly.1663+2a6c48eb0",
|
|
27
|
+
"@react-stately/list": "3.5.2-nightly.3363+2a6c48eb0",
|
|
28
|
+
"@react-types/actiongroup": "3.3.2-nightly.3363+2a6c48eb0",
|
|
29
|
+
"@react-types/shared": "3.0.0-nightly.1663+2a6c48eb0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "2a6c48eb0099671cf9b530ec3d75882c549e9cb5"
|
|
38
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export type {ActionGroupAria} from './useActionGroup';
|
|
13
|
+
export {useActionGroup} from './useActionGroup';
|
|
14
|
+
export {useActionGroupItem} from './useActionGroupItem';
|
package/src/useActionGroup.ts
CHANGED
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
import {AriaActionGroupProps} from '@react-types/actiongroup';
|
|
14
14
|
import {createFocusManager} from '@react-aria/focus';
|
|
15
|
+
import {DOMAttributes, FocusableElement} from '@react-types/shared';
|
|
15
16
|
import {filterDOMProps} from '@react-aria/utils';
|
|
16
|
-
import {HTMLAttributes, RefObject} from 'react';
|
|
17
17
|
import {ListState} from '@react-stately/list';
|
|
18
18
|
import {Orientation} from '@react-types/shared';
|
|
19
|
+
import {RefObject} from 'react';
|
|
19
20
|
import {useLocale} from '@react-aria/i18n';
|
|
20
21
|
|
|
21
22
|
const BUTTON_GROUP_ROLES = {
|
|
@@ -25,10 +26,10 @@ const BUTTON_GROUP_ROLES = {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export interface ActionGroupAria {
|
|
28
|
-
actionGroupProps:
|
|
29
|
+
actionGroupProps: DOMAttributes
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<
|
|
32
|
+
export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {
|
|
32
33
|
let {
|
|
33
34
|
isDisabled,
|
|
34
35
|
orientation = 'horizontal' as Orientation
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {DOMAttributes, FocusableElement} from '@react-types/shared';
|
|
14
|
+
import {Key, RefObject, useEffect, useRef} from 'react';
|
|
14
15
|
import {ListState} from '@react-stately/list';
|
|
15
16
|
import {mergeProps} from '@react-aria/utils';
|
|
16
17
|
import {PressProps} from '@react-aria/interactions';
|
|
@@ -20,7 +21,7 @@ interface ActionGroupItemProps {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
interface ActionGroupItemAria {
|
|
23
|
-
buttonProps:
|
|
24
|
+
buttonProps: DOMAttributes & PressProps
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const BUTTON_ROLES = {
|
|
@@ -30,7 +31,7 @@ const BUTTON_ROLES = {
|
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<
|
|
34
|
+
export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {
|
|
34
35
|
let selectionMode = state.selectionManager.selectionMode;
|
|
35
36
|
let buttonProps = {
|
|
36
37
|
role: BUTTON_ROLES[selectionMode]
|