@react-spectrum/s2
Version:
Spectrum 2 UI components in React
1 lines • 2.01 kB
Source Map (JSON)
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAUD,IAAI,8BAAQ,IAAI;AAKT,MAAM,4CAAqB,CAAA,GAAA,+CAAkB,EAAE,YAAY,CAAC,OAAgC,KAAK;IACtG,gGAAgG;IAChG,yDAAyD;IACzD,+CAA+C;IAC/C,IAAI,SAAS,4BAAM,GAAG,CAAC;IACvB,IAAI,CAAC,QAAQ;QACX,uBACE,gCAAC,CAAA,GAAA,kCAAO;YAAE,SAAS;sBAChB,MAAM,QAAQ;;QAGnB,4BAAM,GAAG,CAAC,MAAM;IAClB;IACA,OAAO;AACT","sources":["packages/@react-spectrum/s2/src/SkeletonCollection.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {createLeafComponent} from '@react-aria/collections';\nimport {ReactNode} from 'react';\nimport {Skeleton} from './Skeleton';\n\nexport interface SkeletonCollectionProps {\n children: () => ReactNode\n}\n\nlet cache = new WeakMap();\n\n/**\n * A SkeletonCollection generates placeholder content within a collection component such as CardView.\n */\nexport const SkeletonCollection = createLeafComponent('skeleton', (props: SkeletonCollectionProps, ref, node) => {\n // Cache rendering based on node object identity. This allows the children function to randomize\n // its content (e.g. heights) and preserve on re-renders.\n // TODO: do we need a `dependencies` prop here?\n let cached = cache.get(node);\n if (!cached) {\n cached = (\n <Skeleton isLoading>\n {props.children()}\n </Skeleton>\n );\n cache.set(node, cached);\n }\n return cached;\n});\n"],"names":[],"version":3,"file":"SkeletonCollection.cjs.map"}