uxcore-kuma
Advanced tools
Comparing version 2.0.4 to 2.0.5
{ | ||
"name": "uxcore-kuma", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "style for uxcore based on kuma", | ||
@@ -5,0 +5,0 @@ "author": "shane.wuq", |
{ | ||
"name": "uxcore-alert", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "uxcore-alert component for uxcore.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/uxcore/uxcore-alert.git", |
@@ -14,3 +14,3 @@ let Calendar = require('../src'); | ||
this.state = { | ||
value: undefined | ||
value: '2016-01-02' | ||
} | ||
@@ -21,3 +21,3 @@ } | ||
this.setState({ | ||
value: null | ||
value: '2016-02-05' | ||
}) | ||
@@ -38,7 +38,7 @@ } | ||
<p>基本</p> | ||
<Calendar locale="en-us" value={1456934400000}/> | ||
<Calendar locale="en-us" value={this.state.value} onSelect={this.onSelect.bind(this)} /> | ||
</div> | ||
<div className="kuma-form-field" style={{width: 400}}> | ||
<p>日期格式</p> | ||
<Calendar value="2015/01/01" format="yyyy/MM/dd" /> | ||
<Calendar value={this.state.value} format="yyyy/MM/dd" onSelect={this.onSelect.bind(this)} /> | ||
</div> | ||
@@ -51,21 +51,21 @@ <div className="kuma-form-field" style={{width: 400}}> | ||
<p>范围</p> | ||
<Calendar disabledDate={disabledDate} /> | ||
<Calendar disabledDate={disabledDate} value={this.state.value} onSelect={this.onSelect.bind(this)} /> | ||
</div> | ||
<div className="kuma-form-field" style={{width: 400}}> | ||
<p>时间选择</p> | ||
<Calendar defaultValue={Date.now()} hasTrigger={true} showTime={true} format="yyyy-MM-dd HH:mm:ss" /> | ||
<Calendar hasTrigger={true} showTime={true} format="yyyy-MM-dd HH:mm:ss" value={this.state.value} onSelect={this.onSelect.bind(this)} /> | ||
</div> | ||
<div className="kuma-form-field" style={{width: 400}}> | ||
<p>禁用</p> | ||
<Calendar value="2015-06-06" disabled={true} /> | ||
<Calendar value={this.state.value} disabled={true} onSelect={this.onSelect.bind(this)}/> | ||
</div> | ||
<div className="kuma-form-field" style={{width: 400}}> | ||
<p>月份</p> | ||
<MonthCalendar /> | ||
<MonthCalendar value={this.state.value} onSelect={this.onSelect.bind(this)} /> | ||
</div> | ||
<div className="kuma-form-field" style={{width: 400}}> | ||
<p>年份</p> | ||
<YearCalendar onSelect={function(...args){console.log(args)}} /> | ||
<YearCalendar value={this.state.value} onSelect={this.onSelect.bind(this)} /> | ||
</div> | ||
<Button onClick={me.handleClick.bind(me)}>reset</Button> | ||
<Button onClick={me.handleClick.bind(me)}>changeTime</Button> | ||
</div> | ||
@@ -72,0 +72,0 @@ ) |
@@ -5,2 +5,6 @@ # History | ||
## 0.3.0 | ||
`CHANGED` new style | ||
`CHANGED` change rc-calendar to ~5.5.0 | ||
## 0.2.6 | ||
@@ -7,0 +11,0 @@ `FIXED` fix camelcase of picker.js |
{ | ||
"name": "uxcore-calendar", | ||
"version": "0.2.6", | ||
"version": "0.3.0", | ||
"description": "calendar componment for react", | ||
@@ -54,3 +54,3 @@ "main": "build/index.js", | ||
"uxcore-button": "~0.3.1", | ||
"uxcore-kuma": "^1.1.0", | ||
"uxcore-kuma": "~2.0.0", | ||
"webpack": "^1.10.5" | ||
@@ -60,9 +60,8 @@ }, | ||
"classnames": "^2.1.2", | ||
"gregorian-calendar": "~3.1.0", | ||
"gregorian-calendar-format": "~3.0.1", | ||
"gregorian-calendar": "4.x", | ||
"gregorian-calendar-format": "4.x", | ||
"object-assign": "^4.0.0", | ||
"rc-align": "~1.2.1", | ||
"rc-calendar": "~3.16.0", | ||
"rc-util": "~2.0.3" | ||
"rc-calendar": "~5.5.0", | ||
"rc-util": "3.x" | ||
} | ||
} |
@@ -1,9 +0,8 @@ | ||
let RcCalendar = require('rc-calendar'); | ||
let Datepicker = require('./Picker'); | ||
let RcCalendar = require('./RcCalendar'); | ||
let GregorianCalendar = require('gregorian-calendar'); | ||
let DateTimeFormat = require('gregorian-calendar-format'); | ||
let Datepicker = require('rc-calendar/lib/Picker'); | ||
let RcMonthCalendar = require('rc-calendar/lib/MonthCalendar'); | ||
let RcYearCalendar = require('./YearCalendar'); | ||
let classSet = require('rc-util').classSet; | ||
let React = require('react'); | ||
let React = require('react'); | ||
let ReactDOM = require('react-dom'); | ||
@@ -13,9 +12,9 @@ | ||
let CalendarLocale = {}; | ||
defaultValueLocale['zh-cn'] = require('gregorian-calendar/lib/locale/zh-cn'); | ||
defaultValueLocale['en-us'] = require('gregorian-calendar/lib/locale/en-us'); | ||
CalendarLocale['zh-cn'] = require('rc-calendar/lib/locale/zh-cn'); | ||
CalendarLocale['en-us'] = require('rc-calendar/lib/locale/en-us'); | ||
defaultValueLocale['zh-cn'] = require('gregorian-calendar/lib/locale/zh_CN'); | ||
defaultValueLocale['en-us'] = require('gregorian-calendar/lib/locale/en_US'); | ||
CalendarLocale['zh-cn'] = require('rc-calendar/lib/locale/zh_CN'); | ||
CalendarLocale['en-us'] = require('rc-calendar/lib/locale/en_US'); | ||
function getGregorianCalendarDate(date, locale){ | ||
defaultValueLocale[locale].timezoneOffset = - new Date().getTimezoneOffset(); | ||
function getGregorianCalendarDate(date, locale) { | ||
defaultValueLocale[locale].timezoneOffset = -new Date().getTimezoneOffset(); | ||
let value = new GregorianCalendar(defaultValueLocale[locale]); | ||
@@ -26,3 +25,3 @@ value.setTime(new Date(date).valueOf()); | ||
function getCalendarContainer(){ | ||
function getCalendarContainer() { | ||
let c = document.createElement('div'); | ||
@@ -51,4 +50,4 @@ c.className = 'uxcore'; | ||
showTime: p.showTime, | ||
showDateInput: p.showDateInput, | ||
locale: CalendarLocale[p.locale], | ||
orient: ['top', 'left'], | ||
prefixCls: 'kuma-calendar' | ||
@@ -61,2 +60,3 @@ }; | ||
prefixCls: 'kuma-calendar-picker', | ||
placement: 'bottomLeft', | ||
getCalendarContainer: getCalendarContainer | ||
@@ -67,5 +67,5 @@ }; | ||
let value = getGregorianCalendarDate(p.value, p.locale); | ||
pickerOptions.value = calendarOptions.value = value; | ||
pickerOptions.value = calendarOptions.defaultValue = value; | ||
} else { | ||
pickerOptions.value = calendarOptions.value = null; | ||
pickerOptions.value = calendarOptions.defaultValue = null; | ||
} | ||
@@ -77,4 +77,3 @@ | ||
pickerOptions.defaultValue = value; | ||
} | ||
else { | ||
} else { | ||
let value = getGregorianCalendarDate(new Date().getTime(), p.locale); | ||
@@ -89,3 +88,3 @@ calendarOptions.defaultValue = value; | ||
function _onChange(v){ | ||
function _onChange(v) { | ||
let date = v.getTime(); | ||
@@ -101,5 +100,7 @@ let value = getGregorianCalendarDate(date, p.locale); | ||
{...pickerOptions}> | ||
<input disabled={me.props.disabled} placeholder={this.props.placeholder} className="kuma-calendar-picker-input kuma-input" /> | ||
{({value}) => { | ||
return <input value={value && formatter.format(value)} readOnly disabled={me.props.disabled} placeholder={this.props.placeholder} className="kuma-calendar-picker-input kuma-input" /> | ||
}} | ||
</Datepicker> | ||
); | ||
); | ||
} | ||
@@ -112,4 +113,5 @@ } | ||
placeholder: '请选择日期', | ||
onSelect: function () {}, | ||
onSelect: function() {}, | ||
locale: 'zh-cn', | ||
showDateInput: false, | ||
hasTrigger: false | ||
@@ -152,5 +154,5 @@ }; | ||
let value = getGregorianCalendarDate(p.value, p.locale); | ||
pickerOptions.value = calendarOptions.value = value; | ||
pickerOptions.value = calendarOptions.defaultValue = value; | ||
} else { | ||
pickerOptions.value = calendarOptions.value = null; | ||
pickerOptions.value = calendarOptions.defaultValue = null; | ||
} | ||
@@ -164,3 +166,3 @@ | ||
function _onChange(v){ | ||
function _onChange(v) { | ||
let date = v.getTime(); | ||
@@ -175,4 +177,6 @@ let value = getGregorianCalendarDate(date, p.locale); | ||
onChange={_onChange.bind(me)} | ||
{...pickerOptions}> | ||
<input disabled={me.props.disabled} placeholder={this.props.placeholder} className="kuma-calendar-picker-input kuma-input" /> | ||
{...pickerOptions}> | ||
{({value}) => { | ||
return <input readOnly value={value && formatter.format(value)} disabled={me.props.disabled} placeholder={this.props.placeholder} className="kuma-calendar-picker-input kuma-input" /> | ||
}} | ||
</Datepicker> | ||
@@ -187,3 +191,3 @@ ); | ||
placeholder: '请选择月份', | ||
onSelect: function () {}, | ||
onSelect: function() {}, | ||
locale: 'zh-cn' | ||
@@ -225,5 +229,5 @@ }; | ||
let value = getGregorianCalendarDate(p.value, p.locale); | ||
pickerOptions.value = calendarOptions.value = value; | ||
pickerOptions.value = calendarOptions.defaultValue = value; | ||
} else { | ||
pickerOptions.value = calendarOptions.value = null; | ||
pickerOptions.value = calendarOptions.defaultValue = null; | ||
} | ||
@@ -237,3 +241,3 @@ | ||
function _onChange(v){ | ||
function _onChange(v) { | ||
let date = v.getTime(); | ||
@@ -245,7 +249,9 @@ let value = getGregorianCalendarDate(date, p.locale); | ||
return (<Datepicker | ||
calendar={calendar} | ||
onChange={_onChange.bind(me)} | ||
{...pickerOptions}> | ||
<input disabled={me.props.disabled} placeholder={this.props.placeholder} className="kuma-calendar-picker-input kuma-input" /> | ||
</Datepicker>); | ||
calendar={calendar} | ||
onChange={_onChange.bind(me)} | ||
{...pickerOptions}> | ||
{({value}) => { | ||
return <input value={value && formatter.format(value)} readOnly disabled={me.props.disabled} placeholder={this.props.placeholder} className="kuma-calendar-picker-input kuma-input" /> | ||
}} | ||
</Datepicker>); | ||
} | ||
@@ -258,3 +264,3 @@ } | ||
placeholder: '请选择年份', | ||
onSelect: function () {}, | ||
onSelect: function() {}, | ||
locale: 'zh-cn' | ||
@@ -270,4 +276,4 @@ }; | ||
Calendar.MonthCalendar = MonthCalendar; | ||
Calendar.YearCalendar = YearCalendar; | ||
Calendar.YearCalendar = YearCalendar; | ||
module.exports = Calendar; |
import YearPanel from 'rc-calendar/lib/year/YearPanel'; | ||
import CalendarMixin from 'rc-calendar/lib/mixin/CalendarMixin'; | ||
import CommonMixin from 'rc-calendar/lib/mixin/CommonMixin'; | ||
import {KeyCode} from 'rc-util'; | ||
let React = require('react'); | ||
let ReactDOM = require('react-dom'); | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
const YearCalendar = React.createClass({ | ||
mixins: [CalendarMixin], | ||
mixins: [CalendarMixin, CommonMixin], | ||
@@ -65,3 +66,5 @@ onKeyDown(e) { | ||
return this.renderRoot({ | ||
children, | ||
children: children, | ||
className: `${props.prefixCls}-year-calendar-container` | ||
}); | ||
@@ -68,0 +71,0 @@ } |
{ | ||
"name": "uxcore-dialog", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "uxcore-dialog ui componment for react", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -0,5 +1,12 @@ | ||
## 1.3.0 | ||
* `CHANGED` new style | ||
## 1.2.24 | ||
* `HotFix` fix doValidate bug which will return undefined if jsxrules is not defined | ||
## 1.2.23 | ||
* `NEW` `InputFormField` add new prop `inputType` #71 | ||
@@ -6,0 +13,0 @@ * `NEW` add new prop `onKeyDown` in `InputFormField` & `TextAreaFormField` |
{ | ||
"name": "uxcore-form", | ||
"version": "1.2.24", | ||
"version": "1.3.0", | ||
"description": "form component for uxcore", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/uxcore/uxcore-form.git", |
{ | ||
"name": "uxcore-popover", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "uxcore-popover component for uxcore.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/uxcore/uxcore-popover.git", |
{ | ||
"name": "uxcore-steps", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "uxcore-steps component for uxcore.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/uxcore/uxcore-steps.git", |
@@ -8,3 +8,2 @@ /** | ||
*/ | ||
let classnames = require('classnames'); | ||
@@ -15,108 +14,150 @@ let Table = require('../src'); | ||
let mockData = { | ||
"datas": [ | ||
{ | ||
"check": true, | ||
"id":"1", | ||
"grade":"grade1", | ||
"email":"email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1", | ||
"firstName":"firstName1", | ||
"lastName":"lastName1", | ||
"birthDate":"birthDate1", | ||
"country":"086156529655931.121(xsxs)", | ||
"city":"87181" | ||
}, | ||
{ | ||
"check": false, | ||
"id":"1", | ||
"grade":"grade1", | ||
"email":"email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1", | ||
"firstName":"firstName1", | ||
"lastName":"lastName1", | ||
"birthDate":"birthDate1", | ||
"country":"086156529655931.121(xsxs)", | ||
"city":"87181" | ||
} | ||
] | ||
"datas": [{ | ||
"check": true, | ||
"id": "1", | ||
"grade": "grade1", | ||
"email": "email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1", | ||
"firstName": "firstName1", | ||
"lastName": "lastName1", | ||
"birthDate": "birthDate1", | ||
"country": "086156529655931.121(xsxs)", | ||
"city": "87181" | ||
}, { | ||
"check": false, | ||
"id": "1", | ||
"grade": "grade1", | ||
"email": "email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1email1", | ||
"firstName": "firstName1", | ||
"lastName": "lastName1", | ||
"birthDate": "birthDate1", | ||
"country": "086156529655931.121(xsxs)", | ||
"city": "87181" | ||
}] | ||
} | ||
///* 第一列为radio的demo | ||
class Demo extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
data: this.props.data | ||
data: this.props.data | ||
} | ||
} | ||
render () { | ||
render() { | ||
let me = this; | ||
// 通过 rowSelection 对象表明需要行选择 | ||
let rowSelection = { | ||
onSelect: function(record, selected, selectedRows) { | ||
console.log(record, selected, selectedRows); | ||
}, | ||
onSelectAll: function(selected, selectedRows) { | ||
console.log(selected, selectedRows); | ||
} | ||
onSelect: function(record, selected, selectedRows) { | ||
console.log(record, selected, selectedRows); | ||
}, | ||
onSelectAll: function(selected, selectedRows) { | ||
console.log(selected, selectedRows); | ||
} | ||
}; | ||
let columns = [ | ||
{ dataKey: 'id', title: 'ID', width: 50,hidden:true}, | ||
{ | ||
dataKey: 'id', | ||
title: 'ID', | ||
width: 50, | ||
hidden: true | ||
}, | ||
// { dataKey: 'radio', title:'', type: 'radioSelector' /*checkboxSelector*/, width: 50, isDisable: function (rowData) { | ||
// return rowData.id > 5; | ||
// }}, | ||
{ dataKey: 'country', title:'国家', width: 200,ordered:true}, | ||
{ dataKey: 'city',title:'城市', width: 150,ordered:true }, | ||
{ dataKey: 'firstName',title:"FristName" }, | ||
{ dataKey: 'lastName' ,title:"LastName"}, | ||
{ dataKey: 'email',title:"Email",width: 200,ordered:true }, | ||
{ dataKey: 'action1', title:'操作1', width:100, type:"action",actions:{ | ||
"clickme": function(rowData, actions) { | ||
alert('thanks clickme,'+rowData.firstName) | ||
}, | ||
"del": function(rowData) { | ||
me.refs.grid.delRow(rowData); | ||
{ | ||
dataKey: 'country', | ||
title: '国家', | ||
width: 200, | ||
ordered: true | ||
}, | ||
{ | ||
dataKey: 'city', | ||
title: '城市', | ||
width: 150, | ||
ordered: true, | ||
message: '都是中国城市' | ||
}, | ||
{ | ||
dataKey: 'firstName', | ||
title: "FristName" | ||
}, | ||
{ | ||
dataKey: 'lastName', | ||
title: "LastName" | ||
}, | ||
{ | ||
dataKey: 'email', | ||
title: "Email", | ||
width: 200, | ||
ordered: true | ||
}, { | ||
dataKey: 'action1', | ||
title: '操作1', | ||
width: 100, | ||
type: "action", | ||
actions: [{ | ||
title: 'click', | ||
callback: function() { | ||
alert('click') | ||
}, | ||
mode: 'edit' | ||
}, { | ||
title: '删除', | ||
callback: function() { | ||
alert('删除') | ||
}, | ||
mode: 'view' | ||
}, { | ||
title: 'view', | ||
callback: function() { | ||
alert('view') | ||
}, | ||
mode: 'edit' | ||
}, { | ||
title: 'view', | ||
callback: function() { | ||
alert('view') | ||
} | ||
}] | ||
}, { | ||
dataKey: 'action', | ||
title: '链接', | ||
width: 100, | ||
render: function(rowData) { | ||
return <div><a href="#">111</a></div> | ||
} | ||
}, | ||
beforeRender: function(rowData,actionItems) { | ||
if(rowData.jsxid%2==0) { | ||
return ['clickme']; | ||
}else { | ||
return ['clickme','del']; | ||
} | ||
} | ||
}, | ||
{ dataKey: 'action', title:'链接', width:100,render: function(rowData){ | ||
return <div><a href="#">111</a></div> | ||
} | ||
} | ||
] | ||
let fetchUrl = './demo/GridDemoData.json'; | ||
let renderProps={ | ||
let fetchUrl = 'http://eternalsky.me:8122/file/getGridJson.jsonp'; | ||
let renderProps = { | ||
actionColumn: { | ||
'edit': function() {}, | ||
'del': function() {} | ||
'edit': function() {}, | ||
'del': function() {} | ||
}, | ||
actionBar: { | ||
'action button': function(type, table) { | ||
alert(type); | ||
'Action Button': function(type, table) { | ||
alert(type); | ||
} | ||
}, | ||
showSearch:true, | ||
showSearch: true, | ||
fetchUrl: fetchUrl, | ||
rowSelector: 'radioSelector', | ||
jsxcolumns: columns, | ||
rowSelection: rowSelection | ||
rowSelection: rowSelection, | ||
renderSubComp: function() { | ||
return <div>1</div> | ||
}, | ||
addRowClassName: function(rowData) { | ||
return 'multiline'; | ||
} | ||
}; | ||
return (<Table {...renderProps} ref="grid"/>); | ||
} | ||
}; | ||
return ( | ||
<div> | ||
<i className="kuma-icon kuma-icon-iconfontup"></i> | ||
<Table {...renderProps} ref="grid"/> | ||
</div> | ||
); | ||
} | ||
} | ||
; | ||
//*/ | ||
module.exports = Demo; |
@@ -5,5 +5,5 @@ # History | ||
# 1.3.21 | ||
# 1.4.0 | ||
* `HOTFIX` change the warning text of using type:checkbox. | ||
* `CHANGED` new style | ||
@@ -10,0 +10,0 @@ # 1.3.20 |
{ | ||
"name": "uxcore-table", | ||
"version": "1.3.21", | ||
"version": "1.4.0", | ||
"description": "table ui component for react", | ||
@@ -53,3 +53,3 @@ "repository": "https://github.com/uxcore/uxcore-table.git", | ||
"react-dom": "~0.14.0", | ||
"uxcore-kuma": "~1.2.1", | ||
"uxcore-kuma": "~2.0.0", | ||
"webpack": "^1.10.5" | ||
@@ -63,9 +63,12 @@ }, | ||
"react-mixin": "~1.7.0", | ||
"uxcore-button": "~0.3.0", | ||
"uxcore-button": "~0.4.0", | ||
"uxcore-const": "~0.0.1", | ||
"uxcore-dropdown": "^0.2.2", | ||
"uxcore-formatter": "~0.1.2", | ||
"uxcore-menu": "^1.1.1", | ||
"uxcore-pagination": "~0.1.0", | ||
"uxcore-popover": "~0.2.4", | ||
"uxcore-radiogroup": "~1.1.1", | ||
"uxcore-select2": "~0.1.4", | ||
"uxcore-tree": "~0.1.8", | ||
"uxcore-tree": "~0.2.0", | ||
"uxcore-validator": "~0.1.0" | ||
@@ -72,0 +75,0 @@ }, |
@@ -19,54 +19,28 @@ # uxcore-table | ||
## Best Practice | ||
## API | ||
```javascript | ||
### 行内编辑用 | ||
let columns = [ | ||
{ dataKey: 'check', type: 'checkbox', disable: false}, // custom checkbox column, dataKey can be anyone, true means checked. | ||
{ dataKey: 'id', title: 'ID', width: 50,hidden:true}, | ||
{ dataKey: 'country', title:'国家', width: 200,ordered:true}, | ||
{ dataKey: 'city',title:'城市', width: 150,ordered:true }, | ||
{ dataKey: 'firstName',title:"FristName" }, | ||
{ dataKey: 'lastName' ,title:"LastName"}, | ||
{ dataKey: 'email',title:"Email",width: 200,ordered:true } | ||
]; | ||
* getData(): 返回表格的数据,并作校验。 | ||
* addEmptyRow(): 添加一个空的新行。 | ||
* addRow(rowData): 以指定数据添加一个新行。 | ||
* delRow(rowData): 删除一个新行。 | ||
* editRow(rowData): 使指定的行切换到编辑模式。 | ||
* editAllRow(): 使所有行切换到编辑模式。 | ||
* viewRow(rowData): 使指定的行切换到查看模式。 | ||
* saveRow(rowData): 保存行的数据(同时切换至查看模式)。 | ||
* saveAllRow(): 保存所有行的数据(同时切换至查看模式)。 | ||
* resetRow(rowData): 重置行到数据(若保存过,则为保存过后的数据)。 | ||
### 获取数据 | ||
let rowSelection = { | ||
onSelect: function(record, selected, selectedRows) { | ||
console.log(record, selected, selectedRows); | ||
}, | ||
onSelectAll: function(record, data) { | ||
console.log(record, data); | ||
} | ||
}; | ||
* fetchData(from): 使表格重新请求一次数据。 | ||
* @param from {string} {optional}: 这个参数会传入到 beforeFetch 的回调中。 | ||
renderProps={ | ||
actionBar: { | ||
'new': function(type, actions){ alert(type); }, // type means 'new' in this line | ||
'import': function(type, actions){ alert(type); }, // actions contains all table's APIs, such as actions.addEmptyRow() | ||
'export': function(type, actions){ alert(type); } | ||
}, | ||
fetchUrl:"http://localhost:3000/demo/data.json", | ||
jsxcolumns:columns, | ||
renderSubComp: (rowData) => { | ||
if (/wsj/.test(rowData.email)) return false; | ||
return <Table {...renderSubProps} passedData={rowData} parentHasCheckbox={true}/> | ||
}, | ||
rowSelection: rowSelection | ||
}, | ||
renderSubProps={ | ||
jsxcolumns:columns, | ||
fetchUrl:"http://localhost:3000/demo/data.json", | ||
queryKeys:["dataKey","firstName"], | ||
onModifyRow: this.onModifyRow | ||
}; | ||
### 其他 | ||
<Table {...renderProps} /> | ||
* toggleSubComp(rowData): 使指定的行显示或隐藏二级组件(subComp)。 | ||
``` | ||
## Props | ||
@@ -332,24 +306,13 @@ | ||
## API | ||
### 对于多行的支持 | ||
### 行内编辑用 | ||
> 正常情况下,Table 中每个单元格按照一行缩略的方式展示,根据业务需要,有时可能需要展示多行,对此,Table 通过 prop `addRowClassName` 配合专属类名 `multiline` 来实现。示例如下: | ||
* getData(): 返回表格的数据,并作校验。 | ||
* addEmptyRow(): 添加一个空的新行。 | ||
* addRow(rowData): 以指定数据添加一个新行。 | ||
* delRow(rowData): 删除一个新行。 | ||
* editRow(rowData): 使指定的行切换到编辑模式。 | ||
* editAllRow(): 使所有行切换到编辑模式。 | ||
* viewRow(rowData): 使指定的行切换到查看模式。 | ||
* saveRow(rowData): 保存行的数据(同时切换至查看模式)。 | ||
* saveAllRow(): 保存所有行的数据(同时切换至查看模式)。 | ||
* resetRow(rowData): 重置行到数据(若保存过,则为保存过后的数据)。 | ||
``` | ||
addRowClassName: function(rowData) { | ||
return 'multiline'; | ||
} | ||
``` | ||
### 获取数据 | ||
> 需要注意:当配置为 multiline 时,用户需自己处理上下间距的问题,处理的方式应为在 multiline 或其他专属类名作用域下进行设置,避免影响其他非 multiline 设置的行。 | ||
* fetchData(from): 使表格重新请求一次数据。 | ||
* @param from {string} {optional}: 这个参数会传入到 beforeFetch 的回调中。 | ||
### 其他 | ||
* toggleSubComp(rowData): 使指定的行显示或隐藏二级组件(subComp)。 |
@@ -35,4 +35,3 @@ /** | ||
return <div {...itemProps}>{item.render(item.title)}</div> | ||
} | ||
else { | ||
} else { | ||
return <Button type="secondary" size="medium" {...itemProps}>{item.title}</Button> | ||
@@ -47,3 +46,3 @@ } | ||
onSearch: me.handleSearch.bind(me), | ||
key:'searchbar', | ||
key: 'searchbar', | ||
placeholder: me.props.searchBarPlaceholder | ||
@@ -62,6 +61,5 @@ }; | ||
items = config; | ||
} | ||
else if (typeof config == "object") { | ||
} else if (typeof config == "object") { | ||
for (let item in config) { | ||
if(config.hasOwnProperty(item)) { | ||
if (config.hasOwnProperty(item)) { | ||
items.push({ | ||
@@ -73,3 +71,3 @@ title: item, | ||
} | ||
} | ||
@@ -81,3 +79,3 @@ return items; | ||
let me = this, | ||
_props = this.props, | ||
_props = this.props, | ||
_barConfig = _props.actionBarConfig; | ||
@@ -91,4 +89,4 @@ | ||
{me.getActionItem(_barConfig).map((item, index) => { | ||
return me.renderActionBtn(item, index) | ||
})} | ||
return me.renderActionBtn(item, index) | ||
})} | ||
{me.renderSearchBar()} | ||
@@ -99,5 +97,6 @@ </div> | ||
}; | ||
} | ||
; | ||
ActionBar.propTypes= { | ||
ActionBar.propTypes = { | ||
}; | ||
@@ -104,0 +103,0 @@ |
@@ -17,3 +17,2 @@ | ||
componentDidMount() { | ||
@@ -20,0 +19,0 @@ let me = this; |
/** | ||
* Created by xy on 15/4/13. | ||
*/ | ||
let React = require('react'); | ||
let ReactDOM = require('react-dom'); | ||
let Const = require('uxcore-const'); | ||
let Dropdown = require('uxcore-dropdown'); | ||
let Menu = require('uxcore-menu'); | ||
let CheckBox = require('./CheckBox'); | ||
@@ -27,4 +30,4 @@ let Radio = require('./Radio'); | ||
super(props); | ||
this.state= { | ||
'fold':1, // 1- fold 0-unfold | ||
this.state = { | ||
'fold': 1, // 1- fold 0-unfold | ||
'checked': !!this.getCellData() | ||
@@ -39,3 +42,3 @@ }; | ||
checked: !!me.getCellData(nextProps) | ||
}) | ||
}) | ||
} | ||
@@ -56,3 +59,3 @@ } | ||
v = _props.rowData; | ||
me.props.changeSelected(e.target.checked, _props.rowIndex, false); | ||
me.props.changeSelected(e.target.checked, _props.rowIndex, false); | ||
} | ||
@@ -64,16 +67,6 @@ | ||
renderTreeIcon() { | ||
if (this.props.cellIndex == 0 && this.props.hasSubComp) { | ||
let open = this.props.rowData.showSubComp; | ||
return <span className="kuma-uxtable-tree-icon" onClick={this.showSubComp.bind(this)}><i className={classnames({ | ||
"kuma-icon": true, | ||
"kuma-icon-tree-open-2": open, | ||
"kuma-icon-tree-close-2": !open | ||
})}></i></span> | ||
} | ||
} | ||
/** | ||
* @param actions {Array or Object} | ||
*/ | ||
/** | ||
* @param actions {Array or Object} | ||
*/ | ||
getActionItems(actions) { | ||
@@ -83,4 +76,3 @@ if (typeof actions !== "object") { | ||
return []; | ||
} | ||
else { | ||
} else { | ||
let me = this; | ||
@@ -90,4 +82,3 @@ me.items = []; | ||
me.items = actions; | ||
} | ||
else { | ||
} else { | ||
for (let i in actions) { | ||
@@ -123,9 +114,14 @@ if (actions.hasOwnProperty(i)) { | ||
handleActionClick(cb, e) { | ||
e.stopPropagation(); | ||
cb && cb(); | ||
} | ||
render() { | ||
let me = this, | ||
props = me.props, | ||
_column = props.column, | ||
_column = props.column, | ||
_width = _column.width, | ||
_mode = props.rowData['__mode__'], | ||
_mode = props.rowData['__mode__'], | ||
_style = { | ||
@@ -139,27 +135,6 @@ width: _width ? _width : 100, | ||
if (_column.type == 'action') { | ||
let showActionIndex = 0; | ||
_v = <div className="action-container"> | ||
{ | ||
me.getActionItems(_column.actions).map(function(item, index) { | ||
// There are two cases in which Table will render the action. | ||
// One is that 'mode' is not defined in action, which means it will be rendered in any mode. | ||
// The other is that 'mode' is defined & 'mode' is equal to the Cell mode, | ||
// which means this action is rendered in the user-specified mode. | ||
if (!('mode' in item) || item.mode == _mode) { | ||
let arr = []; | ||
if (showActionIndex !== 0) { | ||
arr.push(<span key="split" className="split"> | </span>) | ||
} | ||
showActionIndex++; | ||
arr.push(<a href="javascript:void(0);" className="action" key='action' onClick={item.callback.bind(me, _v, me.props.root)}>{!!item.render ? item.render(item.title, me.props.rowData) : item.title}</a>) | ||
return <span key={index}>{arr}</span> | ||
} | ||
}) | ||
} | ||
{me.renderActionItems(_column, _v, _mode)} | ||
</div> | ||
} | ||
else if (_column.type == 'checkbox' || _column.type == 'checkboxSelector') { | ||
} else if (_column.type == 'checkbox' || _column.type == 'checkboxSelector') { | ||
@@ -171,5 +146,5 @@ _style.paddingRight = 18; | ||
if (me.state.checked) { | ||
checked='checked' | ||
checked = 'checked' | ||
} else { | ||
checked=""; | ||
checked = ""; | ||
} | ||
@@ -180,4 +155,3 @@ | ||
disable = _column.disable; | ||
} | ||
else if ('isDisable' in _column) { | ||
} else if ('isDisable' in _column) { | ||
disable = !!_column.isDisable(props.rowData); | ||
@@ -187,4 +161,3 @@ } | ||
} | ||
else if (_column.type == 'radioSelector') { | ||
} else if (_column.type == 'radioSelector') { | ||
_style.paddingRight = 18; | ||
@@ -195,5 +168,5 @@ _style.paddingLeft = 12; | ||
if (me.state.checked) { | ||
checked='checked' | ||
checked = 'checked' | ||
} else { | ||
checked=""; | ||
checked = ""; | ||
} | ||
@@ -204,9 +177,7 @@ | ||
disable = _column.disable; | ||
} | ||
else if ('isDisable' in _column) { | ||
} else if ('isDisable' in _column) { | ||
disable = !!_column.isDisable(props.rowData); | ||
} | ||
_v = <Radio disable={disable} mode={props.mode} align={props.align} jsxchecked={checked} onchange={me.handleCheckChange.bind(me)}/> | ||
} | ||
else if (_column.type == 'treeIcon') { | ||
} else if (_column.type == 'treeIcon') { | ||
_v = me.renderTreeIcon(); | ||
@@ -216,3 +187,2 @@ } | ||
// inline edit mode | ||
else if ((_column.type == 'custom' || _column.type in fieldsMap) && _mode == Const.MODE.EDIT && (!('canEdit' in _column) || _column.canEdit(props.rowData))) { | ||
@@ -232,19 +202,15 @@ renderProps = { | ||
Field = props.column.customField; | ||
} | ||
else { | ||
} else { | ||
Field = fieldsMap[_column.type]; | ||
} | ||
_v = <Field {...renderProps} /> | ||
} | ||
else if (_column.type == 'money' || _column.type == "card" || _column.type == "cnmobile") { | ||
} else if (_column.type == 'money' || _column.type == "card" || _column.type == "cnmobile") { | ||
_v = <div title={me.getCellData()}>{util.formatValue(me.getCellData(), _column.type, _column.delimiter)}</div>; | ||
} | ||
else if (_column.render) { | ||
_v = _column.render.apply(null,[me.getCellData(),_v]); | ||
} | ||
else { | ||
} else if (_column.render) { | ||
_v = _column.render.apply(null, [me.getCellData(), _v]); | ||
} else { | ||
_v = <div title={me.getCellData()}>{me.getCellData()}</div>; | ||
} | ||
let child=me.props.children; | ||
let child = me.props.children; | ||
return ( | ||
@@ -255,7 +221,58 @@ <div className={props.jsxprefixCls} style={_style}> | ||
</div> | ||
); | ||
); | ||
} | ||
}; | ||
Cell.propTypes= { | ||
/** | ||
* @param {Object} column current column config | ||
* @param {Object} rowData current row data | ||
* @param {String} mode current row mode: edit or view, same as rowData['__mode__'] | ||
*/ | ||
renderActionItems(column, rowData, mode) { | ||
let me = this; | ||
let actions = me.getActionItems(column.actions).filter((item) => { | ||
return !('mode' in item) || item.mode == mode; | ||
}); | ||
if (actions.length <= 2) { | ||
return actions.map((item, index) => { | ||
return <a href="javascript:void(0);" key={index} className="action" onClick={me.handleActionClick.bind(me, item.callback.bind(me, rowData, me.props.root))}> | ||
{!!item.render ? item.render(item.title, me.props.rowData) : item.title} | ||
</a> | ||
}) | ||
} else { | ||
let arr = []; | ||
arr.push(<a href="javascript:void(0);" className="action" key='action' onClick={me.handleActionClick.bind(me, actions[0].callback.bind(me, rowData, me.props.root))}> | ||
{!!actions[0].render ? actions[0].render(actions[0].title, me.props.rowData) : actions[0].title} | ||
</a>); | ||
let menu = <Menu> | ||
{actions.slice(1).map((action, index) => { | ||
return <Menu.Item key={index}> | ||
<a href="javascript:void(0);" className="action" key='action' onClick={me.handleActionClick.bind(me, action.callback.bind(me, rowData, me.props.root))}> | ||
{!!action.render ? action.render(action.title, me.props.rowData) : action.title} | ||
</a> | ||
</Menu.Item> | ||
})} | ||
</Menu>; | ||
arr.push( | ||
<i className="kuma-icon kuma-icon-triangle-down" key="icon"></i> | ||
) | ||
return <Dropdown key="icon" overlay={menu} trigger={["click"]}><span>{arr}</span></Dropdown>; | ||
} | ||
} | ||
renderTreeIcon() { | ||
if (this.props.cellIndex == 0 && this.props.hasSubComp) { | ||
let open = this.props.rowData.showSubComp; | ||
return <span className="kuma-uxtable-tree-icon" onClick={this.showSubComp.bind(this)}><i className={classnames({ | ||
"kuma-icon": true, | ||
"kuma-icon-tree-open": open, | ||
"kuma-icon-tree-close": !open | ||
})}></i></span> | ||
} | ||
} | ||
} | ||
; | ||
Cell.propTypes = { | ||
}; | ||
@@ -262,0 +279,0 @@ |
let Formatter = require('uxcore-formatter'); | ||
var util = { | ||
let util = { | ||
formatValue: (value, type, delimiter) => { | ||
@@ -5,0 +5,0 @@ delimiter = delimiter || " "; |
@@ -8,2 +8,3 @@ /** | ||
let Tree = require('uxcore-tree'); | ||
let Popover = require('uxcore-popover'); | ||
let classnames = require('classnames'); | ||
@@ -20,4 +21,4 @@ let {TreeNode} = Tree; | ||
super(props); | ||
this.state= { | ||
pickerDisplay:'none' | ||
this.state = { | ||
pickerDisplay: 'none' | ||
}; | ||
@@ -32,3 +33,3 @@ } | ||
componentWillUnmount () { | ||
componentWillUnmount() { | ||
let me = this; | ||
@@ -47,7 +48,7 @@ $(document).off('click.uxcore-grid-header', me.handleGlobalClick); | ||
if($(target).parents('.kuma-column-picker-container').length == 0 && !$(target).hasClass("kuma-column-picker-container")) { | ||
if ($(target).parents('.kuma-column-picker-container').length == 0 && !$(target).hasClass("kuma-column-picker-container")) { | ||
this.setState({ | ||
pickerDisplay:'none' | ||
pickerDisplay: 'none' | ||
}); | ||
} | ||
} | ||
} | ||
@@ -57,3 +58,3 @@ | ||
let v = this.refs.checkbox.getValue(); | ||
this.props.checkAll.apply(null,[v]); | ||
this.props.checkAll.apply(null, [v]); | ||
} | ||
@@ -64,16 +65,10 @@ | ||
e.stopPropagation(); | ||
if (this.state.pickerDisplay=='block') { | ||
this.setState({ | ||
pickerDisplay:'none' | ||
}); | ||
} | ||
else { | ||
this.setState({ | ||
pickerDisplay:'block' | ||
}); | ||
} | ||
this.setState({ | ||
pickerDisplay: this.state.pickerDisplay == 'block' ? 'none' : 'block' | ||
}); | ||
} | ||
handlePickerCheck(info) { | ||
this.props.handleColumnPickerChange(info.checkedKeys) | ||
handlePickerCheck(checkedKeys) { | ||
this.props.handleColumnPickerChange(checkedKeys) | ||
} | ||
@@ -89,4 +84,3 @@ | ||
_columns = _columns.concat(item.columns); | ||
} | ||
else { | ||
} else { | ||
_columns.push(item); | ||
@@ -118,16 +112,15 @@ } | ||
{columns.map((item, index) => { | ||
if (notRenderColumns.indexOf(item.dataKey) !== -1) return; | ||
if ('group' in item) { | ||
return <TreeNode key={item.group} title={item.group}> | ||
if (notRenderColumns.indexOf(item.dataKey) !== -1) return; | ||
if ('group' in item) { | ||
return <TreeNode key={item.group} title={item.group}> | ||
{item.columns.map((column, idx) => { | ||
return <TreeNode key={column.dataKey} title={column.title}></TreeNode> | ||
})} | ||
return <TreeNode key={column.dataKey} title={column.title}></TreeNode> | ||
})} | ||
</TreeNode> | ||
} | ||
else { | ||
return <TreeNode key={item.dataKey} title={item.title}></TreeNode> | ||
} | ||
}).filter((item, index) => { | ||
return item != undefined | ||
})} | ||
} else { | ||
return <TreeNode key={item.dataKey} title={item.title}></TreeNode> | ||
} | ||
}).filter((item, index) => { | ||
return item != undefined | ||
})} | ||
</Tree> | ||
@@ -149,3 +142,3 @@ ) | ||
<i className="kuma-icon kuma-icon-target-list kuma-column-picker" onClick={this.handleColumnPicker.bind(this)}></i> | ||
<div className="kuma-uxtable-colmnpicker" style={_style} ref="columnpicker"> | ||
<div className="kuma-uxtable-columnpicker" style={_style} ref="columnpicker"> | ||
{me.renderColumnTree()} | ||
@@ -157,25 +150,34 @@ </div> | ||
handleColumnOrder(type, column) { | ||
column.orderType = type; | ||
this.props.orderColumnCB.apply(null, [type, column]); | ||
handleColumnOrder(column) { | ||
let me = this; | ||
let {orderColumnCB, activeColumn, orderType} = me.props; | ||
let type = 'desc'; | ||
let typeMap = { | ||
desc: 'asc', | ||
asc: 'none', | ||
none: 'desc' | ||
}; | ||
if (activeColumn && column.dataKey == activeColumn.dataKey && orderType) { | ||
type = typeMap[orderType]; | ||
} | ||
orderColumnCB && orderColumnCB(type, column); | ||
} | ||
renderOrderIcon(column) { | ||
let me = this; | ||
let {orderType, activeColumn} = me.props; | ||
if (column.ordered) { | ||
let desc = "sort-down", | ||
asc="sort-up"; | ||
if (me.props.activeColumn && column.dataKey == me.props.activeColumn.dataKey) { | ||
if (column.orderType == "desc") { | ||
desc ="sort-down-active"; | ||
} | ||
else { | ||
asc ="sort-up-active"; | ||
} | ||
} | ||
let desc = "iconfontdown", | ||
asc = "iconfontup"; | ||
return ( | ||
<span className="kuma-uxtable-h-sort"> | ||
<i className={asc} onClick={me.handleColumnOrder.bind(me,'asc', column)}/> | ||
<i className={desc} onClick={me.handleColumnOrder.bind(me,'desc',column)}/> | ||
<span className="kuma-uxtable-h-sort" onClick={me.handleColumnOrder.bind(me, column)}> | ||
<i className={classnames({ | ||
[`kuma-icon kuma-icon-${asc}`]: true, | ||
'active': activeColumn && activeColumn.dataKey === column.dataKey && orderType == 'asc' | ||
})} /> | ||
<i className={classnames({ | ||
[`kuma-icon kuma-icon-${desc}`]: true, | ||
'active': activeColumn && activeColumn.dataKey === column.dataKey && orderType == 'desc' | ||
})}/> | ||
</span> | ||
@@ -186,2 +188,9 @@ ) | ||
renderMessageIcon(column) { | ||
if (!column.message) return; | ||
return <Popover overlay={<div className="kuma-uxtable-column-message">{column.message}</div>}> | ||
<i className="kuma-icon kuma-icon-information"></i> | ||
</Popover> | ||
} | ||
renderColumn(item, index, hasGroup, last) { | ||
@@ -200,4 +209,4 @@ | ||
assign(_style, { | ||
height: 80, | ||
lineHeight: 80 + 'px' | ||
height: 100, | ||
lineHeight: 100 + 'px' | ||
}) | ||
@@ -220,5 +229,4 @@ } | ||
_v = <CheckBox {...checkBoxProps} /> | ||
} | ||
else { | ||
_v = <CheckBox {...checkBoxProps} /> | ||
} else { | ||
_v = <span title={item.title}>{item.title}</span>; | ||
@@ -229,3 +237,3 @@ } | ||
assign(_style, { | ||
borderRight: 'none' | ||
borderRight: 'none' | ||
}) | ||
@@ -236,6 +244,7 @@ } | ||
<div key={index} className={classnames({ | ||
"kuma-uxtable-cell": true, | ||
"show-border": me.props.showHeaderBorder | ||
"kuma-uxtable-cell": true, | ||
"show-border": me.props.showHeaderBorder | ||
})} style={_style}> | ||
{_v} | ||
{me.renderMessageIcon(item)} | ||
{me.renderOrderIcon(item)} | ||
@@ -246,5 +255,5 @@ </div> | ||
renderItems(_columns) { | ||
renderColumns(_columns) { | ||
let me = this; | ||
let columns = _columns.map((item, index) => { | ||
@@ -266,4 +275,3 @@ let last = (index == _columns.length - 1); | ||
} | ||
} | ||
else { | ||
} else { | ||
return me.renderColumn(item, index, me.hasGroup, last) | ||
@@ -277,3 +285,3 @@ } | ||
let props = this.props, | ||
let props = this.props, | ||
me = this, | ||
@@ -287,14 +295,14 @@ _picker, | ||
if (props.columnPicker && (props.fixedColumn == 'no' || props.fixedColumn == 'scroll')) { | ||
_picker = this.renderPicker(); | ||
_picker = this.renderPicker(); | ||
} | ||
if (props.fixedColumn == 'fixed') { | ||
_columns= props.columns.filter((item)=>{ | ||
if (item.fixed && !item.hidden) { | ||
if (!item.width) { | ||
item.width = 100; | ||
} | ||
_width = item.width * 1 + _width; | ||
return true | ||
} | ||
_columns = props.columns.filter((item) => { | ||
if (item.fixed && !item.hidden) { | ||
if (!item.width) { | ||
item.width = 100; | ||
} | ||
_width = item.width * 1 + _width; | ||
return true | ||
} | ||
}) | ||
@@ -306,22 +314,19 @@ assign(_headerStyle, { | ||
headerWrapClassName = "kuma-uxtable-header-fixed"; | ||
} | ||
else if (props.fixedColumn == 'scroll') { | ||
_columns = props.columns.filter( (item) => { | ||
if(!item.fixed) { | ||
return true | ||
} else if (props.fixedColumn == 'scroll') { | ||
_columns = props.columns.filter((item) => { | ||
if (!item.fixed) { | ||
return true | ||
} else if (!item.hidden) { | ||
if (!item.width) { | ||
item.width = 100; | ||
} | ||
_width = item.width * 1 + _width; | ||
} | ||
else if (!item.hidden) { | ||
if (!item.width) { | ||
item.width = 100; | ||
} | ||
_width = item.width*1 + _width; | ||
} | ||
}); | ||
assign(_headerStyle, { | ||
width: props.width - _width - 3, | ||
minWidth:props.width - _width - 3 | ||
minWidth: props.width - _width - 3 | ||
}); | ||
headerWrapClassName="kuma-uxtable-header-scroll"; | ||
} | ||
else { | ||
headerWrapClassName = "kuma-uxtable-header-scroll"; | ||
} else { | ||
_columns = props.columns; | ||
@@ -340,5 +345,5 @@ headerWrapClassName = "kuma-uxtable-header-no"; | ||
assign(_headerStyle, { | ||
height: props.headerHeight ? props.headerHeight : (me.hasGroup ? 80 : 40), | ||
lineHeight: (props.headerHeight ? props.headerHeight : 40) + "px" | ||
assign(_headerStyle, { | ||
height: props.headerHeight ? props.headerHeight : (me.hasGroup ? 80 : 50), | ||
lineHeight: (props.headerHeight ? props.headerHeight : 50) + "px" | ||
}); | ||
@@ -350,12 +355,13 @@ | ||
<div className={props.jsxprefixCls} > | ||
{me.renderItems(_columns)} | ||
{me.renderColumns(_columns)} | ||
{_picker} | ||
</div> | ||
</div> | ||
); | ||
); | ||
} | ||
}; | ||
} | ||
; | ||
Header.propTypes= { | ||
Header.propTypes = { | ||
}; | ||
@@ -362,0 +368,0 @@ |
@@ -18,4 +18,6 @@ /** | ||
render() { | ||
let props= this.props,visible=props.visible,loadTips= props.tips?props.tips:"Loading..."; | ||
let props = this.props, | ||
visible = props.visible, | ||
loadTips = props.tips ? props.tips : "Loading..."; | ||
let _className = classnames({ | ||
@@ -30,5 +32,6 @@ [props.jsxprefixCls]: true, | ||
}; | ||
} | ||
; | ||
Mask.propTypes= { | ||
Mask.propTypes = { | ||
}; | ||
@@ -35,0 +38,0 @@ |
@@ -18,4 +18,4 @@ /** | ||
super(props); | ||
this.state = { | ||
expanded: (this.props.level < this.props.levels) ? true : false | ||
this.state = { | ||
expanded: (this.props.level < this.props.levels) ? true : false | ||
} | ||
@@ -62,3 +62,3 @@ } | ||
me.props.root.toggleSubComp(me.props.rowData); | ||
} | ||
} | ||
@@ -70,7 +70,6 @@ renderSubComp() { | ||
return false; | ||
} | ||
else { | ||
} else { | ||
if (props.subComp) { | ||
if (props.rowData.showSubComp) { | ||
let subComp = React.cloneElement(props.subComp,{ | ||
let subComp = React.cloneElement(props.subComp, { | ||
passedData: this.props.rowData, | ||
@@ -83,4 +82,3 @@ parentHasCheckbox: !!this.props.rowSelection, | ||
return false; | ||
} | ||
else if (props.renderSubComp) { | ||
} else if (props.renderSubComp) { | ||
let subComp = props.renderSubComp(deepcopy(props.rowData)); | ||
@@ -91,4 +89,3 @@ if (subComp && props.rowData.showSubComp) { | ||
return false; | ||
} | ||
else { | ||
} else { | ||
return false; | ||
@@ -105,8 +102,8 @@ } | ||
if (props.renderModel!=='tree') { | ||
if (props.renderModel !== 'tree') { | ||
return children; | ||
} | ||
if (props.rowData.datas) { | ||
props.rowData.datas.forEach(function (node) { | ||
let renderProps= assign({}, props, { | ||
props.rowData.datas.forEach(function(node) { | ||
let renderProps = assign({}, props, { | ||
level: me.props.level + 1, | ||
@@ -122,5 +119,5 @@ rowData: node, | ||
let renderProps={ | ||
key: "treeRow"+this.props.rowData.jsxid, | ||
className:"kuma-uxtable-tree-row" | ||
let renderProps = { | ||
key: "treeRow" + this.props.rowData.jsxid, | ||
className: "kuma-uxtable-tree-row" | ||
} | ||
@@ -136,3 +133,4 @@ | ||
let expandCollapseIcon,props = this.props, | ||
let expandCollapseIcon, | ||
props = this.props, | ||
_expandIconClass; | ||
@@ -147,28 +145,27 @@ | ||
_expandIconClass={ | ||
"kuma-icon": true, | ||
"kuma-icon-tree-open-2": false, | ||
"kuma-icon-tree-close-2": true | ||
_expandIconClass = { | ||
"kuma-icon": true, | ||
"kuma-icon-tree-open-2": false, | ||
"kuma-icon-tree-close-2": true | ||
}; | ||
_expandIconClass["kuma-uxtable-expandIcon-"+props.fixedColumn+"-"+rowIndex]=true; | ||
_expandIconClass["kuma-uxtable-expandIcon-" + props.fixedColumn + "-" + rowIndex] = true; | ||
expandCollapseIcon = ( | ||
<span className="kuma-uxtable-tree-icon" data-type={props.fixedColumn} data-index={rowIndex} | ||
onClick={this.toggleExpanded.bind(this)}> | ||
<span className="kuma-uxtable-tree-icon" data-type={props.fixedColumn} data-index={rowIndex} | ||
onClick={this.toggleExpanded.bind(this)}> | ||
<i className={classnames(_expandIconClass)}></i> | ||
</span> | ||
); | ||
} | ||
else { | ||
} else { | ||
_expandIconClass={ | ||
"kuma-icon": true, | ||
"kuma-icon-tree-open-2": true, | ||
"kuma-icon-tree-close-2": false | ||
_expandIconClass = { | ||
"kuma-icon": true, | ||
"kuma-icon-tree-open-2": true, | ||
"kuma-icon-tree-close-2": false | ||
}; | ||
_expandIconClass["kuma-uxtable-expandIcon-"+props.fixedColumn+"-"+rowIndex]=true; | ||
_expandIconClass["kuma-uxtable-expandIcon-" + props.fixedColumn + "-" + rowIndex] = true; | ||
expandCollapseIcon = ( | ||
<span className="kuma-uxtable-tree-icon" data-type={props.fixedColumn} data-index={rowIndex} | ||
onClick={this.toggleExpanded.bind(this)}> | ||
<span className="kuma-uxtable-tree-icon" data-type={props.fixedColumn} data-index={rowIndex} | ||
onClick={this.toggleExpanded.bind(this)}> | ||
<i className={classnames(_expandIconClass)}></i> | ||
@@ -178,4 +175,3 @@ </span> | ||
} | ||
} | ||
else { | ||
} else { | ||
expandCollapseIcon = ( | ||
@@ -190,7 +186,7 @@ <span className="kuma-uxtable-emptyicon"></span> | ||
let indents = []; | ||
if(this.props.renderModel=='tree') { | ||
for (var i = 0; i < this.props.level-1; i++) { | ||
let renderProps={ | ||
className:"indent", | ||
key: 'indent'+i | ||
if (this.props.renderModel == 'tree') { | ||
for (var i = 0; i < this.props.level - 1; i++) { | ||
let renderProps = { | ||
className: "indent", | ||
key: 'indent' + i | ||
} | ||
@@ -200,3 +196,3 @@ indents.push(<span {...renderProps} ></span>); | ||
} | ||
return indents; | ||
@@ -206,13 +202,14 @@ } | ||
toggleExpanded(e) { | ||
this.setState({ expanded: !this.state.expanded }); | ||
this.setState({ | ||
expanded: !this.state.expanded | ||
}); | ||
e.stopPropagation(); | ||
let t = $(e.target); | ||
if (!t.hasClass('kuma-uxtable-tree-icon')) { | ||
t= t.parents('.kuma-uxtable-tree-icon'); | ||
t = t.parents('.kuma-uxtable-tree-icon'); | ||
} | ||
if (t.data('type')=='fixed') { | ||
$(".kuma-uxtable-expandIcon-scroll"+"-"+t.data('index')).trigger('click'); | ||
} | ||
else if (t.data('type')=='scroll') { | ||
$(".kuma-uxtable-expandIcon-fixed"+"-"+t.data('index')).trigger('click'); | ||
if (t.data('type') == 'fixed') { | ||
$(".kuma-uxtable-expandIcon-scroll" + "-" + t.data('index')).trigger('click'); | ||
} else if (t.data('type') == 'scroll') { | ||
$(".kuma-uxtable-expandIcon-fixed" + "-" + t.data('index')).trigger('click'); | ||
} | ||
@@ -232,3 +229,3 @@ } | ||
_style = { | ||
display: 'none' | ||
display: 'none' | ||
}; | ||
@@ -240,4 +237,3 @@ } | ||
_columns = _columns.concat(column.columns); | ||
} | ||
else { | ||
} else { | ||
_columns.push(column); | ||
@@ -247,51 +243,55 @@ } | ||
let firstVisableColumn=0; | ||
let firstVisableColumn = 0; | ||
return ( | ||
<li className={classnames({ | ||
[this.props.jsxprefixCls]: true, | ||
[otherCls]: !!otherCls | ||
})} style={_style} | ||
onClick={this.handleClick.bind(this, props.rowData)} | ||
onDoubleClick={this.handleDoubleClick.bind(this, props.rowData)}> | ||
{_columns.map(function(item,index){ | ||
if (item.hidden) return; | ||
firstVisableColumn++; | ||
let renderProps={ | ||
column: item, | ||
root: props.root, | ||
align: item.align, | ||
rowData: props.rowData, | ||
rowIndex: props.rowIndex, | ||
index: props.index, | ||
cellIndex:index, | ||
hasSubComp: props.subComp ? true : (props.renderSubComp ? props.renderSubComp(deepcopy(props.rowData)) : false), | ||
data: _data, | ||
changeSelected: me.props.changeSelected, | ||
showSubCompCallback: me.showSubCompFunc.bind(me), | ||
rowSelection: props.rowSelection, | ||
actions: props.actions, | ||
mode: props.mode, | ||
handleDataChange: props.handleDataChange, | ||
attachCellField: props.attachCellField, | ||
detachCellField: props.detachCellField, | ||
key: "cell" + index | ||
}; | ||
[this.props.prefixCls]: true, | ||
[otherCls]: !!otherCls, | ||
'even': (props.rowIndex % 2 == 1 ? true : false) | ||
})} style={_style} | ||
onClick={this.handleClick.bind(this, props.rowData)} | ||
onDoubleClick={this.handleDoubleClick.bind(this, props.rowData)}> | ||
<div className={`${this.props.prefixCls}-cells`}> | ||
{_columns.map(function(item, index) { | ||
if (item.hidden) return; | ||
firstVisableColumn++; | ||
let renderProps = { | ||
column: item, | ||
root: props.root, | ||
align: item.align, | ||
rowData: props.rowData, | ||
rowIndex: props.rowIndex, | ||
index: props.index, | ||
cellIndex: index, | ||
hasSubComp: props.subComp ? true : (props.renderSubComp ? props.renderSubComp(deepcopy(props.rowData)) : false), | ||
data: _data, | ||
changeSelected: me.props.changeSelected, | ||
showSubCompCallback: me.showSubCompFunc.bind(me), | ||
rowSelection: props.rowSelection, | ||
actions: props.actions, | ||
mode: props.mode, | ||
handleDataChange: props.handleDataChange, | ||
attachCellField: props.attachCellField, | ||
detachCellField: props.detachCellField, | ||
key: "cell" + index | ||
}; | ||
if (firstVisableColumn == 1) { | ||
return <Cell {...renderProps} >{me.renderIndent()}{me.renderExpendIcon(props.rowIndex)}</Cell> | ||
} | ||
//if have vertical data structure, how to process it | ||
return <Cell {...renderProps} ></Cell> | ||
})} | ||
if (firstVisableColumn == 1) { | ||
return <Cell {...renderProps} >{me.renderIndent()}{me.renderExpendIcon(props.rowIndex)}</Cell> | ||
} | ||
//if have vertical data structure, how to process it | ||
return <Cell {...renderProps} ></Cell> | ||
})} | ||
</div> | ||
{me.renderChild()} | ||
{this.renderSubComp()} | ||
</li> | ||
); | ||
); | ||
} | ||
}; | ||
} | ||
; | ||
Row.propTypes= { | ||
jsxprefixCls: React.PropTypes.string, | ||
Row.propTypes = { | ||
prefixCls: React.PropTypes.string, | ||
showSubComp: React.PropTypes.bool | ||
@@ -301,3 +301,3 @@ }; | ||
Row.defaultProps = { | ||
jsxprefixCls: "kuma-uxtable-row", | ||
prefixCls: "kuma-uxtable-row", | ||
showSubComp: false | ||
@@ -304,0 +304,0 @@ }; |
@@ -45,15 +45,17 @@ /** | ||
</div> | ||
); | ||
); | ||
} | ||
}; | ||
} | ||
; | ||
SearchBar.propTypes= {}; | ||
SearchBar.propTypes = {}; | ||
SearchBar.defaultProps = { | ||
jsxprefixCls: "kuma-uxtable-searchbar", | ||
onSearch: () => {} | ||
onSearch: () => { | ||
} | ||
}; | ||
module.exports = SearchBar; |
@@ -10,6 +10,6 @@ /** | ||
let Header = require("./Header"); | ||
let Tbody = require("./Tbody"); | ||
let Tbody = require("./Tbody"); | ||
let ActionBar = require("./ActionBar"); | ||
let CellField = require('./Cell/CellField'); | ||
let Pagination = require("uxcore-pagination"); | ||
let Pagination = require("uxcore-pagination"); | ||
let Const = require('uxcore-const'); | ||
@@ -75,3 +75,3 @@ let assign = require('object-assign'); | ||
if (nextProps.currentPage != me.props.currentPage) { | ||
newData['currentPage'] = nextProps.currentPage; | ||
newData['currentPage'] = nextProps.currentPage; | ||
} | ||
@@ -130,11 +130,10 @@ if (!!nextProps.jsxcolumns && !!me.props.jsxcolumns && !me._isEqual(nextProps.jsxcolumns, me.props.jsxcolumns)) { | ||
attachCellField(validate, name) { | ||
attachCellField(validate, name) { | ||
let me = this; | ||
if (!name) { | ||
console.error("Table: name can not be empty, check the dataKey of the column config"); | ||
} | ||
else { | ||
} else { | ||
me.fields[name] = validate; | ||
} | ||
} | ||
} | ||
@@ -146,5 +145,5 @@ /** | ||
detachCellField(name) { | ||
detachCellField(name) { | ||
delete this.fields[name]; | ||
} | ||
} | ||
@@ -170,3 +169,4 @@ | ||
let me = this, queryObj = {}; | ||
let me = this, | ||
queryObj = {}; | ||
if (me.props.passedData) { | ||
@@ -176,7 +176,6 @@ let queryKeys = me.props.queryKeys; | ||
queryObj = me.props.passedData; | ||
} | ||
else { | ||
} else { | ||
queryKeys.forEach(function(key) { | ||
if(me.props.passedData[key] !== undefined) { | ||
queryObj[key]= me.props.passedData[key]; | ||
if (me.props.passedData[key] !== undefined) { | ||
queryObj[key] = me.props.passedData[key]; | ||
} | ||
@@ -195,7 +194,10 @@ }) | ||
let activeColumn = me.state.activeColumn; | ||
if(!!activeColumn) { | ||
let orderType = me.state.orderType; | ||
if (!!activeColumn) { | ||
queryObj = assign({}, queryObj, { | ||
orderColumn: activeColumn.dataKey, | ||
orderType: activeColumn.orderType | ||
}) | ||
orderColumn: activeColumn.dataKey | ||
}); | ||
if (!!orderType && orderType != 'none') { | ||
queryObj.orderType = orderType; | ||
} | ||
} | ||
@@ -207,3 +209,3 @@ | ||
queryObj = assign({}, queryObj, { | ||
searchTxt: searchTxt | ||
searchTxt: searchTxt | ||
}) | ||
@@ -213,3 +215,3 @@ } | ||
// fetchParams has the top priority | ||
if(!!me.props.fetchParams) { | ||
if (!!me.props.fetchParams) { | ||
queryObj = assign({}, queryObj, me.props.fetchParams); | ||
@@ -220,3 +222,3 @@ } | ||
} | ||
/** | ||
@@ -232,4 +234,4 @@ * fetch Data via Ajax | ||
// reset uid cause table data has changed | ||
me.uid = 0; | ||
me.uid = 0; | ||
// fetchUrl has the top priority. | ||
@@ -254,5 +256,5 @@ if (!!me.props.fetchUrl) { | ||
let processedData = me.addValuesInData(me.props.processData(deepcopy(_data))); | ||
let updateObj= { | ||
data: processedData, | ||
showMask: false | ||
let updateObj = { | ||
data: processedData, | ||
showMask: false | ||
}; | ||
@@ -264,4 +266,3 @@ if (processedData.currentPage !== undefined) { | ||
me.setState(updateObj) | ||
} | ||
else { | ||
} else { | ||
me.props.onFetchError(result); | ||
@@ -275,8 +276,6 @@ } | ||
} | ||
me.ajax = $.ajax(ajaxOptions); | ||
} | ||
} else if (!!me.props.passedData) { | ||
else if (!!me.props.passedData) { | ||
if (!me.props.queryKeys) { | ||
@@ -288,4 +287,3 @@ let data = me.addValuesInData(me.props.processData(deepcopy(me.props.passedData))); | ||
me.data = deepcopy(data); | ||
} | ||
else { | ||
} else { | ||
let data = {}; | ||
@@ -303,4 +301,3 @@ me.props.queryKeys.forEach((key, index) => { | ||
} | ||
} | ||
else if (!!this.props.jsxdata) { | ||
} else if (!!this.props.jsxdata) { | ||
let data = this.addValuesInData(deepcopy(this.props.jsxdata)); | ||
@@ -311,4 +308,3 @@ me.setState({ | ||
me.data = deepcopy(data); | ||
} | ||
else { | ||
} else { | ||
//default will create one row | ||
@@ -330,4 +326,4 @@ let data = { | ||
} | ||
processColumn(props) { | ||
@@ -344,5 +340,2 @@ | ||
if (item.type == 'checkbox' || item.type == 'radioSelector' || item.type == 'checkboxSelector') { | ||
if (item.type == 'checkbox') { | ||
console.warn("rowSelector using 'type: checkbox' is deprecated, use 'type: checkboxSelector' instead."); | ||
} | ||
hasCheckboxColumn = true; | ||
@@ -353,3 +346,3 @@ me.checkboxColumn = item; | ||
item.align = item.align || 'right'; | ||
} | ||
} | ||
}); | ||
@@ -365,3 +358,3 @@ | ||
// if hidden is not set, then it's false | ||
columns = columns.map((item,index) => { | ||
columns = columns.map((item, index) => { | ||
item.hidden = !!item.hidden; | ||
@@ -372,3 +365,9 @@ return item; | ||
if (!!props.rowSelection & !hasCheckboxColumn) { | ||
me.checkboxColumn = { dataKey: 'jsxchecked', width: 46, type: props.rowSelector, align:'right'}; | ||
// console.warn("It will be deprecated that a checkbox(radio) in first column without column config, You should specify the column type with 'checkboxSelector' or 'radioSelector'"); | ||
me.checkboxColumn = { | ||
dataKey: 'jsxchecked', | ||
width: 46, | ||
type: props.rowSelector, | ||
align: 'right' | ||
}; | ||
me.checkboxColumnKey = 'jsxchecked'; | ||
@@ -381,3 +380,7 @@ | ||
else if (!!props.parentHasCheckbox) { | ||
columns = [{dataKey: 'jsxwhite', width: 46, type: 'empty'}].concat(columns); | ||
columns = [{ | ||
dataKey: 'jsxwhite', | ||
width: 46, | ||
type: 'empty' | ||
}].concat(columns); | ||
} | ||
@@ -387,3 +390,7 @@ | ||
else if (!!props.parentHasCheck) { | ||
columns = [{dataKey: 'jsxwhite', width: 46, type: 'empty'}].concat(columns); | ||
columns = [{ | ||
dataKey: 'jsxwhite', | ||
width: 46, | ||
type: 'empty' | ||
}].concat(columns); | ||
} | ||
@@ -393,4 +400,8 @@ | ||
if ( (!!props.subComp || !!props.renderSubComp) && props.renderModel !== 'tree') { | ||
columns = [{dataKey: 'jsxtreeIcon', width: 34, type: 'treeIcon'}].concat(columns); | ||
if ((!!props.subComp || !!props.renderSubComp) && props.renderModel !== 'tree') { | ||
columns = [{ | ||
dataKey: 'jsxtreeIcon', | ||
width: 34, | ||
type: 'treeIcon' | ||
}].concat(columns); | ||
} | ||
@@ -400,3 +411,7 @@ // no subComp but has passedData, means sub mode, parent should has tree icon, | ||
else if (!!props.passedData) { | ||
columns = [{dataKey: 'jsxwhite', width: 34,type: 'empty'}].concat(columns); | ||
columns = [{ | ||
dataKey: 'jsxwhite', | ||
width: 34, | ||
type: 'empty' | ||
}].concat(columns); | ||
} | ||
@@ -416,13 +431,10 @@ | ||
ele.hidden = false; | ||
} | ||
else { | ||
} else { | ||
ele.hidden = true; | ||
} | ||
}) | ||
} | ||
else { | ||
} else { | ||
if (checkedKeys.indexOf(item.dataKey) !== -1 || notRenderColumns.indexOf(item.dataKey) !== -1) { | ||
item.hidden = false; | ||
} | ||
else { | ||
} else { | ||
item.hidden = true; | ||
@@ -435,3 +447,3 @@ } | ||
}) | ||
} | ||
@@ -452,3 +464,3 @@ | ||
me.checkboxColumn.type == 'radioSelector' ? _data.map((item,index) => { | ||
me.checkboxColumn.type == 'radioSelector' ? _data.map((item, index) => { | ||
if (item.jsxid == rowIndex) { | ||
@@ -461,3 +473,3 @@ item[me.checkboxColumnKey] = checked; | ||
} | ||
}) : _data.map((item,index) => { | ||
}) : _data.map((item, index) => { | ||
if (item.jsxid == rowIndex) { | ||
@@ -469,3 +481,3 @@ item[me.checkboxColumnKey] = checked; | ||
me.setState({ | ||
@@ -492,13 +504,13 @@ data: _content | ||
let selectedRows = []; | ||
_data = _data.forEach((item,index) => { | ||
_data = _data.forEach((item, index) => { | ||
let column = me.checkboxColumn; | ||
let key = me.checkboxColumnKey; | ||
if (!('isDisable' in column) || !column.isDisable(item)) { | ||
item[key] = checked; | ||
selectedRows.push(item); | ||
item[key] = checked; | ||
selectedRows.push(item); | ||
} | ||
}); | ||
if(!!rowSelection && !!rowSelection.onSelectAll) { | ||
rowSelection.onSelectAll.apply(null,[checked, checked ? selectedRows : []]) | ||
if (!!rowSelection && !!rowSelection.onSelectAll) { | ||
rowSelection.onSelectAll.apply(null, [checked, checked ? selectedRows : []]) | ||
} | ||
@@ -510,3 +522,3 @@ me.setState({ | ||
onPageChange (current) { | ||
onPageChange(current) { | ||
let me = this; | ||
@@ -534,3 +546,3 @@ me.setState({ | ||
let {showPagerTotal, showPager, locale} = me.props; | ||
if (showPager && data && data.totalCount) { | ||
@@ -540,12 +552,12 @@ return ( | ||
<Pagination className="mini" | ||
locale={locale} | ||
showSizeChanger={true} | ||
showTotal={showPagerTotal} | ||
total={data.totalCount} | ||
onShowSizeChange={me.handleShowSizeChange.bind(me)} | ||
onChange={me.onPageChange.bind(me)} | ||
current={currentPage} | ||
pageSize={pageSize} /> | ||
locale={locale} | ||
showSizeChanger={true} | ||
showTotal={showPagerTotal} | ||
total={data.totalCount} | ||
onShowSizeChange={me.handleShowSizeChange.bind(me)} | ||
onChange={me.onPageChange.bind(me)} | ||
current={currentPage} | ||
pageSize={pageSize} /> | ||
</div> | ||
); | ||
); | ||
} | ||
@@ -557,5 +569,6 @@ } | ||
me.setState({ | ||
activeColumn: column | ||
activeColumn: column, | ||
orderType: type | ||
}, () => { | ||
me.fetchData("order"); | ||
me.fetchData("order"); | ||
}) | ||
@@ -593,7 +606,12 @@ | ||
}); | ||
return {data: data, pass: pass}; | ||
return { | ||
data: data, | ||
pass: pass | ||
}; | ||
} else { | ||
return { | ||
data: me.state.data, | ||
pass: pass | ||
} | ||
} | ||
else { | ||
return {data: me.state.data, pass: pass} | ||
} | ||
} | ||
@@ -603,3 +621,3 @@ | ||
let props = this.props; | ||
let _columns = props.jsxcolumns.filter( (item) =>{ | ||
let _columns = props.jsxcolumns.filter((item) => { | ||
if (item.fixed) { | ||
@@ -609,3 +627,3 @@ return true | ||
}) | ||
if(_columns.length > 0) { | ||
if (_columns.length > 0) { | ||
return true; | ||
@@ -617,22 +635,22 @@ } | ||
renderHeader(renderHeaderProps) { | ||
if(!this.props.showHeader) { | ||
return ; | ||
} | ||
if(this.hasFixColumn() ){ | ||
return <div className="kuma-uxtable-header-wrapper"> | ||
if (!this.props.showHeader) { | ||
return; | ||
} | ||
if (this.hasFixColumn()) { | ||
return <div className="kuma-uxtable-header-wrapper"> | ||
<Header {...renderHeaderProps} fixedColumn='fixed' key="grid-header-fixed"/> | ||
<Header {...renderHeaderProps} fixedColumn='scroll' key="grid-header-scroll"/> | ||
</div> | ||
}else { | ||
return <div className="kuma-uxtable-header-wrapper"> | ||
} else { | ||
return <div className="kuma-uxtable-header-wrapper"> | ||
<Header {...renderHeaderProps} fixedColumn="no" /> | ||
</div> | ||
} | ||
} | ||
} | ||
renderTbody(renderBodyProps, bodyHeight) { | ||
if (this.hasFixColumn()) { | ||
if (this.hasFixColumn()) { | ||
let {subComp, ...fixedBodyProps} = renderBodyProps; | ||
@@ -647,10 +665,9 @@ return ( | ||
) | ||
} | ||
else { | ||
return <div className="kuma-uxtable-body-wrapper" style={{ | ||
height: bodyHeight | ||
}}> | ||
} else { | ||
return <div className="kuma-uxtable-body-wrapper" style={{ | ||
height: bodyHeight | ||
}}> | ||
<Tbody {...renderBodyProps} fixedColumn='no'/> | ||
</div> | ||
} | ||
} | ||
} | ||
@@ -685,48 +702,48 @@ | ||
bodyHeight = 'auto'; | ||
} | ||
else { | ||
} else { | ||
bodyHeight = props.height == "100%" ? props.height : (props.height - headerHeight - actionBarHeight - pagerHeight); | ||
} | ||
let renderBodyProps = { | ||
columns: this.state.columns, | ||
data: this.state.data ? this.state.data.datas || this.state.data.data : [], | ||
onModifyRow: props.onModifyRow ? props.onModifyRow : function(){}, | ||
rowSelection: props.rowSelection, | ||
addRowClassName: props.addRowClassName, | ||
subComp: props.subComp, | ||
renderSubComp: props.renderSubComp, | ||
mask: this.state.showMask, | ||
changeSelected: this.changeSelected.bind(this), | ||
rowHeight: this.props.rowHeight, | ||
height: bodyHeight, | ||
width: props.width, | ||
root: this, | ||
mode: props.mode, | ||
renderModel: props.renderModel, | ||
levels: props.levels, | ||
handleDataChange: this.handleDataChange.bind(this), | ||
attachCellField: this.attachCellField.bind(this), | ||
detachCellField: this.detachCellField.bind(this), | ||
key:'grid-body' | ||
}, | ||
renderHeaderProps = { | ||
columns: this.state.columns, | ||
activeColumn: this.state.activeColumn, | ||
checkAll: this.selectAll.bind(this), | ||
columnPicker: props.showColumnPicker, | ||
showHeaderBorder: props.showHeaderBorder, | ||
handleColumnPickerChange: this.handleColumnPickerChange.bind(this), | ||
headerHeight: props.headerHeight, | ||
width: props.width, | ||
mode: props.mode, | ||
orderColumnCB: this.handleOrderColumnCB.bind(this), | ||
key:'grid-header' | ||
columns: this.state.columns, | ||
data: this.state.data ? this.state.data.datas || this.state.data.data : [], | ||
onModifyRow: props.onModifyRow ? props.onModifyRow : function() {}, | ||
rowSelection: props.rowSelection, | ||
addRowClassName: props.addRowClassName, | ||
subComp: props.subComp, | ||
renderSubComp: props.renderSubComp, | ||
mask: this.state.showMask, | ||
changeSelected: this.changeSelected.bind(this), | ||
rowHeight: this.props.rowHeight, | ||
height: bodyHeight, | ||
width: props.width, | ||
root: this, | ||
mode: props.mode, | ||
renderModel: props.renderModel, | ||
levels: props.levels, | ||
handleDataChange: this.handleDataChange.bind(this), | ||
attachCellField: this.attachCellField.bind(this), | ||
detachCellField: this.detachCellField.bind(this), | ||
key: 'grid-body' | ||
}, | ||
renderHeaderProps = { | ||
columns: this.state.columns, | ||
activeColumn: this.state.activeColumn, | ||
orderType: this.state.orderType, | ||
checkAll: this.selectAll.bind(this), | ||
columnPicker: props.showColumnPicker, | ||
showHeaderBorder: props.showHeaderBorder, | ||
handleColumnPickerChange: this.handleColumnPickerChange.bind(this), | ||
headerHeight: props.headerHeight, | ||
width: props.width, | ||
mode: props.mode, | ||
orderColumnCB: this.handleOrderColumnCB.bind(this), | ||
key: 'grid-header' | ||
}; | ||
}; | ||
let actionBar; | ||
if(props.actionBar || props.showSearch) { | ||
let renderActionProps={ | ||
if (props.actionBar || props.showSearch) { | ||
let renderActionProps = { | ||
onSearch: this.handleActionBarSearch.bind(this), | ||
@@ -736,3 +753,3 @@ actionBarConfig: this.props.actionBar, | ||
searchBarPlaceholder: this.props.searchBarPlaceholder, | ||
key:'grid-actionbar' | ||
key: 'grid-actionbar' | ||
}; | ||
@@ -749,12 +766,12 @@ actionBar = <ActionBar {...renderActionProps}/> | ||
<div className="kuma-uxtable-content" style={{ | ||
width: !!props.passedData ? "auto" : props.width | ||
}}> | ||
width: !!props.passedData ? "auto" : props.width | ||
}}> | ||
{this.renderHeader(renderHeaderProps)} | ||
{this.renderTbody(renderBodyProps,bodyHeight)} | ||
{this.renderTbody(renderBodyProps, bodyHeight)} | ||
</div> | ||
{this.renderPager()} | ||
</div> | ||
); | ||
); | ||
} | ||
@@ -772,4 +789,4 @@ | ||
if (objAux instanceof Array) { | ||
objAux = objAux.map((item) => { | ||
if (item.jsxid == undefined || item.jsxid == null){ | ||
objAux = objAux.map((item) => { | ||
if (item.jsxid == undefined || item.jsxid == null) { | ||
item.jsxid = me.uid++; | ||
@@ -782,6 +799,5 @@ } | ||
}); | ||
} else { | ||
objAux.jsxid = me.uid++; | ||
} | ||
else { | ||
objAux.jsxid = me.uid++; | ||
} | ||
return objAux; | ||
@@ -796,3 +812,3 @@ } | ||
addValuesInData(objAux) { | ||
if ( !objAux || (!objAux.datas && !objAux.data)) return; | ||
if (!objAux || (!objAux.datas && !objAux.data)) return; | ||
let me = this; | ||
@@ -808,5 +824,5 @@ let data = objAux.datas || objAux.data; | ||
/** | ||
* merge data | ||
*/ | ||
/** | ||
* merge data | ||
*/ | ||
@@ -819,4 +835,3 @@ mergeData(data, obj) { | ||
newData.datas = newData.datas.concat(obj); | ||
} | ||
else if (!!newData.data) { | ||
} else if (!!newData.data) { | ||
newData.data = newData.data.concat(obj); | ||
@@ -828,8 +843,8 @@ } | ||
/** | ||
* insert some data into this.state.data | ||
* @param objAux {Array or Object} datum or data need to be inserted | ||
*/ | ||
/** | ||
* insert some data into this.state.data | ||
* @param objAux {Array or Object} datum or data need to be inserted | ||
*/ | ||
insertRecords(objAux) { | ||
@@ -850,5 +865,5 @@ if (typeof objAux !== "object") return; | ||
/** | ||
* @param {objAux} {a:'b',c:'d',jsxid:''} | ||
*/ | ||
/** | ||
* @param {objAux} {a:'b',c:'d',jsxid:''} | ||
*/ | ||
updateRecord(objAux, cb) { | ||
@@ -864,7 +879,6 @@ let _data = this.state.data; | ||
data = data.map((item) => { | ||
data = data.map((item) => { | ||
if (item.jsxid == objAux.jsxid) { | ||
return objAux; | ||
} | ||
else { | ||
} else { | ||
return item; | ||
@@ -875,4 +889,3 @@ } | ||
_data.data = data | ||
} | ||
else if (!!_data.datas) { | ||
} else if (!!_data.datas) { | ||
_data.datas = data; | ||
@@ -882,3 +895,3 @@ } | ||
this.setState({ | ||
data: _data | ||
data: _data | ||
}, () => { | ||
@@ -911,3 +924,3 @@ !!cb && cb(); | ||
removeRecords(objAux) { | ||
//at least one record | ||
@@ -1006,9 +1019,8 @@ let me = this; | ||
if(_data) { | ||
_data = _data.map((item) => { | ||
if (_data) { | ||
_data = _data.map((item) => { | ||
if (item.jsxid == rowData.jsxid) { | ||
item.showSubComp= !item.showSubComp; | ||
item.showSubComp = !item.showSubComp; | ||
return item; | ||
} | ||
else { | ||
} else { | ||
return item; | ||
@@ -1023,3 +1035,4 @@ } | ||
}; | ||
} | ||
; | ||
@@ -1053,7 +1066,14 @@ Table.defaultProps = { | ||
searchBarPlaceholder: "搜索表格内容", | ||
processData: (data) => {return data}, | ||
beforeFetch: (obj) => {return obj}, | ||
onFetchError: () => {}, | ||
addRowClassName: () => {}, | ||
onChange: () => {}, | ||
processData: (data) => { | ||
return data | ||
}, | ||
beforeFetch: (obj) => { | ||
return obj | ||
}, | ||
onFetchError: () => { | ||
}, | ||
addRowClassName: () => { | ||
}, | ||
onChange: () => { | ||
}, | ||
} | ||
@@ -1060,0 +1080,0 @@ |
@@ -17,3 +17,3 @@ /** | ||
super(props); | ||
this.state= { | ||
this.state = { | ||
}; | ||
@@ -38,8 +38,8 @@ } | ||
if(this.props.data.length == 0 && !this.props.mask ) { | ||
let _style={ | ||
lineHeight: this.props.height-10+"px", | ||
} | ||
return (<div className="kuma-uxtable-body-emptyword" style={_style}>{this.props.root.props.emptyText}</div>); | ||
} | ||
if (this.props.data.length == 0 && !this.props.mask) { | ||
let _style = { | ||
lineHeight: this.props.height - 10 + "px", | ||
} | ||
return (<div className="kuma-uxtable-body-emptyword" style={_style}>{this.props.root.props.emptyText}</div>); | ||
} | ||
} | ||
@@ -52,25 +52,33 @@ | ||
this.el = ReactDOM.findDOMNode(this); | ||
let $tableEl = $(this.el).parents(".kuma-uxtable"); | ||
let $tableEl = $(this.el).parents(".kuma-uxtable"); | ||
if (this.props.fixedColumn == 'no') { | ||
$tableEl.find('.kuma-uxtable-header-no').animate({scrollLeft: $tableEl.find('.kuma-uxtable-body-no').scrollLeft()}, 0) | ||
return; | ||
$tableEl.find('.kuma-uxtable-header-no').animate({ | ||
scrollLeft: $tableEl.find('.kuma-uxtable-body-no').scrollLeft() | ||
}, 0) | ||
return; | ||
} | ||
let target= $(e.target); | ||
if(target.hasClass('kuma-uxtable-body-scroll')) { | ||
$tableEl.find('.kuma-uxtable-body-fixed').animate({scrollTop: $tableEl.find('.kuma-uxtable-body-scroll').scrollTop()}, 0) | ||
$tableEl.find('.kuma-uxtable-header-scroll').animate({scrollLeft: $tableEl.find('.kuma-uxtable-body-scroll').scrollLeft()}, 0) | ||
}else { | ||
$tableEl.find('.kuma-uxtable-body-scroll').animate({scrollTop: $tableEl.find('.kuma-uxtable-body-fixed').scrollTop()}, 0) | ||
let target = $(e.target); | ||
if (target.hasClass('kuma-uxtable-body-scroll')) { | ||
$tableEl.find('.kuma-uxtable-body-fixed').animate({ | ||
scrollTop: $tableEl.find('.kuma-uxtable-body-scroll').scrollTop() | ||
}, 0) | ||
$tableEl.find('.kuma-uxtable-header-scroll').animate({ | ||
scrollLeft: $tableEl.find('.kuma-uxtable-body-scroll').scrollLeft() | ||
}, 0) | ||
} else { | ||
$tableEl.find('.kuma-uxtable-body-scroll').animate({ | ||
scrollTop: $tableEl.find('.kuma-uxtable-body-fixed').scrollTop() | ||
}, 0) | ||
} | ||
} | ||
render() { | ||
let me = this, | ||
_props = me.props, | ||
_columns = _props.columns, | ||
_columns = _props.columns, | ||
_data = _props.data.length > 0 ? _props.data : [], | ||
@@ -82,30 +90,28 @@ _style = {}, | ||
if (_props.fixedColumn == 'fixed') { | ||
_columns = _props.columns.filter((item)=>{ | ||
if (item.fixed && !item.hidden) { | ||
if(!item.width) { | ||
item.width = 100; | ||
} | ||
_width=item.width*1+_width; | ||
return true | ||
} | ||
}) | ||
_style={ | ||
width:_width, | ||
minWidth:_width | ||
} | ||
bodyWrapClassName="kuma-uxtable-body-fixed"; | ||
_columns = _props.columns.filter((item) => { | ||
if (item.fixed && !item.hidden) { | ||
if (!item.width) { | ||
item.width = 100; | ||
} | ||
_width = item.width * 1 + _width; | ||
return true | ||
} | ||
}) | ||
_style = { | ||
width: _width, | ||
minWidth: _width | ||
} | ||
bodyWrapClassName = "kuma-uxtable-body-fixed"; | ||
} | ||
else if(_props.fixedColumn == 'scroll') { | ||
} else if (_props.fixedColumn == 'scroll') { | ||
let fixedWidth = 0 | ||
_columns= _props.columns.filter( (item) =>{ | ||
_columns = _props.columns.filter((item) => { | ||
if (!item.fixed) { | ||
return true; | ||
return true; | ||
} else if (!item.hidden) { | ||
if (!item.width) { | ||
item.width = 100; | ||
} | ||
_width = item.width * 1 + _width; | ||
} | ||
else if (!item.hidden) { | ||
if(!item.width) { | ||
item.width = 100; | ||
} | ||
_width = item.width*1+_width; | ||
} | ||
}) | ||
@@ -116,11 +122,11 @@ | ||
if (util.isIE(8)) { | ||
delta = 3 | ||
delta = 3 | ||
} | ||
_style={ | ||
_style = { | ||
width: _props.width - _width - delta, //change 2 to 3, fix ie8 issue | ||
minWidth: _props.width - _width - delta | ||
} | ||
bodyWrapClassName="kuma-uxtable-body-scroll"; | ||
}else { | ||
bodyWrapClassName="kuma-uxtable-body-no"; | ||
bodyWrapClassName = "kuma-uxtable-body-scroll"; | ||
} else { | ||
bodyWrapClassName = "kuma-uxtable-body-no"; | ||
} | ||
@@ -131,6 +137,6 @@ return ( | ||
{this.renderEmptyData()} | ||
{_data.map(function(item,index) { | ||
let renderProps={ | ||
{_data.map(function(item, index) { | ||
let renderProps = { | ||
columns: _columns, | ||
rowIndex: item.jsxid,//tree mode, rowIndex need think more, so use jsxid | ||
rowIndex: item.jsxid, //tree mode, rowIndex need think more, so use jsxid | ||
rowData: deepcopy(_data[index]), | ||
@@ -146,3 +152,3 @@ index: index, | ||
actions: _props.actions, | ||
key: 'row'+ index, | ||
key: 'row' + index, | ||
mode: _props.mode, | ||
@@ -163,10 +169,11 @@ renderModel: _props.renderModel, | ||
</div> | ||
); | ||
); | ||
} | ||
}; | ||
Tbody.propTypes= { | ||
} | ||
; | ||
Tbody.propTypes = { | ||
}; | ||
@@ -173,0 +180,0 @@ |
{ | ||
"name": "uxcore-tooltip", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "uxcore-tooltip ui component for react", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2591747
680
51606
60