d2coreui 23.0.14 → 23.0.15

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 (403) hide show
  1. package/components/clipboard/clipboardUtils.ts +53 -0
  2. package/components/codemirror/SyntaxHighlighter.tsx +58 -0
  3. package/components/collapse/expandable.tsx +48 -0
  4. package/components/color/colorPicker.tsx +121 -0
  5. package/components/color/colorSwatch.d.ts +18 -13
  6. package/components/color/colorSwatch.jsx +87 -0
  7. package/components/color/colorUtils.ts +60 -0
  8. package/components/date/dateRangeInput.tsx +468 -0
  9. package/components/date/dateRangeInputAdvancedPanel.tsx +238 -0
  10. package/components/date/dateRangeInputConfirm.tsx +200 -0
  11. package/components/date/dateTimeInput.tsx +633 -0
  12. package/components/date/durationInput.tsx +375 -0
  13. package/components/form/NiceFormItem.tsx +32 -0
  14. package/components/grid/cell/beanAccessor.ts +17 -0
  15. package/components/grid/cell/cellEditorUtils.ts +12 -0
  16. package/components/grid/cell/customEnumCellEditor.tsx +130 -0
  17. package/components/grid/cell/dataGridCellEditorComponent.tsx +61 -0
  18. package/components/grid/cell/dateCellEditor.tsx +83 -0
  19. package/components/grid/cell/durationCellEditor.tsx +105 -0
  20. package/components/grid/cell/hexaOctetStringCellEditor.tsx +101 -0
  21. package/components/grid/cell/hexaValueCellEditor.tsx +92 -0
  22. package/components/grid/cell/numberCellEditor.tsx +115 -0
  23. package/components/grid/cell/rangeSelector.d.ts +9 -78
  24. package/components/grid/cell/rangeSelector.js +674 -527
  25. package/components/grid/cell/simpleStatusTextCellEditor.tsx +168 -0
  26. package/components/grid/cell/statusTextCellEditor.tsx +198 -0
  27. package/components/grid/cell/tableDefaultRowStyleRules.ts +51 -0
  28. package/components/grid/cell/textCellEditor.tsx +94 -0
  29. package/components/grid/cell/withAgGridHooks.tsx +15 -0
  30. package/components/grid/columnUtils.ts +29 -0
  31. package/components/grid/config/columnTransfer.tsx +258 -0
  32. package/components/grid/config/dataGridEditor.tsx +328 -0
  33. package/components/grid/config/rowHeightCalculator.tsx +29 -0
  34. package/components/grid/config/rowStylePicker.tsx +196 -0
  35. package/components/grid/dataGrid.tsx +2183 -0
  36. package/components/grid/detail/detailHeaderPanel.tsx +59 -0
  37. package/components/grid/export/contextMenu.tsx +154 -0
  38. package/components/grid/export/progressPopup.tsx +106 -0
  39. package/components/grid/export/worker/clipboardExport.ts +10 -0
  40. package/components/grid/export/worker/csvExport.ts +10 -0
  41. package/components/grid/export/worker/pdfExport.ts +98 -0
  42. package/components/grid/export/worker/txtExport.ts +21 -0
  43. package/components/grid/extendedDataGrid.tsx +974 -0
  44. package/components/grid/filter/customColumnFilter.tsx +14 -0
  45. package/components/grid/filter/dataGridColumnFilter.tsx +70 -0
  46. package/components/grid/filter/dateColumnFilter.tsx +34 -0
  47. package/components/grid/filter/textColumnFilter.tsx +37 -0
  48. package/components/grid/filter/wildcardQuickFilterEngine.ts +50 -0
  49. package/components/grid/header/simpleHeader.tsx +270 -0
  50. package/components/grid/panel/dataGridPagination.tsx +123 -0
  51. package/components/grid/panel/loadingOverlay.tsx +14 -0
  52. package/components/grid/panel/noRecordsOverlay.tsx +16 -0
  53. package/components/grid/panel/tablePagination.tsx +77 -0
  54. package/components/icons/dropdownArrow.tsx +67 -0
  55. package/components/icons/undoIcon.tsx +16 -0
  56. package/components/input/autoCompleteInput.tsx +174 -0
  57. package/components/input/draftUtils.tsx +62 -0
  58. package/components/input/draftail.d.ts +186 -1
  59. package/components/input/draftail.js +1 -2
  60. package/components/input/hexaFormattedInput.tsx +64 -0
  61. package/components/input/mask/helpers.ts +154 -0
  62. package/components/input/mask/inputMaskCore.ts +452 -0
  63. package/components/input/mask/pattern.ts +122 -0
  64. package/components/input/maskedInput.tsx +275 -0
  65. package/components/input/passwordInput.tsx +62 -0
  66. package/components/input/simpleAutoComplete.tsx +60 -0
  67. package/components/input/textarea/extractSpansOfClasses.tsx +125 -0
  68. package/components/input/textarea/getRanges.ts +82 -0
  69. package/components/input/textarea/getType.ts +23 -0
  70. package/components/input/textarea/highlighedContents.tsx +20 -0
  71. package/components/input/textarea/highlightedTextarea.css +61 -0
  72. package/components/input/textarea/mentionsWithHighlighting.tsx +95 -0
  73. package/components/keyboard/keyboardUtils.ts +42 -0
  74. package/components/modal/draggableModalProvider.tsx +37 -0
  75. package/components/modal/impl/clamp.ts +4 -0
  76. package/components/modal/impl/draggableModal.tsx +36 -0
  77. package/components/modal/impl/draggableModalContext.ts +14 -0
  78. package/components/modal/impl/draggableModalInner.tsx +114 -0
  79. package/components/modal/impl/draggableModalReducer.ts +285 -0
  80. package/components/modal/impl/getWindowSize.ts +6 -0
  81. package/components/modal/impl/index.ts +5 -0
  82. package/components/modal/impl/resizeHandle.tsx +12 -0
  83. package/components/modal/impl/useDrag.ts +57 -0
  84. package/components/modal/impl/usePrevious.ts +11 -0
  85. package/components/modal/impl/useResize.ts +79 -0
  86. package/components/modal/modalDialog.tsx +172 -0
  87. package/components/picker/enumValuePicker.tsx +48 -0
  88. package/components/platformSpecific.ts +39 -0
  89. package/components/scrollTo/dom-scroll-into-view.d.ts +1 -0
  90. package/components/scrollTo/onlyText.ts +36 -0
  91. package/components/scrollTo/scrollTo.tsx +324 -0
  92. package/components/style/withCss.tsx +14 -0
  93. package/components/style/withInputNumberCss.tsx +18 -0
  94. package/components/svg.d.ts +1 -0
  95. package/components/table/dragSortingTable.tsx +123 -0
  96. package/components/text/impl/innerSize.ts +15 -0
  97. package/components/text/impl/series.ts +37 -0
  98. package/components/text/impl/shallowEqual.ts +19 -0
  99. package/components/text/impl/uniqueId.ts +5 -0
  100. package/components/text/impl/whilst.ts +25 -0
  101. package/components/text/textFit.tsx +229 -0
  102. package/i18n/components.cs.json +101 -101
  103. package/i18n/components.sk.json +101 -101
  104. package/i18n/components.uk.json +101 -101
  105. package/i18n/componentsLocaleHolder.js +24 -29
  106. package/i18n/componentsLocaleLoader.d.ts +9 -0
  107. package/lib/esm/components/color/colorSwatch.d.ts +13 -0
  108. package/lib/esm/components/grid/cell/rangeSelector.d.ts +78 -0
  109. package/lib/esm/components/grid/cell/rangeSelector.js +527 -0
  110. package/{components → lib/esm/components}/grid/export/contextMenu.js +4 -4
  111. package/lib/esm/components/input/draftail.d.ts +1 -0
  112. package/lib/esm/components/input/draftail.js +2 -0
  113. package/lib/esm/i18n/components.cs.json +101 -0
  114. package/lib/esm/i18n/components.sk.json +101 -0
  115. package/lib/esm/i18n/components.uk.json +101 -0
  116. package/lib/esm/i18n/componentsLocaleHolder.js +29 -0
  117. package/lib/esm/package.json +70 -0
  118. package/lib/esm/tsconfig.build.json +24 -0
  119. package/lib/esm/tsconfig.json +11 -0
  120. package/package.json +3 -3
  121. package/tsconfig.build.json +24 -24
  122. package/tsconfig.json +11 -11
  123. /package/{components → lib/esm/components}/clipboard/clipboardUtils.d.ts +0 -0
  124. /package/{components → lib/esm/components}/clipboard/clipboardUtils.js +0 -0
  125. /package/{components → lib/esm/components}/clipboard/clipboardUtils.js.map +0 -0
  126. /package/{components → lib/esm/components}/codemirror/SyntaxHighlighter.d.ts +0 -0
  127. /package/{components → lib/esm/components}/codemirror/SyntaxHighlighter.js +0 -0
  128. /package/{components → lib/esm/components}/codemirror/SyntaxHighlighter.js.map +0 -0
  129. /package/{components → lib/esm/components}/collapse/expandable.d.ts +0 -0
  130. /package/{components → lib/esm/components}/collapse/expandable.js +0 -0
  131. /package/{components → lib/esm/components}/collapse/expandable.js.map +0 -0
  132. /package/{components → lib/esm/components}/color/colorPicker.d.ts +0 -0
  133. /package/{components → lib/esm/components}/color/colorPicker.js +0 -0
  134. /package/{components → lib/esm/components}/color/colorPicker.js.map +0 -0
  135. /package/{components → lib/esm/components}/color/colorSwatch.js +0 -0
  136. /package/{components → lib/esm/components}/color/colorSwatch.js.map +0 -0
  137. /package/{components → lib/esm/components}/color/colorUtils.d.ts +0 -0
  138. /package/{components → lib/esm/components}/color/colorUtils.js +0 -0
  139. /package/{components → lib/esm/components}/color/colorUtils.js.map +0 -0
  140. /package/{components → lib/esm/components}/date/dateRangeInput.d.ts +0 -0
  141. /package/{components → lib/esm/components}/date/dateRangeInput.js +0 -0
  142. /package/{components → lib/esm/components}/date/dateRangeInput.js.map +0 -0
  143. /package/{components → lib/esm/components}/date/dateRangeInputAdvancedPanel.d.ts +0 -0
  144. /package/{components → lib/esm/components}/date/dateRangeInputAdvancedPanel.js +0 -0
  145. /package/{components → lib/esm/components}/date/dateRangeInputAdvancedPanel.js.map +0 -0
  146. /package/{components → lib/esm/components}/date/dateRangeInputConfirm.d.ts +0 -0
  147. /package/{components → lib/esm/components}/date/dateRangeInputConfirm.js +0 -0
  148. /package/{components → lib/esm/components}/date/dateRangeInputConfirm.js.map +0 -0
  149. /package/{components → lib/esm/components}/date/dateTimeInput.d.ts +0 -0
  150. /package/{components → lib/esm/components}/date/dateTimeInput.js +0 -0
  151. /package/{components → lib/esm/components}/date/dateTimeInput.js.map +0 -0
  152. /package/{components → lib/esm/components}/date/durationInput.d.ts +0 -0
  153. /package/{components → lib/esm/components}/date/durationInput.js +0 -0
  154. /package/{components → lib/esm/components}/date/durationInput.js.map +0 -0
  155. /package/{components → lib/esm/components}/form/NiceFormItem.d.ts +0 -0
  156. /package/{components → lib/esm/components}/form/NiceFormItem.js +0 -0
  157. /package/{components → lib/esm/components}/form/NiceFormItem.js.map +0 -0
  158. /package/{components → lib/esm/components}/grid/cell/beanAccessor.d.ts +0 -0
  159. /package/{components → lib/esm/components}/grid/cell/beanAccessor.js +0 -0
  160. /package/{components → lib/esm/components}/grid/cell/beanAccessor.js.map +0 -0
  161. /package/{components → lib/esm/components}/grid/cell/cellEditorUtils.d.ts +0 -0
  162. /package/{components → lib/esm/components}/grid/cell/cellEditorUtils.js +0 -0
  163. /package/{components → lib/esm/components}/grid/cell/cellEditorUtils.js.map +0 -0
  164. /package/{components → lib/esm/components}/grid/cell/customEnumCellEditor.d.ts +0 -0
  165. /package/{components → lib/esm/components}/grid/cell/customEnumCellEditor.js +0 -0
  166. /package/{components → lib/esm/components}/grid/cell/customEnumCellEditor.js.map +0 -0
  167. /package/{components → lib/esm/components}/grid/cell/dataGridCellEditorComponent.d.ts +0 -0
  168. /package/{components → lib/esm/components}/grid/cell/dataGridCellEditorComponent.js +0 -0
  169. /package/{components → lib/esm/components}/grid/cell/dataGridCellEditorComponent.js.map +0 -0
  170. /package/{components → lib/esm/components}/grid/cell/dateCellEditor.d.ts +0 -0
  171. /package/{components → lib/esm/components}/grid/cell/dateCellEditor.js +0 -0
  172. /package/{components → lib/esm/components}/grid/cell/dateCellEditor.js.map +0 -0
  173. /package/{components → lib/esm/components}/grid/cell/durationCellEditor.d.ts +0 -0
  174. /package/{components → lib/esm/components}/grid/cell/durationCellEditor.js +0 -0
  175. /package/{components → lib/esm/components}/grid/cell/durationCellEditor.js.map +0 -0
  176. /package/{components → lib/esm/components}/grid/cell/hexaOctetStringCellEditor.d.ts +0 -0
  177. /package/{components → lib/esm/components}/grid/cell/hexaOctetStringCellEditor.js +0 -0
  178. /package/{components → lib/esm/components}/grid/cell/hexaOctetStringCellEditor.js.map +0 -0
  179. /package/{components → lib/esm/components}/grid/cell/hexaValueCellEditor.d.ts +0 -0
  180. /package/{components → lib/esm/components}/grid/cell/hexaValueCellEditor.js +0 -0
  181. /package/{components → lib/esm/components}/grid/cell/hexaValueCellEditor.js.map +0 -0
  182. /package/{components → lib/esm/components}/grid/cell/numberCellEditor.d.ts +0 -0
  183. /package/{components → lib/esm/components}/grid/cell/numberCellEditor.js +0 -0
  184. /package/{components → lib/esm/components}/grid/cell/numberCellEditor.js.map +0 -0
  185. /package/{components → lib/esm/components}/grid/cell/rangeSelector.js.map +0 -0
  186. /package/{components → lib/esm/components}/grid/cell/simpleStatusTextCellEditor.d.ts +0 -0
  187. /package/{components → lib/esm/components}/grid/cell/simpleStatusTextCellEditor.js +0 -0
  188. /package/{components → lib/esm/components}/grid/cell/simpleStatusTextCellEditor.js.map +0 -0
  189. /package/{components → lib/esm/components}/grid/cell/statusTextCellEditor.d.ts +0 -0
  190. /package/{components → lib/esm/components}/grid/cell/statusTextCellEditor.js +0 -0
  191. /package/{components → lib/esm/components}/grid/cell/statusTextCellEditor.js.map +0 -0
  192. /package/{components → lib/esm/components}/grid/cell/tableDefaultRowStyleRules.d.ts +0 -0
  193. /package/{components → lib/esm/components}/grid/cell/tableDefaultRowStyleRules.js +0 -0
  194. /package/{components → lib/esm/components}/grid/cell/tableDefaultRowStyleRules.js.map +0 -0
  195. /package/{components → lib/esm/components}/grid/cell/textCellEditor.d.ts +0 -0
  196. /package/{components → lib/esm/components}/grid/cell/textCellEditor.js +0 -0
  197. /package/{components → lib/esm/components}/grid/cell/textCellEditor.js.map +0 -0
  198. /package/{components → lib/esm/components}/grid/cell/withAgGridHooks.d.ts +0 -0
  199. /package/{components → lib/esm/components}/grid/cell/withAgGridHooks.js +0 -0
  200. /package/{components → lib/esm/components}/grid/cell/withAgGridHooks.js.map +0 -0
  201. /package/{components → lib/esm/components}/grid/columnUtils.d.ts +0 -0
  202. /package/{components → lib/esm/components}/grid/columnUtils.js +0 -0
  203. /package/{components → lib/esm/components}/grid/columnUtils.js.map +0 -0
  204. /package/{components → lib/esm/components}/grid/config/columnTransfer.d.ts +0 -0
  205. /package/{components → lib/esm/components}/grid/config/columnTransfer.js +0 -0
  206. /package/{components → lib/esm/components}/grid/config/columnTransfer.js.map +0 -0
  207. /package/{components → lib/esm/components}/grid/config/dataGridEditor.d.ts +0 -0
  208. /package/{components → lib/esm/components}/grid/config/dataGridEditor.js +0 -0
  209. /package/{components → lib/esm/components}/grid/config/dataGridEditor.js.map +0 -0
  210. /package/{components → lib/esm/components}/grid/config/rowHeightCalculator.d.ts +0 -0
  211. /package/{components → lib/esm/components}/grid/config/rowHeightCalculator.js +0 -0
  212. /package/{components → lib/esm/components}/grid/config/rowHeightCalculator.js.map +0 -0
  213. /package/{components → lib/esm/components}/grid/config/rowStylePicker.d.ts +0 -0
  214. /package/{components → lib/esm/components}/grid/config/rowStylePicker.js +0 -0
  215. /package/{components → lib/esm/components}/grid/config/rowStylePicker.js.map +0 -0
  216. /package/{components → lib/esm/components}/grid/dataGrid.d.ts +0 -0
  217. /package/{components → lib/esm/components}/grid/dataGrid.js +0 -0
  218. /package/{components → lib/esm/components}/grid/dataGrid.js.map +0 -0
  219. /package/{components → lib/esm/components}/grid/detail/detailHeaderPanel.d.ts +0 -0
  220. /package/{components → lib/esm/components}/grid/detail/detailHeaderPanel.js +0 -0
  221. /package/{components → lib/esm/components}/grid/detail/detailHeaderPanel.js.map +0 -0
  222. /package/{components → lib/esm/components}/grid/export/contextMenu.d.ts +0 -0
  223. /package/{components → lib/esm/components}/grid/export/contextMenu.js.map +0 -0
  224. /package/{components → lib/esm/components}/grid/export/progressPopup.d.ts +0 -0
  225. /package/{components → lib/esm/components}/grid/export/progressPopup.js +0 -0
  226. /package/{components → lib/esm/components}/grid/export/progressPopup.js.map +0 -0
  227. /package/{components → lib/esm/components}/grid/export/worker/clipboardExport.d.ts +0 -0
  228. /package/{components → lib/esm/components}/grid/export/worker/clipboardExport.js +0 -0
  229. /package/{components → lib/esm/components}/grid/export/worker/clipboardExport.js.map +0 -0
  230. /package/{components → lib/esm/components}/grid/export/worker/csvExport.d.ts +0 -0
  231. /package/{components → lib/esm/components}/grid/export/worker/csvExport.js +0 -0
  232. /package/{components → lib/esm/components}/grid/export/worker/csvExport.js.map +0 -0
  233. /package/{components → lib/esm/components}/grid/export/worker/pdfExport.d.ts +0 -0
  234. /package/{components → lib/esm/components}/grid/export/worker/pdfExport.js +0 -0
  235. /package/{components → lib/esm/components}/grid/export/worker/pdfExport.js.map +0 -0
  236. /package/{components → lib/esm/components}/grid/export/worker/txtExport.d.ts +0 -0
  237. /package/{components → lib/esm/components}/grid/export/worker/txtExport.js +0 -0
  238. /package/{components → lib/esm/components}/grid/export/worker/txtExport.js.map +0 -0
  239. /package/{components → lib/esm/components}/grid/extendedDataGrid.d.ts +0 -0
  240. /package/{components → lib/esm/components}/grid/extendedDataGrid.js +0 -0
  241. /package/{components → lib/esm/components}/grid/extendedDataGrid.js.map +0 -0
  242. /package/{components → lib/esm/components}/grid/filter/customColumnFilter.d.ts +0 -0
  243. /package/{components → lib/esm/components}/grid/filter/customColumnFilter.js +0 -0
  244. /package/{components → lib/esm/components}/grid/filter/customColumnFilter.js.map +0 -0
  245. /package/{components → lib/esm/components}/grid/filter/dataGridColumnFilter.d.ts +0 -0
  246. /package/{components → lib/esm/components}/grid/filter/dataGridColumnFilter.js +0 -0
  247. /package/{components → lib/esm/components}/grid/filter/dataGridColumnFilter.js.map +0 -0
  248. /package/{components → lib/esm/components}/grid/filter/dateColumnFilter.d.ts +0 -0
  249. /package/{components → lib/esm/components}/grid/filter/dateColumnFilter.js +0 -0
  250. /package/{components → lib/esm/components}/grid/filter/dateColumnFilter.js.map +0 -0
  251. /package/{components → lib/esm/components}/grid/filter/textColumnFilter.d.ts +0 -0
  252. /package/{components → lib/esm/components}/grid/filter/textColumnFilter.js +0 -0
  253. /package/{components → lib/esm/components}/grid/filter/textColumnFilter.js.map +0 -0
  254. /package/{components → lib/esm/components}/grid/filter/wildcardQuickFilterEngine.d.ts +0 -0
  255. /package/{components → lib/esm/components}/grid/filter/wildcardQuickFilterEngine.js +0 -0
  256. /package/{components → lib/esm/components}/grid/filter/wildcardQuickFilterEngine.js.map +0 -0
  257. /package/{components → lib/esm/components}/grid/header/simpleHeader.d.ts +0 -0
  258. /package/{components → lib/esm/components}/grid/header/simpleHeader.js +0 -0
  259. /package/{components → lib/esm/components}/grid/header/simpleHeader.js.map +0 -0
  260. /package/{components → lib/esm/components}/grid/panel/dataGridPagination.d.ts +0 -0
  261. /package/{components → lib/esm/components}/grid/panel/dataGridPagination.js +0 -0
  262. /package/{components → lib/esm/components}/grid/panel/dataGridPagination.js.map +0 -0
  263. /package/{components → lib/esm/components}/grid/panel/loadingOverlay.d.ts +0 -0
  264. /package/{components → lib/esm/components}/grid/panel/loadingOverlay.js +0 -0
  265. /package/{components → lib/esm/components}/grid/panel/loadingOverlay.js.map +0 -0
  266. /package/{components → lib/esm/components}/grid/panel/noRecordsOverlay.d.ts +0 -0
  267. /package/{components → lib/esm/components}/grid/panel/noRecordsOverlay.js +0 -0
  268. /package/{components → lib/esm/components}/grid/panel/noRecordsOverlay.js.map +0 -0
  269. /package/{components → lib/esm/components}/grid/panel/tablePagination.d.ts +0 -0
  270. /package/{components → lib/esm/components}/grid/panel/tablePagination.js +0 -0
  271. /package/{components → lib/esm/components}/grid/panel/tablePagination.js.map +0 -0
  272. /package/{components → lib/esm/components}/icons/dropdownArrow.d.ts +0 -0
  273. /package/{components → lib/esm/components}/icons/dropdownArrow.js +0 -0
  274. /package/{components → lib/esm/components}/icons/dropdownArrow.js.map +0 -0
  275. /package/{components → lib/esm/components}/icons/undoIcon.d.ts +0 -0
  276. /package/{components → lib/esm/components}/icons/undoIcon.js +0 -0
  277. /package/{components → lib/esm/components}/icons/undoIcon.js.map +0 -0
  278. /package/{components → lib/esm/components}/input/autoCompleteInput.d.ts +0 -0
  279. /package/{components → lib/esm/components}/input/autoCompleteInput.js +0 -0
  280. /package/{components → lib/esm/components}/input/autoCompleteInput.js.map +0 -0
  281. /package/{components → lib/esm/components}/input/draftUtils.d.ts +0 -0
  282. /package/{components → lib/esm/components}/input/draftUtils.js +0 -0
  283. /package/{components → lib/esm/components}/input/draftUtils.js.map +0 -0
  284. /package/{components → lib/esm/components}/input/draftail.js.map +0 -0
  285. /package/{components → lib/esm/components}/input/hexaFormattedInput.d.ts +0 -0
  286. /package/{components → lib/esm/components}/input/hexaFormattedInput.js +0 -0
  287. /package/{components → lib/esm/components}/input/hexaFormattedInput.js.map +0 -0
  288. /package/{components → lib/esm/components}/input/mask/helpers.d.ts +0 -0
  289. /package/{components → lib/esm/components}/input/mask/helpers.js +0 -0
  290. /package/{components → lib/esm/components}/input/mask/helpers.js.map +0 -0
  291. /package/{components → lib/esm/components}/input/mask/inputMaskCore.d.ts +0 -0
  292. /package/{components → lib/esm/components}/input/mask/inputMaskCore.js +0 -0
  293. /package/{components → lib/esm/components}/input/mask/inputMaskCore.js.map +0 -0
  294. /package/{components → lib/esm/components}/input/mask/pattern.d.ts +0 -0
  295. /package/{components → lib/esm/components}/input/mask/pattern.js +0 -0
  296. /package/{components → lib/esm/components}/input/mask/pattern.js.map +0 -0
  297. /package/{components → lib/esm/components}/input/maskedInput.d.ts +0 -0
  298. /package/{components → lib/esm/components}/input/maskedInput.js +0 -0
  299. /package/{components → lib/esm/components}/input/maskedInput.js.map +0 -0
  300. /package/{components → lib/esm/components}/input/passwordInput.d.ts +0 -0
  301. /package/{components → lib/esm/components}/input/passwordInput.js +0 -0
  302. /package/{components → lib/esm/components}/input/passwordInput.js.map +0 -0
  303. /package/{components → lib/esm/components}/input/simpleAutoComplete.d.ts +0 -0
  304. /package/{components → lib/esm/components}/input/simpleAutoComplete.js +0 -0
  305. /package/{components → lib/esm/components}/input/simpleAutoComplete.js.map +0 -0
  306. /package/{components → lib/esm/components}/input/textarea/extractSpansOfClasses.d.ts +0 -0
  307. /package/{components → lib/esm/components}/input/textarea/extractSpansOfClasses.js +0 -0
  308. /package/{components → lib/esm/components}/input/textarea/extractSpansOfClasses.js.map +0 -0
  309. /package/{components → lib/esm/components}/input/textarea/getRanges.d.ts +0 -0
  310. /package/{components → lib/esm/components}/input/textarea/getRanges.js +0 -0
  311. /package/{components → lib/esm/components}/input/textarea/getRanges.js.map +0 -0
  312. /package/{components → lib/esm/components}/input/textarea/getType.d.ts +0 -0
  313. /package/{components → lib/esm/components}/input/textarea/getType.js +0 -0
  314. /package/{components → lib/esm/components}/input/textarea/getType.js.map +0 -0
  315. /package/{components → lib/esm/components}/input/textarea/highlighedContents.d.ts +0 -0
  316. /package/{components → lib/esm/components}/input/textarea/highlighedContents.js +0 -0
  317. /package/{components → lib/esm/components}/input/textarea/highlighedContents.js.map +0 -0
  318. /package/{components → lib/esm/components}/input/textarea/mentionsWithHighlighting.d.ts +0 -0
  319. /package/{components → lib/esm/components}/input/textarea/mentionsWithHighlighting.js +0 -0
  320. /package/{components → lib/esm/components}/input/textarea/mentionsWithHighlighting.js.map +0 -0
  321. /package/{components → lib/esm/components}/keyboard/keyboardUtils.d.ts +0 -0
  322. /package/{components → lib/esm/components}/keyboard/keyboardUtils.js +0 -0
  323. /package/{components → lib/esm/components}/keyboard/keyboardUtils.js.map +0 -0
  324. /package/{components → lib/esm/components}/modal/draggableModalProvider.d.ts +0 -0
  325. /package/{components → lib/esm/components}/modal/draggableModalProvider.js +0 -0
  326. /package/{components → lib/esm/components}/modal/draggableModalProvider.js.map +0 -0
  327. /package/{components → lib/esm/components}/modal/impl/clamp.d.ts +0 -0
  328. /package/{components → lib/esm/components}/modal/impl/clamp.js +0 -0
  329. /package/{components → lib/esm/components}/modal/impl/clamp.js.map +0 -0
  330. /package/{components → lib/esm/components}/modal/impl/draggableModal.d.ts +0 -0
  331. /package/{components → lib/esm/components}/modal/impl/draggableModal.js +0 -0
  332. /package/{components → lib/esm/components}/modal/impl/draggableModal.js.map +0 -0
  333. /package/{components → lib/esm/components}/modal/impl/draggableModalContext.d.ts +0 -0
  334. /package/{components → lib/esm/components}/modal/impl/draggableModalContext.js +0 -0
  335. /package/{components → lib/esm/components}/modal/impl/draggableModalContext.js.map +0 -0
  336. /package/{components → lib/esm/components}/modal/impl/draggableModalInner.d.ts +0 -0
  337. /package/{components → lib/esm/components}/modal/impl/draggableModalInner.js +0 -0
  338. /package/{components → lib/esm/components}/modal/impl/draggableModalInner.js.map +0 -0
  339. /package/{components → lib/esm/components}/modal/impl/draggableModalReducer.d.ts +0 -0
  340. /package/{components → lib/esm/components}/modal/impl/draggableModalReducer.js +0 -0
  341. /package/{components → lib/esm/components}/modal/impl/draggableModalReducer.js.map +0 -0
  342. /package/{components → lib/esm/components}/modal/impl/getWindowSize.d.ts +0 -0
  343. /package/{components → lib/esm/components}/modal/impl/getWindowSize.js +0 -0
  344. /package/{components → lib/esm/components}/modal/impl/getWindowSize.js.map +0 -0
  345. /package/{components → lib/esm/components}/modal/impl/index.d.ts +0 -0
  346. /package/{components → lib/esm/components}/modal/impl/index.js +0 -0
  347. /package/{components → lib/esm/components}/modal/impl/index.js.map +0 -0
  348. /package/{components → lib/esm/components}/modal/impl/resizeHandle.d.ts +0 -0
  349. /package/{components → lib/esm/components}/modal/impl/resizeHandle.js +0 -0
  350. /package/{components → lib/esm/components}/modal/impl/resizeHandle.js.map +0 -0
  351. /package/{components → lib/esm/components}/modal/impl/useDrag.d.ts +0 -0
  352. /package/{components → lib/esm/components}/modal/impl/useDrag.js +0 -0
  353. /package/{components → lib/esm/components}/modal/impl/useDrag.js.map +0 -0
  354. /package/{components → lib/esm/components}/modal/impl/usePrevious.d.ts +0 -0
  355. /package/{components → lib/esm/components}/modal/impl/usePrevious.js +0 -0
  356. /package/{components → lib/esm/components}/modal/impl/usePrevious.js.map +0 -0
  357. /package/{components → lib/esm/components}/modal/impl/useResize.d.ts +0 -0
  358. /package/{components → lib/esm/components}/modal/impl/useResize.js +0 -0
  359. /package/{components → lib/esm/components}/modal/impl/useResize.js.map +0 -0
  360. /package/{components → lib/esm/components}/modal/modalDialog.d.ts +0 -0
  361. /package/{components → lib/esm/components}/modal/modalDialog.js +0 -0
  362. /package/{components → lib/esm/components}/modal/modalDialog.js.map +0 -0
  363. /package/{components → lib/esm/components}/picker/enumValuePicker.d.ts +0 -0
  364. /package/{components → lib/esm/components}/picker/enumValuePicker.js +0 -0
  365. /package/{components → lib/esm/components}/picker/enumValuePicker.js.map +0 -0
  366. /package/{components → lib/esm/components}/platformSpecific.d.ts +0 -0
  367. /package/{components → lib/esm/components}/platformSpecific.js +0 -0
  368. /package/{components → lib/esm/components}/platformSpecific.js.map +0 -0
  369. /package/{components → lib/esm/components}/scrollTo/onlyText.d.ts +0 -0
  370. /package/{components → lib/esm/components}/scrollTo/onlyText.js +0 -0
  371. /package/{components → lib/esm/components}/scrollTo/onlyText.js.map +0 -0
  372. /package/{components → lib/esm/components}/scrollTo/scrollTo.d.ts +0 -0
  373. /package/{components → lib/esm/components}/scrollTo/scrollTo.js +0 -0
  374. /package/{components → lib/esm/components}/scrollTo/scrollTo.js.map +0 -0
  375. /package/{components → lib/esm/components}/style/withCss.d.ts +0 -0
  376. /package/{components → lib/esm/components}/style/withCss.js +0 -0
  377. /package/{components → lib/esm/components}/style/withCss.js.map +0 -0
  378. /package/{components → lib/esm/components}/style/withInputNumberCss.d.ts +0 -0
  379. /package/{components → lib/esm/components}/style/withInputNumberCss.js +0 -0
  380. /package/{components → lib/esm/components}/style/withInputNumberCss.js.map +0 -0
  381. /package/{components → lib/esm/components}/table/dragSortingTable.d.ts +0 -0
  382. /package/{components → lib/esm/components}/table/dragSortingTable.js +0 -0
  383. /package/{components → lib/esm/components}/table/dragSortingTable.js.map +0 -0
  384. /package/{components → lib/esm/components}/text/impl/innerSize.d.ts +0 -0
  385. /package/{components → lib/esm/components}/text/impl/innerSize.js +0 -0
  386. /package/{components → lib/esm/components}/text/impl/innerSize.js.map +0 -0
  387. /package/{components → lib/esm/components}/text/impl/series.d.ts +0 -0
  388. /package/{components → lib/esm/components}/text/impl/series.js +0 -0
  389. /package/{components → lib/esm/components}/text/impl/series.js.map +0 -0
  390. /package/{components → lib/esm/components}/text/impl/shallowEqual.d.ts +0 -0
  391. /package/{components → lib/esm/components}/text/impl/shallowEqual.js +0 -0
  392. /package/{components → lib/esm/components}/text/impl/shallowEqual.js.map +0 -0
  393. /package/{components → lib/esm/components}/text/impl/uniqueId.d.ts +0 -0
  394. /package/{components → lib/esm/components}/text/impl/uniqueId.js +0 -0
  395. /package/{components → lib/esm/components}/text/impl/uniqueId.js.map +0 -0
  396. /package/{components → lib/esm/components}/text/impl/whilst.d.ts +0 -0
  397. /package/{components → lib/esm/components}/text/impl/whilst.js +0 -0
  398. /package/{components → lib/esm/components}/text/impl/whilst.js.map +0 -0
  399. /package/{components → lib/esm/components}/text/textFit.d.ts +0 -0
  400. /package/{components → lib/esm/components}/text/textFit.js +0 -0
  401. /package/{components → lib/esm/components}/text/textFit.js.map +0 -0
  402. /package/{i18n → lib/esm/i18n}/componentsLocaleHolder.d.ts +0 -0
  403. /package/{i18n → lib/esm/i18n}/componentsLocaleHolder.js.map +0 -0
