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,225 +1,225 @@
|
|
|
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, { Component } from 'react';
|
|
13
|
-
import { Input } from 'antd';
|
|
14
|
-
import InputMask from 'd2coreui/components/input/mask/inputMaskCore';
|
|
15
|
-
import { getSelection, isRedo, isUndo, setSelection } from 'd2coreui/components/input/mask/helpers';
|
|
16
|
-
export default class MaskedInput extends Component {
|
|
17
|
-
constructor(props) {
|
|
18
|
-
super(props);
|
|
19
|
-
this._onChange = (e) => {
|
|
20
|
-
let maskValue = this.mask.getValue();
|
|
21
|
-
let incomingValue = e.target.value;
|
|
22
|
-
if (incomingValue !== maskValue) {
|
|
23
|
-
this._updateMaskSelection();
|
|
24
|
-
this.mask.setValue(incomingValue);
|
|
25
|
-
this.setInputValue(this._getDisplayValue());
|
|
26
|
-
this._updateInputSelection();
|
|
27
|
-
}
|
|
28
|
-
if (this.props.onChange) {
|
|
29
|
-
this.props.onChange(e);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
this._onKeyDown = (e) => {
|
|
33
|
-
setTimeout(() => {
|
|
34
|
-
this.input.classList[this.input.value ? 'add' : 'remove']('has-value');
|
|
35
|
-
}, 100);
|
|
36
|
-
if (isUndo(e)) {
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
if (this.mask.undo()) {
|
|
39
|
-
this.setInputValue(this._getDisplayValue());
|
|
40
|
-
this._updateInputSelection();
|
|
41
|
-
if (this.props.onChange) {
|
|
42
|
-
this.props.onChange(e);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
else if (isRedo(e)) {
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
if (this.mask.redo()) {
|
|
50
|
-
this.setInputValue(this._getDisplayValue());
|
|
51
|
-
this._updateInputSelection();
|
|
52
|
-
if (this.props.onChange) {
|
|
53
|
-
this.props.onChange(e);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (e.key === 'Backspace') {
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
this._updateMaskSelection();
|
|
61
|
-
if (this.mask.backspace()) {
|
|
62
|
-
let value = this._getDisplayValue();
|
|
63
|
-
this.setInputValue(value);
|
|
64
|
-
if (value) {
|
|
65
|
-
this._updateInputSelection();
|
|
66
|
-
}
|
|
67
|
-
if (this.props.onChange) {
|
|
68
|
-
this.props.onChange(e);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
this._onKeyPress = (e) => {
|
|
74
|
-
if (e.metaKey || e.altKey || e.ctrlKey || e.key === 'Enter') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
this._updateMaskSelection();
|
|
79
|
-
if (this.mask.input(e.key)) {
|
|
80
|
-
this.setInputValue(this.mask.getValue());
|
|
81
|
-
this._updateInputSelection();
|
|
82
|
-
if (this.props.onChange) {
|
|
83
|
-
this.props.onChange(e);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
this._onPaste = (e) => {
|
|
88
|
-
e.preventDefault();
|
|
89
|
-
this._updateMaskSelection();
|
|
90
|
-
if (this.mask.paste(e.clipboardData.getData('Text'))) {
|
|
91
|
-
this.setInputValue(this.mask.getValue());
|
|
92
|
-
setTimeout(() => this._updateInputSelection(), 0);
|
|
93
|
-
if (this.props.onChange) {
|
|
94
|
-
this.props.onChange(e);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
this.getInputProps = () => {
|
|
99
|
-
let maxLength = this.mask.pattern.length;
|
|
100
|
-
let eventHandlers = this._getEventHandlers();
|
|
101
|
-
let { placeholder = this.mask.emptyValue } = this.props;
|
|
102
|
-
let _a = this.props, { placeholderChar, formatCharacters } = _a, cleanedProps = __rest(_a, ["placeholderChar", "formatCharacters"]);
|
|
103
|
-
const props = Object.assign(Object.assign(Object.assign({}, cleanedProps), eventHandlers), { maxLength, placeholder });
|
|
104
|
-
delete props.value;
|
|
105
|
-
return props;
|
|
106
|
-
};
|
|
107
|
-
this._lastValue = null;
|
|
108
|
-
this.setInputValue = (value) => {
|
|
109
|
-
if (!this._Input)
|
|
110
|
-
return;
|
|
111
|
-
if (value === this._lastValue)
|
|
112
|
-
return;
|
|
113
|
-
this.setState({ value: value });
|
|
114
|
-
this._lastValue = value;
|
|
115
|
-
if (this._Input.input) {
|
|
116
|
-
this._Input.input.value = value;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
this._Input = null;
|
|
120
|
-
this.handleInputRef = (ref) => {
|
|
121
|
-
if (!ref || !ref.input)
|
|
122
|
-
return;
|
|
123
|
-
this._Input = ref;
|
|
124
|
-
this.input = ref.input;
|
|
125
|
-
if (this._lastValue === null &&
|
|
126
|
-
typeof this.props.defaultValue === 'string') {
|
|
127
|
-
this.mask.setValue(this.props.defaultValue);
|
|
128
|
-
this.setInputValue(this._getDisplayValue());
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
this.state = {
|
|
132
|
-
value: this.props.value,
|
|
133
|
-
};
|
|
134
|
-
let options = {
|
|
135
|
-
pattern: this.props.mask,
|
|
136
|
-
value: this.props.value,
|
|
137
|
-
formatCharacters: this.props.formatCharacters
|
|
138
|
-
};
|
|
139
|
-
if (this.props.placeholderChar) {
|
|
140
|
-
options.placeholderChar = this.props.placeholderChar;
|
|
141
|
-
}
|
|
142
|
-
this.mask = new InputMask(options);
|
|
143
|
-
}
|
|
144
|
-
componentDidMount() {
|
|
145
|
-
this.setInputValue(this._getDisplayValue());
|
|
146
|
-
}
|
|
147
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
148
|
-
if (this.props.mask !== nextProps.mask &&
|
|
149
|
-
this.props.value !== nextProps.mask) {
|
|
150
|
-
if (this.mask.getValue() === this.mask.emptyValue) {
|
|
151
|
-
this.mask.setPattern(nextProps.mask, { value: nextProps.value });
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
this.mask.setPattern(nextProps.mask, {
|
|
155
|
-
value: this.mask.getRawValue()
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
else if (this.props.mask !== nextProps.mask) {
|
|
160
|
-
this.mask.setPattern(nextProps.mask, { value: this.mask.getRawValue() });
|
|
161
|
-
}
|
|
162
|
-
if (this.props.value !== nextProps.value) {
|
|
163
|
-
this.mask.setValue(nextProps.value);
|
|
164
|
-
this.setInputValue(this._getDisplayValue());
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
UNSAFE_componentWillUpdate(nextProps) {
|
|
168
|
-
if (!this.props.mask)
|
|
169
|
-
return null;
|
|
170
|
-
if (nextProps.mask !== this.props.mask) {
|
|
171
|
-
this._updatePattern(nextProps);
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
componentDidUpdate(prevProps) {
|
|
176
|
-
if (!this.props.mask)
|
|
177
|
-
return null;
|
|
178
|
-
if (prevProps.mask !== this.props.mask && this.mask.selection.start) {
|
|
179
|
-
this._updateInputSelection();
|
|
180
|
-
}
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
_updatePattern(props) {
|
|
184
|
-
this.mask.setPattern(props.mask, {
|
|
185
|
-
value: this.mask.getRawValue(),
|
|
186
|
-
selection: getSelection(this.input)
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
_updateMaskSelection() {
|
|
190
|
-
this.mask.selection = getSelection(this.input);
|
|
191
|
-
}
|
|
192
|
-
_updateInputSelection() {
|
|
193
|
-
setSelection(this.input, this.mask.selection);
|
|
194
|
-
}
|
|
195
|
-
_getDisplayValue() {
|
|
196
|
-
let value = this.mask.getValue();
|
|
197
|
-
return value === this.mask.emptyValue ? '' : value;
|
|
198
|
-
}
|
|
199
|
-
_keyPressPropName() {
|
|
200
|
-
if (typeof navigator !== 'undefined') {
|
|
201
|
-
return navigator.userAgent.match(/Android/i)
|
|
202
|
-
? 'onBeforeInput'
|
|
203
|
-
: 'onKeyPress';
|
|
204
|
-
}
|
|
205
|
-
return 'onKeyPress';
|
|
206
|
-
}
|
|
207
|
-
_getEventHandlers() {
|
|
208
|
-
return {
|
|
209
|
-
onChange: this._onChange,
|
|
210
|
-
onKeyDown: this._onKeyDown,
|
|
211
|
-
onPaste: this._onPaste,
|
|
212
|
-
[this._keyPressPropName()]: this._onKeyPress
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
focus() {
|
|
216
|
-
this.input.focus();
|
|
217
|
-
}
|
|
218
|
-
blur() {
|
|
219
|
-
this.input.blur();
|
|
220
|
-
}
|
|
221
|
-
render() {
|
|
222
|
-
return React.createElement(Input, Object.assign({ value: this.state.value }, this.getInputProps(), { ref: this.handleInputRef }));
|
|
223
|
-
}
|
|
224
|
-
}
|
|
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, { Component } from 'react';
|
|
13
|
+
import { Input } from 'antd';
|
|
14
|
+
import InputMask from 'd2coreui/components/input/mask/inputMaskCore';
|
|
15
|
+
import { getSelection, isRedo, isUndo, setSelection } from 'd2coreui/components/input/mask/helpers';
|
|
16
|
+
export default class MaskedInput extends Component {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
this._onChange = (e) => {
|
|
20
|
+
let maskValue = this.mask.getValue();
|
|
21
|
+
let incomingValue = e.target.value;
|
|
22
|
+
if (incomingValue !== maskValue) {
|
|
23
|
+
this._updateMaskSelection();
|
|
24
|
+
this.mask.setValue(incomingValue);
|
|
25
|
+
this.setInputValue(this._getDisplayValue());
|
|
26
|
+
this._updateInputSelection();
|
|
27
|
+
}
|
|
28
|
+
if (this.props.onChange) {
|
|
29
|
+
this.props.onChange(e);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
this._onKeyDown = (e) => {
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
this.input.classList[this.input.value ? 'add' : 'remove']('has-value');
|
|
35
|
+
}, 100);
|
|
36
|
+
if (isUndo(e)) {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
if (this.mask.undo()) {
|
|
39
|
+
this.setInputValue(this._getDisplayValue());
|
|
40
|
+
this._updateInputSelection();
|
|
41
|
+
if (this.props.onChange) {
|
|
42
|
+
this.props.onChange(e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
else if (isRedo(e)) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
if (this.mask.redo()) {
|
|
50
|
+
this.setInputValue(this._getDisplayValue());
|
|
51
|
+
this._updateInputSelection();
|
|
52
|
+
if (this.props.onChange) {
|
|
53
|
+
this.props.onChange(e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (e.key === 'Backspace') {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
this._updateMaskSelection();
|
|
61
|
+
if (this.mask.backspace()) {
|
|
62
|
+
let value = this._getDisplayValue();
|
|
63
|
+
this.setInputValue(value);
|
|
64
|
+
if (value) {
|
|
65
|
+
this._updateInputSelection();
|
|
66
|
+
}
|
|
67
|
+
if (this.props.onChange) {
|
|
68
|
+
this.props.onChange(e);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
this._onKeyPress = (e) => {
|
|
74
|
+
if (e.metaKey || e.altKey || e.ctrlKey || e.key === 'Enter') {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
this._updateMaskSelection();
|
|
79
|
+
if (this.mask.input(e.key)) {
|
|
80
|
+
this.setInputValue(this.mask.getValue());
|
|
81
|
+
this._updateInputSelection();
|
|
82
|
+
if (this.props.onChange) {
|
|
83
|
+
this.props.onChange(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this._onPaste = (e) => {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
this._updateMaskSelection();
|
|
90
|
+
if (this.mask.paste(e.clipboardData.getData('Text'))) {
|
|
91
|
+
this.setInputValue(this.mask.getValue());
|
|
92
|
+
setTimeout(() => this._updateInputSelection(), 0);
|
|
93
|
+
if (this.props.onChange) {
|
|
94
|
+
this.props.onChange(e);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
this.getInputProps = () => {
|
|
99
|
+
let maxLength = this.mask.pattern.length;
|
|
100
|
+
let eventHandlers = this._getEventHandlers();
|
|
101
|
+
let { placeholder = this.mask.emptyValue } = this.props;
|
|
102
|
+
let _a = this.props, { placeholderChar, formatCharacters } = _a, cleanedProps = __rest(_a, ["placeholderChar", "formatCharacters"]);
|
|
103
|
+
const props = Object.assign(Object.assign(Object.assign({}, cleanedProps), eventHandlers), { maxLength, placeholder });
|
|
104
|
+
delete props.value;
|
|
105
|
+
return props;
|
|
106
|
+
};
|
|
107
|
+
this._lastValue = null;
|
|
108
|
+
this.setInputValue = (value) => {
|
|
109
|
+
if (!this._Input)
|
|
110
|
+
return;
|
|
111
|
+
if (value === this._lastValue)
|
|
112
|
+
return;
|
|
113
|
+
this.setState({ value: value });
|
|
114
|
+
this._lastValue = value;
|
|
115
|
+
if (this._Input.input) {
|
|
116
|
+
this._Input.input.value = value;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
this._Input = null;
|
|
120
|
+
this.handleInputRef = (ref) => {
|
|
121
|
+
if (!ref || !ref.input)
|
|
122
|
+
return;
|
|
123
|
+
this._Input = ref;
|
|
124
|
+
this.input = ref.input;
|
|
125
|
+
if (this._lastValue === null &&
|
|
126
|
+
typeof this.props.defaultValue === 'string') {
|
|
127
|
+
this.mask.setValue(this.props.defaultValue);
|
|
128
|
+
this.setInputValue(this._getDisplayValue());
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
this.state = {
|
|
132
|
+
value: this.props.value,
|
|
133
|
+
};
|
|
134
|
+
let options = {
|
|
135
|
+
pattern: this.props.mask,
|
|
136
|
+
value: this.props.value,
|
|
137
|
+
formatCharacters: this.props.formatCharacters
|
|
138
|
+
};
|
|
139
|
+
if (this.props.placeholderChar) {
|
|
140
|
+
options.placeholderChar = this.props.placeholderChar;
|
|
141
|
+
}
|
|
142
|
+
this.mask = new InputMask(options);
|
|
143
|
+
}
|
|
144
|
+
componentDidMount() {
|
|
145
|
+
this.setInputValue(this._getDisplayValue());
|
|
146
|
+
}
|
|
147
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
148
|
+
if (this.props.mask !== nextProps.mask &&
|
|
149
|
+
this.props.value !== nextProps.mask) {
|
|
150
|
+
if (this.mask.getValue() === this.mask.emptyValue) {
|
|
151
|
+
this.mask.setPattern(nextProps.mask, { value: nextProps.value });
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
this.mask.setPattern(nextProps.mask, {
|
|
155
|
+
value: this.mask.getRawValue()
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else if (this.props.mask !== nextProps.mask) {
|
|
160
|
+
this.mask.setPattern(nextProps.mask, { value: this.mask.getRawValue() });
|
|
161
|
+
}
|
|
162
|
+
if (this.props.value !== nextProps.value) {
|
|
163
|
+
this.mask.setValue(nextProps.value);
|
|
164
|
+
this.setInputValue(this._getDisplayValue());
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
UNSAFE_componentWillUpdate(nextProps) {
|
|
168
|
+
if (!this.props.mask)
|
|
169
|
+
return null;
|
|
170
|
+
if (nextProps.mask !== this.props.mask) {
|
|
171
|
+
this._updatePattern(nextProps);
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
componentDidUpdate(prevProps) {
|
|
176
|
+
if (!this.props.mask)
|
|
177
|
+
return null;
|
|
178
|
+
if (prevProps.mask !== this.props.mask && this.mask.selection.start) {
|
|
179
|
+
this._updateInputSelection();
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
_updatePattern(props) {
|
|
184
|
+
this.mask.setPattern(props.mask, {
|
|
185
|
+
value: this.mask.getRawValue(),
|
|
186
|
+
selection: getSelection(this.input)
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
_updateMaskSelection() {
|
|
190
|
+
this.mask.selection = getSelection(this.input);
|
|
191
|
+
}
|
|
192
|
+
_updateInputSelection() {
|
|
193
|
+
setSelection(this.input, this.mask.selection);
|
|
194
|
+
}
|
|
195
|
+
_getDisplayValue() {
|
|
196
|
+
let value = this.mask.getValue();
|
|
197
|
+
return value === this.mask.emptyValue ? '' : value;
|
|
198
|
+
}
|
|
199
|
+
_keyPressPropName() {
|
|
200
|
+
if (typeof navigator !== 'undefined') {
|
|
201
|
+
return navigator.userAgent.match(/Android/i)
|
|
202
|
+
? 'onBeforeInput'
|
|
203
|
+
: 'onKeyPress';
|
|
204
|
+
}
|
|
205
|
+
return 'onKeyPress';
|
|
206
|
+
}
|
|
207
|
+
_getEventHandlers() {
|
|
208
|
+
return {
|
|
209
|
+
onChange: this._onChange,
|
|
210
|
+
onKeyDown: this._onKeyDown,
|
|
211
|
+
onPaste: this._onPaste,
|
|
212
|
+
[this._keyPressPropName()]: this._onKeyPress
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
focus() {
|
|
216
|
+
this.input.focus();
|
|
217
|
+
}
|
|
218
|
+
blur() {
|
|
219
|
+
this.input.blur();
|
|
220
|
+
}
|
|
221
|
+
render() {
|
|
222
|
+
return React.createElement(Input, Object.assign({ value: this.state.value }, this.getInputProps(), { ref: this.handleInputRef }));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
225
|
//# sourceMappingURL=maskedInput.js.map
|
|
@@ -1 +1 @@
|
|
|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,CAAC,aAAa,EAAE,IAAE,GAAG,EAAE,IAAI,CAAC,cAAc,IAAG,CAAC;IACjG,CAAC;CACJ","sourcesContent":["import React, {ChangeEvent, ClipboardEvent, Component, KeyboardEvent} from 'react';\nimport {Input, InputRef} from 'antd';\nimport InputMask from 'd2coreui/components/input/mask/inputMaskCore';\nimport {getSelection, isRedo, isUndo, setSelection} from 'd2coreui/components/input/mask/helpers';\nimport {InputProps} from 'antd/lib/input';\n\nexport type MaskedInputProps = InputProps & {\n mask: string;\n formatCharacters?: object;\n placeholderChar?: string;\n value?: string;\n};\n\ntype TChangeEvent = ChangeEvent<HTMLInputElement>;\ntype TKeyboardEvent = KeyboardEvent<HTMLInputElement>;\ntype TClipboardEvent = ClipboardEvent<any>;\n\nexport default class MaskedInput extends Component<MaskedInputProps, {value?: string}> {\n mask: InputMask;\n input!: HTMLInputElement;\n\n constructor(props: MaskedInputProps) {\n super(props);\n\n this.state = {\n value: this.props.value,\n }\n\n let options: any = {\n pattern: this.props.mask,\n value: this.props.value,\n formatCharacters: this.props.formatCharacters\n };\n\n if (this.props.placeholderChar) {\n options.placeholderChar = this.props.placeholderChar;\n }\n\n this.mask = new InputMask(options);\n }\n\n componentDidMount() {\n this.setInputValue(this._getDisplayValue());\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MaskedInputProps) {\n if (\n this.props.mask !== nextProps.mask &&\n this.props.value !== nextProps.mask\n ) {\n // if we get a new value and a new mask at the same time\n // check if the mask.value is still the initial value\n // - if so use the nextProps value\n // - otherwise the `this.mask` has a value for us (most likely from paste action)\n if (this.mask.getValue() === this.mask.emptyValue) {\n this.mask.setPattern(nextProps.mask, {value: nextProps.value});\n } else {\n this.mask.setPattern(nextProps.mask, {\n value: this.mask.getRawValue()\n });\n }\n } else if (this.props.mask !== nextProps.mask) {\n this.mask.setPattern(nextProps.mask, {value: this.mask.getRawValue()});\n }\n\n if (this.props.value !== nextProps.value) {\n this.mask.setValue(nextProps.value);\n this.setInputValue(this._getDisplayValue());\n }\n }\n\n UNSAFE_componentWillUpdate(nextProps: MaskedInputProps) {\n if (!this.props.mask) return null;\n if (nextProps.mask !== this.props.mask) {\n this._updatePattern(nextProps);\n }\n return;\n }\n\n componentDidUpdate(prevProps: MaskedInputProps) {\n if (!this.props.mask) return null;\n if (prevProps.mask !== this.props.mask && this.mask.selection.start) {\n this._updateInputSelection();\n }\n return;\n }\n\n _updatePattern(props: MaskedInputProps) {\n this.mask.setPattern(props.mask, {\n value: this.mask.getRawValue(),\n selection: getSelection(this.input)\n });\n }\n\n _updateMaskSelection() {\n this.mask.selection = getSelection(this.input);\n }\n\n _updateInputSelection() {\n setSelection(this.input, this.mask.selection);\n }\n\n _onChange = (e: TChangeEvent) => {\n let maskValue = this.mask.getValue();\n let incomingValue = e.target.value;\n if (incomingValue !== maskValue) {\n // only modify mask if form contents actually changed\n this._updateMaskSelection();\n this.mask.setValue(incomingValue); // write the whole updated value into the mask\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\n this._updateInputSelection();\n }\n\n if (this.props.onChange) {\n this.props.onChange(e);\n }\n };\n\n _onKeyDown = (e: TKeyboardEvent) => {\n setTimeout(() => {\n this.input.classList[this.input.value ? 'add' : 'remove']('has-value');\n }, 100);\n\n if (isUndo(e)) {\n e.preventDefault();\n if (this.mask.undo()) {\n this.setInputValue(this._getDisplayValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n return;\n } else if (isRedo(e)) {\n e.preventDefault();\n if (this.mask.redo()) {\n this.setInputValue(this._getDisplayValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n return;\n }\n\n if (e.key === 'Backspace') {\n e.preventDefault();\n this._updateMaskSelection();\n if (this.mask.backspace()) {\n let value = this._getDisplayValue();\n this.setInputValue(value);\n if (value) {\n this._updateInputSelection();\n }\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n }\n };\n\n _onKeyPress = (e: TKeyboardEvent) => {\n // Ignore modified key presses\n // Ignore enter key to allow form submission\n if (e.metaKey || e.altKey || e.ctrlKey || e.key === 'Enter') {\n return;\n }\n\n e.preventDefault();\n this._updateMaskSelection();\n if (this.mask.input(e.key /*|| e.data*/)) {\n this.setInputValue(this.mask.getValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n };\n\n _onPaste = (e: TClipboardEvent) => {\n e.preventDefault();\n this._updateMaskSelection();\n // getData value needed for IE also works in FF & Chrome\n if (this.mask.paste(e.clipboardData.getData('Text'))) {\n // @ts-ignore\n this.setInputValue(this.mask.getValue());\n // Timeout needed for IE\n setTimeout(() => this._updateInputSelection(), 0);\n if (this.props.onChange) {\n // @ts-ignore\n this.props.onChange(e);\n }\n }\n };\n\n _getDisplayValue() {\n let value = this.mask.getValue();\n return value === this.mask.emptyValue ? '' : value;\n }\n\n _keyPressPropName() {\n if (typeof navigator !== 'undefined') {\n return navigator.userAgent.match(/Android/i)\n ? 'onBeforeInput'\n : 'onKeyPress';\n }\n return 'onKeyPress';\n }\n\n _getEventHandlers(): {\n onChange: (e: TChangeEvent) => void;\n onKeyDown: (e: TKeyboardEvent) => void;\n onPaste: (e: TClipboardEvent) => void;\n onBeforeInput?: (e: TChangeEvent) => void;\n onKeyPress?: (e: TKeyboardEvent) => void;\n } {\n return {\n onChange: this._onChange,\n onKeyDown: this._onKeyDown,\n onPaste: this._onPaste,\n [this._keyPressPropName()]: this._onKeyPress\n };\n }\n\n focus() {\n this.input.focus();\n }\n\n blur() {\n this.input.blur();\n }\n\n getInputProps = () => {\n let maxLength = this.mask.pattern.length;\n let eventHandlers = this._getEventHandlers();\n let {placeholder = this.mask.emptyValue} = this.props;\n\n let {placeholderChar, formatCharacters, ...cleanedProps} = this.props;\n const props = {...cleanedProps, ...eventHandlers, maxLength, placeholder};\n delete props.value;\n return props;\n };\n\n _lastValue = null as any;\n setInputValue = (value: string) => {\n if (!this._Input) return;\n if (value === this._lastValue) return;\n\n this.setState({value: value});\n\n this._lastValue = value;\n if (this._Input.input) {\n this._Input.input.value = value;\n }\n };\n\n _Input: InputRef | null = null;\n handleInputRef = (ref: InputRef) => {\n if (!ref || !ref.input) return;\n this._Input = ref;\n this.input = ref.input;\n\n if (\n this._lastValue === null &&\n typeof this.props.defaultValue === 'string'\n ) {\n this.mask.setValue(this.props.defaultValue); // write the whole updated value into the mask\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\n }\n };\n\n render() {\n return <Input value={this.state.value} {...this.getInputProps()} ref={this.handleInputRef}/>;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"maskedInput.js","sourceRoot":"","sources":["../../../../components/input/maskedInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAA8B,SAAS,EAAgB,MAAM,OAAO,CAAC;AACnF,OAAO,EAAC,KAAK,EAAW,MAAM,MAAM,CAAC;AACrC,OAAO,SAAS,MAAM,8CAA8C,CAAC;AACrE,OAAO,EAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAC,MAAM,wCAAwC,CAAC;AAclG,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAA6C;IAIlF,YAAY,KAAuB;QAC/B,KAAK,CAAC,KAAK,CAAC,CAAC;QAgFjB,cAAS,GAAG,CAAC,CAAe,EAAE,EAAE;YAC5B,IAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACrC,IAAI,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YACnC,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAE9B,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC5B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;gBAClC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAA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CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,CAAC;IAED,iBAAiB;QACb,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;YACnC,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;gBACxC,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,YAAY,CAAC;QACvB,CAAC;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,iBAAiB;QAOb,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW;SAC/C,CAAC;IACN,CAAC;IAED,KAAK;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED,IAAI;QACA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAyCD,MAAM;QACF,OAAO,oBAAC,KAAK,kBAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAAM,IAAI,CAAC,aAAa,EAAE,IAAE,GAAG,EAAE,IAAI,CAAC,cAAc,IAAG,CAAC;IACjG,CAAC;CACJ","sourcesContent":["import React, {ChangeEvent, ClipboardEvent, Component, KeyboardEvent} from 'react';\r\nimport {Input, InputRef} from 'antd';\r\nimport InputMask from 'd2coreui/components/input/mask/inputMaskCore';\r\nimport {getSelection, isRedo, isUndo, setSelection} from 'd2coreui/components/input/mask/helpers';\r\nimport {InputProps} from 'antd/lib/input';\r\n\r\nexport type MaskedInputProps = InputProps & {\r\n mask: string;\r\n formatCharacters?: object;\r\n placeholderChar?: string;\r\n value?: string;\r\n};\r\n\r\ntype TChangeEvent = ChangeEvent<HTMLInputElement>;\r\ntype TKeyboardEvent = KeyboardEvent<HTMLInputElement>;\r\ntype TClipboardEvent = ClipboardEvent<any>;\r\n\r\nexport default class MaskedInput extends Component<MaskedInputProps, {value?: string}> {\r\n mask: InputMask;\r\n input!: HTMLInputElement;\r\n\r\n constructor(props: MaskedInputProps) {\r\n super(props);\r\n\r\n this.state = {\r\n value: this.props.value,\r\n }\r\n\r\n let options: any = {\r\n pattern: this.props.mask,\r\n value: this.props.value,\r\n formatCharacters: this.props.formatCharacters\r\n };\r\n\r\n if (this.props.placeholderChar) {\r\n options.placeholderChar = this.props.placeholderChar;\r\n }\r\n\r\n this.mask = new InputMask(options);\r\n }\r\n\r\n componentDidMount() {\r\n this.setInputValue(this._getDisplayValue());\r\n }\r\n\r\n UNSAFE_componentWillReceiveProps(nextProps: MaskedInputProps) {\r\n if (\r\n this.props.mask !== nextProps.mask &&\r\n this.props.value !== nextProps.mask\r\n ) {\r\n // if we get a new value and a new mask at the same time\r\n // check if the mask.value is still the initial value\r\n // - if so use the nextProps value\r\n // - otherwise the `this.mask` has a value for us (most likely from paste action)\r\n if (this.mask.getValue() === this.mask.emptyValue) {\r\n this.mask.setPattern(nextProps.mask, {value: nextProps.value});\r\n } else {\r\n this.mask.setPattern(nextProps.mask, {\r\n value: this.mask.getRawValue()\r\n });\r\n }\r\n } else if (this.props.mask !== nextProps.mask) {\r\n this.mask.setPattern(nextProps.mask, {value: this.mask.getRawValue()});\r\n }\r\n\r\n if (this.props.value !== nextProps.value) {\r\n this.mask.setValue(nextProps.value);\r\n this.setInputValue(this._getDisplayValue());\r\n }\r\n }\r\n\r\n UNSAFE_componentWillUpdate(nextProps: MaskedInputProps) {\r\n if (!this.props.mask) return null;\r\n if (nextProps.mask !== this.props.mask) {\r\n this._updatePattern(nextProps);\r\n }\r\n return;\r\n }\r\n\r\n componentDidUpdate(prevProps: MaskedInputProps) {\r\n if (!this.props.mask) return null;\r\n if (prevProps.mask !== this.props.mask && this.mask.selection.start) {\r\n this._updateInputSelection();\r\n }\r\n return;\r\n }\r\n\r\n _updatePattern(props: MaskedInputProps) {\r\n this.mask.setPattern(props.mask, {\r\n value: this.mask.getRawValue(),\r\n selection: getSelection(this.input)\r\n });\r\n }\r\n\r\n _updateMaskSelection() {\r\n this.mask.selection = getSelection(this.input);\r\n }\r\n\r\n _updateInputSelection() {\r\n setSelection(this.input, this.mask.selection);\r\n }\r\n\r\n _onChange = (e: TChangeEvent) => {\r\n let maskValue = this.mask.getValue();\r\n let incomingValue = e.target.value;\r\n if (incomingValue !== maskValue) {\r\n // only modify mask if form contents actually changed\r\n this._updateMaskSelection();\r\n this.mask.setValue(incomingValue); // write the whole updated value into the mask\r\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\r\n this._updateInputSelection();\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange(e);\r\n }\r\n };\r\n\r\n _onKeyDown = (e: TKeyboardEvent) => {\r\n setTimeout(() => {\r\n this.input.classList[this.input.value ? 'add' : 'remove']('has-value');\r\n }, 100);\r\n\r\n if (isUndo(e)) {\r\n e.preventDefault();\r\n if (this.mask.undo()) {\r\n this.setInputValue(this._getDisplayValue());\r\n this._updateInputSelection();\r\n if (this.props.onChange) {\r\n this.props.onChange(e as unknown as TChangeEvent);\r\n }\r\n }\r\n return;\r\n } else if (isRedo(e)) {\r\n e.preventDefault();\r\n if (this.mask.redo()) {\r\n this.setInputValue(this._getDisplayValue());\r\n this._updateInputSelection();\r\n if (this.props.onChange) {\r\n this.props.onChange(e as unknown as TChangeEvent);\r\n }\r\n }\r\n return;\r\n }\r\n\r\n if (e.key === 'Backspace') {\r\n e.preventDefault();\r\n this._updateMaskSelection();\r\n if (this.mask.backspace()) {\r\n let value = this._getDisplayValue();\r\n this.setInputValue(value);\r\n if (value) {\r\n this._updateInputSelection();\r\n }\r\n if (this.props.onChange) {\r\n this.props.onChange(e as unknown as TChangeEvent);\r\n }\r\n }\r\n }\r\n };\r\n\r\n _onKeyPress = (e: TKeyboardEvent) => {\r\n // Ignore modified key presses\r\n // Ignore enter key to allow form submission\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.key === 'Enter') {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n this._updateMaskSelection();\r\n if (this.mask.input(e.key /*|| e.data*/)) {\r\n this.setInputValue(this.mask.getValue());\r\n this._updateInputSelection();\r\n if (this.props.onChange) {\r\n this.props.onChange(e as unknown as TChangeEvent);\r\n }\r\n }\r\n };\r\n\r\n _onPaste = (e: TClipboardEvent) => {\r\n e.preventDefault();\r\n this._updateMaskSelection();\r\n // getData value needed for IE also works in FF & Chrome\r\n if (this.mask.paste(e.clipboardData.getData('Text'))) {\r\n // @ts-ignore\r\n this.setInputValue(this.mask.getValue());\r\n // Timeout needed for IE\r\n setTimeout(() => this._updateInputSelection(), 0);\r\n if (this.props.onChange) {\r\n // @ts-ignore\r\n this.props.onChange(e);\r\n }\r\n }\r\n };\r\n\r\n _getDisplayValue() {\r\n let value = this.mask.getValue();\r\n return value === this.mask.emptyValue ? '' : value;\r\n }\r\n\r\n _keyPressPropName() {\r\n if (typeof navigator !== 'undefined') {\r\n return navigator.userAgent.match(/Android/i)\r\n ? 'onBeforeInput'\r\n : 'onKeyPress';\r\n }\r\n return 'onKeyPress';\r\n }\r\n\r\n _getEventHandlers(): {\r\n onChange: (e: TChangeEvent) => void;\r\n onKeyDown: (e: TKeyboardEvent) => void;\r\n onPaste: (e: TClipboardEvent) => void;\r\n onBeforeInput?: (e: TChangeEvent) => void;\r\n onKeyPress?: (e: TKeyboardEvent) => void;\r\n } {\r\n return {\r\n onChange: this._onChange,\r\n onKeyDown: this._onKeyDown,\r\n onPaste: this._onPaste,\r\n [this._keyPressPropName()]: this._onKeyPress\r\n };\r\n }\r\n\r\n focus() {\r\n this.input.focus();\r\n }\r\n\r\n blur() {\r\n this.input.blur();\r\n }\r\n\r\n getInputProps = () => {\r\n let maxLength = this.mask.pattern.length;\r\n let eventHandlers = this._getEventHandlers();\r\n let {placeholder = this.mask.emptyValue} = this.props;\r\n\r\n let {placeholderChar, formatCharacters, ...cleanedProps} = this.props;\r\n const props = {...cleanedProps, ...eventHandlers, maxLength, placeholder};\r\n delete props.value;\r\n return props;\r\n };\r\n\r\n _lastValue = null as any;\r\n setInputValue = (value: string) => {\r\n if (!this._Input) return;\r\n if (value === this._lastValue) return;\r\n\r\n this.setState({value: value});\r\n\r\n this._lastValue = value;\r\n if (this._Input.input) {\r\n this._Input.input.value = value;\r\n }\r\n };\r\n\r\n _Input: InputRef | null = null;\r\n handleInputRef = (ref: InputRef) => {\r\n if (!ref || !ref.input) return;\r\n this._Input = ref;\r\n this.input = ref.input;\r\n\r\n if (\r\n this._lastValue === null &&\r\n typeof this.props.defaultValue === 'string'\r\n ) {\r\n this.mask.setValue(this.props.defaultValue); // write the whole updated value into the mask\r\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\r\n }\r\n };\r\n\r\n render() {\r\n return <Input value={this.state.value} {...this.getInputProps()} ref={this.handleInputRef}/>;\r\n }\r\n}"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { PasswordProps } from "antd/lib/input/Password";
|
|
3
|
-
export default class PasswordInput extends React.Component<PasswordProps, unknown> {
|
|
4
|
-
private component;
|
|
5
|
-
constructor(props: Readonly<PasswordProps>);
|
|
6
|
-
focus(): void;
|
|
7
|
-
getIcon: (visible: boolean) => JSX.Element;
|
|
8
|
-
render(): JSX.Element;
|
|
9
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PasswordProps } from "antd/lib/input/Password";
|
|
3
|
+
export default class PasswordInput extends React.Component<PasswordProps, unknown> {
|
|
4
|
+
private component;
|
|
5
|
+
constructor(props: Readonly<PasswordProps>);
|
|
6
|
+
focus(): void;
|
|
7
|
+
getIcon: (visible: boolean) => React.JSX.Element;
|
|
8
|
+
render(): React.JSX.Element;
|
|
9
|
+
}
|