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 0.11.0 to 0.12.0

32

dist/cjs/index.js

@@ -252,38 +252,14 @@ 'use strict';

var _useState = react.useState(),
_height = _useState[0],
height = _useState[0],
setHeight = _useState[1];
var elementRef = react.useRef(null);
var resizeObserver = react.useRef();
var cbRef = react.useCallback(function (element) {
var _resizeObserver$curre;
elementRef.current = element;
if (typeof ResizeObserver !== 'function') return;
(_resizeObserver$curre = resizeObserver.current) == null ? void 0 : _resizeObserver$curre.disconnect();
resizeObserver.current = undefined;
if (element) {
var observer = new ResizeObserver(function () {
var _element$getBoundingC = element.getBoundingClientRect(),
height = _element$getBoundingC.height;
height && setHeight(height);
});
observer.observe(element, {
box: 'border-box'
});
resizeObserver.current = observer;
}
}, []);
useIsomorphicLayoutEffect(function () {
var _elementRef$current;
status === 'preEnter' && setHeight((_elementRef$current = elementRef.current) == null ? void 0 : _elementRef$current.getBoundingClientRect().height);
(status === 'preEnter' || status === 'preExit') && setHeight(elementRef.current.getBoundingClientRect().height);
}, [status]);
var style = {
height: status === 'preEnter' || status === 'exiting' ? 0 : status === 'entering' || status === 'preExit' ? _height : undefined,
height: status === 'preEnter' || status === 'exiting' ? 0 : status === 'entering' || status === 'preExit' ? height : undefined,
overflow: isResolved ? undefined : 'hidden'
};
return [style, cbRef, elementRef];
return [style, elementRef];
};

@@ -290,0 +266,0 @@

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

import { useState, useRef, useCallback } from 'react';
import { useState, useRef } from 'react';
import { useLayoutEffect as useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect.js';

@@ -9,40 +9,16 @@

var _useState = useState(),
_height = _useState[0],
height = _useState[0],
setHeight = _useState[1];
var elementRef = useRef(null);
var resizeObserver = useRef();
var cbRef = useCallback(function (element) {
var _resizeObserver$curre;
elementRef.current = element;
if (typeof ResizeObserver !== 'function') return;
(_resizeObserver$curre = resizeObserver.current) == null ? void 0 : _resizeObserver$curre.disconnect();
resizeObserver.current = undefined;
if (element) {
var observer = new ResizeObserver(function () {
var _element$getBoundingC = element.getBoundingClientRect(),
height = _element$getBoundingC.height;
height && setHeight(height);
});
observer.observe(element, {
box: 'border-box'
});
resizeObserver.current = observer;
}
}, []);
useIsomorphicLayoutEffect(function () {
var _elementRef$current;
status === 'preEnter' && setHeight((_elementRef$current = elementRef.current) == null ? void 0 : _elementRef$current.getBoundingClientRect().height);
(status === 'preEnter' || status === 'preExit') && setHeight(elementRef.current.getBoundingClientRect().height);
}, [status]);
var style = {
height: status === 'preEnter' || status === 'exiting' ? 0 : status === 'entering' || status === 'preExit' ? _height : undefined,
height: status === 'preEnter' || status === 'exiting' ? 0 : status === 'entering' || status === 'preExit' ? height : undefined,
overflow: isResolved ? undefined : 'hidden'
};
return [style, cbRef, elementRef];
return [style, elementRef];
};
export { useHeightTransition };

12

package.json
{
"name": "@szhsin/react-accordion",
"version": "0.11.0",
"version": "0.12.0",
"description": "An unstyled, fully accessible React accordion library.",

@@ -53,4 +53,4 @@ "author": "Zheng Song",

"@types/react": "^18.0.17",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.35.1",
"babel-plugin-pure-annotations": "^0.1.2",

@@ -60,7 +60,7 @@ "eslint": "^8.22.0",

"eslint-plugin-jest": "^26.8.7",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react": "^7.31.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks-addons": "^0.3.1",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"jest": "^29.0.1",
"jest-environment-jsdom": "^29.0.1",
"npm-run-all": "^4.1.5",

@@ -67,0 +67,0 @@ "prettier": "^2.7.1",

@@ -1,4 +0,4 @@

import { RefObject, CSSProperties } from 'react';
import { CSSProperties } from 'react';
import { TransitionState } from 'react-transition-state';
declare const useHeightTransition: <E extends Element>({ status, isResolved }: TransitionState) => readonly [CSSProperties, (element: E | null) => void, RefObject<E>];
declare const useHeightTransition: <E extends Element>({ status, isResolved }: TransitionState) => readonly [CSSProperties, import("react").RefObject<E>];
export { useHeightTransition };
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