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

@szhsin/react-accordion

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@szhsin/react-accordion - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

168

dist/cjs/index.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var react = require('react');

@@ -13,3 +11,2 @@ var reactTransitionState = require('react-transition-state');

var source = arguments[i];
for (var key in source) {

@@ -21,3 +18,2 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;

@@ -27,3 +23,2 @@ };

}
function _objectWithoutPropertiesLoose(source, excluded) {

@@ -34,3 +29,2 @@ if (source == null) return {};

var key, i;
for (i = 0; i < sourceKeys.length; i++) {

@@ -41,3 +35,2 @@ key = sourceKeys[i];

}
return target;

@@ -47,13 +40,10 @@ }

var _excluded$4 = ["transition", "transitionTimeout"];
var getTransition = function getTransition(transition, name) {
return transition === true || !!(transition && transition[name]);
};
var useAccordionProvider = function useAccordionProvider(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
var transitionMap = reactTransitionState.useTransitionMap(_extends({

@@ -87,3 +77,2 @@ timeout: transitionTimeout,

var expandedClassName = typeof className === 'function' ? className(props) : className;
if (typeof expandedClassName === 'string') {

@@ -93,3 +82,2 @@ expandedClassName = expandedClassName.trim();

}
return classString;

@@ -101,9 +89,6 @@ };

if (!source) return target;
var result = _extends({}, target);
Object.keys(source).forEach(function (key) {
var targetProp = target[key];
var sourceProp = source[key];
if (typeof sourceProp === 'function' && targetProp) {

@@ -129,25 +114,19 @@ result[key] = function () {

} while (node && !node.hasAttribute(ACCORDION_ATTR));
return node;
};
var getNextIndex = function getNextIndex(moveUp, current, length) {
return moveUp ? current > 0 ? current - 1 : length - 1 : (current + 1) % length;
};
var moveFocus = function moveFocus(moveUp, e) {
var _document = document,
activeElement = _document.activeElement;
activeElement = _document.activeElement;
if (!activeElement || !activeElement.hasAttribute(ACCORDION_BTN_ATTR) || getAccordion(activeElement) !== e.currentTarget) return;
var nodes = e.currentTarget.querySelectorAll("[" + ACCORDION_BTN_ATTR + "]");
var length = nodes.length;
for (var i = 0; i < length; i++) {
if (nodes[i] === activeElement) {
var next = getNextIndex(moveUp, i, length);
while (getAccordion(nodes[i]) !== getAccordion(nodes[next])) {
next = getNextIndex(moveUp, next, length);
}
if (i !== next) {

@@ -157,3 +136,2 @@ e.preventDefault();

}
break;

@@ -163,6 +141,4 @@ }

};
var useAccordion = function useAccordion() {
var _accordionProps;
var accordionProps = (_accordionProps = {}, _accordionProps[ACCORDION_ATTR] = '', _accordionProps.onKeyDown = function onKeyDown(e) {

@@ -179,8 +155,6 @@ return e.key === 'ArrowUp' ? moveFocus(true, e) : e.key === 'ArrowDown' && moveFocus(false, e);

var providerValue = _ref.providerValue,
className = _ref.className,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
className = _ref.className,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
var _useAccordion = useAccordion(),
accordionProps = _useAccordion.accordionProps;
accordionProps = _useAccordion.accordionProps;
return /*#__PURE__*/jsxRuntime.jsx(AccordionProvider, {

@@ -199,10 +173,9 @@ value: providerValue,

var allowMultiple = _ref.allowMultiple,
initialEntered = _ref.initialEntered,
mountOnEnter = _ref.mountOnEnter,
unmountOnExit = _ref.unmountOnExit,
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
onStateChange = _ref.onStateChange,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
initialEntered = _ref.initialEntered,
mountOnEnter = _ref.mountOnEnter,
unmountOnExit = _ref.unmountOnExit,
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
onStateChange = _ref.onStateChange,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
var providerValue = useAccordionProvider({

@@ -225,8 +198,6 @@ allowMultiple: allowMultiple,

var current = 0;
var useIdShim = function useIdShim() {
var _useState = react.useState(),
id = _useState[0],
setId = _useState[1];
id = _useState[0],
setId = _useState[1];
react.useEffect(function () {

@@ -237,15 +208,17 @@ return setId(++current);

};
var _useId = react.useId || useIdShim;
var useAccordionItem = function useAccordionItem(_ref) {
var _buttonProps;
var state = _ref.state,
toggle = _ref.toggle;
toggle = _ref.toggle,
disabled = _ref.disabled;
var buttonId = _useId();
var panelId = buttonId && buttonId + '-';
var buttonProps = (_buttonProps = {
id: buttonId
}, _buttonProps[ACCORDION_BTN_ATTR] = '', _buttonProps['aria-controls'] = panelId, _buttonProps['aria-expanded'] = state.isEnter, _buttonProps.onClick = toggle, _buttonProps);
var buttonProps = {
id: buttonId,
'aria-controls': panelId,
'aria-expanded': state.isEnter,
onClick: toggle
};
disabled ? buttonProps.disabled = true : buttonProps[ACCORDION_BTN_ATTR] = '';
var panelProps = {

@@ -266,8 +239,6 @@ id: panelId,

var status = _ref.status,
isResolved = _ref.isResolved;
isResolved = _ref.isResolved;
var _useState = react.useState(),
height = _useState[0],
setHeight = _useState[1];
height = _useState[0],
setHeight = _useState[1];
var elementRef = react.useRef(null);

@@ -287,3 +258,2 @@ useIsomorphicLayoutEffect(function () {

}
function useMergeRef(refA, refB) {

@@ -302,7 +272,5 @@ return react.useMemo(function () {

var stateMap = providerValue.stateMap,
mountOnEnter = providerValue.mountOnEnter,
initialEntered = providerValue.initialEntered;
mountOnEnter = providerValue.mountOnEnter,
initialEntered = providerValue.initialEntered;
var _initialEntered = itemInitialEntered != null ? itemInitialEntered : initialEntered;
return stateMap.get(key) || {

@@ -315,10 +283,7 @@ status: _initialEntered ? 'entered' : mountOnEnter ? 'unmounted' : 'exited',

}
var useAccordionContext = function useAccordionContext() {
var context = react.useContext(AccordionContext);
if (process.env.NODE_ENV !== 'production' && !context.stateMap) {
throw new Error('[React-Accordion] Cannot find a <AccordionProvider/> above this AccordionItem.');
}
return context;

@@ -329,5 +294,5 @@ };

var _ref = _temp === void 0 ? {} : _temp,
itemKey = _ref.itemKey,
initialEntered = _ref.initialEntered;
itemKey = _ref.itemKey,
initialEntered = _ref.initialEntered,
disabled = _ref.disabled;
var itemRef = react.useRef(null);

@@ -338,5 +303,6 @@ var context = useAccordionContext();

var setItem = context.setItem,
deleteItem = context.deleteItem,
toggle = context.toggle;
deleteItem = context.deleteItem,
toggle = context.toggle;
react.useEffect(function () {
if (disabled) return;
var key = itemKey != null ? itemKey : itemRef.current;

@@ -349,3 +315,3 @@ setItem(key, {

};
}, [setItem, deleteItem, itemKey, initialEntered]);
}, [setItem, deleteItem, itemKey, initialEntered, disabled]);
return {

@@ -361,9 +327,7 @@ itemRef: itemRef,

var _excluded$1 = ["itemKey", "initialEntered"];
var withAccordionItem = function withAccordionItem(WrappedItem) {
var WithAccordionItem = /*#__PURE__*/react.forwardRef(function (_ref, ref) {
var itemKey = _ref.itemKey,
initialEntered = _ref.initialEntered,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
initialEntered = _ref.initialEntered,
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
return /*#__PURE__*/jsxRuntime.jsx(WrappedItem, _extends({

@@ -373,3 +337,4 @@ forwardedRef: ref

itemKey: itemKey,
initialEntered: initialEntered
initialEntered: initialEntered,
disabled: rest.disabled
})));

@@ -381,40 +346,36 @@ });

var _excluded = ["forwardedRef", "itemRef", "state", "toggle", "className", "header", "headingTag", "headingProps", "buttonProps", "contentProps", "panelProps", "children"];
var _excluded = ["forwardedRef", "itemRef", "state", "toggle", "className", "disabled", "header", "headingTag", "headingProps", "buttonProps", "contentProps", "panelProps", "children"];
var getRenderNode = function getRenderNode(nodeOrFunc, props) {
return typeof nodeOrFunc === 'function' ? nodeOrFunc(props) : nodeOrFunc;
};
var WrappedItem = /*#__PURE__*/react.memo(function (_ref) {
var forwardedRef = _ref.forwardedRef,
itemRef = _ref.itemRef,
state = _ref.state,
toggle = _ref.toggle,
className = _ref.className,
header = _ref.header,
headingTag = _ref.headingTag,
headingProps = _ref.headingProps,
buttonProps = _ref.buttonProps,
contentProps = _ref.contentProps,
panelProps = _ref.panelProps,
children = _ref.children,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
itemRef = _ref.itemRef,
state = _ref.state,
toggle = _ref.toggle,
className = _ref.className,
disabled = _ref.disabled,
header = _ref.header,
headingTag = _ref.headingTag,
headingProps = _ref.headingProps,
buttonProps = _ref.buttonProps,
contentProps = _ref.contentProps,
panelProps = _ref.panelProps,
children = _ref.children,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
var itemState = {
state: state,
toggle: toggle
toggle: toggle,
disabled: disabled
};
var _useAccordionItem = useAccordionItem(itemState),
_buttonProps = _useAccordionItem.buttonProps,
_panelProps = _useAccordionItem.panelProps;
_buttonProps = _useAccordionItem.buttonProps,
_panelProps = _useAccordionItem.panelProps;
var _useHeightTransition = useHeightTransition(state),
transitionStyle = _useHeightTransition[0],
_panelRef = _useHeightTransition[1];
transitionStyle = _useHeightTransition[0],
_panelRef = _useHeightTransition[1];
var panelRef = useMergeRef(panelProps && panelProps.ref, _panelRef);
var status = state.status,
isMounted = state.isMounted,
isEnter = state.isEnter;
isMounted = state.isMounted,
isEnter = state.isEnter;
return /*#__PURE__*/jsxRuntime.jsxs("div", _extends({}, rest, {

@@ -456,4 +417,3 @@ ref: useMergeRef(forwardedRef, itemRef),

var _ref = _temp === void 0 ? {} : _temp,
initialEntered = _ref.initialEntered;
initialEntered = _ref.initialEntered;
return getItemState(context, key, initialEntered);

@@ -460,0 +420,0 @@ },

@@ -5,3 +5,2 @@ function _extends() {

var source = arguments[i];
for (var key in source) {

@@ -13,3 +12,2 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;

@@ -19,3 +17,2 @@ };

}
function _objectWithoutPropertiesLoose(source, excluded) {

@@ -26,3 +23,2 @@ if (source == null) return {};

var key, i;
for (i = 0; i < sourceKeys.length; i++) {

@@ -33,3 +29,2 @@ key = sourceKeys[i];

}
return target;

@@ -36,0 +31,0 @@ }

@@ -10,10 +10,9 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';

var allowMultiple = _ref.allowMultiple,
initialEntered = _ref.initialEntered,
mountOnEnter = _ref.mountOnEnter,
unmountOnExit = _ref.unmountOnExit,
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
onStateChange = _ref.onStateChange,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
initialEntered = _ref.initialEntered,
mountOnEnter = _ref.mountOnEnter,
unmountOnExit = _ref.unmountOnExit,
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
onStateChange = _ref.onStateChange,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
var providerValue = useAccordionProvider({

@@ -20,0 +19,0 @@ allowMultiple: allowMultiple,

@@ -12,40 +12,36 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';

var _excluded = ["forwardedRef", "itemRef", "state", "toggle", "className", "header", "headingTag", "headingProps", "buttonProps", "contentProps", "panelProps", "children"];
var _excluded = ["forwardedRef", "itemRef", "state", "toggle", "className", "disabled", "header", "headingTag", "headingProps", "buttonProps", "contentProps", "panelProps", "children"];
var getRenderNode = function getRenderNode(nodeOrFunc, props) {
return typeof nodeOrFunc === 'function' ? nodeOrFunc(props) : nodeOrFunc;
};
var WrappedItem = /*#__PURE__*/memo(function (_ref) {
var forwardedRef = _ref.forwardedRef,
itemRef = _ref.itemRef,
state = _ref.state,
toggle = _ref.toggle,
className = _ref.className,
header = _ref.header,
headingTag = _ref.headingTag,
headingProps = _ref.headingProps,
buttonProps = _ref.buttonProps,
contentProps = _ref.contentProps,
panelProps = _ref.panelProps,
children = _ref.children,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
itemRef = _ref.itemRef,
state = _ref.state,
toggle = _ref.toggle,
className = _ref.className,
disabled = _ref.disabled,
header = _ref.header,
headingTag = _ref.headingTag,
headingProps = _ref.headingProps,
buttonProps = _ref.buttonProps,
contentProps = _ref.contentProps,
panelProps = _ref.panelProps,
children = _ref.children,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
var itemState = {
state: state,
toggle: toggle
toggle: toggle,
disabled: disabled
};
var _useAccordionItem = useAccordionItem(itemState),
_buttonProps = _useAccordionItem.buttonProps,
_panelProps = _useAccordionItem.panelProps;
_buttonProps = _useAccordionItem.buttonProps,
_panelProps = _useAccordionItem.panelProps;
var _useHeightTransition = useHeightTransition(state),
transitionStyle = _useHeightTransition[0],
_panelRef = _useHeightTransition[1];
transitionStyle = _useHeightTransition[0],
_panelRef = _useHeightTransition[1];
var panelRef = useMergeRef(panelProps && panelProps.ref, _panelRef);
var status = state.status,
isMounted = state.isMounted,
isEnter = state.isEnter;
isMounted = state.isMounted,
isEnter = state.isEnter;
return /*#__PURE__*/jsxs("div", _extends({}, rest, {

@@ -52,0 +48,0 @@ ref: useMergeRef(forwardedRef, itemRef),

@@ -13,8 +13,6 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';

var providerValue = _ref.providerValue,
className = _ref.className,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
className = _ref.className,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
var _useAccordion = useAccordion(),
accordionProps = _useAccordion.accordionProps;
accordionProps = _useAccordion.accordionProps;
return /*#__PURE__*/jsx(AccordionProvider, {

@@ -21,0 +19,0 @@ value: providerValue,

@@ -7,9 +7,7 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';

var _excluded = ["itemKey", "initialEntered"];
var withAccordionItem = function withAccordionItem(WrappedItem) {
var WithAccordionItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
var itemKey = _ref.itemKey,
initialEntered = _ref.initialEntered,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
initialEntered = _ref.initialEntered,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
return /*#__PURE__*/jsx(WrappedItem, _extends({

@@ -19,3 +17,4 @@ forwardedRef: ref

itemKey: itemKey,
initialEntered: initialEntered
initialEntered: initialEntered,
disabled: rest.disabled
})));

@@ -22,0 +21,0 @@ });

@@ -7,25 +7,19 @@ import { ACCORDION_ATTR, ACCORDION_BTN_ATTR } from '../utils/constants.js';

} while (node && !node.hasAttribute(ACCORDION_ATTR));
return node;
};
var getNextIndex = function getNextIndex(moveUp, current, length) {
return moveUp ? current > 0 ? current - 1 : length - 1 : (current + 1) % length;
};
var moveFocus = function moveFocus(moveUp, e) {
var _document = document,
activeElement = _document.activeElement;
activeElement = _document.activeElement;
if (!activeElement || !activeElement.hasAttribute(ACCORDION_BTN_ATTR) || getAccordion(activeElement) !== e.currentTarget) return;
var nodes = e.currentTarget.querySelectorAll("[" + ACCORDION_BTN_ATTR + "]");
var length = nodes.length;
for (var i = 0; i < length; i++) {
if (nodes[i] === activeElement) {
var next = getNextIndex(moveUp, i, length);
while (getAccordion(nodes[i]) !== getAccordion(nodes[next])) {
next = getNextIndex(moveUp, next, length);
}
if (i !== next) {

@@ -35,3 +29,2 @@ e.preventDefault();

}
break;

@@ -41,6 +34,4 @@ }

};
var useAccordion = function useAccordion() {
var _accordionProps;
var accordionProps = (_accordionProps = {}, _accordionProps[ACCORDION_ATTR] = '', _accordionProps.onKeyDown = function onKeyDown(e) {

@@ -47,0 +38,0 @@ return e.key === 'ArrowUp' ? moveFocus(true, e) : e.key === 'ArrowDown' && moveFocus(false, e);

@@ -6,7 +6,5 @@ import { useContext } from 'react';

var stateMap = providerValue.stateMap,
mountOnEnter = providerValue.mountOnEnter,
initialEntered = providerValue.initialEntered;
mountOnEnter = providerValue.mountOnEnter,
initialEntered = providerValue.initialEntered;
var _initialEntered = itemInitialEntered != null ? itemInitialEntered : initialEntered;
return stateMap.get(key) || {

@@ -19,10 +17,7 @@ status: _initialEntered ? 'entered' : mountOnEnter ? 'unmounted' : 'exited',

}
var useAccordionContext = function useAccordionContext() {
var context = useContext(AccordionContext);
if (process.env.NODE_ENV !== 'production' && !context.stateMap) {
throw new Error('[React-Accordion] Cannot find a <AccordionProvider/> above this AccordionItem.');
}
return context;

@@ -29,0 +24,0 @@ };

@@ -5,11 +5,14 @@ import { ACCORDION_BTN_ATTR } from '../utils/constants.js';

var useAccordionItem = function useAccordionItem(_ref) {
var _buttonProps;
var state = _ref.state,
toggle = _ref.toggle;
toggle = _ref.toggle,
disabled = _ref.disabled;
var buttonId = _useId();
var panelId = buttonId && buttonId + '-';
var buttonProps = (_buttonProps = {
id: buttonId
}, _buttonProps[ACCORDION_BTN_ATTR] = '', _buttonProps['aria-controls'] = panelId, _buttonProps['aria-expanded'] = state.isEnter, _buttonProps.onClick = toggle, _buttonProps);
var buttonProps = {
id: buttonId,
'aria-controls': panelId,
'aria-expanded': state.isEnter,
onClick: toggle
};
disabled ? buttonProps.disabled = true : buttonProps[ACCORDION_BTN_ATTR] = '';
var panelProps = {

@@ -16,0 +19,0 @@ id: panelId,

@@ -6,5 +6,5 @@ import { useRef, useEffect, useCallback } from 'react';

var _ref = _temp === void 0 ? {} : _temp,
itemKey = _ref.itemKey,
initialEntered = _ref.initialEntered;
itemKey = _ref.itemKey,
initialEntered = _ref.initialEntered,
disabled = _ref.disabled;
var itemRef = useRef(null);

@@ -15,5 +15,6 @@ var context = useAccordionContext();

var setItem = context.setItem,
deleteItem = context.deleteItem,
toggle = context.toggle;
deleteItem = context.deleteItem,
toggle = context.toggle;
useEffect(function () {
if (disabled) return;
var key = itemKey != null ? itemKey : itemRef.current;

@@ -26,3 +27,3 @@ setItem(key, {

};
}, [setItem, deleteItem, itemKey, initialEntered]);
}, [setItem, deleteItem, itemKey, initialEntered, disabled]);
return {

@@ -29,0 +30,0 @@ itemRef: itemRef,

@@ -5,13 +5,10 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';

var _excluded = ["transition", "transitionTimeout"];
var getTransition = function getTransition(transition, name) {
return transition === true || !!(transition && transition[name]);
};
var useAccordionProvider = function useAccordionProvider(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
transition = _ref.transition,
transitionTimeout = _ref.transitionTimeout,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
var transitionMap = useTransitionMap(_extends({

@@ -18,0 +15,0 @@ timeout: transitionTimeout,

@@ -8,4 +8,3 @@ import { useAccordionContext, getItemState } from './useAccordionContext.js';

var _ref = _temp === void 0 ? {} : _temp,
initialEntered = _ref.initialEntered;
initialEntered = _ref.initialEntered;
return getItemState(context, key, initialEntered);

@@ -12,0 +11,0 @@ },

@@ -6,8 +6,6 @@ import { useState, useRef } from 'react';

var status = _ref.status,
isResolved = _ref.isResolved;
isResolved = _ref.isResolved;
var _useState = useState(),
height = _useState[0],
setHeight = _useState[1];
height = _useState[0],
setHeight = _useState[1];
var elementRef = useRef(null);

@@ -14,0 +12,0 @@ useIsomorphicLayoutEffect(function () {

@@ -5,8 +5,6 @@ import { useId, useState, useEffect } from 'react';

var current = 0;
var useIdShim = function useIdShim() {
var _useState = useState(),
id = _useState[0],
setId = _useState[1];
id = _useState[0],
setId = _useState[1];
useEffect(function () {

@@ -17,5 +15,4 @@ return setId(++current);

};
var _useId = useId || useIdShim;
export { _useId as useId };

@@ -6,3 +6,2 @@ import { useMemo } from 'react';

}
function useMergeRef(refA, refB) {

@@ -9,0 +8,0 @@ return useMemo(function () {

@@ -10,3 +10,2 @@ var bem = function bem(block, element, modifiers) {

var expandedClassName = typeof className === 'function' ? className(props) : className;
if (typeof expandedClassName === 'string') {

@@ -16,3 +15,2 @@ expandedClassName = expandedClassName.trim();

}
return classString;

@@ -19,0 +17,0 @@ };

@@ -5,9 +5,6 @@ import { extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';

if (!source) return target;
var result = _extends({}, target);
Object.keys(source).forEach(function (key) {
var targetProp = target[key];
var sourceProp = source[key];
if (typeof sourceProp === 'function' && targetProp) {

@@ -14,0 +11,0 @@ result[key] = function () {

{
"name": "@szhsin/react-accordion",
"version": "1.0.1",
"version": "1.1.0",
"description": "An unstyled, accessible accordion library for building React apps and design systems.",

@@ -56,30 +56,30 @@ "author": "Zheng Song",

"devDependencies": {
"@babel/core": "^7.19.0",
"@babel/preset-env": "^7.18.10",
"@babel/core": "^7.20.7",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-node-resolve": "^15.0.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.0.0",
"@types/react": "^18.0.18",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.2",
"@types/jest": "^29.2.5",
"@types/react": "^18.0.26",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"babel-plugin-pure-annotations": "^0.1.2",
"eslint": "^8.23.0",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.0.1",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks-addons": "^0.3.1",
"jest": "^29.0.2",
"jest-environment-jsdom": "^29.0.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"prettier": "^2.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup": "^2.79.0",
"typescript": "^4.8.2"
"rollup": "^3.10.0",
"typescript": "^4.9.4"
}
}

@@ -7,3 +7,3 @@ import { ReactNode, ForwardedRef } from 'react';

}
declare type NodeOrFunc = ReactNode | ((props: ItemState) => ReactNode);
type NodeOrFunc = ReactNode | ((props: ItemState) => ReactNode);
interface AccordionItemProps extends ItemStateOptions, ElementProps<HTMLDivElement, TransitionState> {

@@ -10,0 +10,0 @@ header?: NodeOrFunc;

@@ -1,7 +0,7 @@

import { HTMLAttributes } from 'react';
import { HTMLAttributes, ButtonHTMLAttributes } from 'react';
import { ItemState } from '../utils/constants';
declare const useAccordionItem: ({ state, toggle }: ItemState) => {
buttonProps: HTMLAttributes<Element>;
declare const useAccordionItem: ({ state, toggle, disabled }: ItemState) => {
buttonProps: ButtonHTMLAttributes<Element>;
panelProps: HTMLAttributes<Element>;
};
export { useAccordionItem };
/// <reference types="react" />
import { ItemStateOptions } from '../utils/constants';
declare const useAccordionItemEffect: <E extends Element>({ itemKey, initialEntered }?: ItemStateOptions) => {
declare const useAccordionItemEffect: <E extends Element>({ itemKey, initialEntered, disabled }?: ItemStateOptions) => {
itemRef: import("react").RefObject<E>;

@@ -5,0 +5,0 @@ state: Readonly<{

import { RefCallback, MutableRefObject } from 'react';
declare type Ref<T> = RefCallback<T> | MutableRefObject<T | null>;
type Ref<T> = RefCallback<T> | MutableRefObject<T | null>;
declare function useMergeRef<T>(refA?: Ref<T> | null, refB?: Ref<T> | null): Ref<T> | null | undefined;
export { useMergeRef };

@@ -7,6 +7,6 @@ import { HTMLAttributes } from 'react';

export declare const ACCORDION_BTN_ATTR: string;
export declare type Modifiers = {
export type Modifiers = {
readonly [index: string]: boolean | string;
};
export declare type ClassNameProp<P> = string | ((props: P) => string);
export type ClassNameProp<P> = string | ((props: P) => string);
export interface ElementProps<E extends HTMLElement, P = undefined> extends Omit<HTMLAttributes<E>, 'className' | 'children'> {

@@ -16,4 +16,4 @@ className?: P extends undefined ? string : ClassNameProp<P>;

}
export declare type ItemKey = Element | string | number;
export declare type TransitionProp = boolean | {
export type ItemKey = Element | string | number;
export type TransitionProp = boolean | {
enter?: boolean;

@@ -27,2 +27,3 @@ exit?: boolean;

readonly toggle: (toEnter?: boolean) => void;
disabled?: boolean;
}

@@ -32,2 +33,3 @@ export interface ItemStateOptions {

initialEntered?: boolean;
disabled?: boolean;
}

@@ -34,0 +36,0 @@ export interface AccordionProviderOptions extends Omit<TransitionMapOptions<ItemKey>, 'enter' | 'exit' | 'preEnter' | 'preExit' | 'timeout'> {

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