From 43cbdb5659ef5cc627e1d3f97844655fcdaa5e6b Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Mon, 2 Sep 2019 22:07:10 +0800 Subject: [PATCH] cr vc-collapse and update to 1.11.7 --- .../__tests__/__snapshots__/demo.test.js.snap | 6 +++--- components/collapse/demo/custom.md | 2 +- components/vc-collapse/index.js | 2 +- components/vc-collapse/src/Collapse.jsx | 12 ++++-------- components/vc-collapse/src/Panel.jsx | 6 +++--- components/vc-collapse/src/commonProps.js | 12 ++++++++++-- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/components/collapse/__tests__/__snapshots__/demo.test.js.snap b/components/collapse/__tests__/__snapshots__/demo.test.js.snap index 8449dec11..c208b3955 100644 --- a/components/collapse/__tests__/__snapshots__/demo.test.js.snap +++ b/components/collapse/__tests__/__snapshots__/demo.test.js.snap @@ -87,7 +87,7 @@ exports[`renders ./components/collapse/demo/custom.md correctly 1`] = `
-
This is panel header 1
@@ -97,13 +97,13 @@ exports[`renders ./components/collapse/demo/custom.md correctly 1`] = `
-
This is panel header 2
-
This is panel header 3
diff --git a/components/collapse/demo/custom.md b/components/collapse/demo/custom.md index fbbbb4a20..3984495c5 100644 --- a/components/collapse/demo/custom.md +++ b/components/collapse/demo/custom.md @@ -13,7 +13,7 @@ Customize the background, border and margin styles and icon for each panel.

{{text}}

diff --git a/components/vc-collapse/index.js b/components/vc-collapse/index.js index 93e681ee5..733445fb1 100644 --- a/components/vc-collapse/index.js +++ b/components/vc-collapse/index.js @@ -1,4 +1,4 @@ -// based on rc-collapse 1.11.1 +// based on rc-collapse 1.11.7 import CollapsePanel from './src/Panel'; import Collapse from './src/Collapse'; import { collapseProps, panelProps } from './src/commonProps'; diff --git a/components/vc-collapse/src/Collapse.jsx b/components/vc-collapse/src/Collapse.jsx index 700d51ded..0880411b3 100644 --- a/components/vc-collapse/src/Collapse.jsx +++ b/components/vc-collapse/src/Collapse.jsx @@ -9,7 +9,7 @@ function _toArray(activeKey) { if (!Array.isArray(currentActiveKey)) { currentActiveKey = currentActiveKey ? [currentActiveKey] : []; } - return currentActiveKey; + return currentActiveKey.map(key => String(key)); } export default { name: 'Collapse', @@ -84,15 +84,13 @@ export default { let panelEvents = {}; if (!disabled && disabled !== '') { panelEvents = { - itemClick: panelKey => { - this.onClickItem(panelKey); - }, + itemClick: this.onClickItem, }; } const props = { + key, props: { - key, panelKey: key, header, headerClass, @@ -103,9 +101,7 @@ export default { accordion, expandIcon, }, - on: { - ...panelEvents, - }, + on: panelEvents, }; return cloneElement(child, props); diff --git a/components/vc-collapse/src/Panel.jsx b/components/vc-collapse/src/Panel.jsx index b11e1d6f0..a840eaea6 100644 --- a/components/vc-collapse/src/Panel.jsx +++ b/components/vc-collapse/src/Panel.jsx @@ -55,9 +55,9 @@ export default { [`${prefixCls}-item-active`]: isActive, [`${prefixCls}-item-disabled`]: disabled, }; - let icon = null; + let icon = ; if (showArrow && typeof expandIcon === 'function') { - icon = cloneElement(expandIcon(this.$props)); + icon = expandIcon(this.$props); } return (
@@ -69,7 +69,7 @@ export default { tabIndex={disabled ? -1 : 0} aria-expanded={isActive} > - {showArrow && (icon || )} + {showArrow && icon} {header} {extra &&
{extra}
}
diff --git a/components/vc-collapse/src/commonProps.js b/components/vc-collapse/src/commonProps.js index 1517ebf41..7ef65fd7e 100644 --- a/components/vc-collapse/src/commonProps.js +++ b/components/vc-collapse/src/commonProps.js @@ -2,8 +2,16 @@ import PropTypes from '../../_util/vue-types'; const collapseProps = () => ({ prefixCls: PropTypes.string, - activeKey: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]), - defaultActiveKey: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]), + activeKey: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), + ]), + defaultActiveKey: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), + ]), accordion: PropTypes.bool, destroyInactivePanel: PropTypes.bool, bordered: PropTypes.bool,