}
diff --git a/components/modal/style/index.scss b/components/modal/style/index.scss
index 49ab91f0c..645058988 100755
--- a/components/modal/style/index.scss
+++ b/components/modal/style/index.scss
@@ -1,4 +1,4 @@
-@import '../../style/index.scss';
+@import '@hi-ui/core-css/index.scss';
.hi-modal {
position: fixed;
@@ -6,80 +6,98 @@
left: 0;
right: 0;
bottom: 0;
- z-index: 999;
+ z-index: 1000;
- &.hide {
- display: none;
+ &--hide {
+ display: none !important;
}
- .modal-shade {
+ &__mask {
position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ z-index: 1000; // @Todo: should be larger
width: 100%;
height: 100%;
- background-color: rgba(55, 55, 55, 0.6);
- z-index: 1;
- transition: all 0.2s ease-out;
+ background-color: rgba(0, 0, 0, 0.54);
+ transition: all $speed-fast $easing;
}
- .modal-dialog {
- display: flex;
- flex-direction: column;
+ &__dialog {
position: relative;
- top: 120px;
- margin: auto;
- z-index: 1000;
- width: 520px;
- max-height: 75%;
- padding: 10px;
- background-color: #fff;
- box-shadow: 0 5px 15px 0 rgba(0, 0, 0, 0.1);
+ top: 10%;
+ z-index: 1001;
+ box-sizing: border-box;
+ width: 600px;
+ max-height: 80%;
+ margin: 0 auto;
border-radius: 2px;
- transition: all 0.2s ease-out;
-
- .title-container {
- flex: none;
- display: flex;
- align-items: center;
- height: 40px;
- border-bottom: 1px solid #e6e7e8;
-
- .fa-close {
- cursor: pointer;
- }
+ display: flex;
+ flex-direction: column;
+ font-size: $font-size-normal;
+ background-color: $white;
+ box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
+ transition: all $speed-fast $easing;
- .title {
- display: block;
- font-size: 16px;
- color: #383e47;
- text-align: left;
- font-weight: initial;
- padding: 0 16px;
- flex: 1;
- }
+ &--large {
+ width: 800px;
}
- .content {
- flex: auto;
- width: 100%;
- box-sizing: border-box;
- display: block;
- padding: 16px;
- font-size: 14px;
- overflow-x: hidden;
- overflow-y: auto;
+ &--small {
+ width: 360px;
}
+ }
- .control {
- flex: none;
- display: flex;
- border-top: 1px solid #e6e7e8;
- padding: 10px;
- justify-content: flex-end;
- overflow-x: auto;
+ &__header {
+ flex: none;
+ display: flex;
+ align-items: center;
+ height: 56px;
+ border-bottom: 1px solid $gray-light;
+ }
- button {
- margin: 0 10px;
- }
+ &__title {
+ flex: 1;
+ margin: 0;
+ padding: 0 $spacer-4;
+ font-size: $font-size-large;
+ font-weight: $font-weight-normal;
+ text-align: left;
+ color: $black;
+ }
+
+ &__close {
+ width: 56px;
+ height: 56px;
+ font-size: $font-size-large;
+ line-height: 56px;
+ text-align: center;
+ color: $gray-darker;
+ cursor: pointer;
+ transition: color $speed-fast $easing;
+
+ &:hover,
+ &:active {
+ color: $black;
}
}
+
+ &__content {
+ flex: auto;
+ box-sizing: border-box;
+ min-height: 54px;
+ padding: $spacer-4;
+ overflow-x: hidden;
+ overflow-y: auto;
+ }
+
+ &__footer {
+ flex: none;
+ display: flex;
+ border-top: 1px solid $gray-light;
+ padding: $spacer-3 $spacer-4;
+ justify-content: flex-end;
+ }
}
diff --git a/components/nav-menu/NavMenu.js b/components/nav-menu/NavMenu.js
index bad2e8efb..078aa66ea 100644
--- a/components/nav-menu/NavMenu.js
+++ b/components/nav-menu/NavMenu.js
@@ -19,7 +19,7 @@ class NavMenu extends Component {
selectedKey: 0,
selectedSubKey: -1,
vertical: false,
- width: 100
+ width: '100%'
}
constructor (props) {
super(props)
@@ -188,7 +188,7 @@ class NavMenu extends Component {
const subMenCls = classNames(`${prefixCls}__sublist`, {
'hi-navmenu__sublist--on': subMenuShow
})
- const _verticalStyle = vertical ? {width: width + 'px'} : {}
+ const _verticalStyle = vertical ? {width: typeof width === 'number' ? `${width}px` : width} : {}
return (
{
this.delayHidePopper(e)
})
+ } else {
+ this.reference.addEventListener('focus', this.showPopper.bind(this))
+ this.reference.addEventListener('blur', this.hidePopper.bind(this))
+ }
+ }
+
+ componentDidUpdate () {
+ const { trigger } = this.props
+ const popper = this.refs.popper
+ if (popper && trigger === 'hover' && this.unbindHover) {
+ this.unbindHover = false
popper.addEventListener('mouseenter', e => {
this.eventTarget = e.target
// this.showPopper()
@@ -92,27 +107,34 @@ export default class Popover extends Component {
popper.addEventListener('mouseleave', e => {
this.delayHidePopper(e)
})
- } else {
- this.reference.addEventListener('focus', this.showPopper.bind(this))
- this.reference.addEventListener('blur', this.hidePopper.bind(this))
}
}
render () {
- const { style, className, title, content, placement } = this.props
+ const { style, className, title, content, placement, width } = this.props
const {
showPopper
} = this.state
return (
-
-
- { title &&
{title}
}
-
- { content }
-
-
+
{ this.popoverContainer = node }}>
{ React.cloneElement(React.Children.only(this.props.children), { ref: 'reference', tabIndex: '0' }) }
+
+
+
+ { title &&
{title}
}
+
+ { content }
+
+
+
)
}
diff --git a/components/popover/style/index.scss b/components/popover/style/index.scss
index ad9121557..d11a72bb3 100644
--- a/components/popover/style/index.scss
+++ b/components/popover/style/index.scss
@@ -6,100 +6,89 @@ $popper-arrow-gap: -5px !default;
line-height: 30px;
font-size: 16px;
display: inline-block;
+}
+
+.hi-popover-base {
+ background: #fff;
+ padding: 0 5px;
+ white-space: nowrap;
+ transition: all 0.5s;
+ border-radius: 4px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
- .hi-popover-base {
- display: none;
+ &::after {
+ content: '';
position: absolute;
- z-index: 1150;
+ width: 10px;
+ height: 10px;
+ border: 1px solid #e8e8e8;
background: #fff;
- padding: 0 5px;
- white-space: nowrap;
- transition: all 0.5s;
- border-radius: 4px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
-
- &::after {
- content: '';
- position: absolute;
- width: 10px;
- height: 10px;
- border: 1px solid #e8e8e8;
- background: #fff;
- box-sizing: border-box;
- }
+ box-sizing: border-box;
+ }
- &.hi-popover-show {
- display: block;
- }
+ &.hi-popover-show {
+ display: block;
+ }
- .hi-popover__title {
- padding: 5px 15px;
- color: #000;
- border-bottom: 1px solid #e8e8e8;
- }
+ .hi-popover__title {
+ padding: 5px 15px;
+ color: #000;
+ border-bottom: 1px solid #e8e8e8;
+ }
- .hi-popover__content {
- padding: 12px 15px;
- }
+ .hi-popover__content {
+ padding: 12px 15px;
}
+}
- .hi-popover-top {
- bottom: 100%;
- margin-bottom: $popper-gap;
- left: 50%;
- transform: translateX(-50%);
+.hi-popover-top {
+ position: relative;
+ margin-bottom: $popper-gap;
- &::after {
- border-top-color: transparent;
- border-right-color: transparent;
- bottom: $popper-arrow-gap;
- left: 50%;
- transform: translateX(-50%) rotate(-45deg);
- }
+ &::after {
+ border-top-color: transparent;
+ border-right-color: transparent;
+ bottom: $popper-arrow-gap;
+ left: 50%;
+ transform: translateX(-50%) rotate(-45deg);
}
+}
- .hi-popover-right {
- left: 100%;
- margin-left: $popper-gap;
- top: 50%;
- transform: translateY(-50%);
+.hi-popover-right {
+ position: relative;
+ margin-left: $popper-gap;
- &::after {
- border-bottom-color: transparent;
- border-right-color: transparent;
- left: $popper-arrow-gap;
- top: 50%;
- transform: translateY(-50%) rotate(-45deg);
- }
+ &::after {
+ border-bottom-color: transparent;
+ border-right-color: transparent;
+ left: $popper-arrow-gap;
+ top: 50%;
+ transform: translateY(-50%) rotate(-45deg);
}
+}
- .hi-popover-bottom {
- top: 100%;
- margin-top: $popper-gap;
- left: 50%;
- transform: translateX(-50%);
+.hi-popover-bottom {
+ position: relative;
+ margin-top: $popper-gap;
- &::after {
- border-left-color: transparent;
- border-bottom-color: transparent;
- top: $popper-arrow-gap;
- left: 50%;
- transform: translateX(-50%) rotate(-45deg);
- }
+ &::after {
+ border-left-color: transparent;
+ border-bottom-color: transparent;
+ top: $popper-arrow-gap;
+ left: 50%;
+ transform: translateX(-50%) rotate(-45deg);
}
+}
- .hi-popover-left {
- right: 100%;
- margin-right: $popper-gap;
- top: 50%;
- transform: translateY(-50%);
+.hi-popover-left {
+ position: relative;
+ margin-right: $popper-gap;
- &::after {
- border-top-color: transparent;
- border-left-color: transparent;
- right: $popper-arrow-gap;
- top: 50%;
- transform: translateY(-50%) rotate(-45deg);
- }
+ &::after {
+ border-top-color: transparent;
+ border-left-color: transparent;
+ right: $popper-arrow-gap;
+ top: 50%;
+ transform: translateY(-50%) rotate(-45deg);
}
-}
+}
\ No newline at end of file
diff --git a/components/popper/index.js b/components/popper/index.js
index 206fcdf98..8f44ba185 100644
--- a/components/popper/index.js
+++ b/components/popper/index.js
@@ -11,17 +11,21 @@ export default class Popper extends Component {
// attachEle: PropTypes.oneOfType([
// PropTypes.node
// ]).isRequired,
+ width: PropTypes.string,
className: PropTypes.string,
show: PropTypes.bool,
- width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
topGap: PropTypes.number,
- leftGap: PropTypes.number
+ leftGap: PropTypes.number,
+ zIndex: PropTypes.number,
+ placement: PropTypes.oneOf(['bottom', 'bottom-start', 'top', 'left', 'right'])
}
static defaultProps = {
show: false,
topGap: 2,
- leftGap: 0
+ leftGap: 0,
+ zIndex: 1060,
+ placement: 'bottom-start'
}
componentDidUpdate () {
@@ -36,18 +40,49 @@ export default class Popper extends Component {
document.body.removeChild(this.container)
}
- getOffset (ele) {
- let offset = {
- left: 0,
- top: 0
- }
- while (ele && ele !== document.body) {
- offset.top += ele.offsetTop - ele.scrollTop
- offset.left += ele.offsetLeft - ele.scrollLeft
- ele = ele.offsetParent
+ getOffset () {
+ let {
+ attachEle,
+ topGap,
+ leftGap,
+ width,
+ placement
+ } = this.props
+ const rect = attachEle.getBoundingClientRect()
+ let top = rect.y + (document.documentElement.scrollTop || document.body.scrollTop)
+ let left = rect.x + (document.documentElement.scrollLeft || document.body.scrollLeft)
+ width = width === undefined ? rect.width : width
+
+ switch (placement) {
+ case 'bottom':
+ top = top + topGap + rect.height
+ left = left + rect.width / 2
+ break
+ case 'bottom-start':
+ top = top + topGap + rect.height
+ break
+
+ case 'top':
+ top = top - topGap
+ left = left + rect.width / 2
+ break
+
+ case 'left':
+ top = top + rect.height / 2
+ left = left + leftGap
+ break
+
+ case 'right':
+ top = top + rect.height / 2
+ left = left + rect.width + leftGap
+ break
}
- return offset
+ return {
+ width,
+ top,
+ left
+ }
}
renderChildren () {
@@ -55,21 +90,22 @@ export default class Popper extends Component {
children,
className,
show,
- attachEle,
- topGap,
- leftGap,
- width
+ zIndex,
+ placement
} = this.props
- width = width !== undefined ? width : attachEle.offsetWidth
- const height = attachEle.offsetHeight
- const offset = this.getOffset(attachEle)
- const left = offset.left + leftGap + 'px'
- const top = offset.top + topGap + height + 'px'
- window.attachEle = attachEle
+ const offset = this.getOffset()
+ let width = offset.width
+ let left = offset.left + 'px'
+ let top = offset.top + 'px'
return (
-
- { children }
+
)
}
diff --git a/components/popper/style/index.scss b/components/popper/style/index.scss
index a0c3e9f96..01021fcc0 100644
--- a/components/popper/style/index.scss
+++ b/components/popper/style/index.scss
@@ -5,4 +5,30 @@
&--hide {
display: none !important;
}
+ .hi-popper__content {
+ position: absolute;
+ &--top {
+ bottom: 0px;
+ // left: 50%;
+ transform: translateX(-50%);
+ }
+
+ &--right {
+ // left: 100%;
+ // top: 50%;
+ transform: translateY(-50%);
+ }
+
+ &--bottom {
+ // top: 100%;
+ // left: 50%;
+ transform: translateX(-50%);
+ }
+
+ &--left {
+ right: 0px;
+ // top: 50%;
+ transform: translateY(-50%);
+ }
+ }
}
diff --git a/components/radio/style/index.scss b/components/radio/style/index.scss
index cc20ced96..e60a94c07 100644
--- a/components/radio/style/index.scss
+++ b/components/radio/style/index.scss
@@ -32,6 +32,7 @@
box-sizing: border-box;
vertical-align: sub;
position: relative;
+ background-color: #fff;
}
&.checked {
@@ -54,6 +55,7 @@
color: #4284f5;
background: rgba(66, 132, 245, 0.1);
border: 1px solid #a8c6fb;
+ z-index: 2;
}
}
diff --git a/components/select/Select.js b/components/select/Select.js
index b384046bf..c0d8645ab 100644
--- a/components/select/Select.js
+++ b/components/select/Select.js
@@ -10,8 +10,6 @@ import SelectDropdown from './SelectDropdown'
import Provider from '../context'
class Select extends Component {
- noHideDropdown = false
-
static propTypes = {
mode: PropTypes.oneOf(['single', 'multiple']),
list: PropTypes.array,
@@ -24,6 +22,7 @@ class Select extends Component {
]),
autoload: PropTypes.bool,
searchable: PropTypes.bool,
+ clearable: PropTypes.bool,
disabled: PropTypes.bool,
placeholder: PropTypes.string,
noFoundTip: PropTypes.string,
@@ -35,6 +34,7 @@ class Select extends Component {
list: [],
mode: 'single',
disabled: false,
+ clearable: true,
value: '',
autoload: false,
placeholder: '请选择',
@@ -51,6 +51,7 @@ class Select extends Component {
const selectedItems = this.resetSelectedItems(this.props)
const searchable = this.getSearchable()
this.debouncedFilterItems = debounce(this.onFilterItems.bind(this), 300)
+ this.clickOutsideHandel = this.clickOutside.bind(this)
// const focusedIndex = this.resetFocusedIndex(false)
this.state = {
@@ -81,12 +82,19 @@ class Select extends Component {
}
componentDidMount () {
- window.addEventListener('click', this.hideDropdown.bind(this))
+ window.addEventListener('click', this.clickOutsideHandel)
this.resetFocusedIndex()
}
componentWillUnmount () {
- window.removeEventListener('click', this.hideDropdown.bind(this))
+ window.removeEventListener('click', this.clickOutsideHandel)
+ }
+
+ clickOutside (e) {
+ if (ReactDOM.findDOMNode(this.selectInput) && ReactDOM.findDOMNode(this.selectInput).contains(e.target)) {
+ return
+ }
+ this.hideDropdown()
}
componentWillReceiveProps (props) {
@@ -221,7 +229,6 @@ class Select extends Component {
}
handleInputClick (e) {
- this.noHideDropdown = ReactDOM.findDOMNode(this.selectInput).contains(e.target)
this.selectInput.focus()
// if (e) {
// e.stopPropagation()
@@ -241,10 +248,9 @@ class Select extends Component {
}
hideDropdown () {
- !this.noHideDropdown && this.state.dropdownShow === true && this.setState({dropdownShow: false}, () => {
+ this.state.dropdownShow === true && this.setState({dropdownShow: false}, () => {
this.clearKeyword()
})
- this.noHideDropdown = false
}
showDropdown () {
@@ -418,6 +424,7 @@ class Select extends Component {
mode,
className,
disabled,
+ clearable,
style,
children,
noFoundTip
@@ -443,6 +450,7 @@ class Select extends Component {
mode={mode}
disabled={disabled}
searchable={searchable}
+ clearable={clearable}
dropdownShow={dropdownShow}
placeholder={placeholder}
selectedItems={selectedItems}
diff --git a/components/select/SelectInput.js b/components/select/SelectInput.js
index ebe1a7d31..6f6da2a6e 100644
--- a/components/select/SelectInput.js
+++ b/components/select/SelectInput.js
@@ -64,7 +64,8 @@ export default class SelectInput extends Component {
selectedItems,
dropdownShow,
disabled,
- searchable
+ searchable,
+ clearable
} = this.props
let icon = dropdownShow ? 'up' : 'down'
let {
@@ -116,8 +117,8 @@ export default class SelectInput extends Component {
}
-
-
+
+ { clearable && }
)
@@ -129,19 +130,17 @@ export default class SelectInput extends Component {
selectedItems,
dropdownShow,
disabled,
- searchable
+ searchable,
+ clearable
} = this.props
placeholder = selectedItems.length > 0 ? selectedItems[0].name : placeholder
let icon = dropdownShow ? 'up' : 'down'
return (
- {
- !dropdownShow && selectedItems.length > 0 &&
-
-
{selectedItems[0].name}
-
- }
+
0)})}>
+
{selectedItems[0] && selectedItems[0].name}
+
{
(dropdownShow || selectedItems.length === 0) &&
@@ -158,8 +157,8 @@ export default class SelectInput extends Component {
}
-
-
+
+ { clearable && }
)
diff --git a/components/select/style/index.scss b/components/select/style/index.scss
index 9c552c0b7..be72df47b 100644
--- a/components/select/style/index.scss
+++ b/components/select/style/index.scss
@@ -6,4 +6,7 @@ $selectColor:#f7f7f7 !default;
opacity: 0.4;
cursor: not-allowed;
}
+ &__hide {
+ display: none;
+ }
}
diff --git a/components/select/style/select-input.scss b/components/select/style/select-input.scss
index 85fbaca29..74fce262b 100644
--- a/components/select/style/select-input.scss
+++ b/components/select/style/select-input.scss
@@ -34,7 +34,7 @@
}
&:not(.disabled):hover {
- .hi-select__input--icon__expand {
+ .hi-select__input--icon__expand.clearable {
display: none;
}
diff --git a/components/table/body.js b/components/table/body.js
index 1c30ce173..2709b6bfb 100644
--- a/components/table/body.js
+++ b/components/table/body.js
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import Icon from '../icon'
import '../icon/style'
import prifix from './prefix'
-
+import Footer from './footer'
// 点击后会展开的那个图标
class Expand extends Component {
constructor (props) {
@@ -28,6 +28,10 @@ class Expand extends Component {
}
}
+let defaultRender = (text, record, index) => {
+ return text
+}
+
export default class Body extends Component {
render () {
let {columns, dataSource, cbs: {addExpand}, rowSelection = { }, highlightCols} = this.props
@@ -59,6 +63,7 @@ export default class Body extends Component {
// {/* addExpand(e, obj)} data-index={k} data-open={false}> >
*/}
td =
} else {
+ obj.render = obj.render || defaultRender
td = obj.render(item[obj.dataIndex], item, i)
// 做判断的原因是?
@@ -94,6 +99,7 @@ export default class Body extends Component {
return (
{nodes}
+
)
}
diff --git a/components/table/checkbox/index.js b/components/table/checkbox/index.js
new file mode 100644
index 000000000..a1beef76a
--- /dev/null
+++ b/components/table/checkbox/index.js
@@ -0,0 +1,23 @@
+import React, {Component} from 'react'
+import classNames from 'classnames'
+import './style'
+export default class Checkbox extends Component {
+ render () {
+ const {
+ checked,
+ onChange,
+ disabled
+ } = this.props
+ return (
+ {
+ if (disabled) {
+ return
+ }
+ onChange(e, !checked)
+ }} className={classNames({'hi-checkbox': true, 'hi-checkbox--checked': checked, 'hi-checkbox--disabled': disabled})}>
+
+
+
+ )
+ }
+}
diff --git a/components/table/checkbox/style/index.js b/components/table/checkbox/style/index.js
new file mode 100644
index 000000000..63810a681
--- /dev/null
+++ b/components/table/checkbox/style/index.js
@@ -0,0 +1 @@
+import './index.scss'
diff --git a/components/table/checkbox/style/index.scss b/components/table/checkbox/style/index.scss
new file mode 100644
index 000000000..5b43fdcd4
--- /dev/null
+++ b/components/table/checkbox/style/index.scss
@@ -0,0 +1 @@
+.hi-checkbox{display:inline-block;cursor:pointer;font:normal 14px/1.5 -apple-system,BlinkMacSystemFont,"Helvetica Neue",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";text-align:left;text-indent:0;text-shadow:none;text-transform:none;letter-spacing:0;word-spacing:normal;white-space:normal;color:#333}.hi-checkbox ul,.hi-checkbox ol{margin:0;padding:0;list-style-type:none}.hi-checkbox dl{margin-top:0;margin-bottom:0}.hi-checkbox li+li{margin:0}.hi-checkbox a{padding-left:0;padding-right:0}.hi-checkbox:not(.hi-checkbox--disabled):hover .hi-checkbox__input{border:1px solid #4284f5}.hi-checkbox--disabled{cursor:not-allowed}.hi-checkbox--disabled .hi-checkbox__input{background:#f2f2f2 !important;border:1px solid #d8d8d8}.hi-checkbox--disabled .hi-checkbox__input::after{border-color:#d8d8d8}.hi-checkbox--checked .hi-checkbox__input{background:#4284f5}.hi-checkbox--checked .hi-checkbox__input::after{-webkit-transform:rotate(45deg) scaleY(1);transform:rotate(45deg) scaleY(1);pointer-events:none;-webkit-box-sizing:content-box;box-sizing:content-box;content:'';border:2px solid #fff;border-left:0;border-top:0;height:8px;left:5px;position:absolute;top:1px;width:4px;-webkit-transform-origin:center;transform-origin:center}.hi-checkbox--part .hi-checkbox__input{background:#4284f5}.hi-checkbox--part .hi-checkbox__input::after{content:'';position:absolute;display:block;border:1px solid #fff;margin-top:-1px;left:3px;right:3px;top:50%;pointer-events:none}.hi-checkbox__input{display:inline-block;width:16px;height:16px;border:1px solid #d8d8d8;border-radius:2px;vertical-align:middle;position:relative}.hi-checkbox__label{padding:0 16px 0 8px;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
diff --git a/components/table/footer.js b/components/table/footer.js
new file mode 100644
index 000000000..6fc344747
--- /dev/null
+++ b/components/table/footer.js
@@ -0,0 +1,72 @@
+import React, { Component } from 'react'
+
+class Footer extends Component {
+ getSum (item) {
+ const {
+ dataSource
+ } = this.props
+ return dataSource.length > 0 ? dataSource.map(dataItem => dataItem[item.dataIndex]).reduce((pre, next) => pre + next) : 0
+ }
+
+ getSumNodes () {
+ const {
+ columns
+ } = this.props
+ const tds = columns.map((item, index) => {
+ if (item.type === 'number') {
+ return (
+
+ {this.getSum(item)}
+ |
+ )
+ }
+ if (index === 0) {
+ return (
+
合计 |
+ )
+ }
+ return
|
+ })
+ return
{tds}
+ }
+ getAveNodes () {
+ const {
+ columns,
+ dataSource
+ } = this.props
+ const tds = columns.map((item, index) => {
+ if (item.type === 'number') {
+ let num = this.getSum(item) / dataSource.length
+
+ return (
+
+ {Math.round(num * 100) / 100}
+ |
+ )
+ }
+ if (index === 0) {
+ return (
+
均值 |
+ )
+ }
+ return
|
+ })
+ return
{tds}
+ }
+
+ render () {
+ const {
+ advance,
+ dataSource
+ } = this.props
+
+ return (
+
+ {dataSource.length > 0 && advance && advance.sum && this.getSumNodes()}
+ {dataSource.length > 0 && advance && advance.avg && this.getAveNodes()}
+
+ )
+ }
+}
+
+export default Footer
diff --git a/components/table/header.js b/components/table/header.js
index 6d6548409..384978dd7 100644
--- a/components/table/header.js
+++ b/components/table/header.js
@@ -39,14 +39,41 @@ class Sorter extends Component {
}
}
+class ServerSorter extends Component {
+ render () {
+ return (
+
+
+ {
+ let {item: {serverSort}, cbs: {fetch}} = this.props
+ fetch(serverSort[0])
+ }}
+ style={{fontSize: '12px'}} />
+
+ {
+ let {item: {serverSort}, cbs: {fetch}} = this.props
+ fetch(serverSort[0])
+ }}
+ style={{fontSize: '12px'}}
+ />
+
+
+ )
+ }
+}
+
let HeaderCell = (props) => {
let {item, index, contextMenu} = props
-
return (
contextMenu(e, item.key)}>
{typeof item.title === 'function' ? item.title() : item.title}
- {item.sorter ? : null}
+ {item.sorter && }
+ {item.serverSort && }
|
)
@@ -59,14 +86,15 @@ let GroupCell = (props) => {
contextMenu(e, item.key)}>
{item.title}
- {item.sorter ? : null}
+ {item.sorter && }
+ {item.serverSort && 'sirt'}
|
)
}
// 普通的表头
-export class Header extends Component {
+export default class Header extends Component {
render () {
let { columns, headerColumns } = this.props
// 表头可以传组件,如果是文本就渲染文本
@@ -101,7 +129,7 @@ export class Header extends Component {
contextMenu = (e, key) => {
e.preventDefault()
// this.refs.menu =
- let {cbs, scrollWidth} = this.props
- Menu.show(e, cbs, key, !!scrollWidth)
+ let {cbs, scrollWidth, size} = this.props
+ Menu.show(e, cbs, key, !!scrollWidth, size)
}
}
diff --git a/components/table/index.js b/components/table/index.js
index 58cd8af97..5625cbba1 100644
--- a/components/table/index.js
+++ b/components/table/index.js
@@ -4,17 +4,19 @@ import PropTypes from 'prop-types'
import ClickOutside from './clickOuterside'
import TableContent from './tableContent'
import prifix from './prefix'
-
-import Checkbox from '../checkbox'
+import Checkbox from './checkbox'
import Pagination from '../pagination'
import Icon from '../icon'
import './style'
-import '../checkbox/style'
+import loading from '../loading'
import '../pagination/style'
import '../icon/style'
import {setKey, scrollTop, getStyle} from './tool'
-
-export default class Table extends Component {
+import request from 'axios'
+let axios = request.create({
+ baseURL: ''
+})
+class Table extends Component {
static propTypes = {
data: PropTypes.array,
useFixedHeader: PropTypes.bool,
@@ -26,7 +28,6 @@ export default class Table extends Component {
rowClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
onRow: PropTypes.func,
onHeaderRow: PropTypes.func,
- onRowClick: PropTypes.func,
onRowDoubleClick: PropTypes.func,
onRowContextMenu: PropTypes.func,
onRowMouseEnter: PropTypes.func,
@@ -41,6 +42,7 @@ export default class Table extends Component {
static defaultProps = {
data: [],
+ columns: [],
useFixedHeader: false,
rowKey: 'key',
rowClassName: () => '',
@@ -53,6 +55,28 @@ export default class Table extends Component {
rowRef: () => null,
emptyText: () => 'No Data'
}
+ constructor (props) {
+ super(props)
+ // 只有dataSource,columns重造
+ let {data = [], scroll} = props
+ data = setKey(data, 'id')
+ this.state = {
+ dataSource: data,
+ highlightCols: [],
+ scroll,
+ columnMenu: false,
+ // 由外部属性重构为内部状态
+ leftFiexColumns: [],
+ rightFixColumns: [],
+ columns: [],
+ headerColumns: [],
+ loading: false,
+ serverPagination: {
+ total: 0,
+ current: 0
+ }
+ }
+ }
runMemory () {
let {name} = this.props
@@ -104,6 +128,7 @@ export default class Table extends Component {
this.setState({columns, headerColumns, dataSource, highlightCols})
}
+ // noinspection JSAnnotator
cbs = {
highlighCol: (key) => {
let {highlightCols} = this.state
@@ -146,7 +171,6 @@ export default class Table extends Component {
})
},
hideCol: (key) => {
- console.log(key, 'hide')
let {columns, headerColumns} = this.state
columns.map(item => {
if (item.key === key) {
@@ -190,24 +214,76 @@ export default class Table extends Component {
let obj = dataSource.find(o => o.key === item.key)
obj.ishiuitableopen = !obj.ishiuitableopen
this.setState({dataSource: dataSource, ...columnsDetail})
- }
- }
+ // let {index, open} = e.target.dataset
+ // index = parseInt(index)
+ // open = open === 'true'
+ //
+ // let {data} = this.props
+ // if (!open) {
+ // data.splice(index + 1, 0, {expand: true, parent: index, ...{width: '50px'}, ...item})
+ // } else {
+ // data.splice(index + 1, 1)
+ // }
+ // e.target.dataset.open = !open
+ // this.setState({dataSource: data})
+ },
- constructor (props) {
- super(props)
- // 只有dataSource,columns重造
- let {data = [], scroll} = props
- data = setKey(data, 'id')
- this.state = {
- dataSource: data,
- highlightCols: [],
- scroll,
- columnMenu: false,
- // 由外部属性重构为内部状态
- leftFiexColumns: [],
- rightFixColumns: [],
- columns: [],
- headerColumns: []
+ fetch: (extra) => {
+ extra = extra || {}
+ const {origin} = this.props
+ const {
+ data,
+ url,
+ header,
+ type = 'GET',
+ success = (res) => {},
+ error = () => {},
+ currentPageName = Table.config.currentPageName,
+ pageSizeName = Table.config.pageSizeName,
+ pageSize = Table.config.pageSize
+ } = origin
+
+ let l = loading.open({
+ target: ReactDOM.findDOMNode(this.refs.dom)
+ })
+ const {
+ serverPagination: {current}
+ } = this.state
+ let requestParams = {
+ ...data,
+ ...extra
+ }
+ requestParams[currentPageName] = current
+ requestParams[pageSizeName] = pageSize
+
+ let options = {
+ url,
+ method: ['GET', 'get'].includes(type) ? 'GET' : 'POST'
+ }
+ if (options.method === 'GET') {
+ options.params = requestParams
+ } else {
+ options.data = requestParams
+ }
+ if (header) {
+ options.header = header
+ }
+ axios.request(options).then(res => {
+ let {data, columns, page} = success(res)
+ let columnsDetail = this.setColumnsDetail(null, null, columns)
+ this.setState({
+ dataSource: data,
+ ...columnsDetail,
+ loading: false,
+ serverPagination: page
+ })
+ this.runMemory()
+ l.close()
+ }).catch(error)
+
+ // axios.request(url, {params: requestParams}).then(res => {
+ //
+ // })
}
}
@@ -216,7 +292,6 @@ export default class Table extends Component {
let {dataSource, highlightCols, columns, headerColumns, leftFiexColumns, rightFixColumns} = this.state
let that = this
let {scroll} = this.state
-
let {style = {}, ...props} = this.props
let handleScroll = function (e) {
let onLeft = e.target.scrollLeft === 0
@@ -287,9 +362,7 @@ export default class Table extends Component {
}
showColumsPanel= (e) => {
- let {columnMenu} = this.state
- e.stopPropagation()
- this.setState({columnMenu: !columnMenu})
+
}
getScrollYContent () {
@@ -317,12 +390,11 @@ export default class Table extends Component {
let {dataSource, highlightCols, columns, headerColumns} = this.state
let {style = {}, ...props} = this.props
-
return (
{
dataSource.length === 0 ? this.getEmptyContent() : null
@@ -360,8 +432,8 @@ export default class Table extends Component {
render () {
// 多选配置
- let {pagination, name} = this.props
- let {scroll, columnMenu} = this.state
+ let {pagination, name, size = 'normal'} = this.props
+ let {scroll, columnMenu, loading, serverPagination} = this.state
let content
// 不滚动
@@ -388,7 +460,10 @@ export default class Table extends Component {
let {columns} = this.state
return (
-
+
+ {
+ loading && ' '
+ }
@@ -402,42 +477,65 @@ export default class Table extends Component {
: null
}
- { name
- ?
-
+
+
+ {
+ serverPagination.current && serverPagination.current ?
+
{
+ this.setState({
+ serverPagination: {
+ ...serverPagination,
+ current
+ }
+ }, this.cbs.fetch)
+ }}
+ />
+ : null
+ }
+
+ { name &&
+
+
{
+ let {columnMenu} = this.state
+ this.setState({columnMenu: !columnMenu})
+ }} />
{
- columnMenu
- ? this.setState({columnMenu: false})} >
-
- {
- columns.map(item => (
-
-
- {
- (function () {
- if (item.type === 'select') {
- return '多选'
- }
- if (item.type === 'expand') {
- return '展开'
- }
- if (typeof item.title === 'function') {
- return item.title()
- }
- return item.title
- }())
- }
-
-
- this.cbs.hideCol(item.key)} />
-
+ columnMenu &&
this.setState({columnMenu: false})} >
+
+ {
+ columns.map(item => (
+
+
+ {
+ (function () {
+ if (item.type === 'select') {
+ return '多选'
+ }
+ if (item.type === 'expand') {
+ return '展开'
+ }
+ if (typeof item.title === 'function') {
+ return item.title()
+ }
+ return item.title
+ }())
+ }
- ))
- }
-
- : null
+
+ this.cbs.hideCol(item.key)} />
+
+
+ ))
+ }
+
+
}
-
: null
+
}
)
@@ -470,46 +568,6 @@ export default class Table extends Component {
})
}
}
-
- componentDidMount () {
- let {fixTop, scroll, name} = this.props
-
- let dom = ReactDOM.findDOMNode(this.refs['dom'])
- let thead = dom.querySelectorAll('thead')
-
- if (fixTop) {
- // 吸顶逻辑
- document.addEventListener('scroll', () => {
- this.xscroll()
- })
- }
-
- // 如果有列冻结的配置
- if (scroll.x) {
- let dom = ReactDOM.findDOMNode(this.refs['dom'])
- // 如果表格本身太宽超过列冻结配置的话,右边的列冻结就取消
- if (parseInt(getStyle(dom, 'width')) > scroll.x) {
- if (this.refs['fix-right']) {
- this.refs['fix-right'].style.display = 'none'
- }
- }
- }
-
- let columnsDetail = this.setColumnsDetail()
- this.setState({
- ...columnsDetail
- })
-
- // 操作记忆设置
- if (name) {
- this.refs.setting.style.lineHeight = parseInt(getStyle(thead[0], 'height')) - 10 + 'px'
- this.refs.setting.style.marginTop = '5px'
- }
- setTimeout(() => {
- this.runMemory()
- }, 0)
- }
-
getColumns (columns) {
let select = columns.find(({type}) => type === 'select')
let leftFiexColumns = columns.filter(({fixed}) => !!fixed && fixed === 'left')
@@ -538,13 +596,11 @@ export default class Table extends Component {
columns = columns.map((item) => {
item.title = item.title || item.dataIndex
item.key = item.key || item.dataIndex || item.title || item.id
- // item.render = item.render || function(text,record,index){return text};
if (item.type === 'expand') {
item.open = !!item.open
}
return item
})
-
let bodyColumns = []
let headerColumns = []
let deepMap = (columns, parent) => {
@@ -557,7 +613,6 @@ export default class Table extends Component {
deepMap(children, columns[key])
// delete columns[key].children
} else {
- columns[key].render = columns[key].render || function (text) { return text }
columns[key].isLast = true
}
bodyColumns.push(columns[key])
@@ -605,63 +660,60 @@ export default class Table extends Component {
return [headerColumns, bodyColumns]
}
- setColumnsDetail (bool, prop) {
+ setColumnsDetail (bool, prop, c) {
let props = prop || this.props
let leftFiexColumns = []
let rightFixColumns = []
- let [headerColumns, columns] = this.getHeaderGroup(props.columns)
+ let [headerColumns, columns] = this.getHeaderGroup(c || props.columns)
+
let {rowSelection, scroll, name} = props
- if (rowSelection) {
- let {selectedRowKeys = []} = rowSelection
- let { dataSource } = this.state
+ if (rowSelection) {
+ let {selectedRowKeys = [], dataName = 'key'} = rowSelection
columns.unshift({
width: '50',
type: 'select',
key: 'hi-table-select-' + name,
title: () => {
- let {getCheckboxProps = (record) => ({ disabled: false, dataName: record.key }), onChange} = rowSelection
- let data = dataSource.filter(record => !getCheckboxProps(record).disabled)
+ let {getCheckboxProps = (record) => ({ disabled: false }), onChange} = rowSelection
return (
e.preventDefault()}
- checked={selectedRowKeys.length === data.length}
- onChange={(e) => {
- if (e.checked) {
+
+ checked={selectedRowKeys.length === this.state.dataSource.filter(record => !getCheckboxProps(record).disabled).length}
+ onChange={(e, checked) => {
+ let data = this.state.dataSource.filter(record => !getCheckboxProps(record).disabled)
+ if (checked) {
selectedRowKeys.splice(0, selectedRowKeys.length)
for (let i = 0; i < data.length; i++) {
- selectedRowKeys.push(data[i].key)
+ selectedRowKeys.push(data[i][dataName])
}
} else {
selectedRowKeys.splice(0, selectedRowKeys.length)
- data.splice(0, data.length)
}
- onChange(selectedRowKeys, data)
+ onChange(selectedRowKeys, data.filter(record => selectedRowKeys.includes(record[dataName])))
}}
/>
-
)
},
render: (text, record, index) => {
- let {getCheckboxProps = (record) => ({ disabled: false, dataName: record.key }), onChange} = rowSelection
+ let {getCheckboxProps = (record) => ({ disabled: false }), onChange} = rowSelection
// todo dataName 是干嘛的不明白
- let {disabled} = getCheckboxProps(record)
- let data = dataSource.filter(record => !getCheckboxProps(record).disabled)
+
return (
- e.preventDefault()}
- checked={selectedRowKeys.includes(record.key)}
- onChange={(e) => {
- if (e.checked) {
- selectedRowKeys.push(record.key)
+ {
+ let data = this.state.dataSource.filter(record => !getCheckboxProps(record).disabled)
+ if (checked) {
+ selectedRowKeys.push(record[dataName])
} else {
- selectedRowKeys = selectedRowKeys.filter(key => record.key !== key)
+ selectedRowKeys = selectedRowKeys.filter(key => record[dataName] !== key)
}
-
- onChange(selectedRowKeys, data.filter(record => selectedRowKeys.includes(record.key)))
+ onChange(selectedRowKeys, data.filter(record => selectedRowKeys.includes(record[dataName])))
}}
- disabled={disabled}
- key={record.key}
+ key={record[dataName]}
/>
)
}
@@ -684,14 +736,139 @@ export default class Table extends Component {
}
}
- componentWillReceiveProps ({data, columns, width, scroll, ...props}) {
- data = setKey(data, 'id')
- // 只有dataSource,columns重造
+ fetch () {
+ // noinspection JSAnnotator
+ const {
+ origin: {
+ data,
+ url,
+ header,
+ type = 'GET',
+ success = (res) => {},
+ error = () => {},
+ pageSize = Table.config.pageSize,
+ pageSizeName = Table.config.pageSizeName
+ }
+ } = this.props
- let columnsDetail = this.setColumnsDetail(columns, {data, columns, width, scroll, ...props})
- this.setState({dataSource: data, scroll, ...columnsDetail})
+ let l = loading.open({target: ReactDOM.findDOMNode(this.refs.dom)})
+ this.setState({
+ loading: true
+ })
+ let requestParams = {
+ ...data
+ }
+ requestParams[pageSizeName] = pageSize
+ let options = {
+ method: ['GET', 'get'].includes(type) ? 'GET' : 'POST',
+ url
+ }
+ if (options.method === 'GET') {
+ options.params = requestParams
+ } else {
+ options.data = requestParams
+ }
+ if (header) {
+ options.header = header
+ }
+
+ axios(options).then(res => {
+ let {data, columns, page} = success(res)
+ this.setState({
+ dataSource: data,
+ loading: false,
+ serverPagination: page
+ })
+ setTimeout((e) => {
+ let columnsDetail = this.setColumnsDetail(null, null, columns)
+ this.setState({
+ ...columnsDetail
+ })
+ this.runMemory()
+ l.close()
+ })
+ }).catch(error)
+ // axios.request(url, {params: requestParams}).then(res => {
+ // let {data, columns, page} = success(res)
+ //
+ // this.setState({
+ // dataSource: data,
+ // loading: false,
+ // serverPagination: page
+ // })
+ // setTimeout((e) => {
+ // let columnsDetail = this.setColumnsDetail(null, null, columns)
+ // this.setState({
+ // ...columnsDetail
+ // })
+ // this.runMemory()
+ // })
+ // })
+ }
+
+ componentDidMount () {
+ let {fixTop, scroll, name, origin} = this.props
+
+ let dom = ReactDOM.findDOMNode(this.refs['dom'])
+ let thead = dom.querySelectorAll('thead')
+ if (fixTop) {
+ // 吸顶逻辑
+ document.addEventListener('scroll', () => {
+ this.xscroll()
+ })
+ }
+
+ // 如果有列冻结的配置
+ if (scroll.x) {
+ let dom = ReactDOM.findDOMNode(this.refs['dom'])
+ // 如果表格本身太宽超过列冻结配置的话,右边的列冻结就取消
+ if (parseInt(getStyle(dom, 'width')) > scroll.x) {
+ if (this.refs['fix-right']) {
+ this.refs['fix-right'].style.display = 'none'
+ }
+ }
+ }
+
+ let columnsDetail = this.setColumnsDetail()
+ this.setState({
+ ...columnsDetail
+ })
+
+ // 操作记忆设置
+ if (name) {
+ this.refs.setting.style.lineHeight = parseInt(getStyle(thead[0], 'height')) - 10 + 'px'
+ this.refs.setting.style.marginTop = '5px'
+ }
setTimeout(() => {
this.runMemory()
+
+ if (origin) {
+ this.fetch()
+ }
}, 0)
}
+
+ componentWillReceiveProps ({data, columns, width, scroll, ...props}) {
+ // 服务端表格
+ if (props.origin) {
+ props.origin.auto && this.fetch()
+ } else {
+ data = setKey(data, 'id')
+ // 只有dataSource,columns重造
+ let columnsDetail = this.setColumnsDetail(columns, {data, columns, width, scroll, ...props})
+ this.setState({dataSource: data, scroll, ...columnsDetail, ...props})
+ setTimeout(() => {
+ this.runMemory()
+ }, 0)
+ }
+ }
}
+
+Table.config = {
+ currentPageName: 'current',
+ pageSizeName: 'pageSize',
+ pageSize: 10,
+ host: ''
+}
+
+export default Table
diff --git a/components/table/menu/index.js b/components/table/menu/index.js
index 204a53f43..1293500c0 100644
--- a/components/table/menu/index.js
+++ b/components/table/menu/index.js
@@ -32,9 +32,10 @@ document.addEventListener('click', () => {
setTimeout(hide, 0)
})
export default {
- show (e, cbs, key, freeze) {
+ show (e, cbs, key, freeze, size) {
div && hide()
div = document.createElement('div')
+ div.className = 'hi-table-header-menu-' + size || ''
ReactDOM.render(, div)
div.style.position = 'absolute'
div.style.left = e.pageX + 'px'
diff --git a/components/table/style/Table.scss b/components/table/style/Table.scss
index 6500ac708..98ea7c2b0 100644
--- a/components/table/style/Table.scss
+++ b/components/table/style/Table.scss
@@ -1,6 +1,72 @@
$table: 'hi-table' !default;
$bgColor: #f7fafe !default;
+$miniHeight: 30px;
+$miniFontSize: 12px;
+
+$smallHeight: 40px;
+$smallFontSize: 13px;
+
+$normalHeight: 50px;
+$nornamFontSize: 14px;
+
+.#{$table}{
+ &.small{
+ table{
+ tr{
+ height: $smallHeight;
+ font-size: $smallFontSize;
+ }
+ }
+ .hi-table-header-menu{
+ >p{
+ height: $smallHeight !important;
+ font-size: $smallFontSize;
+ }
+ }
+ .hi-table-setting-menu{
+ >div{
+ height: $smallHeight;
+ }
+ }
+ }
+}
+.hi-table-header-menu-small{
+ .hi-table-header-menu{
+ p{
+ height: $smallHeight;
+ }
+ }
+}
+.hi-table-header-menu-mini{
+ .hi-table-header-menu{
+ p{
+ height: $miniHeight;
+ }
+ }
+}
+
+.#{$table}{
+ &.mini{
+ table{
+ tr{
+ height: $miniHeight;
+ font-size: $miniFontSize;
+ }
+ }
+ .hi-table-header-menu{
+ >p{
+ height: $miniHeight !important;
+ font-size: $miniHeight;
+ }
+ }
+ .hi-table-setting-menu{
+ >div{
+ height: $miniHeight;
+ }
+ }
+ }
+}
.#{$table} {
position: relative;
width: 100%;
@@ -22,11 +88,10 @@ $bgColor: #f7fafe !default;
width: 140px;
p {
- font-size: 14px;
color: #383e47;
text-align: left;
margin: 0;
- line-height: 50px;
+ height: $normalHeight;
text-indent: 16px;
display: flex;
align-items: center;
@@ -49,17 +114,16 @@ $bgColor: #f7fafe !default;
width: 140px;
> div {
- font-size: 14px;
color: #383e47;
text-align: left;
margin: 0;
- line-height: 50px;
padding-left: 16px;
+ padding-right: 16px;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
-
+ height: $normalHeight;
&:hover {
background: $bgColor;
color: #4284f5;
@@ -79,7 +143,7 @@ $bgColor: #f7fafe !default;
&.column-menu {
position: absolute;
- right: 10px;
+ right: 30px;
top: 40px;
width: 220px;
max-height: 240px;
@@ -103,9 +167,7 @@ $bgColor: #f7fafe !default;
td,
th {
white-space: nowrap;
- //padding: 16px 8px;
padding-left: 8px;
- font-size: 14px;
border-bottom: 1px solid #e6e7e8;
text-align: left;
}
@@ -132,7 +194,8 @@ $bgColor: #f7fafe !default;
tr {
transition: 0.2s;
cursor: pointer;
- height: 50px;
+ height: $normalHeight;
+ font-size: $nornamFontSize;
padding: 0;
box-sizing: border-box;
@@ -254,13 +317,12 @@ $bgColor: #f7fafe !default;
background: #fff;
border-bottom: 1px solid #e6e7e8;
text-align: center;
- font-size: 14px;
z-index: 1;
}
&-setting {
position: absolute;
- right: 10px;
+ right: 15px;
top: 0;
cursor: pointer;
background: $bgColor;
diff --git a/components/table/tableContent.js b/components/table/tableContent.js
index d9811dfa1..ccbaf1a04 100644
--- a/components/table/tableContent.js
+++ b/components/table/tableContent.js
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import Body from './body'
-import {Header} from './header'
+import Header from './header'
export default class TableContent extends Component {
render () {
@@ -32,7 +32,6 @@ export default class TableContent extends Component {
{body
? : null
}
-
)
}
diff --git a/components/tooltip/index.js b/components/tooltip/index.js
index 6d3748a23..f2529a862 100644
--- a/components/tooltip/index.js
+++ b/components/tooltip/index.js
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
+import Popper from '../popper'
import './style/index'
class Tooltip extends Component {
@@ -35,8 +36,21 @@ class Tooltip extends Component {
style={style}
onMouseEnter={() => { this.setState({tooltipShow: true}) }}
onMouseLeave={() => { this.setState({tooltipShow: false}) }}
+ ref={node => { this.tooltipContainer = node }}
>
- {this.props.title}
+
+
+ {this.props.title}
+
+
+
{this.props.children}
)
diff --git a/components/tooltip/style/index.scss b/components/tooltip/style/index.scss
index 97d2ae383..5a6bb2a6b 100644
--- a/components/tooltip/style/index.scss
+++ b/components/tooltip/style/index.scss
@@ -5,194 +5,174 @@
color: #4a4a4a;
display: inline-block;
- .hi-tooltip-base {
- display: none;
- border-radius: 2px;
+}
+
+
+
+.hi-tooltip-base {
+ border-radius: 2px;
+ background: #4a4a4a;
+ font-size: 12px;
+ color: #fff;
+ padding: 0 5px;
+ line-height: 24px;
+ white-space: nowrap;
+ transition: all 0.5s;
+
+ &::after {
+ content: '';
position: absolute;
- z-index: 11;
- background: #4a4a4a;
- font-size: 12px;
- color: #fff;
- padding: 0 5px;
- line-height: 24px;
- white-space: nowrap;
- transition: all 0.5s;
-
- &::after {
- content: '';
- position: absolute;
- }
}
+}
- .hi-tooltip-show {
- display: block;
- }
+.hi-tooltip-top {
+ position: relative;
+ margin-bottom: 5px;
- .hi-tooltip-top {
- bottom: 100%;
- margin-bottom: 5px;
+ &::after {
+ border: 5px solid transparent;
+ border-top-color: #4a4a4a;
+ bottom: -10px;
left: 50%;
transform: translateX(-50%);
-
- &::after {
- border: 5px solid transparent;
- border-top-color: #4a4a4a;
- bottom: -10px;
- left: 50%;
- transform: translateX(-50%);
- }
}
+}
- .hi-tooltip-right {
- left: 100%;
- margin-left: 5px;
+.hi-tooltip-right {
+ position: relative;
+ margin-left: 5px;
+
+ &::after {
+ border: 5px solid transparent;
+ border-right-color: #4a4a4a;
+ left: -10px;
top: 50%;
transform: translateY(-50%);
-
- &::after {
- border: 5px solid transparent;
- border-right-color: #4a4a4a;
- left: -10px;
- top: 50%;
- transform: translateY(-50%);
- }
}
+}
+
+.hi-tooltip-bottom {
+ position: relative;
+ margin-top: 5px;
- .hi-tooltip-bottom {
- top: 100%;
- margin-top: 5px;
+ &::after {
+ border: 5px solid transparent;
+ border-bottom-color: #4a4a4a;
+ top: -10px;
left: 50%;
transform: translateX(-50%);
-
- &::after {
- border: 5px solid transparent;
- border-bottom-color: #4a4a4a;
- top: -10px;
- left: 50%;
- transform: translateX(-50%);
- }
}
+}
+
+.hi-tooltip-left {
+ position: relative;
+ margin-right: 5px;
- .hi-tooltip-left {
- right: 100%;
- margin-right: 5px;
+ &::after {
+ border: 5px solid transparent;
+ border-left-color: #4a4a4a;
+ right: -10px;
top: 50%;
transform: translateY(-50%);
-
- &::after {
- border: 5px solid transparent;
- border-left-color: #4a4a4a;
- right: -10px;
- top: 50%;
- transform: translateY(-50%);
- }
}
+}
- .hi-tooltip-top-left {
- bottom: 100%;
- margin-bottom: 5px;
- left: 0;
-
- &::after {
- border: 5px solid transparent;
- border-top-color: #4a4a4a;
- bottom: -10px;
- left: 20%;
- transform: translateX(-50%);
- }
- }
+.hi-tooltip-top-left {
+ position: relative;
+ margin-bottom: 5px;
- .hi-tooltip-top-right {
- bottom: 100%;
- margin-bottom: 5px;
- right: 0;
-
- &::after {
- border: 5px solid transparent;
- border-top-color: #4a4a4a;
- bottom: -10px;
- right: 10%;
- transform: translateX(-50%);
- }
+ &::after {
+ border: 5px solid transparent;
+ border-top-color: #4a4a4a;
+ bottom: -10px;
+ left: 20%;
+ transform: translateX(-50%);
}
+}
+
+.hi-tooltip-top-right {
+ position: relative;
+ margin-bottom: 5px;
- .hi-tooltip-bottom-right {
- top: 100%;
- margin-top: 5px;
- right: 0;
-
- &::after {
- border: 5px solid transparent;
- border-bottom-color: #4a4a4a;
- top: -10px;
- right: 10%;
- transform: translateX(-50%);
- }
+ &::after {
+ border: 5px solid transparent;
+ border-top-color: #4a4a4a;
+ bottom: -10px;
+ right: 10%;
+ transform: translateX(-50%);
}
+}
+
+.hi-tooltip-bottom-right {
+ position: relative;
+ margin-top: 5px;
- .hi-tooltip-bottom-left {
- top: 100%;
- margin-top: 5px;
- left: 0;
-
- &::after {
- border: 5px solid transparent;
- border-bottom-color: #4a4a4a;
- top: -10px;
- left: 20%;
- transform: translateX(-50%);
- }
+ &::after {
+ border: 5px solid transparent;
+ border-bottom-color: #4a4a4a;
+ top: -10px;
+ right: 10%;
+ transform: translateX(-50%);
}
+}
+
+.hi-tooltip-bottom-left {
+ position: relative;
+ margin-top: 5px;
- .hi-tooltip-left-top {
- right: 100%;
- margin-right: 5px;
- top: 0;
-
- &::after {
- border: 5px solid transparent;
- border-left-color: #4a4a4a;
- right: -10px;
- top: 15%;
- }
+ &::after {
+ border: 5px solid transparent;
+ border-bottom-color: #4a4a4a;
+ top: -10px;
+ left: 20%;
+ transform: translateX(-50%);
}
+}
- .hi-tooltip-left-bottom {
- right: 100%;
- margin-right: 5px;
- bottom: 0;
-
- &::after {
- border: 5px solid transparent;
- border-left-color: #4a4a4a;
- right: -10px;
- bottom: 15%;
- }
+.hi-tooltip-left-top {
+ position: relative;
+ margin-right: 5px;
+
+ &::after {
+ border: 5px solid transparent;
+ border-left-color: #4a4a4a;
+ right: -10px;
+ top: 15%;
}
+}
- .hi-tooltip-right-top {
- left: 100%;
- margin-left: 5px;
- top: 0;
-
- &::after {
- border: 5px solid transparent;
- border-right-color: #4a4a4a;
- left: -10px;
- top: 15%;
- }
+.hi-tooltip-left-bottom {
+ position: relative;
+ margin-right: 5px;
+
+ &::after {
+ border: 5px solid transparent;
+ border-left-color: #4a4a4a;
+ right: -10px;
+ bottom: 15%;
}
+}
- .hi-tooltip-right-bottom {
- left: 100%;
- margin-left: 5px;
- bottom: 0;
-
- &::after {
- border: 5px solid transparent;
- border-right-color: #4a4a4a;
- left: -10px;
- bottom: 15%;
- }
+.hi-tooltip-right-top {
+ position: relative;
+ margin-left: 5px;
+
+ &::after {
+ border: 5px solid transparent;
+ border-right-color: #4a4a4a;
+ left: -10px;
+ top: 15%;
}
}
+
+.hi-tooltip-right-bottom {
+ position: relative;
+ margin-left: 5px;
+
+ &::after {
+ border: 5px solid transparent;
+ border-right-color: #4a4a4a;
+ left: -10px;
+ bottom: 15%;
+ }
+}
\ No newline at end of file
diff --git a/docs/en-US/button.md b/docs/en-US/button.md
index e0e336ffe..1f554b699 100644
--- a/docs/en-US/button.md
+++ b/docs/en-US/button.md
@@ -10,8 +10,8 @@ Button component provides 7 themes by default. Defined by the `type` attribute,
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -48,8 +48,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -78,8 +78,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -107,8 +107,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -146,8 +146,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
diff --git a/docs/en-US/grid.md b/docs/en-US/grid.md
index afa5f4006..2fe84d3b1 100644
--- a/docs/en-US/grid.md
+++ b/docs/en-US/grid.md
@@ -8,8 +8,8 @@ Horizontal -No gap
```js
render(){
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -41,8 +41,8 @@ Horizontal
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -71,8 +71,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -114,8 +114,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -150,8 +150,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
diff --git a/docs/en-US/i18n.md b/docs/en-US/i18n.md
index 9304d1a55..ffacea2ce 100644
--- a/docs/en-US/i18n.md
+++ b/docs/en-US/i18n.md
@@ -28,8 +28,8 @@ constructor(props) {
}
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
diff --git a/docs/zh-CN/button.md b/docs/zh-CN/button.md
index 9947b9a3d..b6fc9ad03 100644
--- a/docs/zh-CN/button.md
+++ b/docs/zh-CN/button.md
@@ -12,8 +12,8 @@
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -72,9 +72,10 @@ render() {
:::demo
-按钮可设置大小。
+按钮可设置大小及内部图标。
-- 尺寸:可设置为 `large`、`small`,默认为 `default`。
+- 尺寸:可设置为 `large`、`small`,默认为 `default`;
+- 图标:可设置为内部 Icon。
```js
render() {
@@ -87,6 +88,8 @@ render() {
+
+
)
@@ -100,8 +103,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -139,8 +142,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -167,6 +170,7 @@ render() {
| type | 设置按钮类型 | string | primary,line, success,danger, default | default |
| appearance | 按钮显示类型(按钮或链接) | string | button, link | button |
| size | 设置按钮大小 | string | large, normal, small | normal |
+| icon | 设置按钮图标,设置后忽略子元素只渲染对应图标 | string | 详见 `` 组件 | - |
| className | 自定义class | string | - | - |
### Button Events
diff --git a/docs/zh-CN/checkbox.md b/docs/zh-CN/checkbox.md
index 64f574356..06840e25f 100644
--- a/docs/zh-CN/checkbox.md
+++ b/docs/zh-CN/checkbox.md
@@ -7,10 +7,10 @@
render() {
return (
-
console.log(val, isCheck)}>未选中项
-
未选中失效
-
console.log(val, isCheck)}>选中项
-
选中失效
+
console.log(val, isCheck)}>未选中项
+
未选中失效
+
console.log(val, isCheck)}>选中项
+
选中失效
)
}
@@ -24,9 +24,9 @@ render() {
render() {
return (
-
console.log(val, isCheck)}>篮球
-
console.log(val, isCheck)}>足球
-
console.log(val, isCheck)}>排球
+
console.log(val, isCheck)}>篮球
+
console.log(val, isCheck)}>足球
+
console.log(val, isCheck)}>排球
)
}
diff --git a/docs/zh-CN/form.md b/docs/zh-CN/form.md
index 74ebed41b..9fde2ae4f 100644
--- a/docs/zh-CN/form.md
+++ b/docs/zh-CN/form.md
@@ -1,15 +1,10 @@
## Form表单组件
-
-
### 对齐方式
:::demo
-
-
```js
-
constructor() {
super()
@@ -49,11 +44,10 @@ constructor() {
}
}
-
render(){
const {position, alignCheckedIndex, columnCheckedIndex} = this.state
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -117,10 +111,7 @@ render(){
:::demo
-
-
```js
-
render(){
return (
@@ -145,12 +136,9 @@ render(){
### 表单验证
-:::demo
-
-
+:::demo
```js
-
constructor(props) {
super(props)
@@ -226,27 +214,35 @@ handleChange(key, e, value, index) {
}
render(){
+ const Row = Grid.Row
+ const Col = Grid.Col
const {form, checkedIndex} = this.state
return (
)
diff --git a/docs/zh-CN/grid.md b/docs/zh-CN/grid.md
index 7bbd91838..2b0c0b841 100644
--- a/docs/zh-CN/grid.md
+++ b/docs/zh-CN/grid.md
@@ -10,8 +10,8 @@
```js
render(){
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -43,8 +43,8 @@ render(){
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -75,8 +75,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -120,8 +120,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
@@ -158,8 +158,8 @@ render() {
```js
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
diff --git a/docs/zh-CN/i18n.md b/docs/zh-CN/i18n.md
index dfaa881d6..2773c0a94 100644
--- a/docs/zh-CN/i18n.md
+++ b/docs/zh-CN/i18n.md
@@ -28,8 +28,8 @@ constructor(props) {
}
render() {
- const Row = Layout.Row
- const Col = Layout.Col
+ const Row = Grid.Row
+ const Col = Grid.Col
return (
diff --git a/docs/zh-CN/input.md b/docs/zh-CN/input.md
index a2fcf34e0..944943c7c 100644
--- a/docs/zh-CN/input.md
+++ b/docs/zh-CN/input.md
@@ -217,6 +217,91 @@ render() {
:::
+
+### 前置元素
+
+:::demo
+
+国际号码
+
+```js
+constructor () {
+ super()
+ this.state = {
+ tel: '',
+ value: '',
+ selectValue: '86',
+ singleList: [
+ { name:'+86', id:'86' },
+ { name:'+1', id:'1' },
+ { name:'+33', id:'33' },
+ { name:'+91', id:'91' },
+ ]
+ }
+}
+render() {
+ const {
+ value,
+ selectValue,
+ singleList
+ } = this.state
+
+ return (
+
+ this.setState({value: e.target.value})}
+ prepend={
+
+ )
+}
+```
+:::
+
+
+### 后置元素
+
+:::demo
+
+邮箱
+
+```js
+render() {
+ return (
+
+ 搜索}
+ placeholder="请输入邮箱(数字、字母、下划线)"
+ style={{width: '250px'}}
+ />
+
+ )
+}
+```
+:::
+
+
### 多行文本
:::demo
@@ -249,6 +334,8 @@ render() {
| required | 是否必填 | string | true/false | false |
| prefix | 前缀 | string | - | - |
| suffix | 后缀 | string | - | - |
+| prepend | 前置元素 | Element | - | - |
+| append | 后置元素 | Element | - | - |
### Input Events
diff --git a/docs/zh-CN/loading.md b/docs/zh-CN/loading.md
index 38b201b21..400b0a37f 100644
--- a/docs/zh-CN/loading.md
+++ b/docs/zh-CN/loading.md
@@ -81,6 +81,7 @@ clickEvent () {
showLoading: true
})
this.mockTableData().then(res => {
+
this.setState({
showLoading: false,
list: res,
@@ -131,6 +132,55 @@ render () {
```
:::
+
+### 接口调用
+:::demo
+
+```js
+constructor () {
+ super()
+ this.state = {
+ open: false
+ }
+ this.el = null
+}
+
+demoEvent1 () {
+ const l = Loading.open()
+ setTimeout(() => {
+ l.close()
+ }, 3000)
+}
+demoEvent2 () {
+ const l = Loading.open({
+ target: this.el,
+ tip: '加载中...'
+ })
+ setTimeout(() => {
+ l.close()
+ }, 3000)
+}
+render () {
+ return
+
+
+
{this.el = el}} style={{margin: 20}}>
+
+
+ 我是标题
+
+ }
+ >
+
Panel content
+
+
+
+}
+```
+:::
+
### Loading Attributes
| 参数 | 说明 | 类型 | 可选值 |默认值 |
@@ -138,4 +188,5 @@ render () {
| size | 组件大小 | string | large default small | default |
| tip | 自定义的旋转动画下的文字 | string | - | |
| full | 是否全屏 | bool | - | false |
-| show | 是否显示加载动画 | boolean | true false | false |
\ No newline at end of file
+| show | 是否显示加载动画 | boolean | true false | false |
+| target | 用于指令调用时,Loading 遮罩的元素,为空时将整页遮罩 | Element、ReactElement | | |
\ No newline at end of file
diff --git a/docs/zh-CN/modal.md b/docs/zh-CN/modal.md
index 798afc35e..e8253d785 100755
--- a/docs/zh-CN/modal.md
+++ b/docs/zh-CN/modal.md
@@ -25,7 +25,6 @@
{console.log('自定义确定事件')}}
onCancel={this.cancelEvent.bind(this)}
>
@@ -36,6 +35,75 @@
)
}
+```
+:::
+
+### 自定义尺寸
+
+
+:::demo
+
+- 通过 size 自定义尺寸,可使用 `large`、`nomal`、`small`,默认为 `normal`
+
+```js
+ constructor (props) {
+ super(props)
+ this.state = {
+ show: false,
+ size: 'normal',
+ sizeList: [
+ {
+ name: '标准',
+ id: 'normal'
+ },
+ {
+ name: '大',
+ id: 'large'
+ },
+ {
+ name: '小',
+ id: 'small'
+ }
+ ],
+ sizeListActive: 0
+ }
+ }
+ cancelEvent () {
+ this.setState({
+ show: false
+ })
+ console.log("关闭事件")
+ }
+ render(){
+ return(
+
+ {
+ this.setState({
+ size: data,
+ sizeListActive: index
+ })
+ }}
+ />
+
+ 关闭
+ ]}
+ >
+ 一些消息
+ 一些消息
+
+
+
+ )
+ }
```
@@ -45,8 +113,10 @@
:::demo
-> 通过 footers自定义底部的按钮,并执行对应自定义事件
-> 通过 closeBtn 取消右上角关闭按钮
+
+- 通过 footers自定义底部的按钮,并执行对应自定义事件
+- 通过 closeBtn 取消右上角关闭按钮
+
```js
constructor (props) {
super(props)
@@ -68,15 +138,13 @@
title="提示消息"
closeBtn={false}
show={this.state.show}
- backDrop={true}
onConfirm={()=>{console.log('自定义确定事件')}}
onCancel={this.cancelEvent.bind(this)}
- // width={800}
footers={[
- ,
- ,
- ,
-
+ ,
+ ,
+ ,
+
]}
>
一些消息
@@ -94,8 +162,10 @@
### 嵌套用法
:::demo
-> 未传入title 及 closeBtn 为 false,可取消 title 部分
-> footers 传入空数组,可取消底部按钮
+
+- 未传入title 及 closeBtn 为 false,可取消 title 部分
+- footers 传入空数组,可取消底部按钮
+
```js
constructor (props) {
super(props)
@@ -186,8 +256,6 @@
)
}
-
-
```
:::
@@ -195,15 +263,14 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
| -------- | ----- | ---- | ---- | ---- |
-| confirmType | 确定按钮类型 | string(同 button 组件的 type 属性) | - | primary |
-| cancelType | 取消按钮类型 | string(同 button 组件的 type 属性)| - | default |
| title | 标题 | string
Node
React.Component | - | 无 |
| onConfirm | 点击确定的回调 | function | - | 无 |
| onCancel | 点击遮罩或者右上角取消或者取消按钮的回调 | function | - | 无 |
| confirmText | 确定按钮文字 | string | - | 确定 |
| cancelText | 取消按钮文字 | string | - | 取消 |
| backDrop | 点击黑色背景部分是否隐藏弹框 | boolean | true / false | true |
-| width | 自定义弹窗宽度 | number
string | - | 540px |
+| size | 定义弹窗尺寸 | string | normal, large, small | normal |
+| width | 自定义弹窗宽度 | number
string | - | 600px |
| closeBtn | 是否显示右上角关闭按钮 | bool | - | true |
| footers | 自定义底部按钮数组(传入空数组将取消底部按钮) | array | - | - |
| show | 弹窗是否显示 | bool | true / false | false |
diff --git a/docs/zh-CN/radio.md b/docs/zh-CN/radio.md
index c9ec598c7..8d9b9ae26 100644
--- a/docs/zh-CN/radio.md
+++ b/docs/zh-CN/radio.md
@@ -62,6 +62,9 @@ render() {
list={this.state.play}
onChange={(data)=>{
console.log(data)
+ this.setState({
+ people: []
+ })
}}
checked={1}
disabled={1}
diff --git a/docs/zh-CN/select.md b/docs/zh-CN/select.md
index 7db505b24..dd9a5cd1e 100644
--- a/docs/zh-CN/select.md
+++ b/docs/zh-CN/select.md
@@ -29,6 +29,7 @@ render () {