dtable-ui-component 6.0.2 → 6.0.4
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/ButtonFormatter/index.js +8 -2
- package/lib/CheckboxEditor/index.css +8 -20
- package/lib/CheckboxEditor/index.js +98 -35
- package/lib/CheckboxFormatter/index.css +5 -0
- package/lib/CheckboxFormatter/index.js +9 -15
- package/lib/CollaboratorEditor/index.css +12 -35
- package/lib/CollaboratorEditor/index.js +18 -212
- package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +27 -30
- package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
- package/lib/CollaboratorItem/index.css +7 -1
- package/lib/CollaboratorItem/index.js +6 -2
- package/lib/Comment/body/comment.js +190 -0
- package/lib/Comment/body/index.css +95 -0
- package/lib/Comment/body/index.js +32 -0
- package/lib/Comment/footer/btns/index.css +40 -0
- package/lib/Comment/footer/btns/index.js +113 -0
- package/lib/Comment/footer/index.css +157 -0
- package/lib/Comment/footer/index.js +169 -0
- package/lib/Comment/footer/input/index.css +52 -0
- package/lib/Comment/footer/input/index.js +448 -0
- package/lib/Comment/footer/input/participant/index.css +0 -0
- package/lib/Comment/footer/input/participant/index.js +53 -0
- package/lib/Comment/footer/participants/index.css +22 -0
- package/lib/Comment/footer/participants/index.js +68 -0
- package/lib/Comment/footer/participants/participant/index.css +5 -0
- package/lib/Comment/footer/participants/participant/index.js +32 -0
- package/lib/Comment/footer/participants/participant-select/index.css +104 -0
- package/lib/Comment/footer/participants/participant-select/index.js +182 -0
- package/lib/Comment/index.css +19 -0
- package/lib/Comment/index.js +304 -0
- package/lib/Comment/model.js +25 -0
- package/lib/Comment/utils/common.js +62 -0
- package/lib/Comment/utils/index.js +27 -0
- package/lib/Comment/utils/utilities.js +176 -0
- package/lib/DTableColorPicker/index.css +1 -1
- package/lib/DTableCustomizeSelect/index.js +2 -2
- package/lib/DTableFiltersPopover/utils/index.js +1 -7
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
- package/lib/DTableGroupSelect/index.js +3 -3
- package/lib/DTableSelect/index.js +3 -1
- package/lib/DateEditor/index.js +14 -51
- package/lib/DateEditor/pc-date-editor-popover.js +149 -12
- package/lib/{common/delete-tip.js → DeleteTip/index.js} +12 -16
- package/lib/Department-editor/department-single-select.js +1 -1
- package/lib/Department-editor/index.js +3 -4
- package/lib/DepartmentSingleSelectFormatter/index.js +3 -2
- package/lib/DigitalSignEditor/constants.js +7 -0
- package/lib/DigitalSignEditor/index.css +69 -0
- package/lib/DigitalSignEditor/index.js +182 -0
- package/lib/DigitalSignEditor/service.js +39 -0
- package/lib/DigitalSignEditor/signature-board/index.css +35 -0
- package/lib/DigitalSignEditor/signature-board/index.js +135 -0
- package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
- package/lib/DigitalSignEditor/utils.js +29 -0
- package/lib/DurationEditor/index.js +110 -0
- package/lib/EmailEditor/index.js +58 -0
- package/lib/FileEditor/addition-previewer/index.css +1 -0
- package/lib/FileEditor/addition-previewer/index.js +52 -0
- package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
- package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
- package/lib/FileEditor/constants.js +7 -0
- package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
- package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
- package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
- package/lib/FileEditor/files-previewer/index.css +56 -0
- package/lib/FileEditor/files-previewer/index.js +277 -0
- package/lib/FileEditor/index.css +6 -0
- package/lib/FileEditor/index.js +258 -11
- package/lib/FileEditor/utils.js +22 -0
- package/lib/FileItemFormatter/index.js +19 -20
- package/lib/FileUploader/index.css +9 -0
- package/lib/FileUploader/index.js +268 -14
- package/lib/FormulaFormatter/cell-value-validator.js +17 -17
- package/lib/FormulaFormatter/index.js +2 -1
- package/lib/FormulaFormatter/utils.js +0 -31
- package/lib/GeolocationEditor/country-editor.js +319 -0
- package/lib/GeolocationEditor/index.css +641 -0
- package/lib/GeolocationEditor/index.js +240 -0
- package/lib/GeolocationEditor/location-editor.js +368 -0
- package/lib/GeolocationEditor/map-editor/index.js +456 -0
- package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
- package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
- package/lib/GeolocationEditor/map-editor-utils.js +153 -0
- package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
- package/lib/GeolocationEditor/parse-geolocation.js +282 -0
- package/lib/GeolocationEditor/province-city-editor.js +292 -0
- package/lib/GeolocationEditor/province-editor.js +226 -0
- package/lib/GeolocationEditor/selector-header-item.js +28 -0
- package/lib/GeolocationEditor/selector-list.js +33 -0
- package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
- package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
- package/lib/ImageEditor/addition-previewer/index.css +106 -0
- package/lib/ImageEditor/addition-previewer/index.js +63 -0
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
- package/lib/ImageEditor/constants.js +7 -0
- package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
- package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
- package/lib/ImageEditor/images-previewer/index.css +18 -0
- package/lib/ImageEditor/images-previewer/index.js +140 -0
- package/lib/ImageEditor/index.css +24 -0
- package/lib/ImageEditor/index.js +194 -0
- package/lib/ImageFormatter/images-lazy-load.js +4 -2
- package/lib/ImageFormatter/index.js +8 -3
- package/lib/ImageThumbnail/index.css +20 -0
- package/lib/ImageThumbnail/index.js +137 -0
- package/lib/LinkEditor/index.js +2 -3
- package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
- package/lib/MultipleSelectEditor/index.js +16 -177
- package/lib/NumberEditor/index.js +63 -77
- package/lib/RoleStatusEditor/index.css +0 -2
- package/lib/RowExpandDialog/body/index.css +21 -0
- package/lib/RowExpandDialog/body/index.js +262 -0
- package/lib/RowExpandDialog/column-content/index.css +48 -0
- package/lib/RowExpandDialog/column-content/index.js +50 -0
- package/lib/RowExpandDialog/header/index.css +31 -0
- package/lib/RowExpandDialog/header/index.js +55 -0
- package/lib/RowExpandDialog/index.css +28 -0
- package/lib/RowExpandDialog/index.js +237 -0
- package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
- package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
- package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
- package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +104 -0
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
- package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
- package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
- package/lib/RowExpandEditor/RowExpandFileEditor/index.js +148 -0
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
- package/lib/RowExpandEditor/RowExpandImageEditor/index.css +11 -0
- package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +123 -0
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +247 -0
- package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
- package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
- package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +206 -0
- package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
- package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
- package/lib/RowExpandEditor/constants.js +44 -0
- package/lib/RowExpandEditor/index.css +0 -0
- package/lib/RowExpandEditor/index.js +32 -0
- package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
- package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
- package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +12 -13
- package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +5 -5
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +2 -2
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +20 -20
- package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
- package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
- package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
- package/lib/RowExpandFormatter/constants.js +61 -0
- package/lib/RowExpandFormatter/index.css +28 -3
- package/lib/RowExpandFormatter/index.js +113 -131
- package/lib/SimpleLongTextFormatter/widgets/longTextEditor.css +2 -2
- package/lib/SingleSelectEditor/index.js +16 -156
- package/lib/SvgIcon/index.css +11 -0
- package/lib/SvgIcon/index.js +29 -0
- package/lib/TextEditor/index.js +112 -42
- package/lib/UploadProgress/index.js +38 -0
- package/lib/UrlEditor/index.js +61 -0
- package/lib/common/editor-base.js +52 -0
- package/lib/constants/file.js +96 -0
- package/lib/constants/index.js +27 -15
- package/lib/constants/key-codes.js +109 -0
- package/lib/css/cell-editor.css +18 -2
- package/lib/formatterConfig/base-formatter-config.js +23 -23
- package/lib/formatterConfig/index.js +3 -3
- package/lib/hooks/index.js +16 -0
- package/lib/index.js +81 -46
- package/lib/lang/index.js +19 -16
- package/lib/locales/de.json +167 -0
- package/lib/locales/en.json +167 -0
- package/lib/locales/es.json +167 -0
- package/lib/locales/fr.json +167 -0
- package/lib/locales/pt.json +167 -0
- package/lib/locales/ru.json +167 -0
- package/lib/locales/zh-CN.json +167 -0
- package/lib/select-editor/index.js +6 -6
- package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
- package/lib/select-editor/pc-select-editor/index.css +85 -0
- package/lib/select-editor/pc-select-editor/index.js +295 -0
- package/lib/toaster/toast.js +19 -15
- package/lib/utils/cell-comparer.js +35 -0
- package/lib/utils/cell.js +55 -0
- package/lib/utils/column-utils.js +25 -0
- package/lib/utils/editor-utils.js +1 -6
- package/lib/utils/get-event-transfer.js +75 -0
- package/lib/utils/hotkey.js +37 -0
- package/lib/utils/object-utils.js +61 -0
- package/lib/utils/url.js +127 -8
- package/lib/utils/utils.js +119 -2
- package/package.json +4 -3
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
- package/lib/FileEditor/pc-files-addition/index.js +0 -1
- package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
- package/lib/FileEditor/pc-files-preview/index.js +0 -1
- package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
- package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
- package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
- package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
- package/lib/FileItemFormatter/utils.js +0 -99
- package/lib/MultipleSelectEditor/index.css +0 -9
- package/lib/RowExpandLinkFormatter/utils.js +0 -71
- package/lib/RowExpandUrlFormatter/index.css +0 -1
- package/lib/SingleSelectEditor/index.css +0 -14
- package/lib/common/modal-portal.js +0 -26
- package/lib/locals/de.js +0 -103
- package/lib/locals/en.js +0 -104
- package/lib/locals/es.js +0 -103
- package/lib/locals/fr.js +0 -103
- package/lib/locals/pt.js +0 -103
- package/lib/locals/ru.js +0 -103
- package/lib/locals/zh-CN.js +0 -104
- package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
- package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
- /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
- /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
- /package/lib/{common/delete-tip.css → DeleteTip/index.css} +0 -0
- /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
- /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
- /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _reactstrap = require("reactstrap");
|
|
11
|
+
var _lang = require("../../lang");
|
|
12
|
+
var _DTableSearchInput = _interopRequireDefault(require("../../DTableSearchInput"));
|
|
13
|
+
var _constants = require("../../constants");
|
|
14
|
+
require("./index.css");
|
|
15
|
+
class PCSelectEditor extends _react.default.Component {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
this.onHotKey = e => {
|
|
19
|
+
if (e.keyCode === _constants.KeyCodes.Enter) {
|
|
20
|
+
this.onEnter(e);
|
|
21
|
+
} else if (e.keyCode === _constants.KeyCodes.UpArrow) {
|
|
22
|
+
this.onUpArrow(e);
|
|
23
|
+
} else if (e.keyCode === _constants.KeyCodes.DownArrow) {
|
|
24
|
+
this.onDownArrow(e);
|
|
25
|
+
} else if (e.keyCode === _constants.KeyCodes.Tab) {
|
|
26
|
+
if (this.props.onPressTab) {
|
|
27
|
+
this.props.onPressTab(e);
|
|
28
|
+
}
|
|
29
|
+
} else if (e.keyCode === _constants.KeyCodes.Escape) {
|
|
30
|
+
if (this.props.isInModal) {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
this.props.onClose && this.props.onClose();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.onEnter = e => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
let option;
|
|
39
|
+
const {
|
|
40
|
+
isSupportNewOption
|
|
41
|
+
} = this.props;
|
|
42
|
+
if (this.filteredOptions.length === 1) {
|
|
43
|
+
option = this.filteredOptions[0];
|
|
44
|
+
} else if (this.state.highlightIndex > -1) {
|
|
45
|
+
option = this.filteredOptions[this.state.highlightIndex];
|
|
46
|
+
}
|
|
47
|
+
if (option) {
|
|
48
|
+
this.onOptionItemToggle(option);
|
|
49
|
+
} else {
|
|
50
|
+
const {
|
|
51
|
+
searchValue
|
|
52
|
+
} = this.state;
|
|
53
|
+
if (searchValue && isSupportNewOption && this.filteredOptions.length === 0) {
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
this.onAddNewOption();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
this.onUpArrow = e => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
let {
|
|
63
|
+
highlightIndex,
|
|
64
|
+
maxItemNum,
|
|
65
|
+
itemHeight
|
|
66
|
+
} = this.state;
|
|
67
|
+
if (highlightIndex > 0) {
|
|
68
|
+
this.setState({
|
|
69
|
+
highlightIndex: highlightIndex - 1
|
|
70
|
+
}, () => {
|
|
71
|
+
if (highlightIndex < this.filteredOptions.length - maxItemNum) {
|
|
72
|
+
this.container.scrollTop -= itemHeight;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
this.onDownArrow = e => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
let {
|
|
81
|
+
highlightIndex,
|
|
82
|
+
maxItemNum,
|
|
83
|
+
itemHeight
|
|
84
|
+
} = this.state;
|
|
85
|
+
if (highlightIndex < this.filteredOptions.length - 1) {
|
|
86
|
+
this.setState({
|
|
87
|
+
highlightIndex: highlightIndex + 1
|
|
88
|
+
}, () => {
|
|
89
|
+
if (highlightIndex >= maxItemNum) {
|
|
90
|
+
this.container.scrollTop += itemHeight;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
this.onValueChanged = searchValue => {
|
|
96
|
+
const {
|
|
97
|
+
searchValue: oldSearchVal
|
|
98
|
+
} = this.state;
|
|
99
|
+
const {
|
|
100
|
+
options
|
|
101
|
+
} = this.props;
|
|
102
|
+
if (oldSearchVal === searchValue) return;
|
|
103
|
+
this.setState({
|
|
104
|
+
searchValue
|
|
105
|
+
});
|
|
106
|
+
let val = searchValue.toLowerCase();
|
|
107
|
+
this.filteredOptions = val ? options.filter(item => item.name && item.name.toLowerCase().indexOf(val) > -1) : options;
|
|
108
|
+
this.setState({
|
|
109
|
+
highlightIndex: this.filteredOptions.length > 0 ? 0 : -1
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
this.onAddNewOption = () => {
|
|
113
|
+
let name = this.state.searchValue.trim();
|
|
114
|
+
this.props.onAddNewOption(name);
|
|
115
|
+
};
|
|
116
|
+
this.onOptionItemToggle = item => {
|
|
117
|
+
this.props.onCommit(item);
|
|
118
|
+
};
|
|
119
|
+
this.onMenuMouseEnter = index => {
|
|
120
|
+
this.setState({
|
|
121
|
+
highlightIndex: index
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
this.onMenuMouseLeave = index => {
|
|
125
|
+
this.timer = setTimeout(() => {
|
|
126
|
+
if (this.state.highlightIndex === index) {
|
|
127
|
+
this.setState({
|
|
128
|
+
highlightIndex: -1
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}, 300);
|
|
132
|
+
};
|
|
133
|
+
this.getOptionStyle = option => {
|
|
134
|
+
const {
|
|
135
|
+
optionWidth
|
|
136
|
+
} = this.props;
|
|
137
|
+
const textColor = option.textColor || null;
|
|
138
|
+
return {
|
|
139
|
+
display: 'inline-block',
|
|
140
|
+
padding: '0px 10px',
|
|
141
|
+
height: '20px',
|
|
142
|
+
lineHeight: '20px',
|
|
143
|
+
borderRadius: '10px',
|
|
144
|
+
fontSize: '13px',
|
|
145
|
+
backgroundColor: option.color,
|
|
146
|
+
color: textColor,
|
|
147
|
+
maxWidth: optionWidth || 138
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
this.onKeyDown = e => {
|
|
151
|
+
if (e.keyCode === _constants.KeyCodes.ChineseInputMethod || e.keyCode === _constants.KeyCodes.Enter || e.keyCode === _constants.KeyCodes.LeftArrow || e.keyCode === _constants.KeyCodes.RightArrow) {
|
|
152
|
+
e.stopPropagation();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
this.getMaxItemNum = () => {
|
|
156
|
+
let selectContainerStyle = getComputedStyle(this.container, null);
|
|
157
|
+
let selectItemStyle = getComputedStyle(this.selectItem, null);
|
|
158
|
+
let maxSelectItemNum = Math.floor(parseInt(selectContainerStyle.maxHeight) / parseInt(selectItemStyle.height));
|
|
159
|
+
return maxSelectItemNum - 1;
|
|
160
|
+
};
|
|
161
|
+
this.state = {
|
|
162
|
+
searchValue: '',
|
|
163
|
+
highlightIndex: -1,
|
|
164
|
+
maxItemNum: 0,
|
|
165
|
+
itemHeight: 0
|
|
166
|
+
};
|
|
167
|
+
this.filteredOptions = props.options;
|
|
168
|
+
this.timer = null;
|
|
169
|
+
this.parent = null;
|
|
170
|
+
this.ref = null;
|
|
171
|
+
this.container = null;
|
|
172
|
+
this.selectItem = null;
|
|
173
|
+
}
|
|
174
|
+
componentDidMount() {
|
|
175
|
+
if (this.props.isInModal && this.parent) {
|
|
176
|
+
if (this.parent.getBoundingClientRect().top > 330) {
|
|
177
|
+
this.ref.style.top = '-200px';
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const {
|
|
181
|
+
bottom
|
|
182
|
+
} = this.ref.getBoundingClientRect();
|
|
183
|
+
if (bottom > window.innerHeight) {
|
|
184
|
+
this.ref.style.top = parseInt(this.ref.style.top) - bottom + window.innerHeight + 'px';
|
|
185
|
+
}
|
|
186
|
+
if (this.container && this.selectItem) {
|
|
187
|
+
this.setState({
|
|
188
|
+
maxItemNum: this.getMaxItemNum(),
|
|
189
|
+
itemHeight: parseInt(getComputedStyle(this.selectItem, null).height)
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
document.addEventListener('keydown', this.onHotKey, true);
|
|
193
|
+
}
|
|
194
|
+
componentWillUnmount() {
|
|
195
|
+
document.removeEventListener('keydown', this.onHotKey, true);
|
|
196
|
+
if (this.timer) {
|
|
197
|
+
clearTimeout(this.timer);
|
|
198
|
+
this.timer = null;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
render() {
|
|
202
|
+
const {
|
|
203
|
+
isInModal,
|
|
204
|
+
className,
|
|
205
|
+
value,
|
|
206
|
+
column,
|
|
207
|
+
valueKey,
|
|
208
|
+
isSupportNewOption,
|
|
209
|
+
target,
|
|
210
|
+
classNamePrefix
|
|
211
|
+
} = this.props;
|
|
212
|
+
const {
|
|
213
|
+
searchValue,
|
|
214
|
+
highlightIndex
|
|
215
|
+
} = this.state;
|
|
216
|
+
|
|
217
|
+
// maxWidth = single-selects-container's width - single-selects-container's padding-left and padding-right - single-select-container's padding-left - single-select-check-icon's width - The gap between the single-select-check-icon and single-select-name or scroll's width
|
|
218
|
+
// maxWidth = column.width > 200 ? column.width - 20 - 12 - 20 - 10 : 200 - 20 - 12 - 20 - 10
|
|
219
|
+
// maxWidth = column.width > 200 ? column.width - 62 : 200 - 62
|
|
220
|
+
let maxWidth = isInModal ? 250 : (column === null || column === void 0 ? void 0 : column.width) > 200 ? column.width - 62 : 138;
|
|
221
|
+
const dom = /*#__PURE__*/_react.default.createElement("div", {
|
|
222
|
+
className: (0, _classnames.default)('dtable-ui-editor-container dtable-ui-select-editor-container', className, {
|
|
223
|
+
["".concat(classNamePrefix, "-select-editor-container")]: classNamePrefix
|
|
224
|
+
}),
|
|
225
|
+
ref: ref => this.ref = ref
|
|
226
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
227
|
+
className: "select-options-search"
|
|
228
|
+
}, /*#__PURE__*/_react.default.createElement(_DTableSearchInput.default, {
|
|
229
|
+
placeholder: (0, _lang.getLocale)('Search_option'),
|
|
230
|
+
onKeyDown: this.onKeyDown,
|
|
231
|
+
onChange: this.onValueChanged,
|
|
232
|
+
autoFocus: true
|
|
233
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
234
|
+
className: "select-options-container",
|
|
235
|
+
ref: ref => this.container = ref
|
|
236
|
+
}, this.filteredOptions.length > 0 && this.filteredOptions.map((option, index) => {
|
|
237
|
+
let optionStyle = this.getOptionStyle(option);
|
|
238
|
+
optionStyle = {
|
|
239
|
+
...optionStyle,
|
|
240
|
+
maxWidth
|
|
241
|
+
};
|
|
242
|
+
let isSelected = value.includes(option[valueKey]);
|
|
243
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
244
|
+
key: option.id,
|
|
245
|
+
className: "select-option-item",
|
|
246
|
+
ref: ref => this.selectItem = ref
|
|
247
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
248
|
+
className: (0, _classnames.default)('select-option-item-container', {
|
|
249
|
+
'select-option-item-container-highlight': index === highlightIndex
|
|
250
|
+
}),
|
|
251
|
+
onMouseDown: this.onOptionItemToggle.bind(this, option),
|
|
252
|
+
onMouseEnter: this.onMenuMouseEnter.bind(this, index),
|
|
253
|
+
onMouseLeave: this.onMenuMouseLeave.bind(this, index)
|
|
254
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
255
|
+
className: "option-info"
|
|
256
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
257
|
+
className: "option-name",
|
|
258
|
+
style: optionStyle,
|
|
259
|
+
title: option.name
|
|
260
|
+
}, option.name)), /*#__PURE__*/_react.default.createElement("div", {
|
|
261
|
+
className: "option-checked"
|
|
262
|
+
}, isSelected && /*#__PURE__*/_react.default.createElement("i", {
|
|
263
|
+
className: "dtable-font dtable-icon-check-mark"
|
|
264
|
+
}))));
|
|
265
|
+
}), this.filteredOptions.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
266
|
+
className: "dtable-ui-editor-no-search-result"
|
|
267
|
+
}, (0, _lang.getLocale)('No_options_available'))), isSupportNewOption && !!searchValue && /*#__PURE__*/_react.default.createElement("div", {
|
|
268
|
+
className: "select-options-add",
|
|
269
|
+
onClick: this.onAddNewOption
|
|
270
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
271
|
+
className: "dtable-font dtable-icon-add-table"
|
|
272
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Add_an_option'), ' ', searchValue)));
|
|
273
|
+
if (isInModal) {
|
|
274
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
275
|
+
ref: ref => this.parent = ref
|
|
276
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Popover, {
|
|
277
|
+
placement: "bottom-start",
|
|
278
|
+
isOpen: true,
|
|
279
|
+
target: target,
|
|
280
|
+
hideArrow: true,
|
|
281
|
+
fade: false,
|
|
282
|
+
className: (0, _classnames.default)('dtable-ui dtable-ui-row-expand-select-editor-popover', {
|
|
283
|
+
["".concat(classNamePrefix, "-select-editor-popover")]: classNamePrefix
|
|
284
|
+
})
|
|
285
|
+
}, dom));
|
|
286
|
+
}
|
|
287
|
+
return dom;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
PCSelectEditor.defaultProps = {
|
|
291
|
+
options: [],
|
|
292
|
+
value: [],
|
|
293
|
+
valueKey: 'id'
|
|
294
|
+
};
|
|
295
|
+
var _default = exports.default = PCSelectEditor;
|
package/lib/toaster/toast.js
CHANGED
|
@@ -12,19 +12,22 @@ const ANIMATION_DURATION = 240;
|
|
|
12
12
|
class Toast extends _react.default.PureComponent {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
|
+
this._isMounted = false;
|
|
15
16
|
this.state = {
|
|
16
|
-
isShown: true
|
|
17
|
-
height: 0
|
|
17
|
+
isShown: true
|
|
18
18
|
};
|
|
19
|
+
this.containerRef = /*#__PURE__*/_react.default.createRef();
|
|
19
20
|
this.close = event => {
|
|
20
21
|
if (event) {
|
|
21
22
|
event.nativeEvent.stopImmediatePropagation();
|
|
22
23
|
event.stopPropagation();
|
|
23
24
|
}
|
|
24
25
|
this.clearCloseTimer();
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
if (this._isMounted) {
|
|
27
|
+
this.setState({
|
|
28
|
+
isShown: false
|
|
29
|
+
});
|
|
30
|
+
}
|
|
28
31
|
};
|
|
29
32
|
this.startCloseTimer = () => {
|
|
30
33
|
if (this.props.duration) {
|
|
@@ -47,12 +50,12 @@ class Toast extends _react.default.PureComponent {
|
|
|
47
50
|
};
|
|
48
51
|
this.onRef = ref => {
|
|
49
52
|
if (ref === null) return;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
height
|
|
55
|
-
});
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
const {
|
|
55
|
+
height
|
|
56
|
+
} = ref.getBoundingClientRect();
|
|
57
|
+
this.containerRef.current.style.height = height + 'px';
|
|
58
|
+
}, 1);
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
componentDidUpdate(prevProps) {
|
|
@@ -64,9 +67,11 @@ class Toast extends _react.default.PureComponent {
|
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
componentDidMount() {
|
|
70
|
+
this._isMounted = true;
|
|
67
71
|
this.startCloseTimer();
|
|
68
72
|
}
|
|
69
73
|
componentWillUnmount() {
|
|
74
|
+
this._isMounted = false;
|
|
70
75
|
this.clearCloseTimer();
|
|
71
76
|
}
|
|
72
77
|
render() {
|
|
@@ -82,10 +87,9 @@ class Toast extends _react.default.PureComponent {
|
|
|
82
87
|
onMouseEnter: this.handleMouseEnter,
|
|
83
88
|
onMouseLeave: this.handleMouseLeave,
|
|
84
89
|
style: {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
90
|
+
zIndex: this.props.zIndex
|
|
91
|
+
},
|
|
92
|
+
ref: this.containerRef
|
|
89
93
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
90
94
|
ref: this.onRef,
|
|
91
95
|
style: {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isCellValueChanged = void 0;
|
|
8
|
+
var _dtableUtils = require("dtable-utils");
|
|
9
|
+
var _objectUtils = _interopRequireDefault(require("./object-utils"));
|
|
10
|
+
const isCellValueChanged = (oldVal, newVal, columnType) => {
|
|
11
|
+
if (oldVal === newVal) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (oldVal === undefined || oldVal === null) {
|
|
15
|
+
if (columnType === _dtableUtils.CellType.GEOLOCATION && (0, _dtableUtils.isEmptyObject)(newVal)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if ((columnType === _dtableUtils.CellType.DATE || columnType === _dtableUtils.CellType.NUMBER || columnType === _dtableUtils.CellType.AUTO_NUMBER) && newVal === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(newVal)) {
|
|
22
|
+
return newVal.length !== 0;
|
|
23
|
+
}
|
|
24
|
+
return newVal !== false && newVal !== '';
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(oldVal) && Array.isArray(newVal)) {
|
|
27
|
+
// [{}].toString(): [object Object]
|
|
28
|
+
return JSON.stringify(oldVal) !== JSON.stringify(newVal);
|
|
29
|
+
}
|
|
30
|
+
if (typeof oldVal === 'object' && typeof newVal === 'object' && newVal !== null) {
|
|
31
|
+
return !_objectUtils.default.isSameObject(oldVal, newVal);
|
|
32
|
+
}
|
|
33
|
+
return oldVal !== newVal;
|
|
34
|
+
};
|
|
35
|
+
exports.isCellValueChanged = isCellValueChanged;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isValidPosition = exports.isLongTextValueExceedLimit = exports.checkValueConformityFormat = exports.checkNumberValidation = void 0;
|
|
7
|
+
var _constants = require("../constants");
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
const checkValueConformityFormat = (columnData, value) => {
|
|
10
|
+
const {
|
|
11
|
+
format_specification_value,
|
|
12
|
+
format_check_type
|
|
13
|
+
} = columnData || {};
|
|
14
|
+
let isMatched = false;
|
|
15
|
+
if (format_check_type !== 'custom_format') {
|
|
16
|
+
const reg = _constants.FORMAT_REG_EXP_LIST[format_check_type];
|
|
17
|
+
isMatched = reg && reg.test((0, _utils.getTrimmedString)(value));
|
|
18
|
+
} else {
|
|
19
|
+
const reg = new RegExp(format_specification_value);
|
|
20
|
+
isMatched = reg.test((0, _utils.getTrimmedString)(value));
|
|
21
|
+
}
|
|
22
|
+
return isMatched;
|
|
23
|
+
};
|
|
24
|
+
exports.checkValueConformityFormat = checkValueConformityFormat;
|
|
25
|
+
const checkNumberValidation = (columnData, value) => {
|
|
26
|
+
const {
|
|
27
|
+
format_max_value,
|
|
28
|
+
format_min_value
|
|
29
|
+
} = columnData || {};
|
|
30
|
+
const num = parseFloat(value);
|
|
31
|
+
if (isNaN(num) || !num && num !== 0) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if ((format_max_value || format_max_value === 0) && num > format_max_value) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if ((format_min_value || format_min_value === 0) && num < format_min_value) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
exports.checkNumberValidation = checkNumberValidation;
|
|
43
|
+
const isLongTextValueExceedLimit = value => {
|
|
44
|
+
if (!value) return false;
|
|
45
|
+
if (typeof value === 'string') return value.length >= _constants.LONG_TEXT_LENGTH_LIMIT;
|
|
46
|
+
const {
|
|
47
|
+
text
|
|
48
|
+
} = value || {};
|
|
49
|
+
return text ? text.length >= _constants.LONG_TEXT_LENGTH_LIMIT : false;
|
|
50
|
+
};
|
|
51
|
+
exports.isLongTextValueExceedLimit = isLongTextValueExceedLimit;
|
|
52
|
+
const isValidPosition = (lng, lat) => {
|
|
53
|
+
return (lng || lng === 0) && (lat || lat === 0);
|
|
54
|
+
};
|
|
55
|
+
exports.isValidPosition = isValidPosition;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isEnableCheckFormat = exports.getDateColumnFormat = void 0;
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
|
+
const isEnableCheckFormat = column => {
|
|
9
|
+
if (!column) return false;
|
|
10
|
+
const {
|
|
11
|
+
data
|
|
12
|
+
} = column;
|
|
13
|
+
const {
|
|
14
|
+
enable_check_format
|
|
15
|
+
} = data || {};
|
|
16
|
+
if (enable_check_format) return true;
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
exports.isEnableCheckFormat = isEnableCheckFormat;
|
|
20
|
+
const getDateColumnFormat = column => {
|
|
21
|
+
const format = column && column.data && column.data.format ? column.data.format : _dtableUtils.DEFAULT_DATE_FORMAT;
|
|
22
|
+
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
23
|
+
return format;
|
|
24
|
+
};
|
|
25
|
+
exports.getDateColumnFormat = getDateColumnFormat;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.initDateEditorLanguage = exports.getTrimmedString = exports.getSelectOptionItem = void 0;
|
|
7
7
|
const zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
8
8
|
const zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
9
9
|
const enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
@@ -63,11 +63,6 @@ const getSelectOptionItem = (options, optionId) => {
|
|
|
63
63
|
return options.find(option => option.id === optionId);
|
|
64
64
|
};
|
|
65
65
|
exports.getSelectOptionItem = getSelectOptionItem;
|
|
66
|
-
const isValidUrl = url => {
|
|
67
|
-
const reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
|
|
68
|
-
return reg.test(url);
|
|
69
|
-
};
|
|
70
|
-
exports.isValidUrl = isValidUrl;
|
|
71
66
|
const getTrimmedString = value => {
|
|
72
67
|
return typeof value === 'string' ? value.trim() : '';
|
|
73
68
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const HTML = 'text/html';
|
|
8
|
+
const TEXT = 'text/plain';
|
|
9
|
+
// const FILES = 'files';
|
|
10
|
+
|
|
11
|
+
function getType(transfer, type) {
|
|
12
|
+
if (!transfer.types || !transfer.types.length) {
|
|
13
|
+
// COMPAT: In IE 11, there is no `types` field but `getData('Text')`
|
|
14
|
+
// is supported`. (2017/06/23)
|
|
15
|
+
return type === TEXT ? transfer.getData('Text') || null : null;
|
|
16
|
+
}
|
|
17
|
+
return transfer.getData(type);
|
|
18
|
+
}
|
|
19
|
+
function getFiles(transfer) {
|
|
20
|
+
let files;
|
|
21
|
+
try {
|
|
22
|
+
// Get and normalize files if they exist.
|
|
23
|
+
if (transfer.items && transfer.items.length) {
|
|
24
|
+
files = Array.from(transfer.items).map(item => item.kind === 'file' ? item.getAsFile() : null).filter(exists => exists);
|
|
25
|
+
} else if (transfer.files && transfer.files.length) {
|
|
26
|
+
files = Array.from(transfer.files);
|
|
27
|
+
}
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if (transfer.files && transfer.files.length) {
|
|
30
|
+
files = Array.from(transfer.files);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return files;
|
|
34
|
+
}
|
|
35
|
+
function getEventTransfer(event) {
|
|
36
|
+
let html;
|
|
37
|
+
let text;
|
|
38
|
+
let files;
|
|
39
|
+
if (window.isMobile) {
|
|
40
|
+
if (window.dtableTransfer) {
|
|
41
|
+
text = window.dtableTransfer['TEXT'];
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
const transfer = event.dataTransfer || event.clipboardData;
|
|
45
|
+
html = getType(transfer, HTML);
|
|
46
|
+
text = getType(transfer, TEXT);
|
|
47
|
+
files = getFiles(transfer);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// paste html
|
|
51
|
+
if (html) {
|
|
52
|
+
return {
|
|
53
|
+
html,
|
|
54
|
+
text,
|
|
55
|
+
type: 'html'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// paste local picture or other files here
|
|
60
|
+
if (files && files.length) {
|
|
61
|
+
return {
|
|
62
|
+
'files': files,
|
|
63
|
+
type: 'files'
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// paste text
|
|
68
|
+
if (text) {
|
|
69
|
+
return {
|
|
70
|
+
text,
|
|
71
|
+
type: 'text'
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var _default = exports.default = getEventTransfer;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isSpace = exports.isShiftModEnter = exports.isShiftEnter = exports.isOptPageup = exports.isOptPagedown = exports.isModZ = exports.isModUp = exports.isModSlash = exports.isModShiftZ = exports.isModShiftG = exports.isModShiftDot = exports.isModShiftComma = exports.isModSemicolon = exports.isModS = exports.isModRight = exports.isModP = exports.isModOptionR = exports.isModOptionE = exports.isModLeft = exports.isModL = exports.isModG = exports.isModF = exports.isModDown = exports.isModDot = exports.isModComma = exports.isModC = exports.isModBackslash = exports.isEsc = exports.isEnter = void 0;
|
|
8
|
+
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
9
|
+
const isModC = exports.isModC = (0, _isHotkey.default)('mod+c');
|
|
10
|
+
const isModS = exports.isModS = (0, _isHotkey.default)('mod+s');
|
|
11
|
+
const isModZ = exports.isModZ = (0, _isHotkey.default)('mod+z');
|
|
12
|
+
const isModL = exports.isModL = (0, _isHotkey.default)('mod+l');
|
|
13
|
+
const isModF = exports.isModF = (0, _isHotkey.default)('mod+f');
|
|
14
|
+
const isModP = exports.isModP = (0, _isHotkey.default)('mod+p');
|
|
15
|
+
const isModG = exports.isModG = (0, _isHotkey.default)('mod+g');
|
|
16
|
+
const isModDot = exports.isModDot = (0, _isHotkey.default)('mod+.');
|
|
17
|
+
const isModComma = exports.isModComma = (0, _isHotkey.default)('mod+,');
|
|
18
|
+
const isModSlash = exports.isModSlash = (0, _isHotkey.default)('mod+/');
|
|
19
|
+
const isModBackslash = exports.isModBackslash = (0, _isHotkey.default)('mod+\'');
|
|
20
|
+
const isModSemicolon = exports.isModSemicolon = (0, _isHotkey.default)('mod+;');
|
|
21
|
+
const isModUp = exports.isModUp = (0, _isHotkey.default)('mod+up');
|
|
22
|
+
const isModDown = exports.isModDown = (0, _isHotkey.default)('mod+down');
|
|
23
|
+
const isModLeft = exports.isModLeft = (0, _isHotkey.default)('mod+left');
|
|
24
|
+
const isModRight = exports.isModRight = (0, _isHotkey.default)('mod+right');
|
|
25
|
+
const isModShiftZ = exports.isModShiftZ = (0, _isHotkey.default)('mod+shift+z');
|
|
26
|
+
const isModShiftG = exports.isModShiftG = (0, _isHotkey.default)('mod+shift+g');
|
|
27
|
+
const isModOptionR = exports.isModOptionR = (0, _isHotkey.default)('mod+option+r');
|
|
28
|
+
const isModOptionE = exports.isModOptionE = (0, _isHotkey.default)('mod+option+e');
|
|
29
|
+
const isModShiftDot = exports.isModShiftDot = (0, _isHotkey.default)('mod+shift+.');
|
|
30
|
+
const isModShiftComma = exports.isModShiftComma = (0, _isHotkey.default)('mod+shift+,');
|
|
31
|
+
const isShiftEnter = exports.isShiftEnter = (0, _isHotkey.default)('shift+enter');
|
|
32
|
+
const isShiftModEnter = exports.isShiftModEnter = (0, _isHotkey.default)('shift+mod+enter');
|
|
33
|
+
const isOptPageup = exports.isOptPageup = (0, _isHotkey.default)('opt+pageup');
|
|
34
|
+
const isOptPagedown = exports.isOptPagedown = (0, _isHotkey.default)('opt+pagedown');
|
|
35
|
+
const isSpace = exports.isSpace = (0, _isHotkey.default)('space');
|
|
36
|
+
const isEsc = exports.isEsc = (0, _isHotkey.default)('esc');
|
|
37
|
+
const isEnter = exports.isEnter = (0, _isHotkey.default)('enter');
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shallowCloneObject = exports.hasOwnProperty = exports.default = void 0;
|
|
7
|
+
class ObjectUtils {
|
|
8
|
+
static getDataType(data) {
|
|
9
|
+
let type = typeof data;
|
|
10
|
+
if (type !== 'object') {
|
|
11
|
+
return type;
|
|
12
|
+
}
|
|
13
|
+
return Object.prototype.toString.call(data).replace(/^\[object (\S+)\]$/, '$1');
|
|
14
|
+
}
|
|
15
|
+
static iterable(data) {
|
|
16
|
+
return ['Object', 'Array'].includes(this.getDataType(data));
|
|
17
|
+
}
|
|
18
|
+
static isObjectChanged(source, comparison) {
|
|
19
|
+
if (!this.iterable(source)) {
|
|
20
|
+
throw new Error("source should be a Object or Array , but got ".concat(this.getDataType(source)));
|
|
21
|
+
}
|
|
22
|
+
if (this.getDataType(source) !== this.getDataType(comparison)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const sourceKeys = Object.keys(source);
|
|
26
|
+
const comparisonKeys = Object.keys({
|
|
27
|
+
...source,
|
|
28
|
+
...comparison
|
|
29
|
+
});
|
|
30
|
+
if (sourceKeys.length !== comparisonKeys.length) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return comparisonKeys.some(key => {
|
|
34
|
+
if (this.iterable(source[key])) {
|
|
35
|
+
return this.isObjectChanged(source[key], comparison[key]);
|
|
36
|
+
} else {
|
|
37
|
+
return source[key] !== comparison[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
static isSameObject(source, comparison) {
|
|
42
|
+
if (!source || !comparison) return false;
|
|
43
|
+
return !this.isObjectChanged(source, comparison);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const hasOwnProperty = (obj, propertyKey) => {
|
|
47
|
+
if (!obj || !propertyKey) return false;
|
|
48
|
+
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
|
|
49
|
+
};
|
|
50
|
+
exports.hasOwnProperty = hasOwnProperty;
|
|
51
|
+
const shallowCloneObject = obj => {
|
|
52
|
+
const result = {};
|
|
53
|
+
for (const k in obj) {
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
|
55
|
+
result[k] = obj[k];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
exports.shallowCloneObject = shallowCloneObject;
|
|
61
|
+
var _default = exports.default = ObjectUtils;
|