d2coreui 21.0.34 → 23.0.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/components/clipboard/clipboardUtils.d.ts +4 -3
- package/components/clipboard/clipboardUtils.js +47 -22
- package/components/clipboard/clipboardUtils.js.map +1 -1
- package/components/codemirror/SyntaxHighlighter.d.ts +21 -21
- package/components/codemirror/SyntaxHighlighter.js +45 -44
- package/components/codemirror/SyntaxHighlighter.js.map +1 -1
- package/components/collapse/expandable.d.ts +13 -12
- package/components/collapse/expandable.js +20 -20
- package/components/collapse/expandable.js.map +1 -1
- package/components/color/colorPicker.d.ts +20 -20
- package/components/color/colorPicker.js +53 -53
- package/components/color/colorPicker.js.map +1 -1
- package/components/color/colorSwatch.d.ts +13 -12
- package/components/color/colorSwatch.js +62 -62
- package/components/color/colorSwatch.js.map +1 -1
- package/components/color/colorUtils.d.ts +7 -7
- package/components/color/colorUtils.js +43 -43
- package/components/color/colorUtils.js.map +1 -1
- package/components/date/dateRangeInput.d.ts +66 -64
- package/components/date/dateRangeInput.js +292 -297
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -26
- package/components/date/dateRangeInputAdvancedPanel.js +130 -115
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.d.ts +31 -29
- package/components/date/dateRangeInputConfirm.js +132 -121
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +72 -69
- package/components/date/dateTimeInput.js +440 -412
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/date/durationInput.d.ts +59 -56
- package/components/date/durationInput.js +269 -280
- package/components/date/durationInput.js.map +1 -1
- package/components/form/NiceFormItem.d.ts +14 -14
- package/components/form/NiceFormItem.js +28 -31
- package/components/form/NiceFormItem.js.map +1 -1
- package/components/grid/cell/beanAccessor.d.ts +9 -0
- package/components/grid/cell/beanAccessor.js +13 -0
- package/components/grid/cell/beanAccessor.js.map +1 -0
- package/components/grid/cell/cellEditorUtils.d.ts +4 -4
- package/components/grid/cell/cellEditorUtils.js +8 -8
- package/components/grid/cell/customEnumCellEditor.d.ts +4 -27
- package/components/grid/cell/customEnumCellEditor.js +82 -91
- package/components/grid/cell/customEnumCellEditor.js.map +1 -1
- package/components/grid/cell/dataGridCellEditorComponent.d.ts +14 -0
- package/components/grid/cell/dataGridCellEditorComponent.js +49 -0
- package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -0
- package/components/grid/cell/dateCellEditor.d.ts +4 -25
- package/components/grid/cell/dateCellEditor.js +53 -72
- package/components/grid/cell/dateCellEditor.js.map +1 -1
- package/components/grid/cell/durationCellEditor.d.ts +4 -24
- package/components/grid/cell/durationCellEditor.js +74 -97
- package/components/grid/cell/durationCellEditor.js.map +1 -1
- package/components/grid/cell/hexaOctetStringCellEditor.d.ts +4 -24
- package/components/grid/cell/hexaOctetStringCellEditor.js +70 -94
- package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
- package/components/grid/cell/hexaValueCellEditor.d.ts +4 -24
- package/components/grid/cell/hexaValueCellEditor.js +65 -89
- package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
- package/components/grid/cell/numberCellEditor.d.ts +4 -27
- package/components/grid/cell/numberCellEditor.js +73 -95
- package/components/grid/cell/numberCellEditor.js.map +1 -1
- package/components/grid/cell/rangeSelector.d.ts +78 -78
- package/components/grid/cell/rangeSelector.js +526 -518
- package/components/grid/cell/rangeSelector.js.map +1 -1
- package/components/grid/cell/simpleStatusTextCellEditor.d.ts +4 -32
- package/components/grid/cell/simpleStatusTextCellEditor.js +106 -116
- package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
- package/components/grid/cell/statusTextCellEditor.d.ts +4 -32
- package/components/grid/cell/statusTextCellEditor.js +136 -159
- package/components/grid/cell/statusTextCellEditor.js.map +1 -1
- package/components/grid/cell/tableDefaultRowStyleRules.d.ts +20 -20
- package/components/grid/cell/tableDefaultRowStyleRules.js +29 -18
- package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
- package/components/grid/cell/textCellEditor.d.ts +4 -21
- package/components/grid/cell/textCellEditor.js +63 -85
- package/components/grid/cell/textCellEditor.js.map +1 -1
- package/components/grid/cell/withAgGridHooks.d.ts +3 -0
- package/components/grid/cell/withAgGridHooks.js +15 -0
- package/components/grid/cell/withAgGridHooks.js.map +1 -0
- package/components/grid/columnUtils.d.ts +5 -5
- package/components/grid/columnUtils.js +26 -26
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.d.ts +21 -22
- package/components/grid/config/columnTransfer.js +205 -201
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/config/dataGridEditor.d.ts +41 -41
- package/components/grid/config/dataGridEditor.js +181 -160
- package/components/grid/config/dataGridEditor.js.map +1 -1
- package/components/grid/config/rowHeightCalculator.d.ts +8 -0
- package/components/grid/config/rowHeightCalculator.js +20 -0
- package/components/grid/config/rowHeightCalculator.js.map +1 -0
- package/components/grid/config/rowStylePicker.d.ts +27 -25
- package/components/grid/config/rowStylePicker.js +127 -109
- package/components/grid/config/rowStylePicker.js.map +1 -1
- package/components/grid/dataGrid.d.ts +218 -206
- package/components/grid/dataGrid.js +1629 -1538
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/detail/detailHeaderPanel.d.ts +13 -13
- package/components/grid/detail/detailHeaderPanel.js +25 -25
- package/components/grid/detail/detailHeaderPanel.js.map +1 -1
- package/components/grid/export/contextMenu.d.ts +18 -24
- package/components/grid/export/contextMenu.js +116 -113
- package/components/grid/export/contextMenu.js.map +1 -1
- package/components/grid/export/progressPopup.d.ts +29 -29
- package/components/grid/export/progressPopup.js +93 -93
- package/components/grid/export/progressPopup.js.map +1 -1
- package/components/grid/export/worker/clipboardExport.d.ts +1 -1
- package/components/grid/export/worker/clipboardExport.js +8 -8
- package/components/grid/export/worker/csvExport.d.ts +1 -1
- package/components/grid/export/worker/csvExport.js +8 -8
- package/components/grid/export/worker/pdfExport.d.ts +1 -1
- package/components/grid/export/worker/pdfExport.js +81 -81
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/export/worker/txtExport.d.ts +1 -1
- package/components/grid/export/worker/txtExport.js +19 -19
- package/components/grid/extendedDataGrid.d.ts +140 -140
- package/components/grid/extendedDataGrid.js +704 -695
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/grid/filter/customColumnFilter.d.ts +5 -21
- package/components/grid/filter/customColumnFilter.js +11 -82
- package/components/grid/filter/customColumnFilter.js.map +1 -1
- package/components/grid/filter/dataGridColumnFilter.d.ts +17 -0
- package/components/grid/filter/dataGridColumnFilter.js +49 -0
- package/components/grid/filter/dataGridColumnFilter.js.map +1 -0
- package/components/grid/filter/dateColumnFilter.d.ts +7 -11
- package/components/grid/filter/dateColumnFilter.js +22 -56
- package/components/grid/filter/dateColumnFilter.js.map +1 -1
- package/components/grid/filter/textColumnFilter.d.ts +8 -20
- package/components/grid/filter/textColumnFilter.js +24 -76
- package/components/grid/filter/textColumnFilter.js.map +1 -1
- package/components/grid/filter/wildcardQuickFilterEngine.d.ts +7 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js +48 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -0
- package/components/grid/header/simpleHeader.d.ts +17 -16
- package/components/grid/header/simpleHeader.js +230 -186
- package/components/grid/header/simpleHeader.js.map +1 -1
- package/components/grid/panel/dataGridPagination.d.ts +16 -16
- package/components/grid/panel/dataGridPagination.js +58 -58
- package/components/grid/panel/dataGridPagination.js.map +1 -1
- package/components/grid/panel/loadingOverlay.d.ts +6 -6
- package/components/grid/panel/loadingOverlay.js +10 -10
- package/components/grid/panel/loadingOverlay.js.map +1 -1
- package/components/grid/panel/noRecordsOverlay.d.ts +6 -6
- package/components/grid/panel/noRecordsOverlay.js +10 -10
- package/components/grid/panel/noRecordsOverlay.js.map +1 -1
- package/components/grid/panel/tablePagination.d.ts +10 -10
- package/components/grid/panel/tablePagination.js +45 -45
- package/components/grid/panel/tablePagination.js.map +1 -1
- package/components/icons/dropdownArrow.d.ts +8 -0
- package/components/icons/dropdownArrow.js +59 -0
- package/components/icons/dropdownArrow.js.map +1 -0
- package/components/icons/undoIcon.d.ts +8 -8
- package/components/icons/undoIcon.js +6 -6
- package/components/input/autoCompleteInput.d.ts +35 -35
- package/components/input/autoCompleteInput.js +122 -121
- package/components/input/autoCompleteInput.js.map +1 -1
- package/components/input/draftUtils.d.ts +4 -4
- package/components/input/draftUtils.js +48 -48
- package/components/input/draftUtils.js.map +1 -1
- package/components/input/draftail.d.ts +1 -1
- package/components/input/draftail.js +1 -1
- package/components/input/hexaFormattedInput.d.ts +16 -16
- package/components/input/hexaFormattedInput.js +54 -54
- package/components/input/hexaFormattedInput.js.map +1 -1
- package/components/input/mask/helpers.d.ts +28 -28
- package/components/input/mask/helpers.js +112 -112
- package/components/input/mask/helpers.js.map +1 -1
- package/components/input/mask/inputMaskCore.d.ts +46 -46
- package/components/input/mask/inputMaskCore.js +278 -278
- package/components/input/mask/inputMaskCore.js.map +1 -1
- package/components/input/mask/pattern.d.ts +20 -20
- package/components/input/mask/pattern.js +78 -78
- package/components/input/mask/pattern.js.map +1 -1
- package/components/input/maskedInput.d.ts +373 -351
- package/components/input/maskedInput.js +224 -224
- package/components/input/maskedInput.js.map +1 -1
- package/components/input/passwordInput.d.ts +9 -9
- package/components/input/passwordInput.js +55 -55
- package/components/input/passwordInput.js.map +1 -1
- package/components/input/simpleAutoComplete.d.ts +12 -12
- package/components/input/simpleAutoComplete.js +41 -43
- package/components/input/simpleAutoComplete.js.map +1 -1
- package/components/input/textarea/extractSpansOfClasses.d.ts +15 -15
- package/components/input/textarea/extractSpansOfClasses.js +96 -96
- package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
- package/components/input/textarea/getRanges.d.ts +1 -1
- package/components/input/textarea/getRanges.js +73 -73
- package/components/input/textarea/getRanges.js.map +1 -1
- package/components/input/textarea/getType.d.ts +1 -1
- package/components/input/textarea/getType.js +26 -26
- package/components/input/textarea/getType.js.map +1 -1
- package/components/input/textarea/highlighedContents.d.ts +6 -6
- package/components/input/textarea/highlighedContents.js +10 -10
- package/components/input/textarea/mentionsWithHighlighting.d.ts +27 -27
- package/components/input/textarea/mentionsWithHighlighting.js +60 -60
- package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
- package/components/keyboard/keyboardUtils.d.ts +5 -5
- package/components/keyboard/keyboardUtils.js +32 -32
- package/components/modal/draggableModalProvider.d.ts +4 -4
- package/components/modal/draggableModalProvider.js +21 -21
- package/components/modal/draggableModalProvider.js.map +1 -1
- package/components/modal/impl/clamp.d.ts +1 -1
- package/components/modal/impl/clamp.js +1 -1
- package/components/modal/impl/clamp.js.map +1 -1
- package/components/modal/impl/draggableModal.d.ts +12 -12
- package/components/modal/impl/draggableModal.js +17 -17
- package/components/modal/impl/draggableModal.js.map +1 -1
- package/components/modal/impl/draggableModalContext.d.ts +9 -9
- package/components/modal/impl/draggableModalContext.js +2 -2
- package/components/modal/impl/draggableModalContext.js.map +1 -1
- package/components/modal/impl/draggableModalInner.d.ts +15 -13
- package/components/modal/impl/draggableModalInner.js +57 -55
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalReducer.d.ts +66 -62
- package/components/modal/impl/draggableModalReducer.js +77 -78
- package/components/modal/impl/draggableModalReducer.js.map +1 -1
- package/components/modal/impl/getWindowSize.d.ts +4 -4
- package/components/modal/impl/getWindowSize.js +4 -4
- package/components/modal/impl/getWindowSize.js.map +1 -1
- package/components/modal/impl/index.d.ts +3 -3
- package/components/modal/impl/index.js +3 -3
- package/components/modal/impl/index.js.map +1 -1
- package/components/modal/impl/resizeHandle.d.ts +3 -3
- package/components/modal/impl/resizeHandle.js +4 -4
- package/components/modal/impl/resizeHandle.js.map +1 -1
- package/components/modal/impl/useDrag.d.ts +5 -5
- package/components/modal/impl/useDrag.js +42 -42
- package/components/modal/impl/useDrag.js.map +1 -1
- package/components/modal/impl/usePrevious.d.ts +1 -1
- package/components/modal/impl/usePrevious.js +8 -8
- package/components/modal/impl/usePrevious.js.map +1 -1
- package/components/modal/impl/useResize.d.ts +7 -7
- package/components/modal/impl/useResize.js +46 -46
- package/components/modal/impl/useResize.js.map +1 -1
- package/components/modal/modalDialog.d.ts +49 -49
- package/components/modal/modalDialog.js +152 -152
- package/components/modal/modalDialog.js.map +1 -1
- package/components/picker/enumValuePicker.d.ts +16 -16
- package/components/picker/enumValuePicker.js +34 -34
- package/components/picker/enumValuePicker.js.map +1 -1
- package/components/platformSpecific.d.ts +10 -10
- package/components/platformSpecific.js +27 -27
- package/components/scrollTo/onlyText.d.ts +4 -4
- package/components/scrollTo/onlyText.js +30 -30
- package/components/scrollTo/onlyText.js.map +1 -1
- package/components/scrollTo/scrollTo.d.ts +41 -39
- package/components/scrollTo/scrollTo.js +264 -264
- package/components/scrollTo/scrollTo.js.map +1 -1
- package/components/style/withCss.d.ts +9 -0
- package/components/style/withCss.js +6 -0
- package/components/style/withCss.js.map +1 -0
- package/components/style/withInputNumberCss.d.ts +6 -0
- package/components/style/withInputNumberCss.js +13 -0
- package/components/style/withInputNumberCss.js.map +1 -0
- package/components/table/dragSortingTable.d.ts +13 -14
- package/components/table/dragSortingTable.js +96 -82
- package/components/table/dragSortingTable.js.map +1 -1
- package/components/text/impl/innerSize.d.ts +2 -2
- package/components/text/impl/innerSize.js +12 -12
- package/components/text/impl/series.d.ts +1 -1
- package/components/text/impl/series.js +28 -28
- package/components/text/impl/shallowEqual.d.ts +1 -1
- package/components/text/impl/shallowEqual.js +18 -18
- package/components/text/impl/shallowEqual.js.map +1 -1
- package/components/text/impl/uniqueId.d.ts +1 -1
- package/components/text/impl/uniqueId.js +4 -4
- package/components/text/impl/whilst.d.ts +1 -1
- package/components/text/impl/whilst.js +19 -19
- package/components/text/impl/whilst.js.map +1 -1
- package/components/text/textFit.d.ts +38 -38
- package/components/text/textFit.js +165 -168
- package/components/text/textFit.js.map +1 -1
- package/i18n/components.cs.json +101 -100
- package/i18n/components.sk.json +101 -100
- package/i18n/components.uk.json +101 -100
- package/i18n/componentsLocaleHolder.d.ts +3 -3
- package/i18n/componentsLocaleHolder.js +28 -28
- package/i18n/componentsLocaleHolder.js.map +1 -1
- package/package.json +71 -70
- package/style/index.less +274 -298
- package/style/modal/DraggableModal.css +43 -40
- package/style/modal/ResizeHandle.css +27 -19
- package/tsconfig.build.json +24 -24
- package/tsconfig.json +11 -11
- package/components/grid/cell/wildcardQuickFilter.d.ts +0 -11
- package/components/grid/cell/wildcardQuickFilter.js +0 -61
- package/components/grid/cell/wildcardQuickFilter.js.map +0 -1
- package/components/table/dataTable.d.ts +0 -17
- package/components/table/dataTable.js +0 -79
- package/components/table/dataTable.js.map +0 -1
- package/style/antd/antd-tree-showline.css +0 -25
- package/style/antd/full-height-tabs.scss +0 -63
- package/style/draftail/draftail-editor.css +0 -179
- package/style/table/dragSortingTable.css +0 -7
|
@@ -1,298 +1,293 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React from "react";
|
|
13
|
-
import
|
|
14
|
-
import { CalendarOutlined } from "@ant-design/icons";
|
|
15
|
-
import { Divider, Switch, Tooltip } from "antd";
|
|
16
|
-
import DateTimeInput from "./dateTimeInput";
|
|
17
|
-
import memoizeOne from "memoize-one";
|
|
18
|
-
import KeyboardUtils from "../keyboard/keyboardUtils";
|
|
19
|
-
import i18n from "d2core/i18n/i18n";
|
|
20
|
-
import DateRangeInputAdvancedPanel, { TimeShiftDirection } from "./dateRangeInputAdvancedPanel";
|
|
21
|
-
export var DateRangeInputMode;
|
|
22
|
-
(function (DateRangeInputMode) {
|
|
23
|
-
DateRangeInputMode[DateRangeInputMode["SIMPLE"] = 0] = "SIMPLE";
|
|
24
|
-
DateRangeInputMode[DateRangeInputMode["ADVANCED"] = 1] = "ADVANCED";
|
|
25
|
-
})(DateRangeInputMode || (DateRangeInputMode = {}));
|
|
26
|
-
export default class DateRangeInput extends React.Component {
|
|
27
|
-
constructor(props) {
|
|
28
|
-
var _a;
|
|
29
|
-
super(props);
|
|
30
|
-
this.state = {
|
|
31
|
-
valid: !!props.fromValue && props.fromValue.isValid() && !!props.toValue && props.toValue.isValid(),
|
|
32
|
-
selectionStartDate: null,
|
|
33
|
-
popupKeyIndex: 0,
|
|
34
|
-
popupVisible: false,
|
|
35
|
-
mode: (_a = props.defaultMode) !== null && _a !== void 0 ? _a : DateRangeInputMode.SIMPLE,
|
|
36
|
-
};
|
|
37
|
-
this.getDefaultSelectedDateForFromPanel = memoizeOne(this.getDefaultSelectedDateForFromPanel.bind(this));
|
|
38
|
-
}
|
|
39
|
-
componentDidUpdate(_prevProps, prevState) {
|
|
40
|
-
if (prevState.popupVisible !== this.state.popupVisible && this.props.onPopupVisibleChange) {
|
|
41
|
-
this.props.onPopupVisibleChange(this.state.popupVisible);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
getDefaultSelectedDateForFromPanel(fromDate, toDate) {
|
|
45
|
-
if (!!fromDate && !!toDate && fromDate.isSame(toDate, "date")) {
|
|
46
|
-
return fromDate.clone().subtract(1, "month");
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return fromDate !== null && fromDate !== void 0 ? fromDate :
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
getFromValue(date) {
|
|
53
|
-
var _a, _b;
|
|
54
|
-
return ((_b = (_a = this.props.fromValue) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b :
|
|
55
|
-
}
|
|
56
|
-
getToValue(date) {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
return ((_b = (_a = this.props.toValue) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b :
|
|
59
|
-
}
|
|
60
|
-
closePopup() {
|
|
61
|
-
var _a, _b;
|
|
62
|
-
this.setState({ popupKeyIndex: this.state.popupKeyIndex + 1, popupVisible: false });
|
|
63
|
-
(_b = (_a = this.props).onPopupVisibleChange) === null || _b === void 0 ? void 0 : _b.call(_a, false);
|
|
64
|
-
}
|
|
65
|
-
onChange(fromValue, toValue) {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
if (this.props.minDateTime && (fromValue === null || fromValue === void 0 ? void 0 : fromValue.isBefore(this.props.minDateTime))) {
|
|
68
|
-
fromValue = this.props.minDateTime;
|
|
69
|
-
}
|
|
70
|
-
if (this.props.maxDateTime && (toValue === null || toValue === void 0 ? void 0 : toValue.isAfter(this.props.maxDateTime))) {
|
|
71
|
-
toValue = this.props.maxDateTime;
|
|
72
|
-
}
|
|
73
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, fromValue, toValue);
|
|
74
|
-
}
|
|
75
|
-
renderSimplePart() {
|
|
76
|
-
const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange"]);
|
|
77
|
-
const markedDateInterval = this.props.fromValue && this.props.toValue ? [this.props.fromValue, this.props.toValue] : undefined;
|
|
78
|
-
return (React.createElement("div", null,
|
|
79
|
-
React.createElement("div", { style: { display: "flex" } },
|
|
80
|
-
React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { allowClear: allowClear, renderAsCalendar: true, style: { width: "100%" }, onChange: (date) => {
|
|
81
|
-
var _a, _b;
|
|
82
|
-
if (date) {
|
|
83
|
-
const fromValue = this.getFromValue(date);
|
|
84
|
-
const toValue = this.getToValue(date);
|
|
85
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, fromValue, toValue);
|
|
86
|
-
}
|
|
87
|
-
}, defaultSelectedDate: this.getDefaultSelectedDateForFromPanel(fromValue, toValue), markedDateInterval: markedDateInterval, onDateItemMouseDown: (date) => {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
this.setState({ selectionStartDate: date });
|
|
90
|
-
const dateFrom = this.getFromValue(date);
|
|
91
|
-
const dateTo = this.getToValue(date);
|
|
92
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
93
|
-
}, onDateItemMouseOver: (date) => {
|
|
94
|
-
var _a, _b;
|
|
95
|
-
if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {
|
|
96
|
-
let dateFrom;
|
|
97
|
-
let dateTo;
|
|
98
|
-
if (this.state.selectionStartDate.isBefore(date)) {
|
|
99
|
-
dateFrom = this.state.selectionStartDate;
|
|
100
|
-
dateTo = date;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
dateFrom = date;
|
|
104
|
-
dateTo = this.state.selectionStartDate;
|
|
105
|
-
}
|
|
106
|
-
dateFrom = this.getFromValue(dateFrom);
|
|
107
|
-
dateTo = this.getToValue(dateTo);
|
|
108
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
109
|
-
}
|
|
110
|
-
}, onDateItemMouseUp: (_date) => {
|
|
111
|
-
this.setState({ selectionStartDate: null });
|
|
112
|
-
}, ignoreKeyStrokes: true })),
|
|
113
|
-
React.createElement(Divider, { type: "vertical", style: { height: "auto" } }),
|
|
114
|
-
React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { renderAsCalendar: true, allowClear: allowClear, style: { width: "100%" }, onChange: (date) => {
|
|
115
|
-
var _a, _b;
|
|
116
|
-
if (date) {
|
|
117
|
-
const fromValue = this.getFromValue(date);
|
|
118
|
-
const toValue = this.getToValue(date);
|
|
119
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, fromValue, toValue);
|
|
120
|
-
}
|
|
121
|
-
}, markedDateInterval: markedDateInterval, onDateItemMouseDown: (date) => {
|
|
122
|
-
var _a, _b;
|
|
123
|
-
this.setState({ selectionStartDate: date });
|
|
124
|
-
const dateFrom = this.getFromValue(date);
|
|
125
|
-
const dateTo = this.getToValue(date);
|
|
126
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
127
|
-
}, onDateItemMouseOver: (date) => {
|
|
128
|
-
var _a, _b;
|
|
129
|
-
if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {
|
|
130
|
-
let dateFrom;
|
|
131
|
-
let dateTo;
|
|
132
|
-
if (this.state.selectionStartDate.isBefore(date)) {
|
|
133
|
-
dateFrom = this.state.selectionStartDate;
|
|
134
|
-
dateTo = date;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
dateFrom = date;
|
|
138
|
-
dateTo = this.state.selectionStartDate;
|
|
139
|
-
}
|
|
140
|
-
dateFrom = this.getFromValue(dateFrom);
|
|
141
|
-
dateTo = this.getToValue(dateTo);
|
|
142
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
143
|
-
}
|
|
144
|
-
}, onDateItemMouseUp: (_date) => {
|
|
145
|
-
this.setState({ selectionStartDate: null });
|
|
146
|
-
}, ignoreKeyStrokes: true }))),
|
|
147
|
-
React.createElement("div", {
|
|
148
|
-
React.createElement(
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
React.createElement(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
this.setState({ popupVisible: visible });
|
|
294
|
-
}, overlayClassName: "date-range-picker-popup", title: this.renderPopup() }, this.renderInput()));
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from "react";
|
|
13
|
+
import dayjs from "dayjs";
|
|
14
|
+
import { CalendarOutlined } from "@ant-design/icons";
|
|
15
|
+
import { Divider, Switch, Tag, Tooltip } from "antd";
|
|
16
|
+
import DateTimeInput from "./dateTimeInput";
|
|
17
|
+
import memoizeOne from "memoize-one";
|
|
18
|
+
import KeyboardUtils from "../keyboard/keyboardUtils";
|
|
19
|
+
import i18n from "d2core/i18n/i18n";
|
|
20
|
+
import DateRangeInputAdvancedPanel, { TimeShiftDirection } from "./dateRangeInputAdvancedPanel";
|
|
21
|
+
export var DateRangeInputMode;
|
|
22
|
+
(function (DateRangeInputMode) {
|
|
23
|
+
DateRangeInputMode[DateRangeInputMode["SIMPLE"] = 0] = "SIMPLE";
|
|
24
|
+
DateRangeInputMode[DateRangeInputMode["ADVANCED"] = 1] = "ADVANCED";
|
|
25
|
+
})(DateRangeInputMode || (DateRangeInputMode = {}));
|
|
26
|
+
export default class DateRangeInput extends React.Component {
|
|
27
|
+
constructor(props) {
|
|
28
|
+
var _a;
|
|
29
|
+
super(props);
|
|
30
|
+
this.state = {
|
|
31
|
+
valid: !!props.fromValue && props.fromValue.isValid() && !!props.toValue && props.toValue.isValid(),
|
|
32
|
+
selectionStartDate: null,
|
|
33
|
+
popupKeyIndex: 0,
|
|
34
|
+
popupVisible: false,
|
|
35
|
+
mode: (_a = props.defaultMode) !== null && _a !== void 0 ? _a : DateRangeInputMode.SIMPLE,
|
|
36
|
+
};
|
|
37
|
+
this.getDefaultSelectedDateForFromPanel = memoizeOne(this.getDefaultSelectedDateForFromPanel.bind(this));
|
|
38
|
+
}
|
|
39
|
+
componentDidUpdate(_prevProps, prevState) {
|
|
40
|
+
if (prevState.popupVisible !== this.state.popupVisible && this.props.onPopupVisibleChange) {
|
|
41
|
+
this.props.onPopupVisibleChange(this.state.popupVisible);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
getDefaultSelectedDateForFromPanel(fromDate, toDate) {
|
|
45
|
+
if (!!fromDate && !!toDate && fromDate.isSame(toDate, "date")) {
|
|
46
|
+
return fromDate.clone().subtract(1, "month");
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return fromDate !== null && fromDate !== void 0 ? fromDate : dayjs().startOf("day").subtract(1, "month");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
getFromValue(date) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
return ((_b = (_a = this.props.fromValue) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : dayjs().startOf("day")).year(date.year()).month(date.month()).date(date.date());
|
|
55
|
+
}
|
|
56
|
+
getToValue(date) {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
return ((_b = (_a = this.props.toValue) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : dayjs().endOf("day")).year(date.year()).month(date.month()).date(date.date());
|
|
59
|
+
}
|
|
60
|
+
closePopup() {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
this.setState({ popupKeyIndex: this.state.popupKeyIndex + 1, popupVisible: false });
|
|
63
|
+
(_b = (_a = this.props).onPopupVisibleChange) === null || _b === void 0 ? void 0 : _b.call(_a, false);
|
|
64
|
+
}
|
|
65
|
+
onChange(fromValue, toValue) {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
if (this.props.minDateTime && (fromValue === null || fromValue === void 0 ? void 0 : fromValue.isBefore(this.props.minDateTime))) {
|
|
68
|
+
fromValue = this.props.minDateTime;
|
|
69
|
+
}
|
|
70
|
+
if (this.props.maxDateTime && (toValue === null || toValue === void 0 ? void 0 : toValue.isAfter(this.props.maxDateTime))) {
|
|
71
|
+
toValue = this.props.maxDateTime;
|
|
72
|
+
}
|
|
73
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, fromValue, toValue);
|
|
74
|
+
}
|
|
75
|
+
renderSimplePart() {
|
|
76
|
+
const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange"]);
|
|
77
|
+
const markedDateInterval = this.props.fromValue && this.props.toValue ? [this.props.fromValue, this.props.toValue] : undefined;
|
|
78
|
+
return (React.createElement("div", null,
|
|
79
|
+
React.createElement("div", { style: { display: "flex" } },
|
|
80
|
+
React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { allowClear: allowClear, renderAsCalendar: true, style: { width: "100%" }, onChange: (date) => {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
if (date) {
|
|
83
|
+
const fromValue = this.getFromValue(date);
|
|
84
|
+
const toValue = this.getToValue(date);
|
|
85
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, fromValue, toValue);
|
|
86
|
+
}
|
|
87
|
+
}, defaultSelectedDate: this.getDefaultSelectedDateForFromPanel(fromValue, toValue), markedDateInterval: markedDateInterval, onDateItemMouseDown: (date) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
this.setState({ selectionStartDate: date });
|
|
90
|
+
const dateFrom = this.getFromValue(date);
|
|
91
|
+
const dateTo = this.getToValue(date);
|
|
92
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
93
|
+
}, onDateItemMouseOver: (date) => {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {
|
|
96
|
+
let dateFrom;
|
|
97
|
+
let dateTo;
|
|
98
|
+
if (this.state.selectionStartDate.isBefore(date)) {
|
|
99
|
+
dateFrom = this.state.selectionStartDate;
|
|
100
|
+
dateTo = date;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
dateFrom = date;
|
|
104
|
+
dateTo = this.state.selectionStartDate;
|
|
105
|
+
}
|
|
106
|
+
dateFrom = this.getFromValue(dateFrom);
|
|
107
|
+
dateTo = this.getToValue(dateTo);
|
|
108
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
109
|
+
}
|
|
110
|
+
}, onDateItemMouseUp: (_date) => {
|
|
111
|
+
this.setState({ selectionStartDate: null });
|
|
112
|
+
}, ignoreKeyStrokes: true })),
|
|
113
|
+
React.createElement(Divider, { type: "vertical", style: { height: "auto" } }),
|
|
114
|
+
React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { renderAsCalendar: true, allowClear: allowClear, style: { width: "100%" }, onChange: (date) => {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
if (date) {
|
|
117
|
+
const fromValue = this.getFromValue(date);
|
|
118
|
+
const toValue = this.getToValue(date);
|
|
119
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, fromValue, toValue);
|
|
120
|
+
}
|
|
121
|
+
}, markedDateInterval: markedDateInterval, onDateItemMouseDown: (date) => {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
this.setState({ selectionStartDate: date });
|
|
124
|
+
const dateFrom = this.getFromValue(date);
|
|
125
|
+
const dateTo = this.getToValue(date);
|
|
126
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
127
|
+
}, onDateItemMouseOver: (date) => {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
if (KeyboardUtils.isMouseDown() && !!this.state.selectionStartDate) {
|
|
130
|
+
let dateFrom;
|
|
131
|
+
let dateTo;
|
|
132
|
+
if (this.state.selectionStartDate.isBefore(date)) {
|
|
133
|
+
dateFrom = this.state.selectionStartDate;
|
|
134
|
+
dateTo = date;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
dateFrom = date;
|
|
138
|
+
dateTo = this.state.selectionStartDate;
|
|
139
|
+
}
|
|
140
|
+
dateFrom = this.getFromValue(dateFrom);
|
|
141
|
+
dateTo = this.getToValue(dateTo);
|
|
142
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, dateFrom, dateTo);
|
|
143
|
+
}
|
|
144
|
+
}, onDateItemMouseUp: (_date) => {
|
|
145
|
+
this.setState({ selectionStartDate: null });
|
|
146
|
+
}, ignoreKeyStrokes: true }))),
|
|
147
|
+
React.createElement("div", { style: { borderTop: "1px solid #ddd", paddingTop: 6 } }, this.props.ranges && Object.keys(this.props.ranges).map((rangeName, index) => {
|
|
148
|
+
return (React.createElement(Tag, { style: { userSelect: "none", cursor: "pointer" }, color: "blue", key: `range-${index}`, onClick: () => {
|
|
149
|
+
var _a, _b, _c;
|
|
150
|
+
const rangeFunction = (_a = this.props.ranges) === null || _a === void 0 ? void 0 : _a[rangeName];
|
|
151
|
+
if (rangeFunction) {
|
|
152
|
+
const range = rangeFunction();
|
|
153
|
+
(_c = (_b = this.props).onChange) === null || _c === void 0 ? void 0 : _c.call(_b, range[0], range[1]);
|
|
154
|
+
}
|
|
155
|
+
} }, rangeName));
|
|
156
|
+
}))));
|
|
157
|
+
}
|
|
158
|
+
renderAdvancedPart() {
|
|
159
|
+
const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange"]);
|
|
160
|
+
return (React.createElement("div", null,
|
|
161
|
+
React.createElement("div", { style: { display: "flex" } },
|
|
162
|
+
React.createElement(DateTimeInput, Object.assign({}, props, { style: { width: "47%" }, value: fromValue, onChange: (value) => {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, this.props.toValue);
|
|
165
|
+
} })),
|
|
166
|
+
React.createElement("span", { style: { width: "6%", paddingTop: 4, color: "rgba(0, 0, 0, 0.65)", textAlign: "center" } }, "\u27F7"),
|
|
167
|
+
React.createElement(DateTimeInput, Object.assign({}, props, { style: { width: "47%" }, value: toValue, onChange: (value) => {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.fromValue, value);
|
|
170
|
+
} }))),
|
|
171
|
+
React.createElement(DateRangeInputAdvancedPanel, { onBeginIntervalChange: unit => {
|
|
172
|
+
let from;
|
|
173
|
+
if (unit === "15minutes") {
|
|
174
|
+
const roundedMinutes = Math.floor(dayjs().minute() / 15) * 15;
|
|
175
|
+
from = dayjs().startOf("hour").minute(roundedMinutes);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
from = dayjs().startOf(unit);
|
|
179
|
+
}
|
|
180
|
+
this.onChange(from, this.props.toValue);
|
|
181
|
+
}, onIntervalDurationChange: unitOfTime => {
|
|
182
|
+
if (this.props.fromValue) {
|
|
183
|
+
let to;
|
|
184
|
+
if (unitOfTime === "4years") {
|
|
185
|
+
to = this.props.fromValue.clone().add(4, "year").subtract(1, "millisecond");
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
to = this.props.fromValue.clone().add(1, unitOfTime).subtract(1, "millisecond");
|
|
189
|
+
}
|
|
190
|
+
this.onChange(this.props.fromValue, to);
|
|
191
|
+
}
|
|
192
|
+
}, onTimeShift: (shiftBegin, shiftEnd, unitOfTime, type) => {
|
|
193
|
+
var _a, _b;
|
|
194
|
+
let fromValue = (_a = this.props.fromValue) !== null && _a !== void 0 ? _a : null;
|
|
195
|
+
let toValue = (_b = this.props.toValue) !== null && _b !== void 0 ? _b : null;
|
|
196
|
+
if (shiftBegin && fromValue) {
|
|
197
|
+
if (type === TimeShiftDirection.INCREMENT) {
|
|
198
|
+
fromValue = fromValue.add(1, unitOfTime);
|
|
199
|
+
}
|
|
200
|
+
else if (type === TimeShiftDirection.DECREMENT) {
|
|
201
|
+
fromValue = fromValue.subtract(1, unitOfTime);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (shiftEnd && toValue) {
|
|
205
|
+
if (type === TimeShiftDirection.INCREMENT) {
|
|
206
|
+
toValue = toValue.add(1, unitOfTime);
|
|
207
|
+
}
|
|
208
|
+
else if (type === TimeShiftDirection.DECREMENT) {
|
|
209
|
+
toValue = toValue.subtract(1, unitOfTime);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
this.onChange(fromValue, toValue);
|
|
213
|
+
}, onEndIntervalChange: unit => {
|
|
214
|
+
let to;
|
|
215
|
+
if (unit === "15minutes") {
|
|
216
|
+
const roundedMinutes = Math.floor(dayjs().minute() / 15) * 15;
|
|
217
|
+
to = dayjs().startOf("hour").minute(roundedMinutes).subtract(1, "millisecond");
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
to = dayjs().startOf(unit).subtract(1, "millisecond");
|
|
221
|
+
}
|
|
222
|
+
this.onChange(this.props.fromValue, to);
|
|
223
|
+
} })));
|
|
224
|
+
}
|
|
225
|
+
renderPopup() {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
return (React.createElement("div", { onFocus: this.props.onFocus, onBlur: this.props.onBlur },
|
|
228
|
+
this.state.mode === DateRangeInputMode.SIMPLE && this.renderSimplePart(),
|
|
229
|
+
this.state.mode === DateRangeInputMode.ADVANCED && this.renderAdvancedPart(),
|
|
230
|
+
React.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-end" } },
|
|
231
|
+
React.createElement(Switch, { style: { float: "right", marginTop: 8 }, checked: this.state.mode === DateRangeInputMode.ADVANCED, onChange: checked => {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
const mode = checked ? DateRangeInputMode.ADVANCED : DateRangeInputMode.SIMPLE;
|
|
234
|
+
this.setState({ mode: mode });
|
|
235
|
+
(_b = (_a = this.props).onModeChange) === null || _b === void 0 ? void 0 : _b.call(_a, mode);
|
|
236
|
+
}, checkedChildren: i18n("Advanced Mode"), unCheckedChildren: i18n("Simple Mode") }), (_b = (_a = this.props).confirmButtonsRenderer) === null || _b === void 0 ? void 0 :
|
|
237
|
+
_b.call(_a))));
|
|
238
|
+
}
|
|
239
|
+
renderInput() {
|
|
240
|
+
const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, disabled, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "disabled", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange"]);
|
|
241
|
+
let className = "ant-input ant-input-outlined";
|
|
242
|
+
if (disabled || this.state.popupVisible) {
|
|
243
|
+
className += " ant-input-disabled";
|
|
244
|
+
}
|
|
245
|
+
return (React.createElement("div", { style: Object.assign(Object.assign({}, style), { padding: 0, position: "relative" }), className: className, onFocus: this.props.onFocus, onBlur: this.props.onBlur },
|
|
246
|
+
React.createElement("div", { style: { display: "flex", paddingRight: 8 } },
|
|
247
|
+
React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, bordered: false, hidePopup: true, style: { width: "auto" }, inputStyle: { paddingRight: 2 }, onChange: (value) => {
|
|
248
|
+
var _a, _b;
|
|
249
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, this.props.toValue);
|
|
250
|
+
} })),
|
|
251
|
+
React.createElement("span", { style: { alignSelf: "center" } }, "\u27F7"),
|
|
252
|
+
React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, bordered: false, hidePopup: true, style: { width: "auto" }, inputStyle: { paddingLeft: 2 }, onChange: (value) => {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.fromValue, value);
|
|
255
|
+
} })),
|
|
256
|
+
!hidePopup && !renderAsCalendar &&
|
|
257
|
+
React.createElement(CalendarOutlined, { style: { cursor: (disabled || this.state.popupVisible) ? "not-allowed" : "pointer" }, onClick: (event) => {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
if (!disabled && document.createEvent) {
|
|
260
|
+
if (this.state.popupVisible) {
|
|
261
|
+
this.closePopup();
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
var ev = document.createEvent('HTMLEvents');
|
|
265
|
+
ev.initEvent('contextmenu', true, false);
|
|
266
|
+
event.target.dispatchEvent(ev);
|
|
267
|
+
(_b = (_a = this.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
} }))));
|
|
271
|
+
}
|
|
272
|
+
render() {
|
|
273
|
+
if (this.props.renderAsCalendar) {
|
|
274
|
+
return this.renderPopup();
|
|
275
|
+
}
|
|
276
|
+
else if (this.props.hidePopup) {
|
|
277
|
+
return this.renderInput();
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
return (React.createElement(Tooltip, { color: "white", key: "date-range-popup-" + this.state.popupKeyIndex, trigger: this.props.disabled ? [] : ["contextMenu"], align: this.props.align, placement: this.props.placement, overlayInnerStyle: { maxHeight: "100vh", overflowY: "auto", overflowX: "hidden" }, onOpenChange: (visible) => {
|
|
281
|
+
var _a, _b, _c, _d;
|
|
282
|
+
if (visible) {
|
|
283
|
+
(_b = (_a = this.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
(_d = (_c = this.props).onBlur) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
287
|
+
}
|
|
288
|
+
this.setState({ popupVisible: visible });
|
|
289
|
+
}, overlayClassName: "date-range-picker-popup", title: this.renderPopup() }, this.renderInput()));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
298
293
|
//# sourceMappingURL=dateRangeInput.js.map
|