Socket
Socket
Sign inDemoInstall

@radix-ui/react-collection

Package Overview
Dependencies
Maintainers
8
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-collection - npm Package Compare versions

Comparing version 0.1.1-rc.16 to 0.1.1-rc.17

16

dist/index.d.ts

@@ -6,9 +6,17 @@ import React from "react";

export interface CollectionProps extends SlotProps {
scope: any;
}
export function createCollection<ItemElement extends HTMLElement, ItemData>(): readonly [React.FC<{}>, React.ForwardRefExoticComponent<CollectionProps & React.RefAttributes<HTMLElement>>, React.ForwardRefExoticComponent<React.PropsWithoutRef<ItemData & {
children: React.ReactNode;
}> & React.RefAttributes<ItemElement>>, () => () => ({
export function createCollection<ItemElement extends HTMLElement, ItemData>(name: string): readonly [{
readonly Provider: React.FC<{
scope: any;
}>;
readonly Slot: React.ForwardRefExoticComponent<CollectionProps & React.RefAttributes<HTMLElement>>;
readonly ItemSlot: React.ForwardRefExoticComponent<React.PropsWithoutRef<ItemData & {
children: React.ReactNode;
scope: any;
}> & React.RefAttributes<ItemElement>>;
}, (scope: any) => () => ({
ref: React.RefObject<ItemElement>;
} & ItemData)[]];
} & ItemData)[], import("@radix-ui/react-context").CreateScope];
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

