Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-accordion

Package Overview
Dependencies
Maintainers
6
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.0.1 to 0.0.2

2

dist/index.js

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

var e,r=require("@radix-ui/react-collapsible"),t=r.Collapsible,n=r.CollapsibleButton,o=r.CollapsibleContent,a=require("@radix-ui/react-polymorphic").forwardRefWithAs,i=require("@radix-ui/react-utils"),c=i.composeEventHandlers,u=i.createContext,l=i.useComposedRefs,d=i.useControlledState,s=i.useId,f=require("@radix-ui/utils").getPartDataAttrObj,p=(e=require("react"))&&e.__esModule?e.default:e;function v(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||A(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(){return(b=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function m(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function y(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(n=(i=c.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw a}}return t}(e,r)||A(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,r){if(e){if("string"==typeof e)return h(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h(e,r):void 0}}function h(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var g=y(u("AccordionContext","Accordion"),2),x=g[0],w=g[1],O=y(u("AccordionItemContext","AccordionItem"),2),I=O[0],E=O[1],j=a((function(e,r){var n,o=e.value,a=e.children,i=m(e,["value","children"]),c=w("AccordionItem"),u="accordion-button-".concat(s()),l=e.id||u,d=o&&o===c.value||!1,v=null!==(n=c.disabled)&&void 0!==n?n:e.disabled,y=p.useMemo((function(){return{open:d,buttonId:l}}),[d,l]);return p.createElement(t,b({},i,f("AccordionItem"),{ref:r,"data-state":d?"open":"closed","data-disabled":v||void 0,disabled:v,open:d,onOpenChange:function(){return c.setValue(o)}}),p.createElement(I.Provider,{value:y},a))}));exports.AccordionItem=j,j.displayName="AccordionItem";var C=a((function(e,r){var t=e.as,n=void 0===t?"h3":t,o=m(e,["as"]);return p.createElement(n,b({ref:r},o,f("AccordionHeader")))}));exports.AccordionHeader=C,C.displayName="AccordionHeader";var S=a((function(e,r){var t=Object.assign({},e),o=w("AccordionButton").buttonNodesRef,a=E("AccordionButton"),i=p.useRef(null),c=l(i,r);return p.useEffect((function(){var e=o.current,r=i.current;if(r)return e.add(r),function(){e.delete(r)}}),[o]),p.createElement(n,b({},t,f("AccordionButton"),{ref:c,"aria-disabled":a.open||void 0,id:a.buttonId}))}));exports.AccordionButton=S,S.displayName="AccordionButton";var P=a((function(e,r){var t=E("AccordionPanel");return p.createElement(o,b({},e,f("AccordionPanel"),{ref:r,role:"region","aria-labelledby":t.buttonId}))}));exports.AccordionPanel=P,P.displayName="AccordionPanel";var B=["Home","End","ArrowDown","ArrowUp"],H=a((function(e,r){var t=e.as,n=void 0===t?"div":t,o=e.value,a=e.defaultValue,i=e.children,u=e.disabled,s=e.onValueChange,A=void 0===s?function(){}:s,h=m(e,["as","value","defaultValue","children","disabled","onValueChange"]),g=p.useRef(new Set),w=p.useRef(null),O=l(w,r),I=y(d({prop:o,defaultProp:a,onChange:function(e){return e&&A(e)}}),2),E=I[0],j=I[1],C=c(e.onKeyDown,(function(e){var r,t=e.target;if(B.includes(e.key)&&t instanceof HTMLButtonElement){var n=v(g.current).filter((function(e){return!(e&&e.disabled)})),o=n.length,a=n.indexOf(t);if(-1!==a){e.preventDefault();var i=a;switch(e.key){case"Home":i=0;break;case"End":i=o-1;break;case"ArrowDown":i=a+1;break;case"ArrowUp":(i=a-1)<0&&(i=o-1)}null===(r=n[i%o])||void 0===r||r.focus()}}})),S=p.useMemo((function(){return{disabled:u,buttonNodesRef:g,value:E,setValue:j}}),[u,E,j]);return p.createElement(n,b({},h,f("Accordion"),{ref:O,onKeyDown:u?void 0:C}),p.createElement(x.Provider,{value:S},i))}));exports.Accordion=H,H.displayName="Accordion";var R=H;exports.Root=R;var N=j;exports.Item=N;var k=C;exports.Header=k;var D=S;exports.Button=D;var V=P;exports.Panel=V;
var e,r=require("@radix-ui/react-collapsible"),t=r.Collapsible,n=r.CollapsibleButton,o=r.CollapsibleContent,a=require("@radix-ui/react-primitive").Primitive,i=require("@radix-ui/react-utils"),c=i.composeEventHandlers,u=i.createContext,l=i.useComposedRefs,d=i.useControlledState,f=i.useId,s=require("@radix-ui/utils").getSelector,p=(e=require("react"))&&e.__esModule?e.default:e;function v(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||A(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(){return(b=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function m(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function y(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(n=(i=c.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw a}}return t}(e,r)||A(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,r){if(e){if("string"==typeof e)return h(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h(e,r):void 0}}function h(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var w=y(u("AccordionContext","Accordion"),2),x=w[0],g=w[1],I=y(u("AccordionItemContext","AccordionItem"),2),O=I[0],E=I[1],C=p.forwardRef((function(e,r){var n=e.value,o=e.children,a=m(e,["value","children"]),i=g("AccordionItem"),c="accordion-button-".concat(f()),u=e.id||c,l=n&&n===i.value||!1,d=i.disabled||e.disabled,v=p.useMemo((function(){return{open:l,buttonId:u}}),[l,u]);return p.createElement(t,b({selector:s("AccordionItem")},a,{ref:r,"data-state":l?"open":"closed","data-disabled":d||void 0,disabled:d,open:l,onOpenChange:function(){return i.setValue(n)}}),p.createElement(O.Provider,{value:v},o))}));exports.AccordionItem=C,C.displayName="AccordionItem";var S=p.forwardRef((function(e,r){return p.createElement(a,b({as:"h3",selector:s("AccordionHeader")},e,{ref:r}))}));exports.AccordionHeader=S,S.displayName="AccordionHeader";var j=p.forwardRef((function(e,r){var t=g("AccordionButton").buttonNodesRef,o=E("AccordionButton"),a=p.useRef(null),i=l(a,r);return p.useEffect((function(){var e=t.current,r=a.current;if(r)return e.add(r),function(){e.delete(r)}}),[t]),p.createElement(n,b({selector:s("AccordionButton")},e,{ref:i,"aria-disabled":o.open||void 0,id:o.buttonId}))}));exports.AccordionButton=j,j.displayName="AccordionButton";var P=p.forwardRef((function(e,r){var t=E("AccordionPanel");return p.createElement(o,b({selector:s("AccordionPanel")},e,{ref:r,role:"region","aria-labelledby":t.buttonId}))}));exports.AccordionPanel=P,P.displayName="AccordionPanel";var R=["Home","End","ArrowDown","ArrowUp"],B=p.forwardRef((function(e,r){var t=e.value,n=e.defaultValue,o=e.children,i=e.disabled,u=e.onValueChange,f=void 0===u?function(){}:u,A=m(e,["value","defaultValue","children","disabled","onValueChange"]),h=p.useRef(new Set),w=p.useRef(null),g=l(w,r),I=y(d({prop:t,defaultProp:n,onChange:function(e){return e&&f(e)}}),2),O=I[0],E=I[1],C=c(e.onKeyDown,(function(e){var r,t=e.target;if(R.includes(e.key)&&t instanceof HTMLButtonElement){var n=v(h.current).filter((function(e){return!(e&&e.disabled)})),o=n.length,a=n.indexOf(t);if(-1!==a){e.preventDefault();var i=a;switch(e.key){case"Home":i=0;break;case"End":i=o-1;break;case"ArrowDown":i=a+1;break;case"ArrowUp":(i=a-1)<0&&(i=o-1)}null===(r=n[i%o])||void 0===r||r.focus()}}})),S=p.useMemo((function(){return{disabled:i,buttonNodesRef:h,value:O,setValue:E}}),[i,O,E]);return p.createElement(a,b({selector:s("Accordion")},A,{ref:g,onKeyDown:i?void 0:C}),p.createElement(x.Provider,{value:S},o))}));exports.Accordion=B,B.displayName="Accordion";var H=B;exports.Root=H;var N=C;exports.Item=N;var k=S;exports.Header=k;var V=j;exports.Button=V;var q=P;exports.Panel=q;
//# sourceMappingURL=index.js.map

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

import{Collapsible as e,CollapsibleButton as o,CollapsibleContent as r}from"@radix-ui/react-collapsible";import{forwardRefWithAs as t}from"@radix-ui/react-polymorphic";import{composeEventHandlers as n,createContext as c,useComposedRefs as a,useControlledState as i,useId as d}from"@radix-ui/react-utils";import{getPartDataAttrObj as l}from"@radix-ui/utils";import u from"react";function s(){return(s=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function p(e,o){if(null==e)return{};var r,t,n=function(e,o){if(null==e)return{};var r,t,n={},c=Object.keys(e);for(t=0;t<c.length;t++)r=c[t],o.indexOf(r)>=0||(n[r]=e[r]);return n}(e,o);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(t=0;t<c.length;t++)r=c[t],o.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const[f,m]=c("AccordionContext","Accordion"),[A,b]=c("AccordionItemContext","AccordionItem");export const AccordionItem=t(((o,r)=>{var t;const{value:n,children:c}=o,a=p(o,["value","children"]),i=m("AccordionItem"),f="accordion-button-".concat(d()),b=o.id||f,v=n&&n===i.value||!1,y=null!==(t=i.disabled)&&void 0!==t?t:o.disabled,x=u.useMemo((()=>({open:v,buttonId:b})),[v,b]);return u.createElement(e,s({},a,l("AccordionItem"),{ref:r,"data-state":v?"open":"closed","data-disabled":y||void 0,disabled:y,open:v,onOpenChange:()=>i.setValue(n)}),u.createElement(A.Provider,{value:x},c))}));AccordionItem.displayName="AccordionItem";const v="h3";export const AccordionHeader=t(((e,o)=>{const{as:r=v}=e,t=p(e,["as"]);return u.createElement(r,s({ref:o},t,l("AccordionHeader")))}));AccordionHeader.displayName="AccordionHeader";export const AccordionButton=t(((e,r)=>{const t=Object.assign({},e),{buttonNodesRef:n}=m("AccordionButton"),c=b("AccordionButton"),i=u.useRef(null),d=a(i,r);return u.useEffect((()=>{const e=n.current,o=i.current;if(o)return e.add(o),()=>{e.delete(o)}}),[n]),u.createElement(o,s({},t,l("AccordionButton"),{ref:d,"aria-disabled":c.open||void 0,id:c.buttonId}))}));AccordionButton.displayName="AccordionButton";export const AccordionPanel=t(((e,o)=>{const t=b("AccordionPanel");return u.createElement(r,s({},e,l("AccordionPanel"),{ref:o,role:"region","aria-labelledby":t.buttonId}))}));AccordionPanel.displayName="AccordionPanel";const y="div",x=["Home","End","ArrowDown","ArrowUp"];export const Accordion=t(((e,o)=>{const{as:r=y,value:t,defaultValue:c,children:d,disabled:m,onValueChange:A=(()=>{})}=e,b=p(e,["as","value","defaultValue","children","disabled","onValueChange"]),v=u.useRef(new Set),h=u.useRef(null),g=a(h,o),[O,w]=i({prop:t,defaultProp:c,onChange:e=>e&&A(e)}),I=n(e.onKeyDown,(e=>{var o;const r=e.target;if(!(x.includes(e.key)&&(t=r,t instanceof HTMLButtonElement)))return;var t;const n=[...v.current].filter((e=>!(e&&e.disabled))),c=n.length,a=n.indexOf(r);if(-1===a)return;e.preventDefault();let i=a;switch(e.key){case"Home":i=0;break;case"End":i=c-1;break;case"ArrowDown":i=a+1;break;case"ArrowUp":i=a-1,i<0&&(i=c-1)}null===(o=n[i%c])||void 0===o||o.focus()})),P=u.useMemo((()=>({disabled:m,buttonNodesRef:v,value:O,setValue:w})),[m,O,w]);return u.createElement(r,s({},b,l("Accordion"),{ref:g,onKeyDown:m?void 0:I}),u.createElement(f.Provider,{value:P},d))}));Accordion.displayName="Accordion";export const Root=Accordion;export const Item=AccordionItem;export const Header=AccordionHeader;export const Button=AccordionButton;export const Panel=AccordionPanel;
import{Collapsible as e,CollapsibleButton as o,CollapsibleContent as r}from"@radix-ui/react-collapsible";import{Primitive as t}from"@radix-ui/react-primitive";import{composeEventHandlers as n,createContext as c,useComposedRefs as a,useControlledState as d,useId as i}from"@radix-ui/react-utils";import{getSelector as l}from"@radix-ui/utils";import u from"react";function s(){return(s=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function f(e,o){if(null==e)return{};var r,t,n=function(e,o){if(null==e)return{};var r,t,n={},c=Object.keys(e);for(t=0;t<c.length;t++)r=c[t],o.indexOf(r)>=0||(n[r]=e[r]);return n}(e,o);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(t=0;t<c.length;t++)r=c[t],o.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const[p,m]=c("AccordionContext","Accordion"),[A,b]=c("AccordionItemContext","AccordionItem");export const AccordionItem=u.forwardRef(((o,r)=>{const{value:t,children:n}=o,c=f(o,["value","children"]),a=m("AccordionItem"),d="accordion-button-".concat(i()),p=o.id||d,b=t&&t===a.value||!1,v=a.disabled||o.disabled,y=u.useMemo((()=>({open:b,buttonId:p})),[b,p]);return u.createElement(e,s({selector:l("AccordionItem")},c,{ref:r,"data-state":b?"open":"closed","data-disabled":v||void 0,disabled:v,open:b,onOpenChange:()=>a.setValue(t)}),u.createElement(A.Provider,{value:y},n))}));AccordionItem.displayName="AccordionItem";export const AccordionHeader=u.forwardRef(((e,o)=>u.createElement(t,s({as:"h3",selector:l("AccordionHeader")},e,{ref:o}))));AccordionHeader.displayName="AccordionHeader";export const AccordionButton=u.forwardRef(((e,r)=>{const{buttonNodesRef:t}=m("AccordionButton"),n=b("AccordionButton"),c=u.useRef(null),d=a(c,r);return u.useEffect((()=>{const e=t.current,o=c.current;if(o)return e.add(o),()=>{e.delete(o)}}),[t]),u.createElement(o,s({selector:l("AccordionButton")},e,{ref:d,"aria-disabled":n.open||void 0,id:n.buttonId}))}));AccordionButton.displayName="AccordionButton";export const AccordionPanel=u.forwardRef(((e,o)=>{const t=b("AccordionPanel");return u.createElement(r,s({selector:l("AccordionPanel")},e,{ref:o,role:"region","aria-labelledby":t.buttonId}))}));AccordionPanel.displayName="AccordionPanel";const v=["Home","End","ArrowDown","ArrowUp"];export const Accordion=u.forwardRef(((e,o)=>{const{value:r,defaultValue:c,children:i,disabled:m,onValueChange:A=(()=>{})}=e,b=f(e,["value","defaultValue","children","disabled","onValueChange"]),y=u.useRef(new Set),x=u.useRef(null),w=a(x,o),[h,g]=d({prop:r,defaultProp:c,onChange:e=>e&&A(e)}),I=n(e.onKeyDown,(e=>{var o;const r=e.target;if(!(v.includes(e.key)&&(t=r,t instanceof HTMLButtonElement)))return;var t;const n=[...y.current].filter((e=>!(e&&e.disabled))),c=n.length,a=n.indexOf(r);if(-1===a)return;e.preventDefault();let d=a;switch(e.key){case"Home":d=0;break;case"End":d=c-1;break;case"ArrowDown":d=a+1;break;case"ArrowUp":d=a-1,d<0&&(d=c-1)}null===(o=n[d%c])||void 0===o||o.focus()})),O=u.useMemo((()=>({disabled:m,buttonNodesRef:y,value:h,setValue:g})),[m,h,g]);return u.createElement(t,s({selector:l("Accordion")},b,{ref:w,onKeyDown:m?void 0:I}),u.createElement(p.Provider,{value:O},i))}));Accordion.displayName="Accordion";export const Root=Accordion;export const Item=AccordionItem;export const Header=AccordionHeader;export const Button=AccordionButton;export const Panel=AccordionPanel;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-accordion",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",

@@ -21,10 +21,8 @@ "source": "src/index.ts",

"dependencies": {
"@radix-ui/react-collapsible": "0.0.1",
"@radix-ui/react-polymorphic": "0.0.1",
"@radix-ui/react-utils": "0.0.1",
"@radix-ui/utils": "0.0.1"
"@radix-ui/react-collapsible": "0.0.2",
"@radix-ui/react-polymorphic": "0.0.2",
"@radix-ui/react-primitive": "0.0.1",
"@radix-ui/react-utils": "0.0.2",
"@radix-ui/utils": "0.0.2"
},
"devDependencies": {
"parcel": "^2.0.0-beta.1"
},
"peerDependencies": {

@@ -31,0 +29,0 @@ "react": "^16.8 || ^17.0"

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