@lemon-fe/components 1.1.5-alpha.1 → 1.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/base-table/index.js +10 -3
- package/es/base-table/locale/en_US.d.ts +3 -0
- package/es/base-table/locale/en_US.js +5 -0
- package/es/base-table/locale/locale.d.ts +4 -0
- package/es/base-table/locale/locale.js +1 -0
- package/es/base-table/locale/zh_CN.d.ts +3 -0
- package/es/base-table/locale/zh_CN.js +5 -0
- package/es/color-picker/index.js +6 -2
- package/es/color-picker/locale/en_US.d.ts +3 -0
- package/es/color-picker/locale/en_US.js +4 -0
- package/es/color-picker/locale/locale.d.ts +3 -0
- package/es/color-picker/locale/locale.js +1 -0
- package/es/color-picker/locale/zh_CN.d.ts +3 -0
- package/es/color-picker/locale/zh_CN.js +4 -0
- package/es/data-grid/cell-editors/text.js +11 -2
- package/es/data-grid/components/custom-panel/field-modal.js +17 -9
- package/es/data-grid/components/custom-panel/index.js +11 -7
- package/es/data-grid/components/custom-panel/item.js +6 -2
- package/es/data-grid/components/search.js +8 -4
- package/es/data-grid/components/selected.js +9 -2
- package/es/data-grid/hooks.d.ts +4 -4
- package/es/data-grid/index.d.ts +44 -27
- package/es/data-grid/index.js +157 -145
- package/es/data-grid/locale/en_US.d.ts +3 -0
- package/es/data-grid/locale/en_US.js +55 -0
- package/es/data-grid/locale/locale.d.ts +35 -0
- package/es/data-grid/locale/locale.js +1 -0
- package/es/data-grid/locale/zh_CN.d.ts +3 -0
- package/es/data-grid/locale/zh_CN.js +55 -0
- package/es/data-grid/renderer/actions.js +11 -1
- package/es/data-grid/typings.d.ts +2 -2
- package/es/duration-picker/index.d.ts +1 -0
- package/es/duration-picker/index.js +80 -52
- package/es/duration-picker/locale/en_US.d.ts +3 -0
- package/es/duration-picker/locale/en_US.js +11 -0
- package/es/duration-picker/locale/locale.d.ts +10 -0
- package/es/duration-picker/locale/locale.js +1 -0
- package/es/duration-picker/locale/zh_CN.d.ts +3 -0
- package/es/duration-picker/locale/zh_CN.js +11 -0
- package/es/filter/index.js +84 -66
- package/es/filter/index.less +5 -0
- package/es/filter/locale/en_US.d.ts +3 -0
- package/es/filter/locale/en_US.js +22 -0
- package/es/filter/locale/locale.d.ts +22 -0
- package/es/filter/locale/locale.js +1 -0
- package/es/filter/locale/zh_CN.d.ts +3 -0
- package/es/filter/locale/zh_CN.js +22 -0
- package/es/index.d.ts +6 -1
- package/es/index.js +6 -2
- package/es/locale/en_US.d.ts +3 -0
- package/es/locale/en_US.js +32 -0
- package/es/locale/locale.d.ts +29 -0
- package/es/locale/locale.js +7 -0
- package/es/locale/zh_CN.d.ts +3 -0
- package/es/locale/zh_CN.js +65 -0
- package/es/locale-receiver.d.ts +4 -0
- package/es/locale-receiver.js +20 -0
- package/es/select-panel/index.js +15 -4
- package/es/select-panel/locale/en_US.d.ts +3 -0
- package/es/select-panel/locale/en_US.js +5 -0
- package/es/select-panel/locale/locale.d.ts +4 -0
- package/es/select-panel/locale/locale.js +1 -0
- package/es/select-panel/locale/zh_CN.d.ts +3 -0
- package/es/select-panel/locale/zh_CN.js +5 -0
- package/es/select-view/index.js +10 -4
- package/es/select-view/locale/en_US.d.ts +3 -0
- package/es/select-view/locale/en_US.js +6 -0
- package/es/select-view/locale/locale.d.ts +5 -0
- package/es/select-view/locale/locale.js +1 -0
- package/es/select-view/locale/zh_CN.d.ts +3 -0
- package/es/select-view/locale/zh_CN.js +6 -0
- package/es/sider-tree/index.d.ts +1 -1
- package/es/sider-tree/index.js +6 -2
- package/es/sider-tree/locale/en_US.d.ts +3 -0
- package/es/sider-tree/locale/en_US.js +5 -0
- package/es/sider-tree/locale/locale.d.ts +4 -0
- package/es/sider-tree/locale/locale.js +1 -0
- package/es/sider-tree/locale/zh_CN.d.ts +3 -0
- package/es/sider-tree/locale/zh_CN.js +5 -0
- package/es/sider-tree/tree-node-title.js +6 -2
- package/package.json +2 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var locale = {
|
|
2
|
+
localeText: {
|
|
3
|
+
copy: '复制',
|
|
4
|
+
copyWithHeaders: '复制(带表头)',
|
|
5
|
+
copyWithGroupHeaders: '复制(带表头分组)',
|
|
6
|
+
paste: '粘贴',
|
|
7
|
+
export: '导出',
|
|
8
|
+
csvExport: 'CSV 导出',
|
|
9
|
+
searchOoo: '搜索',
|
|
10
|
+
autosizeThiscolumn: '当前列宽自适应',
|
|
11
|
+
autosizeAllColumns: '所有列宽自适应',
|
|
12
|
+
resetColumns: '重置所有列',
|
|
13
|
+
pinColumn: '固定列',
|
|
14
|
+
pinLeft: '固定在左侧',
|
|
15
|
+
pinRight: '固定在右侧',
|
|
16
|
+
noPin: '不固定',
|
|
17
|
+
expandAll: '展开所有',
|
|
18
|
+
collapseAll: '折叠所有',
|
|
19
|
+
columns: '列'
|
|
20
|
+
},
|
|
21
|
+
pagination: {
|
|
22
|
+
totalText: '共${total}条'
|
|
23
|
+
},
|
|
24
|
+
fieldModal: {
|
|
25
|
+
addCustomColumnText: '添加自定义列',
|
|
26
|
+
customColumnNameText: '自定义列名',
|
|
27
|
+
customColumnExpressionText: '自定义公式',
|
|
28
|
+
summaryText: '是否统计合计',
|
|
29
|
+
summaryTypeText: '合计规则',
|
|
30
|
+
summaryTypeContentText: "\n <div>\n <p>1\u3001\u81EA\u5B9A\u4E49\u5217\u6570\u636E\u503C\u6C42\u548C\u5F97\u51FA\u5408\u8BA1\u503C</p>\n <p>\n 2\u3001\u6570\u636E\u6E90\u6839\u636E\u8BA1\u7B97\u516C\u5F0F\u5F97\u51FA\u5408\u8BA1\u503C\n <br />\n \u516C\u5F0F\u4E2D\u6DFB\u52A0\u7684\u5B57\u6BB5\u5148\u6C42\u548C\uFF0C\u518D\u6839\u636E\u8BA1\u7B97\u516C\u5F0F\u8BA1\u7B97\u51FA\u5408\u8BA1\n </p>\n </div>\n ",
|
|
31
|
+
customSummaryDataText: '自定义列数据值求和得出合计值',
|
|
32
|
+
dataSourceSummaryDataText: '数据源根据计算公式得出合计值',
|
|
33
|
+
addFieldText: '添加字段'
|
|
34
|
+
},
|
|
35
|
+
validate: {
|
|
36
|
+
fieldErrorText: '${field}输入错误'
|
|
37
|
+
},
|
|
38
|
+
maxWordText: '${headName}最多${maxLength}个字符',
|
|
39
|
+
operationSuccessText: '操作成功',
|
|
40
|
+
displayText: '显示',
|
|
41
|
+
searchText: '搜索',
|
|
42
|
+
addCustomColumnText: '添加自定义列',
|
|
43
|
+
resetText: '重置',
|
|
44
|
+
saveText: '保存',
|
|
45
|
+
editText: '编辑',
|
|
46
|
+
deleteText: '删除',
|
|
47
|
+
searchPlaceholderText: '输入关键字搜索',
|
|
48
|
+
searchPrevText: '上一个',
|
|
49
|
+
searchNextText: '下一个',
|
|
50
|
+
selectedTipText: '已选${length}条',
|
|
51
|
+
clearSelectedText: '清空已选',
|
|
52
|
+
moreText: '更多',
|
|
53
|
+
actionText: '操作'
|
|
54
|
+
};
|
|
55
|
+
export default locale;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
11
|
import React from 'react';
|
|
6
12
|
import Dropdown from "../../dropdown";
|
|
7
13
|
import Icons from "../../icons";
|
|
14
|
+
import { useLocaleReceiver } from "../../locale-receiver";
|
|
8
15
|
import { prefixClassName } from "../../utils";
|
|
9
16
|
import classNames from 'classnames';
|
|
10
17
|
var prefix = prefixClassName('grid-operator');
|
|
@@ -39,6 +46,9 @@ export default function Actions(props) {
|
|
|
39
46
|
_props$maxShowCount = props.maxShowCount,
|
|
40
47
|
maxShowCount = _props$maxShowCount === void 0 ? Infinity : _props$maxShowCount;
|
|
41
48
|
var actions = typeof actionsProp === 'function' ? actionsProp(data, params) : actionsProp;
|
|
49
|
+
var _useLocaleReceiver = useLocaleReceiver('DataGrid'),
|
|
50
|
+
_useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
|
|
51
|
+
dataGridLocale = _useLocaleReceiver2[0];
|
|
42
52
|
var traverse = function traverse(node, idx) {
|
|
43
53
|
if (node === null) {
|
|
44
54
|
return null;
|
|
@@ -59,7 +69,7 @@ export default function Actions(props) {
|
|
|
59
69
|
var list = actions.map(traverse).filter(Boolean);
|
|
60
70
|
if (list.length > maxShowCount) {
|
|
61
71
|
list = list.slice(0, maxShowCount - 1).concat([{
|
|
62
|
-
label: '更多',
|
|
72
|
+
label: dataGridLocale.moreText || '更多',
|
|
63
73
|
children: list.slice(maxShowCount - 1)
|
|
64
74
|
}]);
|
|
65
75
|
}
|
|
@@ -8,7 +8,7 @@ import type { RowEditorParams } from './cell-editors/row';
|
|
|
8
8
|
import type { SelectEditorParams } from './cell-editors/select';
|
|
9
9
|
import type { TextEditorParams } from './cell-editors/text';
|
|
10
10
|
import type { FieldCol } from './components/custom-panel/typings';
|
|
11
|
-
import type
|
|
11
|
+
import type { DataGridRef } from './index';
|
|
12
12
|
export type { TextEditorParams } from './cell-editors/text';
|
|
13
13
|
export type { NumberEditorParams } from './cell-editors/number';
|
|
14
14
|
export type { DateEditorParams } from './cell-editors/date';
|
|
@@ -102,7 +102,7 @@ export declare type DataGridState<TData> = {
|
|
|
102
102
|
export declare type GridStore = {
|
|
103
103
|
errors: Map<string, Map<string, string[]>>;
|
|
104
104
|
context?: any;
|
|
105
|
-
grid:
|
|
105
|
+
grid: DataGridRef<any>;
|
|
106
106
|
fetchError?: Error;
|
|
107
107
|
};
|
|
108
108
|
export interface RowAction<T> {
|
|
@@ -14,53 +14,13 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
import { DatePicker, Select } from 'antd';
|
|
17
18
|
import React, { useMemo, useState, useEffect } from 'react';
|
|
18
19
|
import { PREFIX_CLS } from "../constants";
|
|
19
20
|
import InputCompact from "../input-compact";
|
|
20
|
-
import {
|
|
21
|
+
import { useLocaleReceiver } from "../locale-receiver";
|
|
21
22
|
import moment from 'moment';
|
|
22
23
|
var emptyValue = [];
|
|
23
|
-
var defaultOptions = [{
|
|
24
|
-
label: '自定义时段',
|
|
25
|
-
value: function value() {
|
|
26
|
-
return emptyValue;
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
label: '今天',
|
|
30
|
-
value: function value() {
|
|
31
|
-
return [moment().startOf('day'), moment().endOf('day')];
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
label: '昨天',
|
|
35
|
-
value: function value() {
|
|
36
|
-
return [moment().add(-1, 'days').startOf('day'), moment().add(-1, 'days').endOf('day')];
|
|
37
|
-
}
|
|
38
|
-
}, {
|
|
39
|
-
label: '本周',
|
|
40
|
-
value: function value() {
|
|
41
|
-
return [moment().startOf('isoWeek'), moment().endOf('isoWeek')];
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
label: '上周',
|
|
45
|
-
value: function value() {
|
|
46
|
-
return [moment().startOf('isoWeek').add(-1, 'week'), moment().endOf('isoWeek').add(-1, 'week')];
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
label: '本月',
|
|
50
|
-
value: function value() {
|
|
51
|
-
return [moment().startOf('month'), moment().endOf('month')];
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
label: '上月',
|
|
55
|
-
value: function value() {
|
|
56
|
-
return [moment().add(-1, 'months').startOf('month'), moment().add(-1, 'months').endOf('month')];
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
label: '最近30日',
|
|
60
|
-
value: function value() {
|
|
61
|
-
return [moment().add(-29, 'days').startOf('day'), moment().endOf('day')];
|
|
62
|
-
}
|
|
63
|
-
}];
|
|
64
24
|
function DurationPicker(props) {
|
|
65
25
|
var _result$type, _result$option;
|
|
66
26
|
var _props$prefixCls = props.prefixCls,
|
|
@@ -68,8 +28,7 @@ function DurationPicker(props) {
|
|
|
68
28
|
types = props.types,
|
|
69
29
|
_props$hideType = props.hideType,
|
|
70
30
|
hideType = _props$hideType === void 0 ? false : _props$hideType,
|
|
71
|
-
|
|
72
|
-
options = _props$options === void 0 ? defaultOptions : _props$options,
|
|
31
|
+
optionsProp = props.options,
|
|
73
32
|
valueProp = props.value,
|
|
74
33
|
_props$dateFormat = props.dateFormat,
|
|
75
34
|
dateFormat = _props$dateFormat === void 0 ? 'YYYY-MM-DD' : _props$dateFormat,
|
|
@@ -77,11 +36,80 @@ function DurationPicker(props) {
|
|
|
77
36
|
style = props.style,
|
|
78
37
|
disabled = props.disabled,
|
|
79
38
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
39
|
+
var _useLocaleReceiver = useLocaleReceiver('DurationPicker'),
|
|
40
|
+
_useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
|
|
41
|
+
DurationPickerLocale = _useLocaleReceiver2[0];
|
|
42
|
+
var customDateText = DurationPickerLocale.customDateText,
|
|
43
|
+
todayText = DurationPickerLocale.todayText,
|
|
44
|
+
yesterdayText = DurationPickerLocale.yesterdayText,
|
|
45
|
+
thisWeekText = DurationPickerLocale.thisWeekText,
|
|
46
|
+
lastWeekText = DurationPickerLocale.lastWeekText,
|
|
47
|
+
thisMonthText = DurationPickerLocale.thisMonthText,
|
|
48
|
+
lastMonthText = DurationPickerLocale.lastMonthText,
|
|
49
|
+
lastThirtyDaysText = DurationPickerLocale.lastThirtyDaysText;
|
|
50
|
+
var options = useMemo(function () {
|
|
51
|
+
if (optionsProp) {
|
|
52
|
+
return optionsProp.map(function (item) {
|
|
53
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
54
|
+
id: item.id || item.label
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return [{
|
|
59
|
+
label: customDateText,
|
|
60
|
+
id: '自定义时间段',
|
|
61
|
+
value: function value() {
|
|
62
|
+
return emptyValue;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
label: todayText,
|
|
66
|
+
id: '今天',
|
|
67
|
+
value: function value() {
|
|
68
|
+
return [moment().startOf('day'), moment().endOf('day')];
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
label: yesterdayText,
|
|
72
|
+
id: '昨天',
|
|
73
|
+
value: function value() {
|
|
74
|
+
return [moment().add(-1, 'days').startOf('day'), moment().add(-1, 'days').endOf('day')];
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
label: thisWeekText,
|
|
78
|
+
id: '本周',
|
|
79
|
+
value: function value() {
|
|
80
|
+
return [moment().startOf('isoWeek'), moment().endOf('isoWeek')];
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
label: lastWeekText,
|
|
84
|
+
id: '上周',
|
|
85
|
+
value: function value() {
|
|
86
|
+
return [moment().startOf('isoWeek').add(-1, 'week'), moment().endOf('isoWeek').add(-1, 'week')];
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
label: thisMonthText,
|
|
90
|
+
id: '本月',
|
|
91
|
+
value: function value() {
|
|
92
|
+
return [moment().startOf('month'), moment().endOf('month')];
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
label: lastMonthText,
|
|
96
|
+
id: '上月',
|
|
97
|
+
value: function value() {
|
|
98
|
+
return [moment().add(-1, 'months').startOf('month'), moment().add(-1, 'months').endOf('month')];
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
label: lastThirtyDaysText,
|
|
102
|
+
id: '最近30日',
|
|
103
|
+
value: function value() {
|
|
104
|
+
return [moment().add(-29, 'days').startOf('day'), moment().endOf('day')];
|
|
105
|
+
}
|
|
106
|
+
}];
|
|
107
|
+
}, [optionsProp]);
|
|
80
108
|
var defaultDurationPickerValue = useMemo(function () {
|
|
81
109
|
if (valueProp === undefined) {
|
|
82
110
|
return {
|
|
83
111
|
type: types[0].value,
|
|
84
|
-
option: options[0].
|
|
112
|
+
option: options[0].id,
|
|
85
113
|
dates: options[0].value().map(function (item) {
|
|
86
114
|
return item.format(dateFormat);
|
|
87
115
|
})
|
|
@@ -103,7 +131,7 @@ function DurationPicker(props) {
|
|
|
103
131
|
return item.value === value.type;
|
|
104
132
|
});
|
|
105
133
|
var option = options.find(function (item) {
|
|
106
|
-
return item.
|
|
134
|
+
return item.id === value.option;
|
|
107
135
|
});
|
|
108
136
|
var dates = value.dates ? value.dates.map(function (date) {
|
|
109
137
|
return moment(date, dateFormat);
|
|
@@ -126,13 +154,13 @@ function DurationPicker(props) {
|
|
|
126
154
|
}
|
|
127
155
|
};
|
|
128
156
|
var handleChangeOption = function handleChangeOption(item) {
|
|
129
|
-
if (value.option !== item.
|
|
157
|
+
if (value.option !== item.id) {
|
|
130
158
|
var itemValue = item.value();
|
|
131
159
|
var newDurationPickerValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
132
160
|
dates: itemValue.length > 0 ? itemValue.map(function (date) {
|
|
133
161
|
return date.format(dateFormat);
|
|
134
162
|
}) : value.dates,
|
|
135
|
-
option: item.
|
|
163
|
+
option: item.id
|
|
136
164
|
});
|
|
137
165
|
setDurationPickerValue(newDurationPickerValue);
|
|
138
166
|
if (onChange) {
|
|
@@ -142,7 +170,7 @@ function DurationPicker(props) {
|
|
|
142
170
|
};
|
|
143
171
|
var handleChangeDates = function handleChangeDates(dates) {
|
|
144
172
|
var newDurationPickerValue = _objectSpread({}, value);
|
|
145
|
-
newDurationPickerValue.option =
|
|
173
|
+
newDurationPickerValue.option = options[0].id;
|
|
146
174
|
if (dates === null) {
|
|
147
175
|
newDurationPickerValue.dates = emptyValue;
|
|
148
176
|
} else {
|
|
@@ -181,20 +209,20 @@ function DurationPicker(props) {
|
|
|
181
209
|
disabled: disabled
|
|
182
210
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
183
211
|
style: {
|
|
184
|
-
|
|
212
|
+
minWidth: 110,
|
|
185
213
|
color: '#666'
|
|
186
214
|
},
|
|
187
215
|
options: options.map(function (item) {
|
|
188
216
|
return {
|
|
189
217
|
label: item.label,
|
|
190
|
-
value: item.
|
|
218
|
+
value: item.id,
|
|
191
219
|
item: item
|
|
192
220
|
};
|
|
193
221
|
}),
|
|
194
222
|
onSelect: function onSelect(_, opt) {
|
|
195
223
|
handleChangeOption(opt.item);
|
|
196
224
|
},
|
|
197
|
-
value: (_result$option = result.option) === null || _result$option === void 0 ? void 0 : _result$option.
|
|
225
|
+
value: (_result$option = result.option) === null || _result$option === void 0 ? void 0 : _result$option.id
|
|
198
226
|
}), /*#__PURE__*/React.createElement(DatePicker.RangePicker, _extends({
|
|
199
227
|
value: result.dates,
|
|
200
228
|
onChange: handleChangeDates,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var locale = {
|
|
2
|
+
customDateText: 'Custom Date',
|
|
3
|
+
todayText: 'Today',
|
|
4
|
+
yesterdayText: 'YesterDay',
|
|
5
|
+
thisWeekText: 'This Week',
|
|
6
|
+
lastWeekText: 'Last Week',
|
|
7
|
+
thisMonthText: 'This Month',
|
|
8
|
+
lastMonthText: 'Last Month',
|
|
9
|
+
lastThirtyDaysText: 'Last 30 Days'
|
|
10
|
+
};
|
|
11
|
+
export default locale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/filter/index.js
CHANGED
|
@@ -7,16 +7,16 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
10
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
11
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
12
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
18
13
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
17
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
21
|
import { Button, Checkbox, Form, Input, Popover, Space, Modal, message, Select, Empty } from 'antd';
|
|
22
22
|
import React, { useEffect, useMemo, useState, useContext } from 'react';
|
|
@@ -26,45 +26,50 @@ import DurationPicker from "../duration-picker";
|
|
|
26
26
|
import FormLayout from "../form-layout";
|
|
27
27
|
import Icons from "../icons";
|
|
28
28
|
import InputNumber from "../input-number";
|
|
29
|
+
import { useLocaleReceiver } from "../locale-receiver";
|
|
30
|
+
import { parseLocalTemplate } from "../locale/locale";
|
|
29
31
|
import TabBar from "../tab-bar";
|
|
30
32
|
import { mergeProp, prefixClassName } from "../utils";
|
|
31
33
|
import { useDebounce, useRequest, useUpdateEffect } from '@lemon-fe/hooks';
|
|
32
34
|
import classNames from 'classnames';
|
|
33
35
|
import ResizeObserver from 'rc-resize-observer';
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
36
|
+
var getInitComponents = function getInitComponents(locale) {
|
|
37
|
+
return [{
|
|
38
|
+
type: 'input',
|
|
39
|
+
render: function render(item) {
|
|
40
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
41
|
+
allowClear: true,
|
|
42
|
+
maxLength: 125
|
|
43
|
+
}, item.extraProps));
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
type: 'input-number',
|
|
47
|
+
render: function render(item) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(InputNumber, _extends({
|
|
49
|
+
style: {
|
|
50
|
+
width: '100%'
|
|
51
|
+
}
|
|
52
|
+
}, item.extraProps));
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
type: 'select',
|
|
56
|
+
render: function render(item) {
|
|
57
|
+
return /*#__PURE__*/React.createElement(Select, item.extraProps);
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
type: 'range-picker',
|
|
61
|
+
colSpan: 2,
|
|
62
|
+
render: function render(item) {
|
|
63
|
+
return /*#__PURE__*/React.createElement(DurationPicker, _extends({
|
|
64
|
+
types: [{
|
|
65
|
+
label: locale.lableDateText || '日期',
|
|
66
|
+
value: 'date'
|
|
67
|
+
}]
|
|
68
|
+
}, item.extraProps));
|
|
69
|
+
}
|
|
70
|
+
}];
|
|
71
|
+
};
|
|
72
|
+
var externalComponents = [];
|
|
68
73
|
var getStorageData = function getData(storageKey) {
|
|
69
74
|
var data = localStorage.getItem("filter-storage-".concat(storageKey));
|
|
70
75
|
if (data) {
|
|
@@ -77,13 +82,7 @@ var setStorageData = function setData(storageKey, data, action) {
|
|
|
77
82
|
};
|
|
78
83
|
var DEFAULT_TAB_TITLE = '默认';
|
|
79
84
|
function setComponents(items) {
|
|
80
|
-
|
|
81
|
-
return [item.type, item];
|
|
82
|
-
}));
|
|
83
|
-
items.forEach(function (item) {
|
|
84
|
-
compMap.set(item.type, item);
|
|
85
|
-
});
|
|
86
|
-
components = _toConsumableArray(compMap.values());
|
|
85
|
+
externalComponents = items;
|
|
87
86
|
}
|
|
88
87
|
function setStorage(getData, setData) {
|
|
89
88
|
getStorageData = getData;
|
|
@@ -112,6 +111,9 @@ function Filter(props) {
|
|
|
112
111
|
filterDependencies = _props$filterDependen === void 0 ? [] : _props$filterDependen,
|
|
113
112
|
formProp = props.form;
|
|
114
113
|
var prefix = prefixClassName('filter');
|
|
114
|
+
var _useLocaleReceiver = useLocaleReceiver('Filter'),
|
|
115
|
+
_useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
|
|
116
|
+
filterLocale = _useLocaleReceiver2[0];
|
|
115
117
|
var emptyValue = useMemo(function () {
|
|
116
118
|
return Object.fromEntries(data.map(function (item) {
|
|
117
119
|
return [item.key, undefined];
|
|
@@ -126,6 +128,16 @@ function Filter(props) {
|
|
|
126
128
|
}
|
|
127
129
|
return null;
|
|
128
130
|
}, []);
|
|
131
|
+
var components = useMemo(function () {
|
|
132
|
+
var initialComponents = getInitComponents(filterLocale);
|
|
133
|
+
var compMap = new Map(initialComponents.map(function (item) {
|
|
134
|
+
return [item.type, item];
|
|
135
|
+
}));
|
|
136
|
+
externalComponents.forEach(function (item) {
|
|
137
|
+
compMap.set(item.type, item);
|
|
138
|
+
});
|
|
139
|
+
return _toConsumableArray(compMap.values());
|
|
140
|
+
}, []);
|
|
129
141
|
var compMap = useMemo(function () {
|
|
130
142
|
var result = new Map(components.map(function (item) {
|
|
131
143
|
return [item.type, item];
|
|
@@ -146,7 +158,7 @@ function Filter(props) {
|
|
|
146
158
|
keywords = _useState4[0],
|
|
147
159
|
setKeywords = _useState4[1];
|
|
148
160
|
var _useState5 = useState([{
|
|
149
|
-
title: DEFAULT_TAB_TITLE,
|
|
161
|
+
title: filterLocale.defaultTitleText || DEFAULT_TAB_TITLE,
|
|
150
162
|
value: defaultValue || value
|
|
151
163
|
}]),
|
|
152
164
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
@@ -259,7 +271,7 @@ function Filter(props) {
|
|
|
259
271
|
}();
|
|
260
272
|
var handleAddTab = function handleAddTab() {
|
|
261
273
|
if (tabs.length > 6) {
|
|
262
|
-
message.warning(
|
|
274
|
+
message.warning(filterLocale.planLimitText);
|
|
263
275
|
return;
|
|
264
276
|
}
|
|
265
277
|
modalForm.setFieldsValue({
|
|
@@ -268,14 +280,18 @@ function Filter(props) {
|
|
|
268
280
|
toggleModal();
|
|
269
281
|
};
|
|
270
282
|
var handleDelete = function handleDelete() {
|
|
283
|
+
var _filterLocale$deleteM;
|
|
271
284
|
if (active === 0) {
|
|
272
|
-
message.warning(
|
|
285
|
+
message.warning(filterLocale.noDefaultRemoveText);
|
|
273
286
|
return;
|
|
274
287
|
}
|
|
275
288
|
var tab = tabs[active];
|
|
289
|
+
var content = parseLocalTemplate(filterLocale.deleteModal.confirmDeleteText, {
|
|
290
|
+
title: tab.title
|
|
291
|
+
});
|
|
276
292
|
Modal.confirm({
|
|
277
|
-
title:
|
|
278
|
-
content:
|
|
293
|
+
title: (_filterLocale$deleteM = filterLocale.deleteModal) === null || _filterLocale$deleteM === void 0 ? void 0 : _filterLocale$deleteM.titleText,
|
|
294
|
+
content: content,
|
|
279
295
|
maskClosable: true,
|
|
280
296
|
width: 300,
|
|
281
297
|
onOk: function onOk() {
|
|
@@ -431,7 +447,7 @@ function Filter(props) {
|
|
|
431
447
|
open: showModal,
|
|
432
448
|
onCancel: toggleModal,
|
|
433
449
|
onOk: handleOk,
|
|
434
|
-
title:
|
|
450
|
+
title: filterLocale.savePlanText,
|
|
435
451
|
width: 300
|
|
436
452
|
}, /*#__PURE__*/React.createElement(Form, {
|
|
437
453
|
form: modalForm,
|
|
@@ -440,7 +456,7 @@ function Filter(props) {
|
|
|
440
456
|
name: tabs[active].title
|
|
441
457
|
}
|
|
442
458
|
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
443
|
-
label:
|
|
459
|
+
label: filterLocale.planNameText,
|
|
444
460
|
name: "name",
|
|
445
461
|
rules: [{
|
|
446
462
|
required: true
|
|
@@ -463,11 +479,8 @@ function Filter(props) {
|
|
|
463
479
|
},
|
|
464
480
|
className: prefix('tab-bar')
|
|
465
481
|
}), /*#__PURE__*/React.createElement(FormLayout, {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
maxHeight: 72,
|
|
469
|
-
overflow: 'hidden'
|
|
470
|
-
} : undefined
|
|
482
|
+
className: classNames(_defineProperty({}, prefix('pending'), !width)),
|
|
483
|
+
direction: "row"
|
|
471
484
|
}, data.map(function (item) {
|
|
472
485
|
if (!preserveFields && isFieldHidden(item)) {
|
|
473
486
|
return null;
|
|
@@ -490,10 +503,15 @@ function Filter(props) {
|
|
|
490
503
|
return null;
|
|
491
504
|
}
|
|
492
505
|
var renderTarget = item;
|
|
506
|
+
var action = item.type.includes('select') ? filterLocale.selectText : filterLocale.inputText;
|
|
507
|
+
var placeholder = parseLocalTemplate(filterLocale.autoPlaceholderText, {
|
|
508
|
+
action: action,
|
|
509
|
+
label: item.label
|
|
510
|
+
});
|
|
493
511
|
if (autoPlaceholder && item.label !== undefined && item.type !== undefined) {
|
|
494
512
|
renderTarget = _objectSpread(_objectSpread({}, item), {}, {
|
|
495
513
|
extraProps: _objectSpread({
|
|
496
|
-
placeholder:
|
|
514
|
+
placeholder: placeholder
|
|
497
515
|
}, item.extraProps)
|
|
498
516
|
});
|
|
499
517
|
}
|
|
@@ -513,17 +531,17 @@ function Filter(props) {
|
|
|
513
531
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
514
532
|
type: "primary",
|
|
515
533
|
htmlType: "submit"
|
|
516
|
-
},
|
|
534
|
+
}, filterLocale.searchText)), /*#__PURE__*/React.createElement(Space, null, simple ? /*#__PURE__*/React.createElement(Button, {
|
|
517
535
|
onClick: handleReset
|
|
518
|
-
},
|
|
536
|
+
}, filterLocale.resetText) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, {
|
|
519
537
|
actions: [{
|
|
520
|
-
text:
|
|
538
|
+
text: filterLocale.resetText,
|
|
521
539
|
onClick: handleReset
|
|
522
540
|
}, {
|
|
523
|
-
text:
|
|
541
|
+
text: filterLocale.savePlanText,
|
|
524
542
|
onClick: handleAddTab
|
|
525
543
|
}, {
|
|
526
|
-
text:
|
|
544
|
+
text: filterLocale.removePlanText,
|
|
527
545
|
onClick: handleDelete
|
|
528
546
|
}]
|
|
529
547
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
@@ -533,7 +551,7 @@ function Filter(props) {
|
|
|
533
551
|
overlayClassName: prefix('popover'),
|
|
534
552
|
destroyTooltipOnHide: true,
|
|
535
553
|
content: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, {
|
|
536
|
-
placeholder:
|
|
554
|
+
placeholder: filterLocale.searchOptionText,
|
|
537
555
|
allowClear: true,
|
|
538
556
|
className: prefix('items-search'),
|
|
539
557
|
prefix: /*#__PURE__*/React.createElement(Icons.Search, null),
|
|
@@ -573,7 +591,7 @@ function Filter(props) {
|
|
|
573
591
|
},
|
|
574
592
|
type: "link",
|
|
575
593
|
className: prefix('collapse')
|
|
576
|
-
}, collapsed ?
|
|
594
|
+
}, collapsed ? filterLocale.advanceSearchText : filterLocale.collapseSearchText, /*#__PURE__*/React.createElement("svg", {
|
|
577
595
|
width: "10",
|
|
578
596
|
height: "10",
|
|
579
597
|
viewBox: "0 0 10 10",
|