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

@reach/accordion

Package Overview
Dependencies
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reach/accordion - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

9

dist/accordion.cjs.development.js

@@ -13,3 +13,2 @@ 'use strict';

var PropTypes = _interopDefault(require('prop-types'));
var warning = _interopDefault(require('warning'));

@@ -116,6 +115,6 @@ function _objectWithoutPropertiesLoose(source, excluded) {

{
warning(!(!isControlled && wasControlled), "Accordion is changing from controlled to uncontrolled. Accordion should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Accordion for the lifetime of the component. Check the `index` prop being passed in.") ;
warning(!(isControlled && !wasControlled), "Accordion is changing from uncontrolled to controlled. Accordion should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled Accordion for the lifetime of the component. Check the `index` prop being passed in.") ;
warning(!(isControlled && collapsible), "The `collapsible` prop on Accordion has no effect when the state of the component is controlled.") ;
warning(!(isControlled && multiple), "The `multiple` prop on Accordion has no effect when the state of the component is controlled.") ;
utils.warning(!(!isControlled && wasControlled), "Accordion is changing from controlled to uncontrolled. Accordion should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Accordion for the lifetime of the component. Check the `index` prop being passed in.") ;
utils.warning(!(isControlled && !wasControlled), "Accordion is changing from uncontrolled to controlled. Accordion should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled Accordion for the lifetime of the component. Check the `index` prop being passed in.") ;
utils.warning(!(isControlled && collapsible), "The `collapsible` prop on Accordion has no effect when the state of the component is controlled.") ;
utils.warning(!(isControlled && multiple), "The `multiple` prop on Accordion has no effect when the state of the component is controlled.") ;
}

@@ -122,0 +121,0 @@

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,r=require("@reach/utils"),o=require("@reach/descendants"),a=require("@reach/auto-id");function d(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(o[t]=e[t]);return o}require("prop-types"),require("warning");var c,i=o.createDescendantContext("AccordionDescendantContext"),s=r.createNamedContext("AccordionContext",{}),u=r.createNamedContext("AccordionItemContext",{});(c=exports.AccordionStates||(exports.AccordionStates={})).Open="OPEN",c.Collapsed="COLLAPSED";var l=n.forwardRef((function(e,c){var u=e.children,l=e.defaultIndex,f=e.index,p=e.onChange,x=e.readOnly,v=void 0!==x&&x,b=e.collapsible,A=void 0!==b&&b,h=e.multiple,m=void 0!==h&&h,I=d(e,["children","defaultIndex","index","onChange","readOnly","collapsible","multiple"]),C=n.useRef(void 0!==f).current,y=o.useDescendants(),O=y[0],w=y[1],D=a.useId(I.id),P=n.useState((function(){switch(!0){case C:return f;case null!=l:return m?Array.isArray(l)?l:[l]:Array.isArray(l)?null!==(e=l[0])&&void 0!==e?e:0:l;var e;case A:return m?[]:-1;default:return m?[0]:0}})),S=P[0],E=P[1],k=n.useCallback((function(e){p&&p(e),C||E((function(n){return e=e,m?(n=n).includes(e)?n.length>1||A?n.filter((function(n){return n!==e})):n:[].concat(n,[e]).sort():(n=n)===e&&A?-1:e}))}),[A,C,m,p]),g=n.useMemo((function(){return{accordionId:D,openPanels:C?f:S,onSelectPanel:v?r.noop:k,readOnly:v}}),[S,f,D,C,k,v]);return n.useEffect((function(){return r.checkStyles("accordion")}),[]),t.createElement(o.DescendantProvider,{context:i,items:O,set:w},t.createElement(s.Provider,{value:g},t.createElement("div",Object.assign({},I,{ref:c,"data-reach-accordion":""}),u)))})),f=r.forwardRefWithAs((function(e,a){var c=e.as,l=void 0===c?"div":c,f=e.children,p=e.disabled,x=void 0!==p&&p,b=d(e,["as","children","disabled"]),A=n.useContext(s),h=A.accordionId,m=A.openPanels,I=A.readOnly,C=n.useRef(null),y=o.useDescendant({context:i,element:C.current,disabled:x}),O=r.makeId(h,y),w=r.makeId("panel",O),D=r.makeId("button",O),P=(Array.isArray(m)?m.includes(y)&&exports.AccordionStates.Open:m===y&&exports.AccordionStates.Open)||exports.AccordionStates.Collapsed;return t.createElement(u.Provider,{value:{disabled:x,buttonId:D,index:y,itemId:O,buttonRef:C,panelId:w,state:P}},t.createElement(l,Object.assign({},b,{ref:a,"data-reach-accordion-item":"","data-state":v(P),"data-disabled":x?"":void 0,"data-read-only":I?"":void 0}),f))})),p=r.forwardRefWithAs((function(e,a){var c=e.as,l=void 0===c?"button":c,f=e.children,p=e.onClick,x=e.onKeyDown,v=e.tabIndex,b=d(e,["as","children","onClick","onKeyDown","onMouseDown","onPointerDown","tabIndex"]),A=n.useContext(s).onSelectPanel,h=n.useContext(u),m=h.disabled,I=h.buttonId,C=h.buttonRef,y=h.index,O=h.panelId,w=h.state,D=r.useForkedRef(a,C),P=o.useDescendantKeyDown(i,{currentIndex:y,orientation:"vertical",key:"element",rotate:!0,callback:function(e){e&&e.focus()},filter:function(e){return!e.disabled}});return t.createElement(l,Object.assign({"aria-controls":O,"aria-expanded":w===exports.AccordionStates.Open,tabIndex:m?-1:v},b,{ref:D,"data-reach-accordion-button":"",disabled:m||void 0,id:I,onClick:r.wrapEvent(p,(function(e){e.preventDefault(),m||(C.current.focus(),A(y))})),onKeyDown:r.wrapEvent(x,P)}),f)})),x=r.forwardRefWithAs((function(e,r){var o=e.as,a=void 0===o?"div":o,c=e.children,i=d(e,["as","children"]),s=n.useContext(u),l=s.panelId,f=s.state;return t.createElement(a,Object.assign({hidden:f!==exports.AccordionStates.Open,role:"region","aria-labelledby":s.buttonId},i,{ref:r,"data-reach-accordion-panel":"","data-disabled":s.disabled||void 0,"data-state":v(f),id:l,tabIndex:-1}),c)}));function v(e){return e===exports.AccordionStates.Open?"open":"collapsed"}exports.Accordion=l,exports.AccordionButton=p,exports.AccordionItem=f,exports.AccordionPanel=x,exports.useAccordionContext=function(){var e=n.useContext(s),t=e.openPanels,r=e.accordionId;return n.useMemo((function(){return{id:r,openPanels:[].concat(t).filter((function(e){return e<0}))}}),[r,t])},exports.useAccordionItemContext=function(){var e=n.useContext(u),t=e.index,r=e.state;return n.useMemo((function(){return{index:t,isExpanded:r===exports.AccordionStates.Open}}),[t,r])};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,r=require("@reach/utils"),o=require("@reach/descendants"),a=require("@reach/auto-id");function d(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(o[t]=e[t]);return o}require("prop-types");var c,i=o.createDescendantContext("AccordionDescendantContext"),s=r.createNamedContext("AccordionContext",{}),u=r.createNamedContext("AccordionItemContext",{});(c=exports.AccordionStates||(exports.AccordionStates={})).Open="OPEN",c.Collapsed="COLLAPSED";var l=n.forwardRef((function(e,c){var u=e.children,l=e.defaultIndex,f=e.index,p=e.onChange,x=e.readOnly,v=void 0!==x&&x,b=e.collapsible,A=void 0!==b&&b,h=e.multiple,m=void 0!==h&&h,I=d(e,["children","defaultIndex","index","onChange","readOnly","collapsible","multiple"]),C=n.useRef(void 0!==f).current,y=o.useDescendants(),O=y[0],D=y[1],P=a.useId(I.id),S=n.useState((function(){switch(!0){case C:return f;case null!=l:return m?Array.isArray(l)?l:[l]:Array.isArray(l)?null!==(e=l[0])&&void 0!==e?e:0:l;var e;case A:return m?[]:-1;default:return m?[0]:0}})),w=S[0],E=S[1],k=n.useCallback((function(e){p&&p(e),C||E((function(n){return e=e,m?(n=n).includes(e)?n.length>1||A?n.filter((function(n){return n!==e})):n:[].concat(n,[e]).sort():(n=n)===e&&A?-1:e}))}),[A,C,m,p]),g=n.useMemo((function(){return{accordionId:P,openPanels:C?f:w,onSelectPanel:v?r.noop:k,readOnly:v}}),[w,f,P,C,k,v]);return n.useEffect((function(){return r.checkStyles("accordion")}),[]),t.createElement(o.DescendantProvider,{context:i,items:O,set:D},t.createElement(s.Provider,{value:g},t.createElement("div",Object.assign({},I,{ref:c,"data-reach-accordion":""}),u)))})),f=r.forwardRefWithAs((function(e,a){var c=e.as,l=void 0===c?"div":c,f=e.children,p=e.disabled,x=void 0!==p&&p,b=d(e,["as","children","disabled"]),A=n.useContext(s),h=A.accordionId,m=A.openPanels,I=A.readOnly,C=n.useRef(null),y=o.useDescendant({context:i,element:C.current,disabled:x}),O=r.makeId(h,y),D=r.makeId("panel",O),P=r.makeId("button",O),S=(Array.isArray(m)?m.includes(y)&&exports.AccordionStates.Open:m===y&&exports.AccordionStates.Open)||exports.AccordionStates.Collapsed;return t.createElement(u.Provider,{value:{disabled:x,buttonId:P,index:y,itemId:O,buttonRef:C,panelId:D,state:S}},t.createElement(l,Object.assign({},b,{ref:a,"data-reach-accordion-item":"","data-state":v(S),"data-disabled":x?"":void 0,"data-read-only":I?"":void 0}),f))})),p=r.forwardRefWithAs((function(e,a){var c=e.as,l=void 0===c?"button":c,f=e.children,p=e.onClick,x=e.onKeyDown,v=e.tabIndex,b=d(e,["as","children","onClick","onKeyDown","onMouseDown","onPointerDown","tabIndex"]),A=n.useContext(s).onSelectPanel,h=n.useContext(u),m=h.disabled,I=h.buttonId,C=h.buttonRef,y=h.index,O=h.panelId,D=h.state,P=r.useForkedRef(a,C),S=o.useDescendantKeyDown(i,{currentIndex:y,orientation:"vertical",key:"element",rotate:!0,callback:function(e){e&&e.focus()},filter:function(e){return!e.disabled}});return t.createElement(l,Object.assign({"aria-controls":O,"aria-expanded":D===exports.AccordionStates.Open,tabIndex:m?-1:v},b,{ref:P,"data-reach-accordion-button":"",disabled:m||void 0,id:I,onClick:r.wrapEvent(p,(function(e){e.preventDefault(),m||(C.current.focus(),A(y))})),onKeyDown:r.wrapEvent(x,S)}),f)})),x=r.forwardRefWithAs((function(e,r){var o=e.as,a=void 0===o?"div":o,c=e.children,i=d(e,["as","children"]),s=n.useContext(u),l=s.panelId,f=s.state;return t.createElement(a,Object.assign({hidden:f!==exports.AccordionStates.Open,role:"region","aria-labelledby":s.buttonId},i,{ref:r,"data-reach-accordion-panel":"","data-disabled":s.disabled||void 0,"data-state":v(f),id:l,tabIndex:-1}),c)}));function v(e){return e===exports.AccordionStates.Open?"open":"collapsed"}exports.Accordion=l,exports.AccordionButton=p,exports.AccordionItem=f,exports.AccordionPanel=x,exports.useAccordionContext=function(){var e=n.useContext(s),t=e.openPanels,r=e.accordionId;return n.useMemo((function(){return{id:r,openPanels:[].concat(t).filter((function(e){return e<0}))}}),[r,t])},exports.useAccordionItemContext=function(){var e=n.useContext(u),t=e.index,r=e.state;return n.useMemo((function(){return{index:t,isExpanded:r===exports.AccordionStates.Open}}),[t,r])};
//# sourceMappingURL=accordion.cjs.production.min.js.map
import React, { forwardRef, useRef, useState, useCallback, useMemo, useEffect, useContext } from 'react';
import { noop, checkStyles, isNumber, isBoolean, forwardRefWithAs, makeId, useForkedRef, wrapEvent, createNamedContext } from '@reach/utils';
import { warning, noop, checkStyles, isNumber, isBoolean, forwardRefWithAs, makeId, useForkedRef, wrapEvent, createNamedContext } from '@reach/utils';
import { useDescendants, DescendantProvider, useDescendant, useDescendantKeyDown, createDescendantContext } from '@reach/descendants';
import { useId } from '@reach/auto-id';
import PropTypes from 'prop-types';
import warning from 'warning';

@@ -8,0 +7,0 @@ function _objectWithoutPropertiesLoose(source, excluded) {

{
"name": "@reach/accordion",
"version": "0.10.0",
"version": "0.10.1",
"description": "Accessible React accordion component",

@@ -16,7 +16,6 @@ "author": "React Training <hello@reacttraining.com>",

"dependencies": {
"@reach/auto-id": "^0.10.0",
"@reach/descendants": "^0.10.0",
"@reach/utils": "^0.10.0",
"tslib": "^1.10.0",
"warning": "^4.0.3"
"@reach/auto-id": "^0.10.1",
"@reach/descendants": "^0.10.1",
"@reach/utils": "^0.10.1",
"tslib": "^1.11.1"
},

@@ -35,3 +34,3 @@ "peerDependencies": {

],
"gitHead": "e95268bdcebc7f0b5311beff4b6a8e29636decfe"
"gitHead": "c279bc0fb9ae84aa77306c5f1a9909d088bc665c"
}

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