@react-aria/tabs 3.0.3-nightly.2949 → 3.0.3-nightly.2967

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
@@ -23,10 +23,6 @@ var {
23
23
  useSelectableCollection
24
24
  } = require("@react-aria/selection");
25
25
 
26
- var {
27
- usePress
28
- } = require("@react-aria/interactions");
29
-
30
26
  var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
31
27
 
32
28
  function $parcel$interopDefault(a) {
@@ -69,26 +65,22 @@ function useTab(props, state, ref) {
69
65
  selectedKey
70
66
  } = state;
71
67
  let isSelected = key === selectedKey;
68
+ let isDisabled = propsDisabled || state.disabledKeys.has(key);
72
69
  let {
73
70
  itemProps
74
71
  } = useSelectableItem({
75
72
  selectionManager: manager,
76
73
  key,
77
- ref
78
- });
79
- let isDisabled = propsDisabled || state.disabledKeys.has(key);
80
- let {
81
- pressProps
82
- } = usePress(_babelRuntimeHelpersExtends({}, itemProps, {
74
+ ref,
83
75
  isDisabled
84
- }));
76
+ });
85
77
  let tabId = $c685c043bb86d16b2fcf2a65974f3$export$generateId(state, key, 'tab');
86
78
  let tabPanelId = $c685c043bb86d16b2fcf2a65974f3$export$generateId(state, key, 'tabpanel');
