@react-aria/actiongroup 3.2.2-nightly.3037 → 3.2.2-nightly.3059
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 +123 -138
- package/dist/main.js.map +1 -1
- package/dist/module.js +107 -115
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/main.js
CHANGED
|
@@ -1,156 +1,141 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var $7plFg$reactariafocus = require("@react-aria/focus");
|
|
2
|
+
var $7plFg$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $7plFg$reactariai18n = require("@react-aria/i18n");
|
|
4
|
+
var $7plFg$react = require("react");
|
|
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
|
+
}
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
Object.defineProperty(dest, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return source[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
9
19
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
return dest;
|
|
21
|
+
}
|
|
22
|
+
function $parcel$export(e, n, v, s) {
|
|
23
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
24
|
+
}
|
|
25
|
+
var $f04a3cd2f8d93328$exports = {};
|
|
14
26
|
|
|
15
|
-
|
|
16
|
-
createFocusManager
|
|
17
|
-
} = require("@react-aria/focus");
|
|
27
|
+
$parcel$export($f04a3cd2f8d93328$exports, "useActionGroup", () => $f04a3cd2f8d93328$export$f4bf8d43c16de704);
|
|
18
28
|
|
|
19
|
-
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
20
29
|
|
|
21
|
-
function $parcel$interopDefault(a) {
|
|
22
|
-
return a && a.__esModule ? a.default : a;
|
|
23
|
-
}
|
|
24
30
|
|
|
25
|
-
const $
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
const $f04a3cd2f8d93328$var$BUTTON_GROUP_ROLES = {
|
|
32
|
+
'none': 'toolbar',
|
|
33
|
+
'single': 'radiogroup',
|
|
34
|
+
'multiple': 'toolbar'
|
|
29
35
|
};
|
|
36
|
+
function $f04a3cd2f8d93328$export$f4bf8d43c16de704(props, state, ref) {
|
|
37
|
+
let { isDisabled: isDisabled , orientation: orientation = 'horizontal' } = props;
|
|
38
|
+
let allKeys = [
|
|
39
|
+
...state.collection.getKeys()
|
|
40
|
+
];
|
|
41
|
+
if (!allKeys.some((key)=>!state.disabledKeys.has(key)
|
|
42
|
+
)) isDisabled = true;
|
|
43
|
+
let { direction: direction } = $7plFg$reactariai18n.useLocale();
|
|
44
|
+
let focusManager = $7plFg$reactariafocus.createFocusManager(ref);
|
|
45
|
+
let flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
46
|
+
let onKeyDown = (e)=>{
|
|
47
|
+
if (!e.currentTarget.contains(e.target)) return;
|
|
48
|
+
switch(e.key){
|
|
49
|
+
case 'ArrowRight':
|
|
50
|
+
case 'ArrowDown':
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
if (e.key === 'ArrowRight' && flipDirection) focusManager.focusPrevious({
|
|
54
|
+
wrap: true
|
|
55
|
+
});
|
|
56
|
+
else focusManager.focusNext({
|
|
57
|
+
wrap: true
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case 'ArrowLeft':
|
|
61
|
+
case 'ArrowUp':
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
if (e.key === 'ArrowLeft' && flipDirection) focusManager.focusNext({
|
|
65
|
+
wrap: true
|
|
66
|
+
});
|
|
67
|
+
else focusManager.focusPrevious({
|
|
68
|
+
wrap: true
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
let role = $f04a3cd2f8d93328$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
|
|
74
|
+
return {
|
|
75
|
+
actionGroupProps: {
|
|
76
|
+
...$7plFg$reactariautils.filterDOMProps(props, {
|
|
77
|
+
labelable: true
|
|
78
|
+
}),
|
|
79
|
+
role: role,
|
|
80
|
+
'aria-orientation': role === 'toolbar' ? orientation : null,
|
|
81
|
+
'aria-disabled': isDisabled,
|
|
82
|
+
onKeyDown: onKeyDown
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
30
86
|
|
|
31
|
-
function useActionGroup(props, state, ref) {
|
|
32
|
-
let {
|
|
33
|
-
isDisabled,
|
|
34
|
-
orientation = 'horizontal'
|
|
35
|
-
} = props;
|
|
36
|
-
let allKeys = [...state.collection.getKeys()];
|
|
37
|
-
|
|
38
|
-
if (!allKeys.some(key => !state.disabledKeys.has(key))) {
|
|
39
|
-
isDisabled = true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let {
|
|
43
|
-
direction
|
|
44
|
-
} = useLocale();
|
|
45
|
-
let focusManager = createFocusManager(ref);
|
|
46
|
-
let flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
47
|
-
|
|
48
|
-
let onKeyDown = e => {
|
|
49
|
-
if (!e.currentTarget.contains(e.target)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
87
|
|
|
53
|
-
|
|
54
|
-
case 'ArrowRight':
|
|
55
|
-
case 'ArrowDown':
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
e.stopPropagation();
|
|
58
|
-
|
|
59
|
-
if (e.key === 'ArrowRight' && flipDirection) {
|
|
60
|
-
focusManager.focusPrevious({
|
|
61
|
-
wrap: true
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
focusManager.focusNext({
|
|
65
|
-
wrap: true
|
|
66
|
-
});
|
|
67
|
-
}
|
|
88
|
+
var $549a2ca943703af8$exports = {};
|
|
68
89
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
case 'ArrowLeft':
|
|
72
|
-
case 'ArrowUp':
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
e.stopPropagation();
|
|
75
|
-
|
|
76
|
-
if (e.key === 'ArrowLeft' && flipDirection) {
|
|
77
|
-
focusManager.focusNext({
|
|
78
|
-
wrap: true
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
focusManager.focusPrevious({
|
|
82
|
-
wrap: true
|
|
83
|
-
});
|
|
84
|
-
}
|
|
90
|
+
$parcel$export($549a2ca943703af8$exports, "useActionGroupItem", () => $549a2ca943703af8$export$9597202bd3099a29);
|
|
85
91
|
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
let role = $fe726d25076e66037c1148278675$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
|
|
91
|
-
return {
|
|
92
|
-
actionGroupProps: _babelRuntimeHelpersExtends({}, filterDOMProps(props, {
|
|
93
|
-
labelable: true
|
|
94
|
-
}), {
|
|
95
|
-
role,
|
|
96
|
-
'aria-orientation': role === 'toolbar' ? orientation : null,
|
|
97
|
-
'aria-disabled': isDisabled,
|
|
98
|
-
onKeyDown
|
|
99
|
-
})
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
92
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
let buttonProps = {
|
|
113
|
-
role: $f62a7779a4b926c91f5485d05f434a$var$BUTTON_ROLES[selectionMode]
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
if (selectionMode !== 'none') {
|
|
117
|
-
let isSelected = state.selectionManager.isSelected(props.key);
|
|
118
|
-
buttonProps['aria-checked'] = isSelected;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
let isFocused = props.key === state.selectionManager.focusedKey;
|
|
122
|
-
let lastRender = useRef({
|
|
123
|
-
isFocused,
|
|
124
|
-
state
|
|
125
|
-
});
|
|
126
|
-
lastRender.current = {
|
|
127
|
-
isFocused,
|
|
128
|
-
state
|
|
129
|
-
}; // If the focused item is removed from the DOM, reset the focused key to null.
|
|
130
|
-
// eslint-disable-next-line arrow-body-style
|
|
131
|
-
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
return () => {
|
|
134
|
-
if (lastRender.current.isFocused) {
|
|
135
|
-
lastRender.current.state.selectionManager.setFocusedKey(null);
|
|
136
|
-
}
|
|
93
|
+
const $549a2ca943703af8$var$BUTTON_ROLES = {
|
|
94
|
+
'none': null,
|
|
95
|
+
'single': 'radio',
|
|
96
|
+
'multiple': 'checkbox'
|
|
97
|
+
};
|
|
98
|
+
function $549a2ca943703af8$export$9597202bd3099a29(props, state, ref) {
|
|
99
|
+
let selectionMode = state.selectionManager.selectionMode;
|
|
100
|
+
let buttonProps = {
|
|
101
|
+
role: $549a2ca943703af8$var$BUTTON_ROLES[selectionMode]
|
|
137
102
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
103
|
+
if (selectionMode !== 'none') {
|
|
104
|
+
let isSelected = state.selectionManager.isSelected(props.key);
|
|
105
|
+
buttonProps['aria-checked'] = isSelected;
|
|
106
|
+
}
|
|
107
|
+
let isFocused = props.key === state.selectionManager.focusedKey;
|
|
108
|
+
let lastRender = $7plFg$react.useRef({
|
|
109
|
+
isFocused: isFocused,
|
|
110
|
+
state: state
|
|
111
|
+
});
|
|
112
|
+
lastRender.current = {
|
|
113
|
+
isFocused: isFocused,
|
|
114
|
+
state: state
|
|
115
|
+
};
|
|
116
|
+
// If the focused item is removed from the DOM, reset the focused key to null.
|
|
117
|
+
// eslint-disable-next-line arrow-body-style
|
|
118
|
+
$7plFg$react.useEffect(()=>{
|
|
119
|
+
return ()=>{
|
|
120
|
+
if (lastRender.current.isFocused) lastRender.current.state.selectionManager.setFocusedKey(null);
|
|
121
|
+
};
|
|
122
|
+
}, []);
|
|
123
|
+
return {
|
|
124
|
+
buttonProps: $7plFg$reactariautils.mergeProps(buttonProps, {
|
|
125
|
+
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
|
|
126
|
+
onFocus () {
|
|
127
|
+
state.selectionManager.setFocusedKey(props.key);
|
|
128
|
+
},
|
|
129
|
+
onPress () {
|
|
130
|
+
state.selectionManager.select(props.key);
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
}
|
|
142
135
|
|
|
143
|
-
onFocus() {
|
|
144
|
-
state.selectionManager.setFocusedKey(props.key);
|
|
145
|
-
},
|
|
146
136
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
137
|
+
$parcel$exportWildcard(module.exports, $f04a3cd2f8d93328$exports);
|
|
138
|
+
$parcel$exportWildcard(module.exports, $549a2ca943703af8$exports);
|
|
150
139
|
|
|
151
|
-
})
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
140
|
|
|
155
|
-
exports.useActionGroupItem = useActionGroupItem;
|
|
156
141
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACkBD,MAAMG,oDAAkB,GAAG;AACzB,UAAQ,SADiB;AAEzB,YAAU,YAFe;AAGzB,cAAY;AAHa,CAA3B;;AAUO,SAASC,cAAT,CAA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D;AAAYpC,IAAAA;AAAZ,GAAD,CAAvB;AACAsC,EAAAA,UAAU,CAACE,OAAX,GAAqB;AAACJ,IAAAA,SAAD;AAAYpC,IAAAA;AAAZ,GAArB,CAbyI,CAezI;AACA;;AACAyC,EAAAA,SAAS,CAAC,MAAM;AACd,WAAO,MAAM;AACX,UAAIH,UAAU,CAACE,OAAX,CAAmBJ,SAAvB,EAAkC;AAChCE,QAAAA,UAAU,CAACE,OAAX,CAAmBxC,KAAnB,CAAyB2B,gBAAzB,CAA0Ce,aAA1C,CAAwD,IAAxD;AACD;AACF,KAJD;AAKD,GANQ,EAMN,EANM,CAAT;AAQA,SAAO;AACLR,IAAAA,WAAW,EAAES,UAAU,CAACT,WAAD,EAAc;AACnCU,MAAAA,QAAQ,EAAER,SAAS,IAAIpC,KAAK,CAAC2B,gBAAN,CAAuBU,UAAvB,IAAqC,IAAlD,GAAyD,CAAzD,GAA6D,CAAC,CADrC;;AAEnCQ,MAAAA,OAAO,GAAG;AACR7C,QAAAA,KAAK,CAAC2B,gBAAN,CAAuBe,aAAvB,CAAqC3C,KAAK,CAACS,GAA3C;AACD,OAJkC;;AAKnCsC,MAAAA,OAAO,GAAG;AACR9C,QAAAA,KAAK,CAAC2B,gBAAN,CAAuBoB,MAAvB,CAA8BhD,KAAK,CAACS,GAApC;AACD;;AAPkC,KAAd;AADlB,GAAP;AAWD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/actiongroup/src/useActionGroup.ts","./packages/@react-aria/actiongroup/src/useActionGroupItem.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\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 {AriaActionGroupProps} from '@react-types/actiongroup';\nimport {createFocusManager} from '@react-aria/focus';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\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: HTMLAttributes<HTMLElement>\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<HTMLElement>): 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 {HTMLAttributes, 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: HTMLAttributes<HTMLElement> & 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<HTMLElement>): 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":["$parcel$interopDefault","a","__esModule","default","BUTTON_GROUP_ROLES","useActionGroup","props","state","ref","isDisabled","orientation","allKeys","collection","getKeys","some","key","disabledKeys","has","direction","useLocale","focusManager","createFocusManager","flipDirection","onKeyDown","e","currentTarget","contains","target","preventDefault","stopPropagation","focusPrevious","wrap","focusNext","role","selectionManager","selectionMode","actionGroupProps","filterDOMProps","labelable","BUTTON_ROLES","useActionGroupItem","buttonProps","isSelected","isFocused","focusedKey","lastRender","useRef","current","useEffect","setFocusedKey","mergeProps","tabIndex","onFocus","onPress","select"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACoBA,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,GAA2B,EAAmB,CAAC;IACpI,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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AI;QAEhE,CAAC;IACH,CAAC,EAAE,CAAC,CAAC;IAEL,MAAM,CAAC,CAAC;QACN,WAAW,EAAE,gCAAU,CAAC,WAAW,EAAE,CAAC;YACpC,QAAQ,EAAE,SAAS,IAAI,KAAK,CAAC,gBAAgB,CAAC,UAAU,IAAI,IAAI,GAAG,CAAC,GAAG,EAAE;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 */\n\nexport * from './useActionGroup';\nexport * 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 {filterDOMProps} from '@react-aria/utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\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: HTMLAttributes<HTMLElement>\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<HTMLElement>): 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 {HTMLAttributes, 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: HTMLAttributes<HTMLElement> & 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<HTMLElement>): 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
|
@@ -1,132 +1,124 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
|
|
6
|
-
const $d6b03789ac7a9e8dac0d1b0b$var$BUTTON_GROUP_ROLES = {
|
|
7
|
-
'none': 'toolbar',
|
|
8
|
-
'single': 'radiogroup',
|
|
9
|
-
'multiple': 'toolbar'
|
|
10
|
-
};
|
|
11
|
-
export function useActionGroup(props, state, ref) {
|
|
12
|
-
let {
|
|
13
|
-
isDisabled,
|
|
14
|
-
orientation = 'horizontal'
|
|
15
|
-
} = props;
|
|
16
|
-
let allKeys = [...state.collection.getKeys()];
|
|
1
|
+
import {createFocusManager as $BCzw5$createFocusManager} from "@react-aria/focus";
|
|
2
|
+
import {filterDOMProps as $BCzw5$filterDOMProps, mergeProps as $BCzw5$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useLocale as $BCzw5$useLocale} from "@react-aria/i18n";
|
|
4
|
+
import {useRef as $BCzw5$useRef, useEffect as $BCzw5$useEffect} from "react";
|
|
17
5
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
var $fc182f041faf8dff$exports = {};
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
direction
|
|
24
|
-
} = useLocale();
|
|
25
|
-
let focusManager = createFocusManager(ref);
|
|
26
|
-
let flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
11
|
+
$parcel$export($fc182f041faf8dff$exports, "useActionGroup", () => $fc182f041faf8dff$export$f4bf8d43c16de704);
|
|
27
12
|
|
|
28
|
-
let onKeyDown = e => {
|
|
29
|
-
if (!e.currentTarget.contains(e.target)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
13
|
|
|
33
|
-
switch (e.key) {
|
|
34
|
-
case 'ArrowRight':
|
|
35
|
-
case 'ArrowDown':
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
e.stopPropagation();
|
|
38
14
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
15
|
+
const $fc182f041faf8dff$var$BUTTON_GROUP_ROLES = {
|
|
16
|
+
'none': 'toolbar',
|
|
17
|
+
'single': 'radiogroup',
|
|
18
|
+
'multiple': 'toolbar'
|
|
19
|
+
};
|
|
20
|
+
function $fc182f041faf8dff$export$f4bf8d43c16de704(props, state, ref) {
|
|
21
|
+
let { isDisabled: isDisabled , orientation: orientation = 'horizontal' } = props;
|
|
22
|
+
let allKeys = [
|
|
23
|
+
...state.collection.getKeys()
|
|
24
|
+
];
|
|
25
|
+
if (!allKeys.some((key)=>!state.disabledKeys.has(key)
|
|
26
|
+
)) isDisabled = true;
|
|
27
|
+
let { direction: direction } = $BCzw5$useLocale();
|
|
28
|
+
let focusManager = $BCzw5$createFocusManager(ref);
|
|
29
|
+
let flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
30
|
+
let onKeyDown = (e)=>{
|
|
31
|
+
if (!e.currentTarget.contains(e.target)) return;
|
|
32
|
+
switch(e.key){
|
|
33
|
+
case 'ArrowRight':
|
|
34
|
+
case 'ArrowDown':
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
if (e.key === 'ArrowRight' && flipDirection) focusManager.focusPrevious({
|
|
38
|
+
wrap: true
|
|
39
|
+
});
|
|
40
|
+
else focusManager.focusNext({
|
|
41
|
+
wrap: true
|
|
42
|
+
});
|
|
43
|
+
break;
|
|
44
|
+
case 'ArrowLeft':
|
|
45
|
+
case 'ArrowUp':
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
if (e.key === 'ArrowLeft' && flipDirection) focusManager.focusNext({
|
|
49
|
+
wrap: true
|
|
50
|
+
});
|
|
51
|
+
else focusManager.focusPrevious({
|
|
52
|
+
wrap: true
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
47
55
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
} else {
|
|
61
|
-
focusManager.focusPrevious({
|
|
62
|
-
wrap: true
|
|
63
|
-
});
|
|
56
|
+
};
|
|
57
|
+
let role = $fc182f041faf8dff$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
|
|
58
|
+
return {
|
|
59
|
+
actionGroupProps: {
|
|
60
|
+
...$BCzw5$filterDOMProps(props, {
|
|
61
|
+
labelable: true
|
|
62
|
+
}),
|
|
63
|
+
role: role,
|
|
64
|
+
'aria-orientation': role === 'toolbar' ? orientation : null,
|
|
65
|
+
'aria-disabled': isDisabled,
|
|
66
|
+
onKeyDown: onKeyDown
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
let role = $d6b03789ac7a9e8dac0d1b0b$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
|
|
71
|
-
return {
|
|
72
|
-
actionGroupProps: _babelRuntimeHelpersEsmExtends({}, filterDOMProps(props, {
|
|
73
|
-
labelable: true
|
|
74
|
-
}), {
|
|
75
|
-
role,
|
|
76
|
-
'aria-orientation': role === 'toolbar' ? orientation : null,
|
|
77
|
-
'aria-disabled': isDisabled,
|
|
78
|
-
onKeyDown
|
|
79
|
-
})
|
|
80
|
-
};
|
|
68
|
+
};
|
|
81
69
|
}
|
|
82
|
-
const $d68d5fee7c6cb722ef27fbc6b2392061$var$BUTTON_ROLES = {
|
|
83
|
-
'none': null,
|
|
84
|
-
'single': 'radio',
|
|
85
|
-
'multiple': 'checkbox'
|
|
86
|
-
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
70
|
|
|
88
|
-
export function useActionGroupItem(props, state, ref) {
|
|
89
|
-
let selectionMode = state.selectionManager.selectionMode;
|
|
90
|
-
let buttonProps = {
|
|
91
|
-
role: $d68d5fee7c6cb722ef27fbc6b2392061$var$BUTTON_ROLES[selectionMode]
|
|
92
|
-
};
|
|
93
71
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
72
|
+
var $4d716f4bf4beb52c$exports = {};
|
|
73
|
+
|
|
74
|
+
$parcel$export($4d716f4bf4beb52c$exports, "useActionGroupItem", () => $4d716f4bf4beb52c$export$9597202bd3099a29);
|
|
98
75
|
|
|
99
|
-
let isFocused = props.key === state.selectionManager.focusedKey;
|
|
100
|
-
let lastRender = useRef({
|
|
101
|
-
isFocused,
|
|
102
|
-
state
|
|
103
|
-
});
|
|
104
|
-
lastRender.current = {
|
|
105
|
-
isFocused,
|
|
106
|
-
state
|
|
107
|
-
}; // If the focused item is removed from the DOM, reset the focused key to null.
|
|
108
|
-
// eslint-disable-next-line arrow-body-style
|
|
109
76
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
77
|
+
const $4d716f4bf4beb52c$var$BUTTON_ROLES = {
|
|
78
|
+
'none': null,
|
|
79
|
+
'single': 'radio',
|
|
80
|
+
'multiple': 'checkbox'
|
|
81
|
+
};
|
|
82
|
+
function $4d716f4bf4beb52c$export$9597202bd3099a29(props, state, ref) {
|
|
83
|
+
let selectionMode = state.selectionManager.selectionMode;
|
|
84
|
+
let buttonProps = {
|
|
85
|
+
role: $4d716f4bf4beb52c$var$BUTTON_ROLES[selectionMode]
|
|
86
|
+
};
|
|
87
|
+
if (selectionMode !== 'none') {
|
|
88
|
+
let isSelected = state.selectionManager.isSelected(props.key);
|
|
89
|
+
buttonProps['aria-checked'] = isSelected;
|
|
90
|
+
}
|
|
91
|
+
let isFocused = props.key === state.selectionManager.focusedKey;
|
|
92
|
+
let lastRender = $BCzw5$useRef({
|
|
93
|
+
isFocused: isFocused,
|
|
94
|
+
state: state
|
|
95
|
+
});
|
|
96
|
+
lastRender.current = {
|
|
97
|
+
isFocused: isFocused,
|
|
98
|
+
state: state
|
|
99
|
+
};
|
|
100
|
+
// If the focused item is removed from the DOM, reset the focused key to null.
|
|
101
|
+
// eslint-disable-next-line arrow-body-style
|
|
102
|
+
$BCzw5$useEffect(()=>{
|
|
103
|
+
return ()=>{
|
|
104
|
+
if (lastRender.current.isFocused) lastRender.current.state.selectionManager.setFocusedKey(null);
|
|
105
|
+
};
|
|
106
|
+
}, []);
|
|
107
|
+
return {
|
|
108
|
+
buttonProps: $BCzw5$mergeProps(buttonProps, {
|
|
109
|
+
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
|
|
110
|
+
onFocus () {
|
|
111
|
+
state.selectionManager.setFocusedKey(props.key);
|
|
112
|
+
},
|
|
113
|
+
onPress () {
|
|
114
|
+
state.selectionManager.select(props.key);
|
|
115
|
+
}
|
|
116
|
+
})
|
|
115
117
|
};
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
buttonProps: mergeProps(buttonProps, {
|
|
119
|
-
tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
|
|
118
|
+
}
|
|
120
119
|
|
|
121
|
-
onFocus() {
|
|
122
|
-
state.selectionManager.setFocusedKey(props.key);
|
|
123
|
-
},
|
|
124
120
|
|
|
125
|
-
onPress() {
|
|
126
|
-
state.selectionManager.select(props.key);
|
|
127
|
-
}
|
|
128
121
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
122
|
+
|
|
123
|
+
export {$fc182f041faf8dff$export$f4bf8d43c16de704 as useActionGroup, $4d716f4bf4beb52c$export$9597202bd3099a29 as useActionGroupItem};
|
|
132
124
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;ACoBA,KAAK,CAAC,wCAAkB,GAAG,CAAC;IAC1B,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CAAC;mBAAA,SAAS;eAAE,KAAK;IAAA,CAAC;IAC1C,UAAU,CAAC,OAAO,GAAG,CAAC;mBAAA,SAAS;eAAE,KAAK;IAAA,CAAC;IAEvC,EAA8E,AAA9E,4EAA8E;IAC9E,EAA4C,AAA5C,0CAA4C;IAC5C,gBAAS,KAAO,CAAC;QACf,MAAM,KAAO,CAAC;YACZ,EAAE,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS,EAC9B,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI;QAEhE,CAAC;IACH,CAAC,EAAE,CAAC,CAAC;IAEL,MAAM,CAAC,CAAC;QACN,WAAW,EAAE,iBAAU,CAAC,WAAW,EAAE,CAAC;YACpC,QAAQ,EAAE,SAAS,IAAI,KAAK,CAAC,gBAAgB,CAAC,UAAU,IAAI,IAAI,GAAG,CAAC,GAAG,EAAE;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 */\n\nexport * from './useActionGroup';\nexport * 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 {filterDOMProps} from '@react-aria/utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\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: HTMLAttributes<HTMLElement>\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<HTMLElement>): 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 {HTMLAttributes, 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: HTMLAttributes<HTMLElement> & 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<HTMLElement>): 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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;AA0BA;IACE,gBAAgB,EAAE,eAAe,WAAW,CAAC,CAAA;CAC9C;AAED,+BAA+B,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,eAAe,CAoDnI;ACjED;IACE,GAAG,EAAE,GAAG,CAAA;CACT;AAED;IACE,WAAW,EAAE,eAAe,WAAW,CAAC,GAAG,UAAU,CAAA;CACtD;AASD,mCAAmC,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,WAAW,CAAC,GAAG,mBAAmB,CAoCzI","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 */\n\nexport * from './useActionGroup';\nexport * 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.2.2-nightly.
|
|
3
|
+
"version": "3.2.2-nightly.3059+2842ff524",
|
|
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.4.2-nightly.
|
|
28
|
-
"@react-types/actiongroup": "3.2.2-nightly.
|
|
29
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
21
|
+
"@react-aria/focus": "3.0.0-nightly.1368+2842ff524",
|
|
22
|
+
"@react-aria/i18n": "3.0.0-nightly.1368+2842ff524",
|
|
23
|
+
"@react-aria/interactions": "3.0.0-nightly.1368+2842ff524",
|
|
24
|
+
"@react-aria/selection": "3.0.0-nightly.1368+2842ff524",
|
|
25
|
+
"@react-aria/utils": "3.0.0-nightly.1368+2842ff524",
|
|
26
|
+
"@react-stately/collections": "3.0.0-nightly.1368+2842ff524",
|
|
27
|
+
"@react-stately/list": "3.4.2-nightly.3059+2842ff524",
|
|
28
|
+
"@react-types/actiongroup": "3.2.2-nightly.3059+2842ff524",
|
|
29
|
+
"@react-types/shared": "3.0.0-nightly.1368+2842ff524"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "2842ff524282eb9847eadb1d98d9a293ecbaa0a2"
|
|
38
38
|
}
|