@react-aria/actiongroup 3.7.4-nightly.4552 → 3.7.4-nightly.4558

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/import.mjs CHANGED
@@ -1,7 +1,5 @@
1
- import {createFocusManager as $1oG4F$createFocusManager} from "@react-aria/focus";
2
- import {useLayoutEffect as $1oG4F$useLayoutEffect, filterDOMProps as $1oG4F$filterDOMProps, useEffectEvent as $1oG4F$useEffectEvent, mergeProps as $1oG4F$mergeProps} from "@react-aria/utils";
3
- import {useState as $1oG4F$useState, useEffect as $1oG4F$useEffect} from "react";
4
- import {useLocale as $1oG4F$useLocale} from "@react-aria/i18n";
1
+ import {useActionGroup as $304ac34015d4535d$export$f4bf8d43c16de704} from "./useActionGroup.mjs";
2
+ import {useActionGroupItem as $f0ac0fb73c3ec062$export$9597202bd3099a29} from "./useActionGroupItem.mjs";
5
3
 
6
4
  /*
7
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -13,137 +11,9 @@ import {useLocale as $1oG4F$useLocale} from "@react-aria/i18n";
13
11
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
12
  * OF ANY KIND, either express or implied. See the License for the specific language
15
13
  * governing permissions and limitations under the License.
16
- */ /*
17
- * Copyright 2020 Adobe. All rights reserved.
18
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
- * you may not use this file except in compliance with the License. You may obtain a copy
20
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software distributed under
23
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
- * OF ANY KIND, either express or implied. See the License for the specific language
25
- * governing permissions and limitations under the License.
26
14
  */
27
15
 
28
16
 
29
17
 
30
- const $304ac34015d4535d$var$BUTTON_GROUP_ROLES = {
31
- "none": "toolbar",
32
- "single": "radiogroup",
33
- "multiple": "toolbar"
34
- };
35
- function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
36
- let { isDisabled: isDisabled, orientation: orientation = "horizontal" } = props;
37
- let [isInToolbar, setInToolbar] = (0, $1oG4F$useState)(false);
38
- (0, $1oG4F$useLayoutEffect)(()=>{
39
- var _ref_current_parentElement;
40
- setInToolbar(!!(ref.current && ((_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.closest('[role="toolbar"]'))));
41
- }, [
42
- ref
43
- ]);
44
- let allKeys = [
45
- ...state.collection.getKeys()
46
- ];
47
- if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
48
- let { direction: direction } = (0, $1oG4F$useLocale)();
49
- let focusManager = (0, $1oG4F$createFocusManager)(ref);
50
- let flipDirection = direction === "rtl" && orientation === "horizontal";
51
- let onKeyDown = (e)=>{
52
- if (!e.currentTarget.contains(e.target)) return;
53
- switch(e.key){
54
- case "ArrowRight":
55
- case "ArrowDown":
56
- e.preventDefault();
57
- e.stopPropagation();
58
- if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
59
- wrap: true
60
- });
61
- else focusManager.focusNext({
62
- wrap: true
63
- });
64
- break;
65
- case "ArrowLeft":
66
- case "ArrowUp":
67
- e.preventDefault();
68
- e.stopPropagation();
69
- if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
70
- wrap: true
71
- });
72
- else focusManager.focusPrevious({
73
- wrap: true
74
- });
75
- break;
76
- }
77
- };
78
- let role = $304ac34015d4535d$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
79
- if (isInToolbar && role === "toolbar") role = "group";
80
- return {
81
- actionGroupProps: {
82
- ...(0, $1oG4F$filterDOMProps)(props, {
83
- labelable: true
84
- }),
85
- role: role,
86
- "aria-orientation": role === "toolbar" ? orientation : undefined,
87
- "aria-disabled": isDisabled,
88
- onKeyDown: onKeyDown
89
- }
90
- };
91
- }
92
-
93
-
94
- /*
95
- * Copyright 2020 Adobe. All rights reserved.
96
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
97
- * you may not use this file except in compliance with the License. You may obtain a copy
98
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
99
- *
100
- * Unless required by applicable law or agreed to in writing, software distributed under
101
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
102
- * OF ANY KIND, either express or implied. See the License for the specific language
103
- * governing permissions and limitations under the License.
104
- */
105
-
106
- const $f0ac0fb73c3ec062$var$BUTTON_ROLES = {
107
- "none": undefined,
108
- "single": "radio",
109
- "multiple": "checkbox"
110
- };
111
- function $f0ac0fb73c3ec062$export$9597202bd3099a29(props, state, ref) {
112
- let selectionMode = state.selectionManager.selectionMode;
113
- let buttonProps = {
114
- role: $f0ac0fb73c3ec062$var$BUTTON_ROLES[selectionMode]
115
- };
116
- if (selectionMode !== "none") {
117
- let isSelected = state.selectionManager.isSelected(props.key);
118
- buttonProps["aria-checked"] = isSelected;
119
- }
120
- let isFocused = props.key === state.selectionManager.focusedKey;
121
- let onRemovedWithFocus = (0, $1oG4F$useEffectEvent)(()=>{
122
- if (isFocused) state.selectionManager.setFocusedKey(null);
123
- });
124
- // If the focused item is removed from the DOM, reset the focused key to null.
125
- (0, $1oG4F$useEffect)(()=>{
126
- return ()=>{
127
- onRemovedWithFocus();
128
- };
129
- }, [
130
- onRemovedWithFocus
131
- ]);
132
- return {
133
- buttonProps: (0, $1oG4F$mergeProps)(buttonProps, {
134
- tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
135
- onFocus () {
136
- state.selectionManager.setFocusedKey(props.key);
137
- },
138
- onPress () {
139
- state.selectionManager.select(props.key);
140
- }
141
- })
142
- };
143
- }
144
-
145
-
146
-
147
-
148
18
  export {$304ac34015d4535d$export$f4bf8d43c16de704 as useActionGroup, $f0ac0fb73c3ec062$export$9597202bd3099a29 as useActionGroupItem};