87
79
  let {
88
80
  tabIndex
89
- } = pressProps;
81
+ } = itemProps;
90
82
  return {
91
- tabProps: _babelRuntimeHelpersExtends({}, pressProps, {
83
+ tabProps: _babelRuntimeHelpersExtends({}, itemProps, {
92
84
  id: tabId,
93
85
  'aria-selected': isSelected,
94
86
  'aria-disabled': isDisabled || undefined,
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;A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B,EAAEC,OAF4B;AAG9C4D,IAAAA,gBAAgB,EAAEJ,QAH4B;AAI9CK,IAAAA,aAAa,EAAEP,kBAAkB,KAAK,WAJQ;AAK9CQ,IAAAA,sBAAsB,EAAE,IALsB;AAM9CC,IAAAA,SAAS,EAAEnE;AANmC,GAAD,CAA/C,CAjB0H,CA0B1H;;AACA,MAAIoE,MAAM,GAAGC,KAAK,EAAlB;AACA,gDAAQC,GAAR,CAAY9E,KAAZ,EAAmB4E,MAAnB;AAEA,MAAIG,iBAAiB,GAAGjC,SAAS,iCAAKvC,KAAL;AAAYkB,IAAAA,EAAE,EAAEmD;AAAhB,KAAjC;AAEA,SAAO;AACLI,IAAAA,YAAY,kCACPjC,UAAU,CAACuB,eAAD,EAAkBS,iBAAlB,CADH;AAEV7E,MAAAA,IAAI,EAAE,SAFI;AAGV,0BAAoBkD,WAHV;AAIV7B,MAAAA,QAAQ,EAAEG;AAJA;AADP,GAAP;AAQD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/tabs/src/utils.ts","./packages/@react-aria/tabs/src/useTab.ts","./packages/@react-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/useTabList.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 {Key} from 'react';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T>, key: Key, role: string) {\n if (typeof key === 'string') {\n key = key.replace(/\\s+/g, '');\n }\n\n let baseId = tabsIds.get(state);\n return `${baseId}-${role}-${key}`;\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 {AriaTabProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {usePress} from '@react-aria/interactions';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tab.\n * When selected, the associated tab panel is shown.\n */\nexport function useTab<T>(\n props: AriaTabProps,\n state: TabListState<T>,\n ref: RefObject<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref\n });\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n\n let {pressProps} = usePress({...itemProps, isDisabled});\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = pressProps;\n\n return {\n tabProps: {\n ...pressProps,\n id: tabId,\n 'aria-selected': isSelected,\n 'aria-disabled': isDisabled || undefined,\n 'aria-controls': isSelected ? tabPanelId : undefined,\n tabIndex: isDisabled ? undefined : tabIndex,\n role: 'tab'\n }\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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for\n * the contents of a tab, and is shown when the tab is selected.\n */\nexport function useTabPanel<T>(props: AriaTabPanelProps, state: TabListState<T>, ref: RefObject<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\n // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.\n // Otherwise, tabbing from the focused tab should go directly to the first tabbable element\n // within the tabpanel.\n useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, state?.selectedKey, 'tabpanel');\n const tabPanelProps = useLabels({...props, id, 'aria-labelledby': generateId(state, state?.selectedKey, 'tab')});\n\n return {\n tabPanelProps: mergeProps(tabPanelProps, {\n tabIndex,\n role: 'tabpanel',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\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 {Collection, Direction, KeyboardDelegate, Orientation} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TabsKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private flipDirection: boolean;\n private disabledKeys: Set<Key>;\n private orientation: Orientation;\n\n constructor(collection: Collection<T>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {\n this.collection = collection;\n this.flipDirection = direction === 'rtl' && orientation === 'horizontal';\n this.orientation = orientation;\n this.disabledKeys = disabledKeys;\n }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getNextKey(key);\n }\n return null;\n }\n }\n\n getKeyAbove(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n\n getKeyBelow(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getNextKey(key);\n }\n return null;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (this.disabledKeys.has(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (this.disabledKeys.has(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\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 {AriaTabListProps} from '@react-types/tabs';\nimport {HTMLAttributes, RefObject, useMemo} from 'react';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {tabsIds} from './utils';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab list.\n * Tabs organize content into multiple sections and allow users to navigate between them.\n */\nexport function useTabList<T>(props: AriaTabListProps<T>, state: TabListState<T>, ref: RefObject<HTMLElement>): TabListAria {\n let {\n orientation = 'horizontal',\n keyboardActivation = 'automatic'\n } = props;\n let {\n collection,\n selectionManager: manager,\n disabledKeys\n } = state;\n let {direction} = useLocale();\n let delegate = useMemo(() => new TabsKeyboardDelegate(\n collection,\n direction,\n orientation,\n disabledKeys), [collection, disabledKeys, orientation, direction]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n selectOnFocus: keyboardActivation === 'automatic',\n disallowEmptySelection: true,\n scrollRef: ref\n });\n\n // Compute base id for all tabs\n let tabsId = useId();\n tabsIds.set(state, tabsId);\n\n let tabListLabelProps = useLabels({...props, id: tabsId});\n\n return {\n tabListProps: {\n ...mergeProps(collectionProps, tabListLabelProps),\n role: 'tablist',\n 'aria-orientation': orientation,\n tabIndex: undefined\n }\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","tabsIds","WeakMap","generateId","state","key","role","replace","baseId","get","useTab","props","ref","isDisabled","propsDisabled","selectionManager","manager","selectedKey","isSelected","itemProps","useSelectableItem","disabledKeys","has","pressProps","usePress","tabId","tabPanelId","tabIndex","tabProps","id","undefined","useTabPanel","setTabIndex","useState","useLayoutEffect","current","update","walker","getFocusableTreeWalker","tabbable","nextNode","observer","MutationObserver","observe","subtree","childList","attributes","attributeFilter","disconnect","tabPanelProps","useLabels","mergeProps","TabsKeyboardDelegate","constructor","collection","direction","orientation","Set","flipDirection","getKeyLeftOf","getNextKey","getPreviousKey","getKeyRightOf","getKeyAbove","getKeyBelow","getFirstKey","getLastKey","getKeyAfter","getKeyBefore","useTabList","keyboardActivation","useLocale","delegate","useMemo","collectionProps","useSelectableCollection","keyboardDelegate","selectOnFocus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C,UAAD,EAAajC,YAAb,EAA2BmC,WAA3B,EAAwCD,SAAxC,CAJK,CAAtB;AAMA,MAAI;AAACmB,IAAAA;AAAD,MAAoBC,uBAAuB,CAAC;AAC9C7D,IAAAA,GAD8C;AAE9CG,IAAAA,gBAAgB,EAAEC,OAF4B;AAG9C0D,IAAAA,gBAAgB,EAAEJ,QAH4B;AAI9CK,IAAAA,aAAa,EAAEP,kBAAkB,KAAK,WAJQ;AAK9CQ,IAAAA,sBAAsB,EAAE,IALsB;AAM9CC,IAAAA,SAAS,EAAEjE;AANmC,GAAD,CAA/C,CAjB0H,CA0B1H;;AACA,MAAIkE,MAAM,GAAGC,KAAK,EAAlB;AACA,gDAAQC,GAAR,CAAY5E,KAAZ,EAAmB0E,MAAnB;AAEA,MAAIG,iBAAiB,GAAGjC,SAAS,iCAAKrC,KAAL;AAAYgB,IAAAA,EAAE,EAAEmD;AAAhB,KAAjC;AAEA,SAAO;AACLI,IAAAA,YAAY,kCACPjC,UAAU,CAACuB,eAAD,EAAkBS,iBAAlB,CADH;AAEV3E,MAAAA,IAAI,EAAE,SAFI;AAGV,0BAAoBgD,WAHV;AAIV7B,MAAAA,QAAQ,EAAEG;AAJA;AADP,GAAP;AAQD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/tabs/src/utils.ts","./packages/@react-aria/tabs/src/useTab.ts","./packages/@react-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/useTabList.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 {Key} from 'react';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T>, key: Key, role: string) {\n if (typeof key === 'string') {\n key = key.replace(/\\s+/g, '');\n }\n\n let baseId = tabsIds.get(state);\n return `${baseId}-${role}-${key}`;\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 {AriaTabProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tab.\n * When selected, the associated tab panel is shown.\n */\nexport function useTab<T>(\n props: AriaTabProps,\n state: TabListState<T>,\n ref: RefObject<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n return {\n tabProps: {\n ...itemProps,\n id: tabId,\n 'aria-selected': isSelected,\n 'aria-disabled': isDisabled || undefined,\n 'aria-controls': isSelected ? tabPanelId : undefined,\n tabIndex: isDisabled ? undefined : tabIndex,\n role: 'tab'\n }\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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for\n * the contents of a tab, and is shown when the tab is selected.\n */\nexport function useTabPanel<T>(props: AriaTabPanelProps, state: TabListState<T>, ref: RefObject<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\n // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.\n // Otherwise, tabbing from the focused tab should go directly to the first tabbable element\n // within the tabpanel.\n useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, state?.selectedKey, 'tabpanel');\n const tabPanelProps = useLabels({...props, id, 'aria-labelledby': generateId(state, state?.selectedKey, 'tab')});\n\n return {\n tabPanelProps: mergeProps(tabPanelProps, {\n tabIndex,\n role: 'tabpanel',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\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 {Collection, Direction, KeyboardDelegate, Orientation} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TabsKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private flipDirection: boolean;\n private disabledKeys: Set<Key>;\n private orientation: Orientation;\n\n constructor(collection: Collection<T>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {\n this.collection = collection;\n this.flipDirection = direction === 'rtl' && orientation === 'horizontal';\n this.orientation = orientation;\n this.disabledKeys = disabledKeys;\n }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getNextKey(key);\n }\n return null;\n }\n }\n\n getKeyAbove(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n\n getKeyBelow(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getNextKey(key);\n }\n return null;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (this.disabledKeys.has(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (this.disabledKeys.has(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\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 {AriaTabListProps} from '@react-types/tabs';\nimport {HTMLAttributes, RefObject, useMemo} from 'react';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {tabsIds} from './utils';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab list.\n * Tabs organize content into multiple sections and allow users to navigate between them.\n */\nexport function useTabList<T>(props: AriaTabListProps<T>, state: TabListState<T>, ref: RefObject<HTMLElement>): TabListAria {\n let {\n orientation = 'horizontal',\n keyboardActivation = 'automatic'\n } = props;\n let {\n collection,\n selectionManager: manager,\n disabledKeys\n } = state;\n let {direction} = useLocale();\n let delegate = useMemo(() => new TabsKeyboardDelegate(\n collection,\n direction,\n orientation,\n disabledKeys), [collection, disabledKeys, orientation, direction]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n selectOnFocus: keyboardActivation === 'automatic',\n disallowEmptySelection: true,\n scrollRef: ref\n });\n\n // Compute base id for all tabs\n let tabsId = useId();\n tabsIds.set(state, tabsId);\n\n let tabListLabelProps = useLabels({...props, id: tabsId});\n\n return {\n tabListProps: {\n ...mergeProps(collectionProps, tabListLabelProps),\n role: 'tablist',\n 'aria-orientation': orientation,\n tabIndex: undefined\n }\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","tabsIds","WeakMap","generateId","state","key","role","replace","baseId","get","useTab","props","ref","isDisabled","propsDisabled","selectionManager","manager","selectedKey","isSelected","disabledKeys","has","itemProps","useSelectableItem","tabId","tabPanelId","tabIndex","tabProps","id","undefined","useTabPanel","setTabIndex","useState","useLayoutEffect","current","update","walker","getFocusableTreeWalker","tabbable","nextNode","observer","MutationObserver","observe","subtree","childList","attributes","attributeFilter","disconnect","tabPanelProps","useLabels","mergeProps","TabsKeyboardDelegate","constructor","collection","direction","orientation","Set","flipDirection","getKeyLeftOf","getNextKey","getPreviousKey","getKeyRightOf","getKeyAbove","getKeyBelow","getFirstKey","getLastKey","getKeyAfter","getKeyBefore","useTabList","keyboardActivation","useLocale","delegate","useMemo","collectionProps","useSelectableCollection","keyboardDelegate","selectOnFocus","disallowEmptySelection","scrollRef","tabsId","useId","set","tabListLabelProps","tabListProps"],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -3,7 +3,6 @@ import { mergeProps, useLabels, useId } from "@react-aria/utils";
3
3
  import { useLayoutEffect, useState, useMemo } from "react";
4
4
  import { getFocusableTreeWalker } from "@react-aria/focus";
5
5
  import { useSelectableItem, useSelectableCollection } from "@react-aria/selection";
6
- import { usePress } from "@react-aria/interactions";
7
6
  import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
8
7
 
9
8
  /*
@@ -42,26 +41,22 @@ export function useTab(props, state, ref) {
42
41
  selectedKey
43
42
  } = state;
44
43
  let isSelected = key === selectedKey;
44
+ let isDisabled = propsDisabled || state.disabledKeys.has(key);
45
45
  let {
46
46
  itemProps
47
47
  } = useSelectableItem({
48
48
  selectionManager: manager,
49
49
  key,
50
- ref
51
- });
52
- let isDisabled = propsDisabled || state.disabledKeys.has(key);
53
- let {
54
- pressProps
55
- } = usePress(_babelRuntimeHelpersEsmExtends({}, itemProps, {
50
+ ref,
56
51
  isDisabled
57
- }));
52
+ });
58
53
  let tabId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tab');
59
54
  let tabPanelId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tabpanel');
60
55
  let {
61
56
  tabIndex
62
- } = pressProps;
57
+ } = itemProps;
63
58
  return {
64
- tabProps: _babelRuntimeHelpersEsmExtends({}, pressProps, {
59
+ tabProps: _babelRuntimeHelpersEsmExtends({}, itemProps, {
65
60
  id: tabId,
66
61
  'aria-selected': isSelected,
67
62
  'aria-disabled': isDisabled || undefined,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;;AAeO,MAAMA,gDAAO,GAAG,IAAIC,OAA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,IAAAA,aAAa,EAAEP,kBAAkB,KAAK,WAJQ;AAK9CQ,IAAAA,sBAAsB,EAAE,IALsB;AAM9CC,IAAAA,SAAS,EAAEnE;AANmC,GAAD,CAA/C,CAjB0H,CA0B1H;;AACA,MAAIoE,MAAM,GAAGC,KAAK,EAAlB;AACA,mDAAQC,GAAR,CAAY9E,KAAZ,EAAmB4E,MAAnB;AAEA,MAAIG,iBAAiB,GAAGjC,SAAS,oCAAKvC,KAAL;AAAYkB,IAAAA,EAAE,EAAEmD;AAAhB,KAAjC;AAEA,SAAO;AACLI,IAAAA,YAAY,qCACPjC,UAAU,CAACuB,eAAD,EAAkBS,iBAAlB,CADH;AAEV7E,MAAAA,IAAI,EAAE,SAFI;AAGV,0BAAoBkD,WAHV;AAIV7B,MAAAA,QAAQ,EAAEG;AAJA;AADP,GAAP;AAQD","sources":["./packages/@react-aria/tabs/src/utils.ts","./packages/@react-aria/tabs/src/useTab.ts","./packages/@react-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/useTabList.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T>, key: Key, role: string) {\n if (typeof key === 'string') {\n key = key.replace(/\\s+/g, '');\n }\n\n let baseId = tabsIds.get(state);\n return `${baseId}-${role}-${key}`;\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 {AriaTabProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {usePress} from '@react-aria/interactions';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tab.\n * When selected, the associated tab panel is shown.\n */\nexport function useTab<T>(\n props: AriaTabProps,\n state: TabListState<T>,\n ref: RefObject<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref\n });\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n\n let {pressProps} = usePress({...itemProps, isDisabled});\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = pressProps;\n\n return {\n tabProps: {\n ...pressProps,\n id: tabId,\n 'aria-selected': isSelected,\n 'aria-disabled': isDisabled || undefined,\n 'aria-controls': isSelected ? tabPanelId : undefined,\n tabIndex: isDisabled ? undefined : tabIndex,\n role: 'tab'\n }\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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for\n * the contents of a tab, and is shown when the tab is selected.\n */\nexport function useTabPanel<T>(props: AriaTabPanelProps, state: TabListState<T>, ref: RefObject<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\n // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.\n // Otherwise, tabbing from the focused tab should go directly to the first tabbable element\n // within the tabpanel.\n useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, state?.selectedKey, 'tabpanel');\n const tabPanelProps = useLabels({...props, id, 'aria-labelledby': generateId(state, state?.selectedKey, 'tab')});\n\n return {\n tabPanelProps: mergeProps(tabPanelProps, {\n tabIndex,\n role: 'tabpanel',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\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 {Collection, Direction, KeyboardDelegate, Orientation} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TabsKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private flipDirection: boolean;\n private disabledKeys: Set<Key>;\n private orientation: Orientation;\n\n constructor(collection: Collection<T>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {\n this.collection = collection;\n this.flipDirection = direction === 'rtl' && orientation === 'horizontal';\n this.orientation = orientation;\n this.disabledKeys = disabledKeys;\n }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getNextKey(key);\n }\n return null;\n }\n }\n\n getKeyAbove(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n\n getKeyBelow(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getNextKey(key);\n }\n return null;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (this.disabledKeys.has(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (this.disabledKeys.has(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\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 {AriaTabListProps} from '@react-types/tabs';\nimport {HTMLAttributes, RefObject, useMemo} from 'react';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {tabsIds} from './utils';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab list.\n * Tabs organize content into multiple sections and allow users to navigate between them.\n */\nexport function useTabList<T>(props: AriaTabListProps<T>, state: TabListState<T>, ref: RefObject<HTMLElement>): TabListAria {\n let {\n orientation = 'horizontal',\n keyboardActivation = 'automatic'\n } = props;\n let {\n collection,\n selectionManager: manager,\n disabledKeys\n } = state;\n let {direction} = useLocale();\n let delegate = useMemo(() => new TabsKeyboardDelegate(\n collection,\n direction,\n orientation,\n disabledKeys), [collection, disabledKeys, orientation, direction]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n selectOnFocus: keyboardActivation === 'automatic',\n disallowEmptySelection: true,\n scrollRef: ref\n });\n\n // Compute base id for all tabs\n let tabsId = useId();\n tabsIds.set(state, tabsId);\n\n let tabListLabelProps = useLabels({...props, id: tabsId});\n\n return {\n tabListProps: {\n ...mergeProps(collectionProps, tabListLabelProps),\n role: 'tablist',\n 'aria-orientation': orientation,\n tabIndex: undefined\n }\n };\n}\n"],"names":["tabsIds","WeakMap","generateId","state","key","role","replace","baseId","get","useTab","props","ref","isDisabled","propsDisabled","selectionManager","manager","selectedKey","isSelected","itemProps","useSelectableItem","disabledKeys","has","pressProps","usePress","tabId","tabPanelId","tabIndex","tabProps","id","undefined","useTabPanel","setTabIndex","useState","useLayoutEffect","current","update","walker","getFocusableTreeWalker","tabbable","nextNode","observer","MutationObserver","observe","subtree","childList","attributes","attributeFilter","disconnect","tabPanelProps","useLabels","mergeProps","TabsKeyboardDelegate","constructor","collection","direction","orientation","Set","flipDirection","getKeyLeftOf","getNextKey","getPreviousKey","getKeyRightOf","getKeyAbove","getKeyBelow","getFirstKey","getLastKey","getKeyAfter","getKeyBefore","useTabList","keyboardActivation","useLocale","delegate","useMemo","collectionProps","useSelectableCollection","keyboardDelegate","selectOnFocus","disallowEmptySelection","scrollRef","tabsId","useId","set","tabListLabelProps","tabListProps"],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;;AAeO,MAAMA,gDAAO,GAAG,IAAIC,OAAJ,EAAhB;;AAEA,SAASC,mDAAT,CAAuBC,KAAvB,EAA+CC,GAA/C,EAAyDC,IAAzD,EAAuE;AAC5E,MAAI,OAAOD,GAAP,KAAe,QAAnB,EAA6B;AAC3BA,IAAAA,GAAG,GAAGA,GAAG,CAACE,OAAJ,CAAY,MAAZ,EAAoB,EAApB,CAAN;AACD;;AAED,MAAIC,MAAM,GAAGP,gDAAO,CAACQ,GAAR,CAAYL,KAAZ,CAAb;AACA,SAAUI,MAAV,SAAoBF,IAApB,SAA4BD,GAA5B;AACD;;ACDD;;;;OAIO,SAASK,MAAT,CACLC,KADK,EAELP,KAFK,EAGLQ,GAHK,EAII;AACT,MAAI;AAACP,IAAAA,GAAD;AAAMQ,IAAAA,UAAU,EAA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abs/src/utils.ts","./packages/@react-aria/tabs/src/useTab.ts","./packages/@react-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/useTabList.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T>, key: Key, role: string) {\n if (typeof key === 'string') {\n key = key.replace(/\\s+/g, '');\n }\n\n let baseId = tabsIds.get(state);\n return `${baseId}-${role}-${key}`;\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 {AriaTabProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tab.\n * When selected, the associated tab panel is shown.\n */\nexport function useTab<T>(\n props: AriaTabProps,\n state: TabListState<T>,\n ref: RefObject<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n return {\n tabProps: {\n ...itemProps,\n id: tabId,\n 'aria-selected': isSelected,\n 'aria-disabled': isDisabled || undefined,\n 'aria-controls': isSelected ? tabPanelId : undefined,\n tabIndex: isDisabled ? undefined : tabIndex,\n role: 'tab'\n }\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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for\n * the contents of a tab, and is shown when the tab is selected.\n */\nexport function useTabPanel<T>(props: AriaTabPanelProps, state: TabListState<T>, ref: RefObject<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\n // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.\n // Otherwise, tabbing from the focused tab should go directly to the first tabbable element\n // within the tabpanel.\n useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, state?.selectedKey, 'tabpanel');\n const tabPanelProps = useLabels({...props, id, 'aria-labelledby': generateId(state, state?.selectedKey, 'tab')});\n\n return {\n tabPanelProps: mergeProps(tabPanelProps, {\n tabIndex,\n role: 'tabpanel',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\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 {Collection, Direction, KeyboardDelegate, Orientation} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TabsKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private flipDirection: boolean;\n private disabledKeys: Set<Key>;\n private orientation: Orientation;\n\n constructor(collection: Collection<T>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {\n this.collection = collection;\n this.flipDirection = direction === 'rtl' && orientation === 'horizontal';\n this.orientation = orientation;\n this.disabledKeys = disabledKeys;\n }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getNextKey(key);\n }\n return null;\n }\n }\n\n getKeyAbove(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n\n getKeyBelow(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getNextKey(key);\n }\n return null;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (this.disabledKeys.has(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (this.disabledKeys.has(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\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 {AriaTabListProps} from '@react-types/tabs';\nimport {HTMLAttributes, RefObject, useMemo} from 'react';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {tabsIds} from './utils';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab list.\n * Tabs organize content into multiple sections and allow users to navigate between them.\n */\nexport function useTabList<T>(props: AriaTabListProps<T>, state: TabListState<T>, ref: RefObject<HTMLElement>): TabListAria {\n let {\n orientation = 'horizontal',\n keyboardActivation = 'automatic'\n } = props;\n let {\n collection,\n selectionManager: manager,\n disabledKeys\n } = state;\n let {direction} = useLocale();\n let delegate = useMemo(() => new TabsKeyboardDelegate(\n collection,\n direction,\n orientation,\n disabledKeys), [collection, disabledKeys, orientation, direction]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n selectOnFocus: keyboardActivation === 'automatic',\n disallowEmptySelection: true,\n scrollRef: ref\n });\n\n // Compute base id for all tabs\n let tabsId = useId();\n tabsIds.set(state, tabsId);\n\n let tabListLabelProps = useLabels({...props, id: tabsId});\n\n return {\n tabListProps: {\n ...mergeProps(collectionProps, tabListLabelProps),\n role: 'tablist',\n 'aria-orientation': orientation,\n tabIndex: undefined\n }\n };\n}\n"],"names":["tabsIds","WeakMap","generateId","state","key","role","replace","baseId","get","useTab","props","ref","isDisabled","propsDisabled","selectionManager","manager","selectedKey","isSelected","disabledKeys","has","itemProps","useSelectableItem","tabId","tabPanelId","tabIndex","tabProps","id","undefined","useTabPanel","setTabIndex","useState","useLayoutEffect","current","update","walker","getFocusableTreeWalker","tabbable","nextNode","observer","MutationObserver","observe","subtree","childList","attributes","attributeFilter","disconnect","tabPanelProps","useLabels","mergeProps","TabsKeyboardDelegate","constructor","collection","direction","orientation","Set","flipDirection","getKeyLeftOf","getNextKey","getPreviousKey","getKeyRightOf","getKeyAbove","getKeyBelow","getFirstKey","getLastKey","getKeyAfter","getKeyBefore","useTabList","keyboardActivation","useLocale","delegate","useMemo","collectionProps","useSelectableCollection","keyboardDelegate","selectOnFocus","disallowEmptySelection","scrollRef","tabsId","useId","set","tabListLabelProps","tabListProps"],"version":3,"file":"module.js.map"}
@@ -1 +1 @@
1
- {"mappings":"A;A;A;ACmBA;IACE,iCAAiC;IACjC,QAAQ,EAAE,eAAe,WAAW,CAAC,CAAA;CACtC;AAED;A;A;GAGG;AACH,uBAAuB,CAAC,EACtB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,aAAa,CAAC,CAAC,EACtB,GAAG,EAAE,UAAU,WAAW,CAAC,GAC1B,OAAO,CA6BT;AC1CD;IACE,uCAAuC;IACvC,aAAa,EAAE,eAAe,WAAW,CAAC,CAAA;CAC3C;AAGD;A;A;GAGG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,YAAY,CA0C1H;AElDD;IACE,uCAAuC;IACvC,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAGD;A;A;GAGG;AACH,2BAA2B,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,WAAW,CAwC1H","sources":["./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/utils.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTab.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTabList.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/index.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":"A;A;A;ACkBA;IACE,iCAAiC;IACjC,QAAQ,EAAE,eAAe,WAAW,CAAC,CAAA;CACtC;AAED;A;A;GAGG;AACH,uBAAuB,CAAC,EACtB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,aAAa,CAAC,CAAC,EACtB,GAAG,EAAE,UAAU,WAAW,CAAC,GAC1B,OAAO,CA6BT;ACzCD;IACE,uCAAuC;IACvC,aAAa,EAAE,eAAe,WAAW,CAAC,CAAA;CAC3C;AAGD;A;A;GAGG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,YAAY,CA0C1H;AElDD;IACE,uCAAuC;IACvC,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAGD;A;A;GAGG;AACH,2BAA2B,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,WAAW,CAwC1H","sources":["./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/utils.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTab.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTabList.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/index.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/tabs",
3
- "version": "3.0.3-nightly.2949+ab0323af3",
3
+ "version": "3.0.3-nightly.2967+252940a26",
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.1263+ab0323af3",
22
- "@react-aria/i18n": "3.0.0-nightly.1263+ab0323af3",
23
- "@react-aria/interactions": "3.0.0-nightly.1263+ab0323af3",
24
- "@react-aria/selection": "3.0.0-nightly.1263+ab0323af3",
25
- "@react-aria/utils": "3.0.0-nightly.1263+ab0323af3",
26
- "@react-stately/list": "3.3.1-nightly.2949+ab0323af3",
27
- "@react-stately/tabs": "3.0.0-nightly.1263+ab0323af3",
28
- "@react-types/shared": "3.0.0-nightly.1263+ab0323af3",
29
- "@react-types/tabs": "3.0.2-nightly.2949+ab0323af3"
21
+ "@react-aria/focus": "3.0.0-nightly.1281+252940a26",
22
+ "@react-aria/i18n": "3.0.0-nightly.1281+252940a26",
23
+ "@react-aria/interactions": "3.0.0-nightly.1281+252940a26",
24
+ "@react-aria/selection": "3.0.0-nightly.1281+252940a26",
25
+ "@react-aria/utils": "3.0.0-nightly.1281+252940a26",
26
+ "@react-stately/list": "3.3.1-nightly.2967+252940a26",
27
+ "@react-stately/tabs": "3.0.0-nightly.1281+252940a26",
28
+ "@react-types/shared": "3.0.0-nightly.1281+252940a26",
29
+ "@react-types/tabs": "3.0.2-nightly.2967+252940a26"
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": "ab0323af3512117c9607304a66a33faf026929c9"
37
+ "gitHead": "252940a267857896b75c988a5cc0ec199e740fcb"
38
38
  }
package/src/useTab.ts CHANGED
@@ -14,7 +14,6 @@ import {AriaTabProps} from '@react-types/tabs';
14
14
  import {generateId} from './utils';
15
15
  import {HTMLAttributes, RefObject} from 'react';
16
16
  import {TabListState} from '@react-stately/tabs';
17
- import {usePress} from '@react-aria/interactions';
18
17
  import {useSelectableItem} from '@react-aria/selection';
19
18
 
20
19
  interface TabAria {
@@ -36,21 +35,21 @@ export function useTab<T>(
36
35
 
37
36
  let isSelected = key === selectedKey;
38
37
 
38
+ let isDisabled = propsDisabled || state.disabledKeys.has(key);
39
39
  let {itemProps} = useSelectableItem({
40
40
  selectionManager: manager,
41
41
  key,
42
- ref
42
+ ref,
43
+ isDisabled
43
44
  });
44
- let isDisabled = propsDisabled || state.disabledKeys.has(key);
45
45
 
46
- let {pressProps} = usePress({...itemProps, isDisabled});
47
46
  let tabId = generateId(state, key, 'tab');
48
47
  let tabPanelId = generateId(state, key, 'tabpanel');
49
- let {tabIndex} = pressProps;
48
+ let {tabIndex} = itemProps;
50
49
 
51
50
  return {
52
51
  tabProps: {
53
- ...pressProps,
52
+ ...itemProps,
54
53
  id: tabId,
55
54
  'aria-selected': isSelected,
56
55
  'aria-disabled': isDisabled || undefined,