{"name":"@rc-component/collapse","version":"1.1.0","keywords":["react","react-component","react-rc-collapse","rc-collapse","collapse","accordion"],"license":"MIT","_id":"@rc-component/collapse@1.1.0","maintainers":[{"name":"zombiej","email":"smith3816@gmail.com"},{"name":"afc163","email":"afc163@gmail.com"},{"name":"madccc","email":"1075746765@qq.com"},{"name":"peachscript","email":"scdzwyxst@gmail.com"}],"homepage":"http://github.com/react-component/collapse","bugs":{"url":"http://github.com/react-component/collapse/issues"},"dist":{"shasum":"87764d8b4ad255be2dc6ea171553fa2ca64c7c50","tarball":"http://registry-npm.ywwl.com/@rc-component/collapse/download/@rc-component/collapse-1.1.0.tgz","fileCount":28,"integrity":"sha512-+A4l89Xb5butHEHAF2td3mO1PEP6exqw4QATXuMWkb91zc6vhhtcEERP6Bpwqj6Ixacr87Y3hfE4pFgYS8PV7A==","signatures":[{"sig":"MEUCIQDR39NFq5FZIrK5AyxQk2HDuNxOG0yY5CKAJOtM1XAjNQIgfUH6d5JNlIlaDEEOdvcVEU2/j0i+6k9YCqEFNvLIrFE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44790,"size":8944,"noattachment":false,"key":"/@rc-component/collapse/-/@rc-component/collapse-1.1.0.tgz"},"main":"./lib/index","module":"./es/index","gitHead":"da6f7fac24b614dc8ce64219fec75cfcbc05c089","scripts":{"lint":"eslint src/ --ext .ts,.tsx,.jsx,.js,.md","test":"rc-test","start":"dumi dev","compile":"father build && lessc assets/index.less assets/index.css","prepare":"husky","coverage":"rc-test --coverage","prettier":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","now-build":"npm run docs:build","docs:build":"dumi build","docs:deploy":"npm run docs:build && gh-pages -d dist","postpublish":"npm run docs:deploy","prepublishOnly":"npm run compile && rc-np"},"typings":"es/index.d.ts","_npmUser":{"name":"zombiej","email":"smith3816@gmail.com"},"repository":{"url":"git+ssh://git@github.com/react-component/collapse.git","type":"git"},"_npmVersion":"10.8.2","description":"rc-collapse ui component for react","directories":{},"lint-staged":{"**/*.{ts,tsx,js,jsx,json,md}":"npm run prettier"},"_nodeVersion":"22.5.1","dependencies":{"classnames":"2.x","@babel/runtime":"^7.10.1","@rc-component/util":"^1.0.1","@rc-component/motion":"^1.1.4"},"_hasShrinkwrap":false,"devDependencies":{"dumi":"^2.1.1","jest":"^29.1.2","less":"^4.2.0","husky":"^9.0.0","react":"^19.1.0","eslint":"^8.55.0","father":"^4.1.3","rc-test":"^7.0.14","gh-pages":"^6.2.0","prettier":"^3.0.3","react-dom":"^19.1.0","typescript":"^5.0.0","@types/jest":"^29.4.0","@types/node":"^22.15.18","lint-staged":"^15.0.2","@types/react":"^19.1.4","@umijs/fabric":"^4.0.0","@rc-component/np":"^1.0.4","@types/react-dom":"^19.1.5","@types/classnames":"^2.2.9","eslint-plugin-jest":"^27.6.0","eslint-plugin-unicorn":"^49.0.0","@testing-library/react":"^16.3.0","@testing-library/jest-dom":"^6.1.4","@rc-component/father-plugin":"^2.0.1","@testing-library/user-event":"^14.5.2"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/collapse_1.1.0_1747625764415_0.47077693966920786","host":"s3://npm-registry-packages-npm-production"},"readme":"# rc-collapse\n\nrc-collapse ui component for react\n\n[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][codecov-image]][codecov-url] [![npm download][download-image]][download-url]\n\n[npm-image]: http://img.shields.io/npm/v/rc-collapse.svg?style=flat-square\n[npm-url]: http://npmjs.org/package/rc-collapse\n[github-actions-image]: https://github.com/react-component/collapse/workflows/CI/badge.svg\n[github-actions-url]: https://github.com/react-component/collapse/actions\n[codecov-image]: https://img.shields.io/codecov/c/github/react-component/collapse/master.svg?style=flat-square\n[codecov-url]: https://app.codecov.io/gh/react-component/collapse\n[download-image]: https://img.shields.io/npm/dm/rc-collapse.svg?style=flat-square\n[download-url]: https://npmjs.org/package/rc-collapse\n\n## Live Demo\n\nhttps://collapse-react-component.vercel.app\n\n## Install\n\n[![rc-collapse](https://nodei.co/npm/rc-collapse.png)](https://npmjs.org/package/rc-collapse)\n\n## Usage\n\n```js\nvar Collapse = require('rc-collapse');\nvar Panel = Collapse.Panel;\nvar React = require('react');\nvar ReactDOM = require('react-dom');\nrequire('rc-collapse/assets/index.css');\n\nvar App = (\n  <Collapse accordion={true}>\n    <Panel header=\"hello\" headerClass=\"my-header-class\">\n      this is panel content\n    </Panel>\n    <Panel header=\"title2\">this is panel content2 or other</Panel>\n  </Collapse>\n);\nReactDOM.render(App, container);\n```\n\n## Features\n\n- support ie8,ie8+,chrome,firefox,safari\n\n## API\n\n### Collapse props\n\n<table class=\"table table-bordered table-striped\">\n    <thead>\n    <tr>\n        <th style=\"width: 100px;\">name</th>\n        <th style=\"width: 50px;\">type</th>\n        <th>default</th>\n        <th>description</th>\n    </tr>\n    </thead>\n    <tbody>\n      <tr>\n          <td>activeKey</td>\n          <td>String|Array<String></td>\n          <th>The first panel key</th>\n          <td>current active Panel key</td>\n      </tr>\n      <tr>\n        <td>className</td>\n        <td>String or object</td>\n        <th></th>\n        <td>custom className to apply</td>\n      </tr>\n      <tr>\n          <td>defaultActiveKey</td>\n          <td>String|Array<String></td>\n          <th>null</th>\n          <td>default active key</td>\n      </tr>\n      <tr>\n          <td>destroyOnHidden</td>\n          <td>Boolean</td>\n          <th>false</th>\n          <td>If destroy the panel which not active, default false. </td>\n      </tr>\n      <tr>\n          <td>accordion</td>\n          <td>Boolean</td>\n          <th>false</th>\n          <td>accordion mode, default is null, is collapse mode</td>\n      </tr>\n      <tr>\n          <td>onChange</td>\n          <td>Function(key)</td>\n          <th>noop</th>\n          <td>called when collapse Panel is changed</td>\n      </tr>\n      <tr>\n          <td>expandIcon</td>\n          <td>(props: PanelProps) => ReactNode</td>\n          <th></th>\n          <td>specific the custom expand icon.</td>\n      </tr>\n      <tr>\n          <td>collapsible</td>\n          <td>'header' | 'icon' | 'disabled'</td>\n          <th>-</th>\n          <td>specify whether the panel of children is collapsible or the area of collapsible.</td>\n      </tr>\n      <tr>\n          <td>items</td>\n          <td>\n            <a href=\"./src/interface.ts#ItemType\">interface.ts#ItemType</a>\n          </td>\n          <th>-</th>\n          <td>collapse items content</td>\n      </tr>\n    </tbody>\n</table>\n\nIf `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).\n\nIf `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).\n\n### Collapse.Panel props\n\n> **deprecated** use `items` instead, will be removed in `v4.0.0`\n\n<table class=\"table table-bordered table-striped\">\n    <thead>\n    <tr>\n        <th style=\"width: 100px;\">name</th>\n        <th style=\"width: 200px;\">type</th>\n        <th>default</th>\n        <th>description</th>\n    </tr>\n    </thead>\n    <tbody>\n      <tr>\n          <td>header</td>\n          <td>String or node</td>\n          <th></th>\n          <td>header content of Panel</td>\n      </tr>\n      <tr>\n          <td>headerClass</td>\n          <td>String</td>\n          <th>' '</th>\n          <td>custom className to apply to header</td>\n      </tr>\n      <tr>\n          <td>showArrow</td>\n          <td>boolean</td>\n          <th>true</th>\n          <td>show arrow beside header</td>\n      </tr>\n      <tr>\n        <td>className</td>\n        <td>String or object</td>\n        <th></th>\n        <td>custom className to apply</td>\n      </tr>\n      <tr>\n        <td>classNames</td>\n        <td>{ header?: string, body?: string }</td>\n        <th></th>\n        <td>Semantic structure className</td>\n      </tr>\n      <tr>\n        <td>style</td>\n        <td>object</td>\n        <th></th>\n        <td>custom style</td>\n      </tr>\n      <tr>\n        <td>styles</td>\n        <td>{ header?: React.CSSProperties, body?: React.CSSProperties }</td>\n        <th></th>\n        <td>Semantic structure styles</td>\n      </tr>\n      <tr>\n        <td>openMotion</td>\n        <td>object</td>\n        <th></th>\n        <td>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.</td>\n      </tr>\n      <tr>\n        <td>forceRender</td>\n        <td>boolean</td>\n        <th>false</th>\n        <td>forced render of content in panel, not lazy render after clicking on header</td>\n      </tr>\n      <tr>\n          <td>extra</td>\n          <td>String | ReactNode</td>\n          <th></th>\n          <td>Content to render in the right of the panel header</td>\n      </tr>\n      <tr>\n          <td>collapsible</td>\n          <td>'header' | 'icon' | 'disabled'</td>\n          <th>-</th>\n          <td>specify whether the panel be collapsible or the area of collapsible.</td>\n      </tr>\n    </tbody>\n</table>\n\n> `disabled` is removed since 3.0.0, please use `collapsible=disabled` replace it.\n\n#### key\n\nIf `key` is not provided, the panel's index will be used instead.\n\n#### KeyBoard Event\n\nBy 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:\n\n```tsx | pure\nconst App = () => {\n  const items: CollapseProps['items'] = [\n    {\n      label: <input onKeyDown={(e) => e.stopPropagation()} />,\n      children: 'content',\n    },\n    {\n      label: (\n        <div onKeyDown={(e) => e.stopPropagation()}>\n          <CustomComponent />\n        </div>\n      ),\n      children: 'content',\n    },\n    {\n      label: 'title 2',\n      children: 'content 2',\n      collapsible: 'disabled',\n    },\n    {\n      label: 'title 3',\n      children: 'content 3',\n      onItemClick: console.log,\n    },\n  ];\n\n  return <Collapse items={items} />;\n};\n```\n\n## Development\n\n```bash\nnpm install\nnpm start\n```\n\n## Test Case\n\n```bash\nnpm test\n```\n\n## Coverage\n\n```bash\nnpm test -- --coverage\n```\n\n## License\n\nrc-collapse is released under the MIT license.\n","publish_time":1747625764646,"_cnpm_publish_time":1747625764646,"dist-tags":{"latest":"1.3.0"}}