Installations
npm install rc-collapse
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
22.8.0
NPM Version
10.8.3
Statistics
324 Stars
291 Commits
134 Forks
28 Watching
11 Branches
60 Contributors
Updated on 13 Nov 2024
Bundle Size
27.85 kB
Minified
10.34 kB
Minified + Gzipped
Languages
TypeScript (93.43%)
Less (5.14%)
JavaScript (1.43%)
Total Downloads
Cumulative downloads
Total Downloads
228,495,440
Last day
-6.7%
284,393
Compared to previous day
Last week
2.6%
1,513,618
Compared to previous week
Last month
10.7%
6,264,598
Compared to previous month
Last year
19.6%
65,118,745
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
4
Dev Dependencies
24
rc-collapse
rc-collapse ui component for react
Live Demo
https://collapse-react-component.vercel.app
Install
Usage
1var Collapse = require('rc-collapse'); 2var Panel = Collapse.Panel; 3var React = require('react'); 4var ReactDOM = require('react-dom'); 5require('rc-collapse/assets/index.css'); 6 7var App = ( 8 <Collapse accordion={true}> 9 <Panel header="hello" headerClass="my-header-class"> 10 this is panel content 11 </Panel> 12 <Panel header="title2">this is panel content2 or other</Panel> 13 </Collapse> 14); 15ReactDOM.render(App, container);
Features
- support ie8,ie8+,chrome,firefox,safari
API
Collapse props
name | type | default | description |
---|---|---|---|
activeKey | String|Array | The first panel key | current active Panel key |
className | String or object | custom className to apply | |
defaultActiveKey | String|Array | null | default active key |
destroyInactivePanel | Boolean | false | If destroy the panel which not active, default false. |
accordion | Boolean | false | accordion mode, default is null, is collapse mode |
onChange | Function(key) | noop | called when collapse Panel is changed |
expandIcon | (props: PanelProps) => ReactNode | specific the custom expand icon. | |
collapsible | 'header' | 'icon' | 'disabled' | - | specify whether the panel of children is collapsible or the area of collapsible. |
items | interface.ts#ItemType | - | collapse items content |
If accordion
is null or false, every panel can open. Opening another panel will not close any of the other panels. activeKey
should be an string, if passing an array (the first item in the array will be used).
If accordion
is true, only one panel can be open. Opening another panel will cause the previously opened panel to close. activeKey
should be an string, if passing an array (the first item in the array will be used).
Collapse.Panel props
deprecated use
items
instead, will be removed inv4.0.0
name | type | default | description |
---|---|---|---|
header | String or node | header content of Panel | |
headerClass | String | ' ' | custom className to apply to header |
showArrow | boolean | true | show arrow beside header |
className | String or object | custom className to apply | |
classNames | { header?: string, body?: string } | Semantic structure className | |
style | object | custom style | |
styles | { header?: React.CSSProperties, body?: React.CSSProperties } | Semantic structure styles | |
openMotion | object | set the animation of open behavior, [more](https://github.com/react-component/motion). Different with v2, closed pane use a `rc-collapse-content-hidden` class to set `display: none` for hidden. | |
forceRender | boolean | false | forced render of content in panel, not lazy render after clicking on header |
extra | String | ReactNode | Content to render in the right of the panel header | |
collapsible | 'header' | 'icon' | 'disabled' | - | specify whether the panel be collapsible or the area of collapsible. |
disabled
is removed since 3.0.0, please usecollapsible=disabled
replace it.
key
If key
is not provided, the panel's index will be used instead.
KeyBoard Event
By default, Collapse will listen onKeyDown
(<3.7.0 onKeyPress
) event with enter
key to toggle panel's active state when collapsible
is not disabled
. If you want to disable this behavior, you can prevent the event from bubbling like this:
1const App = () => { 2 const items: CollapseProps['items'] = [ 3 { 4 label: <input onKeyDown={(e) => e.stopPropagation()} />, 5 children: 'content', 6 }, 7 { 8 label: ( 9 <div onKeyDown={(e) => e.stopPropagation()}> 10 <CustomComponent /> 11 </div> 12 ), 13 children: 'content', 14 }, 15 { 16 label: 'title 2', 17 children: 'content 2', 18 collapsible: 'disabled', 19 }, 20 { 21 label: 'title 3', 22 children: 'content 3', 23 onItemClick: console.log, 24 }, 25 ]; 26 27 return <Collapse items={items} />; 28};
Development
1npm install 2npm start
Test Case
1npm test
Coverage
1npm test -- --coverage
License
rc-collapse is released under the MIT license.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
6 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 8/19 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/site-deploy.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/collapse/site-deploy.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/site-deploy.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/collapse/site-deploy.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/site-deploy.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/collapse/site-deploy.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/site-deploy.yml:25
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 1 out of 2 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/react-component-ci.yml:1
- Warn: topLevel 'contents' permission set to 'write': .github/workflows/site-deploy.yml:9
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 23 are checked with a SAST tool
Score
4.9
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More