d2coreui 21.0.33 → 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 -26
- 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,419 +1,447 @@
|
|
|
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 MaskedInput from "../input/maskedInput";
|
|
14
|
-
import padStart from 'lodash/padStart';
|
|
15
|
-
import isEqual from 'lodash/isEqual';
|
|
16
|
-
import debounce from 'lodash/debounce';
|
|
17
|
-
import
|
|
18
|
-
import { CalendarOutlined } from "@ant-design/icons";
|
|
19
|
-
import { Button, Calendar, Select, Tooltip } from "antd";
|
|
20
|
-
import { Key } from "ts-key-enum";
|
|
21
|
-
import { D2000UnixTimeNullValue } from "d2core/types/unixTimeUtils";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const MIN_TIME = moment.unix(0);
|
|
32
|
-
const MAX_TIME = moment().add(1000, "year");
|
|
33
|
-
export function allowDatesBeforeEpoch() {
|
|
34
|
-
DATE_TIME_DATA_MAP[4].min = 1902;
|
|
35
|
-
}
|
|
36
|
-
export default class DateTimeInput extends React.Component {
|
|
37
|
-
constructor(props) {
|
|
38
|
-
var _a, _b, _c, _d;
|
|
39
|
-
super(props);
|
|
40
|
-
this.inputRef = React.createRef();
|
|
41
|
-
this.today = moment();
|
|
42
|
-
this.state = {
|
|
43
|
-
valid: (!!props.value && props.value.isValid()) || (!!props.allowClear && props.value === null),
|
|
44
|
-
currentPos: null,
|
|
45
|
-
currentInfo: {
|
|
46
|
-
info: undefined,
|
|
47
|
-
time: undefined,
|
|
48
|
-
length: 0
|
|
49
|
-
},
|
|
50
|
-
popupCalendarVisible: false,
|
|
51
|
-
calendarSelectedDate: (_d = (_b = (_a = props.defaultSelectedDate) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : (_c = props.value) === null || _c === void 0 ? void 0 : _c.clone()) !== null && _d !== void 0 ? _d : moment().startOf('day'),
|
|
52
|
-
focused: false,
|
|
53
|
-
};
|
|
54
|
-
this.recalc = this.recalc.bind(this);
|
|
55
|
-
this.increment = this.increment.bind(this);
|
|
56
|
-
this.decrement = this.decrement.bind(this);
|
|
57
|
-
this.onItemMouseOver = debounce(this.onItemMouseOver.bind(this), 100, { maxWait: 100 });
|
|
58
|
-
}
|
|
59
|
-
componentDidUpdate(prevProps, _prevState, _snapshot) {
|
|
60
|
-
if (!isEqual(prevProps, this.props) && this.inputRef.current !== null) {
|
|
61
|
-
this.inputRef.current.input.selectionStart = this.state.currentPos;
|
|
62
|
-
this.inputRef.current.input.selectionEnd = this.state.currentPos;
|
|
63
|
-
if (prevProps.value !== this.props.value) {
|
|
64
|
-
this.setState({ valid: (!!this.props.value && this.props.value.isValid()) || (!!this.props.allowClear && this.props.value === null) });
|
|
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 MaskedInput from "../input/maskedInput";
|
|
14
|
+
import padStart from 'lodash/padStart';
|
|
15
|
+
import isEqual from 'lodash/isEqual';
|
|
16
|
+
import debounce from 'lodash/debounce';
|
|
17
|
+
import dayjs from "dayjs";
|
|
18
|
+
import { CalendarOutlined } from "@ant-design/icons";
|
|
19
|
+
import { Button, Calendar, Select, Tooltip } from "antd";
|
|
20
|
+
import { Key } from "ts-key-enum";
|
|
21
|
+
import { D2000UnixTimeNullValue } from "d2core/types/unixTimeUtils";
|
|
22
|
+
import { createStyles } from "antd-style";
|
|
23
|
+
import WithCss from "d2coreui/components/style/withCss";
|
|
24
|
+
const useStyles = createStyles(({ token, css, cx }) => {
|
|
25
|
+
return {
|
|
26
|
+
dateTimeInputCalendar: css `
|
|
27
|
+
// adaptations of date-picker calendar styles
|
|
28
|
+
.ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner:not(.date-picker-item-marked) {
|
|
29
|
+
color: inherit;
|
|
30
|
+
background: inherit;
|
|
65
31
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (this.inputRef.current !== null) {
|
|
78
|
-
this.setState({
|
|
79
|
-
currentInfo: DateTimeInput.parseDateTimeFormat(this.props.value, this.inputRef.current.input.value, this.props.mask, this.inputRef.current.input.selectionStart),
|
|
80
|
-
currentPos: this.inputRef.current.input.selectionStart,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
increment() {
|
|
85
|
-
var _a;
|
|
86
|
-
if (this.state.currentInfo.info !== undefined && !!this.props.value && DateTimeInput.isValid(this.state.currentInfo, this.props.value, 1)) {
|
|
87
|
-
const unit = this.state.currentInfo.info.unit;
|
|
88
|
-
this.incrementDate(unit);
|
|
89
|
-
}
|
|
90
|
-
(_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
91
|
-
}
|
|
92
|
-
incrementDate(unit) {
|
|
93
|
-
var _a, _b, _c, _d, _e;
|
|
94
|
-
if (!!this.props.value) {
|
|
95
|
-
this.props.value.add(1, unit);
|
|
96
|
-
if (!!this.props.maxDateTime && this.props.value.isAfter(this.props.maxDateTime)) {
|
|
97
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, (_c = this.props.maxDateTime) === null || _c === void 0 ? void 0 : _c.clone());
|
|
32
|
+
|
|
33
|
+
.ant-picker-panel:focus > .ant-picker-date-panel .ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner:before {
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
bottom: 0;
|
|
38
|
+
left: 0;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
border: 1px solid #096dd9;
|
|
41
|
+
border-radius: 2px;
|
|
42
|
+
content: '';
|
|
98
43
|
}
|
|
99
|
-
|
|
100
|
-
|
|
44
|
+
|
|
45
|
+
.ant-picker-content thead {
|
|
46
|
+
user-select: none;
|
|
101
47
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (this.state.currentInfo.info !== undefined && !!this.props.value && DateTimeInput.isValid(this.state.currentInfo, this.props.value, -1)) {
|
|
107
|
-
const unit = this.state.currentInfo.info.unit;
|
|
108
|
-
this.decrementDate(unit);
|
|
109
|
-
}
|
|
110
|
-
(_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
111
|
-
}
|
|
112
|
-
decrementDate(unit) {
|
|
113
|
-
var _a, _b, _c, _d, _e;
|
|
114
|
-
if (!!this.props.value) {
|
|
115
|
-
this.props.value.subtract(1, unit);
|
|
116
|
-
if (!!this.props.minDateTime && this.props.value.isBefore(this.props.minDateTime)) {
|
|
117
|
-
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, (_c = this.props.minDateTime) === null || _c === void 0 ? void 0 : _c.clone());
|
|
48
|
+
|
|
49
|
+
.date-picker-item-marked {
|
|
50
|
+
color: #fff;
|
|
51
|
+
background: #1890ff;
|
|
118
52
|
}
|
|
119
|
-
|
|
120
|
-
|
|
53
|
+
|
|
54
|
+
.ant-picker-cell-in-view.ant-picker-cell-today .ant-picker-cell-inner::before {
|
|
55
|
+
border: 1px solid #13c2c2;
|
|
121
56
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
(_b = (_a = this.props).onDateItemMouseOver) === null || _b === void 0 ? void 0 : _b.call(_a, itemDate);
|
|
127
|
-
}
|
|
128
|
-
renderCalendarNavigation(value) {
|
|
129
|
-
const start = 0;
|
|
130
|
-
const end = 12;
|
|
131
|
-
const monthOptions = [];
|
|
132
|
-
const current = value.clone();
|
|
133
|
-
const localeData = value.localeData();
|
|
134
|
-
const months = [];
|
|
135
|
-
for (let i = 0; i < 12; i++) {
|
|
136
|
-
current.month(i);
|
|
137
|
-
months.push(localeData.months(current));
|
|
138
|
-
}
|
|
139
|
-
for (let index = start; index < end; index++) {
|
|
140
|
-
monthOptions.push(React.createElement(Select.Option, { className: "month-item", key: `${index}`, value: `${index}` }, months[index]));
|
|
141
|
-
}
|
|
142
|
-
const month = value.month();
|
|
143
|
-
const year = value.year();
|
|
144
|
-
const options = [];
|
|
145
|
-
for (let i = year - 4; i <= year + 2; i += 1) {
|
|
146
|
-
options.push(React.createElement(Select.Option, { key: i, value: i, className: "year-item" }, i));
|
|
147
|
-
}
|
|
148
|
-
return (React.createElement("div", { style: { paddingBottom: 8 } },
|
|
149
|
-
React.createElement("div", { style: { float: "left", paddingBottom: 8, width: 140, display: "flex" } },
|
|
150
|
-
React.createElement(Button, { style: { width: 10, padding: 0 }, size: "small", type: "text", tabIndex: -1, disabled: !DateTimeInput.checkDateValueValidity(this.state.calendarSelectedDate, -1, "month"), onClick: () => {
|
|
151
|
-
this.state.calendarSelectedDate.subtract(1, "month");
|
|
152
|
-
this.setState({ calendarSelectedDate: this.state.calendarSelectedDate });
|
|
153
|
-
}, className: "ant-picker-header-prev-btn" },
|
|
154
|
-
React.createElement("span", { className: "ant-picker-prev-icon" })),
|
|
155
|
-
React.createElement(Select, { style: { flex: "1 1 auto" }, size: "small", dropdownMatchSelectWidth: false, dropdownStyle: { zIndex: 2070 }, getPopupContainer: this.props.getPopupContainer, value: String(month), onChange: selectedMonth => {
|
|
156
|
-
const newValue = this.state.calendarSelectedDate.clone();
|
|
157
|
-
newValue.month(parseInt(selectedMonth, 10));
|
|
158
|
-
this.setState({ calendarSelectedDate: newValue });
|
|
159
|
-
} }, monthOptions),
|
|
160
|
-
React.createElement(Button, { style: { width: 10, padding: 0 }, size: "small", type: "text", tabIndex: -1, className: "ant-picker-header-next-btn", onClick: () => {
|
|
161
|
-
this.state.calendarSelectedDate.add(1, "month");
|
|
162
|
-
this.setState({ calendarSelectedDate: this.state.calendarSelectedDate });
|
|
163
|
-
} },
|
|
164
|
-
React.createElement("span", { className: "ant-picker-next-icon" }))),
|
|
165
|
-
React.createElement("div", { style: { float: "right", paddingBottom: 8, width: 110 } },
|
|
166
|
-
React.createElement(Button, { style: { width: 12, padding: 0 }, size: "small", type: "text", tabIndex: -1, className: "ant-picker-header-prev-btn", onClick: () => {
|
|
167
|
-
this.state.calendarSelectedDate.subtract(1, "year");
|
|
168
|
-
this.setState({ calendarSelectedDate: this.state.calendarSelectedDate });
|
|
169
|
-
} },
|
|
170
|
-
React.createElement("span", { className: "ant-picker-prev-icon" })),
|
|
171
|
-
React.createElement(Select, { size: "small", style: { width: 84 }, dropdownMatchSelectWidth: false, dropdownStyle: { zIndex: 2070 }, getPopupContainer: this.props.getPopupContainer, onChange: newYear => {
|
|
172
|
-
const newValue = this.state.calendarSelectedDate.clone().year(parseInt(newYear, 10));
|
|
173
|
-
this.setState({ calendarSelectedDate: newValue });
|
|
174
|
-
}, value: String(year) }, options),
|
|
175
|
-
React.createElement(Button, { style: { width: 12, padding: 0 }, size: "small", type: "text", tabIndex: -1, className: "ant-picker-header-next-btn", onClick: () => {
|
|
176
|
-
this.state.calendarSelectedDate.add(1, "year");
|
|
177
|
-
this.setState({ calendarSelectedDate: this.state.calendarSelectedDate });
|
|
178
|
-
} },
|
|
179
|
-
React.createElement("span", { className: "ant-picker-next-icon" })))));
|
|
180
|
-
}
|
|
181
|
-
renderCalendar() {
|
|
182
|
-
var _a, _b;
|
|
183
|
-
return (React.createElement("div", { onKeyDown: !this.props.ignoreKeyStrokes ? (e) => {
|
|
184
|
-
var _a, _b, _c, _d;
|
|
185
|
-
if (e.key === Key.Enter) {
|
|
186
|
-
var tagName = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
187
|
-
if (tagName !== "input") {
|
|
188
|
-
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.state.calendarSelectedDate);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
} : undefined, onMouseOver: (e) => {
|
|
192
|
-
if (e.target instanceof HTMLTableCellElement) {
|
|
193
|
-
const date = moment(e.target.title, "YYYY-MM-DD");
|
|
194
|
-
this.onItemMouseOver(date);
|
|
195
|
-
}
|
|
196
|
-
} },
|
|
197
|
-
React.createElement(Calendar, { fullscreen: false, style: this.props.renderAsCalendar ? this.props.style : undefined, dateFullCellRender: ((date) => {
|
|
198
|
-
let className = date.isSame(this.today, "date") ? 'ant-picker-cell-inner ant-picker-calendar-date ant-picker-calendar-date-today' : 'ant-picker-cell-inner ant-picker-calendar-date';
|
|
199
|
-
const markedDateInterval = this.props.markedDateInterval;
|
|
200
|
-
if (markedDateInterval && (markedDateInterval[0].isBefore(date) || markedDateInterval[0].isSame(date, "millisecond")) &&
|
|
201
|
-
(markedDateInterval[1].isAfter(date) || markedDateInterval[1].isSame(date, "millisecond"))) {
|
|
202
|
-
className += " date-picker-item-marked";
|
|
203
|
-
}
|
|
204
|
-
else if (date.isSame(this.props.value, "date")) {
|
|
205
|
-
className += " date-picker-item-marked";
|
|
206
|
-
}
|
|
207
|
-
return (React.createElement("div", { className: className, style: { userSelect: "none" }, onKeyDown: (e) => {
|
|
208
|
-
var _a, _b, _c, _d;
|
|
209
|
-
if (e.key === Key.Enter) {
|
|
210
|
-
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : moment().startOf("day");
|
|
211
|
-
newValue = newValue.year(date.year()).month(date.month()).date(date.date());
|
|
212
|
-
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, date);
|
|
213
|
-
}
|
|
214
|
-
}, onMouseDown: () => {
|
|
215
|
-
var _a, _b, _c, _d;
|
|
216
|
-
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : moment().startOf("day");
|
|
217
|
-
newValue = newValue.year(date.year()).month(date.month()).date(date.date());
|
|
218
|
-
(_d = (_c = this.props).onDateItemMouseDown) === null || _d === void 0 ? void 0 : _d.call(_c, newValue);
|
|
219
|
-
}, onMouseUp: () => {
|
|
220
|
-
var _a, _b, _c, _d;
|
|
221
|
-
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : moment().startOf("day");
|
|
222
|
-
newValue = newValue.year(date.year()).month(date.month()).date(date.date());
|
|
223
|
-
(_d = (_c = this.props).onDateItemMouseUp) === null || _d === void 0 ? void 0 : _d.call(_c, newValue);
|
|
224
|
-
} },
|
|
225
|
-
React.createElement("div", { className: `ant-picker-calendar-date-value` }, padStart("" + date.date(), 2, '0')),
|
|
226
|
-
React.createElement("div", { className: `ant-picker-calendar-date-content` })));
|
|
227
|
-
}), headerRender: ({ value }) => {
|
|
228
|
-
return this.renderCalendarNavigation(value);
|
|
229
|
-
}, value: this.state.calendarSelectedDate, validRange: [(_a = this.props.minDateTime) !== null && _a !== void 0 ? _a : MIN_TIME, (_b = this.props.maxDateTime) !== null && _b !== void 0 ? _b : MAX_TIME], onSelect: (value) => {
|
|
230
|
-
var _a, _b, _c, _d;
|
|
231
|
-
if (window.event instanceof MouseEvent) {
|
|
232
|
-
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : moment().startOf("day");
|
|
233
|
-
newValue = newValue.year(value.year()).month(value.month()).date(value.date());
|
|
234
|
-
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, newValue);
|
|
235
|
-
}
|
|
236
|
-
this.setState({ calendarSelectedDate: value, popupCalendarVisible: false });
|
|
237
|
-
} })));
|
|
238
|
-
}
|
|
239
|
-
renderInput() {
|
|
240
|
-
var _a;
|
|
241
|
-
const _b = this.props, { mask, value, onChange, onInvalidValue, style, disabled, inputDisabled, bordered, hidePopup, renderAsCalendar, allowClear, minDateTime, maxDateTime, onDateItemMouseDown, onDateItemMouseOver, onDateItemMouseUp, markedDateInterval, inputStyle, getPopupContainer, autoFocus, className } = _b, props = __rest(_b, ["mask", "value", "onChange", "onInvalidValue", "style", "disabled", "inputDisabled", "bordered", "hidePopup", "renderAsCalendar", "allowClear", "minDateTime", "maxDateTime", "onDateItemMouseDown", "onDateItemMouseOver", "onDateItemMouseUp", "markedDateInterval", "inputStyle", "getPopupContainer", "autoFocus", "className"]);
|
|
242
|
-
const isUpDisabled = disabled || this.state.currentInfo.info === undefined || !DateTimeInput.isValid(this.state.currentInfo, this.props.value, 1);
|
|
243
|
-
const isDownDisabled = disabled || this.state.currentInfo.info === undefined || !DateTimeInput.isValid(this.state.currentInfo, this.props.value, -1);
|
|
244
|
-
const unix = value === null || value === void 0 ? void 0 : value.valueOf();
|
|
245
|
-
let divClassName = "custom-date-time-picker";
|
|
246
|
-
if (disabled || inputDisabled) {
|
|
247
|
-
divClassName += " ant-input-number disabled ant-input-disabled readonly";
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
divClassName += " ant-input-number";
|
|
251
|
-
}
|
|
252
|
-
if (bordered === false) {
|
|
253
|
-
divClassName += " ant-input-borderless";
|
|
254
|
-
}
|
|
255
|
-
const maskedInputStyle = { color: this.state.valid ? "inherit" : "red", border: "none" };
|
|
256
|
-
if (inputStyle) {
|
|
257
|
-
Object.assign(maskedInputStyle, inputStyle);
|
|
258
|
-
}
|
|
259
|
-
return (React.createElement("div", Object.assign({ style: bordered === false ? Object.assign(Object.assign({}, style), { border: 0 }) : style }, props, { className: (className ? className + " " : "") + divClassName }),
|
|
260
|
-
React.createElement("div", { className: "ant-input-number-input-wrap", onKeyDown: (event) => {
|
|
261
|
-
if (event.keyCode === 38) {
|
|
262
|
-
this.increment();
|
|
263
|
-
event.preventDefault();
|
|
264
|
-
event.stopPropagation();
|
|
265
|
-
}
|
|
266
|
-
else if (event.keyCode === 40) {
|
|
267
|
-
this.decrement();
|
|
268
|
-
event.preventDefault();
|
|
269
|
-
event.stopPropagation();
|
|
270
|
-
}
|
|
271
|
-
} },
|
|
272
|
-
React.createElement(MaskedInput, { mask: this.props.mask.replace(/[a-zA-Z]/g, '1'), bordered: bordered, ref: this.inputRef, style: maskedInputStyle, value: (this.state.focused || unix !== D2000UnixTimeNullValue * 1000) ? ((_a = value === null || value === void 0 ? void 0 : value.locale("locale.d2000").format(this.props.mask)) !== null && _a !== void 0 ? _a : "") : "", placeholder: (!this.state.focused && unix === D2000UnixTimeNullValue * 1000) ? "Null Time" : undefined, onFocus: (event => {
|
|
273
|
-
event.target.selectionStart = event.target.selectionEnd = this.state.currentPos;
|
|
274
|
-
this.setState({ focused: true });
|
|
275
|
-
}), onBlur: () => {
|
|
276
|
-
this.setState({ focused: false });
|
|
277
|
-
}, autoFocus: autoFocus, disabled: disabled || inputDisabled, onWheel: (event) => {
|
|
278
|
-
if (event.deltaY > 0) {
|
|
279
|
-
if (!isDownDisabled) {
|
|
280
|
-
this.decrement();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
if (event.deltaY < 0) {
|
|
284
|
-
if (!isUpDisabled) {
|
|
285
|
-
this.increment();
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}, onMouseUp: this.recalc, onKeyUp: this.recalc, onChange: (event) => {
|
|
289
|
-
const inputString = event.target.value;
|
|
290
|
-
const value = DateTimeInput.parseDateTimeFormat(this.props.value, inputString, this.props.mask, event.target.selectionStart);
|
|
291
|
-
if (value.time !== undefined) {
|
|
292
|
-
if (this.props.minDateTime !== undefined && value.time.isBefore(this.props.minDateTime)) {
|
|
293
|
-
value.time = this.props.minDateTime.clone();
|
|
294
|
-
}
|
|
295
|
-
if (this.props.maxDateTime !== undefined && value.time.isAfter(this.props.maxDateTime)) {
|
|
296
|
-
value.time = this.props.maxDateTime.clone();
|
|
297
|
-
}
|
|
298
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value.time.clone());
|
|
299
|
-
}
|
|
300
|
-
else if (!!this.props.allowClear && !inputString) {
|
|
301
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
onInvalidValue === null || onInvalidValue === void 0 ? void 0 : onInvalidValue(inputString);
|
|
305
|
-
}
|
|
306
|
-
this.setState({
|
|
307
|
-
valid: (value.time !== undefined && value.time.isValid()) || (!!this.props.allowClear && !inputString),
|
|
308
|
-
currentInfo: value
|
|
309
|
-
});
|
|
310
|
-
} })),
|
|
311
|
-
!hidePopup && !renderAsCalendar && React.createElement("div", { className: "ant-input-number-handler-wrap", style: {
|
|
312
|
-
width: 28,
|
|
313
|
-
opacity: 1,
|
|
314
|
-
height: "100%",
|
|
315
|
-
textAlign: "center",
|
|
316
|
-
cursor: "pointer",
|
|
317
|
-
background: "transparent",
|
|
318
|
-
border: bordered === false ? 0 : undefined
|
|
319
|
-
}, onClick: (event) => {
|
|
320
|
-
if (document.createEvent) {
|
|
321
|
-
var ev = document.createEvent('HTMLEvents');
|
|
322
|
-
ev.initEvent('contextmenu', true, false);
|
|
323
|
-
event.target.dispatchEvent(ev);
|
|
324
|
-
}
|
|
325
|
-
} },
|
|
326
|
-
React.createElement(CalendarOutlined, { style: { color: "rgba(0,0,0,0.65)", verticalAlign: "middle", marginTop: 2 } }))));
|
|
327
|
-
}
|
|
328
|
-
render() {
|
|
329
|
-
if (this.props.renderAsCalendar) {
|
|
330
|
-
return this.renderCalendar();
|
|
331
|
-
}
|
|
332
|
-
else if (this.props.hidePopup) {
|
|
333
|
-
return this.renderInput();
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
return (React.createElement(Tooltip, { color: "white", trigger: this.props.disabled ? [] : ["contextMenu"], getPopupContainer: this.props.getPopupContainer, overlayInnerStyle: { maxHeight: "100vh", overflowY: "auto", overflowX: "hidden", width: 266 }, open: this.state.popupCalendarVisible, onOpenChange: (visible) => {
|
|
337
|
-
var _a, _b, _c, _d;
|
|
338
|
-
this.setState({ popupCalendarVisible: visible });
|
|
339
|
-
if (visible) {
|
|
340
|
-
this.setState({ calendarSelectedDate: (_d = (_b = (_a = this.props.defaultSelectedDate) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : (_c = this.props.value) === null || _c === void 0 ? void 0 : _c.clone()) !== null && _d !== void 0 ? _d : moment().startOf("day") });
|
|
341
|
-
}
|
|
342
|
-
}, title: this.renderCalendar(), placement: this.props.placement }, this.renderInput()));
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
static isValid(info, value, offset) {
|
|
346
|
-
var _a;
|
|
347
|
-
const unit = (_a = info.info) === null || _a === void 0 ? void 0 : _a.unit;
|
|
348
|
-
return this.checkDateValueValidity(value, offset, unit);
|
|
349
|
-
}
|
|
350
|
-
static checkDateValueValidity(value, offset, unit) {
|
|
351
|
-
if (value === null) {
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
let v = value.clone().add(offset, unit);
|
|
355
|
-
return v.isValid() && v.isSameOrAfter(moment(0));
|
|
356
|
-
}
|
|
357
|
-
static parseDateTimeFormat(previousTime, value, mask, cursorPos) {
|
|
358
|
-
var _a, _b, _c;
|
|
359
|
-
let result = {
|
|
360
|
-
time: moment(0).startOf("day"),
|
|
361
|
-
info: undefined,
|
|
362
|
-
length: 0,
|
|
363
|
-
};
|
|
364
|
-
for (let v of DATE_TIME_DATA_MAP) {
|
|
365
|
-
let index = -1;
|
|
366
|
-
let length = 0;
|
|
367
|
-
let min = 0;
|
|
368
|
-
let max = 0;
|
|
369
|
-
if (Array.isArray(v.key) || Array.isArray(v.min) || Array.isArray(v.max)) {
|
|
370
|
-
for (let i = 0; i < v.key.length; i++) {
|
|
371
|
-
const x = v.key[i];
|
|
372
|
-
index = mask.indexOf(x);
|
|
373
|
-
if (index !== -1) {
|
|
374
|
-
length = x.length;
|
|
375
|
-
min = v.min[i];
|
|
376
|
-
max = v.max[i];
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
57
|
+
|
|
58
|
+
.ant-picker-cell:hover:not(.ant-picker-cell-in-view) .ant-picker-cell-inner, .ant-picker-cell:hover:not(.ant-picker-cell-selected):not(.ant-picker-cell-range-start):not(.ant-picker-cell-range-end):not(.ant-picker-cell-range-hover-start):not(.ant-picker-cell-range-hover-end) .ant-picker-cell-inner {
|
|
59
|
+
background: #1890ff;
|
|
60
|
+
color: rgba(0, 0, 0, 0.85);
|
|
380
61
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
62
|
+
`,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
const DATE_TIME_DATA_MAP = [
|
|
66
|
+
{ key: "SSS", min: 0, max: 999, unit: "ms" },
|
|
67
|
+
{ key: "ss", min: 0, max: 59, unit: "s" },
|
|
68
|
+
{ key: "mm", min: 0, max: 59, unit: "m" },
|
|
69
|
+
{ key: "HH", min: 0, max: 23, unit: "h" },
|
|
70
|
+
{ key: ["YYYY", "YY"], min: [1900, 0], max: [9999, 99], unit: "y" },
|
|
71
|
+
{ key: "MM", min: 1, max: 12, unit: "M" },
|
|
72
|
+
{ key: "DD", min: 1, max: 31, unit: "d" },
|
|
73
|
+
];
|
|
74
|
+
const MIN_TIME = dayjs.unix(0);
|
|
75
|
+
const MAX_TIME = dayjs().add(1000, "year");
|
|
76
|
+
export function allowDatesBeforeEpoch() {
|
|
77
|
+
DATE_TIME_DATA_MAP[4].min = 1902;
|
|
78
|
+
}
|
|
79
|
+
export default class DateTimeInput extends React.Component {
|
|
80
|
+
constructor(props) {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
super(props);
|
|
83
|
+
this.inputRef = React.createRef();
|
|
84
|
+
this.today = dayjs();
|
|
85
|
+
this.state = {
|
|
86
|
+
valid: DateTimeInput.isValidValue(props.value, props.minDateTime, props.maxDateTime, props.allowClear),
|
|
87
|
+
currentPos: null,
|
|
88
|
+
currentInfo: {
|
|
89
|
+
info: undefined,
|
|
90
|
+
time: undefined,
|
|
91
|
+
length: 0
|
|
92
|
+
},
|
|
93
|
+
popupCalendarVisible: false,
|
|
94
|
+
calendarSelectedDate: (_d = (_b = (_a = props.defaultSelectedDate) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : (_c = props.value) === null || _c === void 0 ? void 0 : _c.clone()) !== null && _d !== void 0 ? _d : dayjs().startOf('day'),
|
|
95
|
+
focused: false,
|
|
96
|
+
};
|
|
97
|
+
this.recalc = this.recalc.bind(this);
|
|
98
|
+
this.increment = this.increment.bind(this);
|
|
99
|
+
this.decrement = this.decrement.bind(this);
|
|
100
|
+
this.onItemMouseOver = debounce(this.onItemMouseOver.bind(this), 100, { maxWait: 100 });
|
|
101
|
+
}
|
|
102
|
+
componentDidUpdate(prevProps, _prevState, _snapshot) {
|
|
103
|
+
if (!isEqual(prevProps, this.props) && this.inputRef.current !== null) {
|
|
104
|
+
this.inputRef.current.input.selectionStart = this.state.currentPos;
|
|
105
|
+
this.inputRef.current.input.selectionEnd = this.state.currentPos;
|
|
106
|
+
if (prevProps.value !== this.props.value) {
|
|
107
|
+
this.setState({ valid: DateTimeInput.isValidValue(this.props.value, this.props.minDateTime, this.props.maxDateTime, this.props.allowClear) });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
get input() {
|
|
112
|
+
var _a;
|
|
113
|
+
return (_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
|
|
114
|
+
}
|
|
115
|
+
focus() {
|
|
116
|
+
var _a;
|
|
117
|
+
(_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
118
|
+
}
|
|
119
|
+
recalc() {
|
|
120
|
+
if (this.inputRef.current !== null) {
|
|
121
|
+
this.setState({
|
|
122
|
+
currentInfo: DateTimeInput.parseDateTimeFormat(this.props.value, this.inputRef.current.input.value, this.props.mask, this.inputRef.current.input.selectionStart),
|
|
123
|
+
currentPos: this.inputRef.current.input.selectionStart,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
increment() {
|
|
128
|
+
var _a;
|
|
129
|
+
if (this.state.currentInfo.info !== undefined && !!this.props.value && DateTimeInput.isValid(this.state.currentInfo, this.props.value, 1)) {
|
|
130
|
+
const unit = this.state.currentInfo.info.unit;
|
|
131
|
+
this.incrementDate(unit);
|
|
132
|
+
}
|
|
133
|
+
(_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
134
|
+
}
|
|
135
|
+
incrementDate(unit) {
|
|
136
|
+
var _a, _b, _c, _d, _e;
|
|
137
|
+
if (!!this.props.value) {
|
|
138
|
+
const value = this.props.value.clone().add(1, unit);
|
|
139
|
+
if (!!this.props.maxDateTime && value.isAfter(this.props.maxDateTime)) {
|
|
140
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, (_c = this.props.maxDateTime) === null || _c === void 0 ? void 0 : _c.clone());
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
(_e = (_d = this.props).onChange) === null || _e === void 0 ? void 0 : _e.call(_d, value);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
decrement() {
|
|
148
|
+
var _a;
|
|
149
|
+
if (this.state.currentInfo.info !== undefined && !!this.props.value && DateTimeInput.isValid(this.state.currentInfo, this.props.value, -1)) {
|
|
150
|
+
const unit = this.state.currentInfo.info.unit;
|
|
151
|
+
this.decrementDate(unit);
|
|
152
|
+
}
|
|
153
|
+
(_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
154
|
+
}
|
|
155
|
+
decrementDate(unit) {
|
|
156
|
+
var _a, _b, _c, _d, _e;
|
|
157
|
+
if (!!this.props.value) {
|
|
158
|
+
const value = this.props.value.clone().subtract(1, unit);
|
|
159
|
+
if (!!this.props.minDateTime && value.isBefore(this.props.minDateTime)) {
|
|
160
|
+
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, (_c = this.props.minDateTime) === null || _c === void 0 ? void 0 : _c.clone());
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
(_e = (_d = this.props).onChange) === null || _e === void 0 ? void 0 : _e.call(_d, value);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
onItemMouseOver(itemDate) {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
(_b = (_a = this.props).onDateItemMouseOver) === null || _b === void 0 ? void 0 : _b.call(_a, itemDate);
|
|
170
|
+
}
|
|
171
|
+
renderCalendarNavigation(value) {
|
|
172
|
+
const start = 0;
|
|
173
|
+
const end = 12;
|
|
174
|
+
const monthOptions = [];
|
|
175
|
+
const current = value.clone();
|
|
176
|
+
const localeData = value.localeData();
|
|
177
|
+
const months = [];
|
|
178
|
+
for (let i = 0; i < 12; i++) {
|
|
179
|
+
months.push(localeData.months(current.month(i)));
|
|
180
|
+
}
|
|
181
|
+
for (let index = start; index < end; index++) {
|
|
182
|
+
monthOptions.push(React.createElement(Select.Option, { key: `${index}`, value: `${index}` }, months[index]));
|
|
183
|
+
}
|
|
184
|
+
const month = value.month();
|
|
185
|
+
const year = value.year();
|
|
186
|
+
const options = [];
|
|
187
|
+
for (let i = year - 4; i <= year + 2; i += 1) {
|
|
188
|
+
options.push(React.createElement(Select.Option, { key: `${i}`, value: `${i}` }, i));
|
|
189
|
+
}
|
|
190
|
+
const calendarSelectedDate = this.state.calendarSelectedDate;
|
|
191
|
+
return (React.createElement("div", { style: { display: "flex", marginBottom: 6 } },
|
|
192
|
+
React.createElement("div", { style: { display: "flex", width: 140 } },
|
|
193
|
+
React.createElement(Button, { style: { width: 10, padding: 0 }, size: "small", type: "text", tabIndex: -1, disabled: !DateTimeInput.checkDateValueValidity(calendarSelectedDate, -1, "month"), onClick: () => {
|
|
194
|
+
this.setState({ calendarSelectedDate: calendarSelectedDate.subtract(1, "month") });
|
|
195
|
+
}, className: "ant-picker-header-prev-btn" },
|
|
196
|
+
React.createElement("span", { className: "ant-picker-prev-icon" })),
|
|
197
|
+
React.createElement(Select, { style: { flex: "1 1 auto" }, size: "small", popupMatchSelectWidth: false, dropdownStyle: { zIndex: 2070 }, getPopupContainer: this.props.getPopupContainer, value: String(month), onChange: selectedMonth => {
|
|
198
|
+
this.setState({ calendarSelectedDate: calendarSelectedDate.month(parseInt(selectedMonth, 10)) });
|
|
199
|
+
} }, monthOptions),
|
|
200
|
+
React.createElement(Button, { style: { width: 10, padding: 0 }, size: "small", type: "text", tabIndex: -1, className: "ant-picker-header-next-btn", onClick: () => {
|
|
201
|
+
this.setState({ calendarSelectedDate: calendarSelectedDate.add(1, "month") });
|
|
202
|
+
} },
|
|
203
|
+
React.createElement("span", { className: "ant-picker-next-icon" }))),
|
|
204
|
+
React.createElement("div", { style: { display: "flex", width: 110 } },
|
|
205
|
+
React.createElement(Button, { style: { width: 12, padding: 0 }, size: "small", type: "text", tabIndex: -1, className: "ant-picker-header-prev-btn", onClick: () => {
|
|
206
|
+
this.setState({ calendarSelectedDate: calendarSelectedDate.subtract(1, "year") });
|
|
207
|
+
} },
|
|
208
|
+
React.createElement("span", { className: "ant-picker-prev-icon" })),
|
|
209
|
+
React.createElement(Select, { size: "small", style: { width: 84 }, popupMatchSelectWidth: false, dropdownStyle: { zIndex: 2070 }, getPopupContainer: this.props.getPopupContainer, onChange: newYear => {
|
|
210
|
+
this.setState({ calendarSelectedDate: calendarSelectedDate.year(parseInt(newYear, 10)) });
|
|
211
|
+
}, value: String(year) }, options),
|
|
212
|
+
React.createElement(Button, { style: { width: 12, padding: 0 }, size: "small", type: "text", tabIndex: -1, className: "ant-picker-header-next-btn", onClick: () => {
|
|
213
|
+
this.setState({ calendarSelectedDate: calendarSelectedDate.add(1, "year") });
|
|
214
|
+
} },
|
|
215
|
+
React.createElement("span", { className: "ant-picker-next-icon" })))));
|
|
216
|
+
}
|
|
217
|
+
renderCalendar() {
|
|
218
|
+
return (React.createElement("div", { onKeyDown: !this.props.ignoreKeyStrokes ? (e) => {
|
|
219
|
+
var _a, _b, _c, _d;
|
|
220
|
+
if (e.key === Key.Enter) {
|
|
221
|
+
var tagName = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
222
|
+
if (tagName !== "input") {
|
|
223
|
+
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.state.calendarSelectedDate);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} : undefined, onMouseOver: (e) => {
|
|
227
|
+
if (e.target instanceof HTMLTableCellElement) {
|
|
228
|
+
const date = dayjs(e.target.title, "YYYY-MM-DD");
|
|
229
|
+
this.onItemMouseOver(date);
|
|
230
|
+
}
|
|
231
|
+
} },
|
|
232
|
+
React.createElement(WithCss, { useStyles: useStyles }, (css) => {
|
|
233
|
+
var _a, _b;
|
|
234
|
+
return React.createElement(Calendar, { className: css.styles.dateTimeInputCalendar, fullscreen: false, style: this.props.renderAsCalendar ? this.props.style : undefined, fullCellRender: ((date) => {
|
|
235
|
+
let className = date.isSame(this.today, "date") ? 'ant-picker-cell-inner ant-picker-calendar-date ant-picker-calendar-date-today' : 'ant-picker-cell-inner ant-picker-calendar-date';
|
|
236
|
+
const markedDateInterval = this.props.markedDateInterval;
|
|
237
|
+
if (markedDateInterval && (markedDateInterval[0].isBefore(date) || markedDateInterval[0].isSame(date, "millisecond")) &&
|
|
238
|
+
(markedDateInterval[1].isAfter(date) || markedDateInterval[1].isSame(date, "millisecond"))) {
|
|
239
|
+
className += " date-picker-item-marked";
|
|
240
|
+
}
|
|
241
|
+
else if (date.isSame(this.props.value, "date")) {
|
|
242
|
+
className += " date-picker-item-marked";
|
|
243
|
+
}
|
|
244
|
+
return (React.createElement("div", { className: className, style: { userSelect: "none" }, onKeyDown: (e) => {
|
|
245
|
+
var _a, _b, _c, _d;
|
|
246
|
+
if (e.key === Key.Enter) {
|
|
247
|
+
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : dayjs().startOf("day");
|
|
248
|
+
newValue = newValue.year(date.year()).month(date.month()).date(date.date());
|
|
249
|
+
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, newValue);
|
|
250
|
+
}
|
|
251
|
+
}, onMouseDown: () => {
|
|
252
|
+
var _a, _b, _c, _d;
|
|
253
|
+
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : dayjs().startOf("day");
|
|
254
|
+
newValue = newValue.year(date.year()).month(date.month()).date(date.date());
|
|
255
|
+
(_d = (_c = this.props).onDateItemMouseDown) === null || _d === void 0 ? void 0 : _d.call(_c, newValue);
|
|
256
|
+
}, onMouseUp: () => {
|
|
257
|
+
var _a, _b, _c, _d;
|
|
258
|
+
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : dayjs().startOf("day");
|
|
259
|
+
newValue = newValue.year(date.year()).month(date.month()).date(date.date());
|
|
260
|
+
(_d = (_c = this.props).onDateItemMouseUp) === null || _d === void 0 ? void 0 : _d.call(_c, newValue);
|
|
261
|
+
} },
|
|
262
|
+
React.createElement("div", { className: `ant-picker-calendar-date-value` }, padStart("" + date.date(), 2, '0')),
|
|
263
|
+
React.createElement("div", { className: `ant-picker-calendar-date-content` })));
|
|
264
|
+
}), headerRender: ({ value }) => {
|
|
265
|
+
return this.renderCalendarNavigation(value);
|
|
266
|
+
}, value: this.state.calendarSelectedDate, validRange: [(_a = this.props.minDateTime) !== null && _a !== void 0 ? _a : MIN_TIME, (_b = this.props.maxDateTime) !== null && _b !== void 0 ? _b : MAX_TIME], onSelect: (value) => {
|
|
267
|
+
var _a, _b, _c, _d;
|
|
268
|
+
if (window.event instanceof MouseEvent) {
|
|
269
|
+
let newValue = (_b = (_a = this.props.value) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : dayjs().startOf("day");
|
|
270
|
+
newValue = newValue.year(value.year()).month(value.month()).date(value.date());
|
|
271
|
+
(_d = (_c = this.props).onChange) === null || _d === void 0 ? void 0 : _d.call(_c, newValue);
|
|
272
|
+
}
|
|
273
|
+
this.setState({ calendarSelectedDate: value, popupCalendarVisible: false });
|
|
274
|
+
} });
|
|
275
|
+
})));
|
|
276
|
+
}
|
|
277
|
+
renderInput() {
|
|
278
|
+
var _a;
|
|
279
|
+
const _b = this.props, { mask, value, onChange, onInvalidValue, style, disabled, inputDisabled, bordered, hidePopup, renderAsCalendar, allowClear, minDateTime, maxDateTime, onDateItemMouseDown, onDateItemMouseOver, onDateItemMouseUp, markedDateInterval, inputStyle, getPopupContainer, autoFocus, className, size } = _b, props = __rest(_b, ["mask", "value", "onChange", "onInvalidValue", "style", "disabled", "inputDisabled", "bordered", "hidePopup", "renderAsCalendar", "allowClear", "minDateTime", "maxDateTime", "onDateItemMouseDown", "onDateItemMouseOver", "onDateItemMouseUp", "markedDateInterval", "inputStyle", "getPopupContainer", "autoFocus", "className", "size"]);
|
|
280
|
+
const isUpDisabled = disabled || this.state.currentInfo.info === undefined || !DateTimeInput.isValid(this.state.currentInfo, this.props.value, 1);
|
|
281
|
+
const isDownDisabled = disabled || this.state.currentInfo.info === undefined || !DateTimeInput.isValid(this.state.currentInfo, this.props.value, -1);
|
|
282
|
+
const unix = value === null || value === void 0 ? void 0 : value.valueOf();
|
|
283
|
+
const maskedInputStyle = { color: this.state.valid ? undefined : "#ff4d4f" };
|
|
284
|
+
if (inputStyle) {
|
|
285
|
+
Object.assign(maskedInputStyle, inputStyle);
|
|
286
|
+
}
|
|
287
|
+
return (React.createElement("div", Object.assign({ style: Object.assign(Object.assign({}, style), { position: "relative" }) }, props, { className: className }),
|
|
288
|
+
React.createElement("div", { onKeyDown: (event) => {
|
|
289
|
+
if (event.code === "ArrowUp") {
|
|
290
|
+
this.increment();
|
|
291
|
+
event.preventDefault();
|
|
292
|
+
event.stopPropagation();
|
|
293
|
+
}
|
|
294
|
+
else if (event.code === "ArrowDown") {
|
|
295
|
+
this.decrement();
|
|
296
|
+
event.preventDefault();
|
|
297
|
+
event.stopPropagation();
|
|
298
|
+
}
|
|
299
|
+
} },
|
|
300
|
+
React.createElement(MaskedInput, { mask: this.props.mask.replace(/[a-zA-Z]/g, '1'), bordered: bordered, ref: this.inputRef, style: maskedInputStyle, size: size, value: (this.state.focused || unix !== D2000UnixTimeNullValue * 1000) ? ((_a = value === null || value === void 0 ? void 0 : value.locale("locale.d2000").format(this.props.mask)) !== null && _a !== void 0 ? _a : "") : "", placeholder: (!this.state.focused && unix === D2000UnixTimeNullValue * 1000) ? "Null Time" : undefined, onFocus: (event => {
|
|
301
|
+
event.target.selectionStart = event.target.selectionEnd = this.state.currentPos;
|
|
302
|
+
this.setState({ focused: true });
|
|
303
|
+
}), onBlur: () => {
|
|
304
|
+
this.setState({ focused: false });
|
|
305
|
+
}, autoFocus: autoFocus, disabled: disabled || inputDisabled, onWheel: (event) => {
|
|
306
|
+
if (event.deltaY > 0) {
|
|
307
|
+
if (!isDownDisabled) {
|
|
308
|
+
this.decrement();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (event.deltaY < 0) {
|
|
312
|
+
if (!isUpDisabled) {
|
|
313
|
+
this.increment();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}, onMouseUp: this.recalc, onKeyUp: this.recalc, onChange: (event) => {
|
|
317
|
+
const inputString = event.target.value;
|
|
318
|
+
const value = DateTimeInput.parseDateTimeFormat(this.props.value, inputString, this.props.mask, event.target.selectionStart);
|
|
319
|
+
const valid = DateTimeInput.isValidValue(value.time, this.props.minDateTime, this.props.maxDateTime, this.props.allowClear) || (!!this.props.allowClear && !inputString);
|
|
320
|
+
if (value.time !== undefined && valid) {
|
|
321
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value.time.clone());
|
|
322
|
+
}
|
|
323
|
+
else if (!!this.props.allowClear && !inputString) {
|
|
324
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
onInvalidValue === null || onInvalidValue === void 0 ? void 0 : onInvalidValue(inputString);
|
|
328
|
+
}
|
|
329
|
+
this.setState({
|
|
330
|
+
valid: valid,
|
|
331
|
+
currentInfo: value
|
|
332
|
+
});
|
|
333
|
+
} })),
|
|
334
|
+
!hidePopup && !renderAsCalendar && React.createElement("div", { style: {
|
|
335
|
+
width: 28,
|
|
336
|
+
opacity: 1,
|
|
337
|
+
height: "100%",
|
|
338
|
+
textAlign: "center",
|
|
339
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
340
|
+
background: "transparent",
|
|
341
|
+
position: "absolute",
|
|
342
|
+
top: 0,
|
|
343
|
+
right: 0,
|
|
344
|
+
}, onClick: (event) => {
|
|
345
|
+
if (document.createEvent) {
|
|
346
|
+
var ev = document.createEvent('HTMLEvents');
|
|
347
|
+
ev.initEvent('contextmenu', true, false);
|
|
348
|
+
event.target.dispatchEvent(ev);
|
|
349
|
+
}
|
|
350
|
+
} },
|
|
351
|
+
React.createElement(CalendarOutlined, { style: { color: "rgba(0,0,0,0.65)", verticalAlign: "middle", height: "100%" } }))));
|
|
352
|
+
}
|
|
353
|
+
render() {
|
|
354
|
+
if (this.props.renderAsCalendar) {
|
|
355
|
+
return this.renderCalendar();
|
|
356
|
+
}
|
|
357
|
+
else if (this.props.hidePopup) {
|
|
358
|
+
return this.renderInput();
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
return (React.createElement(Tooltip, { color: "white", trigger: this.props.disabled ? [] : ["contextMenu"], getPopupContainer: this.props.getPopupContainer, overlayInnerStyle: { maxHeight: "100vh", overflowY: "auto", overflowX: "hidden", width: 266 }, open: this.state.popupCalendarVisible, onOpenChange: (visible) => {
|
|
362
|
+
var _a, _b, _c, _d;
|
|
363
|
+
this.setState({ popupCalendarVisible: visible });
|
|
364
|
+
if (visible) {
|
|
365
|
+
this.setState({ calendarSelectedDate: (_d = (_b = (_a = this.props.defaultSelectedDate) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : (_c = this.props.value) === null || _c === void 0 ? void 0 : _c.clone()) !== null && _d !== void 0 ? _d : dayjs().startOf("day") });
|
|
366
|
+
}
|
|
367
|
+
}, title: this.renderCalendar(), placement: this.props.placement }, this.renderInput()));
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
static isValid(info, value, offset) {
|
|
371
|
+
var _a;
|
|
372
|
+
const unit = (_a = info.info) === null || _a === void 0 ? void 0 : _a.unit;
|
|
373
|
+
return this.checkDateValueValidity(value, offset, unit);
|
|
374
|
+
}
|
|
375
|
+
static checkDateValueValidity(value, offset, unit) {
|
|
376
|
+
if (value === null) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
let v = value.clone().add(offset, unit);
|
|
380
|
+
return v.isValid() && v.isSameOrAfter(dayjs(0));
|
|
381
|
+
}
|
|
382
|
+
static parseDateTimeFormat(previousTime, value, mask, cursorPos) {
|
|
383
|
+
var _a, _b, _c;
|
|
384
|
+
let result = {
|
|
385
|
+
time: dayjs().startOf("day"),
|
|
386
|
+
info: undefined,
|
|
387
|
+
length: 0,
|
|
388
|
+
};
|
|
389
|
+
for (let v of DATE_TIME_DATA_MAP) {
|
|
390
|
+
let index = -1;
|
|
391
|
+
let length = 0;
|
|
392
|
+
let min = 0;
|
|
393
|
+
let max = 0;
|
|
394
|
+
if (Array.isArray(v.key) || Array.isArray(v.min) || Array.isArray(v.max)) {
|
|
395
|
+
for (let i = 0; i < v.key.length; i++) {
|
|
396
|
+
const x = v.key[i];
|
|
397
|
+
index = mask.indexOf(x);
|
|
398
|
+
if (index !== -1) {
|
|
399
|
+
length = x.length;
|
|
400
|
+
min = v.min[i];
|
|
401
|
+
max = v.max[i];
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
index = mask.indexOf(v.key);
|
|
408
|
+
length = v.key.length;
|
|
409
|
+
min = v.min;
|
|
410
|
+
max = v.max;
|
|
411
|
+
}
|
|
412
|
+
if (index !== -1) {
|
|
413
|
+
let val = Number(value.substring(index, index + length));
|
|
414
|
+
if (!isNaN(val) && val >= min && val <= max) {
|
|
415
|
+
if (v.unit === "M") {
|
|
416
|
+
val--;
|
|
417
|
+
}
|
|
418
|
+
if (v.unit === "d") {
|
|
419
|
+
result.time = (_a = result.time) === null || _a === void 0 ? void 0 : _a.set('D', val);
|
|
420
|
+
}
|
|
421
|
+
else if (v.unit === "y" && length === 2) {
|
|
422
|
+
const century = (previousTime != null && previousTime.isValid()) ? Math.floor(previousTime.year() / 100) * 100 : (val > 70 ? 1900 : 2000);
|
|
423
|
+
result.time = (_b = result.time) === null || _b === void 0 ? void 0 : _b.set(v.unit, century + val);
|
|
424
|
+
}
|
|
425
|
+
else if (v.unit !== "weeks" && v.unit !== "week" && v.unit !== "w") {
|
|
426
|
+
result.time = (_c = result.time) === null || _c === void 0 ? void 0 : _c.set(v.unit, val);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
result.time = undefined;
|
|
431
|
+
result.info = undefined;
|
|
432
|
+
result.length = 0;
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
if (cursorPos !== null && cursorPos >= index && cursorPos <= index + length) {
|
|
436
|
+
result.info = v;
|
|
437
|
+
result.length = length;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
static isValidValue(value, minDateTime, maxDateTime, allowClear) {
|
|
444
|
+
return (!!value && value.isValid() && (!minDateTime || value.isSameOrAfter(minDateTime)) && (!maxDateTime || value.isSameOrBefore(maxDateTime))) || (!!allowClear && value === null);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
419
447
|
//# sourceMappingURL=dateTimeInput.js.map
|