@react-aria/actiongroup 3.4.5-nightly.3698 → 3.4.5-nightly.3705

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.
Files changed (2) hide show
  1. package/dist/import.mjs +144 -0
  2. package/package.json +16 -11
@@ -0,0 +1,144 @@
1
+ import {createFocusManager as $1oG4F$createFocusManager} from "@react-aria/focus";
2
+ import {filterDOMProps as $1oG4F$filterDOMProps, mergeProps as $1oG4F$mergeProps} from "@react-aria/utils";
3
+ import {useLocale as $1oG4F$useLocale} from "@react-aria/i18n";
4
+ import {useRef as $1oG4F$useRef, useEffect as $1oG4F$useEffect} from "react";
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
+ * 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
+ */
27
+
28
+
29
+ const $304ac34015d4535d$var$BUTTON_GROUP_ROLES = {
30
+ "none": "toolbar",
31
+ "single": "radiogroup",
32
+ "multiple": "toolbar"
33
+ };
34
+ function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
35
+ let { isDisabled: isDisabled , orientation: orientation = "horizontal" } = props;
36
+ let allKeys = [
37
+ ...state.collection.getKeys()
38
+ ];
39
+ if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
40
+ let { direction: direction } = (0, $1oG4F$useLocale)();
41
+ let focusManager = (0, $1oG4F$createFocusManager)(ref);
42
+ let flipDirection = direction === "rtl" && orientation === "horizontal";
43
+ let onKeyDown = (e)=>{
44
+ if (!e.currentTarget.contains(e.target)) return;
45
+ switch(e.key){
46
+ case "ArrowRight":
47
+ case "ArrowDown":
48
+ e.preventDefault();
49
+ e.stopPropagation();
50
+ if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
51
+ wrap: true
52
+ });
53
+ else focusManager.focusNext({
54
+ wrap: true
55
+ });
56
+ break;
57
+ case "ArrowLeft":
58
+ case "ArrowUp":
59
+ e.preventDefault();
60
+ e.stopPropagation();
61
+ if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
62
+ wrap: true
63
+ });
64
+ else focusManager.focusPrevious({
65
+ wrap: true
66
+ });
67
+ break;
68
+ }
69
+ };
70
+ let role = $304ac34015d4535d$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
71
+ return {
72
+ actionGroupProps: {
73
+ ...(0, $1oG4F$filterDOMProps)(props, {
74
+ labelable: true
75
+ }),
76
+ role: role,
77
+ "aria-orientation": role === "toolbar" ? orientation : undefined,
78
+ "aria-disabled": isDisabled,
79
+ onKeyDown: onKeyDown
80
+ }
81
+ };
82
+ }
83
+
84
+
85
+ /*
86
+ * Copyright 2020 Adobe. All rights reserved.
87
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
88
+ * you may not use this file except in compliance with the License. You may obtain a copy
89
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
90
+ *
91
+ * Unless required by applicable law or agreed to in writing, software distributed under
92
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
93
+ * OF ANY KIND, either express or implied. See the License for the specific language
94
+ * governing permissions and limitations under the License.
95
+ */
96
+
97
+ const $f0ac0fb73c3ec062$var$BUTTON_ROLES = {
98
+ "none": undefined,
99
+ "single": "radio",
100
+ "multiple": "checkbox"
101
+ };
102
+ function $f0ac0fb73c3ec062$export$9597202bd3099a29(props, state, ref) {
103
+ let selectionMode = state.selectionManager.selectionMode;
104
+ let buttonProps = {
105
+ role: $f0ac0fb73c3ec062$var$BUTTON_ROLES[selectionMode]
106
+ };
107
+ if (selectionMode !== "none") {
108
+ let isSelected = state.selectionManager.isSelected(props.key);
109
+ buttonProps["aria-checked"] = isSelected;
110
+ }
111
+ let isFocused = props.key === state.selectionManager.focusedKey;
112
+ let lastRender = (0, $1oG4F$useRef)({
113
+ isFocused: isFocused,
114
+ state: state
115
+ });
116
+ lastRender.current = {
117
+ isFocused: isFocused,
118
+ state: state
119
+ };
120
+ // If the focused item is removed from the DOM, reset the focused key to null.
121
+ // eslint-disable-next-line arrow-body-style
122
+ (0, $1oG4F$useEffect)(()=>{
123
+ return ()=>{
124
+ if (lastRender.current.isFocused) lastRender.current.state.selectionManager.setFocusedKey(null);
125
+ };
126
+ }, []);
127
+ return {
128
+ buttonProps: (0, $1oG4F$mergeProps)(buttonProps, {
129
+ tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
130
+ onFocus () {
131
+ state.selectionManager.setFocusedKey(props.key);
132
+ },
133
+ onPress () {
134
+ state.selectionManager.select(props.key);
135
+ }
136
+ })
137
+ };
138
+ }
139
+
140
+
141
+
142
+
143
+ export {$304ac34015d4535d$export$f4bf8d43c16de704 as useActionGroup, $f0ac0fb73c3ec062$export$9597202bd3099a29 as useActionGroupItem};
144
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/actiongroup",
3
- "version": "3.4.5-nightly.3698+72ee92f6d",
3
+ "version": "3.4.5-nightly.3705+93b3c951e",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,15 +22,15 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-aria/focus": "3.0.0-nightly.1998+72ee92f6d",
21
- "@react-aria/i18n": "3.0.0-nightly.1998+72ee92f6d",
22
- "@react-aria/interactions": "3.0.0-nightly.1998+72ee92f6d",
23
- "@react-aria/selection": "3.0.0-nightly.1998+72ee92f6d",
24
- "@react-aria/utils": "3.0.0-nightly.1998+72ee92f6d",
25
- "@react-stately/collections": "3.0.0-nightly.1998+72ee92f6d",
26
- "@react-stately/list": "3.6.2-nightly.3698+72ee92f6d",
27
- "@react-types/actiongroup": "3.3.6-nightly.3698+72ee92f6d",
28
- "@react-types/shared": "3.0.0-nightly.1998+72ee92f6d",
25
+ "@react-aria/focus": "3.0.0-nightly.2005+93b3c951e",
26
+ "@react-aria/i18n": "3.0.0-nightly.2005+93b3c951e",
27
+ "@react-aria/interactions": "3.0.0-nightly.2005+93b3c951e",
28
+ "@react-aria/selection": "3.0.0-nightly.2005+93b3c951e",
29
+ "@react-aria/utils": "3.0.0-nightly.2005+93b3c951e",
30
+ "@react-stately/collections": "3.0.0-nightly.2005+93b3c951e",
31
+ "@react-stately/list": "3.6.2-nightly.3705+93b3c951e",
32
+ "@react-types/actiongroup": "3.3.6-nightly.3705+93b3c951e",
33
+ "@react-types/shared": "3.0.0-nightly.2005+93b3c951e",
29
34
  "@swc/helpers": "^0.4.14"
30
35
  },
31
36
  "peerDependencies": {
@@ -34,5 +39,5 @@
34
39
  "publishConfig": {
35
40
  "access": "public"
36
41
  },
37
- "gitHead": "72ee92f6d497163468a80642ccb96576f822f365"
42
+ "gitHead": "93b3c951eb784b14183f9988f2d188b34de8f42d"
38
43
  }