[Feature]暂无数据支持多语

This commit is contained in:
yangchch6 2019-05-21 19:31:38 +08:00
parent fbdefdb95b
commit cd4e5a0b77
7 changed files with 81 additions and 36 deletions

View File

@ -52,6 +52,12 @@ var _beeIcon = require('bee-icon');
var _beeIcon2 = _interopRequireDefault(_beeIcon);
var _i18n = require('./lib/i18n');
var _i18n2 = _interopRequireDefault(_i18n);
var _tool = require('bee-locale/build/tool');
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; }
@ -141,18 +147,7 @@ var defaultProps = {
getBodyWrapper: function getBodyWrapper(body) {
return body;
},
emptyText: function emptyText() {
return _react2["default"].createElement(
'div',
null,
_react2["default"].createElement(_beeIcon2["default"], { type: 'uf-nodata', className: 'table-nodata' }),
_react2["default"].createElement(
'span',
null,
'\u6682\u65E0\u6570\u636E'
)
);
},
// emptyText: () => <div><Icon type="uf-nodata" className="table-nodata"></Icon><span>{locale["no_data"]}</span></div>,
columns: [],
minColumnWidth: 80,
locale: {},
@ -1169,10 +1164,26 @@ var Table = function (_Component) {
Table.prototype.getEmptyText = function getEmptyText() {
var _props6 = this.props,
emptyText = _props6.emptyText,
defaultEmptyText = _props6.emptyText,
clsPrefix = _props6.clsPrefix,
data = _props6.data;
var locale = (0, _tool.getComponentLocale)(this.props, this.context, 'Table', function () {
return _i18n2["default"];
});
var emptyText = defaultEmptyText !== undefined ? defaultEmptyText() : function () {
return _react2["default"].createElement(
'div',
null,
_react2["default"].createElement(_beeIcon2["default"], { type: 'uf-nodata', className: 'table-nodata' }),
_react2["default"].createElement(
'span',
null,
locale["no_data"]
)
);
};
return !data.length ? _react2["default"].createElement(
'div',
{ className: clsPrefix + '-placeholder' },
@ -1471,6 +1482,9 @@ var Table = function (_Component) {
Table.propTypes = propTypes;
Table.defaultProps = defaultProps;
Table.contextTypes = {
beeLocale: _propTypes2["default"].object
};
exports["default"] = Table;
module.exports = exports['default'];

View File

@ -15,6 +15,7 @@ module.exports = {
'less_than_equal_to': '小于等于',
'be_equal_to': '等于',
'not_equal_to': '不等于',
"no_data": '暂无数据',
'en-us': {
'resetSettings': 'reset settings',
'include': 'include',
@ -28,7 +29,8 @@ module.exports = {
'less_than': 'less than',
'less_than_equal_to': 'less than equal to',
'be_equal_to': 'be equal to',
'not_equal_to': 'not equal to'
'not_equal_to': 'not equal to',
"no_data": 'no data'
},
'zh-tw': {
'resetSettings': '還原設置',
@ -43,6 +45,7 @@ module.exports = {
'less_than': '小於',
'less_than_equal to': '小於等於',
'be_equal_to': '等於',
'not_equal_to': '不等於'
'not_equal_to': '不等於',
"no_data": '暫無數據'
}
};

47
dist/demo.js vendored
View File

@ -33904,6 +33904,12 @@
var _beeIcon2 = _interopRequireDefault(_beeIcon);
var _i18n = __webpack_require__(584);
var _i18n2 = _interopRequireDefault(_i18n);
var _tool = __webpack_require__(132);
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; }
@ -33993,18 +33999,7 @@
getBodyWrapper: function getBodyWrapper(body) {
return body;
},
emptyText: function emptyText() {
return _react2['default'].createElement(
'div',
null,
_react2['default'].createElement(_beeIcon2['default'], { type: 'uf-nodata', className: 'table-nodata' }),
_react2['default'].createElement(
'span',
null,
'\u6682\u65E0\u6570\u636E'
)
);
},
// emptyText: () => <div><Icon type="uf-nodata" className="table-nodata"></Icon><span>{locale["no_data"]}</span></div>,
columns: [],
minColumnWidth: 80,
locale: {},
@ -35021,10 +35016,26 @@
Table.prototype.getEmptyText = function getEmptyText() {
var _props6 = this.props,
emptyText = _props6.emptyText,
defaultEmptyText = _props6.emptyText,
clsPrefix = _props6.clsPrefix,
data = _props6.data;
var locale = (0, _tool.getComponentLocale)(this.props, this.context, 'Table', function () {
return _i18n2['default'];
});
var emptyText = defaultEmptyText !== undefined ? defaultEmptyText() : function () {
return _react2['default'].createElement(
'div',
null,
_react2['default'].createElement(_beeIcon2['default'], { type: 'uf-nodata', className: 'table-nodata' }),
_react2['default'].createElement(
'span',
null,
locale["no_data"]
)
);
};
return !data.length ? _react2['default'].createElement(
'div',
{ className: clsPrefix + '-placeholder' },
@ -35323,6 +35334,9 @@
Table.propTypes = propTypes;
Table.defaultProps = defaultProps;
Table.contextTypes = {
beeLocale: _propTypes2['default'].object
};
exports['default'] = Table;
module.exports = exports['default'];
@ -80047,6 +80061,7 @@
'less_than_equal_to': '小于等于',
'be_equal_to': '等于',
'not_equal_to': '不等于',
"no_data": '暂无数据',
'en-us': {
'resetSettings': 'reset settings',
'include': 'include',
@ -80060,7 +80075,8 @@
'less_than': 'less than',
'less_than_equal_to': 'less than equal to',
'be_equal_to': 'be equal to',
'not_equal_to': 'not equal to'
'not_equal_to': 'not equal to',
"no_data": 'no data'
},
'zh-tw': {
'resetSettings': '還原設置',
@ -80075,7 +80091,8 @@
'less_than': '小於',
'less_than_equal to': '小於等於',
'be_equal_to': '等於',
'not_equal_to': '不等於'
'not_equal_to': '不等於',
"no_data": '暫無數據'
}
};

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",
"version": "2.0.19",
"version": "2.0.20-alpha.2",
"description": "Table ui component for react",
"keywords": [
"react",
@ -54,7 +54,7 @@
"bee-icon": "latest",
"bee-input-number": "^2.0.7",
"bee-loading": "^1.0.9",
"bee-locale": "0.0.13",
"bee-locale": "0.0.14",
"bee-menus": "^2.0.6",
"bee-radio": "^2.0.8",
"bee-select": "^2.0.11",

View File

@ -11,6 +11,8 @@ import createStore from './createStore';
import Loading from 'bee-loading';
import Icon from 'bee-icon';
import { Event,EventUtil,closest} from "./utils";
import i18n from "./lib/i18n";
import { getComponentLocale } from "bee-locale/build/tool";
const propTypes = {
data: PropTypes.array,
@ -80,7 +82,7 @@ const defaultProps = {
scroll: {},
rowRef: () => null,
getBodyWrapper: body => body,
emptyText: () => <div><Icon type="uf-nodata" className="table-nodata"></Icon><span></span></div>,
// emptyText: () => <div><Icon type="uf-nodata" className="table-nodata"></Icon><span>{locale["no_data"]}</span></div>,
columns:[],
minColumnWidth: 80,
locale:{},
@ -1005,7 +1007,10 @@ class Table extends Component {
}
getEmptyText() {
const { emptyText, clsPrefix, data } = this.props;
const { emptyText : defaultEmptyText, clsPrefix, data } = this.props;
let locale = getComponentLocale(this.props, this.context, 'Table', () => i18n);
let emptyText = defaultEmptyText !== undefined ? defaultEmptyText() : () => <div><Icon type="uf-nodata" className="table-nodata"></Icon><span>{locale["no_data"]}</span></div>;
return !data.length ? (
<div className={`${clsPrefix}-placeholder`}>
{emptyText()}
@ -1309,5 +1314,8 @@ class Table extends Component {
Table.propTypes = propTypes;
Table.defaultProps = defaultProps;
Table.contextTypes = {
beeLocale: PropTypes.object
};
export default Table;

View File

@ -13,6 +13,7 @@ module.exports = {
'less_than_equal_to':'小于等于',
'be_equal_to':'等于',
'not_equal_to':'不等于',
"no_data":'暂无数据',
'en-us': {
'resetSettings': 'reset settings',
'include': 'include',
@ -27,6 +28,7 @@ module.exports = {
'less_than_equal_to':'less than equal to',
'be_equal_to':'be equal to',
'not_equal_to':'not equal to',
"no_data":'no data',
},
'zh-tw': {
'resetSettings': '還原設置',
@ -41,6 +43,7 @@ module.exports = {
'less_than':'小於',
'less_than_equal to':'小於等於',
'be_equal_to':'等於',
'not_equal_to':'不等於'
'not_equal_to':'不等於',
"no_data":'暫無數據',
}
}