149
19
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,15 +1,13 @@
1
- var $hjKwo$reactariafocus = require("@react-aria/focus");
2
- var $hjKwo$reactariautils = require("@react-aria/utils");
3
- var $hjKwo$react = require("react");
4
- var $hjKwo$reactariai18n = require("@react-aria/i18n");
1
+ var $ceb684449a137553$exports = require("./useActionGroup.main.js");
2
+ var $44b92e5de834b44e$exports = require("./useActionGroupItem.main.js");
5
3
 
6
4
 
7
5
  function $parcel$export(e, n, v, s) {
8
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
7
  }
10
8
 
11
- $parcel$export(module.exports, "useActionGroup", () => $ceb684449a137553$export$f4bf8d43c16de704);
12
- $parcel$export(module.exports, "useActionGroupItem", () => $44b92e5de834b44e$export$9597202bd3099a29);
9
+ $parcel$export(module.exports, "useActionGroup", () => $ceb684449a137553$exports.useActionGroup);
10
+ $parcel$export(module.exports, "useActionGroupItem", () => $44b92e5de834b44e$exports.useActionGroupItem);
13
11
  /*
14
12
  * Copyright 2020 Adobe. All rights reserved.
15
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -20,136 +18,8 @@ $parcel$export(module.exports, "useActionGroupItem", () => $44b92e5de834b44e$exp
20
18
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
19
  * OF ANY KIND, either express or implied. See the License for the specific language
22
20
  * governing permissions and limitations under the License.
23
- */ /*
24
- * Copyright 2020 Adobe. All rights reserved.
25
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
26
- * you may not use this file except in compliance with the License. You may obtain a copy
27
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
28
- *
29
- * Unless required by applicable law or agreed to in writing, software distributed under
30
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
31
- * OF ANY KIND, either express or implied. See the License for the specific language
32
- * governing permissions and limitations under the License.
33
21
  */
34
22
 
35
23
 
36
24
 
37
- const $ceb684449a137553$var$BUTTON_GROUP_ROLES = {
38
- "none": "toolbar",
39
- "single": "radiogroup",
40
- "multiple": "toolbar"
41
- };
42
- function $ceb684449a137553$export$f4bf8d43c16de704(props, state, ref) {
43
- let { isDisabled: isDisabled, orientation: orientation = "horizontal" } = props;
44
- let [isInToolbar, setInToolbar] = (0, $hjKwo$react.useState)(false);
45
- (0, $hjKwo$reactariautils.useLayoutEffect)(()=>{
46
- var _ref_current_parentElement;
47
- setInToolbar(!!(ref.current && ((_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.closest('[role="toolbar"]'))));
48
- }, [
49
- ref
50
- ]);
51
- let allKeys = [
52
- ...state.collection.getKeys()
53
- ];
54
- if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
55
- let { direction: direction } = (0, $hjKwo$reactariai18n.useLocale)();
56
- let focusManager = (0, $hjKwo$reactariafocus.createFocusManager)(ref);
57
- let flipDirection = direction === "rtl" && orientation === "horizontal";
58
- let onKeyDown = (e)=>{
59
- if (!e.currentTarget.contains(e.target)) return;
60
- switch(e.key){
61
- case "ArrowRight":
62
- case "ArrowDown":
63
- e.preventDefault();
64
- e.stopPropagation();
65
- if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
66
- wrap: true
67
- });
68
- else focusManager.focusNext({
69
- wrap: true
70
- });
71
- break;
72
- case "ArrowLeft":
73
- case "ArrowUp":
74
- e.preventDefault();
75
- e.stopPropagation();
76
- if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
77
- wrap: true
78
- });
79
- else focusManager.focusPrevious({
80
- wrap: true
81
- });
82
- break;
83
- }
84
- };
85
- let role = $ceb684449a137553$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
86
- if (isInToolbar && role === "toolbar") role = "group";
87
- return {
88
- actionGroupProps: {
89
- ...(0, $hjKwo$reactariautils.filterDOMProps)(props, {
90
- labelable: true
91
- }),
92
- role: role,
93
- "aria-orientation": role === "toolbar" ? orientation : undefined,
94
- "aria-disabled": isDisabled,
95
- onKeyDown: onKeyDown
96
- }
97
- };
98
- }
99
-
100
-
101
- /*
102
- * Copyright 2020 Adobe. All rights reserved.
103
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
104
- * you may not use this file except in compliance with the License. You may obtain a copy
105
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
106
- *
107
- * Unless required by applicable law or agreed to in writing, software distributed under
108
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
109
- * OF ANY KIND, either express or implied. See the License for the specific language
110
- * governing permissions and limitations under the License.
111
- */
112
-
113
- const $44b92e5de834b44e$var$BUTTON_ROLES = {
114
- "none": undefined,
115
- "single": "radio",
116
- "multiple": "checkbox"
117
- };
118
- function $44b92e5de834b44e$export$9597202bd3099a29(props, state, ref) {
119
- let selectionMode = state.selectionManager.selectionMode;
120
- let buttonProps = {
121
- role: $44b92e5de834b44e$var$BUTTON_ROLES[selectionMode]
122
- };
123
- if (selectionMode !== "none") {
124
- let isSelected = state.selectionManager.isSelected(props.key);
125
- buttonProps["aria-checked"] = isSelected;
126
- }
127
- let isFocused = props.key === state.selectionManager.focusedKey;
128
- let onRemovedWithFocus = (0, $hjKwo$reactariautils.useEffectEvent)(()=>{
129
- if (isFocused) state.selectionManager.setFocusedKey(null);
130
- });
131
- // If the focused item is removed from the DOM, reset the focused key to null.
132
- (0, $hjKwo$react.useEffect)(()=>{
133
- return ()=>{
134
- onRemovedWithFocus();
135
- };
136
- }, [
137
- onRemovedWithFocus
138
- ]);
139
- return {
140
- buttonProps: (0, $hjKwo$reactariautils.mergeProps)(buttonProps, {
141
- tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
142
- onFocus () {
143
- state.selectionManager.setFocusedKey(props.key);
144
- },
145
- onPress () {
146
- state.selectionManager.select(props.key);
147
- }
148
- })
149
- };
150
- }
151
-
152
-
153
-
154
-
155
25
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"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@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';\nexport type {AriaActionGroupProps} from '@react-types/actiongroup';\nexport type {ActionGroupItemAria, AriaActionGroupItemProps} 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, Orientation} from '@react-types/shared';\nimport {filterDOMProps, useLayoutEffect} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject, useState} 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\n let [isInToolbar, setInToolbar] = useState(false);\n useLayoutEffect(() => {\n setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role=\"toolbar\"]')));\n }, [ref]);\n\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: string | undefined = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n if (isInToolbar && role === 'toolbar') {\n role = 'group';\n }\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : undefined,\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, Key} from '@react-types/shared';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps, useEffectEvent} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\nimport {RefObject, useEffect} from 'react';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': undefined,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: AriaActionGroupItemProps, 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 onRemovedWithFocus = useEffectEvent(() => {\n if (isFocused) {\n state.selectionManager.setFocusedKey(null);\n }\n });\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n useEffect(() => {\n return () => {\n onRemovedWithFocus();\n };\n }, [onRemovedWithFocus]);\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"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/actiongroup/src/index.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';\nexport type {AriaActionGroupProps} from '@react-types/actiongroup';\nexport type {ActionGroupItemAria, AriaActionGroupItemProps} from './useActionGroupItem';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,7 +1,5 @@
1
- import {createFocusManager as $1oG4F$createFocusManager} from "@react-aria/focus";
2
- import {useLayoutEffect as $1oG4F$useLayoutEffect, filterDOMProps as $1oG4F$filterDOMProps, useEffectEvent as $1oG4F$useEffectEvent, mergeProps as $1oG4F$mergeProps} from "@react-aria/utils";
3
- import {useState as $1oG4F$useState, useEffect as $1oG4F$useEffect} from "react";
4
- import {useLocale as $1oG4F$useLocale} from "@react-aria/i18n";
1
+ import {useActionGroup as $304ac34015d4535d$export$f4bf8d43c16de704} from "./useActionGroup.module.js";
2
+ import {useActionGroupItem as $f0ac0fb73c3ec062$export$9597202bd3099a29} from "./useActionGroupItem.module.js";
5
3
 
