@react-aria/actiongroup 3.3.2-nightly.3373 → 3.4.0

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.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,MAAM,GACpC,MAAM;QAGR,MAAM,CAAE,CAAC,CAAC,GAAG;YACX,IAAI,CAAC,CAAY;YACjB,IAAI,CAAC,CAAW;gBACd,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,eAAe;gBACjB,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAY,eAAI,aAAa,EACzC,YAAY,CAAC,aAAa,CAAC,CAAC;oBAAA,IAAI,EAA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C,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG;QAC5D,WAAW,CAAC,CAAc,iBAAI,UAAU;IAC1C,CAAC;IAED,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,gBAAgB,CAAC,UAAU;IAC/D,GAAG,CAAC,UAAU,GAAG,mBAAM,CAAC,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,sBAAS,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,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 */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaActionGroupProps} from '@react-types/actiongroup';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\ninterface ActionGroupItemProps {\n key: Key\n}\n\ninterface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {\n let selectionMode = state.selectionManager.selectionMode;\n let buttonProps = {\n role: BUTTON_ROLES[selectionMode]\n };\n\n if (selectionMode !== 'none') {\n let isSelected = state.selectionManager.isSelected(props.key);\n buttonProps['aria-checked'] = isSelected;\n }\n\n let isFocused = props.key === state.selectionManager.focusedKey;\n let lastRender = useRef({isFocused, state});\n lastRender.current = {isFocused, state};\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (lastRender.current.isFocused) {\n lastRender.current.state.selectionManager.setFocusedKey(null);\n }\n };\n }, []);\n\n return {\n buttonProps: mergeProps(buttonProps, {\n tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,\n onFocus() {\n state.selectionManager.setFocusedKey(props.key);\n },\n onPress() {\n state.selectionManager.select(props.key);\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
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,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AAG;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":"main.js.map"}
@@ -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,WAA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AAO,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 */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaActionGroupProps} from '@react-types/actiongroup';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {Orientation} from '@react-types/shared';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nconst BUTTON_GROUP_ROLES = {\n 'none': 'toolbar',\n 'single': 'radiogroup',\n 'multiple': 'toolbar'\n};\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes\n}\n\nexport function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {\n let {\n isDisabled,\n orientation = 'horizontal' as Orientation\n } = props;\n let allKeys = [...state.collection.getKeys()];\n if (!allKeys.some(key => !state.disabledKeys.has(key))) {\n isDisabled = true;\n }\n\n let {direction} = useLocale();\n let focusManager = createFocusManager(ref);\n let flipDirection = direction === 'rtl' && orientation === 'horizontal';\n let onKeyDown = (e) => {\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowRight' && flipDirection) {\n focusManager.focusPrevious({wrap: true});\n } else {\n focusManager.focusNext({wrap: true});\n }\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'ArrowLeft' && flipDirection) {\n focusManager.focusNext({wrap: true});\n } else {\n focusManager.focusPrevious({wrap: true});\n }\n break;\n }\n };\n\n let role = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n return {\n actionGroupProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n 'aria-orientation': role === 'toolbar' ? orientation : null,\n 'aria-disabled': isDisabled,\n onKeyDown\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {Key, RefObject, useEffect, useRef} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressProps} from '@react-aria/interactions';\n\ninterface ActionGroupItemProps {\n key: Key\n}\n\ninterface ActionGroupItemAria {\n buttonProps: DOMAttributes & PressProps\n}\n\nconst BUTTON_ROLES = {\n 'none': null,\n 'single': 'radio',\n 'multiple': 'checkbox'\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {\n let selectionMode = state.selectionManager.selectionMode;\n let buttonProps = {\n role: BUTTON_ROLES[selectionMode]\n };\n\n if (selectionMode !== 'none') {\n let isSelected = state.selectionManager.isSelected(props.key);\n buttonProps['aria-checked'] = isSelected;\n }\n\n let isFocused = props.key === state.selectionManager.focusedKey;\n let lastRender = useRef({isFocused, state});\n lastRender.current = {isFocused, state};\n\n // If the focused item is removed from the DOM, reset the focused key to null.\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (lastRender.current.isFocused) {\n lastRender.current.state.selectionManager.setFocusedKey(null);\n }\n };\n }, []);\n\n return {\n buttonProps: mergeProps(buttonProps, {\n tabIndex: isFocused || state.selectionManager.focusedKey == null ? 0 : -1,\n onFocus() {\n state.selectionManager.setF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BAAI,UAAU;IAC1C,CAAC;IAED,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,gBAAgB,CAAC,UAAU;IAC/D,GAAG,CAAC,UAAU,GAAG,aAAM,CAAC,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 */\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.js.map"}
package/dist/types.d.ts CHANGED
@@ -7,12 +7,13 @@ export interface ActionGroupAria {
7
7
  actionGroupProps: DOMAttributes;
8
8
  }
9
9
  export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria;
10
- interface ActionGroupItemProps {
10
+ export interface AriaActionGroupItemProps {
11
11
  key: Key;
12
12
  }
13
- interface ActionGroupItemAria {
13
+ export interface ActionGroupItemAria {
14
14
  buttonProps: DOMAttributes & PressProps;
15
15
  }
16
- export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria;
16
+ export function useActionGroupItem<T>(props: AriaActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria;
17
+ export type { AriaActionGroupProps } from '@react-types/actiongroup';
17
18
 
18
19
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;;;AA2BA;IACE,gBAAgB,EAAE,aAAa,CAAA;CAChC;AAED,+BAA+B,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,eAAe,CAoDxI;ACjED;IACE,GAAG,EAAE,GAAG,CAAA;CACT;AAED;IACE,WAAW,EAAE,aAAa,GAAG,UAAU,CAAA;CACxC;AASD,mCAAmC,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,gBAAgB,CAAC,GAAG,mBAAmB,CAoC9I","sources":["packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/useActionGroup.ts","packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/useActionGroupItem.ts","packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/index.ts","packages/@react-aria/actiongroup/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;AA2BA;IACE,gBAAgB,EAAE,aAAa,CAAA;CAChC;AAED,+BAA+B,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,eAAe,CAoDxI;ACjED;IACE,GAAG,EAAE,GAAG,CAAA;CACT;AAED;IACE,WAAW,EAAE,aAAa,GAAG,UAAU,CAAA;CACxC;AASD,mCAAmC,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,gBAAgB,CAAC,GAAG,mBAAmB,CAoClJ;ACvDD,YAAY,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC","sources":["packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/useActionGroup.ts","packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/useActionGroupItem.ts","packages/@react-aria/actiongroup/src/packages/@react-aria/actiongroup/src/index.ts","packages/@react-aria/actiongroup/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {ActionGroupAria} from './useActionGroup';\nexport {useActionGroup} from './useActionGroup';\nexport {useActionGroupItem} from './useActionGroupItem';\nexport type {AriaActionGroupProps} from '@react-types/actiongroup';\nexport type {ActionGroupItemAria, AriaActionGroupItemProps} from './useActionGroupItem';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/actiongroup",
3
- "version": "3.3.2-nightly.3373+8defd74c9",
3
+ "version": "3.4.0",
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.1673+8defd74c9",
22
- "@react-aria/i18n": "3.0.0-nightly.1673+8defd74c9",
23
- "@react-aria/interactions": "3.0.0-nightly.1673+8defd74c9",
24
- "@react-aria/selection": "3.0.0-nightly.1673+8defd74c9",
25
- "@react-aria/utils": "3.0.0-nightly.1673+8defd74c9",
26
- "@react-stately/collections": "3.0.0-nightly.1673+8defd74c9",
27
- "@react-stately/list": "3.5.2-nightly.3373+8defd74c9",
28
- "@react-types/actiongroup": "3.3.2-nightly.3373+8defd74c9",
29
- "@react-types/shared": "3.0.0-nightly.1673+8defd74c9"
21
+ "@react-aria/focus": "^3.7.0",
22
+ "@react-aria/i18n": "^3.5.0",
23
+ "@react-aria/interactions": "^3.10.0",
24
+ "@react-aria/selection": "^3.10.0",
25
+ "@react-aria/utils": "^3.13.2",
26
+ "@react-stately/collections": "^3.4.2",
27
+ "@react-stately/list": "^3.5.2",
28
+ "@react-types/actiongroup": "^3.3.2",
29
+ "@react-types/shared": "^3.14.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "8defd74c9698b4dda32fd20bcfc579b123cd98e7"
37
+ "gitHead": "cd7c0ec917122c7612f653c22f8ed558f8b66ecd"
38
38
  }
package/src/index.ts CHANGED
@@ -12,3 +12,5 @@
12
12
  export type {ActionGroupAria} from './useActionGroup';
13
13
  export {useActionGroup} from './useActionGroup';
14
14
  export {useActionGroupItem} from './useActionGroupItem';
15
+ export type {AriaActionGroupProps} from '@react-types/actiongroup';
16
+ export type {ActionGroupItemAria, AriaActionGroupItemProps} from './useActionGroupItem';
@@ -16,11 +16,11 @@ import {ListState} from '@react-stately/list';
16
16
  import {mergeProps} from '@react-aria/utils';
17
17
  import {PressProps} from '@react-aria/interactions';
18
18
 
19
- interface ActionGroupItemProps {
19
+ export interface AriaActionGroupItemProps {
20
20
  key: Key
21
21
  }
22
22
 
23
- interface ActionGroupItemAria {
23
+ export interface ActionGroupItemAria {
24
24
  buttonProps: DOMAttributes & PressProps
25
25
  }
26
26
 
@@ -31,7 +31,7 @@ const BUTTON_ROLES = {
31
31
  };
32
32
 
33
33
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
- export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {
34
+ export function useActionGroupItem<T>(props: AriaActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {
35
35
  let selectionMode = state.selectionManager.selectionMode;
36
36
  let buttonProps = {
37
37
  role: BUTTON_ROLES[selectionMode]