dtable-ui-component 4.3.7 → 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.js +92 -103
- 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.js +141 -159
- package/lib/SelectOptionGroup/option.js +24 -40
- 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 +22 -43
- 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
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
function DtableSwitch(props) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const {
|
|
4
|
+
onChange,
|
|
5
|
+
checked,
|
|
6
|
+
placeholder,
|
|
7
|
+
disabled,
|
|
8
|
+
switchClassName
|
|
9
|
+
} = props;
|
|
8
10
|
return /*#__PURE__*/React.createElement("div", {
|
|
9
11
|
className: "dtable-switch position-relative ".concat(switchClassName || '')
|
|
10
12
|
}, /*#__PURE__*/React.createElement("label", {
|
package/lib/DateEditor/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
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, { Fragment } from 'react';
|
|
6
2
|
import MediaQuery from 'react-responsive';
|
|
7
3
|
import dayjs from 'dayjs';
|
|
@@ -9,122 +5,120 @@ import { getDateDisplayString } from 'dtable-utils';
|
|
|
9
5
|
import PCDateEditorPopover from './pc-date-editor-popover';
|
|
10
6
|
import MBDateEditorPopover from './mb-date-editor-popover';
|
|
11
7
|
import './index.css';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var defaultDateFormat = 'YYYY-MM-DD';
|
|
22
|
-
var dateFormat = column.data && column.data.format;
|
|
8
|
+
class DateEditor extends React.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.getDateFormat = () => {
|
|
12
|
+
let {
|
|
13
|
+
column
|
|
14
|
+
} = this.props;
|
|
15
|
+
let defaultDateFormat = 'YYYY-MM-DD';
|
|
16
|
+
let dateFormat = column.data && column.data.format;
|
|
23
17
|
return dateFormat || defaultDateFormat;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
this.onDateEditorToggle = () => {
|
|
20
|
+
const {
|
|
21
|
+
isReadOnly
|
|
22
|
+
} = this.props;
|
|
27
23
|
if (isReadOnly) {
|
|
28
24
|
return;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
isPopoverShow: !
|
|
26
|
+
this.setState({
|
|
27
|
+
isPopoverShow: !this.state.isPopoverShow
|
|
32
28
|
});
|
|
33
29
|
};
|
|
34
|
-
|
|
35
|
-
if (value !==
|
|
36
|
-
|
|
30
|
+
this.onValueChanged = value => {
|
|
31
|
+
if (value !== this.state.newValue) {
|
|
32
|
+
this.setState({
|
|
37
33
|
newValue: value
|
|
38
34
|
});
|
|
39
|
-
|
|
35
|
+
this.onCommit(value);
|
|
40
36
|
}
|
|
41
37
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
this.onCommit = newValue => {
|
|
39
|
+
let updated = {};
|
|
40
|
+
let {
|
|
41
|
+
column
|
|
42
|
+
} = this.props;
|
|
45
43
|
updated[column.key] = newValue;
|
|
46
|
-
|
|
44
|
+
this.props.onCommit(updated);
|
|
47
45
|
};
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
this.onClosePopover = () => {
|
|
47
|
+
this.setState({
|
|
50
48
|
isPopoverShow: false
|
|
51
49
|
});
|
|
52
50
|
};
|
|
53
|
-
|
|
51
|
+
this.state = {
|
|
54
52
|
isDateInit: false,
|
|
55
53
|
newValue: '',
|
|
56
54
|
isPopoverShow: false,
|
|
57
55
|
showHourAndMinute: false,
|
|
58
56
|
defaultCalendarValue: null
|
|
59
57
|
};
|
|
60
|
-
return _this;
|
|
61
58
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
key: "render",
|
|
79
|
-
value: function render() {
|
|
80
|
-
if (!this.state.isDateInit) {
|
|
81
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
82
|
-
className: "cell-editor date-editor"
|
|
83
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
className: "date-editor-container"
|
|
85
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
86
|
-
className: "control-form"
|
|
87
|
-
})));
|
|
88
|
-
}
|
|
89
|
-
var _this$props2 = this.props,
|
|
90
|
-
lang = _this$props2.lang,
|
|
91
|
-
column = _this$props2.column;
|
|
92
|
-
var _this$state = this.state,
|
|
93
|
-
newValue = _this$state.newValue,
|
|
94
|
-
isPopoverShow = _this$state.isPopoverShow,
|
|
95
|
-
dateFormat = _this$state.dateFormat,
|
|
96
|
-
showHourAndMinute = _this$state.showHourAndMinute;
|
|
59
|
+
componentDidMount() {
|
|
60
|
+
const {
|
|
61
|
+
value,
|
|
62
|
+
lang
|
|
63
|
+
} = this.props;
|
|
64
|
+
dayjs.locale(lang);
|
|
65
|
+
let dateFormat = this.getDateFormat();
|
|
66
|
+
this.setState({
|
|
67
|
+
isDateInit: true,
|
|
68
|
+
newValue: value,
|
|
69
|
+
dateFormat: dateFormat,
|
|
70
|
+
showHourAndMinute: dateFormat.indexOf('HH:mm') > -1
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
if (!this.state.isDateInit) {
|
|
97
75
|
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
-
className: "cell-editor
|
|
99
|
-
}, !isPopoverShow && /*#__PURE__*/React.createElement("div", {
|
|
100
|
-
className: "dtable-ui-date-editor-container"
|
|
76
|
+
className: "cell-editor date-editor"
|
|
101
77
|
}, /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
className: "
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}, /*#__PURE__*/React.createElement(PCDateEditorPopover, {
|
|
107
|
-
lang: lang,
|
|
108
|
-
value: newValue,
|
|
109
|
-
dateFormat: dateFormat,
|
|
110
|
-
showHourAndMinute: showHourAndMinute,
|
|
111
|
-
onValueChanged: this.onValueChanged
|
|
112
|
-
})), /*#__PURE__*/React.createElement(MediaQuery, {
|
|
113
|
-
query: '(max-width: 767.8px)'
|
|
114
|
-
}, /*#__PURE__*/React.createElement(MBDateEditorPopover, {
|
|
115
|
-
isReadOnly: this.props.isReadOnly,
|
|
116
|
-
lang: lang,
|
|
117
|
-
value: newValue,
|
|
118
|
-
dateFormat: dateFormat,
|
|
119
|
-
showHourAndMinute: showHourAndMinute,
|
|
120
|
-
column: column,
|
|
121
|
-
onValueChanged: this.onValueChanged,
|
|
122
|
-
onClosePopover: this.onClosePopover
|
|
123
|
-
}))));
|
|
78
|
+
className: "date-editor-container"
|
|
79
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
className: "control-form"
|
|
81
|
+
})));
|
|
124
82
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
83
|
+
let {
|
|
84
|
+
lang,
|
|
85
|
+
column
|
|
86
|
+
} = this.props;
|
|
87
|
+
let {
|
|
88
|
+
newValue,
|
|
89
|
+
isPopoverShow,
|
|
90
|
+
dateFormat,
|
|
91
|
+
showHourAndMinute
|
|
92
|
+
} = this.state;
|
|
93
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: "cell-editor dtable-ui-date-editor"
|
|
95
|
+
}, !isPopoverShow && /*#__PURE__*/React.createElement("div", {
|
|
96
|
+
className: "dtable-ui-date-editor-container"
|
|
97
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: "form-control",
|
|
99
|
+
onClick: this.onDateEditorToggle
|
|
100
|
+
}, getDateDisplayString(newValue, dateFormat))), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
|
|
101
|
+
query: '(min-width: 768px)'
|
|
102
|
+
}, /*#__PURE__*/React.createElement(PCDateEditorPopover, {
|
|
103
|
+
lang: lang,
|
|
104
|
+
value: newValue,
|
|
105
|
+
dateFormat: dateFormat,
|
|
106
|
+
showHourAndMinute: showHourAndMinute,
|
|
107
|
+
onValueChanged: this.onValueChanged
|
|
108
|
+
})), /*#__PURE__*/React.createElement(MediaQuery, {
|
|
109
|
+
query: '(max-width: 767.8px)'
|
|
110
|
+
}, /*#__PURE__*/React.createElement(MBDateEditorPopover, {
|
|
111
|
+
isReadOnly: this.props.isReadOnly,
|
|
112
|
+
lang: lang,
|
|
113
|
+
value: newValue,
|
|
114
|
+
dateFormat: dateFormat,
|
|
115
|
+
showHourAndMinute: showHourAndMinute,
|
|
116
|
+
column: column,
|
|
117
|
+
onValueChanged: this.onValueChanged,
|
|
118
|
+
onClosePopover: this.onClosePopover
|
|
119
|
+
}))));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
128
122
|
DateEditor.defaultProps = {
|
|
129
123
|
isReadOnly: false,
|
|
130
124
|
value: '',
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import _DatePicker from "antd-mobile/lib/date-picker";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
2
|
import React from 'react';
|
|
7
3
|
import dayjs from 'dayjs';
|
|
8
4
|
import Calendar from '@seafile/seafile-calendar';
|
|
@@ -12,79 +8,85 @@ import { initDateEditorLanguage } from '../../utils/editor-utils';
|
|
|
12
8
|
import MBEditorHeader from '../../MBEditorHeader';
|
|
13
9
|
import '@seafile/seafile-calendar/assets/index.css';
|
|
14
10
|
import './index.css';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _this;
|
|
20
|
-
_classCallCheck(this, DateEditorPopover);
|
|
21
|
-
_this = _super.call(this, props);
|
|
22
|
-
_this.handleHistaryBack = function (e) {
|
|
11
|
+
class DateEditorPopover extends React.PureComponent {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.handleHistaryBack = e => {
|
|
23
15
|
e.preventDefault();
|
|
24
|
-
|
|
16
|
+
this.closePopover();
|
|
25
17
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dateFormat
|
|
29
|
-
showHourAndMinute
|
|
30
|
-
|
|
18
|
+
this.handleDateChange = date => {
|
|
19
|
+
let {
|
|
20
|
+
dateFormat,
|
|
21
|
+
showHourAndMinute
|
|
22
|
+
} = this.props;
|
|
23
|
+
let newValue = dayjs(date);
|
|
31
24
|
if (showHourAndMinute) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
const {
|
|
26
|
+
datePickerValue
|
|
27
|
+
} = this.state;
|
|
28
|
+
const HM = datePickerValue.format('HH:mm');
|
|
29
|
+
const format = dateFormat.split(' ')[0]; // 'YYYY-MM-DD HH:mm'
|
|
30
|
+
const newDate = dayjs(date).format(format) + ' ' + HM;
|
|
36
31
|
newValue = dayjs(newDate);
|
|
37
32
|
}
|
|
38
|
-
|
|
33
|
+
this.setState({
|
|
39
34
|
datePickerValue: dayjs(date)
|
|
40
35
|
});
|
|
41
|
-
|
|
36
|
+
this.props.onValueChanged(newValue.format(dateFormat));
|
|
42
37
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
this.handleTimeChange = time => {
|
|
39
|
+
const {
|
|
40
|
+
datePickerValue
|
|
41
|
+
} = this.state;
|
|
42
|
+
const {
|
|
43
|
+
dateFormat
|
|
44
|
+
} = this.props;
|
|
45
|
+
const format = dateFormat.split(' ')[0]; // 'YYYY-MM-DD HH:mm'
|
|
46
|
+
const YMD = datePickerValue.format(format);
|
|
47
|
+
const newDate = YMD + ' ' + dayjs(time).format('HH:mm');
|
|
48
|
+
const newValue = dayjs(newDate);
|
|
49
|
+
this.setState({
|
|
51
50
|
datePickerValue: newValue
|
|
52
51
|
});
|
|
53
|
-
|
|
52
|
+
this.props.onValueChanged(datePickerValue.format(dateFormat));
|
|
54
53
|
};
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
this.closePopover = () => {
|
|
55
|
+
this.props.onClosePopover();
|
|
57
56
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
this.deleteDate = () => {
|
|
58
|
+
this.props.onValueChanged('');
|
|
59
|
+
this.closePopover();
|
|
61
60
|
};
|
|
62
|
-
|
|
61
|
+
this.onChange = value => {
|
|
63
62
|
if (!value) return;
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
let {
|
|
64
|
+
dateFormat
|
|
65
|
+
} = this.props;
|
|
66
|
+
this.setState({
|
|
66
67
|
datePickerValue: value
|
|
67
68
|
});
|
|
68
|
-
|
|
69
|
+
this.props.onValueChanged(value.format(dateFormat));
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
-
if (
|
|
71
|
+
this.onContainerClick = event => {
|
|
72
|
+
if (this.editorPopover && this.editorPopover.contains(event.target)) {
|
|
72
73
|
event.stopPropagation();
|
|
73
74
|
event.nativeEvent.stopImmediatePropagation();
|
|
74
75
|
return false;
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
this.setEditorPopover = editorPopover => {
|
|
79
|
+
this.editorPopover = editorPopover;
|
|
79
80
|
};
|
|
80
|
-
|
|
81
|
-
return
|
|
81
|
+
this.getCalendarContainer = () => {
|
|
82
|
+
return this.calendarContainerRef.current;
|
|
82
83
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
dateFormat
|
|
86
|
-
lang
|
|
87
|
-
|
|
84
|
+
this.getCalender = () => {
|
|
85
|
+
let {
|
|
86
|
+
dateFormat,
|
|
87
|
+
lang
|
|
88
|
+
} = this.props;
|
|
89
|
+
let defaultValue = dayjs().clone();
|
|
88
90
|
return /*#__PURE__*/React.createElement(Calendar, {
|
|
89
91
|
locale: initDateEditorLanguage(lang),
|
|
90
92
|
format: dateFormat,
|
|
@@ -100,10 +102,14 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
100
102
|
}
|
|
101
103
|
});
|
|
102
104
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
this.renderDataPicker = () => {
|
|
106
|
+
let {
|
|
107
|
+
dateFormat
|
|
108
|
+
} = this.props;
|
|
109
|
+
let {
|
|
110
|
+
datePickerValue
|
|
111
|
+
} = this.state;
|
|
112
|
+
let calendar = this.getCalender();
|
|
107
113
|
return /*#__PURE__*/React.createElement(SeaDatePicker, {
|
|
108
114
|
open: true,
|
|
109
115
|
style: {
|
|
@@ -111,14 +117,16 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
111
117
|
},
|
|
112
118
|
calendar: calendar,
|
|
113
119
|
value: datePickerValue,
|
|
114
|
-
getCalendarContainer:
|
|
115
|
-
onChange:
|
|
116
|
-
},
|
|
117
|
-
|
|
120
|
+
getCalendarContainer: this.getCalendarContainer,
|
|
121
|
+
onChange: this.onChange
|
|
122
|
+
}, _ref => {
|
|
123
|
+
let {
|
|
124
|
+
value
|
|
125
|
+
} = _ref;
|
|
118
126
|
value = value && value.format(dateFormat);
|
|
119
127
|
return /*#__PURE__*/React.createElement("div", {
|
|
120
128
|
tabIndex: "0",
|
|
121
|
-
onFocus:
|
|
129
|
+
onFocus: this.onReadOnlyFocus
|
|
122
130
|
}, /*#__PURE__*/React.createElement("input", {
|
|
123
131
|
placeholder: getLocale('Please_select'),
|
|
124
132
|
readOnly: true,
|
|
@@ -126,86 +134,80 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
126
134
|
className: "form-control",
|
|
127
135
|
value: value || ''
|
|
128
136
|
}), /*#__PURE__*/React.createElement("div", {
|
|
129
|
-
ref:
|
|
137
|
+
ref: this.calendarContainerRef,
|
|
130
138
|
style: {
|
|
131
139
|
height: '22rem'
|
|
132
140
|
}
|
|
133
141
|
}));
|
|
134
142
|
});
|
|
135
143
|
};
|
|
136
|
-
|
|
144
|
+
this.state = {
|
|
137
145
|
open: true,
|
|
138
146
|
datePickerValue: props.value ? dayjs(props.value) : dayjs().clone()
|
|
139
147
|
};
|
|
140
|
-
|
|
141
|
-
return _this;
|
|
148
|
+
this.calendarContainerRef = React.createRef();
|
|
142
149
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}, getLocale('Clear')))));
|
|
207
|
-
}
|
|
208
|
-
}]);
|
|
209
|
-
return DateEditorPopover;
|
|
210
|
-
}(React.PureComponent);
|
|
150
|
+
componentDidMount() {
|
|
151
|
+
history.pushState(null, null, '#'); // eslint-disable-line
|
|
152
|
+
window.addEventListener('popstate', this.handleHistaryBack, false);
|
|
153
|
+
}
|
|
154
|
+
componentWillUnmount() {
|
|
155
|
+
window.removeEventListener('popstate', this.handleHistaryBack, false);
|
|
156
|
+
}
|
|
157
|
+
render() {
|
|
158
|
+
const {
|
|
159
|
+
lang,
|
|
160
|
+
column,
|
|
161
|
+
dateFormat,
|
|
162
|
+
showHourAndMinute
|
|
163
|
+
} = this.props;
|
|
164
|
+
const leftFormat = dateFormat.split(' ')[0];
|
|
165
|
+
const rightFormat = dateFormat.split(' ')[1];
|
|
166
|
+
const {
|
|
167
|
+
datePickerValue
|
|
168
|
+
} = this.state;
|
|
169
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
170
|
+
ref: this.setEditorPopover,
|
|
171
|
+
className: "dtable-ui-mb-editor-popover mb-date-editor-popover",
|
|
172
|
+
onClick: this.onContainerClick
|
|
173
|
+
}, /*#__PURE__*/React.createElement(MBEditorHeader, {
|
|
174
|
+
title: column.name,
|
|
175
|
+
leftContent: /*#__PURE__*/React.createElement("i", {
|
|
176
|
+
className: "dtable-font dtable-icon-return"
|
|
177
|
+
}),
|
|
178
|
+
rightContent: /*#__PURE__*/React.createElement("span", null, getLocale('Done')),
|
|
179
|
+
onLeftClick: this.props.onClosePopover,
|
|
180
|
+
onRightClick: this.props.onClosePopover
|
|
181
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
182
|
+
className: "dtable-ui-mb-editor-body dtable-ui-mb-date-editor-body"
|
|
183
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
184
|
+
className: "mb-date-editor-input"
|
|
185
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
className: "date-input"
|
|
187
|
+
}, /*#__PURE__*/React.createElement(_DatePicker, {
|
|
188
|
+
mode: "date",
|
|
189
|
+
locale: initDateEditorLanguage(lang),
|
|
190
|
+
value: this.state.value,
|
|
191
|
+
onChange: this.handleDateChange
|
|
192
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
193
|
+
className: "date-input-day"
|
|
194
|
+
}, datePickerValue && datePickerValue.format(leftFormat)))), showHourAndMinute && /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: "date-input"
|
|
196
|
+
}, /*#__PURE__*/React.createElement(_DatePicker, {
|
|
197
|
+
mode: "time",
|
|
198
|
+
locale: initDateEditorLanguage(lang),
|
|
199
|
+
value: this.state.value,
|
|
200
|
+
onChange: this.handleTimeChange
|
|
201
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
202
|
+
className: "date-input-day"
|
|
203
|
+
}, datePickerValue && datePickerValue.format(rightFormat))))), /*#__PURE__*/React.createElement("div", {
|
|
204
|
+
className: "dtable-ui mb-date-editor-picker"
|
|
205
|
+
}, this.renderDataPicker()), /*#__PURE__*/React.createElement("div", {
|
|
206
|
+
className: "mb-date-editor-clear"
|
|
207
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
208
|
+
onClick: this.deleteDate,
|
|
209
|
+
className: "clear-date"
|
|
210
|
+
}, getLocale('Clear')))));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
211
213
|
export default DateEditorPopover;
|