6
4
  /*
7
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -13,137 +11,9 @@ import {useLocale as $1oG4F$useLocale} from "@react-aria/i18n";
13
11
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
12
  * OF ANY KIND, either express or implied. See the License for the specific language
15
13
  * governing permissions and limitations under the License.
16
- */ /*
17
- * Copyright 2020 Adobe. All rights reserved.
18
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
- * you may not use this file except in compliance with the License. You may obtain a copy
20
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software distributed under
23
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
- * OF ANY KIND, either express or implied. See the License for the specific language
25
- * governing permissions and limitations under the License.
26
14
  */
27
15
 
28
16
 
29
17
 
30
- const $304ac34015d4535d$var$BUTTON_GROUP_ROLES = {
31
- "none": "toolbar",
32
- "single": "radiogroup",
33
- "multiple": "toolbar"
34
- };
35
- function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
36
- let { isDisabled: isDisabled, orientation: orientation = "horizontal" } = props;
37
- let [isInToolbar, setInToolbar] = (0, $1oG4F$useState)(false);
38
- (0, $1oG4F$useLayoutEffect)(()=>{
39
- var _ref_current_parentElement;
40
- setInToolbar(!!(ref.current && ((_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.closest('[role="toolbar"]'))));
41
- }, [
42
- ref
43
- ]);
44
- let allKeys = [
45
- ...state.collection.getKeys()
46
- ];
47
- if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
48
- let { direction: direction } = (0, $1oG4F$useLocale)();
49
- let focusManager = (0, $1oG4F$createFocusManager)(ref);
50
- let flipDirection = direction === "rtl" && orientation === "horizontal";
51
- let onKeyDown = (e)=>{
52
- if (!e.currentTarget.contains(e.target)) return;
53
- switch(e.key){
54
- case "ArrowRight":
55
- case "ArrowDown":
56
- e.preventDefault();
57
- e.stopPropagation();
58
- if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
59
- wrap: true
60
- });
61
- else focusManager.focusNext({
62
- wrap: true
63
- });
64
- break;
65
- case "ArrowLeft":
66
- case "ArrowUp":
67
- e.preventDefault();
68
- e.stopPropagation();
69
- if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
70
- wrap: true
71
- });
72
- else focusManager.focusPrevious({
73
- wrap: true
74
- });
75
- break;
76
- }
77
- };
78
- let role = $304ac34015d4535d$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
79
- if (isInToolbar && role === "toolbar") role = "group";
80
- return {
81
- actionGroupProps: {
82
- ...(0, $1oG4F$filterDOMProps)(props, {
83
- labelable: true
84
- }),
85
- role: role,
86
- "aria-orientation": role === "toolbar" ? orientation : undefined,
87
- "aria-disabled": isDisabled,
88
- onKeyDown: onKeyDown
89
- }
90
- };
91
- }
92
-
93
-
94
- /*
95
- * Copyright 2020 Adobe. All rights reserved.
96
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
97
- * you may not use this file except in compliance with the License. You may obtain a copy
98
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
99
- *
100
- * Unless required by applicable law or agreed to in writing, software distributed under
101
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
102
- * OF ANY KIND, either express or implied. See the License for the specific language
103
- * governing permissions and limitations under the License.
104
- */
105
-
106
- const $f0ac0fb73c3ec062$var$BUTTON_ROLES = {
107
- "none": undefined,
108
- "single": "radio",
109
- "multiple": "checkbox"
110
- };
111
- function $f0ac0fb73c3ec062$export$9597202bd3099a29(props, state, ref) {
112
- let selectionMode = state.selectionManager.selectionMode;
113
- let buttonProps = {
114
- role: $f0ac0fb73c3ec062$var$BUTTON_ROLES[selectionMode]
115
- };
116
- if (selectionMode !== "none") {
117
- let isSelected = state.selectionManager.isSelected(props.key);
118
- buttonProps["aria-checked"] = isSelected;
119
- }
120
- let isFocused = props.key === state.selectionManager.focusedKey;
121
- let onRemovedWithFocus = (0, $1oG4F$useEffectEvent)(()=>{
122
- if (isFocused) state.selectionManager.setFocusedKey(null);
123
- });
124
- // If the focused item is removed from the DOM, reset the focused key to null.
125
- (0, $1oG4F$useEffect)(()=>{
126
- return ()=>{
127
- onRemovedWithFocus();
128
- };
129
- }, [
130
- onRemovedWithFocus
131
- ]);
132
- return {
133
- buttonProps: (0, $1oG4F$mergeProps)(buttonProps, {
134
- tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
135
- onFocus () {
136
- state.selectionManager.setFocusedKey(props.key);
137
- },
138
- onPress () {
139
- state.selectionManager.select(props.key);
140
- }
141
- })
142
- };
143
- }
144
-
145
-
146
-
147
-
148
18
  export {$304ac34015d4535d$export$f4bf8d43c16de704 as useActionGroup, $f0ac0fb73c3ec062$export$9597202bd3099a29 as useActionGroupItem};