@@ -0,0 +1,154 @@
1
+ import {KeyboardEvent} from 'react';
2
+
3
+ let KEYCODE_Z = "KeyZ";
4
+ let KEYCODE_Y = "KeyY";
5
+
6
+ export function isUndo(e: KeyboardEvent): boolean {
7
+ return (
8
+ (e.ctrlKey || e.metaKey) &&
9
+ e.code === (e.shiftKey ? KEYCODE_Y : KEYCODE_Z)
10
+ );
11
+ }
12
+
13
+ export function isRedo(e: KeyboardEvent): boolean {
14
+ return (
15
+ (e.ctrlKey || e.metaKey) &&
16
+ e.code === (e.shiftKey ? KEYCODE_Z : KEYCODE_Y)
17
+ );
18
+ }
19
+
20
+ type GetSelectionResult = { start: number; end: number };
21
+
22
+ export function getSelection(el: HTMLInputElement): GetSelectionResult {
23
+ let start, end;
24
+ if (el.selectionStart !== undefined) {
25
+ start = el.selectionStart;
26
+ end = el.selectionEnd;
27
+ } else {
28
+ try {
29
+ el.focus();
30
+ // @ts-ignore (IE only)
31
+ let rangeEl = el.createTextRange();
32
+ let clone = rangeEl.duplicate();
33
+
34
+ // @ts-ignore (IE only)
35
+ rangeEl.moveToBookmark(document.selection.createRange().getBookmark());
36
+ clone.setEndPoint('EndToStart', rangeEl);
37
+
38
+ start = clone.text.length;
39
+ end = start + rangeEl.text.length;
40
+ } catch (e) {
41
+ /* not focused or not visible */
42
+ }
43
+ }
44
+
45
+ return { start, end };
46
+ }
47
+
48
+ let selectionTimeout: any;
49
+ export function setSelection(
50
+ el: HTMLInputElement,
51
+ selection: GetSelectionResult
52
+ ) {
53
+ clearTimeout(selectionTimeout);
54
+
55
+ try {
56
+ if (
57
+ el.selectionStart === selection.start &&
58
+ el.selectionEnd === selection.end
59
+ ) {
60
+ return;
61
+ }
62
+
63
+ if (el.selectionStart !== undefined) {
64
+ el.focus();
65
+ el.setSelectionRange(selection.start, selection.end);
66
+
67
+ // fix https://bugs.chromium.org/p/chromium/issues/detail?id=32865
68
+ selectionTimeout = setTimeout(() => {
69
+ setSelection(el, selection);
70
+ }, 0);
71
+
72
+ } else {
73
+ el.focus();
74
+ // @ts-ignore (IE only)
75
+ let rangeEl = el.createTextRange();
76
+ rangeEl.collapse(true);
77
+ rangeEl.moveStart('character', selection.start);
78
+ rangeEl.moveEnd('character', selection.end - selection.start);
79
+ rangeEl.select();
80
+ }
81
+ } catch (e) {
82
+ /* not focused or not visible */
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Merge an object defining format characters into the defaults.
88
+ * Passing null/undefined for en existing format character removes it.
89
+ * Passing a definition for an existing format character overrides it.
90
+ */
91
+ export function mergeFormatCharacters(formatCharacters: FormatCharacters) {
92
+ var merged = { ...DEFAULT_FORMAT_CHARACTERS };
93
+ if (formatCharacters) {
94
+ var chars = Object.keys(formatCharacters);
95
+ for (var i = 0, l = chars.length; i < l; i++) {
96
+ var char = chars[i];
97
+ if (formatCharacters[char] == null) {
98
+ delete merged[char];
99
+ } else {
100
+ merged[char] = formatCharacters[char];
101
+ }
102
+ }
103
+ }
104
+ return merged;
105
+ }
106
+
107
+ export const ESCAPE_CHAR = '\\';
108
+
109
+ export const DIGIT_RE = /^\d$/;
110
+ export const LETTER_RE = /^[A-Za-z]$/;
111
+ export const ALPHANNUMERIC_RE = /^[\dA-Za-z]$/;
112
+
113
+ export const DEFAULT_PLACEHOLDER_CHAR = '_';
114
+
115
+ export const DEFAULT_FORMAT_CHARACTERS: FormatCharacters = {
116
+ '*': {
117
+ validate: function(char: string) {
118
+ return ALPHANNUMERIC_RE.test(char);
119
+ }
120
+ },
121
+ '1': {
122
+ validate: function(char: string) {
123
+ return DIGIT_RE.test(char);
124
+ }
125
+ },
126
+ a: {
127
+ validate: function(char: string) {
128
+ return LETTER_RE.test(char);
129
+ }
130
+ },
131
+ A: {
132
+ validate: function(char: string) {
133
+ return LETTER_RE.test(char);
134
+ },
135
+ transform: function(char: string) {
136
+ return char.toUpperCase();
137
+ }
138
+ },
139
+ '#': {
140
+ validate: function(char: string) {
141
+ return ALPHANNUMERIC_RE.test(char);
142
+ },
143
+ transform: function(char: string) {
144
+ return char.toUpperCase();
145
+ }
146
+ }
147
+ };
148
+
149
+ export type FormatCharacters = {
150
+ [key: string]: {
151
+ transform?(str: string): string;
152
+ validate(str: string): boolean;
153
+ };
154
+ };
@@ -0,0 +1,452 @@
1
+ import {DEFAULT_PLACEHOLDER_CHAR, FormatCharacters, mergeFormatCharacters} from './helpers';
2
+ import {Pattern} from './pattern';
3
+
4
+ type SelectionObject = { start: number; end: number };
5
+
6
+ type Options = {
7
+ formatCharacters: FormatCharacters;
8
+ pattern: string;
9
+ isRevealingMask: boolean;
10
+ placeholderChar: string;
11
+ selection: SelectionObject;
12
+ value: string;
13
+ };
14
+
15
+ export class InputMask {
16
+ static Pattern = Pattern;
17
+
18
+ formatCharacters!: FormatCharacters;
19
+ pattern!: Pattern;
20
+ isRevealingMask!: boolean;
21
+ placeholderChar!: string;
22
+ selection!: SelectionObject;
23
+ value!: string[];
24
+ emptyValue = '';
25
+
26
+ _history: {
27
+ value: string;
28
+ selection: SelectionObject;
29
+ lastOp: string | null;
30
+ startUndo?: boolean;
31
+ }[] = [];
32
+
33
+ _historyIndex: null | number = null;
34
+ _lastOp: null | string = null;
35
+ _lastSelection: null | SelectionObject = null;
36
+
37
+ constructor(options: Partial<Options>) {
38
+ const mergedOptions: Options = {
39
+ ...{
40
+ isRevealingMask: false,
41
+ placeholderChar: DEFAULT_PLACEHOLDER_CHAR,
42
+ selection: {start: 0, end: 0},
43
+ value: ''
44
+ },
45
+ ...options
46
+ } as Options;
47
+
48
+ if (!mergedOptions.pattern) {
49
+ throw new Error('InputMask: you must provide a pattern.');
50
+ }
51
+
52
+ if (
53
+ typeof mergedOptions.placeholderChar !== 'string' ||
54
+ mergedOptions.placeholderChar.length > 1
55
+ ) {
56
+ throw new Error(
57
+ 'InputMask: placeholderChar should be a single character or an empty string.'
58
+ );
59
+ }
60
+
61
+ this.placeholderChar = mergedOptions.placeholderChar;
62
+ this.formatCharacters = mergeFormatCharacters(
63
+ mergedOptions.formatCharacters
64
+ );
65
+
66
+ this.setPattern(mergedOptions.pattern, {
67
+ value: mergedOptions.value,
68
+ selection: mergedOptions.selection,
69
+ isRevealingMask: mergedOptions.isRevealingMask
70
+ });
71
+ }
72
+
73
+ setPattern(patternSource: string, options: Partial<Options>) {
74
+ const merged = {
75
+ selection: {start: 0, end: 0},
76
+ value: '',
77
+ ...options
78
+ };
79
+
80
+ this.pattern = new Pattern(
81
+ patternSource,
82
+ this.formatCharacters,
83
+ this.placeholderChar,
84
+ merged.isRevealingMask
85
+ );
86
+
87
+ this.setValue(merged.value);
88
+
89
+ this.emptyValue = this.pattern.formatValue([]).join('');
90
+ this.selection = merged.selection;
91
+ this._resetHistory();
92
+ }
93
+
94
+ setValue(value?: string) {
95
+ if (value == null) {
96
+ value = '';
97
+ }
98
+ this.value = this.pattern.formatValue((value || '').split(''));
99
+ }
100
+
101
+ _resetHistory() {
102
+ this._history = [];
103
+ this._historyIndex = null;
104
+ this._lastOp = null;
105
+ this._lastSelection = {...this.selection};
106
+ }
107
+
108
+ getValue(): string {
109
+ if (this.pattern.isRevealingMask) {
110
+ this.value = this.pattern.formatValue(
111
+ (this.getRawValue() || '').split('')
112
+ );
113
+ }
114
+ return (this.value || []).join('');
115
+ }
116
+
117
+ getRawValue(): string {
118
+ var rawValue = [];
119
+ for (var i = 0; i < this.value.length; i++) {
120
+ if (this.pattern._editableIndices[i] === true) {
121
+ rawValue.push(this.value[i]);
122
+ }
123
+ }
124
+ return rawValue.join('');
125
+ }
126
+
127
+ /**
128
+ * Applies a single character of input based on the current selection.
129
+ * @param {string} char
130
+ * @return {boolean} true if a change has been made to value or selection as a
131
+ * result of the input, false otherwise.
132
+ */
133
+ input(char: string) {
134
+ // Ignore additional input if the cursor's at the end of the pattern
135
+ if (
136
+ this.selection.start === this.selection.end &&
137
+ this.selection.start === this.pattern.length
138
+ ) {
139
+ return false;
140
+ }
141
+
142
+ const selectionBefore = copy(this.selection);
143
+ const valueBefore = this.getValue();
144
+
145
+ let inputIndex = this.selection.start;
146
+
147
+ // If the cursor or selection is prior to the first editable character, make
148
+ // sure any input given is applied to it.
149
+ if (this.pattern.firstEditableIndex && inputIndex < this.pattern.firstEditableIndex) {
150
+ inputIndex = this.pattern.firstEditableIndex;
151
+ }
152
+
153
+ // Bail out or add the character to input
154
+ if (this.pattern.isEditableIndex(inputIndex)) {
155
+ if (!this.pattern.isValidAtIndex(char, inputIndex)) {
156
+ return false;
157
+ }
158
+ this.value[inputIndex] = this.pattern.transform(char, inputIndex);
159
+ } else {
160
+ console.log('not editable');
161
+ }
162
+
163
+ // If multiple characters were selected, blank the remainder out based on the
164
+ // pattern.
165
+ let end = this.selection.end - 1;
166
+ while (end > inputIndex) {
167
+ if (this.pattern.isEditableIndex(end)) {
168
+ this.value[end] = this.placeholderChar;
169
+ }
170
+ end--;
171
+ }
172
+
173
+ // Advance the cursor to the next character
174
+ this.selection.start = this.selection.end = inputIndex + 1;
175
+
176
+ // Skip over any subsequent static characters
177
+ while (
178
+ this.pattern.length > this.selection.start &&
179
+ !this.pattern.isEditableIndex(this.selection.start)
180
+ ) {
181
+ this.selection.start++;
182
+ this.selection.end++;
183
+ }
184
+
185
+ // History
186
+ if (this._historyIndex != null) {
187
+ // Took more input after undoing, so blow any subsequent history away
188
+ this._history.splice(
189
+ this._historyIndex,
190
+ this._history.length - this._historyIndex
191
+ );
192
+ this._historyIndex = null;
193
+ }
194
+ if (
195
+ this._lastOp !== 'input' ||
196
+ selectionBefore.start !== selectionBefore.end ||
197
+ (this._lastSelection !== null &&
198
+ selectionBefore.start !== this._lastSelection.start)
199
+ ) {
200
+ this._history.push({
201
+ value: valueBefore,
202
+ selection: selectionBefore,
203
+ lastOp: this._lastOp
204
+ });
205
+ }
206
+ this._lastOp = 'input';
207
+ this._lastSelection = copy(this.selection);
208
+
209
+ return true;
210
+ }
211
+
212
+ /**
213
+ * Attempts to delete from the value based on the current cursor position or
214
+ * selection.
215
+ * @return {boolean} true if the value or selection changed as the result of
216
+ * backspacing, false otherwise.
217
+ */
218
+ backspace() {
219
+ // If the cursor is at the start there's nothing to do
220
+ if (this.selection.start === 0 && this.selection.end === 0) {
221
+ return false;
222
+ }
223
+
224
+ var selectionBefore = {...this.selection};
225
+ var valueBefore = this.getValue();
226
+
227
+ // No range selected - work on the character preceding the cursor
228
+ if (this.selection.start === this.selection.end) {
229
+ if (this.pattern.isEditableIndex(this.selection.start - 1)) {
230
+ if (this.pattern.isRevealingMask) {
231
+ this.value.splice(this.selection.start - 1);
232
+ } else {
233
+ this.value[this.selection.start - 1] = this.placeholderChar;
234
+ }
235
+ }
236
+ this.selection.start--;
237
+ this.selection.end--;
238
+ }
239
+ // Range selected - delete characters and leave the cursor at the start of the selection
240
+ else {
241
+ var end = this.selection.end - 1;
242
+ while (end >= this.selection.start) {
243
+ if (this.pattern.isEditableIndex(end)) {
244
+ this.value[end] = this.placeholderChar;
245
+ }
246
+ end--;
247
+ }
248
+ this.selection.end = this.selection.start;
249
+ }
250
+
251
+ // History
252
+ if (this._historyIndex != null) {
253
+ // Took more input after undoing, so blow any subsequent history away
254
+ this._history.splice(
255
+ this._historyIndex,
256
+ this._history.length - this._historyIndex
257
+ );
258
+ }
259
+ if (
260
+ this._lastOp !== 'backspace' ||
261
+ selectionBefore.start !== selectionBefore.end ||
262
+ (this._lastSelection !== null &&
263
+ selectionBefore.start !== this._lastSelection.start)
264
+ ) {
265
+ this._history.push({
266
+ value: valueBefore,
267
+ selection: selectionBefore,
268
+ lastOp: this._lastOp
269
+ });
270
+ }
271
+ this._lastOp = 'backspace';
272
+ this._lastSelection = {...this.selection};
273
+
274
+ return true;
275
+ }
276
+
277
+ /**
278
+ * Attempts to paste a string of input at the current cursor position or over
279
+ * the top of the current selection.
280
+ * Invalid content at any position will cause the paste to be rejected, and it
281
+ * may contain static parts of the mask's pattern.
282
+ * @param {string} input
283
+ * @return {boolean} true if the paste was successful, false otherwise.
284
+ */
285
+ paste(input: string) {
286
+ // This is necessary because we're just calling input() with each character
287
+ // and rolling back if any were invalid, rather than checking up-front.
288
+ var initialState = {
289
+ value: this.value.slice(),
290
+ selection: {...this.selection},
291
+ _lastOp: this._lastOp,
292
+ _history: this._history.slice(),
293
+ _historyIndex: this._historyIndex,
294
+ _lastSelection: {...this._lastSelection}
295
+ };
296
+
297
+ // If there are static characters at the start of the pattern and the cursor
298
+ // or selection is within them, the static characters must match for a valid
299
+ // paste.
300
+ if (this.selection.start < this.pattern.firstEditableIndex!) {
301
+ for (
302
+ var i = 0, l = this.pattern.firstEditableIndex! - this.selection.start;
303
+ i < l;
304
+ i++
305
+ ) {
306
+ if (input.charAt(i) !== this.pattern.pattern[i]) {
307
+ return false;
308
+ }
309
+ }
310
+
311
+ // Continue as if the selection and input started from the editable part of
312
+ // the pattern.
313
+ input = input.substring(
314
+ this.pattern.firstEditableIndex! - this.selection.start
315
+ );
316
+ this.selection.start = this.pattern.firstEditableIndex!;
317
+ }
318
+
319
+ for (
320
+ i = 0, l = input.length;
321
+ i < l && this.selection.start <= this.pattern.lastEditableIndex!;
322
+ i++
323
+ ) {
324
+ var valid = this.input(input.charAt(i));
325
+ // Allow static parts of the pattern to appear in pasted input - they will
326
+ // already have been stepped over by input(), so verify that the value
327
+ // deemed invalid by input() was the expected static character.
328
+ if (!valid) {
329
+ if (this.selection.start > 0) {
330
+ // XXX This only allows for one static character to be skipped
331
+ var patternIndex = this.selection.start - 1;
332
+ if (
333
+ !this.pattern.isEditableIndex(patternIndex) &&
334
+ input.charAt(i) === this.pattern.pattern[patternIndex]
335
+ ) {
336
+ continue;
337
+ }
338
+ }
339
+
340
+ Object.keys(initialState).forEach(key => {
341
+ // @ts-ignore
342
+ this[key] = initialState[key];
343
+ });
344
+
345
+ return false;
346
+ }
347
+ }
348
+
349
+ return true;
350
+ }
351
+
352
+ undo() {
353
+ // If there is no history, or nothing more on the history stack, we can't undo
354
+ if (this._history.length === 0 || this._historyIndex === 0) {
355
+ return false;
356
+ }
357
+
358
+ var historyItem;
359
+ if (this._historyIndex == null) {
360
+ // Not currently undoing, set up the initial history index
361
+ this._historyIndex = this._history.length - 1;
362
+ historyItem = this._history[this._historyIndex];
363
+ // Add a new history entry if anything has changed since the last one, so we
364
+ // can redo back to the initial state we started undoing from.
365
+ var value = this.getValue();
366
+ if (
367
+ historyItem.value !== value ||
368
+ historyItem.selection.start !== this.selection.start ||
369
+ historyItem.selection.end !== this.selection.end
370
+ ) {
371
+ this._history.push({
372
+ value: value,
373
+ selection: {...this.selection},
374
+ lastOp: this._lastOp,
375
+ startUndo: true
376
+ });
377
+ }
378
+ } else {
379
+ historyItem = this._history[--this._historyIndex];
380
+ }
381
+
382
+ this.value = historyItem.value.split('');
383
+ this.selection = historyItem.selection;
384
+ this._lastOp = historyItem.lastOp;
385
+ return true;
386
+ }
387
+
388
+ redo() {
389
+ if (this._history.length === 0 || this._historyIndex == null) {
390
+ return false;
391
+ }
392
+ var historyItem = this._history[++this._historyIndex];
393
+ // If this is the last history item, we're done redoing
394
+ if (this._historyIndex === this._history.length - 1) {
395
+ this._historyIndex = null;
396
+ // If the last history item was only added to start undoing, remove it
397
+ if (historyItem.startUndo) {
398
+ this._history.pop();
399
+ }
400
+ }
401
+ this.value = historyItem.value.split('');
402
+ this.selection = historyItem.selection;
403
+ this._lastOp = historyItem.lastOp;
404
+ return true;
405
+ }
406
+
407
+ setSelection(selection: SelectionObject) {
408
+ this.selection = {...selection};
409
+
410
+ if (this.selection.start === this.selection.end) {
411
+ if (this.selection.start < this.pattern.firstEditableIndex!) {
412
+ this.selection!.start = this.selection!.end = this.pattern
413
+ .firstEditableIndex as number;
414
+ return true;
415
+ }
416
+ // Set selection to the first editable, non-placeholder character before the selection
417
+ // OR to the beginning of the pattern
418
+ var index = this.selection.start;
419
+ while (index >= this.pattern.firstEditableIndex!) {
420
+ if (
421
+ (this.pattern.isEditableIndex(index - 1) &&
422
+ this.value[index - 1] !== this.placeholderChar) ||
423
+ index === this.pattern.firstEditableIndex
424
+ ) {
425
+ this.selection.start = this.selection.end = index;
426
+ break;
427
+ }
428
+ index--;
429
+ }
430
+ return true;
431
+ }
432
+ return false;
433
+ }
434
+ }
435
+
436
+ function extend(dest: any, src: any) {
437
+ if (src) {
438
+ let props = Object.keys(src);
439
+
440
+ for (var i = 0, l = props.length; i < l; i++) {
441
+ dest[props[i]] = src[props[i]];
442
+ }
443
+ }
444
+
445
+ return dest;
446
+ }
447
+
448
+ function copy<T = any>(obj: T): T {
449
+ return extend({}, obj);
450
+ }
451
+
452
+ export default InputMask;