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,279 +1,279 @@
|
|
|
1
|
-
import { DEFAULT_PLACEHOLDER_CHAR, mergeFormatCharacters } from './helpers';
|
|
2
|
-
import { Pattern } from './pattern';
|
|
3
|
-
export class InputMask {
|
|
4
|
-
constructor(options) {
|
|
5
|
-
this.emptyValue = '';
|
|
6
|
-
this._history = [];
|
|
7
|
-
this._historyIndex = null;
|
|
8
|
-
this._lastOp = null;
|
|
9
|
-
this._lastSelection = null;
|
|
10
|
-
const mergedOptions = Object.assign({
|
|
11
|
-
isRevealingMask: false,
|
|
12
|
-
placeholderChar: DEFAULT_PLACEHOLDER_CHAR,
|
|
13
|
-
selection: { start: 0, end: 0 },
|
|
14
|
-
value: ''
|
|
15
|
-
}, options);
|
|
16
|
-
if (!mergedOptions.pattern) {
|
|
17
|
-
throw new Error('InputMask: you must provide a pattern.');
|
|
18
|
-
}
|
|
19
|
-
if (typeof mergedOptions.placeholderChar !== 'string' ||
|
|
20
|
-
mergedOptions.placeholderChar.length > 1) {
|
|
21
|
-
throw new Error('InputMask: placeholderChar should be a single character or an empty string.');
|
|
22
|
-
}
|
|
23
|
-
this.placeholderChar = mergedOptions.placeholderChar;
|
|
24
|
-
this.formatCharacters = mergeFormatCharacters(mergedOptions.formatCharacters);
|
|
25
|
-
this.setPattern(mergedOptions.pattern, {
|
|
26
|
-
value: mergedOptions.value,
|
|
27
|
-
selection: mergedOptions.selection,
|
|
28
|
-
isRevealingMask: mergedOptions.isRevealingMask
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
setPattern(patternSource, options) {
|
|
32
|
-
const merged = Object.assign({ selection: { start: 0, end: 0 }, value: '' }, options);
|
|
33
|
-
this.pattern = new Pattern(patternSource, this.formatCharacters, this.placeholderChar, merged.isRevealingMask);
|
|
34
|
-
this.setValue(merged.value);
|
|
35
|
-
this.emptyValue = this.pattern.formatValue([]).join('');
|
|
36
|
-
this.selection = merged.selection;
|
|
37
|
-
this._resetHistory();
|
|
38
|
-
}
|
|
39
|
-
setValue(value) {
|
|
40
|
-
if (value == null) {
|
|
41
|
-
value = '';
|
|
42
|
-
}
|
|
43
|
-
this.value = this.pattern.formatValue((value || '').split(''));
|
|
44
|
-
}
|
|
45
|
-
_resetHistory() {
|
|
46
|
-
this._history = [];
|
|
47
|
-
this._historyIndex = null;
|
|
48
|
-
this._lastOp = null;
|
|
49
|
-
this._lastSelection = Object.assign({}, this.selection);
|
|
50
|
-
}
|
|
51
|
-
getValue() {
|
|
52
|
-
if (this.pattern.isRevealingMask) {
|
|
53
|
-
this.value = this.pattern.formatValue((this.getRawValue() || '').split(''));
|
|
54
|
-
}
|
|
55
|
-
return (this.value || []).join('');
|
|
56
|
-
}
|
|
57
|
-
getRawValue() {
|
|
58
|
-
var rawValue = [];
|
|
59
|
-
for (var i = 0; i < this.value.length; i++) {
|
|
60
|
-
if (this.pattern._editableIndices[i] === true) {
|
|
61
|
-
rawValue.push(this.value[i]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return rawValue.join('');
|
|
65
|
-
}
|
|
66
|
-
input(char) {
|
|
67
|
-
if (this.selection.start === this.selection.end &&
|
|
68
|
-
this.selection.start === this.pattern.length) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
const selectionBefore = copy(this.selection);
|
|
72
|
-
const valueBefore = this.getValue();
|
|
73
|
-
let inputIndex = this.selection.start;
|
|
74
|
-
if (this.pattern.firstEditableIndex && inputIndex < this.pattern.firstEditableIndex) {
|
|
75
|
-
inputIndex = this.pattern.firstEditableIndex;
|
|
76
|
-
}
|
|
77
|
-
if (this.pattern.isEditableIndex(inputIndex)) {
|
|
78
|
-
if (!this.pattern.isValidAtIndex(char, inputIndex)) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
this.value[inputIndex] = this.pattern.transform(char, inputIndex);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
console.log('not editable');
|
|
85
|
-
}
|
|
86
|
-
let end = this.selection.end - 1;
|
|
87
|
-
while (end > inputIndex) {
|
|
88
|
-
if (this.pattern.isEditableIndex(end)) {
|
|
89
|
-
this.value[end] = this.placeholderChar;
|
|
90
|
-
}
|
|
91
|
-
end--;
|
|
92
|
-
}
|
|
93
|
-
this.selection.start = this.selection.end = inputIndex + 1;
|
|
94
|
-
while (this.pattern.length > this.selection.start &&
|
|
95
|
-
!this.pattern.isEditableIndex(this.selection.start)) {
|
|
96
|
-
this.selection.start++;
|
|
97
|
-
this.selection.end++;
|
|
98
|
-
}
|
|
99
|
-
if (this._historyIndex != null) {
|
|
100
|
-
this._history.splice(this._historyIndex, this._history.length - this._historyIndex);
|
|
101
|
-
this._historyIndex = null;
|
|
102
|
-
}
|
|
103
|
-
if (this._lastOp !== 'input' ||
|
|
104
|
-
selectionBefore.start !== selectionBefore.end ||
|
|
105
|
-
(this._lastSelection !== null &&
|
|
106
|
-
selectionBefore.start !== this._lastSelection.start)) {
|
|
107
|
-
this._history.push({
|
|
108
|
-
value: valueBefore,
|
|
109
|
-
selection: selectionBefore,
|
|
110
|
-
lastOp: this._lastOp
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
this._lastOp = 'input';
|
|
114
|
-
this._lastSelection = copy(this.selection);
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
backspace() {
|
|
118
|
-
if (this.selection.start === 0 && this.selection.end === 0) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
var selectionBefore = Object.assign({}, this.selection);
|
|
122
|
-
var valueBefore = this.getValue();
|
|
123
|
-
if (this.selection.start === this.selection.end) {
|
|
124
|
-
if (this.pattern.isEditableIndex(this.selection.start - 1)) {
|
|
125
|
-
if (this.pattern.isRevealingMask) {
|
|
126
|
-
this.value.splice(this.selection.start - 1);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.value[this.selection.start - 1] = this.placeholderChar;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
this.selection.start--;
|
|
133
|
-
this.selection.end--;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
var end = this.selection.end - 1;
|
|
137
|
-
while (end >= this.selection.start) {
|
|
138
|
-
if (this.pattern.isEditableIndex(end)) {
|
|
139
|
-
this.value[end] = this.placeholderChar;
|
|
140
|
-
}
|
|
141
|
-
end--;
|
|
142
|
-
}
|
|
143
|
-
this.selection.end = this.selection.start;
|
|
144
|
-
}
|
|
145
|
-
if (this._historyIndex != null) {
|
|
146
|
-
this._history.splice(this._historyIndex, this._history.length - this._historyIndex);
|
|
147
|
-
}
|
|
148
|
-
if (this._lastOp !== 'backspace' ||
|
|
149
|
-
selectionBefore.start !== selectionBefore.end ||
|
|
150
|
-
(this._lastSelection !== null &&
|
|
151
|
-
selectionBefore.start !== this._lastSelection.start)) {
|
|
152
|
-
this._history.push({
|
|
153
|
-
value: valueBefore,
|
|
154
|
-
selection: selectionBefore,
|
|
155
|
-
lastOp: this._lastOp
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
this._lastOp = 'backspace';
|
|
159
|
-
this._lastSelection = Object.assign({}, this.selection);
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
paste(input) {
|
|
163
|
-
var initialState = {
|
|
164
|
-
value: this.value.slice(),
|
|
165
|
-
selection: Object.assign({}, this.selection),
|
|
166
|
-
_lastOp: this._lastOp,
|
|
167
|
-
_history: this._history.slice(),
|
|
168
|
-
_historyIndex: this._historyIndex,
|
|
169
|
-
_lastSelection: Object.assign({}, this._lastSelection)
|
|
170
|
-
};
|
|
171
|
-
if (this.selection.start < this.pattern.firstEditableIndex) {
|
|
172
|
-
for (var i = 0, l = this.pattern.firstEditableIndex - this.selection.start; i < l; i++) {
|
|
173
|
-
if (input.charAt(i) !== this.pattern.pattern[i]) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
input = input.substring(this.pattern.firstEditableIndex - this.selection.start);
|
|
178
|
-
this.selection.start = this.pattern.firstEditableIndex;
|
|
179
|
-
}
|
|
180
|
-
for (i = 0, l = input.length; i < l && this.selection.start <= this.pattern.lastEditableIndex; i++) {
|
|
181
|
-
var valid = this.input(input.charAt(i));
|
|
182
|
-
if (!valid) {
|
|
183
|
-
if (this.selection.start > 0) {
|
|
184
|
-
var patternIndex = this.selection.start - 1;
|
|
185
|
-
if (!this.pattern.isEditableIndex(patternIndex) &&
|
|
186
|
-
input.charAt(i) === this.pattern.pattern[patternIndex]) {
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
Object.keys(initialState).forEach(key => {
|
|
191
|
-
this[key] = initialState[key];
|
|
192
|
-
});
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
undo() {
|
|
199
|
-
if (this._history.length === 0 || this._historyIndex === 0) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
var historyItem;
|
|
203
|
-
if (this._historyIndex == null) {
|
|
204
|
-
this._historyIndex = this._history.length - 1;
|
|
205
|
-
historyItem = this._history[this._historyIndex];
|
|
206
|
-
var value = this.getValue();
|
|
207
|
-
if (historyItem.value !== value ||
|
|
208
|
-
historyItem.selection.start !== this.selection.start ||
|
|
209
|
-
historyItem.selection.end !== this.selection.end) {
|
|
210
|
-
this._history.push({
|
|
211
|
-
value: value,
|
|
212
|
-
selection: Object.assign({}, this.selection),
|
|
213
|
-
lastOp: this._lastOp,
|
|
214
|
-
startUndo: true
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
historyItem = this._history[--this._historyIndex];
|
|
220
|
-
}
|
|
221
|
-
this.value = historyItem.value.split('');
|
|
222
|
-
this.selection = historyItem.selection;
|
|
223
|
-
this._lastOp = historyItem.lastOp;
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
redo() {
|
|
227
|
-
if (this._history.length === 0 || this._historyIndex == null) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
var historyItem = this._history[++this._historyIndex];
|
|
231
|
-
if (this._historyIndex === this._history.length - 1) {
|
|
232
|
-
this._historyIndex = null;
|
|
233
|
-
if (historyItem.startUndo) {
|
|
234
|
-
this._history.pop();
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
this.value = historyItem.value.split('');
|
|
238
|
-
this.selection = historyItem.selection;
|
|
239
|
-
this._lastOp = historyItem.lastOp;
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
setSelection(selection) {
|
|
243
|
-
this.selection = Object.assign({}, selection);
|
|
244
|
-
if (this.selection.start === this.selection.end) {
|
|
245
|
-
if (this.selection.start < this.pattern.firstEditableIndex) {
|
|
246
|
-
this.selection.start = this.selection.end = this.pattern
|
|
247
|
-
.firstEditableIndex;
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
var index = this.selection.start;
|
|
251
|
-
while (index >= this.pattern.firstEditableIndex) {
|
|
252
|
-
if ((this.pattern.isEditableIndex(index - 1) &&
|
|
253
|
-
this.value[index - 1] !== this.placeholderChar) ||
|
|
254
|
-
index === this.pattern.firstEditableIndex) {
|
|
255
|
-
this.selection.start = this.selection.end = index;
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
index--;
|
|
259
|
-
}
|
|
260
|
-
return true;
|
|
261
|
-
}
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
InputMask.Pattern = Pattern;
|
|
266
|
-
function extend(dest, src) {
|
|
267
|
-
if (src) {
|
|
268
|
-
let props = Object.keys(src);
|
|
269
|
-
for (var i = 0, l = props.length; i < l; i++) {
|
|
270
|
-
dest[props[i]] = src[props[i]];
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return dest;
|
|
274
|
-
}
|
|
275
|
-
function copy(obj) {
|
|
276
|
-
return extend({}, obj);
|
|
277
|
-
}
|
|
278
|
-
export default InputMask;
|
|
1
|
+
import { DEFAULT_PLACEHOLDER_CHAR, mergeFormatCharacters } from './helpers';
|
|
2
|
+
import { Pattern } from './pattern';
|
|
3
|
+
export class InputMask {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.emptyValue = '';
|
|
6
|
+
this._history = [];
|
|
7
|
+
this._historyIndex = null;
|
|
8
|
+
this._lastOp = null;
|
|
9
|
+
this._lastSelection = null;
|
|
10
|
+
const mergedOptions = Object.assign({
|
|
11
|
+
isRevealingMask: false,
|
|
12
|
+
placeholderChar: DEFAULT_PLACEHOLDER_CHAR,
|
|
13
|
+
selection: { start: 0, end: 0 },
|
|
14
|
+
value: ''
|
|
15
|
+
}, options);
|
|
16
|
+
if (!mergedOptions.pattern) {
|
|
17
|
+
throw new Error('InputMask: you must provide a pattern.');
|
|
18
|
+
}
|
|
19
|
+
if (typeof mergedOptions.placeholderChar !== 'string' ||
|
|
20
|
+
mergedOptions.placeholderChar.length > 1) {
|
|
21
|
+
throw new Error('InputMask: placeholderChar should be a single character or an empty string.');
|
|
22
|
+
}
|
|
23
|
+
this.placeholderChar = mergedOptions.placeholderChar;
|
|
24
|
+
this.formatCharacters = mergeFormatCharacters(mergedOptions.formatCharacters);
|
|
25
|
+
this.setPattern(mergedOptions.pattern, {
|
|
26
|
+
value: mergedOptions.value,
|
|
27
|
+
selection: mergedOptions.selection,
|
|
28
|
+
isRevealingMask: mergedOptions.isRevealingMask
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
setPattern(patternSource, options) {
|
|
32
|
+
const merged = Object.assign({ selection: { start: 0, end: 0 }, value: '' }, options);
|
|
33
|
+
this.pattern = new Pattern(patternSource, this.formatCharacters, this.placeholderChar, merged.isRevealingMask);
|
|
34
|
+
this.setValue(merged.value);
|
|
35
|
+
this.emptyValue = this.pattern.formatValue([]).join('');
|
|
36
|
+
this.selection = merged.selection;
|
|
37
|
+
this._resetHistory();
|
|
38
|
+
}
|
|
39
|
+
setValue(value) {
|
|
40
|
+
if (value == null) {
|
|
41
|
+
value = '';
|
|
42
|
+
}
|
|
43
|
+
this.value = this.pattern.formatValue((value || '').split(''));
|
|
44
|
+
}
|
|
45
|
+
_resetHistory() {
|
|
46
|
+
this._history = [];
|
|
47
|
+
this._historyIndex = null;
|
|
48
|
+
this._lastOp = null;
|
|
49
|
+
this._lastSelection = Object.assign({}, this.selection);
|
|
50
|
+
}
|
|
51
|
+
getValue() {
|
|
52
|
+
if (this.pattern.isRevealingMask) {
|
|
53
|
+
this.value = this.pattern.formatValue((this.getRawValue() || '').split(''));
|
|
54
|
+
}
|
|
55
|
+
return (this.value || []).join('');
|
|
56
|
+
}
|
|
57
|
+
getRawValue() {
|
|
58
|
+
var rawValue = [];
|
|
59
|
+
for (var i = 0; i < this.value.length; i++) {
|
|
60
|
+
if (this.pattern._editableIndices[i] === true) {
|
|
61
|
+
rawValue.push(this.value[i]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return rawValue.join('');
|
|
65
|
+
}
|
|
66
|
+
input(char) {
|
|
67
|
+
if (this.selection.start === this.selection.end &&
|
|
68
|
+
this.selection.start === this.pattern.length) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const selectionBefore = copy(this.selection);
|
|
72
|
+
const valueBefore = this.getValue();
|
|
73
|
+
let inputIndex = this.selection.start;
|
|
74
|
+
if (this.pattern.firstEditableIndex && inputIndex < this.pattern.firstEditableIndex) {
|
|
75
|
+
inputIndex = this.pattern.firstEditableIndex;
|
|
76
|
+
}
|
|
77
|
+
if (this.pattern.isEditableIndex(inputIndex)) {
|
|
78
|
+
if (!this.pattern.isValidAtIndex(char, inputIndex)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
this.value[inputIndex] = this.pattern.transform(char, inputIndex);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.log('not editable');
|
|
85
|
+
}
|
|
86
|
+
let end = this.selection.end - 1;
|
|
87
|
+
while (end > inputIndex) {
|
|
88
|
+
if (this.pattern.isEditableIndex(end)) {
|
|
89
|
+
this.value[end] = this.placeholderChar;
|
|
90
|
+
}
|
|
91
|
+
end--;
|
|
92
|
+
}
|
|
93
|
+
this.selection.start = this.selection.end = inputIndex + 1;
|
|
94
|
+
while (this.pattern.length > this.selection.start &&
|
|
95
|
+
!this.pattern.isEditableIndex(this.selection.start)) {
|
|
96
|
+
this.selection.start++;
|
|
97
|
+
this.selection.end++;
|
|
98
|
+
}
|
|
99
|
+
if (this._historyIndex != null) {
|
|
100
|
+
this._history.splice(this._historyIndex, this._history.length - this._historyIndex);
|
|
101
|
+
this._historyIndex = null;
|
|
102
|
+
}
|
|
103
|
+
if (this._lastOp !== 'input' ||
|
|
104
|
+
selectionBefore.start !== selectionBefore.end ||
|
|
105
|
+
(this._lastSelection !== null &&
|
|
106
|
+
selectionBefore.start !== this._lastSelection.start)) {
|
|
107
|
+
this._history.push({
|
|
108
|
+
value: valueBefore,
|
|
109
|
+
selection: selectionBefore,
|
|
110
|
+
lastOp: this._lastOp
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
this._lastOp = 'input';
|
|
114
|
+
this._lastSelection = copy(this.selection);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
backspace() {
|
|
118
|
+
if (this.selection.start === 0 && this.selection.end === 0) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
var selectionBefore = Object.assign({}, this.selection);
|
|
122
|
+
var valueBefore = this.getValue();
|
|
123
|
+
if (this.selection.start === this.selection.end) {
|
|
124
|
+
if (this.pattern.isEditableIndex(this.selection.start - 1)) {
|
|
125
|
+
if (this.pattern.isRevealingMask) {
|
|
126
|
+
this.value.splice(this.selection.start - 1);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.value[this.selection.start - 1] = this.placeholderChar;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.selection.start--;
|
|
133
|
+
this.selection.end--;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
var end = this.selection.end - 1;
|
|
137
|
+
while (end >= this.selection.start) {
|
|
138
|
+
if (this.pattern.isEditableIndex(end)) {
|
|
139
|
+
this.value[end] = this.placeholderChar;
|
|
140
|
+
}
|
|
141
|
+
end--;
|
|
142
|
+
}
|
|
143
|
+
this.selection.end = this.selection.start;
|
|
144
|
+
}
|
|
145
|
+
if (this._historyIndex != null) {
|
|
146
|
+
this._history.splice(this._historyIndex, this._history.length - this._historyIndex);
|
|
147
|
+
}
|
|
148
|
+
if (this._lastOp !== 'backspace' ||
|
|
149
|
+
selectionBefore.start !== selectionBefore.end ||
|
|
150
|
+
(this._lastSelection !== null &&
|
|
151
|
+
selectionBefore.start !== this._lastSelection.start)) {
|
|
152
|
+
this._history.push({
|
|
153
|
+
value: valueBefore,
|
|
154
|
+
selection: selectionBefore,
|
|
155
|
+
lastOp: this._lastOp
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
this._lastOp = 'backspace';
|
|
159
|
+
this._lastSelection = Object.assign({}, this.selection);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
paste(input) {
|
|
163
|
+
var initialState = {
|
|
164
|
+
value: this.value.slice(),
|
|
165
|
+
selection: Object.assign({}, this.selection),
|
|
166
|
+
_lastOp: this._lastOp,
|
|
167
|
+
_history: this._history.slice(),
|
|
168
|
+
_historyIndex: this._historyIndex,
|
|
169
|
+
_lastSelection: Object.assign({}, this._lastSelection)
|
|
170
|
+
};
|
|
171
|
+
if (this.selection.start < this.pattern.firstEditableIndex) {
|
|
172
|
+
for (var i = 0, l = this.pattern.firstEditableIndex - this.selection.start; i < l; i++) {
|
|
173
|
+
if (input.charAt(i) !== this.pattern.pattern[i]) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
input = input.substring(this.pattern.firstEditableIndex - this.selection.start);
|
|
178
|
+
this.selection.start = this.pattern.firstEditableIndex;
|
|
179
|
+
}
|
|
180
|
+
for (i = 0, l = input.length; i < l && this.selection.start <= this.pattern.lastEditableIndex; i++) {
|
|
181
|
+
var valid = this.input(input.charAt(i));
|
|
182
|
+
if (!valid) {
|
|
183
|
+
if (this.selection.start > 0) {
|
|
184
|
+
var patternIndex = this.selection.start - 1;
|
|
185
|
+
if (!this.pattern.isEditableIndex(patternIndex) &&
|
|
186
|
+
input.charAt(i) === this.pattern.pattern[patternIndex]) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
Object.keys(initialState).forEach(key => {
|
|
191
|
+
this[key] = initialState[key];
|
|
192
|
+
});
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
undo() {
|
|
199
|
+
if (this._history.length === 0 || this._historyIndex === 0) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
var historyItem;
|
|
203
|
+
if (this._historyIndex == null) {
|
|
204
|
+
this._historyIndex = this._history.length - 1;
|
|
205
|
+
historyItem = this._history[this._historyIndex];
|
|
206
|
+
var value = this.getValue();
|
|
207
|
+
if (historyItem.value !== value ||
|
|
208
|
+
historyItem.selection.start !== this.selection.start ||
|
|
209
|
+
historyItem.selection.end !== this.selection.end) {
|
|
210
|
+
this._history.push({
|
|
211
|
+
value: value,
|
|
212
|
+
selection: Object.assign({}, this.selection),
|
|
213
|
+
lastOp: this._lastOp,
|
|
214
|
+
startUndo: true
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
historyItem = this._history[--this._historyIndex];
|
|
220
|
+
}
|
|
221
|
+
this.value = historyItem.value.split('');
|
|
222
|
+
this.selection = historyItem.selection;
|
|
223
|
+
this._lastOp = historyItem.lastOp;
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
redo() {
|
|
227
|
+
if (this._history.length === 0 || this._historyIndex == null) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
var historyItem = this._history[++this._historyIndex];
|
|
231
|
+
if (this._historyIndex === this._history.length - 1) {
|
|
232
|
+
this._historyIndex = null;
|
|
233
|
+
if (historyItem.startUndo) {
|
|
234
|
+
this._history.pop();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
this.value = historyItem.value.split('');
|
|
238
|
+
this.selection = historyItem.selection;
|
|
239
|
+
this._lastOp = historyItem.lastOp;
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
setSelection(selection) {
|
|
243
|
+
this.selection = Object.assign({}, selection);
|
|
244
|
+
if (this.selection.start === this.selection.end) {
|
|
245
|
+
if (this.selection.start < this.pattern.firstEditableIndex) {
|
|
246
|
+
this.selection.start = this.selection.end = this.pattern
|
|
247
|
+
.firstEditableIndex;
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
var index = this.selection.start;
|
|
251
|
+
while (index >= this.pattern.firstEditableIndex) {
|
|
252
|
+
if ((this.pattern.isEditableIndex(index - 1) &&
|
|
253
|
+
this.value[index - 1] !== this.placeholderChar) ||
|
|
254
|
+
index === this.pattern.firstEditableIndex) {
|
|
255
|
+
this.selection.start = this.selection.end = index;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
index--;
|
|
259
|
+
}
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
InputMask.Pattern = Pattern;
|
|
266
|
+
function extend(dest, src) {
|
|
267
|
+
if (src) {
|
|
268
|
+
let props = Object.keys(src);
|
|
269
|
+
for (var i = 0, l = props.length; i < l; i++) {
|
|
270
|
+
dest[props[i]] = src[props[i]];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return dest;
|
|
274
|
+
}
|
|
275
|
+
function copy(obj) {
|
|
276
|
+
return extend({}, obj);
|
|
277
|
+
}
|
|
278
|
+
export default InputMask;
|
|
279
279
|
//# sourceMappingURL=inputMaskCore.js.map
|