149
19
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;;AAUD,MAAM,2CAAqB;IACzB,QAAQ;IACR,UAAU;IACV,YAAY;AACd;AAMO,SAAS,0CAAkB,KAA8B,EAAE,KAAmB,EAAE,GAAgC;IACrH,IAAI,cACF,UAAU,eACV,cAAc,cACf,GAAG;IAEJ,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAC3C,CAAA,GAAA,sBAAc,EAAE;YACiB;QAA/B,aAAa,CAAC,CAAE,CAAA,IAAI,OAAO,MAAI,6BAAA,IAAI,OAAO,CAAC,aAAa,cAAzB,iDAAA,2BAA2B,OAAO,CAAC,oBAAkB;IACtF,GAAG;QAAC;KAAI;IAER,IAAI,UAAU;WAAI,MAAM,UAAU,CAAC,OAAO;KAAG;IAC7C,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAA,MAAO,CAAC,MAAM,YAAY,CAAC,GAAG,CAAC,OAC/C,aAAa;IAGf,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,eAAe,CAAA,GAAA,yBAAiB,EAAE;IACtC,IAAI,gBAAgB,cAAc,SAAS,gBAAgB;IAC3D,IAAI,YAAY,CAAC;QACf,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GACpC;QAGF,OAAQ,EAAE,GAAG;YACX,KAAK;YACL,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,IAAI,EAAE,GAAG,KAAK,gBAAgB,eAC5B,aAAa,aAAa,CAAC;oBAAC,MAAM;gBAAI;qBAEtC,aAAa,SAAS,CAAC;oBAAC,MAAM;gBAAI;gBAEpC;YACF,KAAK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ACE,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,GAAG;YAChD;YACA;gBACE,MAAM,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG;YACzC;QACF;IACF;AACF;","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';\nexport type {AriaActionGroupProps} from '@react-types/actiongroup';\nexport type {ActionGroupItemAria, AriaActionGroupItemProps} 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, Orientation} from '@react-types/shared';\nimport {filterDOMProps, useLayoutEffect} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject, useState} 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\n let [isInToolbar, setInToolbar] = useState(false);\n useLayoutEffect(() => {\n setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role=\"toolbar\"]')));\n }, [ref]);\n\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: string | undefined = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n if (isInToolbar && role === 'toolbar') {\n role = 'group';\n }\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : undefined,\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, Key} from '@react-types/shared';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps, useEffectEvent} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\nimport {RefObject, useEffect} from 'react';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': undefined,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: AriaActionGroupItemProps, 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 onRemovedWithFocus = useEffectEvent(() => {\n if (isFocused) {\n state.selectionManager.setFocusedKey(null);\n }\n });\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n useEffect(() => {\n return () => {\n onRemovedWithFocus();\n };\n }, [onRemovedWithFocus]);\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"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/actiongroup/src/index.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';\nexport type {AriaActionGroupProps} from '@react-types/actiongroup';\nexport type {ActionGroupItemAria, AriaActionGroupItemProps} from './useActionGroupItem';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,90 @@
1
+ var $aCPyD$reactariafocus = require("@react-aria/focus");
2
+ var $aCPyD$reactariautils = require("@react-aria/utils");
3
+ var $aCPyD$react = require("react");
4
+ var $aCPyD$reactariai18n = require("@react-aria/i18n");
5
+
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+
11
+ $parcel$export(module.exports, "useActionGroup", () => $ceb684449a137553$export$f4bf8d43c16de704);
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */
23
+
24
+
25
+
26
+ const $ceb684449a137553$var$BUTTON_GROUP_ROLES = {
27
+ "none": "toolbar",
28
+ "single": "radiogroup",
29
+ "multiple": "toolbar"
30
+ };
31
+ function $ceb684449a137553$export$f4bf8d43c16de704(props, state, ref) {
32
+ let { isDisabled: isDisabled, orientation: orientation = "horizontal" } = props;
33
+ let [isInToolbar, setInToolbar] = (0, $aCPyD$react.useState)(false);
34
+ (0, $aCPyD$reactariautils.useLayoutEffect)(()=>{
35
+ var _ref_current_parentElement;
36
+ setInToolbar(!!(ref.current && ((_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.closest('[role="toolbar"]'))));
37
+ }, [
38
+ ref
39
+ ]);
40
+ let allKeys = [
41
+ ...state.collection.getKeys()
42
+ ];
43
+ if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
44
+ let { direction: direction } = (0, $aCPyD$reactariai18n.useLocale)();
45
+ let focusManager = (0, $aCPyD$reactariafocus.createFocusManager)(ref);
46
+ let flipDirection = direction === "rtl" && orientation === "horizontal";
47
+ let onKeyDown = (e)=>{
48
+ if (!e.currentTarget.contains(e.target)) return;
49
+ switch(e.key){
50
+ case "ArrowRight":
51
+ case "ArrowDown":
52
+ e.preventDefault();
53
+ e.stopPropagation();
54
+ if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
55
+ wrap: true
56
+ });
57
+ else focusManager.focusNext({
58
+ wrap: true
59
+ });
60
+ break;
61
+ case "ArrowLeft":
62
+ case "ArrowUp":
63
+ e.preventDefault();
64
+ e.stopPropagation();
65
+ if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
66
+ wrap: true
67
+ });
68
+ else focusManager.focusPrevious({
69
+ wrap: true
70
+ });
71
+ break;
72
+ }
73
+ };
74
+ let role = $ceb684449a137553$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
75
+ if (isInToolbar && role === "toolbar") role = "group";
76
+ return {
77
+ actionGroupProps: {
78
+ ...(0, $aCPyD$reactariautils.filterDOMProps)(props, {
79
+ labelable: true
80
+ }),
81
+ role: role,
82
+ "aria-orientation": role === "toolbar" ? orientation : undefined,
83
+ "aria-disabled": isDisabled,
84
+ onKeyDown: onKeyDown
85
+ }
86
+ };
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Ae,eAC3B,aAAa,SAAS,CAAC;oBAAC,MAAM;gBAAI;qBAElC,aAAa,aAAa,CAAC;oBAAC,MAAM;gBAAI;gBAExC;QACJ;IACF;IAEA,IAAI,OAA2B,wCAAkB,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvF,IAAI,eAAe,SAAS,WAC1B,OAAO;IAET,OAAO;QACL,kBAAkB;YAChB,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,oBAAoB,SAAS,YAAY,cAAc;YACvD,iBAAiB;uBACjB;QACF;IACF;AACF","sources":["packages/@react-aria/actiongroup/src/useActionGroup.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 */\n\nimport {AriaActionGroupProps} from '@react-types/actiongroup';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DOMAttributes, FocusableElement, Orientation} from '@react-types/shared';\nimport {filterDOMProps, useLayoutEffect} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject, useState} 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\n let [isInToolbar, setInToolbar] = useState(false);\n useLayoutEffect(() => {\n setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role=\"toolbar\"]')));\n }, [ref]);\n\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: string | undefined = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n if (isInToolbar && role === 'toolbar') {\n role = 'group';\n }\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : undefined,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n"],"names":[],"version":3,"file":"useActionGroup.main.js.map"}
@@ -0,0 +1,85 @@
1
+ import {createFocusManager as $6SCDv$createFocusManager} from "@react-aria/focus";
2
+ import {useLayoutEffect as $6SCDv$useLayoutEffect, filterDOMProps as $6SCDv$filterDOMProps} from "@react-aria/utils";
3
+ import {useState as $6SCDv$useState} from "react";
4
+ import {useLocale as $6SCDv$useLocale} from "@react-aria/i18n";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ const $304ac34015d4535d$var$BUTTON_GROUP_ROLES = {
21
+ "none": "toolbar",
22
+ "single": "radiogroup",
23
+ "multiple": "toolbar"
24
+ };
25
+ function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
26
+ let { isDisabled: isDisabled, orientation: orientation = "horizontal" } = props;
27
+ let [isInToolbar, setInToolbar] = (0, $6SCDv$useState)(false);
28
+ (0, $6SCDv$useLayoutEffect)(()=>{
29
+ var _ref_current_parentElement;
30
+ setInToolbar(!!(ref.current && ((_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.closest('[role="toolbar"]'))));
31
+ }, [
32
+ ref
33
+ ]);
34
+ let allKeys = [
35
+ ...state.collection.getKeys()
36
+ ];
37
+ if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
38
+ let { direction: direction } = (0, $6SCDv$useLocale)();
39
+ let focusManager = (0, $6SCDv$createFocusManager)(ref);
40
+ let flipDirection = direction === "rtl" && orientation === "horizontal";
41
+ let onKeyDown = (e)=>{
42
+ if (!e.currentTarget.contains(e.target)) return;
43
+ switch(e.key){
44
+ case "ArrowRight":
45
+ case "ArrowDown":
46
+ e.preventDefault();
47
+ e.stopPropagation();
48
+ if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
49
+ wrap: true
50
+ });
51
+ else focusManager.focusNext({
52
+ wrap: true
53
+ });
54
+ break;
55
+ case "ArrowLeft":
56
+ case "ArrowUp":
57
+ e.preventDefault();
58
+ e.stopPropagation();
59
+ if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
60
+ wrap: true
61
+ });
62
+ else focusManager.focusPrevious({
63
+ wrap: true
64
+ });
65
+ break;
66
+ }
67
+ };
68
+ let role = $304ac34015d4535d$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
69
+ if (isInToolbar && role === "toolbar") role = "group";
70
+ return {
71
+ actionGroupProps: {
72
+ ...(0, $6SCDv$filterDOMProps)(props, {
73
+ labelable: true
74
+ }),
75
+ role: role,
76
+ "aria-orientation": role === "toolbar" ? orientation : undefined,
77
+ "aria-disabled": isDisabled,
78
+ onKeyDown: onKeyDown
79
+ }
80
+ };
81
+ }
82
+
83
+
84
+ export {$304ac34015d4535d$export$f4bf8d43c16de704 as useActionGroup};
85
+ //# sourceMappingURL=useActionGroup.mjs.map
@@ -0,0 +1,85 @@
1
+ import {createFocusManager as $6SCDv$createFocusManager} from "@react-aria/focus";
2
+ import {useLayoutEffect as $6SCDv$useLayoutEffect, filterDOMProps as $6SCDv$filterDOMProps} from "@react-aria/utils";
3
+ import {useState as $6SCDv$useState} from "react";
4
+ import {useLocale as $6SCDv$useLocale} from "@react-aria/i18n";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ const $304ac34015d4535d$var$BUTTON_GROUP_ROLES = {
21
+ "none": "toolbar",
22
+ "single": "radiogroup",
23
+ "multiple": "toolbar"
24
+ };
25
+ function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
26
+ let { isDisabled: isDisabled, orientation: orientation = "horizontal" } = props;
27
+ let [isInToolbar, setInToolbar] = (0, $6SCDv$useState)(false);
28
+ (0, $6SCDv$useLayoutEffect)(()=>{
29
+ var _ref_current_parentElement;
30
+ setInToolbar(!!(ref.current && ((_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.closest('[role="toolbar"]'))));
31
+ }, [
32
+ ref
33
+ ]);
34
+ let allKeys = [
35
+ ...state.collection.getKeys()
36
+ ];
37
+ if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
38
+ let { direction: direction } = (0, $6SCDv$useLocale)();
39
+ let focusManager = (0, $6SCDv$createFocusManager)(ref);
40
+ let flipDirection = direction === "rtl" && orientation === "horizontal";
41
+ let onKeyDown = (e)=>{
42
+ if (!e.currentTarget.contains(e.target)) return;
43
+ switch(e.key){
44
+ case "ArrowRight":
45
+ case "ArrowDown":
46
+ e.preventDefault();
47
+ e.stopPropagation();
48
+ if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
49
+ wrap: true
50
+ });
51
+ else focusManager.focusNext({
52
+ wrap: true
53
+ });
54
+ break;
55
+ case "ArrowLeft":
56
+ case "ArrowUp":
57
+ e.preventDefault();
58
+ e.stopPropagation();
59
+ if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
60
+ wrap: true
61
+ });
62
+ else focusManager.focusPrevious({
63
+ wrap: true
64
+ });
65
+ break;
66
+ }
67
+ };
68
+ let role = $304ac34015d4535d$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
69
+ if (isInToolbar && role === "toolbar") role = "group";
70
+ return {
71
+ actionGroupProps: {
72
+ ...(0, $6SCDv$filterDOMProps)(props, {
73
+ labelable: true
74
+ }),
75
+ role: role,
76
+ "aria-orientation": role === "toolbar" ? orientation : undefined,
77
+ "aria-disabled": isDisabled,
78
+ onKeyDown: onKeyDown
79
+ }
80
+ };
81
+ }
82
+
83
+
84
+ export {$304ac34015d4535d$export$f4bf8d43c16de704 as useActionGroup};
85
+ //# sourceMappingURL=useActionGroup.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA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ExC;QACJ;IACF;IAEA,IAAI,OAA2B,wCAAkB,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvF,IAAI,eAAe,SAAS,WAC1B,OAAO;IAET,OAAO;QACL,kBAAkB;YAChB,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,oBAAoB,SAAS,YAAY,cAAc;YACvD,iBAAiB;uBACjB;QACF;IACF;AACF","sources":["packages/@react-aria/actiongroup/src/useActionGroup.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 */\n\nimport {AriaActionGroupProps} from '@react-types/actiongroup';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DOMAttributes, FocusableElement, Orientation} from '@react-types/shared';\nimport {filterDOMProps, useLayoutEffect} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject, useState} 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\n let [isInToolbar, setInToolbar] = useState(false);\n useLayoutEffect(() => {\n setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role=\"toolbar\"]')));\n }, [ref]);\n\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: string | undefined = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n if (isInToolbar && role === 'toolbar') {\n role = 'group';\n }\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : undefined,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n"],"names":[],"version":3,"file":"useActionGroup.module.js.map"}
@@ -0,0 +1,62 @@
1
+ var $7WRxK$reactariautils = require("@react-aria/utils");
2
+ var $7WRxK$react = require("react");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "useActionGroupItem", () => $44b92e5de834b44e$export$9597202bd3099a29);
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */
21
+
22
+ const $44b92e5de834b44e$var$BUTTON_ROLES = {
23
+ "none": undefined,
24
+ "single": "radio",
25
+ "multiple": "checkbox"
26
+ };
27
+ function $44b92e5de834b44e$export$9597202bd3099a29(props, state, ref) {
28
+ let selectionMode = state.selectionManager.selectionMode;
29
+ let buttonProps = {
30
+ role: $44b92e5de834b44e$var$BUTTON_ROLES[selectionMode]
31
+ };
32
+ if (selectionMode !== "none") {
33
+ let isSelected = state.selectionManager.isSelected(props.key);
34
+ buttonProps["aria-checked"] = isSelected;
35
+ }
36
+ let isFocused = props.key === state.selectionManager.focusedKey;
37
+ let onRemovedWithFocus = (0, $7WRxK$reactariautils.useEffectEvent)(()=>{
38
+ if (isFocused) state.selectionManager.setFocusedKey(null);
39
+ });
40
+ // If the focused item is removed from the DOM, reset the focused key to null.
41
+ (0, $7WRxK$react.useEffect)(()=>{
42
+ return ()=>{
43
+ onRemovedWithFocus();
44
+ };
45
+ }, [
46
+ onRemovedWithFocus
47
+ ]);
48
+ return {
49
+ buttonProps: (0, $7WRxK$reactariautils.mergeProps)(buttonProps, {
50
+ tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
51
+ onFocus () {
52
+ state.selectionManager.setFocusedKey(props.key);
53
+ },
54
+ onPress () {
55
+ state.selectionManager.select(props.key);
56
+ }
57
+ })
58
+ };
59
+ }
60
+
61
+
62
+ //# sourceMappingURL=useActionGroupItem.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAgBD,MAAM,qCAAe;IACnB,QAAQ;IACR,UAAU;IACV,YAAY;AACd;AAGO,SAAS,0CAAsB,KAA+B,EAAE,KAAmB,EAAE,GAAiC;IAC3H,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;IACxD,IAAI,cAAc;QAChB,MAAM,kCAAY,CAAC,cAAc;IACnC;IAEA,IAAI,kBAAkB,QAAQ;QAC5B,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,MAAM,GAAG;QAC5D,WAAW,CAAC,eAAe,GAAG;IAChC;IAEA,IAAI,YAAY,MAAM,GAAG,KAAK,MAAM,gBAAgB,CAAC,UAAU;IAC/D,IAAI,qBAAqB,CAAA,GAAA,oCAAa,EAAE;QACtC,IAAI,WACF,MAAM,gBAAgB,CAAC,aAAa,CAAC;IAEzC;IAEA,8EAA8E;IAC9E,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL;QACF;IACF,GAAG;QAAC;KAAmB;IAEvB,OAAO;QACL,aAAa,CAAA,GAAA,gCAAS,EAAE,aAAa;YACnC,UAAU,aAAa,MAAM,gBAAgB,CAAC,UAAU,IAAI,OAAO,IAAI;YACvE;gBACE,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,GAAG;YAChD;YACA;gBACE,MAAM,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG;YACzC;QACF;IACF;AACF","sources":["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 */\n\nimport {DOMAttributes, FocusableElement, Key} from '@react-types/shared';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps, useEffectEvent} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\nimport {RefObject, useEffect} from 'react';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': undefined,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: AriaActionGroupItemProps, 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 onRemovedWithFocus = useEffectEvent(() => {\n if (isFocused) {\n state.selectionManager.setFocusedKey(null);\n }\n });\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n useEffect(() => {\n return () => {\n onRemovedWithFocus();\n };\n }, [onRemovedWithFocus]);\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":"useActionGroupItem.main.js.map"}
@@ -0,0 +1,57 @@
1
+ import {useEffectEvent as $jllmK$useEffectEvent, mergeProps as $jllmK$mergeProps} from "@react-aria/utils";
2
+ import {useEffect as $jllmK$useEffect} from "react";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ const $f0ac0fb73c3ec062$var$BUTTON_ROLES = {
17
+ "none": undefined,
18
+ "single": "radio",
19
+ "multiple": "checkbox"
20
+ };
21
+ function $f0ac0fb73c3ec062$export$9597202bd3099a29(props, state, ref) {
22
+ let selectionMode = state.selectionManager.selectionMode;
23
+ let buttonProps = {
24
+ role: $f0ac0fb73c3ec062$var$BUTTON_ROLES[selectionMode]
25
+ };
26
+ if (selectionMode !== "none") {
27
+ let isSelected = state.selectionManager.isSelected(props.key);
28
+ buttonProps["aria-checked"] = isSelected;
29
+ }
30
+ let isFocused = props.key === state.selectionManager.focusedKey;
31
+ let onRemovedWithFocus = (0, $jllmK$useEffectEvent)(()=>{
32
+ if (isFocused) state.selectionManager.setFocusedKey(null);
33
+ });
34
+ // If the focused item is removed from the DOM, reset the focused key to null.
35
+ (0, $jllmK$useEffect)(()=>{
36
+ return ()=>{
37
+ onRemovedWithFocus();
38
+ };
39
+ }, [
40
+ onRemovedWithFocus
41
+ ]);
42
+ return {
43
+ buttonProps: (0, $jllmK$mergeProps)(buttonProps, {
44
+ tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
45
+ onFocus () {
46
+ state.selectionManager.setFocusedKey(props.key);
47
+ },
48
+ onPress () {
49
+ state.selectionManager.select(props.key);
50
+ }
51
+ })
52
+ };
53
+ }
54
+
55
+
56
+ export {$f0ac0fb73c3ec062$export$9597202bd3099a29 as useActionGroupItem};
57
+ //# sourceMappingURL=useActionGroupItem.mjs.map
@@ -0,0 +1,57 @@
1
+ import {useEffectEvent as $jllmK$useEffectEvent, mergeProps as $jllmK$mergeProps} from "@react-aria/utils";
2
+ import {useEffect as $jllmK$useEffect} from "react";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ const $f0ac0fb73c3ec062$var$BUTTON_ROLES = {
17
+ "none": undefined,
18
+ "single": "radio",
19
+ "multiple": "checkbox"
20
+ };
21
+ function $f0ac0fb73c3ec062$export$9597202bd3099a29(props, state, ref) {
22
+ let selectionMode = state.selectionManager.selectionMode;
23
+ let buttonProps = {
24
+ role: $f0ac0fb73c3ec062$var$BUTTON_ROLES[selectionMode]
25
+ };
26
+ if (selectionMode !== "none") {
27
+ let isSelected = state.selectionManager.isSelected(props.key);
28
+ buttonProps["aria-checked"] = isSelected;
29
+ }
30
+ let isFocused = props.key === state.selectionManager.focusedKey;
31
+ let onRemovedWithFocus = (0, $jllmK$useEffectEvent)(()=>{
32
+ if (isFocused) state.selectionManager.setFocusedKey(null);
33
+ });
34
+ // If the focused item is removed from the DOM, reset the focused key to null.
35
+ (0, $jllmK$useEffect)(()=>{
36
+ return ()=>{
37
+ onRemovedWithFocus();
38
+ };
39
+ }, [
40
+ onRemovedWithFocus
41
+ ]);
42
+ return {
43
+ buttonProps: (0, $jllmK$mergeProps)(buttonProps, {
44
+ tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
45
+ onFocus () {
46
+ state.selectionManager.setFocusedKey(props.key);
47
+ },
48
+ onPress () {
49
+ state.selectionManager.select(props.key);
50
+ }
51
+ })
52
+ };
53
+ }
54
+
55
+
56
+ export {$f0ac0fb73c3ec062$export$9597202bd3099a29 as useActionGroupItem};
57
+ //# sourceMappingURL=useActionGroupItem.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAgBD,MAAM,qCAAe;IACnB,QAAQ;IACR,UAAU;IACV,YAAY;AACd;AAGO,SAAS,0CAAsB,KAA+B,EAAE,KAAmB,EAAE,GAAiC;IAC3H,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;IACxD,IAAI,cAAc;QAChB,MAAM,kCAAY,CAAC,cAAc;IACnC;IAEA,IAAI,kBAAkB,QAAQ;QAC5B,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,MAAM,GAAG;QAC5D,WAAW,CAAC,eAAe,GAAG;IAChC;IAEA,IAAI,YAAY,MAAM,GAAG,KAAK,MAAM,gBAAgB,CAAC,UAAU;IAC/D,IAAI,qBAAqB,CAAA,GAAA,qBAAa,EAAE;QACtC,IAAI,WACF,MAAM,gBAAgB,CAAC,aAAa,CAAC;IAEzC;IAEA,8EAA8E;IAC9E,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL;QACF;IACF,GAAG;QAAC;KAAmB;IAEvB,OAAO;QACL,aAAa,CAAA,GAAA,iBAAS,EAAE,aAAa;YACnC,UAAU,aAAa,MAAM,gBAAgB,CAAC,UAAU,IAAI,OAAO,IAAI;YACvE;gBACE,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,GAAG;YAChD;YACA;gBACE,MAAM,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG;YACzC;QACF;IACF;AACF","sources":["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 */\n\nimport {DOMAttributes, FocusableElement, Key} from '@react-types/shared';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps, useEffectEvent} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\nimport {RefObject, useEffect} from 'react';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': undefined,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: AriaActionGroupItemProps, 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 onRemovedWithFocus = useEffectEvent(() => {\n if (isFocused) {\n state.selectionManager.setFocusedKey(null);\n }\n });\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n useEffect(() => {\n return () => {\n onRemovedWithFocus();\n };\n }, [onRemovedWithFocus]);\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":"useActionGroupItem.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/actiongroup",
3
- "version": "3.7.4-nightly.4552+64ed13090",
3
+ "version": "3.7.4-nightly.4558+c5e4b3701",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,13 +22,13 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "3.0.0-nightly.2840+64ed13090",
26
- "@react-aria/i18n": "3.0.0-nightly.2840+64ed13090",
27
- "@react-aria/interactions": "3.0.0-nightly.2840+64ed13090",
28
- "@react-aria/utils": "3.0.0-nightly.2840+64ed13090",
29
- "@react-stately/list": "3.10.4-nightly.4552+64ed13090",
30
- "@react-types/actiongroup": "3.4.8-nightly.4552+64ed13090",
31
- "@react-types/shared": "3.0.0-nightly.2840+64ed13090",
25
+ "@react-aria/focus": "3.0.0-nightly.2846+c5e4b3701",
26
+ "@react-aria/i18n": "3.0.0-nightly.2846+c5e4b3701",
27
+ "@react-aria/interactions": "3.0.0-nightly.2846+c5e4b3701",
28
+ "@react-aria/utils": "3.0.0-nightly.2846+c5e4b3701",
29
+ "@react-stately/list": "3.10.4-nightly.4558+c5e4b3701",
30
+ "@react-types/actiongroup": "3.4.8-nightly.4558+c5e4b3701",
31
+ "@react-types/shared": "3.0.0-nightly.2846+c5e4b3701",
32
32
  "@swc/helpers": "^0.5.0"
33
33
  },
34
34
  "peerDependencies": {
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "64ed13090ce77cc0e4cb4cd5602e75f655bff6bb"
41
+ "gitHead": "c5e4b3701fdb89eb551f1b3697ac253f06ef68fa"
42
42
  }