react-aria
Version:
Spectrum UI components in React
1 lines • 1.94 kB
Source Map (JSON)
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAeM,MAAM,4CAAkD,IAAI;AAKnE,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,OAAO,CAAC,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY;IAC5D,IAAI,OAAO,0CAAS,GAAG,CAAC;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM;IAGlB,OAAO,GAAG,KAAK,EAAE,CAAC,QAAQ,EAAE,mCAAa,UAAU;AACrD","sources":["packages/react-aria/src/listbox/utils.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-types/shared';\nimport {ListState} from 'react-stately/useListState';\n\ninterface ListData {\n id?: string;\n shouldSelectOnPressUp?: boolean;\n shouldFocusOnHover?: boolean;\n shouldUseVirtualFocus?: boolean;\n isVirtualized?: boolean;\n onAction?: (key: Key) => void;\n linkBehavior?: 'action' | 'selection' | 'override';\n}\n\nexport const listData: WeakMap<ListState<unknown>, ListData> = new WeakMap<\n ListState<unknown>,\n ListData\n>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n"],"names":[],"version":3,"file":"utils.cjs.map"}