feat(bee-table): 加多语

This commit is contained in:
liushaozhen 2018-11-01 14:35:46 +08:00
parent 1e8eaf28a3
commit ffc232d47c
17 changed files with 432 additions and 217 deletions

View File

@ -24,6 +24,12 @@ var _beeIcon = require('bee-icon');
var _beeIcon2 = _interopRequireDefault(_beeIcon); var _beeIcon2 = _interopRequireDefault(_beeIcon);
var _i18n = require('./i18n');
var _i18n2 = _interopRequireDefault(_i18n);
var _tool = require('bee-locale/build/tool');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
@ -77,6 +83,11 @@ var FilterDropDown = function (_Component) {
FilterDropDown.prototype.render = function render() { FilterDropDown.prototype.render = function render() {
var isShowCondition = this.props.isShowCondition; var isShowCondition = this.props.isShowCondition;
var locale = (0, _tool.getComponentLocale)(this.props, this.context, 'Table', function () {
return _i18n2["default"];
});
var dropmenu = _react2["default"].createElement( var dropmenu = _react2["default"].createElement(
_beeMenus2["default"], _beeMenus2["default"],
{ {
@ -86,32 +97,32 @@ var FilterDropDown = function (_Component) {
_react2["default"].createElement( _react2["default"].createElement(
Item, Item,
{ key: '2' }, { key: '2' },
'\u5305\u542B' locale['include']
), ),
_react2["default"].createElement( _react2["default"].createElement(
Item, Item,
{ key: '6' }, { key: '6' },
'\u4E0D\u5305\u542B' locale['exclusive']
), ),
_react2["default"].createElement( _react2["default"].createElement(
Item, Item,
{ key: '1' }, { key: '1' },
'\u7B49\u4E8E' locale['equal']
), ),
_react2["default"].createElement( _react2["default"].createElement(
Item, Item,
{ key: '5' }, { key: '5' },
'\u4E0D\u7B49\u4E8E' locale['unequal']
), ),
_react2["default"].createElement( _react2["default"].createElement(
Item, Item,
{ key: '7' }, { key: '7' },
'\u4EE5\u5F00\u59CB' locale['begin']
), ),
_react2["default"].createElement( _react2["default"].createElement(
Item, Item,
{ key: '3' }, { key: '3' },
'\u4EE5\u7ED3\u5C3E' locale['end']
) )
); );
return _react2["default"].createElement( return _react2["default"].createElement(

View File

@ -126,7 +126,8 @@ var FilterType = function (_Component) {
className = _this$props.className, className = _this$props.className,
onChange = _this$props.onChange, onChange = _this$props.onChange,
onSelectDropdown = _this$props.onSelectDropdown, onSelectDropdown = _this$props.onSelectDropdown,
clsPrefix = _this$props.clsPrefix; clsPrefix = _this$props.clsPrefix,
locale = _this$props.locale;
switch (rendertype) { switch (rendertype) {
case 'text': case 'text':
@ -144,6 +145,7 @@ var FilterType = function (_Component) {
onBlur: _this.changeTextCallBlur onBlur: _this.changeTextCallBlur
}), }),
_react2["default"].createElement(_FilterDropDown2["default"], { _react2["default"].createElement(_FilterDropDown2["default"], {
locale: locale,
onSelectDropdown: onSelectDropdown, onSelectDropdown: onSelectDropdown,
onClickClear: _this.clearText, onClickClear: _this.clearText,
isShowClear: _this.state.text, isShowClear: _this.state.text,
@ -159,6 +161,7 @@ var FilterType = function (_Component) {
onChange: _this.changeSelect onChange: _this.changeSelect
})), })),
_react2["default"].createElement(_FilterDropDown2["default"], { _react2["default"].createElement(_FilterDropDown2["default"], {
locale: locale,
onSelectDropdown: onSelectDropdown, onSelectDropdown: onSelectDropdown,
onClickClear: _this.clearSelectValue, onClickClear: _this.clearSelectValue,
isShowCondition: filterDropdown, isShowCondition: filterDropdown,
@ -175,6 +178,7 @@ var FilterType = function (_Component) {
open: _this.state.open open: _this.state.open
})), })),
filterDropdown == 'show' && _react2["default"].createElement(_FilterDropDown2["default"], { filterDropdown == 'show' && _react2["default"].createElement(_FilterDropDown2["default"], {
locale: locale,
onSelectDropdown: onSelectDropdown, onSelectDropdown: onSelectDropdown,
onClickClear: _this.clearDateValue, onClickClear: _this.clearDateValue,
isShowCondition: filterDropdown, isShowCondition: filterDropdown,
@ -189,7 +193,7 @@ var FilterType = function (_Component) {
className: className, className: className,
onChange: onChange onChange: onChange
}), }),
filterDropdown == 'show' && _react2["default"].createElement(_FilterDropDown2["default"], { filterDropdown == 'show' && _react2["default"].createElement(_FilterDropDown2["default"], { locale: locale,
onSelectDropdown: onSelectDropdown onSelectDropdown: onSelectDropdown
}) })
); );

View File

@ -127,7 +127,8 @@ var defaultProps = {
return 'No Data'; return 'No Data';
}, },
columns: [], columns: [],
minColumnWidth: 80 minColumnWidth: 80,
locale: {}
}; };
var Table = function (_Component) { var Table = function (_Component) {
@ -389,6 +390,7 @@ var Table = function (_Component) {
contentWidthDiff = this.state.contentWidthDiff; contentWidthDiff = this.state.contentWidthDiff;
} }
return showHeader ? _react2["default"].createElement(_TableHeader2["default"], _extends({}, drop, dragBorder, { return showHeader ? _react2["default"].createElement(_TableHeader2["default"], _extends({}, drop, dragBorder, {
locale: this.props.locale,
minColumnWidth: minColumnWidth, minColumnWidth: minColumnWidth,
contentWidthDiff: contentWidthDiff, contentWidthDiff: contentWidthDiff,
contentWidth: this.contentWidth, contentWidth: this.contentWidth,

View File

@ -249,12 +249,14 @@ var TableHeader = function (_Component) {
var _this$props4 = _this.props, var _this$props4 = _this.props,
clsPrefix = _this$props4.clsPrefix, clsPrefix = _this$props4.clsPrefix,
rows = _this$props4.rows, rows = _this$props4.rows,
filterDelay = _this$props4.filterDelay; filterDelay = _this$props4.filterDelay,
locale = _this$props4.locale;
switch (type) { switch (type) {
//文本输入 //文本输入
case 'text': case 'text':
return _react2["default"].createElement(_FilterType2["default"], { return _react2["default"].createElement(_FilterType2["default"], {
locale: locale,
rendertype: type, rendertype: type,
clsPrefix: clsPrefix, clsPrefix: clsPrefix,
className: clsPrefix + ' filter-text', className: clsPrefix + ' filter-text',
@ -280,6 +282,7 @@ var TableHeader = function (_Component) {
selectDataSource = rows[1][index]['filterdropdowndata']; selectDataSource = rows[1][index]['filterdropdowndata'];
} }
return _react2["default"].createElement(_FilterType2["default"], { return _react2["default"].createElement(_FilterType2["default"], {
locale: locale,
rendertype: type, rendertype: type,
className: clsPrefix + ' filter-dropdown', className: clsPrefix + ' filter-dropdown',
data: selectDataSource, data: selectDataSource,
@ -291,6 +294,7 @@ var TableHeader = function (_Component) {
//日期 //日期
case 'date': case 'date':
return _react2["default"].createElement(_FilterType2["default"], { return _react2["default"].createElement(_FilterType2["default"], {
locale: locale,
rendertype: type, rendertype: type,
className: 'filter-date', className: 'filter-date',
onClick: function onClick() {}, onClick: function onClick() {},

30
build/i18n.js Normal file
View File

@ -0,0 +1,30 @@
'use strict';
module.exports = {
'lang': 'zh-cn',
'resetSettings': '还原设置',
'include': '包含',
'exclusive': '不包含',
'equal': '等于',
'unequal': '不等于',
'begin': '以开始',
'end': '以结尾',
'en-us': {
'resetSettings': 'reset settings',
'include': 'include',
'exclusive': 'exclusive',
'equal': 'equal',
'unequal': 'unequal',
'begin': 'begin',
'end': 'end'
},
'zh-tw': {
'resetSettings': '還原設置',
'include': '包含',
'exclusive': '不包含',
'equal': '等於',
'unequal': '不等於',
'begin': '以開始',
'end': '以結尾'
}
};

View File

@ -22,6 +22,12 @@ var _beeIcon2 = _interopRequireDefault(_beeIcon);
var _util = require("./util"); var _util = require("./util");
var _i18n = require("../i18n");
var _i18n2 = _interopRequireDefault(_i18n);
var _tool = require("bee-locale/build/tool");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
@ -84,6 +90,10 @@ function filterColumn(Table, Popover) {
showModal = _state.showModal; showModal = _state.showModal;
var locale = (0, _tool.getComponentLocale)(this.props, this.context, 'Table', function () {
return _i18n2["default"];
});
var _columns = [], var _columns = [],
widthState = 0, widthState = 0,
scroll = scrollPro; scroll = scrollPro;
@ -105,7 +115,7 @@ function filterColumn(Table, Popover) {
_react2["default"].createElement( _react2["default"].createElement(
"span", "span",
{ className: prefixCls + "-clear-setting", onClick: this.clear }, { className: prefixCls + "-clear-setting", onClick: this.clear },
"\u8FD8\u539F\u8BBE\u7F6E" locale['resetSettings']
), ),
_react2["default"].createElement( _react2["default"].createElement(
"div", "div",

3
dist/demo.css vendored
View File

@ -2420,9 +2420,6 @@ i.uf {
/* /*
* 选择时删除文本阴影及设置默认选中颜色 * 选择时删除文本阴影及设置默认选中颜色
*/ */
::-moz-selection {
background: rgb(187,222,251);
text-shadow: none; }
::selection { ::selection {
background: rgb(187,222,251); background: rgb(187,222,251);
text-shadow: none; } text-shadow: none; }

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

488
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "bee-table", "name": "bee-table",
"version": "1.4.31", "version": "1.4.32",
"description": "Table ui component for react", "description": "Table ui component for react",
"keywords": [ "keywords": [
"react", "react",
@ -53,6 +53,7 @@
"bee-form-control": "latest", "bee-form-control": "latest",
"bee-icon": "^1.0.5", "bee-icon": "^1.0.5",
"bee-loading": "^1.0.3", "bee-loading": "^1.0.3",
"bee-locale": "0.0.11",
"bee-menus": "^1.0.7", "bee-menus": "^1.0.7",
"bee-popover": "^1.0.2", "bee-popover": "^1.0.2",
"bee-select": "^1.0.21", "bee-select": "^1.0.21",

View File

@ -3,6 +3,8 @@ import Dropdown from 'bee-dropdown';
import Menu from 'bee-menus'; import Menu from 'bee-menus';
import Button from 'bee-button'; import Button from 'bee-button';
import Icon from 'bee-icon'; import Icon from 'bee-icon';
import i18n from './i18n';
import { getComponentLocale } from 'bee-locale/build/tool';
const { Item } = Menu; const { Item } = Menu;
class FilterDropDown extends Component { class FilterDropDown extends Component {
@ -34,17 +36,20 @@ class FilterDropDown extends Component {
} }
render() { render() {
let { isShowCondition } = this.props; let { isShowCondition } = this.props;
let locale = getComponentLocale(this.props, this.context, 'Table', () => i18n);
let dropmenu = ( let dropmenu = (
<Menu <Menu
onSelect={this.onSelectDropdown} onSelect={this.onSelectDropdown}
selectedKeys={this.state.selectValue} selectedKeys={this.state.selectValue}
> >
<Item key="2">包含</Item> <Item key="2">{locale['include']}</Item>
<Item key="6">不包含</Item> <Item key="6">{locale['exclusive']}</Item>
<Item key="1">等于</Item> <Item key="1">{locale['equal']}</Item>
<Item key="5">不等于</Item> <Item key="5">{locale['unequal']}</Item>
<Item key="7">以开始</Item> <Item key="7">{locale['begin']}</Item>
<Item key="3">以结尾</Item> <Item key="3">{locale['end']}</Item>
</Menu> </Menu>
); );
return (<div> return (<div>

View File

@ -85,7 +85,7 @@ class FilterType extends Component {
} }
//组件渲染 //组件渲染
renderControl = (rendertype) => { renderControl = (rendertype) => {
let { filterDropdown, className, onChange, onSelectDropdown, clsPrefix } = this.props; let { filterDropdown, className, onChange, onSelectDropdown, clsPrefix, locale } = this.props;
switch (rendertype) { switch (rendertype) {
case 'text': case 'text':
return <div className={`${clsPrefix} filter-wrap`}><FormControl return <div className={`${clsPrefix} filter-wrap`}><FormControl
@ -97,6 +97,7 @@ class FilterType extends Component {
onBlur={this.changeTextCallBlur} onBlur={this.changeTextCallBlur}
/> />
<FilterDropDown <FilterDropDown
locale={locale}
onSelectDropdown={onSelectDropdown} onSelectDropdown={onSelectDropdown}
onClickClear={this.clearText} onClickClear={this.clearText}
isShowClear={this.state.text} isShowClear={this.state.text}
@ -110,6 +111,7 @@ class FilterType extends Component {
value={this.state.selectValue} value={this.state.selectValue}
onChange={this.changeSelect} onChange={this.changeSelect}
/><FilterDropDown /><FilterDropDown
locale={locale}
onSelectDropdown={onSelectDropdown} onSelectDropdown={onSelectDropdown}
onClickClear={this.clearSelectValue} onClickClear={this.clearSelectValue}
isShowCondition={filterDropdown} isShowCondition={filterDropdown}
@ -123,6 +125,7 @@ class FilterType extends Component {
onChange={this.changeDate} onChange={this.changeDate}
open={this.state.open} open={this.state.open}
/>{filterDropdown == 'show' && <FilterDropDown />{filterDropdown == 'show' && <FilterDropDown
locale={locale}
onSelectDropdown={onSelectDropdown} onSelectDropdown={onSelectDropdown}
onClickClear={this.clearDateValue} onClickClear={this.clearDateValue}
isShowCondition={filterDropdown} isShowCondition={filterDropdown}
@ -135,7 +138,7 @@ class FilterType extends Component {
className={className} className={className}
onChange={onChange} onChange={onChange}
/> />
{filterDropdown == 'show' && <FilterDropDown {filterDropdown == 'show' && <FilterDropDown locale={locale}
onSelectDropdown={onSelectDropdown} onSelectDropdown={onSelectDropdown}
> >
</FilterDropDown>} </FilterDropDown>}

View File

@ -69,7 +69,8 @@ const defaultProps = {
getBodyWrapper: body => body, getBodyWrapper: body => body,
emptyText: () => 'No Data', emptyText: () => 'No Data',
columns:[], columns:[],
minColumnWidth: 80 minColumnWidth: 80,
locale:{}
}; };
class Table extends Component { class Table extends Component {
@ -301,6 +302,7 @@ class Table extends Component {
<TableHeader <TableHeader
{...drop} {...drop}
{...dragBorder} {...dragBorder}
locale={this.props.locale}
minColumnWidth={minColumnWidth} minColumnWidth={minColumnWidth}
contentWidthDiff={contentWidthDiff} contentWidthDiff={contentWidthDiff}
contentWidth={this.contentWidth} contentWidth={this.contentWidth}

View File

@ -237,11 +237,12 @@ class TableHeader extends Component {
* @description 过滤渲染的组件类型 * @description 过滤渲染的组件类型
*/ */
filterRenderType = (type, dataIndex, index) => { filterRenderType = (type, dataIndex, index) => {
const { clsPrefix, rows, filterDelay } = this.props; const { clsPrefix, rows, filterDelay,locale } = this.props;
switch (type) { switch (type) {
//文本输入 //文本输入
case 'text': case 'text':
return <FilterType return <FilterType
locale={locale}
rendertype={type} rendertype={type}
clsPrefix={clsPrefix} clsPrefix={clsPrefix}
className={`${clsPrefix} filter-text`} className={`${clsPrefix} filter-text`}
@ -265,6 +266,7 @@ class TableHeader extends Component {
selectDataSource = rows[1][index]['filterdropdowndata'] selectDataSource = rows[1][index]['filterdropdowndata']
} }
return <FilterType return <FilterType
locale={locale}
rendertype={type} rendertype={type}
className={`${clsPrefix} filter-dropdown`} className={`${clsPrefix} filter-dropdown`}
data={selectDataSource} data={selectDataSource}
@ -276,6 +278,7 @@ class TableHeader extends Component {
//日期 //日期
case 'date': case 'date':
return <FilterType return <FilterType
locale={locale}
rendertype={type} rendertype={type}
className={`filter-date`} className={`filter-date`}
onClick={() => { }} onClick={() => { }}

28
src/i18n.js Normal file
View File

@ -0,0 +1,28 @@
module.exports = {
'lang': 'zh-cn',
'resetSettings': '还原设置',
'include': '包含',
'exclusive': '不包含',
'equal': '等于',
'unequal':'不等于',
'begin':'以开始',
'end':'以结尾',
'en-us': {
'resetSettings': 'reset settings',
'include': 'include',
'exclusive': 'exclusive',
'equal': 'equal',
'unequal':'unequal',
'begin':'begin',
'end':'end',
},
'zh-tw': {
'resetSettings': '還原設置',
'include': '包含',
'exclusive': '不包含',
'equal': '等於',
'unequal':'不等於',
'begin':'以開始',
'end':'以結尾',
}
}

View File

@ -2,6 +2,9 @@ import React, { Component } from "react";
import Checkbox from 'bee-checkbox'; import Checkbox from 'bee-checkbox';
import Icon from "bee-icon"; import Icon from "bee-icon";
import {ObjectAssign} from './util'; import {ObjectAssign} from './util';
import i18n from '../i18n'
import { getComponentLocale } from 'bee-locale/build/tool';
function noop() {} function noop() {}
/** /**
* 参数: 过滤表头 * 参数: 过滤表头
@ -121,6 +124,8 @@ export default function filterColumn(Table,Popover) {
const {data,prefixCls,scroll:scrollPro} = this.props; const {data,prefixCls,scroll:scrollPro} = this.props;
const {columns,showModal} = this.state; const {columns,showModal} = this.state;
let locale = getComponentLocale(this.props, this.context, 'Table', () => i18n);
let _columns = [],widthState=0,scroll=scrollPro; let _columns = [],widthState=0,scroll=scrollPro;
columns.forEach((da)=>{ columns.forEach((da)=>{
if(da.ifshow){ if(da.ifshow){
@ -136,7 +141,7 @@ export default function filterColumn(Table,Popover) {
let content = ( let content = (
<div className={`${prefixCls}-pop-cont`}> <div className={`${prefixCls}-pop-cont`}>
<span className={`${prefixCls}-clear-setting`} onClick={this.clear}>还原设置</span> <span className={`${prefixCls}-clear-setting`} onClick={this.clear}>{locale['resetSettings']}</span>
<div> <div>
{ {
this.getCloumItem() this.getCloumItem()