var e,r=require("@radix-ui/react-slot").Slot,t=require("@radix-ui/react-compose-refs").useComposedRefs,n=(e=require("react"))&&e.__esModule?e.default:e;exports.createCollection=function(){const e=/*#__PURE__*/n.createContext({}),o=r=>{const{children:t}=r,o=n.useRef(null),c=n.useRef(new Map).current;/*#__PURE__*/return n.createElement(e.Provider,{value:n.useMemo((()=>({itemMap:c,collectionRef:o})),[c])},t)},c=/*#__PURE__*/n.forwardRef(((o,c)=>{const{children:u}=o,l=n.useContext(e),a=t(c,l.collectionRef);/*#__PURE__*/return n.createElement(r,{ref:a},u)})),u="data-radix-collection-item",l=/*#__PURE__*/n.forwardRef(((o,c)=>{const{children:l,...a}=o,i=n.useRef(null),f=t(c,i),s=n.useContext(e);return n.useEffect((()=>(s.itemMap.set(i,{ref:i,...a}),()=>{s.itemMap.delete(i)}))),/*#__PURE__*/n.createElement(r,{[u]:"",ref:f},l)}));return[o,c,l,function(){const r=n.useContext(e);return n.useCallback((()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(r.itemMap.values()).sort(((e,r)=>t.indexOf(e.ref.current)-t.indexOf(r.ref.current)))}),[r.collectionRef,r.itemMap])}]};
var e,r=require("@radix-ui/react-slot").Slot,t=require("@radix-ui/react-compose-refs").useComposedRefs,o=require("@radix-ui/react-context").createContextScope,c=(e=require("react"))&&e.__esModule?e.default:e;exports.createCollection=function(e){const n=e+"CollectionProvider",[l,i]=o(n),[u,a]=l(n,{collectionRef:{current:null},itemMap:new Map}),f=e=>{const{scope:r,children:t}=e,o=c.useRef(null),n=c.useRef(new Map).current;/*#__PURE__*/return c.createElement(u,{scope:r,itemMap:n,collectionRef:o},t)},s=e+"CollectionSlot",d=/*#__PURE__*/c.forwardRef(((e,o)=>{const{scope:n,children:l}=e,i=a(s,n),u=t(o,i.collectionRef);/*#__PURE__*/return c.createElement(r,{ref:u},l)})),m=e+"CollectionItemSlot",p="data-radix-collection-item",R=/*#__PURE__*/c.forwardRef(((e,o)=>{const{scope:n,children:l,...i}=e,u=c.useRef(null),f=t(o,u),s=a(m,n);return c.useEffect((()=>(s.itemMap.set(u,{ref:u,...i}),()=>{s.itemMap.delete(u)}))),/*#__PURE__*/c.createElement(r,{[p]:"",ref:f},l)}));return[{Provider:f,Slot:d,ItemSlot:R},function(r){const t=a(e+"CollectionConsumer",r);return c.useCallback((()=>{const e=t.collectionRef.current;if(!e)return[];const r=Array.from(e.querySelectorAll(`[${p}]`));return Array.from(t.itemMap.values()).sort(((e,t)=>r.indexOf(e.ref.current)-r.indexOf(t.ref.current)))}),[t.collectionRef,t.itemMap])},i]};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{Slot as e}from"@radix-ui/react-slot";import{useComposedRefs as r}from"@radix-ui/react-compose-refs";import t from"react";export function createCollection(){const n=/*#__PURE__*/t.createContext({}),o=e=>{const{children:r}=e,o=t.useRef(null),c=t.useRef(new Map).current;/*#__PURE__*/return t.createElement(n.Provider,{value:t.useMemo((()=>({itemMap:c,collectionRef:o})),[c])},r)},c=/*#__PURE__*/t.forwardRef(((o,c)=>{const{children:l}=o,f=t.useContext(n),i=r(c,f.collectionRef);/*#__PURE__*/return t.createElement(e,{ref:i},l)})),l="data-radix-collection-item",f=/*#__PURE__*/t.forwardRef(((o,c)=>{const{children:f,...i}=o,u=t.useRef(null),a=r(c,u),s=t.useContext(n);return t.useEffect((()=>(s.itemMap.set(u,{ref:u,...i}),()=>{s.itemMap.delete(u)}))),/*#__PURE__*/t.createElement(e,{[l]:"",ref:a},f)}));return[o,c,f,function(){const e=t.useContext(n);return t.useCallback((()=>{const r=e.collectionRef.current;if(!r)return[];const t=Array.from(r.querySelectorAll(`[${l}]`));return Array.from(e.itemMap.values()).sort(((e,r)=>t.indexOf(e.ref.current)-t.indexOf(r.ref.current)))}),[e.collectionRef,e.itemMap])}]}
import{Slot as e}from"@radix-ui/react-slot";import{useComposedRefs as r}from"@radix-ui/react-compose-refs";import{createContextScope as t}from"@radix-ui/react-context";import o from"react";export function createCollection(c){const n=c+"CollectionProvider",[l,i]=t(n),[f,a]=l(n,{collectionRef:{current:null},itemMap:new Map}),u=e=>{const{scope:r,children:t}=e,c=o.useRef(null),n=o.useRef(new Map).current;/*#__PURE__*/return o.createElement(f,{scope:r,itemMap:n,collectionRef:c},t)},m=c+"CollectionSlot",s=/*#__PURE__*/o.forwardRef(((t,c)=>{const{scope:n,children:l}=t,i=a(m,n),f=r(c,i.collectionRef);/*#__PURE__*/return o.createElement(e,{ref:f},l)})),p=c+"CollectionItemSlot",d="data-radix-collection-item",R=/*#__PURE__*/o.forwardRef(((t,c)=>{const{scope:n,children:l,...i}=t,f=o.useRef(null),u=r(c,f),m=a(p,n);return o.useEffect((()=>(m.itemMap.set(f,{ref:f,...i}),()=>{m.itemMap.delete(f)}))),/*#__PURE__*/o.createElement(e,{[d]:"",ref:u},l)}));return[{Provider:u,Slot:s,ItemSlot:R},function(e){const r=a(c+"CollectionConsumer",e);return o.useCallback((()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(r.itemMap.values()).sort(((e,r)=>t.indexOf(e.ref.current)-t.indexOf(r.ref.current)))}),[r.collectionRef,r.itemMap])},i]}
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-collection",
"version": "0.1.1-rc.16",
"version": "0.1.1-rc.17",
"license": "MIT",

@@ -21,4 +21,5 @@ "source": "src/index.ts",

"@radix-ui/react-compose-refs": "0.1.0",
"@radix-ui/react-primitive": "0.1.1-rc.16",
"@radix-ui/react-slot": "0.1.1-rc.12"
"@radix-ui/react-context": "0.1.1-rc.1",
"@radix-ui/react-primitive": "0.1.1-rc.17",
"@radix-ui/react-slot": "0.1.1-rc.13"
},

@@ -25,0 +26,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc