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.
Files changed (295) hide show
  1. package/components/clipboard/clipboardUtils.d.ts +4 -3
  2. package/components/clipboard/clipboardUtils.js +47 -22
  3. package/components/clipboard/clipboardUtils.js.map +1 -1
  4. package/components/codemirror/SyntaxHighlighter.d.ts +21 -21
  5. package/components/codemirror/SyntaxHighlighter.js +45 -44
  6. package/components/codemirror/SyntaxHighlighter.js.map +1 -1
  7. package/components/collapse/expandable.d.ts +13 -12
  8. package/components/collapse/expandable.js +20 -20
  9. package/components/collapse/expandable.js.map +1 -1
  10. package/components/color/colorPicker.d.ts +20 -20
  11. package/components/color/colorPicker.js +53 -53
  12. package/components/color/colorPicker.js.map +1 -1
  13. package/components/color/colorSwatch.d.ts +13 -12
  14. package/components/color/colorSwatch.js +62 -62
  15. package/components/color/colorSwatch.js.map +1 -1
  16. package/components/color/colorUtils.d.ts +7 -7
  17. package/components/color/colorUtils.js +43 -43
  18. package/components/color/colorUtils.js.map +1 -1
  19. package/components/date/dateRangeInput.d.ts +66 -64
  20. package/components/date/dateRangeInput.js +292 -297
  21. package/components/date/dateRangeInput.js.map +1 -1
  22. package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -26
  23. package/components/date/dateRangeInputAdvancedPanel.js +130 -115
  24. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  25. package/components/date/dateRangeInputConfirm.d.ts +31 -29
  26. package/components/date/dateRangeInputConfirm.js +132 -121
  27. package/components/date/dateRangeInputConfirm.js.map +1 -1
  28. package/components/date/dateTimeInput.d.ts +72 -69
  29. package/components/date/dateTimeInput.js +440 -412
  30. package/components/date/dateTimeInput.js.map +1 -1
  31. package/components/date/durationInput.d.ts +59 -56
  32. package/components/date/durationInput.js +269 -280
  33. package/components/date/durationInput.js.map +1 -1
  34. package/components/form/NiceFormItem.d.ts +14 -14
  35. package/components/form/NiceFormItem.js +28 -31
  36. package/components/form/NiceFormItem.js.map +1 -1
  37. package/components/grid/cell/beanAccessor.d.ts +9 -0
  38. package/components/grid/cell/beanAccessor.js +13 -0
  39. package/components/grid/cell/beanAccessor.js.map +1 -0
  40. package/components/grid/cell/cellEditorUtils.d.ts +4 -4
  41. package/components/grid/cell/cellEditorUtils.js +8 -8
  42. package/components/grid/cell/customEnumCellEditor.d.ts +4 -26
  43. package/components/grid/cell/customEnumCellEditor.js +82 -91
  44. package/components/grid/cell/customEnumCellEditor.js.map +1 -1
  45. package/components/grid/cell/dataGridCellEditorComponent.d.ts +14 -0
  46. package/components/grid/cell/dataGridCellEditorComponent.js +49 -0
  47. package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -0
  48. package/components/grid/cell/dateCellEditor.d.ts +4 -25
  49. package/components/grid/cell/dateCellEditor.js +53 -72
  50. package/components/grid/cell/dateCellEditor.js.map +1 -1
  51. package/components/grid/cell/durationCellEditor.d.ts +4 -24
  52. package/components/grid/cell/durationCellEditor.js +74 -97
  53. package/components/grid/cell/durationCellEditor.js.map +1 -1
  54. package/components/grid/cell/hexaOctetStringCellEditor.d.ts +4 -24
  55. package/components/grid/cell/hexaOctetStringCellEditor.js +70 -94
  56. package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
  57. package/components/grid/cell/hexaValueCellEditor.d.ts +4 -24
  58. package/components/grid/cell/hexaValueCellEditor.js +65 -89
  59. package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
  60. package/components/grid/cell/numberCellEditor.d.ts +4 -27
  61. package/components/grid/cell/numberCellEditor.js +73 -95
  62. package/components/grid/cell/numberCellEditor.js.map +1 -1
  63. package/components/grid/cell/rangeSelector.d.ts +78 -78
  64. package/components/grid/cell/rangeSelector.js +526 -518
  65. package/components/grid/cell/rangeSelector.js.map +1 -1
  66. package/components/grid/cell/simpleStatusTextCellEditor.d.ts +4 -32
  67. package/components/grid/cell/simpleStatusTextCellEditor.js +106 -116
  68. package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
  69. package/components/grid/cell/statusTextCellEditor.d.ts +4 -32
  70. package/components/grid/cell/statusTextCellEditor.js +136 -159
  71. package/components/grid/cell/statusTextCellEditor.js.map +1 -1
  72. package/components/grid/cell/tableDefaultRowStyleRules.d.ts +20 -20
  73. package/components/grid/cell/tableDefaultRowStyleRules.js +29 -18
  74. package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
  75. package/components/grid/cell/textCellEditor.d.ts +4 -21
  76. package/components/grid/cell/textCellEditor.js +63 -85
  77. package/components/grid/cell/textCellEditor.js.map +1 -1
  78. package/components/grid/cell/withAgGridHooks.d.ts +3 -0
  79. package/components/grid/cell/withAgGridHooks.js +15 -0
  80. package/components/grid/cell/withAgGridHooks.js.map +1 -0
  81. package/components/grid/columnUtils.d.ts +5 -5
  82. package/components/grid/columnUtils.js +26 -26
  83. package/components/grid/columnUtils.js.map +1 -1
  84. package/components/grid/config/columnTransfer.d.ts +21 -22
  85. package/components/grid/config/columnTransfer.js +205 -201
  86. package/components/grid/config/columnTransfer.js.map +1 -1
  87. package/components/grid/config/dataGridEditor.d.ts +41 -41
  88. package/components/grid/config/dataGridEditor.js +181 -160
  89. package/components/grid/config/dataGridEditor.js.map +1 -1
  90. package/components/grid/config/rowHeightCalculator.d.ts +8 -0
  91. package/components/grid/config/rowHeightCalculator.js +20 -0
  92. package/components/grid/config/rowHeightCalculator.js.map +1 -0
  93. package/components/grid/config/rowStylePicker.d.ts +27 -25
  94. package/components/grid/config/rowStylePicker.js +127 -109
  95. package/components/grid/config/rowStylePicker.js.map +1 -1
  96. package/components/grid/dataGrid.d.ts +218 -206
  97. package/components/grid/dataGrid.js +1629 -1538
  98. package/components/grid/dataGrid.js.map +1 -1
  99. package/components/grid/detail/detailHeaderPanel.d.ts +13 -13
  100. package/components/grid/detail/detailHeaderPanel.js +25 -25
  101. package/components/grid/detail/detailHeaderPanel.js.map +1 -1
  102. package/components/grid/export/contextMenu.d.ts +18 -24
  103. package/components/grid/export/contextMenu.js +116 -113
  104. package/components/grid/export/contextMenu.js.map +1 -1
  105. package/components/grid/export/progressPopup.d.ts +29 -29
  106. package/components/grid/export/progressPopup.js +93 -93
  107. package/components/grid/export/progressPopup.js.map +1 -1
  108. package/components/grid/export/worker/clipboardExport.d.ts +1 -1
  109. package/components/grid/export/worker/clipboardExport.js +8 -8
  110. package/components/grid/export/worker/csvExport.d.ts +1 -1
  111. package/components/grid/export/worker/csvExport.js +8 -8
  112. package/components/grid/export/worker/pdfExport.d.ts +1 -1
  113. package/components/grid/export/worker/pdfExport.js +81 -81
  114. package/components/grid/export/worker/pdfExport.js.map +1 -1
  115. package/components/grid/export/worker/txtExport.d.ts +1 -1
  116. package/components/grid/export/worker/txtExport.js +19 -19
  117. package/components/grid/extendedDataGrid.d.ts +140 -140
  118. package/components/grid/extendedDataGrid.js +704 -695
  119. package/components/grid/extendedDataGrid.js.map +1 -1
  120. package/components/grid/filter/customColumnFilter.d.ts +5 -21
  121. package/components/grid/filter/customColumnFilter.js +11 -82
  122. package/components/grid/filter/customColumnFilter.js.map +1 -1
  123. package/components/grid/filter/dataGridColumnFilter.d.ts +17 -0
  124. package/components/grid/filter/dataGridColumnFilter.js +49 -0
  125. package/components/grid/filter/dataGridColumnFilter.js.map +1 -0
  126. package/components/grid/filter/dateColumnFilter.d.ts +7 -11
  127. package/components/grid/filter/dateColumnFilter.js +22 -56
  128. package/components/grid/filter/dateColumnFilter.js.map +1 -1
  129. package/components/grid/filter/textColumnFilter.d.ts +8 -20
  130. package/components/grid/filter/textColumnFilter.js +24 -76
  131. package/components/grid/filter/textColumnFilter.js.map +1 -1
  132. package/components/grid/filter/wildcardQuickFilterEngine.d.ts +7 -0
  133. package/components/grid/filter/wildcardQuickFilterEngine.js +48 -0
  134. package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -0
  135. package/components/grid/header/simpleHeader.d.ts +17 -16
  136. package/components/grid/header/simpleHeader.js +230 -186
  137. package/components/grid/header/simpleHeader.js.map +1 -1
  138. package/components/grid/panel/dataGridPagination.d.ts +16 -16
  139. package/components/grid/panel/dataGridPagination.js +58 -58
  140. package/components/grid/panel/dataGridPagination.js.map +1 -1
  141. package/components/grid/panel/loadingOverlay.d.ts +6 -6
  142. package/components/grid/panel/loadingOverlay.js +10 -10
  143. package/components/grid/panel/loadingOverlay.js.map +1 -1
  144. package/components/grid/panel/noRecordsOverlay.d.ts +6 -6
  145. package/components/grid/panel/noRecordsOverlay.js +10 -10
  146. package/components/grid/panel/noRecordsOverlay.js.map +1 -1
  147. package/components/grid/panel/tablePagination.d.ts +10 -10
  148. package/components/grid/panel/tablePagination.js +45 -45
  149. package/components/grid/panel/tablePagination.js.map +1 -1
  150. package/components/icons/dropdownArrow.d.ts +8 -0
  151. package/components/icons/dropdownArrow.js +59 -0
  152. package/components/icons/dropdownArrow.js.map +1 -0
  153. package/components/icons/undoIcon.d.ts +8 -8
  154. package/components/icons/undoIcon.js +6 -6
  155. package/components/input/autoCompleteInput.d.ts +35 -35
  156. package/components/input/autoCompleteInput.js +122 -121
  157. package/components/input/autoCompleteInput.js.map +1 -1
  158. package/components/input/draftUtils.d.ts +4 -4
  159. package/components/input/draftUtils.js +48 -48
  160. package/components/input/draftUtils.js.map +1 -1
  161. package/components/input/draftail.d.ts +1 -1
  162. package/components/input/draftail.js +1 -1
  163. package/components/input/hexaFormattedInput.d.ts +16 -16
  164. package/components/input/hexaFormattedInput.js +54 -54
  165. package/components/input/hexaFormattedInput.js.map +1 -1
  166. package/components/input/mask/helpers.d.ts +28 -28
  167. package/components/input/mask/helpers.js +112 -112
  168. package/components/input/mask/helpers.js.map +1 -1
  169. package/components/input/mask/inputMaskCore.d.ts +46 -46
  170. package/components/input/mask/inputMaskCore.js +278 -278
  171. package/components/input/mask/inputMaskCore.js.map +1 -1
  172. package/components/input/mask/pattern.d.ts +20 -20
  173. package/components/input/mask/pattern.js +78 -78
  174. package/components/input/mask/pattern.js.map +1 -1
  175. package/components/input/maskedInput.d.ts +373 -351
  176. package/components/input/maskedInput.js +224 -224
  177. package/components/input/maskedInput.js.map +1 -1
  178. package/components/input/passwordInput.d.ts +9 -9
  179. package/components/input/passwordInput.js +55 -55
  180. package/components/input/passwordInput.js.map +1 -1
  181. package/components/input/simpleAutoComplete.d.ts +12 -12
  182. package/components/input/simpleAutoComplete.js +41 -43
  183. package/components/input/simpleAutoComplete.js.map +1 -1
  184. package/components/input/textarea/extractSpansOfClasses.d.ts +15 -15
  185. package/components/input/textarea/extractSpansOfClasses.js +96 -96
  186. package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
  187. package/components/input/textarea/getRanges.d.ts +1 -1
  188. package/components/input/textarea/getRanges.js +73 -73
  189. package/components/input/textarea/getRanges.js.map +1 -1
  190. package/components/input/textarea/getType.d.ts +1 -1
  191. package/components/input/textarea/getType.js +26 -26
  192. package/components/input/textarea/getType.js.map +1 -1
  193. package/components/input/textarea/highlighedContents.d.ts +6 -6
  194. package/components/input/textarea/highlighedContents.js +10 -10
  195. package/components/input/textarea/mentionsWithHighlighting.d.ts +27 -27
  196. package/components/input/textarea/mentionsWithHighlighting.js +60 -60
  197. package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
  198. package/components/keyboard/keyboardUtils.d.ts +5 -5
  199. package/components/keyboard/keyboardUtils.js +32 -32
  200. package/components/modal/draggableModalProvider.d.ts +4 -4
  201. package/components/modal/draggableModalProvider.js +21 -21
  202. package/components/modal/draggableModalProvider.js.map +1 -1
  203. package/components/modal/impl/clamp.d.ts +1 -1
  204. package/components/modal/impl/clamp.js +1 -1
  205. package/components/modal/impl/clamp.js.map +1 -1
  206. package/components/modal/impl/draggableModal.d.ts +12 -12
  207. package/components/modal/impl/draggableModal.js +17 -17
  208. package/components/modal/impl/draggableModal.js.map +1 -1
  209. package/components/modal/impl/draggableModalContext.d.ts +9 -9
  210. package/components/modal/impl/draggableModalContext.js +2 -2
  211. package/components/modal/impl/draggableModalContext.js.map +1 -1
  212. package/components/modal/impl/draggableModalInner.d.ts +15 -13
  213. package/components/modal/impl/draggableModalInner.js +57 -55
  214. package/components/modal/impl/draggableModalInner.js.map +1 -1
  215. package/components/modal/impl/draggableModalReducer.d.ts +66 -62
  216. package/components/modal/impl/draggableModalReducer.js +77 -78
  217. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  218. package/components/modal/impl/getWindowSize.d.ts +4 -4
  219. package/components/modal/impl/getWindowSize.js +4 -4
  220. package/components/modal/impl/getWindowSize.js.map +1 -1
  221. package/components/modal/impl/index.d.ts +3 -3
  222. package/components/modal/impl/index.js +3 -3
  223. package/components/modal/impl/index.js.map +1 -1
  224. package/components/modal/impl/resizeHandle.d.ts +3 -3
  225. package/components/modal/impl/resizeHandle.js +4 -4
  226. package/components/modal/impl/resizeHandle.js.map +1 -1
  227. package/components/modal/impl/useDrag.d.ts +5 -5
  228. package/components/modal/impl/useDrag.js +42 -42
  229. package/components/modal/impl/useDrag.js.map +1 -1
  230. package/components/modal/impl/usePrevious.d.ts +1 -1
  231. package/components/modal/impl/usePrevious.js +8 -8
  232. package/components/modal/impl/usePrevious.js.map +1 -1
  233. package/components/modal/impl/useResize.d.ts +7 -7
  234. package/components/modal/impl/useResize.js +46 -46
  235. package/components/modal/impl/useResize.js.map +1 -1
  236. package/components/modal/modalDialog.d.ts +49 -49
  237. package/components/modal/modalDialog.js +152 -152
  238. package/components/modal/modalDialog.js.map +1 -1
  239. package/components/picker/enumValuePicker.d.ts +16 -16
  240. package/components/picker/enumValuePicker.js +34 -34
  241. package/components/picker/enumValuePicker.js.map +1 -1
  242. package/components/platformSpecific.d.ts +10 -10
  243. package/components/platformSpecific.js +27 -27
  244. package/components/scrollTo/onlyText.d.ts +4 -4
  245. package/components/scrollTo/onlyText.js +30 -30
  246. package/components/scrollTo/onlyText.js.map +1 -1
  247. package/components/scrollTo/scrollTo.d.ts +41 -39
  248. package/components/scrollTo/scrollTo.js +264 -264
  249. package/components/scrollTo/scrollTo.js.map +1 -1
  250. package/components/style/withCss.d.ts +9 -0
  251. package/components/style/withCss.js +6 -0
  252. package/components/style/withCss.js.map +1 -0
  253. package/components/style/withInputNumberCss.d.ts +6 -0
  254. package/components/style/withInputNumberCss.js +13 -0
  255. package/components/style/withInputNumberCss.js.map +1 -0
  256. package/components/table/dragSortingTable.d.ts +13 -14
  257. package/components/table/dragSortingTable.js +96 -82
  258. package/components/table/dragSortingTable.js.map +1 -1
  259. package/components/text/impl/innerSize.d.ts +2 -2
  260. package/components/text/impl/innerSize.js +12 -12
  261. package/components/text/impl/series.d.ts +1 -1
  262. package/components/text/impl/series.js +28 -28
  263. package/components/text/impl/shallowEqual.d.ts +1 -1
  264. package/components/text/impl/shallowEqual.js +18 -18
  265. package/components/text/impl/shallowEqual.js.map +1 -1
  266. package/components/text/impl/uniqueId.d.ts +1 -1
  267. package/components/text/impl/uniqueId.js +4 -4
  268. package/components/text/impl/whilst.d.ts +1 -1
  269. package/components/text/impl/whilst.js +19 -19
  270. package/components/text/impl/whilst.js.map +1 -1
  271. package/components/text/textFit.d.ts +38 -38
  272. package/components/text/textFit.js +165 -168
  273. package/components/text/textFit.js.map +1 -1
  274. package/i18n/components.cs.json +101 -100
  275. package/i18n/components.sk.json +101 -100
  276. package/i18n/components.uk.json +101 -100
  277. package/i18n/componentsLocaleHolder.d.ts +3 -3
  278. package/i18n/componentsLocaleHolder.js +28 -28
  279. package/i18n/componentsLocaleHolder.js.map +1 -1
  280. package/package.json +71 -70
  281. package/style/index.less +274 -298
  282. package/style/modal/DraggableModal.css +43 -40
  283. package/style/modal/ResizeHandle.css +27 -19
  284. package/tsconfig.build.json +24 -24
  285. package/tsconfig.json +11 -11
  286. package/components/grid/cell/wildcardQuickFilter.d.ts +0 -11
  287. package/components/grid/cell/wildcardQuickFilter.js +0 -61
  288. package/components/grid/cell/wildcardQuickFilter.js.map +0 -1
  289. package/components/table/dataTable.d.ts +0 -17
  290. package/components/table/dataTable.js +0 -79
  291. package/components/table/dataTable.js.map +0 -1
  292. package/style/antd/antd-tree-showline.css +0 -25
  293. package/style/antd/full-height-tabs.scss +0 -63
  294. package/style/draftail/draftail-editor.css +0 -179
  295. 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 @@
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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AClD,CAAC;IA+FD,gBAAgB;QACZ,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO,KAAK,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,CAAC;IAED,iBAAiB;QACb,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;YAClC,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;gBACxC,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,YAAY,CAAC;SACtB;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';\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,CAAC,CAAC;gBAC5C,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACjC,CAAC;YAED,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACtB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;QACL,CAAC,CAAC;QAEF,eAAU,GAAG,CAAC,CAAiB,EAAE,EAAE;YAC/B,UAAU,CAAC,GAAG,EAAE;gBACZ,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAA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AS,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
+ }