dtable-ui-component 4.3.6 → 4.3.8
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/lib/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.css +22 -59
- package/lib/DTableCustomizeSelect/index.js +99 -95
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.css +103 -0
- package/lib/SelectOptionGroup/index.js +157 -135
- package/lib/SelectOptionGroup/option.js +31 -38
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +28 -0
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +4 -4
package/lib/common/delete-tip.js
CHANGED
|
@@ -1,72 +1,47 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import ModalPortal from './modal-portal';
|
|
7
3
|
import { getLocale } from '../lang';
|
|
8
4
|
import './delete-tip.css';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
-
args[_key] = arguments[_key];
|
|
17
|
-
}
|
|
18
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
19
|
-
_this.handleOutsideClick = function (e) {
|
|
20
|
-
if (_this.tipContainer && !_this.tipContainer.contains(e.target)) {
|
|
21
|
-
_this.props.toggle();
|
|
5
|
+
export default class DeleteTip extends React.Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.handleOutsideClick = e => {
|
|
9
|
+
if (this.tipContainer && !this.tipContainer.contains(e.target)) {
|
|
10
|
+
this.props.toggle();
|
|
22
11
|
}
|
|
23
12
|
};
|
|
24
|
-
return _this;
|
|
25
13
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
position
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
className: "d-flex justify-content-end"
|
|
61
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
62
|
-
className: "btn btn-secondary mr-2",
|
|
63
|
-
onClick: toggle
|
|
64
|
-
}, getLocale('Cancel')), /*#__PURE__*/React.createElement("button", {
|
|
65
|
-
className: "btn btn-primary",
|
|
66
|
-
onClick: onDelete
|
|
67
|
-
}, getLocale('Delete')))));
|
|
68
|
-
}
|
|
69
|
-
}]);
|
|
70
|
-
return DeleteTip;
|
|
71
|
-
}(React.Component);
|
|
72
|
-
export { DeleteTip as default };
|
|
14
|
+
componentDidMount() {
|
|
15
|
+
document.addEventListener('click', this.handleOutsideClick);
|
|
16
|
+
}
|
|
17
|
+
componentWillUnmount() {
|
|
18
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
const {
|
|
22
|
+
toggle,
|
|
23
|
+
onDelete,
|
|
24
|
+
position,
|
|
25
|
+
deleteTip
|
|
26
|
+
} = this.props;
|
|
27
|
+
return /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
ref: node => this.tipContainer = node,
|
|
29
|
+
className: "dtable-tip tip-container",
|
|
30
|
+
style: {
|
|
31
|
+
top: position.top,
|
|
32
|
+
left: position.left
|
|
33
|
+
},
|
|
34
|
+
onClick: e => e.stopPropagation()
|
|
35
|
+
}, /*#__PURE__*/React.createElement("b", {
|
|
36
|
+
className: "mb-4"
|
|
37
|
+
}, deleteTip), /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "d-flex justify-content-end"
|
|
39
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
40
|
+
className: "btn btn-secondary mr-2",
|
|
41
|
+
onClick: toggle
|
|
42
|
+
}, getLocale('Cancel')), /*#__PURE__*/React.createElement("button", {
|
|
43
|
+
className: "btn btn-primary",
|
|
44
|
+
onClick: onDelete
|
|
45
|
+
}, getLocale('Delete')))));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,36 +1,18 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import ReactDOM from 'react-dom';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _this;
|
|
13
|
-
_classCallCheck(this, ModalPortal);
|
|
14
|
-
_this = _super.call(this, props);
|
|
15
|
-
_this.el = document.createElement('div');
|
|
16
|
-
return _this;
|
|
3
|
+
const modalRoot = document.getElementById('modal-wrapper');
|
|
4
|
+
export default class ModalPortal extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.el = document.createElement('div');
|
|
17
8
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, {
|
|
29
|
-
key: "render",
|
|
30
|
-
value: function render() {
|
|
31
|
-
return ReactDOM.createPortal(this.props.children, this.el);
|
|
32
|
-
}
|
|
33
|
-
}]);
|
|
34
|
-
return ModalPortal;
|
|
35
|
-
}(React.Component);
|
|
36
|
-
export { ModalPortal as default };
|
|
9
|
+
componentDidMount() {
|
|
10
|
+
modalRoot.appendChild(this.el);
|
|
11
|
+
}
|
|
12
|
+
componentWillUnmount() {
|
|
13
|
+
modalRoot.removeChild(this.el);
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
return ReactDOM.createPortal(this.props.children, this.el);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/lib/constants/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CellType, FORMULA_RESULT_TYPE } from 'dtable-utils';
|
|
2
|
-
|
|
2
|
+
const NUMBER_TYPES = {
|
|
3
3
|
'NUMBER': 'number',
|
|
4
4
|
'NUMBER_WITH_COMMAS': 'number-with-commas',
|
|
5
5
|
'PERCENT': 'percent',
|
|
@@ -8,7 +8,7 @@ var NUMBER_TYPES = {
|
|
|
8
8
|
'DOLLAR': 'dollar',
|
|
9
9
|
'CUSTOM_CURRENCY': 'custom_currency'
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
const DATE_TYPES = {
|
|
12
12
|
'D/M/YYYY': 'D/M/YYYY',
|
|
13
13
|
'D/M/YYYY HH:mm': 'D/M/YYYY HH:mm',
|
|
14
14
|
'M/D/YYYY': 'M/D/YY',
|
|
@@ -16,7 +16,7 @@ var DATE_TYPES = {
|
|
|
16
16
|
'YYYY-MM-DD': 'YYYY-MM-DD',
|
|
17
17
|
'YYYY-MM-DD HH:mm': 'YYYY-MM-DD HH:mm'
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const SIMPLE_CELL_COLUMNS = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.CTIME, CellType.MTIME, CellType.AUTO_NUMBER, CellType.URL, CellType.EMAIL, CellType.DURATION, CellType.CHECKBOX, CellType.RATE];
|
|
20
|
+
const ARRAY_FORMAT_COLUMNS = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
|
|
21
|
+
const SIMPLE_CELL_FORMULA_RESULTS = [FORMULA_RESULT_TYPE.NUMBER, FORMULA_RESULT_TYPE.STRING, FORMULA_RESULT_TYPE.DATE, FORMULA_RESULT_TYPE.BOOL];
|
|
22
22
|
export { CellType, NUMBER_TYPES, DATE_TYPES, FORMULA_RESULT_TYPE, SIMPLE_CELL_COLUMNS, ARRAY_FORMAT_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS };
|
package/lib/data/dtable-value.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const DTABLE_VALUE = {
|
|
2
2
|
'tables': [{
|
|
3
3
|
'_id': '0000',
|
|
4
4
|
'name': 'Table1',
|
|
@@ -2709,7 +2709,7 @@ var DTABLE_VALUE = {
|
|
|
2709
2709
|
'header_settings': {}
|
|
2710
2710
|
}]
|
|
2711
2711
|
};
|
|
2712
|
-
|
|
2712
|
+
const DEPARTMENTS = [{
|
|
2713
2713
|
id: 1,
|
|
2714
2714
|
id_in_org: 1,
|
|
2715
2715
|
name: '海文互知',
|
|
@@ -2728,7 +2728,7 @@ var DEPARTMENTS = [{
|
|
|
2728
2728
|
org_id: -1,
|
|
2729
2729
|
parent_id: 1
|
|
2730
2730
|
}];
|
|
2731
|
-
|
|
2731
|
+
const COLLABORATORS = [{
|
|
2732
2732
|
'avatar_url': 'https://dev.seatable.cn/image-view/avatars/0/0/916e1e9e7c6184061cb7d96a680292/resized/80/de58ef113a311d390934b06ceafd77cf.png',
|
|
2733
2733
|
'contact_email': '',
|
|
2734
2734
|
'email': 'anbing@1.com',
|
|
@@ -2757,7 +2757,7 @@ var COLLABORATORS = [{
|
|
|
2757
2757
|
'name_pinyin': 'an\'bing',
|
|
2758
2758
|
'id': 'W-00009'
|
|
2759
2759
|
}];
|
|
2760
|
-
|
|
2760
|
+
const SIGN_CONFIG = {
|
|
2761
2761
|
server: 'https://dev.seatable.cn',
|
|
2762
2762
|
workspaceID: 3,
|
|
2763
2763
|
dtableUuid: '8327efbf-c9ff-4a14-9010-00e801a7e295'
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
var _CellType$DEFAULT$Cel;
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { CellType } from '../constants';
|
|
5
3
|
import CheckboxFormatter from '../CheckboxFormatter';
|
|
@@ -23,4 +21,27 @@ import EmailFormatter from '../EmailFormatter';
|
|
|
23
21
|
import DurationFormatter from '../DurationFormatter';
|
|
24
22
|
import RateFormatter from '../RateFormatter';
|
|
25
23
|
import ButtonFormatter from '../ButtonFormatter';
|
|
26
|
-
export default
|
|
24
|
+
export default {
|
|
25
|
+
[CellType.DEFAULT]: /*#__PURE__*/React.createElement(TextCellFormatter, null),
|
|
26
|
+
[CellType.TEXT]: /*#__PURE__*/React.createElement(TextCellFormatter, null),
|
|
27
|
+
[CellType.CHECKBOX]: /*#__PURE__*/React.createElement(CheckboxFormatter, null),
|
|
28
|
+
[CellType.LONG_TEXT]: /*#__PURE__*/React.createElement(SimpleLongTextFormatter, null),
|
|
29
|
+
[CellType.SINGLE_SELECT]: /*#__PURE__*/React.createElement(SingleSelectFormatter, null),
|
|
30
|
+
[CellType.IMAGE]: /*#__PURE__*/React.createElement(ImageFormatter, null),
|
|
31
|
+
[CellType.FILE]: /*#__PURE__*/React.createElement(FileFormatter, null),
|
|
32
|
+
[CellType.MULTIPLE_SELECT]: /*#__PURE__*/React.createElement(MultipleSelectFormatter, null),
|
|
33
|
+
[CellType.COLLABORATOR]: /*#__PURE__*/React.createElement(CollaboratorFormatter, null),
|
|
34
|
+
[CellType.NUMBER]: /*#__PURE__*/React.createElement(NumberFormatter, null),
|
|
35
|
+
[CellType.DATE]: /*#__PURE__*/React.createElement(DateFormatter, null),
|
|
36
|
+
[CellType.CREATOR]: /*#__PURE__*/React.createElement(CreatorFormatter, null),
|
|
37
|
+
[CellType.CTIME]: /*#__PURE__*/React.createElement(CTimeFormatter, null),
|
|
38
|
+
[CellType.LAST_MODIFIER]: /*#__PURE__*/React.createElement(LastModifierFormatter, null),
|
|
39
|
+
[CellType.MTIME]: /*#__PURE__*/React.createElement(MTimeFormatter, null),
|
|
40
|
+
[CellType.GEOLOCATION]: /*#__PURE__*/React.createElement(GeolocationFormatter, null),
|
|
41
|
+
[CellType.AUTO_NUMBER]: /*#__PURE__*/React.createElement(AutoNumberFormatter, null),
|
|
42
|
+
[CellType.URL]: /*#__PURE__*/React.createElement(UrlFormatter, null),
|
|
43
|
+
[CellType.EMAIL]: /*#__PURE__*/React.createElement(EmailFormatter, null),
|
|
44
|
+
[CellType.DURATION]: /*#__PURE__*/React.createElement(DurationFormatter, null),
|
|
45
|
+
[CellType.RATE]: /*#__PURE__*/React.createElement(RateFormatter, null),
|
|
46
|
+
[CellType.BUTTON]: /*#__PURE__*/React.createElement(ButtonFormatter, null)
|
|
47
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
var _objectSpread2;
|
|
4
1
|
import React from 'react';
|
|
5
2
|
import { CellType } from '../constants';
|
|
6
3
|
import BaseFormatterConfig from './base-formatter-config';
|
|
7
4
|
import LinkFormatter from '../LinkFormatter';
|
|
8
5
|
import FormulaFormatter from '../FormulaFormatter';
|
|
9
|
-
|
|
6
|
+
const FormatterConfig = {
|
|
7
|
+
...BaseFormatterConfig,
|
|
8
|
+
[CellType.FORMULA]: /*#__PURE__*/React.createElement(FormulaFormatter, null),
|
|
9
|
+
[CellType.LINK]: /*#__PURE__*/React.createElement(LinkFormatter, null)
|
|
10
|
+
};
|
|
10
11
|
export default FormatterConfig;
|
package/lib/lang/index.js
CHANGED
|
@@ -2,16 +2,16 @@ import de from '../locals/de';
|
|
|
2
2
|
import en from '../locals/en';
|
|
3
3
|
import fr from '../locals/fr';
|
|
4
4
|
import zh_CN from '../locals/zh-CN';
|
|
5
|
-
|
|
5
|
+
let langData = {
|
|
6
6
|
'de': de,
|
|
7
7
|
'en': en,
|
|
8
8
|
'fr': fr,
|
|
9
9
|
'zh-cn': zh_CN
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const LANGUAGE = 'en';
|
|
12
|
+
let LANGUAGE_MAP = langData[LANGUAGE];
|
|
13
13
|
export function setLocale(args) {
|
|
14
|
-
|
|
14
|
+
let lang = typeof args === 'string' ? args : LANGUAGE;
|
|
15
15
|
LANGUAGE_MAP = langData[lang] || langData[LANGUAGE];
|
|
16
16
|
}
|
|
17
17
|
export function getLocale(key, def) {
|
|
@@ -26,14 +26,14 @@ export function substitute(str, obj) {
|
|
|
26
26
|
if (str.indexOf('{') < 0) {
|
|
27
27
|
return str;
|
|
28
28
|
}
|
|
29
|
-
return str.replace(/\\?\{([^{}]+)\}/g,
|
|
29
|
+
return str.replace(/\\?\{([^{}]+)\}/g, (match, name) => {
|
|
30
30
|
if (match.charAt(0) === '\\') {
|
|
31
31
|
return match.slice(1);
|
|
32
32
|
}
|
|
33
33
|
return obj[name] === null || obj[name] === undefined ? '' : obj[name];
|
|
34
34
|
});
|
|
35
35
|
} else if (typeof str === 'function') {
|
|
36
|
-
|
|
36
|
+
let val = str(obj);
|
|
37
37
|
if (val === obj && typeof val === 'object') {
|
|
38
38
|
val = Object.assign({}, obj);
|
|
39
39
|
}
|
package/lib/locals/de.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const de = {};
|
|
2
2
|
export default de;
|
package/lib/locals/en.js
CHANGED
package/lib/locals/fr.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const fr = {};
|
|
2
2
|
export default fr;
|
package/lib/locals/zh-CN.js
CHANGED