@react-aria/actiongroup 3.4.4-nightly.3598 → 3.4.4-nightly.3600

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 CHANGED
@@ -9,43 +9,62 @@ function $parcel$export(e, n, v, s) {
9
9
 
10
10
  $parcel$export(module.exports, "useActionGroup", () => $ceb684449a137553$export$f4bf8d43c16de704);
11
11
  $parcel$export(module.exports, "useActionGroupItem", () => $44b92e5de834b44e$export$9597202bd3099a29);
12
-
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
+ * Copyright 2020 Adobe. All rights reserved.
24
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License. You may obtain a copy
26
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software distributed under
29
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
+ * OF ANY KIND, either express or implied. See the License for the specific language
31
+ * governing permissions and limitations under the License.
32
+ */
13
33
 
14
34
 
15
35
  const $ceb684449a137553$var$BUTTON_GROUP_ROLES = {
16
- 'none': 'toolbar',
17
- 'single': 'radiogroup',
18
- 'multiple': 'toolbar'
36
+ "none": "toolbar",
37
+ "single": "radiogroup",
38
+ "multiple": "toolbar"
19
39
  };
20
40
  function $ceb684449a137553$export$f4bf8d43c16de704(props, state, ref) {
21
- let { isDisabled: isDisabled , orientation: orientation = 'horizontal' } = props;
41
+ let { isDisabled: isDisabled , orientation: orientation = "horizontal" } = props;
22
42
  let allKeys = [
23
43
  ...state.collection.getKeys()
24
44
  ];
25
- if (!allKeys.some((key)=>!state.disabledKeys.has(key)
26
- )) isDisabled = true;
27
- let { direction: direction } = $hjKwo$reactariai18n.useLocale();
28
- let focusManager = $hjKwo$reactariafocus.createFocusManager(ref);
29
- let flipDirection = direction === 'rtl' && orientation === 'horizontal';
45
+ if (!allKeys.some((key)=>!state.disabledKeys.has(key))) isDisabled = true;
46
+ let { direction: direction } = (0, $hjKwo$reactariai18n.useLocale)();
47
+ let focusManager = (0, $hjKwo$reactariafocus.createFocusManager)(ref);
48
+ let flipDirection = direction === "rtl" && orientation === "horizontal";
30
49
  let onKeyDown = (e)=>{
31
50
  if (!e.currentTarget.contains(e.target)) return;
32
51
  switch(e.key){
33
- case 'ArrowRight':
34
- case 'ArrowDown':
52
+ case "ArrowRight":
53
+ case "ArrowDown":
35
54
  e.preventDefault();
36
55
  e.stopPropagation();
37
- if (e.key === 'ArrowRight' && flipDirection) focusManager.focusPrevious({
56
+ if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
38
57
  wrap: true
39
58
  });
40
59
  else focusManager.focusNext({
41
60
  wrap: true
42
61
  });
43
62
  break;
44
- case 'ArrowLeft':
45
- case 'ArrowUp':
63
+ case "ArrowLeft":
64
+ case "ArrowUp":
46
65
  e.preventDefault();
47
66
  e.stopPropagation();
48
- if (e.key === 'ArrowLeft' && flipDirection) focusManager.focusNext({
67
+ if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
49
68
  wrap: true
50
69
  });
51
70
  else focusManager.focusPrevious({
@@ -57,36 +76,46 @@ function $ceb684449a137553$export$f4bf8d43c16de704(props, state, ref) {
57
76
  let role = $ceb684449a137553$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
58
77
  return {
59
78
  actionGroupProps: {
60
- ...$hjKwo$reactariautils.filterDOMProps(props, {
79
+ ...(0, $hjKwo$reactariautils.filterDOMProps)(props, {
61
80
  labelable: true
62
81
  }),
63
82
  role: role,
64
- 'aria-orientation': role === 'toolbar' ? orientation : null,
65
- 'aria-disabled': isDisabled,
83
+ "aria-orientation": role === "toolbar" ? orientation : null,
84
+ "aria-disabled": isDisabled,
66
85
  onKeyDown: onKeyDown
67
86
  }
68
87
  };
69
88
  }
70
89
 
71
90
 
72
-
91
+ /*
92
+ * Copyright 2020 Adobe. All rights reserved.
93
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
94
+ * you may not use this file except in compliance with the License. You may obtain a copy
95
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
96
+ *
97
+ * Unless required by applicable law or agreed to in writing, software distributed under
98
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
99
+ * OF ANY KIND, either express or implied. See the License for the specific language
100
+ * governing permissions and limitations under the License.
101
+ */
73
102
 
74
103
  const $44b92e5de834b44e$var$BUTTON_ROLES = {
75
- 'none': null,
76
- 'single': 'radio',
77
- 'multiple': 'checkbox'
104
+ "none": null,
105
+ "single": "radio",
106
+ "multiple": "checkbox"
78
107
  };
79
108
  function $44b92e5de834b44e$export$9597202bd3099a29(props, state, ref) {
80
109
  let selectionMode = state.selectionManager.selectionMode;
81
110
  let buttonProps = {
82
111
  role: $44b92e5de834b44e$var$BUTTON_ROLES[selectionMode]
83
112
  };
84
- if (selectionMode !== 'none') {
113
+ if (selectionMode !== "none") {
85
114
  let isSelected = state.selectionManager.isSelected(props.key);
86
- buttonProps['aria-checked'] = isSelected;
115
+ buttonProps["aria-checked"] = isSelected;
87
116
  }
88
117
  let isFocused = props.key === state.selectionManager.focusedKey;
89
- let lastRender = $hjKwo$react.useRef({
118
+ let lastRender = (0, $hjKwo$react.useRef)({
90
119
  isFocused: isFocused,
91
120
  state: state
92
121
  });
@@ -96,13 +125,13 @@ function $44b92e5de834b44e$export$9597202bd3099a29(props, state, ref) {
96
125
  };
97
126
  // If the focused item is removed from the DOM, reset the focused key to null.
98
127
  // eslint-disable-next-line arrow-body-style
99
- $hjKwo$react.useEffect(()=>{
128
+ (0, $hjKwo$react.useEffect)(()=>{
100
129
  return ()=>{
101
130
  if (lastRender.current.isFocused) lastRender.current.state.selectionManager.setFocusedKey(null);
102
131
  };
103
132
  }, []);
104
133
  return {
105
- buttonProps: $hjKwo$reactariautils.mergeProps(buttonProps, {
134
+ buttonProps: (0, $hjKwo$reactariautils.mergeProps)(buttonProps, {
106
135
  tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
107
136
  onFocus () {
108
137
  state.selectionManager.setFocusedKey(props.key);
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;ACqBA,KAAK,CAAC,wCAAkB,GAAG,CAAC;IAC1B,CAAM,OAAE,CAAS;IACjB,CAAQ,SAAE,CAAY;IACtB,CAAU,WAAE,CAAS;AACvB,CAAC;SAMe,yCAAc,CAAI,KAA8B,EAAE,KAAmB,EAAE,GAAgC,EAAmB,CAAC;IACzI,GAAG,CAAC,CAAC,aACH,UAAU,gBACV,WAAW,GAAG,CAAY,aAC5B,CAAC,GAAG,KAAK;IACT,GAAG,CAAC,OAAO,GAAG,CAAC;WAAG,KAAK,CAAC,UAAU,CAAC,OAAO;IAAE,CAAC;IAC7C,EAAE,GAAG,OAAO,CAAC,IAAI,EAAC,GAAG,IAAK,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG;OAClD,UAAU,GAAG,IAAI;IAGnB,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,8BAAS;IAC3B,GAAG,CAAC,YAAY,GAAG,wCAAkB,CAAC,GAAG;IACzC,GAAG,CAAC,aAAa,GAAG,SAAS,KAAK,CAAK,QAAI,WAAW,KAAK,CAAY;IACvE,GAAG,CAAC,SAAS,IAAI,CAAC,GAAK,CAAC;QACtB,EAAE,GAAG,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,MAA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,GAAG;YACzC,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/actiongroup/src/index.ts","packages/@react-aria/actiongroup/src/useActionGroup.ts","packages/@react-aria/actiongroup/src/useActionGroupItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\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} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: 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 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"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AASA,MAAM,2CAAqB;IACzB,QAAQ;IACR,UAAU;IACV,YAAY;AACd;AAMO,SAAS,0CAAkB,KAA8B,EAAE,KAAmB,EAAE,GAAgC,EAAmB;IACxI,IAAI,cACF,WAAU,eACV,cAAc,eACf,GAAG;IACJ,IAAI,UAAU;WAAI,MAAM,UAAU,CAAC,OAAO;KAAG;IAC7C,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAA,MAAO,CAAC,MAAM,YAAY,CAAC,G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;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,CAAC;IAED,IAAI,YAAY,MAAM,GAAG,KAAK,MAAM,gBAAgB,CAAC,UAAU;IAC/D,IAAI,aAAa,CAAA,GAAA,mBAAK,EAAE;mBAAC;eAAW;IAAK;IACzC,WAAW,OAAO,GAAG;mBAAC;eAAW;IAAK;IAEtC,8EAA8E;IAC9E,4CAA4C;IAC5C,CAAA,GAAA,sBAAS,AAAD,EAAE,IAAM;QACd,OAAO,IAAM;YACX,IAAI,WAAW,OAAO,CAAC,SAAS,EAC9B,WAAW,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI;QAEhE;IACF,GAAG,EAAE;IAEL,OAAO;QACL,aAAa,CAAA,GAAA,gCAAU,AAAD,EAAE,aAAa;YACnC,UAAU,aAAa,MAAM,gBAAgB,CAAC,UAAU,IAAI,IAAI,GAAG,IAAI,EAAE;YACzE,WAAU;gBACR,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,GAAG;YAChD;YACA,WAAU;gBACR,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} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: 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 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.mjs CHANGED
@@ -3,43 +3,62 @@ import {filterDOMProps as $1oG4F$filterDOMProps, mergeProps as $1oG4F$mergeProps
3
3
  import {useLocale as $1oG4F$useLocale} from "@react-aria/i18n";
4
4
  import {useRef as $1oG4F$useRef, useEffect as $1oG4F$useEffect} from "react";
5
5
 
6
-
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
+ */
7
27
 
8
28
 
9
29
  const $304ac34015d4535d$var$BUTTON_GROUP_ROLES = {
10
- 'none': 'toolbar',
11
- 'single': 'radiogroup',
12
- 'multiple': 'toolbar'
30
+ "none": "toolbar",
31
+ "single": "radiogroup",
32
+ "multiple": "toolbar"
13
33
  };
14
34
  function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
15
- let { isDisabled: isDisabled , orientation: orientation = 'horizontal' } = props;
35
+ let { isDisabled: isDisabled , orientation: orientation = "horizontal" } = props;
16
36
  let allKeys = [
17
37
  ...state.collection.getKeys()
18
38
  ];
19
- if (!allKeys.some((key)=>!state.disabledKeys.has(key)
20
- )) isDisabled = true;
21
- let { direction: direction } = $1oG4F$useLocale();
22
- let focusManager = $1oG4F$createFocusManager(ref);
23
- let flipDirection = direction === 'rtl' && orientation === 'horizontal';
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";
24
43
  let onKeyDown = (e)=>{
25
44
  if (!e.currentTarget.contains(e.target)) return;
26
45
  switch(e.key){
27
- case 'ArrowRight':
28
- case 'ArrowDown':
46
+ case "ArrowRight":
47
+ case "ArrowDown":
29
48
  e.preventDefault();
30
49
  e.stopPropagation();
31
- if (e.key === 'ArrowRight' && flipDirection) focusManager.focusPrevious({
50
+ if (e.key === "ArrowRight" && flipDirection) focusManager.focusPrevious({
32
51
  wrap: true
33
52
  });
34
53
  else focusManager.focusNext({
35
54
  wrap: true
36
55
  });
37
56
  break;
38
- case 'ArrowLeft':
39
- case 'ArrowUp':
57
+ case "ArrowLeft":
58
+ case "ArrowUp":
40
59
  e.preventDefault();
41
60
  e.stopPropagation();
42
- if (e.key === 'ArrowLeft' && flipDirection) focusManager.focusNext({
61
+ if (e.key === "ArrowLeft" && flipDirection) focusManager.focusNext({
43
62
  wrap: true
44
63
  });
45
64
  else focusManager.focusPrevious({
@@ -51,36 +70,46 @@ function $304ac34015d4535d$export$f4bf8d43c16de704(props, state, ref) {
51
70
  let role = $304ac34015d4535d$var$BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];
52
71
  return {
53
72
  actionGroupProps: {
54
- ...$1oG4F$filterDOMProps(props, {
73
+ ...(0, $1oG4F$filterDOMProps)(props, {
55
74
  labelable: true
56
75
  }),
57
76
  role: role,
58
- 'aria-orientation': role === 'toolbar' ? orientation : null,
59
- 'aria-disabled': isDisabled,
77
+ "aria-orientation": role === "toolbar" ? orientation : null,
78
+ "aria-disabled": isDisabled,
60
79
  onKeyDown: onKeyDown
61
80
  }
62
81
  };
63
82
  }
64
83
 
65
84
 
66
-
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
+ */
67
96
 
68
97
  const $f0ac0fb73c3ec062$var$BUTTON_ROLES = {
69
- 'none': null,
70
- 'single': 'radio',
71
- 'multiple': 'checkbox'
98
+ "none": null,
99
+ "single": "radio",
100
+ "multiple": "checkbox"
72
101
  };
73
102
  function $f0ac0fb73c3ec062$export$9597202bd3099a29(props, state, ref) {
74
103
  let selectionMode = state.selectionManager.selectionMode;
75
104
  let buttonProps = {
76
105
  role: $f0ac0fb73c3ec062$var$BUTTON_ROLES[selectionMode]
77
106
  };
78
- if (selectionMode !== 'none') {
107
+ if (selectionMode !== "none") {
79
108
  let isSelected = state.selectionManager.isSelected(props.key);
80
- buttonProps['aria-checked'] = isSelected;
109
+ buttonProps["aria-checked"] = isSelected;
81
110
  }
82
111
  let isFocused = props.key === state.selectionManager.focusedKey;
83
- let lastRender = $1oG4F$useRef({
112
+ let lastRender = (0, $1oG4F$useRef)({
84
113
  isFocused: isFocused,
85
114
  state: state
86
115
  });
@@ -90,13 +119,13 @@ function $f0ac0fb73c3ec062$export$9597202bd3099a29(props, state, ref) {
90
119
  };
91
120
  // If the focused item is removed from the DOM, reset the focused key to null.
92
121
  // eslint-disable-next-line arrow-body-style
93
- $1oG4F$useEffect(()=>{
122
+ (0, $1oG4F$useEffect)(()=>{
94
123
  return ()=>{
95
124
  if (lastRender.current.isFocused) lastRender.current.state.selectionManager.setFocusedKey(null);
96
125
  };
97
126
  }, []);
98
127
  return {
99
- buttonProps: $1oG4F$mergeProps(buttonProps, {
128
+ buttonProps: (0, $1oG4F$mergeProps)(buttonProps, {
100
129
  tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,
101
130
  onFocus () {
102
131
  state.selectionManager.setFocusedKey(props.key);
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;ACqBA,KAAK,CAAC,wCAAkB,GAAG,CAAC;IAC1B,CAAM,OAAE,CAAS;IACjB,CAAQ,SAAE,CAAY;IACtB,CAAU,WAAE,CAAS;AACvB,CAAC;SAMe,yCAAc,CAAI,KAA8B,EAAE,KAAmB,EAAE,GAAgC,EAAmB,CAAC;IACzI,GAAG,CAAC,CAAC,aACH,UAAU,gBACV,WAAW,GAAG,CAAY,aAC5B,CAAC,GAAG,KAAK;IACT,GAAG,CAAC,OAAO,GAAG,CAAC;WAAG,KAAK,CAAC,UAAU,CAAC,OAAO;IAAE,CAAC;IAC7C,EAAE,GAAG,OAAO,CAAC,IAAI,EAAC,GAAG,IAAK,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG;OAClD,UAAU,GAAG,IAAI;IAGnB,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,gBAAS;IAC3B,GAAG,CAAC,YA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,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 */\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} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: 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 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.mjs.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AASA,MAAM,2CAAqB;IACzB,QAAQ;IACR,UAAU;IACV,YAAY;AACd;AAMO,SAAS,0CAAkB,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;;;;;;;;;CAUC,GAED;;AAcA,MAAM,qCAAe;IACnB,QAAQ,IAAI;IACZ,UAAU;IACV,YAAY;AACd;AAGO,SAAS,0CAAsB,KAA+B,EAAE,KAAmB,EAAE,GAAiC,EAAuB;IAClJ,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,CAAC;IAED,IAAI,YAAY,MAAM,GAAG,KAAK,MAAM,gBAAgB,CAAC,UAAU;IAC/D,IAAI,aAAa,CAAA,GAAA,aAAK,EAAE;mBAAC;eAAW;IAAK;IACzC,WAAW,OAAO,GAAG;mBAAC;eAAW;IAAK;IAEtC,8EAA8E;IAC9E,4CAA4C;IAC5C,CAAA,GAAA,gBAAS,AAAD,EAAE,IAAM;QACd,OAAO,IAAM;YACX,IAAI,WAAW,OAAO,CAAC,SAAS,EAC9B,WAAW,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI;QAEhE;IACF,GAAG,EAAE;IAEL,OAAO;QACL,aAAa,CAAA,GAAA,iBAAU,AAAD,EAAE,aAAa;YACnC,UAAU,aAAa,MAAM,gBAAgB,CAAC,UAAU,IAAI,IAAI,GAAG,IAAI,EAAE;YACzE,WAAU;gBACR,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,GAAG;YAChD;YACA,WAAU;gBACR,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} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\nexport interface AriaActionGroupItemProps {\n key: Key\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: 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 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.mjs.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/actiongroup",
3
- "version": "3.4.4-nightly.3598+810579b67",
3
+ "version": "3.4.4-nightly.3600+bfce84fee",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,16 +22,16 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@babel/runtime": "^7.6.2",
26
- "@react-aria/focus": "3.0.0-nightly.1898+810579b67",
27
- "@react-aria/i18n": "3.0.0-nightly.1898+810579b67",
28
- "@react-aria/interactions": "3.0.0-nightly.1898+810579b67",
29
- "@react-aria/selection": "3.0.0-nightly.1898+810579b67",
30
- "@react-aria/utils": "3.0.0-nightly.1898+810579b67",
31
- "@react-stately/collections": "3.0.0-nightly.1898+810579b67",
32
- "@react-stately/list": "3.6.1-nightly.3598+810579b67",
33
- "@react-types/actiongroup": "3.3.6-nightly.3598+810579b67",
34
- "@react-types/shared": "3.0.0-nightly.1898+810579b67"
25
+ "@react-aria/focus": "3.0.0-nightly.1900+bfce84fee",
26
+ "@react-aria/i18n": "3.0.0-nightly.1900+bfce84fee",
27
+ "@react-aria/interactions": "3.0.0-nightly.1900+bfce84fee",
28
+ "@react-aria/selection": "3.0.0-nightly.1900+bfce84fee",
29
+ "@react-aria/utils": "3.0.0-nightly.1900+bfce84fee",
30
+ "@react-stately/collections": "3.0.0-nightly.1900+bfce84fee",
31
+ "@react-stately/list": "3.6.1-nightly.3600+bfce84fee",
32
+ "@react-types/actiongroup": "3.3.6-nightly.3600+bfce84fee",
33
+ "@react-types/shared": "3.0.0-nightly.1900+bfce84fee",
34
+ "@swc/helpers": "^0.4.14"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "810579b671791f1593108f62cdc1893de3a220e3"
42
+ "gitHead": "bfce84fee12a027d9cbc38b43e1747e3e4b4b169"
43
43
  }