@react-aria/tag 3.0.0-nightly.3175 → 3.0.0-rc.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/import.mjs +466 -0
- package/dist/main.js +273 -162
- package/dist/main.js.map +1 -1
- package/dist/module.js +272 -149
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +52 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -12
- package/src/TagKeyboardDelegate.ts +34 -46
- package/src/index.ts +7 -3
- package/src/useTag.ts +60 -52
- package/src/useTagGroup.ts +47 -20
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;MCgBa,yCAAmB,SAAY,2BAAoB;IAC9D,aAAa,CAAC,GAAQ,EAAE,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,CAAK,OAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG;IAChF,CAAC;IAED,YAAY,CAAC,GAAQ,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,CAAK,OAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG;IAChF,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,CAAC;QAChB,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG;QAC3C,EAAE,GAAG,SAAS,EACZ,MAAM;QAGR,EAA8D,AAA9D,4DAA8D;QAC9D,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,GACvB,GAAG,GAAG,SAAS,CAAC,SAAS;QAG3B,EAAqB,AAArB,mBAAqB;QACrB,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG;QAC1B,EAAE,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;YAChB,EAA8E,AAA9E,4EA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-aria/tag/src/index.ts","packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/intl/*.js","packages/@react-aria/tag/intl/ar-AE.json","packages/@react-aria/tag/intl/bg-BG.json","packages/@react-aria/tag/intl/cs-CZ.json","packages/@react-aria/tag/intl/da-DK.json","packages/@react-aria/tag/intl/de-DE.json","packages/@react-aria/tag/intl/el-GR.json","packages/@react-aria/tag/intl/en-US.json","packages/@react-aria/tag/intl/es-ES.json","packages/@react-aria/tag/intl/et-EE.json","packages/@react-aria/tag/intl/fi-FI.json","packages/@react-aria/tag/intl/fr-FR.json","packages/@react-aria/tag/intl/he-IL.json","packages/@react-aria/tag/intl/hr-HR.json","packages/@react-aria/tag/intl/hu-HU.json","packages/@react-aria/tag/intl/it-IT.json","packages/@react-aria/tag/intl/ja-JP.json","packages/@react-aria/tag/intl/ko-KR.json","packages/@react-aria/tag/intl/lt-LT.json","packages/@react-aria/tag/intl/lv-LV.json","packages/@react-aria/tag/intl/nb-NO.json","packages/@react-aria/tag/intl/nl-NL.json","packages/@react-aria/tag/intl/pl-PL.json","packages/@react-aria/tag/intl/pt-BR.json","packages/@react-aria/tag/intl/pt-PT.json","packages/@react-aria/tag/intl/ro-RO.json","packages/@react-aria/tag/intl/ru-RU.json","packages/@react-aria/tag/intl/sk-SK.json","packages/@react-aria/tag/intl/sl-SI.json","packages/@react-aria/tag/intl/sr-SP.json","packages/@react-aria/tag/intl/sv-SE.json","packages/@react-aria/tag/intl/tr-TR.json","packages/@react-aria/tag/intl/uk-UA.json","packages/@react-aria/tag/intl/zh-CN.json","packages/@react-aria/tag/intl/zh-TW.json","packages/@react-aria/tag/src/useTagGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './TagKeyboardDelegate';\nexport * from './useTag';\nexport * from './useTagGroup';\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 {GridCollection} from '@react-types/grid';\nimport {GridKeyboardDelegate} from '@react-aria/grid';\nimport {Key} from 'react';\n\nexport class TagKeyboardDelegate<T> extends GridKeyboardDelegate<T, GridCollection<T>> {\n getKeyRightOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);\n }\n\n getKeyLeftOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyBelow(key) : this.getKeyAbove(key);\n }\n\n getKeyBelow(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the next item\n key = this.findNextKey(key);\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n let newKey = [...item.childNodes][startItem.index].key;\n\n // Ignore disabled tags\n if (this.disabledKeys.has(newKey)) {\n return this.getKeyBelow(newKey);\n }\n return newKey;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyAbove(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key);\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n let newKey = [...item.childNodes][startItem.index].key;\n\n // ignore disabled tags\n if (this.disabledKeys.has(newKey)) {\n return this.getKeyAbove(newKey);\n }\n return newKey;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\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 {ButtonHTMLAttributes, HTMLAttributes, KeyboardEvent} from 'react';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {GridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {TagProps} from '@react-types/tag';\nimport {useGridCell, useGridRow} from '@react-aria/grid';\nimport {useMessageFormatter} from '@react-aria/i18n';\n\n\nexport interface TagAria {\n labelProps: HTMLAttributes<HTMLElement>,\n tagProps: HTMLAttributes<HTMLElement>,\n tagRowProps: HTMLAttributes<HTMLElement>,\n clearButtonProps: ButtonHTMLAttributes<HTMLButtonElement>\n}\n\nexport function useTag(props: TagProps<any>, state: GridState<any, any>): TagAria {\n let {isFocused} = props;\n const {\n isDisabled,\n isRemovable,\n onRemove,\n children,\n item,\n tagRef,\n tagRowRef\n } = props;\n const formatMessage = useMessageFormatter(intlMessages);\n const removeString = formatMessage('remove');\n const labelId = useId();\n const buttonId = useId();\n\n let {rowProps} = useGridRow({\n node: item\n }, state, tagRowRef);\n // Don't want the row to be focusable or accessible via keyboard\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {tabIndex, ...otherRowProps} = rowProps;\n\n let {gridCellProps} = useGridCell({\n node: [...item.childNodes][0],\n focusMode: 'cell'\n }, state, tagRef);\n\n function onKeyDown(e: KeyboardEvent<HTMLElement>) {\n if (e.key === 'Delete' || e.key === 'Backspace') {\n onRemove(children, e);\n e.preventDefault();\n }\n }\n const pressProps = {\n onPress: e => onRemove?.(children, e)\n };\n\n isFocused = isFocused || state.selectionManager.focusedKey === item.childNodes[0].key;\n let domProps = filterDOMProps(props);\n return {\n clearButtonProps: mergeProps(pressProps, {\n 'aria-label': removeString,\n 'aria-labelledby': `${buttonId} ${labelId}`,\n id: buttonId,\n isDisabled\n }),\n labelProps: {\n id: labelId\n },\n tagRowProps: otherRowProps,\n tagProps: mergeProps(domProps, gridCellProps, {\n 'aria-disabled': isDisabled,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label'],\n onKeyDown: !isDisabled && isRemovable ? onKeyDown : null,\n tabIndex: (isFocused || state.selectionManager.focusedKey == null) && !isDisabled ? 0 : -1,\n onFocus() {\n state.selectionManager.setFocusedKey(item.childNodes[0].key);\n },\n ref: tagRef\n })\n };\n}\n","const _temp0 = require(\"./ar-AE.json\");\nconst _temp1 = require(\"./bg-BG.json\");\nconst _temp2 = require(\"./cs-CZ.json\");\nconst _temp3 = require(\"./da-DK.json\");\nconst _temp4 = require(\"./de-DE.json\");\nconst _temp5 = require(\"./el-GR.json\");\nconst _temp6 = require(\"./en-US.json\");\nconst _temp7 = require(\"./es-ES.json\");\nconst _temp8 = require(\"./et-EE.json\");\nconst _temp9 = require(\"./fi-FI.json\");\nconst _temp10 = require(\"./fr-FR.json\");\nconst _temp11 = require(\"./he-IL.json\");\nconst _temp12 = require(\"./hr-HR.json\");\nconst _temp13 = require(\"./hu-HU.json\");\nconst _temp14 = require(\"./it-IT.json\");\nconst _temp15 = require(\"./ja-JP.json\");\nconst _temp16 = require(\"./ko-KR.json\");\nconst _temp17 = require(\"./lt-LT.json\");\nconst _temp18 = require(\"./lv-LV.json\");\nconst _temp19 = require(\"./nb-NO.json\");\nconst _temp20 = require(\"./nl-NL.json\");\nconst _temp21 = require(\"./pl-PL.json\");\nconst _temp22 = require(\"./pt-BR.json\");\nconst _temp23 = require(\"./pt-PT.json\");\nconst _temp24 = require(\"./ro-RO.json\");\nconst _temp25 = require(\"./ru-RU.json\");\nconst _temp26 = require(\"./sk-SK.json\");\nconst _temp27 = require(\"./sl-SI.json\");\nconst _temp28 = require(\"./sr-SP.json\");\nconst _temp29 = require(\"./sv-SE.json\");\nconst _temp30 = require(\"./tr-TR.json\");\nconst _temp31 = require(\"./uk-UA.json\");\nconst _temp32 = require(\"./zh-CN.json\");\nconst _temp33 = require(\"./zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}","{\n \"remove\": \"إزالة\"\n}\n","{\n \"remove\": \"Премахване\"\n}\n","{\n \"remove\": \"Odebrat\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Entfernen\"\n}\n","{\n \"remove\": \"Κατάργηση\"\n}\n","{\n \"remove\": \"Remove\"\n}\n","{\n \"remove\": \"Quitar\"\n}\n","{\n \"remove\": \"Eemalda\"\n}\n","{\n \"remove\": \"Poista\"\n}\n","{\n \"remove\": \"Supprimer\"\n}\n","{\n \"remove\": \"הסר\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Eltávolítás\"\n}\n","{\n \"remove\": \"Rimuovi\"\n}\n","{\n \"remove\": \"削除\"\n}\n","{\n \"remove\": \"제거\"\n}\n","{\n \"remove\": \"Pašalinti\"\n}\n","{\n \"remove\": \"Noņemt\"\n}\n","{\n \"remove\": \"Fjern\"\n}\n","{\n \"remove\": \"Verwijderen\"\n}\n","{\n \"remove\": \"Usuń\"\n}\n","{\n \"remove\": \"Remover\"\n}\n","{\n \"remove\": \"Eliminar\"\n}\n","{\n \"remove\": \"Îndepărtaţi\"\n}\n","{\n \"remove\": \"Удалить\"\n}\n","{\n \"remove\": \"Odstrániť\"\n}\n","{\n \"remove\": \"Odstrani\"\n}\n","{\n \"remove\": \"Ukloni\"\n}\n","{\n \"remove\": \"Ta bort\"\n}\n","{\n \"remove\": \"Kaldır\"\n}\n","{\n \"remove\": \"Видалити\"\n}\n","{\n \"remove\": \"删除\"\n}\n","{\n \"remove\": \"移除\"\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 {DOMProps} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, Key, ReactNode, useState} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\n\ninterface AriaTagGroupProps extends DOMProps {\n children: ReactNode,\n disabledKeys?: Iterable<Key>,\n isDisabled?: boolean,\n isReadOnly?: boolean, // removes close button\n validationState?: 'valid' | 'invalid'\n}\n\ninterface TagGroupAria {\n tagGroupProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useTagGroup(props: AriaTagGroupProps, listState): TagGroupAria {\n let {isDisabled} = props;\n let [isFocusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: setFocusWithin\n });\n let allKeys = [...listState.collection.getKeys()];\n if (!allKeys.some(key => !listState.disabledKeys.has(key))) {\n isDisabled = true;\n }\n let domProps = filterDOMProps(props);\n return {\n tagGroupProps: mergeProps(domProps, {\n 'aria-atomic': false,\n 'aria-relevant': 'additions',\n 'aria-live': isFocusWithin ? 'polite' : 'off',\n 'aria-disabled': isDisabled === true,\n ...focusWithinProps\n } as HTMLAttributes<HTMLElement>)\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,AAGO,MAAM;IASX,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW;IACpC;IAEA,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU;IACnC;IAEA,cAAc,GAAQ,EAAE;QACtB,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI;IACjF;IAEA,aAAa,GAAQ,EAAE;QACrB,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI;IACjF;IAEA,YAAY,GAAG,EAAE;QACf,IAAI,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,UAAU,EAAE;IAC3F,IAAI,cAAC,WAAU,cAAE,WAAU,oBAAE,iBAAgB,qBAAE,kBAAiB,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7E,IAAI,aAAC,UAAS,EAAC,GAAG,CAAA,GAAA,kBAAW,AAAD,EAAE;QAAC,GAAG,KAAK;QAAE,GAAG,UAAU;0BAAE;IAAgB,GAAG,OAAO;IAElF,iEAAiE;IACjE,OAAO,UAAU,QAAQ;IAEzB,IAAI,CAAC,eAAe,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE,KAAK;IACpD,IAAI,oBAAC,iBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAc,AAAD,EAAE;QACtC,qBAAqB;IACvB;IACA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE;IAC9B,OAAO;QACL,WAAW,CAAA,GAAA,iBAAU,AAAD,EAAE,WAAW,UAAU;YACzC,MAAM,MAAM,UAAU,CAAC,IAAI,GAAG,SAAS,IAAI;YAC3C,eAAe,KAAK;YACpB,iBAAiB;YACjB,aAAa,gBAAgB,WAAW,KAAK;YAC7C,GAAG,gBAAgB;YACnB,GAAG,UAAU;QACf;oBACA;0BACA;2BACA;IACF;AACF;;","sources":["packages/@react-aria/tag/src/index.ts","packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/intl/*.js","packages/@react-aria/tag/intl/ar-AE.json","packages/@react-aria/tag/intl/bg-BG.json","packages/@react-aria/tag/intl/cs-CZ.json","packages/@react-aria/tag/intl/da-DK.json","packages/@react-aria/tag/intl/de-DE.json","packages/@react-aria/tag/intl/el-GR.json","packages/@react-aria/tag/intl/en-US.json","packages/@react-aria/tag/intl/es-ES.json","packages/@react-aria/tag/intl/et-EE.json","packages/@react-aria/tag/intl/fi-FI.json","packages/@react-aria/tag/intl/fr-FR.json","packages/@react-aria/tag/intl/he-IL.json","packages/@react-aria/tag/intl/hr-HR.json","packages/@react-aria/tag/intl/hu-HU.json","packages/@react-aria/tag/intl/it-IT.json","packages/@react-aria/tag/intl/ja-JP.json","packages/@react-aria/tag/intl/ko-KR.json","packages/@react-aria/tag/intl/lt-LT.json","packages/@react-aria/tag/intl/lv-LV.json","packages/@react-aria/tag/intl/nb-NO.json","packages/@react-aria/tag/intl/nl-NL.json","packages/@react-aria/tag/intl/pl-PL.json","packages/@react-aria/tag/intl/pt-BR.json","packages/@react-aria/tag/intl/pt-PT.json","packages/@react-aria/tag/intl/ro-RO.json","packages/@react-aria/tag/intl/ru-RU.json","packages/@react-aria/tag/intl/sk-SK.json","packages/@react-aria/tag/intl/sl-SI.json","packages/@react-aria/tag/intl/sr-SP.json","packages/@react-aria/tag/intl/sv-SE.json","packages/@react-aria/tag/intl/tr-TR.json","packages/@react-aria/tag/intl/uk-UA.json","packages/@react-aria/tag/intl/zh-CN.json","packages/@react-aria/tag/intl/zh-TW.json","packages/@react-aria/tag/src/useTagGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nexport {useTag} from './useTag';\nexport {useTagGroup} from './useTagGroup';\n\nexport type {TagProps} from '@react-types/tag';\nexport type {TagGroupAria, AriaTagGroupProps} from './useTagGroup';\nexport type {AriaTagProps, TagAria} from './useTag';\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} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TagKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private direction: Direction;\n\n constructor(collection: Collection<T>, direction: Direction) {\n this.collection = collection;\n this.direction = direction;\n }\n\n getFirstKey() {\n return this.collection.getFirstKey();\n }\n\n getLastKey() {\n return this.collection.getLastKey();\n }\n \n getKeyRightOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);\n }\n\n getKeyLeftOf(key: Key) {\n return this.direction === 'rtl' ? this.getKeyBelow(key) : this.getKeyAbove(key);\n }\n\n getKeyBelow(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // Find the next item\n key = this.collection.getKeyAfter(key);\n\n if (key != null) {\n return key;\n } else {\n return this.collection.getFirstKey();\n }\n }\n\n getKeyAbove(key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // Find the previous item\n key = this.collection.getKeyBefore(key);\n if (key != null) {\n return key;\n } else {\n return this.collection.getLastKey();\n }\n }\n\n getKeyPageAbove(key) {\n return this.getKeyAbove(key);\n }\n\n getKeyPageBelow(key) {\n return this.getKeyBelow(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 {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, DOMProps, FocusableElement} from '@react-types/shared';\nimport {chain, filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {KeyboardEvent, RefObject} from 'react';\nimport type {TagGroupState} from '@react-stately/tag';\nimport {TagProps} from '@react-types/tag';\nimport {useGridListItem} from '@react-aria/gridlist';\nimport {useInteractionModality} from '@react-aria/interactions';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n\nexport interface TagAria {\n /** Props for the tag visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the tag cell element. */\n gridCellProps: DOMAttributes,\n /** Props for the tag row element. */\n rowProps: DOMAttributes,\n /** Props for the tag remove button. */\n removeButtonProps: AriaButtonProps\n}\n\nexport interface AriaTagProps<T> extends TagProps<T>, DOMProps, AriaLabelingProps {}\n\n/**\n * Provides the behavior and accessibility implementation for a tag component.\n * @param props - Props to be applied to the tag.\n * @param state - State for the tag group, as returned by `useTagGroupState`.\n * @param ref - A ref to a DOM element for the tag.\n */\nexport function useTag<T>(props: AriaTagProps<T>, state: TagGroupState<T>, ref: RefObject<FocusableElement>): TagAria {\n let {\n allowsRemoving,\n item\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages);\n let labelId = useId();\n let buttonId = useId();\n\n let {rowProps, gridCellProps} = useGridListItem({\n node: item\n }, state, ref);\n\n // We want the group to handle keyboard navigation between tags.\n delete rowProps.onKeyDownCapture;\n\n let onRemove = chain(props.onRemove, state.onRemove);\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Delete' || e.key === 'Backspace') {\n onRemove(item.key);\n e.preventDefault();\n }\n };\n\n let modality: string = useInteractionModality();\n if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {\n modality = 'touch';\n }\n let description = allowsRemoving && (modality === 'keyboard' || modality === 'virtual') ? stringFormatter.format('removeDescription') : '';\n let descProps = useDescription(description);\n\n let domProps = filterDOMProps(props);\n let isFocused = item.key === state.selectionManager.focusedKey;\n return {\n removeButtonProps: {\n 'aria-label': stringFormatter.format('removeButtonLabel', {label: item.textValue}),\n 'aria-labelledby': `${buttonId} ${labelId}`,\n id: buttonId,\n onPress: () => allowsRemoving && onRemove ? onRemove(item.key) : null,\n excludeFromTabOrder: true\n },\n labelProps: {\n id: labelId\n },\n rowProps: {\n ...rowProps,\n tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1,\n onKeyDown: allowsRemoving ? onKeyDown : null,\n 'aria-describedby': descProps['aria-describedby']\n },\n gridCellProps: mergeProps(domProps, gridCellProps, {\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label']\n })\n };\n}\n","const _temp0 = require(\"./ar-AE.json\");\nconst _temp1 = require(\"./bg-BG.json\");\nconst _temp2 = require(\"./cs-CZ.json\");\nconst _temp3 = require(\"./da-DK.json\");\nconst _temp4 = require(\"./de-DE.json\");\nconst _temp5 = require(\"./el-GR.json\");\nconst _temp6 = require(\"./en-US.json\");\nconst _temp7 = require(\"./es-ES.json\");\nconst _temp8 = require(\"./et-EE.json\");\nconst _temp9 = require(\"./fi-FI.json\");\nconst _temp10 = require(\"./fr-FR.json\");\nconst _temp11 = require(\"./he-IL.json\");\nconst _temp12 = require(\"./hr-HR.json\");\nconst _temp13 = require(\"./hu-HU.json\");\nconst _temp14 = require(\"./it-IT.json\");\nconst _temp15 = require(\"./ja-JP.json\");\nconst _temp16 = require(\"./ko-KR.json\");\nconst _temp17 = require(\"./lt-LT.json\");\nconst _temp18 = require(\"./lv-LV.json\");\nconst _temp19 = require(\"./nb-NO.json\");\nconst _temp20 = require(\"./nl-NL.json\");\nconst _temp21 = require(\"./pl-PL.json\");\nconst _temp22 = require(\"./pt-BR.json\");\nconst _temp23 = require(\"./pt-PT.json\");\nconst _temp24 = require(\"./ro-RO.json\");\nconst _temp25 = require(\"./ru-RU.json\");\nconst _temp26 = require(\"./sk-SK.json\");\nconst _temp27 = require(\"./sl-SI.json\");\nconst _temp28 = require(\"./sr-SP.json\");\nconst _temp29 = require(\"./sv-SE.json\");\nconst _temp30 = require(\"./tr-TR.json\");\nconst _temp31 = require(\"./uk-UA.json\");\nconst _temp32 = require(\"./zh-CN.json\");\nconst _temp33 = require(\"./zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}","{\n \"removeButtonLabel\": \"إزالة\",\n \"removeDescription\": \"اضغط على مفتاح DELETE لإزالة علامة.\"\n}\n","{\n \"removeButtonLabel\": \"Премахване\",\n \"removeDescription\": \"Натиснете Delete, за да премахнете маркера.\"\n}\n","{\n \"removeButtonLabel\": \"Odebrat\",\n \"removeDescription\": \"Stisknutím klávesy Delete odeberete značku.\"\n}\n","{\n \"removeButtonLabel\": \"Fjern\",\n \"removeDescription\": \"Tryk på Slet for at fjerne tag.\"\n}\n","{\n \"removeButtonLabel\": \"Entfernen\",\n \"removeDescription\": \"Auf „Löschen“ drücken, um das Tag zu entfernen.\"\n}\n","{\n \"removeButtonLabel\": \"Κατάργηση\",\n \"removeDescription\": \"Πατήστε Διαγραφή για να καταργήσετε την ετικέτα.\"\n}\n","{ \n \"removeDescription\": \"Press Delete to remove tag.\",\n \"removeButtonLabel\": \"Remove\"\n}\n","{\n \"removeButtonLabel\": \"Quitar\",\n \"removeDescription\": \"Pulse Eliminar para quitar la etiqueta.\"\n}\n","{\n \"removeButtonLabel\": \"Eemalda\",\n \"removeDescription\": \"Sildi eemaldamiseks vajutage kustutusklahvi Delete.\"\n}\n","{\n \"removeButtonLabel\": \"Poista\",\n \"removeDescription\": \"Poista tunniste painamalla Poista-painiketta.\"\n}\n","{\n \"removeButtonLabel\": \"Supprimer\",\n \"removeDescription\": \"Appuyez sur Supprimer pour supprimer l’étiquette.\"\n}\n","{\n \"removeButtonLabel\": \"הסר\",\n \"removeDescription\": \"לחץ על מחק כדי להסיר תג.\"\n}\n","{\n \"removeButtonLabel\": \"Ukloni\",\n \"removeDescription\": \"Pritisnite Delete za uklanjanje oznake.\"\n}\n","{\n \"removeButtonLabel\": \"Eltávolítás\",\n \"removeDescription\": \"Nyomja meg a Delete billentyűt a címke eltávolításához.\"\n}\n","{\n \"removeButtonLabel\": \"Rimuovi\",\n \"removeDescription\": \"Premi Elimina per rimuovere il tag.\"\n}\n","{\n \"removeButtonLabel\": \"削除\",\n \"removeDescription\": \"タグを削除するには、Delete キーを押します。\"\n}\n","{\n \"removeButtonLabel\": \"제거\",\n \"removeDescription\": \"태그를 제거하려면 Delete 키를 누르십시오.\"\n}\n","{\n \"removeButtonLabel\": \"Pašalinti\",\n \"removeDescription\": \"Norėdami pašalinti žymą, paspauskite „Delete“ klavišą.\"\n}\n","{\n \"removeButtonLabel\": \"Noņemt\",\n \"removeDescription\": \"Nospiediet Delete [Dzēst], lai noņemtu tagu.\"\n}\n","{\n \"removeButtonLabel\": \"Fjern\",\n \"removeDescription\": \"Trykk på Slett for å fjerne taggen.\"\n}\n","{\n \"removeButtonLabel\": \"Verwijderen\",\n \"removeDescription\": \"Druk op Verwijderen om de tag te verwijderen.\"\n}\n","{\n \"removeButtonLabel\": \"Usuń\",\n \"removeDescription\": \"Naciśnij Usuń, aby usunąć znacznik.\"\n}\n","{\n \"removeButtonLabel\": \"Remover\",\n \"removeDescription\": \"Pressione Delete para remover a tag.\"\n}\n","{\n \"removeButtonLabel\": \"Eliminar\",\n \"removeDescription\": \"Prima Delete para eliminar a tag.\"\n}\n","{\n \"removeButtonLabel\": \"Îndepărtaţi\",\n \"removeDescription\": \"Apăsați pe Delete (Ștergere) pentru a elimina eticheta.\"\n}\n","{\n \"removeButtonLabel\": \"Удалить\",\n \"removeDescription\": \"Нажмите DELETE, чтобы удалить тег.\"\n}\n","{\n \"removeButtonLabel\": \"Odstrániť\",\n \"removeDescription\": \"Ak chcete odstrániť značku, stlačte kláves Delete.\"\n}\n","{\n \"removeButtonLabel\": \"Odstrani\",\n \"removeDescription\": \"Pritisnite Delete, da odstranite oznako.\"\n}\n","{\n \"removeButtonLabel\": \"Ukloni\",\n \"removeDescription\": \"Pritisnite Obriši da biste uklonili oznaku.\"\n}\n","{\n \"removeButtonLabel\": \"Ta bort\",\n \"removeDescription\": \"Tryck på Radera för att ta bort taggen.\"\n}\n","{\n \"removeButtonLabel\": \"Kaldır\",\n \"removeDescription\": \"Etiketi kaldırmak için Sil tuşuna basın.\"\n}\n","{\n \"removeButtonLabel\": \"Вилучити\",\n \"removeDescription\": \"Натисніть Delete, щоб вилучити тег.\"\n}\n","{\n \"removeButtonLabel\": \"删除\",\n \"removeDescription\": \"按下“删除”以删除标记。\"\n}\n","{\n \"removeButtonLabel\": \"移除\",\n \"removeDescription\": \"按 Delete 鍵以移除標記。\"\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 {AriaLabelingProps, DOMAttributes, DOMProps, Validation} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {RefObject, useState} from 'react';\nimport {TagGroupProps} from '@react-types/tag';\nimport type {TagGroupState} from '@react-stately/tag';\nimport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useGridList} from '@react-aria/gridlist';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface TagGroupAria {\n /** Props for the tag grouping element. */\n gridProps: DOMAttributes,\n /** Props for the tag group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the tag group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the tag group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\nexport interface AriaTagGroupProps<T> extends TagGroupProps<T>, DOMProps, AriaLabelingProps, Validation {\n /**\n * An optional keyboard delegate to handle arrow key navigation,\n * to override the default.\n */\n keyboardDelegate?: TagKeyboardDelegate<T>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tag group component.\n * A tag group is a focusable list of labels, categories, keywords, or other items, with support for keyboard navigation and removal.\n * @param props - Props to be applied to the tag group.\n * @param state - State for the tag group, as returned by `useTagGroupState`.\n * @param ref - A ref to a DOM element for the tag group.\n */\nexport function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState<T>, ref: RefObject<HTMLElement>): TagGroupAria {\n let {direction} = useLocale();\n let keyboardDelegate = props.keyboardDelegate || new TagKeyboardDelegate(state.collection, direction);\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField(props);\n let {gridProps} = useGridList({...props, ...fieldProps, keyboardDelegate}, state, ref);\n\n // Don't want the grid to be focusable or accessible via keyboard\n delete gridProps.tabIndex;\n\n let [isFocusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: setFocusWithin\n });\n let domProps = filterDOMProps(props);\n return {\n gridProps: mergeProps(gridProps, domProps, {\n role: state.collection.size ? 'grid' : null,\n 'aria-atomic': false,\n 'aria-relevant': 'additions',\n 'aria-live': isFocusWithin ? 'polite' : 'off',\n ...focusWithinProps,\n ...fieldProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,32 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { TagProps } from "@react-types/tag";
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Collection, Direction, KeyboardDelegate, AriaLabelingProps, DOMAttributes, DOMProps, FocusableElement, Validation } from "@react-types/shared";
|
|
2
|
+
import { Key, RefObject } from "react";
|
|
3
|
+
import { AriaButtonProps } from "@react-types/button";
|
|
4
|
+
import { TagGroupState } from "@react-stately/tag";
|
|
5
|
+
import { TagProps, TagGroupProps } from "@react-types/tag";
|
|
6
|
+
export class TagKeyboardDelegate<T> implements KeyboardDelegate {
|
|
7
|
+
constructor(collection: Collection<T>, direction: Direction);
|
|
8
|
+
getFirstKey(): Key;
|
|
9
|
+
getLastKey(): Key;
|
|
8
10
|
getKeyRightOf(key: Key): any;
|
|
9
11
|
getKeyLeftOf(key: Key): any;
|
|
10
12
|
getKeyBelow(key: any): any;
|
|
11
13
|
getKeyAbove(key: any): any;
|
|
14
|
+
getKeyPageAbove(key: any): any;
|
|
15
|
+
getKeyPageBelow(key: any): any;
|
|
12
16
|
}
|
|
13
17
|
export interface TagAria {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
/** Props for the tag visible label (if any). */
|
|
19
|
+
labelProps: DOMAttributes;
|
|
20
|
+
/** Props for the tag cell element. */
|
|
21
|
+
gridCellProps: DOMAttributes;
|
|
22
|
+
/** Props for the tag row element. */
|
|
23
|
+
rowProps: DOMAttributes;
|
|
24
|
+
/** Props for the tag remove button. */
|
|
25
|
+
removeButtonProps: AriaButtonProps;
|
|
18
26
|
}
|
|
19
|
-
export
|
|
20
|
-
interface AriaTagGroupProps extends DOMProps {
|
|
21
|
-
children: ReactNode;
|
|
22
|
-
disabledKeys?: Iterable<Key>;
|
|
23
|
-
isDisabled?: boolean;
|
|
24
|
-
isReadOnly?: boolean;
|
|
25
|
-
validationState?: 'valid' | 'invalid';
|
|
27
|
+
export interface AriaTagProps<T> extends TagProps<T>, DOMProps, AriaLabelingProps {
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Provides the behavior and accessibility implementation for a tag component.
|
|
31
|
+
* @param props - Props to be applied to the tag.
|
|
32
|
+
* @param state - State for the tag group, as returned by `useTagGroupState`.
|
|
33
|
+
* @param ref - A ref to a DOM element for the tag.
|
|
34
|
+
*/
|
|
35
|
+
export function useTag<T>(props: AriaTagProps<T>, state: TagGroupState<T>, ref: RefObject<FocusableElement>): TagAria;
|
|
36
|
+
export interface TagGroupAria {
|
|
37
|
+
/** Props for the tag grouping element. */
|
|
38
|
+
gridProps: DOMAttributes;
|
|
39
|
+
/** Props for the tag group's visible label (if any). */
|
|
40
|
+
labelProps: DOMAttributes;
|
|
41
|
+
/** Props for the tag group description element, if any. */
|
|
42
|
+
descriptionProps: DOMAttributes;
|
|
43
|
+
/** Props for the tag group error message element, if any. */
|
|
44
|
+
errorMessageProps: DOMAttributes;
|
|
29
45
|
}
|
|
30
|
-
export
|
|
46
|
+
export interface AriaTagGroupProps<T> extends TagGroupProps<T>, DOMProps, AriaLabelingProps, Validation {
|
|
47
|
+
/**
|
|
48
|
+
* An optional keyboard delegate to handle arrow key navigation,
|
|
49
|
+
* to override the default.
|
|
50
|
+
*/
|
|
51
|
+
keyboardDelegate?: TagKeyboardDelegate<T>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Provides the behavior and accessibility implementation for a tag group component.
|
|
55
|
+
* A tag group is a focusable list of labels, categories, keywords, or other items, with support for keyboard navigation and removal.
|
|
56
|
+
* @param props - Props to be applied to the tag group.
|
|
57
|
+
* @param state - State for the tag group, as returned by `useTagGroupState`.
|
|
58
|
+
* @param ref - A ref to a DOM element for the tag group.
|
|
59
|
+
*/
|
|
60
|
+
export function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState<T>, ref: RefObject<HTMLElement>): TagGroupAria;
|
|
61
|
+
export type { TagProps } from '@react-types/tag';
|
|
31
62
|
|
|
32
63
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;AAeA,iCAAiC,CAAC,CAAE,YAAW,gBAAgB;gBAIjD,UAAU,EAAE,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;IAK3D,WAAW;IAIX,UAAU;IAIV,aAAa,CAAC,GAAG,EAAE,GAAG;IAItB,YAAY,CAAC,GAAG,EAAE,GAAG;IAIrB,WAAW,CAAC,GAAG,KAAA;IAgBf,WAAW,CAAC,GAAG,KAAA;IAef,eAAe,CAAC,GAAG,KAAA;IAInB,eAAe,CAAC,GAAG,KAAA;CAGpB;ACrDD;IACE,gDAAgD;IAChD,UAAU,EAAE,aAAa,CAAC;IAC1B,sCAAsC;IACtC,aAAa,EAAE,aAAa,CAAC;IAC7B,qCAAqC;IACrC,QAAQ,EAAE,aAAa,CAAC;IACxB,uCAAuC;IACvC,iBAAiB,EAAE,eAAe,CAAA;CACnC;AAED,8BAA8B,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB;CAAG;AAEpF;;;;;GAKG;AACH,uBAAuB,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,OAAO,CAwDpH;AC7ED;IACE,0CAA0C;IAC1C,SAAS,EAAE,aAAa,CAAC;IACzB,wDAAwD;IACxD,UAAU,EAAE,aAAa,CAAC;IAC1B,2DAA2D;IAC3D,gBAAgB,EAAE,aAAa,CAAC;IAChC,6DAA6D;IAC7D,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED,mCAAmC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU;IACrG;;;OAGG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAA;CAC1C;AAED;;;;;;GAMG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,YAAY,CA2B9H;AC5DD,YAAY,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC","sources":["packages/@react-aria/tag/src/packages/@react-aria/tag/src/TagKeyboardDelegate.ts","packages/@react-aria/tag/src/packages/@react-aria/tag/src/useTag.ts","packages/@react-aria/tag/src/packages/@react-aria/tag/src/useTagGroup.ts","packages/@react-aria/tag/src/packages/@react-aria/tag/src/index.ts","packages/@react-aria/tag/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {TagKeyboardDelegate} from './TagKeyboardDelegate';\nexport {useTag} from './useTag';\nexport {useTagGroup} from './useTagGroup';\n\nexport type {TagProps} from '@react-types/tag';\nexport type {TagGroupAria, AriaTagGroupProps} from './useTagGroup';\nexport type {AriaTagProps, TagAria} from './useTag';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/tag",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -17,21 +22,23 @@
|
|
|
17
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@react-aria/
|
|
22
|
-
"@react-aria/
|
|
23
|
-
"@react-aria/
|
|
24
|
-
"@react-aria/utils": "3.
|
|
25
|
-
"@react-stately/
|
|
26
|
-
"@react-
|
|
27
|
-
"@react-types/
|
|
28
|
-
"@react-types/
|
|
25
|
+
"@react-aria/gridlist": "^3.3.0",
|
|
26
|
+
"@react-aria/i18n": "^3.7.1",
|
|
27
|
+
"@react-aria/interactions": "^3.15.0",
|
|
28
|
+
"@react-aria/label": "^3.5.1",
|
|
29
|
+
"@react-aria/utils": "^3.16.0",
|
|
30
|
+
"@react-stately/list": "^3.8.0",
|
|
31
|
+
"@react-stately/tag": "3.0.0-rc.0",
|
|
32
|
+
"@react-types/button": "^3.7.2",
|
|
33
|
+
"@react-types/shared": "^3.18.0",
|
|
34
|
+
"@react-types/tag": "3.0.0-rc.0",
|
|
35
|
+
"@swc/helpers": "^0.4.14"
|
|
29
36
|
},
|
|
30
37
|
"peerDependencies": {
|
|
31
|
-
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
38
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
32
39
|
},
|
|
33
40
|
"publishConfig": {
|
|
34
41
|
"access": "public"
|
|
35
42
|
},
|
|
36
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "9d1ba9bd8ebcd63bf3495ade16d349bcb71795ce"
|
|
37
44
|
}
|
|
@@ -10,11 +10,26 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {GridKeyboardDelegate} from '@react-aria/grid';
|
|
13
|
+
import {Collection, Direction, KeyboardDelegate} from '@react-types/shared';
|
|
15
14
|
import {Key} from 'react';
|
|
16
15
|
|
|
17
|
-
export class TagKeyboardDelegate<T>
|
|
16
|
+
export class TagKeyboardDelegate<T> implements KeyboardDelegate {
|
|
17
|
+
private collection: Collection<T>;
|
|
18
|
+
private direction: Direction;
|
|
19
|
+
|
|
20
|
+
constructor(collection: Collection<T>, direction: Direction) {
|
|
21
|
+
this.collection = collection;
|
|
22
|
+
this.direction = direction;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getFirstKey() {
|
|
26
|
+
return this.collection.getFirstKey();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getLastKey() {
|
|
30
|
+
return this.collection.getLastKey();
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
getKeyRightOf(key: Key) {
|
|
19
34
|
return this.direction === 'rtl' ? this.getKeyAbove(key) : this.getKeyBelow(key);
|
|
20
35
|
}
|
|
@@ -29,30 +44,13 @@ export class TagKeyboardDelegate<T> extends GridKeyboardDelegate<T, GridCollecti
|
|
|
29
44
|
return;
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
// If focus was on a cell, start searching from the parent row
|
|
33
|
-
if (this.isCell(startItem)) {
|
|
34
|
-
key = startItem.parentKey;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
47
|
// Find the next item
|
|
38
|
-
key = this.
|
|
39
|
-
if (key != null) {
|
|
40
|
-
// If focus was on a cell, focus the cell with the same index in the next row.
|
|
41
|
-
if (this.isCell(startItem)) {
|
|
42
|
-
let item = this.collection.getItem(key);
|
|
43
|
-
let newKey = [...item.childNodes][startItem.index].key;
|
|
48
|
+
key = this.collection.getKeyAfter(key);
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return newKey;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Otherwise, focus the next row
|
|
53
|
-
if (this.focusMode === 'row') {
|
|
54
|
-
return key;
|
|
55
|
-
}
|
|
50
|
+
if (key != null) {
|
|
51
|
+
return key;
|
|
52
|
+
} else {
|
|
53
|
+
return this.collection.getFirstKey();
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
|
|
@@ -62,30 +60,20 @@ export class TagKeyboardDelegate<T> extends GridKeyboardDelegate<T, GridCollecti
|
|
|
62
60
|
return;
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
// If focus is on a cell, start searching from the parent row
|
|
66
|
-
if (this.isCell(startItem)) {
|
|
67
|
-
key = startItem.parentKey;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
63
|
// Find the previous item
|
|
71
|
-
key = this.
|
|
64
|
+
key = this.collection.getKeyBefore(key);
|
|
72
65
|
if (key != null) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
return key;
|
|
67
|
+
} else {
|
|
68
|
+
return this.collection.getLastKey();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
return newKey;
|
|
83
|
-
}
|
|
72
|
+
getKeyPageAbove(key) {
|
|
73
|
+
return this.getKeyAbove(key);
|
|
74
|
+
}
|
|
84
75
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return key;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
76
|
+
getKeyPageBelow(key) {
|
|
77
|
+
return this.getKeyBelow(key);
|
|
90
78
|
}
|
|
91
79
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
13
|
+
export {TagKeyboardDelegate} from './TagKeyboardDelegate';
|
|
14
|
+
export {useTag} from './useTag';
|
|
15
|
+
export {useTagGroup} from './useTagGroup';
|
|
16
|
+
|
|
17
|
+
export type {TagProps} from '@react-types/tag';
|
|
18
|
+
export type {TagGroupAria, AriaTagGroupProps} from './useTagGroup';
|
|
19
|
+
export type {AriaTagProps, TagAria} from './useTag';
|
package/src/useTag.ts
CHANGED
|
@@ -10,84 +10,92 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import {AriaButtonProps} from '@react-types/button';
|
|
14
|
+
import {AriaLabelingProps, DOMAttributes, DOMProps, FocusableElement} from '@react-types/shared';
|
|
15
|
+
import {chain, filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
|
|
16
16
|
// @ts-ignore
|
|
17
17
|
import intlMessages from '../intl/*.json';
|
|
18
|
+
import {KeyboardEvent, RefObject} from 'react';
|
|
19
|
+
import type {TagGroupState} from '@react-stately/tag';
|
|
18
20
|
import {TagProps} from '@react-types/tag';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
+
import {useGridListItem} from '@react-aria/gridlist';
|
|
22
|
+
import {useInteractionModality} from '@react-aria/interactions';
|
|
23
|
+
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
21
24
|
|
|
22
25
|
|
|
23
26
|
export interface TagAria {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
/** Props for the tag visible label (if any). */
|
|
28
|
+
labelProps: DOMAttributes,
|
|
29
|
+
/** Props for the tag cell element. */
|
|
30
|
+
gridCellProps: DOMAttributes,
|
|
31
|
+
/** Props for the tag row element. */
|
|
32
|
+
rowProps: DOMAttributes,
|
|
33
|
+
/** Props for the tag remove button. */
|
|
34
|
+
removeButtonProps: AriaButtonProps
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export interface AriaTagProps<T> extends TagProps<T>, DOMProps, AriaLabelingProps {}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Provides the behavior and accessibility implementation for a tag component.
|
|
41
|
+
* @param props - Props to be applied to the tag.
|
|
42
|
+
* @param state - State for the tag group, as returned by `useTagGroupState`.
|
|
43
|
+
* @param ref - A ref to a DOM element for the tag.
|
|
44
|
+
*/
|
|
45
|
+
export function useTag<T>(props: AriaTagProps<T>, state: TagGroupState<T>, ref: RefObject<FocusableElement>): TagAria {
|
|
46
|
+
let {
|
|
47
|
+
allowsRemoving,
|
|
48
|
+
item
|
|
40
49
|
} = props;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const buttonId = useId();
|
|
50
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
51
|
+
let labelId = useId();
|
|
52
|
+
let buttonId = useId();
|
|
45
53
|
|
|
46
|
-
let {rowProps} =
|
|
54
|
+
let {rowProps, gridCellProps} = useGridListItem({
|
|
47
55
|
node: item
|
|
48
|
-
}, state,
|
|
49
|
-
// Don't want the row to be focusable or accessible via keyboard
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
-
let {tabIndex, ...otherRowProps} = rowProps;
|
|
56
|
+
}, state, ref);
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
focusMode: 'cell'
|
|
56
|
-
}, state, tagRef);
|
|
58
|
+
// We want the group to handle keyboard navigation between tags.
|
|
59
|
+
delete rowProps.onKeyDownCapture;
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
let onRemove = chain(props.onRemove, state.onRemove);
|
|
62
|
+
|
|
63
|
+
let onKeyDown = (e: KeyboardEvent) => {
|
|
59
64
|
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
60
|
-
onRemove(
|
|
65
|
+
onRemove(item.key);
|
|
61
66
|
e.preventDefault();
|
|
62
67
|
}
|
|
63
|
-
}
|
|
64
|
-
const pressProps = {
|
|
65
|
-
onPress: e => onRemove?.(children, e)
|
|
66
68
|
};
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
let modality: string = useInteractionModality();
|
|
71
|
+
if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {
|
|
72
|
+
modality = 'touch';
|
|
73
|
+
}
|
|
74
|
+
let description = allowsRemoving && (modality === 'keyboard' || modality === 'virtual') ? stringFormatter.format('removeDescription') : '';
|
|
75
|
+
let descProps = useDescription(description);
|
|
76
|
+
|
|
69
77
|
let domProps = filterDOMProps(props);
|
|
78
|
+
let isFocused = item.key === state.selectionManager.focusedKey;
|
|
70
79
|
return {
|
|
71
|
-
|
|
72
|
-
'aria-label':
|
|
80
|
+
removeButtonProps: {
|
|
81
|
+
'aria-label': stringFormatter.format('removeButtonLabel', {label: item.textValue}),
|
|
73
82
|
'aria-labelledby': `${buttonId} ${labelId}`,
|
|
74
83
|
id: buttonId,
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
onPress: () => allowsRemoving && onRemove ? onRemove(item.key) : null,
|
|
85
|
+
excludeFromTabOrder: true
|
|
86
|
+
},
|
|
77
87
|
labelProps: {
|
|
78
88
|
id: labelId
|
|
79
89
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
rowProps: {
|
|
91
|
+
...rowProps,
|
|
92
|
+
tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1,
|
|
93
|
+
onKeyDown: allowsRemoving ? onKeyDown : null,
|
|
94
|
+
'aria-describedby': descProps['aria-describedby']
|
|
95
|
+
},
|
|
96
|
+
gridCellProps: mergeProps(domProps, gridCellProps, {
|
|
83
97
|
'aria-errormessage': props['aria-errormessage'],
|
|
84
|
-
'aria-label': props['aria-label']
|
|
85
|
-
onKeyDown: !isDisabled && isRemovable ? onKeyDown : null,
|
|
86
|
-
tabIndex: (isFocused || state.selectionManager.focusedKey == null) && !isDisabled ? 0 : -1,
|
|
87
|
-
onFocus() {
|
|
88
|
-
state.selectionManager.setFocusedKey(item.childNodes[0].key);
|
|
89
|
-
},
|
|
90
|
-
ref: tagRef
|
|
98
|
+
'aria-label': props['aria-label']
|
|
91
99
|
})
|
|
92
100
|
};
|
|
93
101
|
}
|