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

@interop-ui/react-accordion

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.0.1-6 to 0.0.1-7

2

dist/index.module.js

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

import{Collapsible as e,styles as t}from"@interop-ui/react-collapsible";import{composeEventHandlers as n,createContext as r,createStyleObj as o,forwardRef as c,useComposedRefs as i,useControlledState as a,useId as l}from"@interop-ui/react-utils";import{cssReset as u}from"@interop-ui/utils";import d from"react";function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(){return(b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function m(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}const[O,y]=r("AccordionContext","Accordion"),[v,g]=r("AccordionItemContext","Accordion.Item"),A=c((function(t,n){var r;const{value:o,isOpen:c,defaultIsOpen:i,children:a,onToggle:u}=t,s=m(t,["value","isOpen","defaultIsOpen","children","onToggle"]),f=y("Accordion.Item"),p="accordion-button-".concat(l()),O=t.id||p,g=o&&o===f.value||!1,A=d.useMemo(()=>({isOpen:g,buttonId:O}),[g,O]);return d.createElement(e,b({},s,k("item"),{ref:n,disabled:null!==(r=f.isDisabled)&&void 0!==r?r:t.disabled,isOpen:g,onToggle:()=>f.setValue(o)}),d.createElement(v.Provider,{value:A},a))})),h="h3",w=c((function(e,t){const{as:n=h}=e,r=m(e,["as"]);return d.createElement(n,b({ref:t},r,k("header")))})),j=c((function(t,n){const r=Object.assign({},t),{buttonNodesRef:o}=y("Accordion.Button"),c=g("Accordion.Button"),a=d.useRef(null),l=i(a,n);return d.useEffect(()=>{const e=o.current,t=a.current;if(t)return e.add(t),()=>{e.delete(t)}},[o]),d.createElement(e.Button,b({},r,k("button"),{ref:l,"aria-disabled":c.isOpen||void 0,id:c.buttonId}))})),P=c((function(t,n){const r=g("Accordion.Panel");return d.createElement(e.Content,b({},t,k("panel"),{ref:n,role:"region","aria-labelledby":r.buttonId}))})),E="div",I=["Home","End","ArrowDown","ArrowUp"];export const Accordion=c((function(e,t){const{as:r=E,value:o,defaultValue:c,children:l,disabled:u,onChange:s=(()=>{})}=e,f=m(e,["as","value","defaultValue","children","disabled","onChange"]),p=d.useRef(new Set),y=d.useRef(null),v=i(y,t),[g,A]=a({prop:o,defaultProp:c,onChange:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(e=>e&&s(e))}),h=n(e.onKeyDown,e=>{var t;const n=e.target;if(!(I.includes(e.key)&&(r=n,r instanceof HTMLButtonElement)))return;var r;const o=[...p.current].filter(e=>!(e&&e.disabled)),c=o.length,i=o.indexOf(n);if(-1===i)return;e.preventDefault();let a=i;switch(e.key){case"Home":a=0;break;case"End":a=c-1;break;case"ArrowDown":a=i+1;break;case"ArrowUp":a=i-1,a<0&&(a=c-1)}null===(t=o[a%c])||void 0===t||t.focus()}),w=d.useMemo(()=>({isDisabled:u,buttonNodesRef:p,value:g,setValue:A}),[u,g,A]);return d.createElement(r,b({},f,k("root"),{ref:v,onKeyDown:u?void 0:h}),d.createElement(O.Provider,{value:w},l))}));Accordion.Item=A,Accordion.Header=w,Accordion.Button=j,Accordion.Panel=P,Accordion.displayName="Accordion",Accordion.Item.displayName="Accordion.Item",Accordion.Header.displayName="Accordion.Header",Accordion.Button.displayName="Accordion.Button",Accordion.Panel.displayName="Accordion.Panel";const[D,k]=o("Accordion",{root:f({},u(E)),item:f(f({},u("div")),t.root),header:f({},u(h)),button:f(f({},u("button")),t.button),panel:f(f({},u("div")),t.content)});export{D as styles};
import{Collapsible as e,styles as t}from"@interop-ui/react-collapsible";import{composeEventHandlers as n,createContext as r,createStyleObj as o,forwardRef as c,useComposedRefs as i,useControlledState as a,useId as l}from"@interop-ui/react-utils";import{cssReset as u}from"@interop-ui/utils";import d from"react";function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(){return(b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function m(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}const[O,y]=r("AccordionContext","Accordion"),[v,g]=r("AccordionItemContext","Accordion.Item"),A=c((function(t,n){var r;const{value:o,isOpen:c,defaultIsOpen:i,children:a,onToggle:u}=t,s=m(t,["value","isOpen","defaultIsOpen","children","onToggle"]),f=y("Accordion.Item"),p="accordion-button-".concat(l()),O=t.id||p,g=o&&o===f.value||!1,A=d.useMemo((()=>({isOpen:g,buttonId:O})),[g,O]);return d.createElement(e,b({},s,k("item"),{ref:n,disabled:null!==(r=f.isDisabled)&&void 0!==r?r:t.disabled,isOpen:g,onToggle:()=>f.setValue(o)}),d.createElement(v.Provider,{value:A},a))})),h="h3",w=c((function(e,t){const{as:n=h}=e,r=m(e,["as"]);return d.createElement(n,b({ref:t},r,k("header")))})),j=c((function(t,n){const r=Object.assign({},t),{buttonNodesRef:o}=y("Accordion.Button"),c=g("Accordion.Button"),a=d.useRef(null),l=i(a,n);return d.useEffect((()=>{const e=o.current,t=a.current;if(t)return e.add(t),()=>{e.delete(t)}}),[o]),d.createElement(e.Button,b({},r,k("button"),{ref:l,"aria-disabled":c.isOpen||void 0,id:c.buttonId}))})),P=c((function(t,n){const r=g("Accordion.Panel");return d.createElement(e.Content,b({},t,k("panel"),{ref:n,role:"region","aria-labelledby":r.buttonId}))})),E="div",I=["Home","End","ArrowDown","ArrowUp"];export const Accordion=c((function(e,t){const{as:r=E,value:o,defaultValue:c,children:l,disabled:u,onChange:s=(()=>{})}=e,f=m(e,["as","value","defaultValue","children","disabled","onChange"]),p=d.useRef(new Set),y=d.useRef(null),v=i(y,t),[g,A]=a({prop:o,defaultProp:c,onChange:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((e=>e&&s(e)))}),h=n(e.onKeyDown,(e=>{var t;const n=e.target;if(!(I.includes(e.key)&&(r=n,r instanceof HTMLButtonElement)))return;var r;const o=[...p.current].filter((e=>!(e&&e.disabled))),c=o.length,i=o.indexOf(n);if(-1===i)return;e.preventDefault();let a=i;switch(e.key){case"Home":a=0;break;case"End":a=c-1;break;case"ArrowDown":a=i+1;break;case"ArrowUp":a=i-1,a<0&&(a=c-1)}null===(t=o[a%c])||void 0===t||t.focus()})),w=d.useMemo((()=>({isDisabled:u,buttonNodesRef:p,value:g,setValue:A})),[u,g,A]);return d.createElement(r,b({},f,k("root"),{ref:v,onKeyDown:u?void 0:h}),d.createElement(O.Provider,{value:w},l))}));Accordion.Item=A,Accordion.Header=w,Accordion.Button=j,Accordion.Panel=P,Accordion.displayName="Accordion",Accordion.Item.displayName="Accordion.Item",Accordion.Header.displayName="Accordion.Header",Accordion.Button.displayName="Accordion.Button",Accordion.Panel.displayName="Accordion.Panel";const[D,k]=o("Accordion",{root:f({},u(E)),item:f(f({},u("div")),t.root),header:f({},u(h)),button:f(f({},u("button")),t.button),panel:f(f({},u("div")),t.content)});export{D as styles};
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/react-accordion",
"version": "0.0.1-6",
"version": "0.0.1-7",
"license": "MIT",

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

"dependencies": {
"@interop-ui/react-collapsible": "0.0.1-5",
"@interop-ui/react-utils": "0.0.1-5",
"@interop-ui/react-collapsible": "0.0.1-6",
"@interop-ui/react-utils": "0.0.1-6",
"@interop-ui/utils": "0.0.1-3"

@@ -25,0 +25,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