@radix-ui/react-collection 1.2.1-rc.1791984254107 → 1.2.1

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/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/collection-legacy.tsx", "../src/collection.tsx", "../src/ordered-dictionary.ts"],
4
- "sourcesContent": ["'use client';\nexport { createCollection } from './collection-legacy';\nexport type { CollectionProps } from './collection-legacy';\n\nexport { createCollection as unstable_createCollection } from './collection';\nexport type {\n CollectionSlotProps as unstable_CollectionSlotProps,\n CollectionDict as unstable_CollectionDict,\n} from './collection';\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionProps extends SlotProps {\n scope: any;\n}\n\n// We have resorted to returning slots directly rather than exposing primitives that can then\n// be slotted like `<CollectionItem as={Slot}>\u2026</CollectionItem>`.\n// This is because we encountered issues with generic types that cannot be statically analysed\n// due to creating them dynamically via createCollection.\n\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData = {},\n>(name: string) {\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n type ContextValue = {\n collectionRef: React.RefObject<CollectionElement | null>;\n itemMap: Map<\n React.RefObject<ItemElement | null>,\n { ref: React.RefObject<ItemElement | null> } & ItemData\n >;\n };\n\n const [CollectionProviderImpl, useCollectionContext] = createCollectionContext<ContextValue>(\n PROVIDER_NAME,\n { collectionRef: { current: null }, itemMap: new Map() },\n );\n\n const CollectionProvider: React.FC<{ children?: React.ReactNode | undefined; scope: any }> = (\n props,\n ) => {\n const { scope, children } = props;\n const ref = React.useRef<CollectionElement>(null);\n const itemMap = React.useRef<ContextValue['itemMap']>(new Map()).current;\n return (\n <CollectionProviderImpl scope={scope} itemMap={itemMap} collectionRef={ref}>\n {children}\n </CollectionProviderImpl>\n );\n };\n\n CollectionProvider.displayName = PROVIDER_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = ItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const context = useCollectionContext(ITEM_SLOT_NAME, scope);\n\n React.useEffect(() => {\n context.itemMap.set(ref, { ref, ...(itemData as unknown as ItemData) });\n return () => void context.itemMap.delete(ref);\n });\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const context = useCollectionContext(name + 'CollectionConsumer', scope);\n\n const getItems = React.useCallback(() => {\n const collectionNode = context.collectionRef.current;\n if (!collectionNode) return [];\n const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n const items = Array.from(context.itemMap.values());\n const orderedItems = items.sort(\n (a, b) => orderedNodes.indexOf(a.ref.current!) - orderedNodes.indexOf(b.ref.current!),\n );\n return orderedItems;\n }, [context.collectionRef, context.itemMap]);\n\n return getItems;\n }\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n useCollection,\n createCollectionScope,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionProps };\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport type { EntryOf } from './ordered-dictionary';\nimport { OrderedDict, type ReadOnlyOrderedDict } from './ordered-dictionary';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionSlotProps extends SlotProps {\n scope: any;\n}\n\ninterface BaseItemData {\n id?: string | undefined;\n}\n\ntype ItemDataWithElement<\n ItemData extends BaseItemData,\n ItemElement extends HTMLElement,\n> = ItemData & {\n element: ItemElement;\n};\n\ntype BaseCollectionDict<\n ItemElement extends HTMLElement,\n ItemData extends BaseItemData,\n> = OrderedDict<ItemElement, ItemDataWithElement<ItemData, ItemElement>>;\n\ntype CollectionDict<ItemElement extends HTMLElement, ItemData> = ReadOnlyOrderedDict<\n ItemElement,\n ItemDataWithElement<ItemData & BaseItemData, ItemElement>\n>;\n\n/**\n * Creates a collection that tracks its items in document order and exposes them\n * during render via `useCollection`.\n *\n * Item data passed to `ItemSlot` (every prop other than `scope` and `children`)\n * must be referentially stable across renders. It is compared shallowly, and any\n * change re-registers the item and replaces the item map. Memoize objects,\n * arrays and callbacks with `useMemo` / `useCallback`, or define them outside of\n * render.\n */\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData extends {} = {},\n>(name: string) {\n type AllItemData = ItemData & BaseItemData;\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n interface CollectionStableContextValue {\n collectionElementRef: React.Ref<CollectionElement | null>;\n collectionElementRefObject: React.RefObject<CollectionElement | null>;\n setCollection: React.Dispatch<\n React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>\n >;\n getCollection: () => CollectionDict<ItemElement, AllItemData>;\n registryRef: React.RefObject<BaseCollectionDict<ItemElement, AllItemData>>;\n }\n\n interface CollectionStatefulContextValue {\n collectionElement: CollectionElement | null;\n collection: CollectionDict<ItemElement, AllItemData>;\n }\n\n const [CollectionStableContextProvider, useStableCollectionContext] =\n createCollectionContext<CollectionStableContextValue>(PROVIDER_NAME);\n CollectionStableContextProvider.displayName = name + 'CollectionStableContextProvider';\n\n const [CollectionStatefulContextProvider, useStatefulCollectionContext] =\n createCollectionContext<CollectionStatefulContextValue>(PROVIDER_NAME);\n CollectionStatefulContextProvider.displayName = name + 'CollectionStatefulContextProvider';\n\n type CollectionState = [\n ItemMap: BaseCollectionDict<ItemElement, AllItemData>,\n SetItemMap: React.Dispatch<React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>>,\n ];\n\n const CollectionProvider: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state?: CollectionState | undefined;\n }> = ({ state, ...props }) => {\n return state ? (\n <CollectionProviderImpl {...props} state={state} />\n ) : (\n <CollectionInit {...props} />\n );\n };\n CollectionProvider.displayName = PROVIDER_NAME;\n\n const CollectionInit: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n }> = (props) => {\n const state = useInitCollection();\n return <CollectionProviderImpl {...props} state={state} />;\n };\n CollectionInit.displayName = name + 'CollectionInit';\n\n const CollectionProviderImpl: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state: CollectionState;\n }> = (props) => {\n const { scope, children, state } = props;\n const ref = React.useRef<CollectionElement>(null);\n const [collectionElement, setCollectionElement] = React.useState<CollectionElement | null>(\n null,\n );\n const composeRefs = useComposedRefs(ref, setCollectionElement);\n const [collection, setCollection] = state;\n\n // Written only during commit (from item ref callbacks and layout effects),\n // so it never includes items from renders that React discards.\n const registryRef = React.useRef<BaseCollectionDict<ItemElement, AllItemData>>(\n new OrderedDict(),\n );\n const getCollection = React.useCallback(() => {\n const registry = registryRef.current;\n if (!isInDocumentOrder(registry)) {\n registry.sort(sortByDocumentPosition);\n }\n return registry;\n }, []);\n\n React.useEffect(() => {\n if (!collectionElement) {\n return;\n }\n\n const observer = getChildListObserver(() => {\n setCollection((map) => {\n const sorted = map.toSorted(sortByDocumentPosition);\n const orderChanged = sorted.some(([key], index) => map.keyAt(index) !== key);\n\n return orderChanged ? sorted : map;\n });\n });\n observer.observe(collectionElement, {\n childList: true,\n subtree: true,\n });\n return () => {\n observer.disconnect();\n };\n }, [collectionElement, setCollection]);\n\n return (\n <CollectionStableContextProvider\n scope={scope}\n collectionElementRef={composeRefs}\n collectionElementRefObject={ref}\n getCollection={getCollection}\n setCollection={setCollection}\n registryRef={registryRef}\n >\n <CollectionStatefulContextProvider\n scope={scope}\n collectionElement={collectionElement}\n collection={collection}\n >\n {children}\n </CollectionStatefulContextProvider>\n </CollectionStableContextProvider>\n );\n };\n\n CollectionProviderImpl.displayName = name + 'CollectionProviderImpl';\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionSlotProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useStableCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionElementRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = AllItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n /**\n * Registers its child element as a collection item. Every prop other than\n * `scope` and `children` is item data and must be referentially stable across\n * renders (see `createCollection`).\n */\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const context = useStableCollectionContext(ITEM_SLOT_NAME, scope);\n\n const { setCollection, registryRef } = context;\n\n const itemDataRef = React.useRef(itemData);\n if (!shallowEqual(itemDataRef.current, itemData)) {\n itemDataRef.current = itemData;\n }\n const memoizedItemData = itemDataRef.current;\n\n // TODO: Once React 19 is the minimum supported version, return a cleanup\n // function that unregisters `node` instead of handling `null`, which\n // depends on `ref.current` still holding the previous element.\n const registerElement = React.useCallback(\n (node: ItemElement | null) => {\n const registry = registryRef.current;\n if (node) {\n registry.set(node, {\n ...(itemDataRef.current as unknown as AllItemData),\n element: node,\n });\n } else if (ref.current) {\n registry.delete(ref.current);\n }\n },\n [registryRef],\n );\n const composedRefs = useComposedRefs(forwardedRef, registerElement, ref);\n\n useLayoutEffect(() => {\n const node = ref.current;\n const registry = registryRef.current;\n if (node && registry.has(node)) {\n registry.set(node, { ...(memoizedItemData as unknown as AllItemData), element: node });\n }\n }, [memoizedItemData, registryRef]);\n\n const registeredRef = React.useRef<{\n element: ItemElement;\n itemData: typeof memoizedItemData;\n } | null>(null);\n\n React.useEffect(() => {\n const element = ref.current;\n const registered = registeredRef.current;\n if (\n (registered?.element ?? null) === element &&\n (!element || registered?.itemData === memoizedItemData)\n ) {\n return;\n }\n\n registeredRef.current = element ? { element, itemData: memoizedItemData } : null;\n setCollection((map) => {\n const next = new OrderedDict(map);\n if (registered && registered.element !== element) {\n next.delete(registered.element);\n }\n if (element) {\n next.set(element, { ...(memoizedItemData as unknown as AllItemData), element });\n }\n return next.sort(sortByDocumentPosition);\n });\n });\n\n React.useEffect(() => {\n return () => {\n const registered = registeredRef.current;\n registeredRef.current = null;\n if (!registered) {\n return;\n }\n setCollection((map) => {\n if (!map.has(registered.element)) {\n return map;\n }\n const next = new OrderedDict(map);\n next.delete(registered.element);\n return next;\n });\n };\n }, [setCollection]);\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs as any}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useInitCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useInitCollection() {\n return React.useState<BaseCollectionDict<ItemElement, AllItemData>>(new OrderedDict());\n }\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const { collection } = useStatefulCollectionContext(name + 'CollectionConsumer', scope);\n return collection;\n }\n\n function useGetCollection(scope: any) {\n const { getCollection } = useStableCollectionContext(name + 'CollectionConsumer', scope);\n return getCollection;\n }\n\n const functions = {\n createCollectionScope,\n useCollection,\n useGetCollection,\n useInitCollection,\n };\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n functions,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionSlotProps, CollectionDict };\n\nfunction shallowEqual(a: any, b: any) {\n if (a === b) return true;\n if (typeof a !== 'object' || typeof b !== 'object') return false;\n if (a == null || b == null) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\n if (a[key] !== b[key]) return false;\n }\n return true;\n}\n\nfunction isElementPreceding(a: Element, b: Element) {\n return !!(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\nfunction isInDocumentOrder<E extends HTMLElement, T extends BaseItemData>(\n dict: BaseCollectionDict<E, T>,\n) {\n let previous: Element | undefined;\n for (const element of dict.keys()) {\n if (previous) {\n const position = previous.compareDocumentPosition(element);\n if (\n !(position & Node.DOCUMENT_POSITION_DISCONNECTED) &&\n position & Node.DOCUMENT_POSITION_PRECEDING\n ) {\n return false;\n }\n }\n previous = element;\n }\n return true;\n}\n\nfunction sortByDocumentPosition<E extends HTMLElement, T extends BaseItemData>(\n a: EntryOf<BaseCollectionDict<E, T>>,\n b: EntryOf<BaseCollectionDict<E, T>>,\n) {\n return !a[1].element || !b[1].element\n ? 0\n : isElementPreceding(a[1].element, b[1].element)\n ? -1\n : 1;\n}\n\nfunction getChildListObserver(callback: () => void) {\n const observer = new MutationObserver((mutationsList) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'childList') {\n callback();\n return;\n }\n }\n });\n\n return observer;\n}\n", "// Not a real member because it shouldn't be accessible, but the super class\n// calls `set` which needs to read the instanciation state, so it can't be a\n// private member.\nconst __instanciated = new WeakMap<OrderedDict<any, any>, boolean>();\nexport class OrderedDict<K, V> extends Map<K, V> {\n #keys: K[];\n\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);\n constructor(entries?: readonly (readonly [K, V])[] | null) {\n super(entries);\n this.#keys = [...super.keys()];\n __instanciated.set(this, true);\n }\n\n set(key: K, value: V) {\n if (__instanciated.get(this) && !this.has(key)) {\n this.#keys.push(key);\n }\n super.set(key, value);\n return this;\n }\n\n /**\n * Sets a key-value pair so that it ends up at the given index.\n * - Existing keys are moved\n * - Negative indices count from the end of the resulting dictionary, so\n * inserting at -1 makes the item the last one, -2 the second to last, etc.\n * - Out-of-range indices are clamped\n */\n insert(index: number, key: K, value: V) {\n const has = this.has(key);\n const finalSize = has ? this.size : this.size + 1;\n const relativeIndex = toSafeInteger(index);\n const targetIndex =\n relativeIndex >= 0\n ? Math.min(relativeIndex, finalSize - 1)\n : Math.max(finalSize + relativeIndex, 0);\n\n if (has ? this.#keys.indexOf(key) === targetIndex : targetIndex === this.size) {\n this.set(key, value);\n return this;\n }\n\n const keys = this.#keys.filter((existingKey) => existingKey !== key);\n keys.splice(targetIndex, 0, key);\n const entries = keys.map((entryKey): [K, V] => [\n entryKey,\n entryKey === key ? value : this.get(entryKey)!,\n ]);\n this.clear();\n for (const [entryKey, entryValue] of entries) {\n this.set(entryKey, entryValue);\n }\n return this;\n }\n\n with(index: number, key: K, value: V) {\n const copy = new OrderedDict(this);\n copy.insert(index, key, value);\n return copy;\n }\n\n before(key: K) {\n const index = this.#keys.indexOf(key) - 1;\n if (index < 0) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position before the given key.\n */\n setBefore(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex < index ? index - 1 : index;\n return this.insert(targetIndex, newKey, value);\n }\n\n after(key: K) {\n let index = this.#keys.indexOf(key);\n index = index === -1 || index === this.size - 1 ? -1 : index + 1;\n if (index === -1) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position after the given key.\n */\n setAfter(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex <= index ? index : index + 1;\n return this.insert(targetIndex, newKey, value);\n }\n\n first() {\n return this.entryAt(0);\n }\n\n last() {\n return this.entryAt(-1);\n }\n\n clear() {\n this.#keys = [];\n return super.clear();\n }\n\n delete(key: K) {\n const deleted = super.delete(key);\n if (deleted) {\n this.#keys.splice(this.#keys.indexOf(key), 1);\n }\n return deleted;\n }\n\n deleteAt(index: number) {\n const key = this.keyAt(index);\n if (key !== undefined) {\n return this.delete(key);\n }\n return false;\n }\n\n at(index: number) {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return this.get(key);\n }\n }\n\n entryAt(index: number): [K, V] | undefined {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return [key, this.get(key)!];\n }\n }\n\n indexOf(key: K) {\n return this.#keys.indexOf(key);\n }\n\n keyAt(index: number) {\n return at(this.#keys, index);\n }\n\n from(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.at(dest);\n }\n\n keyFrom(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.keyAt(dest);\n }\n\n find(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return entry;\n }\n index++;\n }\n return undefined;\n }\n\n findIndex(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return index;\n }\n index++;\n }\n return -1;\n }\n\n filter<KK extends K, VV extends V>(\n predicate: (entry: [K, V], index: number, dict: OrderedDict<K, V>) => entry is [KK, VV],\n thisArg?: any,\n ): OrderedDict<KK, VV>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ): OrderedDict<K, V>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n const entries: Array<[K, V]> = [];\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n entries.push(entry);\n }\n index++;\n }\n return new OrderedDict(entries);\n }\n\n map<U>(\n callbackfn: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => U,\n thisArg?: any,\n ): OrderedDict<K, U> {\n const entries: [K, U][] = [];\n let index = 0;\n for (const entry of this) {\n entries.push([entry[0], Reflect.apply(callbackfn, thisArg, [entry, index, this])]);\n index++;\n }\n return new OrderedDict(entries);\n }\n\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduce<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduce<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let index = 0;\n let accumulator = initialValue as U;\n for (const entry of this) {\n if (index === 0 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n index++;\n }\n return accumulator;\n }\n\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduceRight<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduceRight<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let accumulator = initialValue as U;\n for (let index = this.size - 1; index >= 0; index--) {\n const entry = this.entryAt(index)!;\n if (index === this.size - 1 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n }\n return accumulator;\n }\n\n /**\n * Sorts the dictionary in place. This method mutates the dictionary and\n * returns a reference to the same object\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n sort(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.sort requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n this.clear();\n for (const [key, value] of entries) {\n this.set(key, value);\n }\n return this;\n }\n\n /**\n * Returns a copy of the dictionary with its elements sorted.\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n toSorted(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.toSorted requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n return new OrderedDict(entries);\n }\n\n toReversed(): OrderedDict<K, V> {\n const reversed = new OrderedDict<K, V>();\n for (let index = this.size - 1; index >= 0; index--) {\n const key = this.keyAt(index)!;\n const element = this.get(key)!;\n reversed.set(key, element);\n }\n return reversed;\n }\n\n toSpliced(start: number, deleteCount?: number): OrderedDict<K, V>;\n toSpliced(start: number, deleteCount: number, ...items: [K, V][]): OrderedDict<K, V>;\n\n toSpliced(...args: [start: number, deleteCount: number, ...items: [K, V][]]) {\n const entries = [...this.entries()];\n entries.splice(...args);\n return new OrderedDict(entries);\n }\n\n slice(start?: number, end?: number) {\n const result = new OrderedDict<K, V>();\n for (const key of this.#keys.slice(start, end)) {\n result.set(key, this.get(key)!);\n }\n return result;\n }\n\n every(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (!Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return false;\n }\n index++;\n }\n return true;\n }\n\n some(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return true;\n }\n index++;\n }\n return false;\n }\n}\n\nexport type KeyOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<infer K, any> ? K : never;\nexport type ValueOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<any, infer V> ? V : never;\nexport type EntryOf<D extends OrderedDict<any, any>> = [KeyOf<D>, ValueOf<D>];\nexport type KeyFrom<E extends EntryOf<any>> = E[0];\nexport type ValueFrom<E extends EntryOf<any>> = E[1];\n\nfunction at<T>(array: ArrayLike<T>, index: number): T | undefined {\n if ('at' in Array.prototype) {\n return Array.prototype.at.call(array, index);\n }\n const actualIndex = toSafeIndex(array, index);\n return actualIndex === -1 ? undefined : array[actualIndex];\n}\n\nfunction toSafeIndex(array: ArrayLike<any>, index: number) {\n const length = array.length;\n const relativeIndex = toSafeInteger(index);\n const actualIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;\n return actualIndex < 0 || actualIndex >= length ? -1 : actualIndex;\n}\n\nfunction toSafeInteger(number: number) {\n // eslint-disable-next-line no-self-compare\n return number !== number || number === 0 ? 0 : Math.trunc(number);\n}\n\nexport type ReadOnlyOrderedDict<K, V> = Omit<\n OrderedDict<K, V>,\n 'set' | 'insert' | 'setBefore' | 'setAfter' | 'clear' | 'delete' | 'deleteAt' | 'sort'\n>;\n"],
4
+ "sourcesContent": ["'use client';\nexport { createCollection } from './collection-legacy.js';\nexport type { CollectionProps } from './collection-legacy.js';\n\nexport { createCollection as unstable_createCollection } from './collection.js';\nexport type {\n CollectionSlotProps as unstable_CollectionSlotProps,\n CollectionDict as unstable_CollectionDict,\n} from './collection.js';\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionProps extends SlotProps {\n scope: any;\n}\n\n// We have resorted to returning slots directly rather than exposing primitives that can then\n// be slotted like `<CollectionItem as={Slot}>\u2026</CollectionItem>`.\n// This is because we encountered issues with generic types that cannot be statically analysed\n// due to creating them dynamically via createCollection.\n\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData = {},\n>(name: string) {\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n type ContextValue = {\n collectionRef: React.RefObject<CollectionElement | null>;\n itemMap: Map<\n React.RefObject<ItemElement | null>,\n { ref: React.RefObject<ItemElement | null> } & ItemData\n >;\n };\n\n const [CollectionProviderImpl, useCollectionContext] = createCollectionContext<ContextValue>(\n PROVIDER_NAME,\n { collectionRef: { current: null }, itemMap: new Map() },\n );\n\n const CollectionProvider: React.FC<{ children?: React.ReactNode | undefined; scope: any }> = (\n props,\n ) => {\n const { scope, children } = props;\n const ref = React.useRef<CollectionElement>(null);\n const itemMap = React.useRef<ContextValue['itemMap']>(new Map()).current;\n return (\n <CollectionProviderImpl scope={scope} itemMap={itemMap} collectionRef={ref}>\n {children}\n </CollectionProviderImpl>\n );\n };\n\n CollectionProvider.displayName = PROVIDER_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = ItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const context = useCollectionContext(ITEM_SLOT_NAME, scope);\n\n React.useEffect(() => {\n context.itemMap.set(ref, { ref, ...(itemData as unknown as ItemData) });\n return () => void context.itemMap.delete(ref);\n });\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const context = useCollectionContext(name + 'CollectionConsumer', scope);\n\n const getItems = React.useCallback(() => {\n const collectionNode = context.collectionRef.current;\n if (!collectionNode) return [];\n const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n const items = Array.from(context.itemMap.values());\n const orderedItems = items.sort(\n (a, b) => orderedNodes.indexOf(a.ref.current!) - orderedNodes.indexOf(b.ref.current!),\n );\n return orderedItems;\n }, [context.collectionRef, context.itemMap]);\n\n return getItems;\n }\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n useCollection,\n createCollectionScope,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionProps };\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport type { EntryOf } from './ordered-dictionary.js';\nimport { OrderedDict, type ReadOnlyOrderedDict } from './ordered-dictionary.js';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionSlotProps extends SlotProps {\n scope: any;\n}\n\ninterface BaseItemData {\n id?: string | undefined;\n}\n\ntype ItemDataWithElement<\n ItemData extends BaseItemData,\n ItemElement extends HTMLElement,\n> = ItemData & {\n element: ItemElement;\n};\n\ntype BaseCollectionDict<\n ItemElement extends HTMLElement,\n ItemData extends BaseItemData,\n> = OrderedDict<ItemElement, ItemDataWithElement<ItemData, ItemElement>>;\n\ntype CollectionDict<ItemElement extends HTMLElement, ItemData> = ReadOnlyOrderedDict<\n ItemElement,\n ItemDataWithElement<ItemData & BaseItemData, ItemElement>\n>;\n\n/**\n * Creates a collection that tracks its items in document order and exposes them\n * during render via `useCollection`.\n *\n * Item data passed to `ItemSlot` (every prop other than `scope` and `children`)\n * must be referentially stable across renders. It is compared shallowly, and any\n * change re-registers the item and replaces the item map. Memoize objects,\n * arrays and callbacks with `useMemo` / `useCallback`, or define them outside of\n * render.\n */\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData extends {} = {},\n>(name: string) {\n type AllItemData = ItemData & BaseItemData;\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n interface CollectionStableContextValue {\n collectionElementRef: React.Ref<CollectionElement | null>;\n collectionElementRefObject: React.RefObject<CollectionElement | null>;\n setCollection: React.Dispatch<\n React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>\n >;\n getCollection: () => CollectionDict<ItemElement, AllItemData>;\n registryRef: React.RefObject<BaseCollectionDict<ItemElement, AllItemData>>;\n }\n\n interface CollectionStatefulContextValue {\n collectionElement: CollectionElement | null;\n collection: CollectionDict<ItemElement, AllItemData>;\n }\n\n const [CollectionStableContextProvider, useStableCollectionContext] =\n createCollectionContext<CollectionStableContextValue>(PROVIDER_NAME);\n CollectionStableContextProvider.displayName = name + 'CollectionStableContextProvider';\n\n const [CollectionStatefulContextProvider, useStatefulCollectionContext] =\n createCollectionContext<CollectionStatefulContextValue>(PROVIDER_NAME);\n CollectionStatefulContextProvider.displayName = name + 'CollectionStatefulContextProvider';\n\n type CollectionState = [\n ItemMap: BaseCollectionDict<ItemElement, AllItemData>,\n SetItemMap: React.Dispatch<React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>>,\n ];\n\n const CollectionProvider: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state?: CollectionState | undefined;\n }> = ({ state, ...props }) => {\n return state ? (\n <CollectionProviderImpl {...props} state={state} />\n ) : (\n <CollectionInit {...props} />\n );\n };\n CollectionProvider.displayName = PROVIDER_NAME;\n\n const CollectionInit: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n }> = (props) => {\n const state = useInitCollection();\n return <CollectionProviderImpl {...props} state={state} />;\n };\n CollectionInit.displayName = name + 'CollectionInit';\n\n const CollectionProviderImpl: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state: CollectionState;\n }> = (props) => {\n const { scope, children, state } = props;\n const ref = React.useRef<CollectionElement>(null);\n const [collectionElement, setCollectionElement] = React.useState<CollectionElement | null>(\n null,\n );\n const composeRefs = useComposedRefs(ref, setCollectionElement);\n const [collection, setCollection] = state;\n\n // Written only during commit (from item ref callbacks and layout effects),\n // so it never includes items from renders that React discards.\n const registryRef = React.useRef<BaseCollectionDict<ItemElement, AllItemData>>(\n new OrderedDict(),\n );\n const getCollection = React.useCallback(() => {\n const registry = registryRef.current;\n if (!isInDocumentOrder(registry)) {\n registry.sort(sortByDocumentPosition);\n }\n return registry;\n }, []);\n\n React.useEffect(() => {\n if (!collectionElement) {\n return;\n }\n\n const observer = getChildListObserver(() => {\n setCollection((map) => {\n const sorted = map.toSorted(sortByDocumentPosition);\n const orderChanged = sorted.some(([key], index) => map.keyAt(index) !== key);\n\n return orderChanged ? sorted : map;\n });\n });\n observer.observe(collectionElement, {\n childList: true,\n subtree: true,\n });\n return () => {\n observer.disconnect();\n };\n }, [collectionElement, setCollection]);\n\n return (\n <CollectionStableContextProvider\n scope={scope}\n collectionElementRef={composeRefs}\n collectionElementRefObject={ref}\n getCollection={getCollection}\n setCollection={setCollection}\n registryRef={registryRef}\n >\n <CollectionStatefulContextProvider\n scope={scope}\n collectionElement={collectionElement}\n collection={collection}\n >\n {children}\n </CollectionStatefulContextProvider>\n </CollectionStableContextProvider>\n );\n };\n\n CollectionProviderImpl.displayName = name + 'CollectionProviderImpl';\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionSlotProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useStableCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionElementRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = AllItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n /**\n * Registers its child element as a collection item. Every prop other than\n * `scope` and `children` is item data and must be referentially stable across\n * renders (see `createCollection`).\n */\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const context = useStableCollectionContext(ITEM_SLOT_NAME, scope);\n\n const { setCollection, registryRef } = context;\n\n const itemDataRef = React.useRef(itemData);\n if (!shallowEqual(itemDataRef.current, itemData)) {\n itemDataRef.current = itemData;\n }\n const memoizedItemData = itemDataRef.current;\n\n // TODO: Once React 19 is the minimum supported version, return a cleanup\n // function that unregisters `node` instead of handling `null`, which\n // depends on `ref.current` still holding the previous element.\n const registerElement = React.useCallback(\n (node: ItemElement | null) => {\n const registry = registryRef.current;\n if (node) {\n registry.set(node, {\n ...(itemDataRef.current as unknown as AllItemData),\n element: node,\n });\n } else if (ref.current) {\n registry.delete(ref.current);\n }\n },\n [registryRef],\n );\n const composedRefs = useComposedRefs(forwardedRef, registerElement, ref);\n\n useLayoutEffect(() => {\n const node = ref.current;\n const registry = registryRef.current;\n if (node && registry.has(node)) {\n registry.set(node, { ...(memoizedItemData as unknown as AllItemData), element: node });\n }\n }, [memoizedItemData, registryRef]);\n\n const registeredRef = React.useRef<{\n element: ItemElement;\n itemData: typeof memoizedItemData;\n } | null>(null);\n\n React.useEffect(() => {\n const element = ref.current;\n const registered = registeredRef.current;\n if (\n (registered?.element ?? null) === element &&\n (!element || registered?.itemData === memoizedItemData)\n ) {\n return;\n }\n\n registeredRef.current = element ? { element, itemData: memoizedItemData } : null;\n setCollection((map) => {\n const next = new OrderedDict(map);\n if (registered && registered.element !== element) {\n next.delete(registered.element);\n }\n if (element) {\n next.set(element, { ...(memoizedItemData as unknown as AllItemData), element });\n }\n return next.sort(sortByDocumentPosition);\n });\n });\n\n React.useEffect(() => {\n return () => {\n const registered = registeredRef.current;\n registeredRef.current = null;\n if (!registered) {\n return;\n }\n setCollection((map) => {\n if (!map.has(registered.element)) {\n return map;\n }\n const next = new OrderedDict(map);\n next.delete(registered.element);\n return next;\n });\n };\n }, [setCollection]);\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs as any}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useInitCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useInitCollection() {\n return React.useState<BaseCollectionDict<ItemElement, AllItemData>>(new OrderedDict());\n }\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const { collection } = useStatefulCollectionContext(name + 'CollectionConsumer', scope);\n return collection;\n }\n\n function useGetCollection(scope: any) {\n const { getCollection } = useStableCollectionContext(name + 'CollectionConsumer', scope);\n return getCollection;\n }\n\n const functions = {\n createCollectionScope,\n useCollection,\n useGetCollection,\n useInitCollection,\n };\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n functions,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionSlotProps, CollectionDict };\n\nfunction shallowEqual(a: any, b: any) {\n if (a === b) return true;\n if (typeof a !== 'object' || typeof b !== 'object') return false;\n if (a == null || b == null) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\n if (a[key] !== b[key]) return false;\n }\n return true;\n}\n\nfunction isElementPreceding(a: Element, b: Element) {\n return !!(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\nfunction isInDocumentOrder<E extends HTMLElement, T extends BaseItemData>(\n dict: BaseCollectionDict<E, T>,\n) {\n let previous: Element | undefined;\n for (const element of dict.keys()) {\n if (previous) {\n const position = previous.compareDocumentPosition(element);\n if (\n !(position & Node.DOCUMENT_POSITION_DISCONNECTED) &&\n position & Node.DOCUMENT_POSITION_PRECEDING\n ) {\n return false;\n }\n }\n previous = element;\n }\n return true;\n}\n\nfunction sortByDocumentPosition<E extends HTMLElement, T extends BaseItemData>(\n a: EntryOf<BaseCollectionDict<E, T>>,\n b: EntryOf<BaseCollectionDict<E, T>>,\n) {\n return !a[1].element || !b[1].element\n ? 0\n : isElementPreceding(a[1].element, b[1].element)\n ? -1\n : 1;\n}\n\nfunction getChildListObserver(callback: () => void) {\n const observer = new MutationObserver((mutationsList) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'childList') {\n callback();\n return;\n }\n }\n });\n\n return observer;\n}\n", "// Not a real member because it shouldn't be accessible, but the super class\n// calls `set` which needs to read the instanciation state, so it can't be a\n// private member.\nconst __instanciated = new WeakMap<OrderedDict<any, any>, boolean>();\nexport class OrderedDict<K, V> extends Map<K, V> {\n #keys: K[];\n\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);\n constructor(entries?: readonly (readonly [K, V])[] | null) {\n super(entries);\n this.#keys = [...super.keys()];\n __instanciated.set(this, true);\n }\n\n set(key: K, value: V) {\n if (__instanciated.get(this) && !this.has(key)) {\n this.#keys.push(key);\n }\n super.set(key, value);\n return this;\n }\n\n /**\n * Sets a key-value pair so that it ends up at the given index.\n * - Existing keys are moved\n * - Negative indices count from the end of the resulting dictionary, so\n * inserting at -1 makes the item the last one, -2 the second to last, etc.\n * - Out-of-range indices are clamped\n */\n insert(index: number, key: K, value: V) {\n const has = this.has(key);\n const finalSize = has ? this.size : this.size + 1;\n const relativeIndex = toSafeInteger(index);\n const targetIndex =\n relativeIndex >= 0\n ? Math.min(relativeIndex, finalSize - 1)\n : Math.max(finalSize + relativeIndex, 0);\n\n if (has ? this.#keys.indexOf(key) === targetIndex : targetIndex === this.size) {\n this.set(key, value);\n return this;\n }\n\n const keys = this.#keys.filter((existingKey) => existingKey !== key);\n keys.splice(targetIndex, 0, key);\n const entries = keys.map((entryKey): [K, V] => [\n entryKey,\n entryKey === key ? value : this.get(entryKey)!,\n ]);\n this.clear();\n for (const [entryKey, entryValue] of entries) {\n this.set(entryKey, entryValue);\n }\n return this;\n }\n\n with(index: number, key: K, value: V) {\n const copy = new OrderedDict(this);\n copy.insert(index, key, value);\n return copy;\n }\n\n before(key: K) {\n const index = this.#keys.indexOf(key) - 1;\n if (index < 0) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position before the given key.\n */\n setBefore(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex < index ? index - 1 : index;\n return this.insert(targetIndex, newKey, value);\n }\n\n after(key: K) {\n let index = this.#keys.indexOf(key);\n index = index === -1 || index === this.size - 1 ? -1 : index + 1;\n if (index === -1) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position after the given key.\n */\n setAfter(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex <= index ? index : index + 1;\n return this.insert(targetIndex, newKey, value);\n }\n\n first() {\n return this.entryAt(0);\n }\n\n last() {\n return this.entryAt(-1);\n }\n\n clear() {\n this.#keys = [];\n return super.clear();\n }\n\n delete(key: K) {\n const deleted = super.delete(key);\n if (deleted) {\n this.#keys.splice(this.#keys.indexOf(key), 1);\n }\n return deleted;\n }\n\n deleteAt(index: number) {\n const key = this.keyAt(index);\n if (key !== undefined) {\n return this.delete(key);\n }\n return false;\n }\n\n at(index: number) {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return this.get(key);\n }\n }\n\n entryAt(index: number): [K, V] | undefined {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return [key, this.get(key)!];\n }\n }\n\n indexOf(key: K) {\n return this.#keys.indexOf(key);\n }\n\n keyAt(index: number) {\n return at(this.#keys, index);\n }\n\n from(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.at(dest);\n }\n\n keyFrom(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.keyAt(dest);\n }\n\n find(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return entry;\n }\n index++;\n }\n return undefined;\n }\n\n findIndex(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return index;\n }\n index++;\n }\n return -1;\n }\n\n filter<KK extends K, VV extends V>(\n predicate: (entry: [K, V], index: number, dict: OrderedDict<K, V>) => entry is [KK, VV],\n thisArg?: any,\n ): OrderedDict<KK, VV>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ): OrderedDict<K, V>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n const entries: Array<[K, V]> = [];\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n entries.push(entry);\n }\n index++;\n }\n return new OrderedDict(entries);\n }\n\n map<U>(\n callbackfn: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => U,\n thisArg?: any,\n ): OrderedDict<K, U> {\n const entries: [K, U][] = [];\n let index = 0;\n for (const entry of this) {\n entries.push([entry[0], Reflect.apply(callbackfn, thisArg, [entry, index, this])]);\n index++;\n }\n return new OrderedDict(entries);\n }\n\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduce<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduce<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let index = 0;\n let accumulator = initialValue as U;\n for (const entry of this) {\n if (index === 0 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n index++;\n }\n return accumulator;\n }\n\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduceRight<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduceRight<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let accumulator = initialValue as U;\n for (let index = this.size - 1; index >= 0; index--) {\n const entry = this.entryAt(index)!;\n if (index === this.size - 1 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n }\n return accumulator;\n }\n\n /**\n * Sorts the dictionary in place. This method mutates the dictionary and\n * returns a reference to the same object\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n sort(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.sort requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n this.clear();\n for (const [key, value] of entries) {\n this.set(key, value);\n }\n return this;\n }\n\n /**\n * Returns a copy of the dictionary with its elements sorted.\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n toSorted(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.toSorted requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n return new OrderedDict(entries);\n }\n\n toReversed(): OrderedDict<K, V> {\n const reversed = new OrderedDict<K, V>();\n for (let index = this.size - 1; index >= 0; index--) {\n const key = this.keyAt(index)!;\n const element = this.get(key)!;\n reversed.set(key, element);\n }\n return reversed;\n }\n\n toSpliced(start: number, deleteCount?: number): OrderedDict<K, V>;\n toSpliced(start: number, deleteCount: number, ...items: [K, V][]): OrderedDict<K, V>;\n\n toSpliced(...args: [start: number, deleteCount: number, ...items: [K, V][]]) {\n const entries = [...this.entries()];\n entries.splice(...args);\n return new OrderedDict(entries);\n }\n\n slice(start?: number, end?: number) {\n const result = new OrderedDict<K, V>();\n for (const key of this.#keys.slice(start, end)) {\n result.set(key, this.get(key)!);\n }\n return result;\n }\n\n every(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (!Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return false;\n }\n index++;\n }\n return true;\n }\n\n some(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return true;\n }\n index++;\n }\n return false;\n }\n}\n\nexport type KeyOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<infer K, any> ? K : never;\nexport type ValueOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<any, infer V> ? V : never;\nexport type EntryOf<D extends OrderedDict<any, any>> = [KeyOf<D>, ValueOf<D>];\nexport type KeyFrom<E extends EntryOf<any>> = E[0];\nexport type ValueFrom<E extends EntryOf<any>> = E[1];\n\nfunction at<T>(array: ArrayLike<T>, index: number): T | undefined {\n if ('at' in Array.prototype) {\n return Array.prototype.at.call(array, index);\n }\n const actualIndex = toSafeIndex(array, index);\n return actualIndex === -1 ? undefined : array[actualIndex];\n}\n\nfunction toSafeIndex(array: ArrayLike<any>, index: number) {\n const length = array.length;\n const relativeIndex = toSafeInteger(index);\n const actualIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;\n return actualIndex < 0 || actualIndex >= length ? -1 : actualIndex;\n}\n\nfunction toSafeInteger(number: number) {\n // eslint-disable-next-line no-self-compare\n return number !== number || number === 0 ? 0 : Math.trunc(number);\n}\n\nexport type ReadOnlyOrderedDict<K, V> = Omit<\n OrderedDict<K, V>,\n 'set' | 'insert' | 'setBefore' | 'setAfter' | 'clear' | 'delete' | 'deleteAt' | 'sort'\n>;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,mCAAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,2BAAmC;AACnC,gCAAgC;AAChC,wBAAsC;AA4ChC;AAAA;AA/BqB,SAAS,iBAGlC,MAAc;AAKd,QAAM,gBAAgB,OAAO;AAC7B,QAAM,CAAC,yBAAyB,qBAAqB,QAAI,yCAAmB,aAAa;AAUzF,QAAM,CAAC,wBAAwB,oBAAoB,IAAI;AAAA,IACrD;AAAA,IACA,EAAE,eAAe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QAAO;AACnC,QAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,QAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,MAAI,MAAM,WAAW,MAAM,OAAQ,QAAO;AAC1C,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,GAAG,GAAG,EAAG,QAAO;AAC1D,QAAI,EAAE,GAAG,MAAM,EAAE,GAAG,EAAG,QAAO;AAAA,EAChC;AACA,SAAO;AACT;AAZS;AAcT,SAAS,mBAAmB,GAAY,GAAY;AAClD,SAAO,CAAC,EAAE,EAAE,wBAAwB,CAAC,IAAI,KAAK;AAChD;AAFS;AAIT,SAAS,kBACP,MACA;AACA,MAAI;AACJ,aAAW,WAAW,KAAK,KAAK,GAAG;AACjC,QAAI,UAAU;AACZ,YAAM,WAAW,SAAS,wBAAwB,OAAO;AACzD,UACE,EAAE,WAAW,KAAK,mCAClB,WAAW,KAAK,6BAChB;AACA,eAAO;AAAA,MACT;AAAA,IACF;AACA,eAAW;AAAA,EACb;AACA,SAAO;AACT;AAjBS;AAmBT,SAAS,uBACP,GACA,GACA;AACA,SAAO,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,EAAE,UAC1B,IACA,mBAAmB,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,IAC3C,KACA;AACR;AATS;AAWT,SAAS,qBAAqB,UAAsB;AAClD,QAAM,WAAW,IAAI,iBAAiB,CAAC,kBAAkB;AACvD,eAAW,YAAY,eAAe;AACpC,UAAI,SAAS,SAAS,aAAa;AACjC,iBAAS;AACT;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAXS;",
6
6
  "names": ["createCollection", "React", "import_react_context", "import_react_compose_refs", "import_react_slot", "import_jsx_runtime", "createCollection"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/collection-legacy.tsx", "../src/collection.tsx", "../src/ordered-dictionary.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionProps extends SlotProps {\n scope: any;\n}\n\n// We have resorted to returning slots directly rather than exposing primitives that can then\n// be slotted like `<CollectionItem as={Slot}>\u2026</CollectionItem>`.\n// This is because we encountered issues with generic types that cannot be statically analysed\n// due to creating them dynamically via createCollection.\n\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData = {},\n>(name: string) {\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n type ContextValue = {\n collectionRef: React.RefObject<CollectionElement | null>;\n itemMap: Map<\n React.RefObject<ItemElement | null>,\n { ref: React.RefObject<ItemElement | null> } & ItemData\n >;\n };\n\n const [CollectionProviderImpl, useCollectionContext] = createCollectionContext<ContextValue>(\n PROVIDER_NAME,\n { collectionRef: { current: null }, itemMap: new Map() },\n );\n\n const CollectionProvider: React.FC<{ children?: React.ReactNode | undefined; scope: any }> = (\n props,\n ) => {\n const { scope, children } = props;\n const ref = React.useRef<CollectionElement>(null);\n const itemMap = React.useRef<ContextValue['itemMap']>(new Map()).current;\n return (\n <CollectionProviderImpl scope={scope} itemMap={itemMap} collectionRef={ref}>\n {children}\n </CollectionProviderImpl>\n );\n };\n\n CollectionProvider.displayName = PROVIDER_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = ItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const context = useCollectionContext(ITEM_SLOT_NAME, scope);\n\n React.useEffect(() => {\n context.itemMap.set(ref, { ref, ...(itemData as unknown as ItemData) });\n return () => void context.itemMap.delete(ref);\n });\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const context = useCollectionContext(name + 'CollectionConsumer', scope);\n\n const getItems = React.useCallback(() => {\n const collectionNode = context.collectionRef.current;\n if (!collectionNode) return [];\n const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n const items = Array.from(context.itemMap.values());\n const orderedItems = items.sort(\n (a, b) => orderedNodes.indexOf(a.ref.current!) - orderedNodes.indexOf(b.ref.current!),\n );\n return orderedItems;\n }, [context.collectionRef, context.itemMap]);\n\n return getItems;\n }\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n useCollection,\n createCollectionScope,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionProps };\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport type { EntryOf } from './ordered-dictionary';\nimport { OrderedDict, type ReadOnlyOrderedDict } from './ordered-dictionary';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionSlotProps extends SlotProps {\n scope: any;\n}\n\ninterface BaseItemData {\n id?: string | undefined;\n}\n\ntype ItemDataWithElement<\n ItemData extends BaseItemData,\n ItemElement extends HTMLElement,\n> = ItemData & {\n element: ItemElement;\n};\n\ntype BaseCollectionDict<\n ItemElement extends HTMLElement,\n ItemData extends BaseItemData,\n> = OrderedDict<ItemElement, ItemDataWithElement<ItemData, ItemElement>>;\n\ntype CollectionDict<ItemElement extends HTMLElement, ItemData> = ReadOnlyOrderedDict<\n ItemElement,\n ItemDataWithElement<ItemData & BaseItemData, ItemElement>\n>;\n\n/**\n * Creates a collection that tracks its items in document order and exposes them\n * during render via `useCollection`.\n *\n * Item data passed to `ItemSlot` (every prop other than `scope` and `children`)\n * must be referentially stable across renders. It is compared shallowly, and any\n * change re-registers the item and replaces the item map. Memoize objects,\n * arrays and callbacks with `useMemo` / `useCallback`, or define them outside of\n * render.\n */\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData extends {} = {},\n>(name: string) {\n type AllItemData = ItemData & BaseItemData;\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n interface CollectionStableContextValue {\n collectionElementRef: React.Ref<CollectionElement | null>;\n collectionElementRefObject: React.RefObject<CollectionElement | null>;\n setCollection: React.Dispatch<\n React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>\n >;\n getCollection: () => CollectionDict<ItemElement, AllItemData>;\n registryRef: React.RefObject<BaseCollectionDict<ItemElement, AllItemData>>;\n }\n\n interface CollectionStatefulContextValue {\n collectionElement: CollectionElement | null;\n collection: CollectionDict<ItemElement, AllItemData>;\n }\n\n const [CollectionStableContextProvider, useStableCollectionContext] =\n createCollectionContext<CollectionStableContextValue>(PROVIDER_NAME);\n CollectionStableContextProvider.displayName = name + 'CollectionStableContextProvider';\n\n const [CollectionStatefulContextProvider, useStatefulCollectionContext] =\n createCollectionContext<CollectionStatefulContextValue>(PROVIDER_NAME);\n CollectionStatefulContextProvider.displayName = name + 'CollectionStatefulContextProvider';\n\n type CollectionState = [\n ItemMap: BaseCollectionDict<ItemElement, AllItemData>,\n SetItemMap: React.Dispatch<React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>>,\n ];\n\n const CollectionProvider: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state?: CollectionState | undefined;\n }> = ({ state, ...props }) => {\n return state ? (\n <CollectionProviderImpl {...props} state={state} />\n ) : (\n <CollectionInit {...props} />\n );\n };\n CollectionProvider.displayName = PROVIDER_NAME;\n\n const CollectionInit: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n }> = (props) => {\n const state = useInitCollection();\n return <CollectionProviderImpl {...props} state={state} />;\n };\n CollectionInit.displayName = name + 'CollectionInit';\n\n const CollectionProviderImpl: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state: CollectionState;\n }> = (props) => {\n const { scope, children, state } = props;\n const ref = React.useRef<CollectionElement>(null);\n const [collectionElement, setCollectionElement] = React.useState<CollectionElement | null>(\n null,\n );\n const composeRefs = useComposedRefs(ref, setCollectionElement);\n const [collection, setCollection] = state;\n\n // Written only during commit (from item ref callbacks and layout effects),\n // so it never includes items from renders that React discards.\n const registryRef = React.useRef<BaseCollectionDict<ItemElement, AllItemData>>(\n new OrderedDict(),\n );\n const getCollection = React.useCallback(() => {\n const registry = registryRef.current;\n if (!isInDocumentOrder(registry)) {\n registry.sort(sortByDocumentPosition);\n }\n return registry;\n }, []);\n\n React.useEffect(() => {\n if (!collectionElement) {\n return;\n }\n\n const observer = getChildListObserver(() => {\n setCollection((map) => {\n const sorted = map.toSorted(sortByDocumentPosition);\n const orderChanged = sorted.some(([key], index) => map.keyAt(index) !== key);\n\n return orderChanged ? sorted : map;\n });\n });\n observer.observe(collectionElement, {\n childList: true,\n subtree: true,\n });\n return () => {\n observer.disconnect();\n };\n }, [collectionElement, setCollection]);\n\n return (\n <CollectionStableContextProvider\n scope={scope}\n collectionElementRef={composeRefs}\n collectionElementRefObject={ref}\n getCollection={getCollection}\n setCollection={setCollection}\n registryRef={registryRef}\n >\n <CollectionStatefulContextProvider\n scope={scope}\n collectionElement={collectionElement}\n collection={collection}\n >\n {children}\n </CollectionStatefulContextProvider>\n </CollectionStableContextProvider>\n );\n };\n\n CollectionProviderImpl.displayName = name + 'CollectionProviderImpl';\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionSlotProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useStableCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionElementRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = AllItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n /**\n * Registers its child element as a collection item. Every prop other than\n * `scope` and `children` is item data and must be referentially stable across\n * renders (see `createCollection`).\n */\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const context = useStableCollectionContext(ITEM_SLOT_NAME, scope);\n\n const { setCollection, registryRef } = context;\n\n const itemDataRef = React.useRef(itemData);\n if (!shallowEqual(itemDataRef.current, itemData)) {\n itemDataRef.current = itemData;\n }\n const memoizedItemData = itemDataRef.current;\n\n // TODO: Once React 19 is the minimum supported version, return a cleanup\n // function that unregisters `node` instead of handling `null`, which\n // depends on `ref.current` still holding the previous element.\n const registerElement = React.useCallback(\n (node: ItemElement | null) => {\n const registry = registryRef.current;\n if (node) {\n registry.set(node, {\n ...(itemDataRef.current as unknown as AllItemData),\n element: node,\n });\n } else if (ref.current) {\n registry.delete(ref.current);\n }\n },\n [registryRef],\n );\n const composedRefs = useComposedRefs(forwardedRef, registerElement, ref);\n\n useLayoutEffect(() => {\n const node = ref.current;\n const registry = registryRef.current;\n if (node && registry.has(node)) {\n registry.set(node, { ...(memoizedItemData as unknown as AllItemData), element: node });\n }\n }, [memoizedItemData, registryRef]);\n\n const registeredRef = React.useRef<{\n element: ItemElement;\n itemData: typeof memoizedItemData;\n } | null>(null);\n\n React.useEffect(() => {\n const element = ref.current;\n const registered = registeredRef.current;\n if (\n (registered?.element ?? null) === element &&\n (!element || registered?.itemData === memoizedItemData)\n ) {\n return;\n }\n\n registeredRef.current = element ? { element, itemData: memoizedItemData } : null;\n setCollection((map) => {\n const next = new OrderedDict(map);\n if (registered && registered.element !== element) {\n next.delete(registered.element);\n }\n if (element) {\n next.set(element, { ...(memoizedItemData as unknown as AllItemData), element });\n }\n return next.sort(sortByDocumentPosition);\n });\n });\n\n React.useEffect(() => {\n return () => {\n const registered = registeredRef.current;\n registeredRef.current = null;\n if (!registered) {\n return;\n }\n setCollection((map) => {\n if (!map.has(registered.element)) {\n return map;\n }\n const next = new OrderedDict(map);\n next.delete(registered.element);\n return next;\n });\n };\n }, [setCollection]);\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs as any}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useInitCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useInitCollection() {\n return React.useState<BaseCollectionDict<ItemElement, AllItemData>>(new OrderedDict());\n }\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const { collection } = useStatefulCollectionContext(name + 'CollectionConsumer', scope);\n return collection;\n }\n\n function useGetCollection(scope: any) {\n const { getCollection } = useStableCollectionContext(name + 'CollectionConsumer', scope);\n return getCollection;\n }\n\n const functions = {\n createCollectionScope,\n useCollection,\n useGetCollection,\n useInitCollection,\n };\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n functions,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionSlotProps, CollectionDict };\n\nfunction shallowEqual(a: any, b: any) {\n if (a === b) return true;\n if (typeof a !== 'object' || typeof b !== 'object') return false;\n if (a == null || b == null) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\n if (a[key] !== b[key]) return false;\n }\n return true;\n}\n\nfunction isElementPreceding(a: Element, b: Element) {\n return !!(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\nfunction isInDocumentOrder<E extends HTMLElement, T extends BaseItemData>(\n dict: BaseCollectionDict<E, T>,\n) {\n let previous: Element | undefined;\n for (const element of dict.keys()) {\n if (previous) {\n const position = previous.compareDocumentPosition(element);\n if (\n !(position & Node.DOCUMENT_POSITION_DISCONNECTED) &&\n position & Node.DOCUMENT_POSITION_PRECEDING\n ) {\n return false;\n }\n }\n previous = element;\n }\n return true;\n}\n\nfunction sortByDocumentPosition<E extends HTMLElement, T extends BaseItemData>(\n a: EntryOf<BaseCollectionDict<E, T>>,\n b: EntryOf<BaseCollectionDict<E, T>>,\n) {\n return !a[1].element || !b[1].element\n ? 0\n : isElementPreceding(a[1].element, b[1].element)\n ? -1\n : 1;\n}\n\nfunction getChildListObserver(callback: () => void) {\n const observer = new MutationObserver((mutationsList) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'childList') {\n callback();\n return;\n }\n }\n });\n\n return observer;\n}\n", "// Not a real member because it shouldn't be accessible, but the super class\n// calls `set` which needs to read the instanciation state, so it can't be a\n// private member.\nconst __instanciated = new WeakMap<OrderedDict<any, any>, boolean>();\nexport class OrderedDict<K, V> extends Map<K, V> {\n #keys: K[];\n\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);\n constructor(entries?: readonly (readonly [K, V])[] | null) {\n super(entries);\n this.#keys = [...super.keys()];\n __instanciated.set(this, true);\n }\n\n set(key: K, value: V) {\n if (__instanciated.get(this) && !this.has(key)) {\n this.#keys.push(key);\n }\n super.set(key, value);\n return this;\n }\n\n /**\n * Sets a key-value pair so that it ends up at the given index.\n * - Existing keys are moved\n * - Negative indices count from the end of the resulting dictionary, so\n * inserting at -1 makes the item the last one, -2 the second to last, etc.\n * - Out-of-range indices are clamped\n */\n insert(index: number, key: K, value: V) {\n const has = this.has(key);\n const finalSize = has ? this.size : this.size + 1;\n const relativeIndex = toSafeInteger(index);\n const targetIndex =\n relativeIndex >= 0\n ? Math.min(relativeIndex, finalSize - 1)\n : Math.max(finalSize + relativeIndex, 0);\n\n if (has ? this.#keys.indexOf(key) === targetIndex : targetIndex === this.size) {\n this.set(key, value);\n return this;\n }\n\n const keys = this.#keys.filter((existingKey) => existingKey !== key);\n keys.splice(targetIndex, 0, key);\n const entries = keys.map((entryKey): [K, V] => [\n entryKey,\n entryKey === key ? value : this.get(entryKey)!,\n ]);\n this.clear();\n for (const [entryKey, entryValue] of entries) {\n this.set(entryKey, entryValue);\n }\n return this;\n }\n\n with(index: number, key: K, value: V) {\n const copy = new OrderedDict(this);\n copy.insert(index, key, value);\n return copy;\n }\n\n before(key: K) {\n const index = this.#keys.indexOf(key) - 1;\n if (index < 0) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position before the given key.\n */\n setBefore(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex < index ? index - 1 : index;\n return this.insert(targetIndex, newKey, value);\n }\n\n after(key: K) {\n let index = this.#keys.indexOf(key);\n index = index === -1 || index === this.size - 1 ? -1 : index + 1;\n if (index === -1) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position after the given key.\n */\n setAfter(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex <= index ? index : index + 1;\n return this.insert(targetIndex, newKey, value);\n }\n\n first() {\n return this.entryAt(0);\n }\n\n last() {\n return this.entryAt(-1);\n }\n\n clear() {\n this.#keys = [];\n return super.clear();\n }\n\n delete(key: K) {\n const deleted = super.delete(key);\n if (deleted) {\n this.#keys.splice(this.#keys.indexOf(key), 1);\n }\n return deleted;\n }\n\n deleteAt(index: number) {\n const key = this.keyAt(index);\n if (key !== undefined) {\n return this.delete(key);\n }\n return false;\n }\n\n at(index: number) {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return this.get(key);\n }\n }\n\n entryAt(index: number): [K, V] | undefined {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return [key, this.get(key)!];\n }\n }\n\n indexOf(key: K) {\n return this.#keys.indexOf(key);\n }\n\n keyAt(index: number) {\n return at(this.#keys, index);\n }\n\n from(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.at(dest);\n }\n\n keyFrom(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.keyAt(dest);\n }\n\n find(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return entry;\n }\n index++;\n }\n return undefined;\n }\n\n findIndex(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return index;\n }\n index++;\n }\n return -1;\n }\n\n filter<KK extends K, VV extends V>(\n predicate: (entry: [K, V], index: number, dict: OrderedDict<K, V>) => entry is [KK, VV],\n thisArg?: any,\n ): OrderedDict<KK, VV>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ): OrderedDict<K, V>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n const entries: Array<[K, V]> = [];\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n entries.push(entry);\n }\n index++;\n }\n return new OrderedDict(entries);\n }\n\n map<U>(\n callbackfn: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => U,\n thisArg?: any,\n ): OrderedDict<K, U> {\n const entries: [K, U][] = [];\n let index = 0;\n for (const entry of this) {\n entries.push([entry[0], Reflect.apply(callbackfn, thisArg, [entry, index, this])]);\n index++;\n }\n return new OrderedDict(entries);\n }\n\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduce<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduce<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let index = 0;\n let accumulator = initialValue as U;\n for (const entry of this) {\n if (index === 0 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n index++;\n }\n return accumulator;\n }\n\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduceRight<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduceRight<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let accumulator = initialValue as U;\n for (let index = this.size - 1; index >= 0; index--) {\n const entry = this.entryAt(index)!;\n if (index === this.size - 1 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n }\n return accumulator;\n }\n\n /**\n * Sorts the dictionary in place. This method mutates the dictionary and\n * returns a reference to the same object\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n sort(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.sort requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n this.clear();\n for (const [key, value] of entries) {\n this.set(key, value);\n }\n return this;\n }\n\n /**\n * Returns a copy of the dictionary with its elements sorted.\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n toSorted(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.toSorted requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n return new OrderedDict(entries);\n }\n\n toReversed(): OrderedDict<K, V> {\n const reversed = new OrderedDict<K, V>();\n for (let index = this.size - 1; index >= 0; index--) {\n const key = this.keyAt(index)!;\n const element = this.get(key)!;\n reversed.set(key, element);\n }\n return reversed;\n }\n\n toSpliced(start: number, deleteCount?: number): OrderedDict<K, V>;\n toSpliced(start: number, deleteCount: number, ...items: [K, V][]): OrderedDict<K, V>;\n\n toSpliced(...args: [start: number, deleteCount: number, ...items: [K, V][]]) {\n const entries = [...this.entries()];\n entries.splice(...args);\n return new OrderedDict(entries);\n }\n\n slice(start?: number, end?: number) {\n const result = new OrderedDict<K, V>();\n for (const key of this.#keys.slice(start, end)) {\n result.set(key, this.get(key)!);\n }\n return result;\n }\n\n every(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (!Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return false;\n }\n index++;\n }\n return true;\n }\n\n some(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return true;\n }\n index++;\n }\n return false;\n }\n}\n\nexport type KeyOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<infer K, any> ? K : never;\nexport type ValueOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<any, infer V> ? V : never;\nexport type EntryOf<D extends OrderedDict<any, any>> = [KeyOf<D>, ValueOf<D>];\nexport type KeyFrom<E extends EntryOf<any>> = E[0];\nexport type ValueFrom<E extends EntryOf<any>> = E[1];\n\nfunction at<T>(array: ArrayLike<T>, index: number): T | undefined {\n if ('at' in Array.prototype) {\n return Array.prototype.at.call(array, index);\n }\n const actualIndex = toSafeIndex(array, index);\n return actualIndex === -1 ? undefined : array[actualIndex];\n}\n\nfunction toSafeIndex(array: ArrayLike<any>, index: number) {\n const length = array.length;\n const relativeIndex = toSafeInteger(index);\n const actualIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;\n return actualIndex < 0 || actualIndex >= length ? -1 : actualIndex;\n}\n\nfunction toSafeInteger(number: number) {\n // eslint-disable-next-line no-self-compare\n return number !== number || number === 0 ? 0 : Math.trunc(number);\n}\n\nexport type ReadOnlyOrderedDict<K, V> = Omit<\n OrderedDict<K, V>,\n 'set' | 'insert' | 'setBefore' | 'setAfter' | 'clear' | 'delete' | 'deleteAt' | 'sort'\n>;\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionProps extends SlotProps {\n scope: any;\n}\n\n// We have resorted to returning slots directly rather than exposing primitives that can then\n// be slotted like `<CollectionItem as={Slot}>\u2026</CollectionItem>`.\n// This is because we encountered issues with generic types that cannot be statically analysed\n// due to creating them dynamically via createCollection.\n\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData = {},\n>(name: string) {\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n type ContextValue = {\n collectionRef: React.RefObject<CollectionElement | null>;\n itemMap: Map<\n React.RefObject<ItemElement | null>,\n { ref: React.RefObject<ItemElement | null> } & ItemData\n >;\n };\n\n const [CollectionProviderImpl, useCollectionContext] = createCollectionContext<ContextValue>(\n PROVIDER_NAME,\n { collectionRef: { current: null }, itemMap: new Map() },\n );\n\n const CollectionProvider: React.FC<{ children?: React.ReactNode | undefined; scope: any }> = (\n props,\n ) => {\n const { scope, children } = props;\n const ref = React.useRef<CollectionElement>(null);\n const itemMap = React.useRef<ContextValue['itemMap']>(new Map()).current;\n return (\n <CollectionProviderImpl scope={scope} itemMap={itemMap} collectionRef={ref}>\n {children}\n </CollectionProviderImpl>\n );\n };\n\n CollectionProvider.displayName = PROVIDER_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = ItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const context = useCollectionContext(ITEM_SLOT_NAME, scope);\n\n React.useEffect(() => {\n context.itemMap.set(ref, { ref, ...(itemData as unknown as ItemData) });\n return () => void context.itemMap.delete(ref);\n });\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const context = useCollectionContext(name + 'CollectionConsumer', scope);\n\n const getItems = React.useCallback(() => {\n const collectionNode = context.collectionRef.current;\n if (!collectionNode) return [];\n const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n const items = Array.from(context.itemMap.values());\n const orderedItems = items.sort(\n (a, b) => orderedNodes.indexOf(a.ref.current!) - orderedNodes.indexOf(b.ref.current!),\n );\n return orderedItems;\n }, [context.collectionRef, context.itemMap]);\n\n return getItems;\n }\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n useCollection,\n createCollectionScope,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionProps };\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createSlot, type Slot } from '@radix-ui/react-slot';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport type { EntryOf } from './ordered-dictionary.js';\nimport { OrderedDict, type ReadOnlyOrderedDict } from './ordered-dictionary.js';\n\ntype SlotProps = React.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionSlotProps extends SlotProps {\n scope: any;\n}\n\ninterface BaseItemData {\n id?: string | undefined;\n}\n\ntype ItemDataWithElement<\n ItemData extends BaseItemData,\n ItemElement extends HTMLElement,\n> = ItemData & {\n element: ItemElement;\n};\n\ntype BaseCollectionDict<\n ItemElement extends HTMLElement,\n ItemData extends BaseItemData,\n> = OrderedDict<ItemElement, ItemDataWithElement<ItemData, ItemElement>>;\n\ntype CollectionDict<ItemElement extends HTMLElement, ItemData> = ReadOnlyOrderedDict<\n ItemElement,\n ItemDataWithElement<ItemData & BaseItemData, ItemElement>\n>;\n\n/**\n * Creates a collection that tracks its items in document order and exposes them\n * during render via `useCollection`.\n *\n * Item data passed to `ItemSlot` (every prop other than `scope` and `children`)\n * must be referentially stable across renders. It is compared shallowly, and any\n * change re-registers the item and replaces the item map. Memoize objects,\n * arrays and callbacks with `useMemo` / `useCallback`, or define them outside of\n * render.\n */\n/* @__NO_SIDE_EFFECTS__ */ function createCollection<\n ItemElement extends HTMLElement,\n ItemData extends {} = {},\n>(name: string) {\n type AllItemData = ItemData & BaseItemData;\n /* -----------------------------------------------------------------------------------------------\n * CollectionProvider\n * ---------------------------------------------------------------------------------------------*/\n\n const PROVIDER_NAME = name + 'CollectionProvider';\n const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n interface CollectionStableContextValue {\n collectionElementRef: React.Ref<CollectionElement | null>;\n collectionElementRefObject: React.RefObject<CollectionElement | null>;\n setCollection: React.Dispatch<\n React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>\n >;\n getCollection: () => CollectionDict<ItemElement, AllItemData>;\n registryRef: React.RefObject<BaseCollectionDict<ItemElement, AllItemData>>;\n }\n\n interface CollectionStatefulContextValue {\n collectionElement: CollectionElement | null;\n collection: CollectionDict<ItemElement, AllItemData>;\n }\n\n const [CollectionStableContextProvider, useStableCollectionContext] =\n createCollectionContext<CollectionStableContextValue>(PROVIDER_NAME);\n CollectionStableContextProvider.displayName = name + 'CollectionStableContextProvider';\n\n const [CollectionStatefulContextProvider, useStatefulCollectionContext] =\n createCollectionContext<CollectionStatefulContextValue>(PROVIDER_NAME);\n CollectionStatefulContextProvider.displayName = name + 'CollectionStatefulContextProvider';\n\n type CollectionState = [\n ItemMap: BaseCollectionDict<ItemElement, AllItemData>,\n SetItemMap: React.Dispatch<React.SetStateAction<BaseCollectionDict<ItemElement, AllItemData>>>,\n ];\n\n const CollectionProvider: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state?: CollectionState | undefined;\n }> = ({ state, ...props }) => {\n return state ? (\n <CollectionProviderImpl {...props} state={state} />\n ) : (\n <CollectionInit {...props} />\n );\n };\n CollectionProvider.displayName = PROVIDER_NAME;\n\n const CollectionInit: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n }> = (props) => {\n const state = useInitCollection();\n return <CollectionProviderImpl {...props} state={state} />;\n };\n CollectionInit.displayName = name + 'CollectionInit';\n\n const CollectionProviderImpl: React.FC<{\n children?: React.ReactNode | undefined;\n scope: any;\n state: CollectionState;\n }> = (props) => {\n const { scope, children, state } = props;\n const ref = React.useRef<CollectionElement>(null);\n const [collectionElement, setCollectionElement] = React.useState<CollectionElement | null>(\n null,\n );\n const composeRefs = useComposedRefs(ref, setCollectionElement);\n const [collection, setCollection] = state;\n\n // Written only during commit (from item ref callbacks and layout effects),\n // so it never includes items from renders that React discards.\n const registryRef = React.useRef<BaseCollectionDict<ItemElement, AllItemData>>(\n new OrderedDict(),\n );\n const getCollection = React.useCallback(() => {\n const registry = registryRef.current;\n if (!isInDocumentOrder(registry)) {\n registry.sort(sortByDocumentPosition);\n }\n return registry;\n }, []);\n\n React.useEffect(() => {\n if (!collectionElement) {\n return;\n }\n\n const observer = getChildListObserver(() => {\n setCollection((map) => {\n const sorted = map.toSorted(sortByDocumentPosition);\n const orderChanged = sorted.some(([key], index) => map.keyAt(index) !== key);\n\n return orderChanged ? sorted : map;\n });\n });\n observer.observe(collectionElement, {\n childList: true,\n subtree: true,\n });\n return () => {\n observer.disconnect();\n };\n }, [collectionElement, setCollection]);\n\n return (\n <CollectionStableContextProvider\n scope={scope}\n collectionElementRef={composeRefs}\n collectionElementRefObject={ref}\n getCollection={getCollection}\n setCollection={setCollection}\n registryRef={registryRef}\n >\n <CollectionStatefulContextProvider\n scope={scope}\n collectionElement={collectionElement}\n collection={collection}\n >\n {children}\n </CollectionStatefulContextProvider>\n </CollectionStableContextProvider>\n );\n };\n\n CollectionProviderImpl.displayName = name + 'CollectionProviderImpl';\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionSlot\n * ---------------------------------------------------------------------------------------------*/\n\n const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);\n const CollectionSlot = React.forwardRef<CollectionElement, CollectionSlotProps>(\n (props, forwardedRef) => {\n const { scope, children } = props;\n const context = useStableCollectionContext(COLLECTION_SLOT_NAME, scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionElementRef);\n return <CollectionSlotImpl ref={composedRefs}>{children}</CollectionSlotImpl>;\n },\n );\n\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * CollectionItem\n * ---------------------------------------------------------------------------------------------*/\n\n const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n type CollectionItemSlotProps = AllItemData & {\n children: React.ReactNode;\n scope: any;\n };\n\n const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);\n /**\n * Registers its child element as a collection item. Every prop other than\n * `scope` and `children` is item data and must be referentially stable across\n * renders (see `createCollection`).\n */\n const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n (props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef<ItemElement>(null);\n const context = useStableCollectionContext(ITEM_SLOT_NAME, scope);\n\n const { setCollection, registryRef } = context;\n\n const itemDataRef = React.useRef(itemData);\n if (!shallowEqual(itemDataRef.current, itemData)) {\n itemDataRef.current = itemData;\n }\n const memoizedItemData = itemDataRef.current;\n\n // TODO: Once React 19 is the minimum supported version, return a cleanup\n // function that unregisters `node` instead of handling `null`, which\n // depends on `ref.current` still holding the previous element.\n const registerElement = React.useCallback(\n (node: ItemElement | null) => {\n const registry = registryRef.current;\n if (node) {\n registry.set(node, {\n ...(itemDataRef.current as unknown as AllItemData),\n element: node,\n });\n } else if (ref.current) {\n registry.delete(ref.current);\n }\n },\n [registryRef],\n );\n const composedRefs = useComposedRefs(forwardedRef, registerElement, ref);\n\n useLayoutEffect(() => {\n const node = ref.current;\n const registry = registryRef.current;\n if (node && registry.has(node)) {\n registry.set(node, { ...(memoizedItemData as unknown as AllItemData), element: node });\n }\n }, [memoizedItemData, registryRef]);\n\n const registeredRef = React.useRef<{\n element: ItemElement;\n itemData: typeof memoizedItemData;\n } | null>(null);\n\n React.useEffect(() => {\n const element = ref.current;\n const registered = registeredRef.current;\n if (\n (registered?.element ?? null) === element &&\n (!element || registered?.itemData === memoizedItemData)\n ) {\n return;\n }\n\n registeredRef.current = element ? { element, itemData: memoizedItemData } : null;\n setCollection((map) => {\n const next = new OrderedDict(map);\n if (registered && registered.element !== element) {\n next.delete(registered.element);\n }\n if (element) {\n next.set(element, { ...(memoizedItemData as unknown as AllItemData), element });\n }\n return next.sort(sortByDocumentPosition);\n });\n });\n\n React.useEffect(() => {\n return () => {\n const registered = registeredRef.current;\n registeredRef.current = null;\n if (!registered) {\n return;\n }\n setCollection((map) => {\n if (!map.has(registered.element)) {\n return map;\n }\n const next = new OrderedDict(map);\n next.delete(registered.element);\n return next;\n });\n };\n }, [setCollection]);\n\n return (\n <CollectionItemSlotImpl {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs as any}>\n {children}\n </CollectionItemSlotImpl>\n );\n },\n );\n\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n /* -----------------------------------------------------------------------------------------------\n * useInitCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useInitCollection() {\n return React.useState<BaseCollectionDict<ItemElement, AllItemData>>(new OrderedDict());\n }\n\n /* -----------------------------------------------------------------------------------------------\n * useCollection\n * ---------------------------------------------------------------------------------------------*/\n\n function useCollection(scope: any) {\n const { collection } = useStatefulCollectionContext(name + 'CollectionConsumer', scope);\n return collection;\n }\n\n function useGetCollection(scope: any) {\n const { getCollection } = useStableCollectionContext(name + 'CollectionConsumer', scope);\n return getCollection;\n }\n\n const functions = {\n createCollectionScope,\n useCollection,\n useGetCollection,\n useInitCollection,\n };\n\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n functions,\n ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionSlotProps, CollectionDict };\n\nfunction shallowEqual(a: any, b: any) {\n if (a === b) return true;\n if (typeof a !== 'object' || typeof b !== 'object') return false;\n if (a == null || b == null) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\n if (a[key] !== b[key]) return false;\n }\n return true;\n}\n\nfunction isElementPreceding(a: Element, b: Element) {\n return !!(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\nfunction isInDocumentOrder<E extends HTMLElement, T extends BaseItemData>(\n dict: BaseCollectionDict<E, T>,\n) {\n let previous: Element | undefined;\n for (const element of dict.keys()) {\n if (previous) {\n const position = previous.compareDocumentPosition(element);\n if (\n !(position & Node.DOCUMENT_POSITION_DISCONNECTED) &&\n position & Node.DOCUMENT_POSITION_PRECEDING\n ) {\n return false;\n }\n }\n previous = element;\n }\n return true;\n}\n\nfunction sortByDocumentPosition<E extends HTMLElement, T extends BaseItemData>(\n a: EntryOf<BaseCollectionDict<E, T>>,\n b: EntryOf<BaseCollectionDict<E, T>>,\n) {\n return !a[1].element || !b[1].element\n ? 0\n : isElementPreceding(a[1].element, b[1].element)\n ? -1\n : 1;\n}\n\nfunction getChildListObserver(callback: () => void) {\n const observer = new MutationObserver((mutationsList) => {\n for (const mutation of mutationsList) {\n if (mutation.type === 'childList') {\n callback();\n return;\n }\n }\n });\n\n return observer;\n}\n", "// Not a real member because it shouldn't be accessible, but the super class\n// calls `set` which needs to read the instanciation state, so it can't be a\n// private member.\nconst __instanciated = new WeakMap<OrderedDict<any, any>, boolean>();\nexport class OrderedDict<K, V> extends Map<K, V> {\n #keys: K[];\n\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);\n constructor(entries?: readonly (readonly [K, V])[] | null) {\n super(entries);\n this.#keys = [...super.keys()];\n __instanciated.set(this, true);\n }\n\n set(key: K, value: V) {\n if (__instanciated.get(this) && !this.has(key)) {\n this.#keys.push(key);\n }\n super.set(key, value);\n return this;\n }\n\n /**\n * Sets a key-value pair so that it ends up at the given index.\n * - Existing keys are moved\n * - Negative indices count from the end of the resulting dictionary, so\n * inserting at -1 makes the item the last one, -2 the second to last, etc.\n * - Out-of-range indices are clamped\n */\n insert(index: number, key: K, value: V) {\n const has = this.has(key);\n const finalSize = has ? this.size : this.size + 1;\n const relativeIndex = toSafeInteger(index);\n const targetIndex =\n relativeIndex >= 0\n ? Math.min(relativeIndex, finalSize - 1)\n : Math.max(finalSize + relativeIndex, 0);\n\n if (has ? this.#keys.indexOf(key) === targetIndex : targetIndex === this.size) {\n this.set(key, value);\n return this;\n }\n\n const keys = this.#keys.filter((existingKey) => existingKey !== key);\n keys.splice(targetIndex, 0, key);\n const entries = keys.map((entryKey): [K, V] => [\n entryKey,\n entryKey === key ? value : this.get(entryKey)!,\n ]);\n this.clear();\n for (const [entryKey, entryValue] of entries) {\n this.set(entryKey, entryValue);\n }\n return this;\n }\n\n with(index: number, key: K, value: V) {\n const copy = new OrderedDict(this);\n copy.insert(index, key, value);\n return copy;\n }\n\n before(key: K) {\n const index = this.#keys.indexOf(key) - 1;\n if (index < 0) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position before the given key.\n */\n setBefore(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex < index ? index - 1 : index;\n return this.insert(targetIndex, newKey, value);\n }\n\n after(key: K) {\n let index = this.#keys.indexOf(key);\n index = index === -1 || index === this.size - 1 ? -1 : index + 1;\n if (index === -1) {\n return undefined;\n }\n return this.entryAt(index);\n }\n\n /**\n * Sets a new key-value pair at the position after the given key.\n */\n setAfter(key: K, newKey: K, value: V) {\n const index = this.#keys.indexOf(key);\n if (index === -1) {\n return this;\n }\n const currentIndex = this.#keys.indexOf(newKey);\n const targetIndex = currentIndex !== -1 && currentIndex <= index ? index : index + 1;\n return this.insert(targetIndex, newKey, value);\n }\n\n first() {\n return this.entryAt(0);\n }\n\n last() {\n return this.entryAt(-1);\n }\n\n clear() {\n this.#keys = [];\n return super.clear();\n }\n\n delete(key: K) {\n const deleted = super.delete(key);\n if (deleted) {\n this.#keys.splice(this.#keys.indexOf(key), 1);\n }\n return deleted;\n }\n\n deleteAt(index: number) {\n const key = this.keyAt(index);\n if (key !== undefined) {\n return this.delete(key);\n }\n return false;\n }\n\n at(index: number) {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return this.get(key);\n }\n }\n\n entryAt(index: number): [K, V] | undefined {\n const key = at(this.#keys, index);\n if (key !== undefined) {\n return [key, this.get(key)!];\n }\n }\n\n indexOf(key: K) {\n return this.#keys.indexOf(key);\n }\n\n keyAt(index: number) {\n return at(this.#keys, index);\n }\n\n from(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.at(dest);\n }\n\n keyFrom(key: K, offset: number) {\n const index = this.indexOf(key);\n if (index === -1) {\n return undefined;\n }\n let dest = index + offset;\n if (dest < 0) dest = 0;\n if (dest >= this.size) dest = this.size - 1;\n return this.keyAt(dest);\n }\n\n find(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return entry;\n }\n index++;\n }\n return undefined;\n }\n\n findIndex(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => boolean,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return index;\n }\n index++;\n }\n return -1;\n }\n\n filter<KK extends K, VV extends V>(\n predicate: (entry: [K, V], index: number, dict: OrderedDict<K, V>) => entry is [KK, VV],\n thisArg?: any,\n ): OrderedDict<KK, VV>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ): OrderedDict<K, V>;\n\n filter(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n const entries: Array<[K, V]> = [];\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n entries.push(entry);\n }\n index++;\n }\n return new OrderedDict(entries);\n }\n\n map<U>(\n callbackfn: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => U,\n thisArg?: any,\n ): OrderedDict<K, U> {\n const entries: [K, U][] = [];\n let index = 0;\n for (const entry of this) {\n entries.push([entry[0], Reflect.apply(callbackfn, thisArg, [entry, index, this])]);\n index++;\n }\n return new OrderedDict(entries);\n }\n\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduce(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduce<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduce<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let index = 0;\n let accumulator = initialValue as U;\n for (const entry of this) {\n if (index === 0 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n index++;\n }\n return accumulator;\n }\n\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n ): [K, V];\n reduceRight(\n callbackfn: (\n previousValue: [K, V],\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => [K, V],\n initialValue: [K, V],\n ): [K, V];\n reduceRight<U>(\n callbackfn: (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n initialValue: U,\n ): U;\n\n reduceRight<U>(\n ...args: [\n (\n previousValue: U,\n currentEntry: [K, V],\n currentIndex: number,\n dictionary: OrderedDict<K, V>,\n ) => U,\n U?,\n ]\n ) {\n const [callbackfn, initialValue] = args;\n const hasInitialValue = args.length > 1;\n if (!hasInitialValue && this.size === 0) {\n throw new TypeError('Reduce of empty OrderedDict with no initial value');\n }\n let accumulator = initialValue as U;\n for (let index = this.size - 1; index >= 0; index--) {\n const entry = this.entryAt(index)!;\n if (index === this.size - 1 && !hasInitialValue) {\n accumulator = entry as any;\n } else {\n accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);\n }\n }\n return accumulator;\n }\n\n /**\n * Sorts the dictionary in place. This method mutates the dictionary and\n * returns a reference to the same object\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n sort(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.sort requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n this.clear();\n for (const [key, value] of entries) {\n this.set(key, value);\n }\n return this;\n }\n\n /**\n * Returns a copy of the dictionary with its elements sorted.\n *\n * @param compareFn Function used to determine the order of the elements. It\n * is expected to return a negative value if the first argument is less than\n * the second argument, zero if they're equal, and a positive value otherwise.\n */\n toSorted(compareFn: (a: [K, V], b: [K, V]) => number): OrderedDict<K, V> {\n if (typeof compareFn !== 'function') {\n throw new TypeError(`OrderedDict.toSorted requires a compare function`);\n }\n const entries = [...this.entries()].sort(compareFn);\n return new OrderedDict(entries);\n }\n\n toReversed(): OrderedDict<K, V> {\n const reversed = new OrderedDict<K, V>();\n for (let index = this.size - 1; index >= 0; index--) {\n const key = this.keyAt(index)!;\n const element = this.get(key)!;\n reversed.set(key, element);\n }\n return reversed;\n }\n\n toSpliced(start: number, deleteCount?: number): OrderedDict<K, V>;\n toSpliced(start: number, deleteCount: number, ...items: [K, V][]): OrderedDict<K, V>;\n\n toSpliced(...args: [start: number, deleteCount: number, ...items: [K, V][]]) {\n const entries = [...this.entries()];\n entries.splice(...args);\n return new OrderedDict(entries);\n }\n\n slice(start?: number, end?: number) {\n const result = new OrderedDict<K, V>();\n for (const key of this.#keys.slice(start, end)) {\n result.set(key, this.get(key)!);\n }\n return result;\n }\n\n every(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (!Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return false;\n }\n index++;\n }\n return true;\n }\n\n some(\n predicate: (entry: [K, V], index: number, dictionary: OrderedDict<K, V>) => unknown,\n thisArg?: any,\n ) {\n let index = 0;\n for (const entry of this) {\n if (Reflect.apply(predicate, thisArg, [entry, index, this])) {\n return true;\n }\n index++;\n }\n return false;\n }\n}\n\nexport type KeyOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<infer K, any> ? K : never;\nexport type ValueOf<D extends OrderedDict<any, any>> =\n D extends OrderedDict<any, infer V> ? V : never;\nexport type EntryOf<D extends OrderedDict<any, any>> = [KeyOf<D>, ValueOf<D>];\nexport type KeyFrom<E extends EntryOf<any>> = E[0];\nexport type ValueFrom<E extends EntryOf<any>> = E[1];\n\nfunction at<T>(array: ArrayLike<T>, index: number): T | undefined {\n if ('at' in Array.prototype) {\n return Array.prototype.at.call(array, index);\n }\n const actualIndex = toSafeIndex(array, index);\n return actualIndex === -1 ? undefined : array[actualIndex];\n}\n\nfunction toSafeIndex(array: ArrayLike<any>, index: number) {\n const length = array.length;\n const relativeIndex = toSafeInteger(index);\n const actualIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;\n return actualIndex < 0 || actualIndex >= length ? -1 : actualIndex;\n}\n\nfunction toSafeInteger(number: number) {\n // eslint-disable-next-line no-self-compare\n return number !== number || number === 0 ? 0 : Math.trunc(number);\n}\n\nexport type ReadOnlyOrderedDict<K, V> = Omit<\n OrderedDict<K, V>,\n 'set' | 'insert' | 'setBefore' | 'setAfter' | 'clear' | 'delete' | 'deleteAt' | 'sort'\n>;\n"],
5
5
  "mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,kBAA6B;AA4ChC;AAAA;AA/BqB,SAAS,iBAGlC,MAAc;AAKd,QAAM,gBAAgB,OAAO;AAC7B,QAAM,CAAC,yBAAyB,qBAAqB,IAAI,mBAAmB,aAAa;AAUzF,QAAM,CAAC,wBAAwB,oBAAoB,IAAI;AAAA,IACrD;AAAA,IACA,EAAE,eAAe,EAAE,SAAS,KAAK,GAAG,SAAS,oBAAI,IAAI,EAAE;AAAA,EACzD;AAEA,QAAM,qBAAuF,wBAC3F,UACG;AACH,UAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,UAAM,MAAY,aAA0B,IAAI;AAChD,UAAM,UAAgB,aAAgC,oBAAI,IAAI,CAAC,EAAE;AACjE,WACE,oBAAC,0BAAuB,OAAc,SAAkB,eAAe,KACpE,UACH;AAAA,EAEJ,GAX6F;AAa7F,qBAAmB,cAAc;AAMjC,QAAM,uBAAuB,OAAO;AAEpC,QAAM,qBAAqB,WAAW,oBAAoB;AAC1D,QAAM,iBAAuB;AAAA,IAC3B,CAAC,OAAO,iBAAiB;AACvB,YAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,YAAM,UAAU,qBAAqB,sBAAsB,KAAK;AAChE,YAAM,eAAe,gBAAgB,cAAc,QAAQ,aAAa;AACxE,aAAO,oBAAC,sBAAmB,KAAK,cAAe,UAAS;AAAA,IAC1D;AAAA,EACF;AAEA,i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AK,mCAClB,WAAW,KAAK,6BAChB;AACA,eAAO;AAAA,MACT;AAAA,IACF;AACA,eAAW;AAAA,EACb;AACA,SAAO;AACT;AAjBS;AAmBT,SAAS,uBACP,GACA,GACA;AACA,SAAO,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,EAAE,UAC1B,IACA,mBAAmB,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,IAC3C,KACA;AACR;AATS;AAWT,SAAS,qBAAqB,UAAsB;AAClD,QAAM,WAAW,IAAI,iBAAiB,CAAC,kBAAkB;AACvD,eAAW,YAAY,eAAe;AACpC,UAAI,SAAS,SAAS,aAAa;AACjC,iBAAS;AACT;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAXS;",
6
6
  "names": ["React", "createContextScope", "useComposedRefs", "createSlot", "jsx", "createCollection", "createContextScope", "useComposedRefs", "createSlot"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-collection",
3
- "version": "1.2.1-rc.1791984254107",
3
+ "version": "1.2.1",
4
4
  "license": "MIT",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",
@@ -11,11 +11,11 @@
11
11
  ],
12
12
  "sideEffects": false,
13
13
  "dependencies": {
14
- "@radix-ui/react-compose-refs": "1.1.5",
15
- "@radix-ui/react-primitive": "2.2.0",
16
- "@radix-ui/react-slot": "1.5.0",
17
- "@radix-ui/react-context": "1.3.1-rc.1791984254107",
18
- "@radix-ui/react-use-layout-effect": "1.1.4"
14
+ "@radix-ui/react-compose-refs": "1.1.6",
15
+ "@radix-ui/react-context": "1.3.1",
16
+ "@radix-ui/react-primitive": "2.2.1",
17
+ "@radix-ui/react-slot": "1.5.1",
18
+ "@radix-ui/react-use-layout-effect": "1.1.5"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/react": "^19.3.0",
@@ -23,8 +23,8 @@
23
23
  "react": "^19.3.0",
24
24
  "react-dom": "^19.3.0",
25
25
  "typescript": "^5.9.3",
26
- "@repo/typescript-config": "0.0.0",
27
- "@repo/builder": "0.0.0"
26
+ "@repo/builder": "0.0.0",
27
+ "@repo/typescript-config": "0.0.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@types/react": "*",
@@ -53,7 +53,8 @@
53
53
  "lint": "oxlint --max-warnings 0 src",
54
54
  "clean": "rm -rf dist",
55
55
  "reset": "rm -rf dist node_modules",
56
- "typecheck": "tsc --noEmit",
56
+ "types:check:pkg": "tsc --noEmit -p tsconfig.lib.json",
57
+ "types:check:test": "tsc --noEmit -p tsconfig.test.json",
57
58
  "build": "radix-build"
58
59
  },
59
60
  "types": "./dist/index.d.ts",