d2coreui 23.0.52 → 23.0.53

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 (280) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +154 -0
  3. package/components/clipboard/clipboardUtils.d.ts +11 -0
  4. package/components/clipboard/clipboardUtils.js +16 -4
  5. package/components/clipboard/clipboardUtils.js.map +1 -1
  6. package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
  7. package/components/codemirror/SyntaxHighlighter.js +6 -1
  8. package/components/codemirror/SyntaxHighlighter.js.map +1 -1
  9. package/components/collapse/expandable.d.ts +10 -0
  10. package/components/collapse/expandable.js +4 -0
  11. package/components/collapse/expandable.js.map +1 -1
  12. package/components/color/colorPicker.d.ts +16 -0
  13. package/components/color/colorPicker.js +4 -0
  14. package/components/color/colorPicker.js.map +1 -1
  15. package/components/color/colorSwatch.d.ts +16 -0
  16. package/components/color/colorSwatch.js +23 -2
  17. package/components/color/colorSwatch.js.map +1 -1
  18. package/components/color/colorUtils.d.ts +9 -0
  19. package/components/color/colorUtils.js +15 -0
  20. package/components/color/colorUtils.js.map +1 -1
  21. package/components/date/dateRangeInput.d.ts +76 -0
  22. package/components/date/dateRangeInput.js +63 -12
  23. package/components/date/dateRangeInput.js.map +1 -1
  24. package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
  25. package/components/date/dateRangeInputAdvancedPanel.js +7 -0
  26. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  27. package/components/date/dateRangeInputConfirm.d.ts +18 -0
  28. package/components/date/dateRangeInputConfirm.js +12 -0
  29. package/components/date/dateRangeInputConfirm.js.map +1 -1
  30. package/components/date/dateTimeInput.d.ts +99 -0
  31. package/components/date/dateTimeInput.js +78 -6
  32. package/components/date/dateTimeInput.js.map +1 -1
  33. package/components/date/durationInput.d.ts +37 -0
  34. package/components/date/durationInput.js +26 -3
  35. package/components/date/durationInput.js.map +1 -1
  36. package/components/date/savedIntervals.d.ts +63 -0
  37. package/components/date/savedIntervals.js +37 -0
  38. package/components/date/savedIntervals.js.map +1 -1
  39. package/components/date/savedIntervalsDialog.d.ts +13 -0
  40. package/components/date/savedIntervalsDialog.js +7 -2
  41. package/components/date/savedIntervalsDialog.js.map +1 -1
  42. package/components/form/NiceFormItem.d.ts +9 -0
  43. package/components/form/NiceFormItem.js +4 -0
  44. package/components/form/NiceFormItem.js.map +1 -1
  45. package/components/grid/cell/beanAccessor.d.ts +12 -0
  46. package/components/grid/cell/beanAccessor.js +8 -0
  47. package/components/grid/cell/beanAccessor.js.map +1 -1
  48. package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
  49. package/components/grid/cell/bigNumberCellEditor.js +19 -0
  50. package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
  51. package/components/grid/cell/cellControl.d.ts +4 -0
  52. package/components/grid/cell/cellControl.js +14 -0
  53. package/components/grid/cell/cellControl.js.map +1 -1
  54. package/components/grid/cell/cellEditorUtils.d.ts +6 -0
  55. package/components/grid/cell/cellEditorUtils.js +6 -0
  56. package/components/grid/cell/cellEditorUtils.js.map +1 -1
  57. package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
  58. package/components/grid/cell/customEnumCellEditor.js +10 -0
  59. package/components/grid/cell/customEnumCellEditor.js.map +1 -1
  60. package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
  61. package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
  62. package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
  63. package/components/grid/cell/dateCellEditor.d.ts +6 -0
  64. package/components/grid/cell/dateCellEditor.js +10 -0
  65. package/components/grid/cell/dateCellEditor.js.map +1 -1
  66. package/components/grid/cell/dragListenerFeature.d.ts +6 -0
  67. package/components/grid/cell/dragListenerFeature.js +6 -0
  68. package/components/grid/cell/dragListenerFeature.js.map +1 -1
  69. package/components/grid/cell/durationCellEditor.d.ts +6 -0
  70. package/components/grid/cell/durationCellEditor.js +14 -0
  71. package/components/grid/cell/durationCellEditor.js.map +1 -1
  72. package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
  73. package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
  74. package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
  75. package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
  76. package/components/grid/cell/hexaValueCellEditor.js +14 -0
  77. package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
  78. package/components/grid/cell/numberCellEditor.d.ts +6 -0
  79. package/components/grid/cell/numberCellEditor.js +15 -0
  80. package/components/grid/cell/numberCellEditor.js.map +1 -1
  81. package/components/grid/cell/rangeSelector.d.ts +7 -0
  82. package/components/grid/cell/rangeSelector.js +59 -5
  83. package/components/grid/cell/rangeSelector.js.map +1 -1
  84. package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
  85. package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
  86. package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
  87. package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
  88. package/components/grid/cell/statusTextCellEditor.js +17 -0
  89. package/components/grid/cell/statusTextCellEditor.js.map +1 -1
  90. package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
  91. package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
  92. package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
  93. package/components/grid/cell/textCellEditor.d.ts +6 -0
  94. package/components/grid/cell/textCellEditor.js +15 -0
  95. package/components/grid/cell/textCellEditor.js.map +1 -1
  96. package/components/grid/cell/withAgGridHooks.d.ts +8 -0
  97. package/components/grid/cell/withAgGridHooks.js +8 -0
  98. package/components/grid/cell/withAgGridHooks.js.map +1 -1
  99. package/components/grid/columnUtils.d.ts +7 -0
  100. package/components/grid/columnUtils.js +7 -0
  101. package/components/grid/columnUtils.js.map +1 -1
  102. package/components/grid/config/columnTransfer.d.ts +18 -0
  103. package/components/grid/config/columnTransfer.js +14 -3
  104. package/components/grid/config/columnTransfer.js.map +1 -1
  105. package/components/grid/config/dataGridEditor.d.ts +31 -0
  106. package/components/grid/config/dataGridEditor.js +14 -2
  107. package/components/grid/config/dataGridEditor.js.map +1 -1
  108. package/components/grid/config/rowHeightCalculator.d.ts +11 -0
  109. package/components/grid/config/rowHeightCalculator.js +11 -0
  110. package/components/grid/config/rowHeightCalculator.js.map +1 -1
  111. package/components/grid/config/rowStylePicker.d.ts +19 -0
  112. package/components/grid/config/rowStylePicker.js +12 -0
  113. package/components/grid/config/rowStylePicker.js.map +1 -1
  114. package/components/grid/dataGrid.d.ts +331 -0
  115. package/components/grid/dataGrid.js +168 -11
  116. package/components/grid/dataGrid.js.map +1 -1
  117. package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
  118. package/components/grid/detail/detailHeaderPanel.js +5 -0
  119. package/components/grid/detail/detailHeaderPanel.js.map +1 -1
  120. package/components/grid/export/contextMenu.d.ts +31 -0
  121. package/components/grid/export/contextMenu.js +8 -0
  122. package/components/grid/export/contextMenu.js.map +1 -1
  123. package/components/grid/export/progressPopup.d.ts +21 -0
  124. package/components/grid/export/progressPopup.js +17 -0
  125. package/components/grid/export/progressPopup.js.map +1 -1
  126. package/components/grid/export/worker/pdfExport.js +5 -0
  127. package/components/grid/export/worker/pdfExport.js.map +1 -1
  128. package/components/grid/extendedDataGrid.d.ts +240 -0
  129. package/components/grid/extendedDataGrid.js +116 -2
  130. package/components/grid/extendedDataGrid.js.map +1 -1
  131. package/components/grid/filter/customColumnFilter.d.ts +5 -0
  132. package/components/grid/filter/customColumnFilter.js +5 -0
  133. package/components/grid/filter/customColumnFilter.js.map +1 -1
  134. package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
  135. package/components/grid/filter/dataGridColumnFilter.js +19 -0
  136. package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
  137. package/components/grid/filter/dateColumnFilter.d.ts +6 -0
  138. package/components/grid/filter/dateColumnFilter.js +6 -0
  139. package/components/grid/filter/dateColumnFilter.js.map +1 -1
  140. package/components/grid/filter/textColumnFilter.d.ts +6 -0
  141. package/components/grid/filter/textColumnFilter.js +6 -0
  142. package/components/grid/filter/textColumnFilter.js.map +1 -1
  143. package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
  144. package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
  145. package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
  146. package/components/grid/header/simpleHeader.d.ts +17 -0
  147. package/components/grid/header/simpleHeader.js +20 -0
  148. package/components/grid/header/simpleHeader.js.map +1 -1
  149. package/components/grid/panel/dataGridPagination.d.ts +10 -0
  150. package/components/grid/panel/dataGridPagination.js +5 -0
  151. package/components/grid/panel/dataGridPagination.js.map +1 -1
  152. package/components/grid/panel/loadingOverlay.d.ts +5 -0
  153. package/components/grid/panel/loadingOverlay.js +4 -0
  154. package/components/grid/panel/loadingOverlay.js.map +1 -1
  155. package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
  156. package/components/grid/panel/noRecordsOverlay.js +5 -0
  157. package/components/grid/panel/noRecordsOverlay.js.map +1 -1
  158. package/components/grid/panel/tablePagination.d.ts +4 -0
  159. package/components/grid/panel/tablePagination.js +4 -0
  160. package/components/grid/panel/tablePagination.js.map +1 -1
  161. package/components/icons/dropdownArrow.d.ts +3 -0
  162. package/components/icons/dropdownArrow.js +2 -0
  163. package/components/icons/dropdownArrow.js.map +1 -1
  164. package/components/icons/undoIcon.d.ts +2 -0
  165. package/components/icons/undoIcon.js +2 -0
  166. package/components/icons/undoIcon.js.map +1 -1
  167. package/components/input/autoCompleteInput.d.ts +29 -0
  168. package/components/input/autoCompleteInput.js +7 -0
  169. package/components/input/autoCompleteInput.js.map +1 -1
  170. package/components/input/draftUtils.d.ts +7 -0
  171. package/components/input/draftUtils.js +9 -0
  172. package/components/input/draftUtils.js.map +1 -1
  173. package/components/input/hexaFormattedInput.d.ts +9 -0
  174. package/components/input/hexaFormattedInput.js +3 -0
  175. package/components/input/hexaFormattedInput.js.map +1 -1
  176. package/components/input/mask/helpers.d.ts +27 -0
  177. package/components/input/mask/helpers.js +27 -0
  178. package/components/input/mask/helpers.js.map +1 -1
  179. package/components/input/mask/inputMaskCore.d.ts +80 -0
  180. package/components/input/mask/inputMaskCore.js +90 -0
  181. package/components/input/mask/inputMaskCore.js.map +1 -1
  182. package/components/input/mask/pattern.d.ts +24 -0
  183. package/components/input/mask/pattern.js +26 -0
  184. package/components/input/mask/pattern.js.map +1 -1
  185. package/components/input/maskedInput.d.ts +53 -0
  186. package/components/input/maskedInput.js +44 -4
  187. package/components/input/maskedInput.js.map +1 -1
  188. package/components/input/passwordInput.d.ts +7 -0
  189. package/components/input/passwordInput.js +8 -0
  190. package/components/input/passwordInput.js.map +1 -1
  191. package/components/input/simpleAutoComplete.d.ts +6 -0
  192. package/components/input/simpleAutoComplete.js +6 -0
  193. package/components/input/simpleAutoComplete.js.map +1 -1
  194. package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
  195. package/components/input/textarea/extractSpansOfClasses.js +26 -1
  196. package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
  197. package/components/input/textarea/getRanges.d.ts +7 -0
  198. package/components/input/textarea/getRanges.js +11 -0
  199. package/components/input/textarea/getRanges.js.map +1 -1
  200. package/components/input/textarea/getType.d.ts +5 -0
  201. package/components/input/textarea/getType.js +5 -0
  202. package/components/input/textarea/getType.js.map +1 -1
  203. package/components/input/textarea/highlighedContents.d.ts +4 -0
  204. package/components/input/textarea/highlighedContents.js +5 -0
  205. package/components/input/textarea/highlighedContents.js.map +1 -1
  206. package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
  207. package/components/input/textarea/mentionsWithHighlighting.js +14 -0
  208. package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
  209. package/components/keyboard/keyboardUtils.d.ts +6 -0
  210. package/components/keyboard/keyboardUtils.js +6 -0
  211. package/components/keyboard/keyboardUtils.js.map +1 -1
  212. package/components/modal/draggableModalProvider.d.ts +6 -0
  213. package/components/modal/draggableModalProvider.js +7 -0
  214. package/components/modal/draggableModalProvider.js.map +1 -1
  215. package/components/modal/impl/clamp.js +1 -0
  216. package/components/modal/impl/clamp.js.map +1 -1
  217. package/components/modal/impl/draggableModal.d.ts +1 -0
  218. package/components/modal/impl/draggableModal.js +6 -0
  219. package/components/modal/impl/draggableModal.js.map +1 -1
  220. package/components/modal/impl/draggableModalContext.js +1 -0
  221. package/components/modal/impl/draggableModalContext.js.map +1 -1
  222. package/components/modal/impl/draggableModalInner.js +12 -1
  223. package/components/modal/impl/draggableModalInner.js.map +1 -1
  224. package/components/modal/impl/draggableModalReducer.d.ts +7 -1
  225. package/components/modal/impl/draggableModalReducer.js +6 -1
  226. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  227. package/components/modal/impl/draggableModalStyles.d.ts +17 -0
  228. package/components/modal/impl/draggableModalStyles.js +31 -0
  229. package/components/modal/impl/draggableModalStyles.js.map +1 -1
  230. package/components/modal/impl/getWindowSize.js +1 -0
  231. package/components/modal/impl/getWindowSize.js.map +1 -1
  232. package/components/modal/impl/index.js +1 -0
  233. package/components/modal/impl/index.js.map +1 -1
  234. package/components/modal/impl/resizeHandle.d.ts +1 -0
  235. package/components/modal/impl/resizeHandle.js +4 -1
  236. package/components/modal/impl/resizeHandle.js.map +1 -1
  237. package/components/modal/impl/useDrag.js +1 -0
  238. package/components/modal/impl/useDrag.js.map +1 -1
  239. package/components/modal/impl/usePrevious.js +1 -0
  240. package/components/modal/impl/usePrevious.js.map +1 -1
  241. package/components/modal/impl/useResize.js +1 -0
  242. package/components/modal/impl/useResize.js.map +1 -1
  243. package/components/modal/modalDialog.d.ts +85 -0
  244. package/components/modal/modalDialog.js +80 -10
  245. package/components/modal/modalDialog.js.map +1 -1
  246. package/components/picker/enumValuePicker.d.ts +17 -0
  247. package/components/picker/enumValuePicker.js +4 -0
  248. package/components/picker/enumValuePicker.js.map +1 -1
  249. package/components/platformSpecific.d.ts +17 -0
  250. package/components/platformSpecific.js +16 -0
  251. package/components/platformSpecific.js.map +1 -1
  252. package/components/scrollTo/onlyText.d.ts +5 -0
  253. package/components/scrollTo/onlyText.js +5 -0
  254. package/components/scrollTo/onlyText.js.map +1 -1
  255. package/components/scrollTo/scrollTo.d.ts +56 -0
  256. package/components/scrollTo/scrollTo.js +40 -3
  257. package/components/scrollTo/scrollTo.js.map +1 -1
  258. package/components/style/withCss.d.ts +15 -0
  259. package/components/style/withCss.js +6 -0
  260. package/components/style/withCss.js.map +1 -1
  261. package/components/table/dragSortingTable.d.ts +15 -0
  262. package/components/table/dragSortingTable.js +12 -0
  263. package/components/table/dragSortingTable.js.map +1 -1
  264. package/components/text/impl/innerSize.js +2 -0
  265. package/components/text/impl/innerSize.js.map +1 -1
  266. package/components/text/impl/series.d.ts +10 -0
  267. package/components/text/impl/series.js +10 -0
  268. package/components/text/impl/series.js.map +1 -1
  269. package/components/text/impl/shallowEqual.js +1 -0
  270. package/components/text/impl/shallowEqual.js.map +1 -1
  271. package/components/text/impl/whilst.d.ts +7 -0
  272. package/components/text/impl/whilst.js +7 -0
  273. package/components/text/impl/whilst.js.map +1 -1
  274. package/components/text/textFit.d.ts +24 -0
  275. package/components/text/textFit.js +29 -1
  276. package/components/text/textFit.js.map +1 -1
  277. package/i18n/componentsLocaleHolder.d.ts +9 -0
  278. package/i18n/componentsLocaleHolder.js +9 -0
  279. package/i18n/componentsLocaleHolder.js.map +1 -1
  280. package/package.json +66 -65
@@ -1 +1 @@
1
- {"version":3,"file":"tablePagination.js","sourceRoot":"","sources":["../../../../../components/grid/panel/tablePagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AACrE,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAOpC,MA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C,EAAE,EAAE;wCACb,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;4CACrB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;gDACnD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC;4CACzE,CAAC;wCACL,CAAC;oCACL,CAAC,GACZ;gCACF,oBAAC,MAAM,IAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAC,SAAS,EAAC,OAAO,EAAE,GAAG,EAAE;wCAC3D,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;4CACnD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC;wCACzE,CAAC;oCACL,CAAC;oCACG,oBAAC,aAAa,OAAE,CACX,CACG,EAEpB,OAAO,EAAC,OAAO,EACf,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE;gCACtB,IAAI,CAAC,OAAO,EAAE,CAAC;oCACX,IAAI,CAAC,QAAQ,CAAC,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAC;gCAC1C,CAAC;4BACL,CAAC,EACD,gBAAgB,EAAC,uBAAuB,IAEvC,eAAe,CACV,CACb,CAAC;oBACN,CAAC;yBAAM,CAAC;wBACJ,OAAO,eAAe,CAAC;oBAC3B,CAAC;gBACL,CAAC,IACH,CACA,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {CheckOutlined} from \"@ant-design/icons\";\r\nimport {Button, InputNumber, Pagination, Popover, Space} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {PaginationProps} from \"antd/es/pagination\";\r\n\r\ninterface PaginationComponentState {\r\n gotoPageNumber?: number | null\r\n}\r\n\r\nexport default class PaginationComponent extends React.Component<PaginationProps, PaginationComponentState> {\r\n constructor(props: Readonly<PaginationProps>) {\r\n super(props);\r\n this.state = {\r\n gotoPageNumber: null\r\n }\r\n }\r\n\r\n render() {\r\n const pageCount = this.props.total && this.props.pageSize ? Math.ceil(this.props.total / this.props.pageSize) : 1;\r\n return (\r\n <div>\r\n <Pagination\r\n showSizeChanger={false}\r\n {...this.props}\r\n itemRender={(page, type, originalElement) => {\r\n if (page === this.props.current && type === \"page\") {\r\n return (\r\n <Popover\r\n title=\"\"\r\n placement=\"bottom\"\r\n content={\r\n <Space.Compact>\r\n <InputNumber min={1} max={pageCount}\r\n value={this.state.gotoPageNumber ? this.state.gotoPageNumber : this.props.current}\r\n onChange={(newValue) => {\r\n if (typeof newValue === \"number\") {\r\n this.setState({gotoPageNumber: newValue});\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.code === \"Enter\") {\r\n if (this.state.gotoPageNumber && this.props.onChange) {\r\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize!);\r\n }\r\n }\r\n }}\r\n />\r\n <Button title={i18n(\"Goto Page\")} type=\"primary\" onClick={() => {\r\n if (this.state.gotoPageNumber && this.props.onChange) {\r\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize!);\r\n }\r\n }}>\r\n <CheckOutlined/>\r\n </Button>\r\n </Space.Compact>\r\n }\r\n trigger=\"hover\"\r\n onOpenChange={(visible) => {\r\n if (!visible) {\r\n this.setState({gotoPageNumber: null});\r\n }\r\n }}\r\n overlayClassName=\"control-panel-popover\"\r\n >\r\n {originalElement}\r\n </Popover>\r\n );\r\n } else {\r\n return originalElement;\r\n }\r\n }}\r\n />\r\n </div>\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"tablePagination.js","sourceRoot":"","sources":["../../../../../components/grid/panel/tablePagination.tsx"],"names":[],"mappings":"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AAC;yBAAM,CAAC;wBACJ,OAAO,eAAe,CAAC;oBAC3B,CAAC;gBACL,CAAC,IACH,CACA,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {CheckOutlined} from \"@ant-design/icons\";\r\nimport {Button, InputNumber, Pagination, Popover, Space} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {PaginationProps} from \"antd/es/pagination\";\r\n\r\ninterface PaginationComponentState {\r\n gotoPageNumber?: number | null\r\n}\r\n\r\n/**\r\n * antd `Pagination` (size changer hidden by default) whose current page item opens, on hover, a go-to-page input.\r\n * Accepts all antd `PaginationProps`; the go-to-page input calls `onChange(page, pageSize)`.\r\n */\r\nexport default class PaginationComponent extends React.Component<PaginationProps, PaginationComponentState> {\r\n constructor(props: Readonly<PaginationProps>) {\r\n super(props);\r\n this.state = {\r\n gotoPageNumber: null\r\n }\r\n }\r\n\r\n render() {\r\n const pageCount = this.props.total && this.props.pageSize ? Math.ceil(this.props.total / this.props.pageSize) : 1;\r\n return (\r\n <div>\r\n <Pagination\r\n showSizeChanger={false}\r\n {...this.props}\r\n itemRender={(page, type, originalElement) => {\r\n if (page === this.props.current && type === \"page\") {\r\n return (\r\n <Popover\r\n title=\"\"\r\n placement=\"bottom\"\r\n content={\r\n <Space.Compact>\r\n <InputNumber min={1} max={pageCount}\r\n value={this.state.gotoPageNumber ? this.state.gotoPageNumber : this.props.current}\r\n onChange={(newValue) => {\r\n if (typeof newValue === \"number\") {\r\n this.setState({gotoPageNumber: newValue});\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.code === \"Enter\") {\r\n if (this.state.gotoPageNumber && this.props.onChange) {\r\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize!);\r\n }\r\n }\r\n }}\r\n />\r\n <Button title={i18n(\"Goto Page\")} type=\"primary\" onClick={() => {\r\n if (this.state.gotoPageNumber && this.props.onChange) {\r\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize!);\r\n }\r\n }}>\r\n <CheckOutlined/>\r\n </Button>\r\n </Space.Compact>\r\n }\r\n trigger=\"hover\"\r\n onOpenChange={(visible) => {\r\n if (!visible) {\r\n this.setState({gotoPageNumber: null});\r\n }\r\n }}\r\n overlayClassName=\"control-panel-popover\"\r\n >\r\n {originalElement}\r\n </Popover>\r\n );\r\n } else {\r\n return originalElement;\r\n }\r\n }}\r\n />\r\n </div>\r\n );\r\n }\r\n}"]}
@@ -1,8 +1,11 @@
1
1
  import React from "react";
2
2
  import { AntdIconProps } from "@ant-design/icons/lib/components/AntdIcon";
3
+ /** Props of {@link DropdownArrow}; other props are passed to the antd `DownOutlined` icon (except `className`). */
3
4
  export interface DropdownArrowProps extends AntdIconProps {
5
+ /** Rotates the arrow by 180 degrees (pointing up), with a transition. */
4
6
  opened?: boolean;
5
7
  }
8
+ /** Small down-arrow icon styled like the antd select arrow, used as a dropdown open/close indicator. */
6
9
  export default class DropdownArrow extends React.PureComponent<DropdownArrowProps> {
7
10
  render(): React.JSX.Element;
8
11
  }
@@ -13,6 +13,7 @@ import React from "react";
13
13
  import { createStyles } from "antd-style";
14
14
  import { DownOutlined } from "@ant-design/icons";
15
15
  import WithCss from "d2coreui/components/style/withCss";
16
+ // @ts-ignore
16
17
  const useStyles = createStyles(({ token, css, cx }) => {
17
18
  return {
18
19
  dropdownArrow: css `
@@ -49,6 +50,7 @@ const useStyles = createStyles(({ token, css, cx }) => {
49
50
  `
50
51
  };
51
52
  }, { label: "dropdownArrow" });
53
+ /** Small down-arrow icon styled like the antd select arrow, used as a dropdown open/close indicator. */
52
54
  export default class DropdownArrow extends React.PureComponent {
53
55
  render() {
54
56
  const _a = this.props, { opened } = _a, restProps = __rest(_a, ["opened"]);
@@ -1 +1 @@
1
- {"version":3,"file":"dropdownArrow.js","sourceRoot":"","sources":["../../../../components/icons/dropdownArrow.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC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"react\";\r\nimport {createStyles} from \"antd-style\";\r\nimport {DownOutlined} from \"@ant-design/icons\";\r\nimport WithCss from \"d2coreui/components/style/withCss\";\r\nimport {AntdIconProps} from \"@ant-design/icons/lib/components/AntdIcon\";\r\n\r\n// @ts-ignore\r\nconst useStyles = createStyles(({token, css, cx}) => {\r\n return {\r\n dropdownArrow: css`\r\n transform-origin: 50% 50%;\r\n margin-left: ${token.controlPaddingHorizontalSM}px;\r\n `,\r\n\r\n dropdownArrowIcon: css`\r\n color: ${token.colorTextDisabled};\r\n font-size: ${token.fontSizeSM}px;\r\n vertical-align: center;\r\n cursor: pointer;\r\n transition: color 0.3s;\r\n\r\n &:hover {\r\n color: ${token.colorTextSecondary};\r\n }\r\n\r\n &:active {\r\n color: ${token.colorText};\r\n }\r\n\r\n + i {\r\n margin-left: 6px;\r\n }\r\n\r\n svg {\r\n transition: transform 0.3s;\r\n }\r\n `,\r\n\r\n dropdownArrowIconOpen: css`\r\n svg {\r\n transform: rotate(180deg);\r\n }\r\n `\r\n };\r\n}, {label: \"dropdownArrow\"});\r\n\r\nexport interface DropdownArrowProps extends AntdIconProps {\r\n opened?: boolean\r\n}\r\n\r\nexport default class DropdownArrow extends React.PureComponent<DropdownArrowProps> {\r\n render() {\r\n const {opened, ...restProps} = this.props;\r\n\r\n return (\r\n <WithCss useStyles={useStyles}>{\r\n (css) =>\r\n <span className={css.styles.dropdownArrow}>\r\n <DownOutlined {...restProps}\r\n className={opened ? css.cx(css.styles.dropdownArrowIcon, css.styles.dropdownArrowIconOpen) : css.styles.dropdownArrowIcon}\r\n role=\"button\" tabIndex={-1}\r\n />\r\n </span>\r\n }</WithCss>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"dropdownArrow.js","sourceRoot":"","sources":["../../../../components/icons/dropdownArrow.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAA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\";\r\nimport {createStyles} from \"antd-style\";\r\nimport {DownOutlined} from \"@ant-design/icons\";\r\nimport WithCss from \"d2coreui/components/style/withCss\";\r\nimport {AntdIconProps} from \"@ant-design/icons/lib/components/AntdIcon\";\r\n\r\n// @ts-ignore\r\nconst useStyles = createStyles(({token, css, cx}) => {\r\n return {\r\n dropdownArrow: css`\r\n transform-origin: 50% 50%;\r\n margin-left: ${token.controlPaddingHorizontalSM}px;\r\n `,\r\n\r\n dropdownArrowIcon: css`\r\n color: ${token.colorTextDisabled};\r\n font-size: ${token.fontSizeSM}px;\r\n vertical-align: center;\r\n cursor: pointer;\r\n transition: color 0.3s;\r\n\r\n &:hover {\r\n color: ${token.colorTextSecondary};\r\n }\r\n\r\n &:active {\r\n color: ${token.colorText};\r\n }\r\n\r\n + i {\r\n margin-left: 6px;\r\n }\r\n\r\n svg {\r\n transition: transform 0.3s;\r\n }\r\n `,\r\n\r\n dropdownArrowIconOpen: css`\r\n svg {\r\n transform: rotate(180deg);\r\n }\r\n `\r\n };\r\n}, {label: \"dropdownArrow\"});\r\n\r\n/** Props of {@link DropdownArrow}; other props are passed to the antd `DownOutlined` icon (except `className`). */\r\nexport interface DropdownArrowProps extends AntdIconProps {\r\n /** Rotates the arrow by 180 degrees (pointing up), with a transition. */\r\n opened?: boolean\r\n}\r\n\r\n/** Small down-arrow icon styled like the antd select arrow, used as a dropdown open/close indicator. */\r\nexport default class DropdownArrow extends React.PureComponent<DropdownArrowProps> {\r\n render() {\r\n const {opened, ...restProps} = this.props;\r\n\r\n return (\r\n <WithCss useStyles={useStyles}>{\r\n (css) =>\r\n <span className={css.styles.dropdownArrow}>\r\n <DownOutlined {...restProps}\r\n className={opened ? css.cx(css.styles.dropdownArrowIcon, css.styles.dropdownArrowIconOpen) : css.styles.dropdownArrowIcon}\r\n role=\"button\" tabIndex={-1}\r\n />\r\n </span>\r\n }</WithCss>\r\n );\r\n }\r\n}\r\n"]}
@@ -1,7 +1,9 @@
1
1
  import React, { CSSProperties } from "react";
2
+ /** 14x14 "undo" (curved back arrow) icon in the current text color. */
2
3
  declare const UndoIcon: (props: {
3
4
  style?: CSSProperties;
4
5
  }) => React.JSX.Element;
6
+ /** {@link UndoIcon} sized 12x12 with a right margin, for menu items; `style` is merged over these defaults. */
5
7
  declare const UndoMenuIcon: (props: {
6
8
  style?: CSSProperties;
7
9
  }) => React.JSX.Element;
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
  import Icon from "@ant-design/icons/es/components/Icon";
3
+ /** 14x14 "undo" (curved back arrow) icon in the current text color. */
3
4
  const UndoIcon = (props) => (React.createElement(Icon, { component: () => React.createElement("svg", { preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 14 14", width: 14, height: 14, style: props.style },
4
5
  React.createElement("path", { d: "m 8.327691,3.3283097 c 2.800837,0 5.07135,2.3743226 5.07135,5.303197 0,2.9288733 -2.270513,5.3031963 -5.07135,5.3031963 H 4.946796 v -0.883866 h 3.380895 c 2.334032,0 4.226127,-1.978602 4.226127,-4.4193303 0,-2.4407292 -1.892095,-4.4193308 -4.226127,-4.4193308 H 2.338436 L 4.904535,6.8955935 4.306962,7.5204869 0.720677,3.7702428 4.306962,0.01999879 4.904535,0.64489216 2.338436,3.3283097 Z", style: { display: "inline", fill: "currentColor" } })) }));
6
+ /** {@link UndoIcon} sized 12x12 with a right margin, for menu items; `style` is merged over these defaults. */
5
7
  const UndoMenuIcon = (props) => (React.createElement(UndoIcon, { style: Object.assign({ marginRight: 6, width: 12, height: 12 }, props.style) }));
6
8
  export { UndoIcon, UndoMenuIcon };
7
9
  //# sourceMappingURL=undoIcon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"undoIcon.js","sourceRoot":"","sources":["../../../../components/icons/undoIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,IAAI,MAAM,sCAAsC,CAAC;AAExD,MAAM,QAAQ,GAAG,CAAC,KAAgC,EAAE,EAAE,CAAC,CACnD,oBAAC,IAAI,IAAC,SAAS,EAAE,GAAG,EAAE,CAAC,6BAAK,mBAAmB,EAAC,eAAe,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAC7E,KAAK,EAAE,KAAK,CAAC,KAAK;QAC1C,8BACI,CAAC,EAAC,yYAAyY,EAC3Y,KAAK,EAAE,EAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAC,GAAG,CACrD,GAAG,CAAC,CAAC;AAEf,MAAM,YAAY,GAAG,CAAC,KAAgC,EAAE,EAAE,CAAC,CACvD,oBAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAC,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAC1F,CAAA;AAED,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,CAAC","sourcesContent":["import React, {CSSProperties} from \"react\";\r\nimport Icon from \"@ant-design/icons/es/components/Icon\";\r\n\r\nconst UndoIcon = (props: { style?: CSSProperties }) => (\r\n <Icon component={() => <svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 14 14\" width={14} height={14}\r\n style={props.style}>\r\n <path\r\n d=\"m 8.327691,3.3283097 c 2.800837,0 5.07135,2.3743226 5.07135,5.303197 0,2.9288733 -2.270513,5.3031963 -5.07135,5.3031963 H 4.946796 v -0.883866 h 3.380895 c 2.334032,0 4.226127,-1.978602 4.226127,-4.4193303 0,-2.4407292 -1.892095,-4.4193308 -4.226127,-4.4193308 H 2.338436 L 4.904535,6.8955935 4.306962,7.5204869 0.720677,3.7702428 4.306962,0.01999879 4.904535,0.64489216 2.338436,3.3283097 Z\"\r\n style={{display: \"inline\", fill: \"currentColor\"}}/>\r\n </svg>}/>);\r\n\r\nconst UndoMenuIcon = (props: { style?: CSSProperties }) => (\r\n <UndoIcon style={Object.assign({marginRight: 6, width: 12, height: 12}, props.style)}/>\r\n)\r\n\r\nexport {UndoIcon, UndoMenuIcon};"]}
1
+ {"version":3,"file":"undoIcon.js","sourceRoot":"","sources":["../../../../components/icons/undoIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,IAAI,MAAM,sCAAsC,CAAC;AAExD,uEAAuE;AACvE,MAAM,QAAQ,GAAG,CAAC,KAAgC,EAAE,EAAE,CAAC,CACnD,oBAAC,IAAI,IAAC,SAAS,EAAE,GAAG,EAAE,CAAC,6BAAK,mBAAmB,EAAC,eAAe,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAC7E,KAAK,EAAE,KAAK,CAAC,KAAK;QAC1C,8BACI,CAAC,EAAC,yYAAyY,EAC3Y,KAAK,EAAE,EAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAC,GAAG,CACrD,GAAG,CAAC,CAAC;AAEf,+GAA+G;AAC/G,MAAM,YAAY,GAAG,CAAC,KAAgC,EAAE,EAAE,CAAC,CACvD,oBAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAC,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAC1F,CAAA;AAED,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,CAAC","sourcesContent":["import React, {CSSProperties} from \"react\";\r\nimport Icon from \"@ant-design/icons/es/components/Icon\";\r\n\r\n/** 14x14 \"undo\" (curved back arrow) icon in the current text color. */\r\nconst UndoIcon = (props: { style?: CSSProperties }) => (\r\n <Icon component={() => <svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 14 14\" width={14} height={14}\r\n style={props.style}>\r\n <path\r\n d=\"m 8.327691,3.3283097 c 2.800837,0 5.07135,2.3743226 5.07135,5.303197 0,2.9288733 -2.270513,5.3031963 -5.07135,5.3031963 H 4.946796 v -0.883866 h 3.380895 c 2.334032,0 4.226127,-1.978602 4.226127,-4.4193303 0,-2.4407292 -1.892095,-4.4193308 -4.226127,-4.4193308 H 2.338436 L 4.904535,6.8955935 4.306962,7.5204869 0.720677,3.7702428 4.306962,0.01999879 4.904535,0.64489216 2.338436,3.3283097 Z\"\r\n style={{display: \"inline\", fill: \"currentColor\"}}/>\r\n </svg>}/>);\r\n\r\n/** {@link UndoIcon} sized 12x12 with a right margin, for menu items; `style` is merged over these defaults. */\r\nconst UndoMenuIcon = (props: { style?: CSSProperties }) => (\r\n <UndoIcon style={Object.assign({marginRight: 6, width: 12, height: 12}, props.style)}/>\r\n)\r\n\r\nexport {UndoIcon, UndoMenuIcon};"]}
@@ -1,21 +1,49 @@
1
1
  import React from "react";
2
2
  import { InputProps } from "antd/es";
3
3
  interface InputSearchWithHistoryProps extends Omit<InputProps, "onChange" | "onSearch" | "onSelect" | "placeholder" | "options"> {
4
+ /** Current text. The component keeps its own copy, which is replaced whenever this prop changes. */
4
5
  value?: string;
6
+ /** History entries offered in the dropdown (falsy entries are skipped). The dropdown arrow is shown only when non-empty. */
5
7
  options?: string[];
8
+ /** Placeholder of the text input. */
6
9
  placeholder?: string;
10
+ /** Content rendered at the start of the text input. */
7
11
  prefix?: React.ReactNode;
12
+ /**
13
+ * Called with the new text on every edit, on clear and when a history entry is picked.
14
+ * @default no-op
15
+ */
8
16
  onChange(searchString: string): void;
17
+ /**
18
+ * Called on Enter (whether or not the dropdown is open) and after a history entry is picked.
19
+ * @default no-op
20
+ */
9
21
  onSearch(): void;
22
+ /** Called after a history entry is picked, right after `onSearch`. */
10
23
  onSelect?: () => void;
24
+ /** Called on Enter while the dropdown is closed, before `onSearch`. */
11
25
  onPressEnter?(): void;
26
+ /**
27
+ * Makes the input read-only. Combined with `disabled`, the input is rendered read-only instead of disabled,
28
+ * so the clear button and the history dropdown stay usable.
29
+ */
12
30
  inputReadonly?: boolean;
31
+ /**
32
+ * Maps a string to its displayed form; applied to the input value and to the option labels.
33
+ * Picking an option passes the unformatted option to `onChange`, typing passes the edited displayed text.
34
+ */
13
35
  stringFormatter?(rawString: string): string;
14
36
  }
15
37
  interface InputSearchWithHistoryState {
16
38
  opened: boolean;
17
39
  searchString: string;
18
40
  }
41
+ /**
42
+ * Text input with a history dropdown. When `options` is non-empty, a down-arrow suffix (or the ArrowDown key)
43
+ * opens a menu of the entries; picking one sets the text and fires `onChange`, `onSearch` and `onSelect`.
44
+ * Escape closes the menu. The `style` prop is applied to the wrapping element (default width 200 px);
45
+ * `onBlur`, `onFocus` and `onKeyDown` are not forwarded to the input.
46
+ */
19
47
  export default class AutoCompleteInput extends React.Component<InputSearchWithHistoryProps, InputSearchWithHistoryState> {
20
48
  static get defaultProps(): {
21
49
  onSearch: () => void;
@@ -25,6 +53,7 @@ export default class AutoCompleteInput extends React.Component<InputSearchWithHi
25
53
  private menuRef;
26
54
  constructor(props: Readonly<InputSearchWithHistoryProps>);
27
55
  componentDidUpdate(prevProps: Readonly<InputSearchWithHistoryProps>): void;
56
+ /** Moves the keyboard focus to the text input. */
28
57
  focus(): void;
29
58
  private triggerChange;
30
59
  private toggleDropdown;
@@ -13,6 +13,12 @@ import React from "react";
13
13
  import { Dropdown, Input, Menu } from "antd";
14
14
  import { DownOutlined } from "@ant-design/icons";
15
15
  import { Key } from "ts-key-enum";
16
+ /**
17
+ * Text input with a history dropdown. When `options` is non-empty, a down-arrow suffix (or the ArrowDown key)
18
+ * opens a menu of the entries; picking one sets the text and fires `onChange`, `onSearch` and `onSelect`.
19
+ * Escape closes the menu. The `style` prop is applied to the wrapping element (default width 200 px);
20
+ * `onBlur`, `onFocus` and `onKeyDown` are not forwarded to the input.
21
+ */
16
22
  export default class AutoCompleteInput extends React.Component {
17
23
  static get defaultProps() {
18
24
  return {
@@ -56,6 +62,7 @@ export default class AutoCompleteInput extends React.Component {
56
62
  this.setState({ searchString: this.props.value || "" });
57
63
  }
58
64
  }
65
+ /** Moves the keyboard focus to the text input. */
59
66
  focus() {
60
67
  var _a;
61
68
  (_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
@@ -1 +1 @@
1
- {"version":3,"file":"autoCompleteInput.js","sourceRoot":"","sources":["../../../../components/input/autoCompleteInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAY,IAAI,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AA6BhC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAmE;IACpH,MAAM,KAAK,YAAY;QACnB,OAAO;YACH,QAAQ,EAAE,GAAG,EAAE;YACf,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE;YACf,CAAC;SACJ,CAAC;IACN,CAAC;IAKD,YAAY,KAA4C;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QAJT,aAAQ,GAAG,KAAK,CAAC,SAAS,EAAY,CAAC;QACvC,YAAO,GAAG,KAAK,CAAC,SAAS,EAAO,CAAC;QAoBjC,kBAAa,GAAG,CAAC,KAAa,EAAE,EAAE;YACtC,IAAI,CAAC,QAAQ,CAAC,EAAC,YAAY,EAAE,KAAK,EAAC,EAAE,GAAG,EAAE;gBACtC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QAEM,mBAAc,GAAG,CAAC,CAAoB,EAAE,EAAE;YAC9C,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,EAAE,CAAC;YACpB,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,eAAe,EAAE,CAAC;YAErB,IAA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M,EAAE,KAAK,EAAC,CAAC,CAAC;4BAC/B,IAAI,QAAQ;gCAAE,QAAQ,EAAE,CAAC;wBAC7B,CAAC;6BAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC;4BACnD,IAAI,YAAY;gCAAE,YAAY,EAAE,CAAC;4BACjC,IAAI,QAAQ;gCAAE,QAAQ,EAAE,CAAC;wBAC7B,CAAC;oBACL,CAAC,EACG,MAAM,EACF,UAAU,CAAC,CAAC,CAAC,CACT,oBAAC,YAAY,IACT,KAAK,EAAE;4BACH,MAAM,EAAE,CAAC,QAAQ,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;4BAChE,KAAK,EAAE,qBAAqB;4BAC5B,OAAO,EAAE,KAAK;yBACjB,EACD,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EACtC,OAAO,EAAE,IAAI,CAAC,cAAc,GAC9B,CACL,CAAC,CAAC,CAAC,IAAI,IAEd,CACK,CACT,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Dropdown, Input, InputRef, Menu} from \"antd\";\r\nimport {DownOutlined} from \"@ant-design/icons\";\r\nimport {InputProps} from \"antd/es\";\r\nimport {Key} from \"ts-key-enum\";\r\n\r\ninterface InputSearchWithHistoryProps extends Omit<InputProps, \"onChange\" | \"onSearch\" | \"onSelect\" | \"placeholder\" | \"options\"> {\r\n value?: string\r\n\r\n options?: string[]\r\n\r\n placeholder?: string\r\n\r\n prefix?: React.ReactNode\r\n\r\n onChange(searchString: string): void\r\n\r\n onSearch(): void\r\n\r\n onSelect?: () => void\r\n\r\n onPressEnter?(): void\r\n\r\n inputReadonly?: boolean\r\n\r\n stringFormatter?(rawString: string): string\r\n}\r\n\r\ninterface InputSearchWithHistoryState {\r\n opened: boolean\r\n searchString: string\r\n}\r\n\r\nexport default class AutoCompleteInput extends React.Component<InputSearchWithHistoryProps, InputSearchWithHistoryState> {\r\n static get defaultProps() {\r\n return {\r\n onSearch: () => {\r\n },\r\n onChange: () => {\r\n }\r\n };\r\n }\r\n\r\n private inputRef = React.createRef<InputRef>();\r\n private menuRef = React.createRef<any>();\r\n\r\n constructor(props: Readonly<InputSearchWithHistoryProps>) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n searchString: props.value || \"\",\r\n };\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<InputSearchWithHistoryProps>) {\r\n if (this.props.value !== prevProps.value && this.props.value !== this.state.searchString) {\r\n this.setState({searchString: this.props.value || \"\"});\r\n }\r\n }\r\n\r\n public focus() {\r\n this.inputRef.current?.focus();\r\n }\r\n\r\n private triggerChange = (value: string) => {\r\n this.setState({searchString: value}, () => {\r\n this.props.onChange(value);\r\n });\r\n };\r\n\r\n private toggleDropdown = (e?: React.MouseEvent) => {\r\n e?.preventDefault();\r\n e?.stopPropagation();\r\n\r\n if (this.props.disabled && !this.props.inputReadonly) return;\r\n\r\n const willOpen = !this.state.opened;\r\n\r\n this.setState({opened: willOpen}, () => {\r\n if (willOpen) {\r\n setTimeout(() => {\r\n this.menuRef.current?.focus();\r\n }, 50);\r\n }\r\n });\r\n };\r\n\r\n render() {\r\n const {\r\n disabled,\r\n inputReadonly,\r\n placeholder,\r\n prefix,\r\n onPressEnter,\r\n onSearch,\r\n onSelect,\r\n options,\r\n stringFormatter,\r\n style,\r\n value,\r\n onBlur,\r\n onKeyDown,\r\n onFocus,\r\n\r\n ...rest\r\n } = this.props;\r\n\r\n const hasHistory = options && options.length > 0;\r\n\r\n const historyMenu = (\r\n <Menu\r\n ref={this.menuRef}\r\n onClick={({key}) => {\r\n this.triggerChange(key);\r\n this.setState({opened: false});\r\n onSearch?.();\r\n onSelect?.();\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.Escape) {\r\n this.setState({opened: false});\r\n this.focus();\r\n }\r\n }}\r\n items={options?.filter(Boolean).map((opt) => ({\r\n key: opt,\r\n label: stringFormatter ? stringFormatter(opt) : opt,\r\n }))}\r\n />\r\n );\r\n\r\n return (\r\n <div style={{width: 200, display: \"inline-block\", ...style}}>\r\n <Dropdown\r\n popupRender={() => historyMenu}\r\n open={this.state.opened && hasHistory}\r\n onOpenChange={(open) => {\r\n this.setState({opened: open});\r\n }}\r\n trigger={[]}\r\n >\r\n <Input\r\n {...rest}\r\n ref={this.inputRef}\r\n placeholder={placeholder}\r\n prefix={prefix}\r\n value={stringFormatter ? stringFormatter(this.state.searchString) : this.state.searchString}\r\n disabled={disabled && !inputReadonly}\r\n readOnly={inputReadonly}\r\n allowClear={!disabled || inputReadonly}\r\n onChange={(e) => {\r\n this.triggerChange(e.target.value);\r\n }}\r\n onKeyDown={(e) => {\r\n if (!this.state.opened && e.key === Key.ArrowDown) {\r\n e.preventDefault();\r\n this.toggleDropdown();\r\n } else if (e.key === Key.Escape) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n } else if (this.state.opened && e.key === Key.Enter) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n if (onSearch) onSearch();\r\n } else if (!this.state.opened && e.key === Key.Enter) {\r\n if (onPressEnter) onPressEnter();\r\n if (onSearch) onSearch();\r\n }\r\n }}\r\n suffix={\r\n hasHistory ? (\r\n <DownOutlined\r\n style={{\r\n cursor: (disabled && !inputReadonly) ? \"not-allowed\" : \"pointer\",\r\n color: \"rgba(0, 0, 0, 0.25)\",\r\n padding: \"4px\"\r\n }}\r\n onMouseDown={(e) => e.preventDefault()}\r\n onClick={this.toggleDropdown}\r\n />\r\n ) : null\r\n }\r\n />\r\n </Dropdown>\r\n </div>\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"autoCompleteInput.js","sourceRoot":"","sources":["../../../../components/input/autoCompleteInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA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I,QAAQ;gCAAE,QAAQ,EAAE,CAAC;wBAC7B,CAAC;oBACL,CAAC,EACG,MAAM,EACF,UAAU,CAAC,CAAC,CAAC,CACT,oBAAC,YAAY,IACT,KAAK,EAAE;4BACH,MAAM,EAAE,CAAC,QAAQ,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;4BAChE,KAAK,EAAE,qBAAqB;4BAC5B,OAAO,EAAE,KAAK;yBACjB,EACD,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EACtC,OAAO,EAAE,IAAI,CAAC,cAAc,GAC9B,CACL,CAAC,CAAC,CAAC,IAAI,IAEd,CACK,CACT,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Dropdown, Input, InputRef, Menu} from \"antd\";\r\nimport {DownOutlined} from \"@ant-design/icons\";\r\nimport {InputProps} from \"antd/es\";\r\nimport {Key} from \"ts-key-enum\";\r\n\r\ninterface InputSearchWithHistoryProps extends Omit<InputProps, \"onChange\" | \"onSearch\" | \"onSelect\" | \"placeholder\" | \"options\"> {\r\n /** Current text. The component keeps its own copy, which is replaced whenever this prop changes. */\r\n value?: string\r\n\r\n /** History entries offered in the dropdown (falsy entries are skipped). The dropdown arrow is shown only when non-empty. */\r\n options?: string[]\r\n\r\n /** Placeholder of the text input. */\r\n placeholder?: string\r\n\r\n /** Content rendered at the start of the text input. */\r\n prefix?: React.ReactNode\r\n\r\n /**\r\n * Called with the new text on every edit, on clear and when a history entry is picked.\r\n * @default no-op\r\n */\r\n onChange(searchString: string): void\r\n\r\n /**\r\n * Called on Enter (whether or not the dropdown is open) and after a history entry is picked.\r\n * @default no-op\r\n */\r\n onSearch(): void\r\n\r\n /** Called after a history entry is picked, right after `onSearch`. */\r\n onSelect?: () => void\r\n\r\n /** Called on Enter while the dropdown is closed, before `onSearch`. */\r\n onPressEnter?(): void\r\n\r\n /**\r\n * Makes the input read-only. Combined with `disabled`, the input is rendered read-only instead of disabled,\r\n * so the clear button and the history dropdown stay usable.\r\n */\r\n inputReadonly?: boolean\r\n\r\n /**\r\n * Maps a string to its displayed form; applied to the input value and to the option labels.\r\n * Picking an option passes the unformatted option to `onChange`, typing passes the edited displayed text.\r\n */\r\n stringFormatter?(rawString: string): string\r\n}\r\n\r\ninterface InputSearchWithHistoryState {\r\n opened: boolean\r\n searchString: string\r\n}\r\n\r\n/**\r\n * Text input with a history dropdown. When `options` is non-empty, a down-arrow suffix (or the ArrowDown key)\r\n * opens a menu of the entries; picking one sets the text and fires `onChange`, `onSearch` and `onSelect`.\r\n * Escape closes the menu. The `style` prop is applied to the wrapping element (default width 200 px);\r\n * `onBlur`, `onFocus` and `onKeyDown` are not forwarded to the input.\r\n */\r\nexport default class AutoCompleteInput extends React.Component<InputSearchWithHistoryProps, InputSearchWithHistoryState> {\r\n static get defaultProps() {\r\n return {\r\n onSearch: () => {\r\n },\r\n onChange: () => {\r\n }\r\n };\r\n }\r\n\r\n private inputRef = React.createRef<InputRef>();\r\n private menuRef = React.createRef<any>();\r\n\r\n constructor(props: Readonly<InputSearchWithHistoryProps>) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n searchString: props.value || \"\",\r\n };\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<InputSearchWithHistoryProps>) {\r\n if (this.props.value !== prevProps.value && this.props.value !== this.state.searchString) {\r\n this.setState({searchString: this.props.value || \"\"});\r\n }\r\n }\r\n\r\n /** Moves the keyboard focus to the text input. */\r\n public focus() {\r\n this.inputRef.current?.focus();\r\n }\r\n\r\n private triggerChange = (value: string) => {\r\n this.setState({searchString: value}, () => {\r\n this.props.onChange(value);\r\n });\r\n };\r\n\r\n private toggleDropdown = (e?: React.MouseEvent) => {\r\n e?.preventDefault();\r\n e?.stopPropagation();\r\n\r\n if (this.props.disabled && !this.props.inputReadonly) return;\r\n\r\n const willOpen = !this.state.opened;\r\n\r\n this.setState({opened: willOpen}, () => {\r\n if (willOpen) {\r\n setTimeout(() => {\r\n this.menuRef.current?.focus();\r\n }, 50);\r\n }\r\n });\r\n };\r\n\r\n render() {\r\n const {\r\n disabled,\r\n inputReadonly,\r\n placeholder,\r\n prefix,\r\n onPressEnter,\r\n onSearch,\r\n onSelect,\r\n options,\r\n stringFormatter,\r\n style,\r\n value,\r\n onBlur,\r\n onKeyDown,\r\n onFocus,\r\n\r\n ...rest\r\n } = this.props;\r\n\r\n const hasHistory = options && options.length > 0;\r\n\r\n const historyMenu = (\r\n <Menu\r\n ref={this.menuRef}\r\n onClick={({key}) => {\r\n this.triggerChange(key);\r\n this.setState({opened: false});\r\n onSearch?.();\r\n onSelect?.();\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.Escape) {\r\n this.setState({opened: false});\r\n this.focus();\r\n }\r\n }}\r\n items={options?.filter(Boolean).map((opt) => ({\r\n key: opt,\r\n label: stringFormatter ? stringFormatter(opt) : opt,\r\n }))}\r\n />\r\n );\r\n\r\n return (\r\n <div style={{width: 200, display: \"inline-block\", ...style}}>\r\n <Dropdown\r\n popupRender={() => historyMenu}\r\n open={this.state.opened && hasHistory}\r\n onOpenChange={(open) => {\r\n this.setState({opened: open});\r\n }}\r\n trigger={[]}\r\n >\r\n <Input\r\n {...rest}\r\n ref={this.inputRef}\r\n placeholder={placeholder}\r\n prefix={prefix}\r\n value={stringFormatter ? stringFormatter(this.state.searchString) : this.state.searchString}\r\n disabled={disabled && !inputReadonly}\r\n readOnly={inputReadonly}\r\n allowClear={!disabled || inputReadonly}\r\n onChange={(e) => {\r\n this.triggerChange(e.target.value);\r\n }}\r\n onKeyDown={(e) => {\r\n if (!this.state.opened && e.key === Key.ArrowDown) {\r\n e.preventDefault();\r\n this.toggleDropdown();\r\n } else if (e.key === Key.Escape) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n } else if (this.state.opened && e.key === Key.Enter) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n if (onSearch) onSearch();\r\n } else if (!this.state.opened && e.key === Key.Enter) {\r\n if (onPressEnter) onPressEnter();\r\n if (onSearch) onSearch();\r\n }\r\n }}\r\n suffix={\r\n hasHistory ? (\r\n <DownOutlined\r\n style={{\r\n cursor: (disabled && !inputReadonly) ? \"not-allowed\" : \"pointer\",\r\n color: \"rgba(0, 0, 0, 0.25)\",\r\n padding: \"4px\"\r\n }}\r\n onMouseDown={(e) => e.preventDefault()}\r\n onClick={this.toggleDropdown}\r\n />\r\n ) : null\r\n }\r\n />\r\n </Dropdown>\r\n </div>\r\n );\r\n }\r\n}"]}
@@ -1,4 +1,11 @@
1
1
  import { RawDraftContentState } from "draft-js";
2
+ /** Helpers for content produced by the Draft.js / Draftail rich-text editor. */
2
3
  export default class DraftUtils {
4
+ /**
5
+ * Converts raw Draft.js content to an HTML string. The `MARK` inline style becomes
6
+ * `<span class="marked-message-content">`, blockquotes become `<blockquote>`, `LINK`, `IMAGE` and
7
+ * `HORIZONTAL_RULE` entities become `<a>`, `<img>` and `<hr>`, and atomic blocks produce no wrapper markup.
8
+ * @returns the HTML, or an empty string when `raw` is not provided.
9
+ */
3
10
  static toHTML(raw: RawDraftContentState): string;
4
11
  }
@@ -8,12 +8,14 @@ const exporterConfig = {
8
8
  return React.createElement("span", { className: "marked-message-content" });
9
9
  }
10
10
  style;
11
+ // @ts-ignore
11
12
  return;
12
13
  },
13
14
  blockToHTML: (block) => {
14
15
  if (block.type === BLOCK_TYPE.BLOCKQUOTE) {
15
16
  return React.createElement("blockquote", null);
16
17
  }
18
+ // Discard atomic blocks, as they get converted based on their entity.
17
19
  if (block.type === BLOCK_TYPE.ATOMIC) {
18
20
  return {
19
21
  start: "",
@@ -36,7 +38,14 @@ const exporterConfig = {
36
38
  },
37
39
  };
38
40
  const conversionFunction = convertToHTML(exporterConfig);
41
+ /** Helpers for content produced by the Draft.js / Draftail rich-text editor. */
39
42
  export default class DraftUtils {
43
+ /**
44
+ * Converts raw Draft.js content to an HTML string. The `MARK` inline style becomes
45
+ * `<span class="marked-message-content">`, blockquotes become `<blockquote>`, `LINK`, `IMAGE` and
46
+ * `HORIZONTAL_RULE` entities become `<a>`, `<img>` and `<hr>`, and atomic blocks produce no wrapper markup.
47
+ * @returns the HTML, or an empty string when `raw` is not provided.
48
+ */
40
49
  static toHTML(raw) {
41
50
  if (raw) {
42
51
  return conversionFunction(convertFromRaw(raw));
@@ -1 +1 @@
1
- {"version":3,"file":"draftUtils.js","sourceRoot":"","sources":["../../../../components/input/draftUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAA6C,MAAM,UAAU,CAAA;AACnF,OAAO,EAAC,aAAa,EAAuB,MAAM,eAAe,CAAA;AACjE,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,cAAc,GAAyB;IACzC,WAAW,EAAE,CAAC,KAA2B,EAAE,EAAE;QACzC,IAAK,KAAgB,KAAI,MAAM,EAAE,CAAC;YAC9B,OAAO,8BAAM,SAAS,EAAE,wBAAwB,GAAI,CAAC;QACzD,CAAC;QACD,KAAK,CAAC;QAEN,OAAO;IACX,CAAC;IAED,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;QACnB,IAAK,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC,UAAU,EAAE,CAAC;YAChD,OAAO,uCAAa,CAAA;QACxB,CAAC;QAGD,IAAK,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,OAAO;gBACH,KAAK,EAAE,EAAE;gBACT,GAAG,EAAE,EAAE;aACV,CAAA;QACL,CAAC;QAED,OAAO,IAAI,CAAA;IACf,CAAC;IAED,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;QACnC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,2BAAG,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAG,YAAY,CAAK,CAAA;QACvD,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,KAAK,EAAE,CAAC;YACpC,OAAO,6BAAK,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;QAC7D,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,eAAe,EAAE,CAAC;YAC9C,OAAO,+BAAK,CAAA;QAChB,CAAC;QAED,OAAO,YAAY,CAAA;IACvB,CAAC;CACJ,CAAA;AAGD,MAAM,kBAAkB,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,UAAU;IAE3B,MAAM,CAAC,MAAM,CAAC,GAAyB;QACnC,IAAI,GAAG,EAAE,CAAC;YACN,OAAO,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACJ,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CAEJ","sourcesContent":["import {convertFromRaw, DraftInlineStyleType, RawDraftContentState} from \"draft-js\"\r\nimport {convertToHTML, IConvertToHTMLConfig} from \"draft-convert\"\r\nimport {BLOCK_TYPE, ENTITY_TYPE} from \"./draftail\"\r\nimport React from \"react\";\r\n\r\nconst exporterConfig: IConvertToHTMLConfig = {\r\n styleToHTML: (style: DraftInlineStyleType) => {\r\n if ((style as string)=== 'MARK') {\r\n return <span className={\"marked-message-content\"} />;\r\n }\r\n style;\r\n // @ts-ignore\r\n return;\r\n },\r\n\r\n blockToHTML: (block) => {\r\n if ((block as any).type === BLOCK_TYPE.BLOCKQUOTE) {\r\n return <blockquote/>\r\n }\r\n\r\n // Discard atomic blocks, as they get converted based on their entity.\r\n if ((block as any).type === BLOCK_TYPE.ATOMIC) {\r\n return {\r\n start: \"\",\r\n end: \"\",\r\n }\r\n }\r\n\r\n return null\r\n },\r\n\r\n entityToHTML: (entity, originalText) => {\r\n if (entity.type === ENTITY_TYPE.LINK) {\r\n return <a href={entity.data.url}>{originalText}</a>\r\n }\r\n\r\n if (entity.type === ENTITY_TYPE.IMAGE) {\r\n return <img src={entity.data.src} alt={entity.data.alt}/>\r\n }\r\n\r\n if (entity.type === ENTITY_TYPE.HORIZONTAL_RULE) {\r\n return <hr/>\r\n }\r\n\r\n return originalText\r\n },\r\n}\r\n\r\n\r\nconst conversionFunction = convertToHTML(exporterConfig);\r\n\r\nexport default class DraftUtils {\r\n\r\n static toHTML(raw: RawDraftContentState): string {\r\n if (raw) {\r\n return conversionFunction(convertFromRaw(raw));\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n}"]}
1
+ {"version":3,"file":"draftUtils.js","sourceRoot":"","sources":["../../../../components/input/draftUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAA6C,MAAM,UAAU,CAAA;AACnF,OAAO,EAAC,aAAa,EAAuB,MAAM,eAAe,CAAA;AACjE,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,cAAc,GAAyB;IACzC,WAAW,EAAE,CAAC,KAA2B,EAAE,EAAE;QACzC,IAAK,KAAgB,KAAI,MAAM,EAAE,CAAC;YAC9B,OAAO,8BAAM,SAAS,EAAE,wBAAwB,GAAI,CAAC;QACzD,CAAC;QACD,KAAK,CAAC;QACN,aAAa;QACb,OAAO;IACX,CAAC;IAED,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;QACnB,IAAK,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC,UAAU,EAAE,CAAC;YAChD,OAAO,uCAAa,CAAA;QACxB,CAAC;QAED,sEAAsE;QACtE,IAAK,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,OAAO;gBACH,KAAK,EAAE,EAAE;gBACT,GAAG,EAAE,EAAE;aACV,CAAA;QACL,CAAC;QAED,OAAO,IAAI,CAAA;IACf,CAAC;IAED,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;QACnC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,2BAAG,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAG,YAAY,CAAK,CAAA;QACvD,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,KAAK,EAAE,CAAC;YACpC,OAAO,6BAAK,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;QAC7D,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,eAAe,EAAE,CAAC;YAC9C,OAAO,+BAAK,CAAA;QAChB,CAAC;QAED,OAAO,YAAY,CAAA;IACvB,CAAC;CACJ,CAAA;AAGD,MAAM,kBAAkB,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAEzD,gFAAgF;AAChF,MAAM,CAAC,OAAO,OAAO,UAAU;IAE3B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,GAAyB;QACnC,IAAI,GAAG,EAAE,CAAC;YACN,OAAO,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACJ,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CAEJ","sourcesContent":["import {convertFromRaw, DraftInlineStyleType, RawDraftContentState} from \"draft-js\"\r\nimport {convertToHTML, IConvertToHTMLConfig} from \"draft-convert\"\r\nimport {BLOCK_TYPE, ENTITY_TYPE} from \"./draftail\"\r\nimport React from \"react\";\r\n\r\nconst exporterConfig: IConvertToHTMLConfig = {\r\n styleToHTML: (style: DraftInlineStyleType) => {\r\n if ((style as string)=== 'MARK') {\r\n return <span className={\"marked-message-content\"} />;\r\n }\r\n style;\r\n // @ts-ignore\r\n return;\r\n },\r\n\r\n blockToHTML: (block) => {\r\n if ((block as any).type === BLOCK_TYPE.BLOCKQUOTE) {\r\n return <blockquote/>\r\n }\r\n\r\n // Discard atomic blocks, as they get converted based on their entity.\r\n if ((block as any).type === BLOCK_TYPE.ATOMIC) {\r\n return {\r\n start: \"\",\r\n end: \"\",\r\n }\r\n }\r\n\r\n return null\r\n },\r\n\r\n entityToHTML: (entity, originalText) => {\r\n if (entity.type === ENTITY_TYPE.LINK) {\r\n return <a href={entity.data.url}>{originalText}</a>\r\n }\r\n\r\n if (entity.type === ENTITY_TYPE.IMAGE) {\r\n return <img src={entity.data.src} alt={entity.data.alt}/>\r\n }\r\n\r\n if (entity.type === ENTITY_TYPE.HORIZONTAL_RULE) {\r\n return <hr/>\r\n }\r\n\r\n return originalText\r\n },\r\n}\r\n\r\n\r\nconst conversionFunction = convertToHTML(exporterConfig);\r\n\r\n/** Helpers for content produced by the Draft.js / Draftail rich-text editor. */\r\nexport default class DraftUtils {\r\n\r\n /**\r\n * Converts raw Draft.js content to an HTML string. The `MARK` inline style becomes\r\n * `<span class=\"marked-message-content\">`, blockquotes become `<blockquote>`, `LINK`, `IMAGE` and\r\n * `HORIZONTAL_RULE` entities become `<a>`, `<img>` and `<hr>`, and atomic blocks produce no wrapper markup.\r\n * @returns the HTML, or an empty string when `raw` is not provided.\r\n */\r\n static toHTML(raw: RawDraftContentState): string {\r\n if (raw) {\r\n return conversionFunction(convertFromRaw(raw));\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n}"]}
@@ -1,14 +1,23 @@
1
1
  import React from "react";
2
2
  import { InputProps } from "antd/es";
3
3
  interface HexaFormattedInputProps extends Omit<InputProps, "value" | "onChange"> {
4
+ /** Current hexadecimal string (controlled); displayed upper-cased. */
4
5
  value: string;
6
+ /** Maximum number of digits; on blur the value is left-padded with zeros to this length. */
5
7
  maxLength: number;
8
+ /**
9
+ * Called with the typed text on every edit that leaves only hex digits (or an empty string); other edits are
10
+ * rejected. On blur it is called again with the zero-padded upper-cased value, or `undefined` when empty.
11
+ */
6
12
  onChange(value: string | undefined): void;
7
13
  }
14
+ /** Controlled antd `Input` that accepts only hexadecimal digits and normalizes the value on blur. */
8
15
  export default class HexaFormattedInput extends React.Component<HexaFormattedInputProps, any> {
9
16
  private inputRef;
10
17
  constructor(props: Readonly<HexaFormattedInputProps>);
18
+ /** The underlying DOM input element, or `undefined` before mount. */
11
19
  get input(): HTMLInputElement | null | undefined;
20
+ /** Moves the keyboard focus to the input. */
12
21
  focus(): void;
13
22
  private getFormattedValue;
14
23
  render(): React.JSX.Element;
@@ -11,15 +11,18 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React from "react";
13
13
  import { Input } from "antd";
14
+ /** Controlled antd `Input` that accepts only hexadecimal digits and normalizes the value on blur. */
14
15
  export default class HexaFormattedInput extends React.Component {
15
16
  constructor(props) {
16
17
  super(props);
17
18
  this.inputRef = null;
18
19
  }
20
+ /** The underlying DOM input element, or `undefined` before mount. */
19
21
  get input() {
20
22
  var _a;
21
23
  return (_a = this.inputRef) === null || _a === void 0 ? void 0 : _a.input;
22
24
  }
25
+ /** Moves the keyboard focus to the input. */
23
26
  focus() {
24
27
  var _a;
25
28
  (_a = this.inputRef) === null || _a === void 0 ? void 0 : _a.focus();
@@ -1 +1 @@
1
- {"version":3,"file":"hexaFormattedInput.js","sourceRoot":"","sources":["../../../../components/input/hexaFormattedInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAW,MAAM,MAAM,CAAC;AAUrC,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAAuC;IAGzF,YAAY,KAAwC;QAChD,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,aAAQ,GAAoB,IAAI,CAAC;IAIz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oBACT,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACJ,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBACrD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;gBACxC,CAAC;YACL,CAAC,EACD,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,IACjC,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Input, InputRef} from \"antd\";\r\nimport {InputProps} from \"antd/es\";\r\n\r\ninterface HexaFormattedInputProps extends Omit<InputProps, \"value\" | \"onChange\"> {\r\n value: string\r\n maxLength: number\r\n\r\n onChange(value: string | undefined): void\r\n}\r\n\r\nexport default class HexaFormattedInput extends React.Component<HexaFormattedInputProps, any> {\r\n private inputRef: InputRef | null = null;\r\n\r\n constructor(props: Readonly<HexaFormattedInputProps>) {\r\n super(props);\r\n }\r\n\r\n get input() {\r\n return this.inputRef?.input;\r\n }\r\n\r\n focus() {\r\n this.inputRef?.focus();\r\n }\r\n\r\n private getFormattedValue(value: string): string {\r\n let valueToFormat = value;\r\n for (let i = 0; i < this.props.maxLength - value.length; i++) {\r\n valueToFormat = \"0\" + valueToFormat;\r\n }\r\n return valueToFormat.toUpperCase();\r\n }\r\n\r\n render() {\r\n const {value, maxLength, onChange, ...rest} = this.props;\r\n\r\n return (\r\n <Input\r\n {...rest}\r\n ref={component => {\r\n this.inputRef = component;\r\n }}\r\n value={this.props.value.toUpperCase()}\r\n onChange={event => {\r\n const value = event.target.value;\r\n if (/^[0-9A-Fa-f]+$/.test(value) || value === \"\") {\r\n this.props.onChange(value);\r\n }\r\n }}\r\n onBlur={event => {\r\n let value = event.target.value;\r\n if (!value) {\r\n this.props.onChange(undefined);\r\n } else {\r\n const formattedValue = this.getFormattedValue(value);\r\n this.props.onChange(formattedValue);\r\n }\r\n }}\r\n maxLength={this.props.maxLength}\r\n />\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"hexaFormattedInput.js","sourceRoot":"","sources":["../../../../components/input/hexaFormattedInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAW,MAAM,MAAM,CAAC;AAgBrC,qGAAqG;AACrG,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAAuC;IAGzF,YAAY,KAAwC;QAChD,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,aAAQ,GAAoB,IAAI,CAAC;IAIzC,CAAC;IAED,qEAAqE;IACrE,IAAI,KAAK;;QACL,OAAO,MAAA,IAAI,CAAC,QAAQ,0CAAE,KAAK,CAAC;IAChC,CAAC;IAED,6CAA6C;IAC7C,KAAK;;QACD,MAAA,IAAI,CAAC,QAAQ,0CAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEO,iBAAiB,CAAC,KAAa;QACnC,IAAI,aAAa,GAAG,KAAK,CAAC;QAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3D,aAAa,GAAG,GAAG,GAAG,aAAa,CAAC;QACxC,CAAC;QACD,OAAO,aAAa,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAED,MAAM;QACF,MAAM,KAAwC,IAAI,CAAC,KAAK,EAAlD,EAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,OAAuB,EAAlB,IAAI,cAApC,kCAAqC,CAAa,CAAC;QAEzD,OAAO,CACH,oBAAC,KAAK,oBACE,IAAI,IACR,GAAG,EAAE,SAAS,CAAC,EAAE;gBACb,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;YAC9B,CAAC,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,EACrC,QAAQ,EAAE,KAAK,CAAC,EAAE;gBACd,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;gBACjC,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;oBAC/C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC;YACL,CAAC,EACD,MAAM,EAAE,KAAK,CAAC,EAAE;gBACZ,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;oBACT,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACJ,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBACrD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;gBACxC,CAAC;YACL,CAAC,EACD,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,IACjC,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Input, InputRef} from \"antd\";\r\nimport {InputProps} from \"antd/es\";\r\n\r\ninterface HexaFormattedInputProps extends Omit<InputProps, \"value\" | \"onChange\"> {\r\n /** Current hexadecimal string (controlled); displayed upper-cased. */\r\n value: string\r\n /** Maximum number of digits; on blur the value is left-padded with zeros to this length. */\r\n maxLength: number\r\n\r\n /**\r\n * Called with the typed text on every edit that leaves only hex digits (or an empty string); other edits are\r\n * rejected. On blur it is called again with the zero-padded upper-cased value, or `undefined` when empty.\r\n */\r\n onChange(value: string | undefined): void\r\n}\r\n\r\n/** Controlled antd `Input` that accepts only hexadecimal digits and normalizes the value on blur. */\r\nexport default class HexaFormattedInput extends React.Component<HexaFormattedInputProps, any> {\r\n private inputRef: InputRef | null = null;\r\n\r\n constructor(props: Readonly<HexaFormattedInputProps>) {\r\n super(props);\r\n }\r\n\r\n /** The underlying DOM input element, or `undefined` before mount. */\r\n get input() {\r\n return this.inputRef?.input;\r\n }\r\n\r\n /** Moves the keyboard focus to the input. */\r\n focus() {\r\n this.inputRef?.focus();\r\n }\r\n\r\n private getFormattedValue(value: string): string {\r\n let valueToFormat = value;\r\n for (let i = 0; i < this.props.maxLength - value.length; i++) {\r\n valueToFormat = \"0\" + valueToFormat;\r\n }\r\n return valueToFormat.toUpperCase();\r\n }\r\n\r\n render() {\r\n const {value, maxLength, onChange, ...rest} = this.props;\r\n\r\n return (\r\n <Input\r\n {...rest}\r\n ref={component => {\r\n this.inputRef = component;\r\n }}\r\n value={this.props.value.toUpperCase()}\r\n onChange={event => {\r\n const value = event.target.value;\r\n if (/^[0-9A-Fa-f]+$/.test(value) || value === \"\") {\r\n this.props.onChange(value);\r\n }\r\n }}\r\n onBlur={event => {\r\n let value = event.target.value;\r\n if (!value) {\r\n this.props.onChange(undefined);\r\n } else {\r\n const formattedValue = this.getFormattedValue(value);\r\n this.props.onChange(formattedValue);\r\n }\r\n }}\r\n maxLength={this.props.maxLength}\r\n />\r\n );\r\n }\r\n}"]}
@@ -1,27 +1,54 @@
1
1
  import { KeyboardEvent } from 'react';
2
+ /** Whether the keyboard event is an undo shortcut: Ctrl/Cmd+Z, or Ctrl/Cmd+Shift+Y. */
2
3
  export declare function isUndo(e: KeyboardEvent): boolean;
4
+ /** Whether the keyboard event is a redo shortcut: Ctrl/Cmd+Y, or Ctrl/Cmd+Shift+Z. */
3
5
  export declare function isRedo(e: KeyboardEvent): boolean;
6
+ /** Selection range in an input, as character offsets (`end` exclusive). */
4
7
  type GetSelectionResult = {
5
8
  start: number;
6
9
  end: number;
7
10
  };
11
+ /** Reads the current selection of the input element (with a fallback for legacy IE). */
8
12
  export declare function getSelection(el: HTMLInputElement): GetSelectionResult;
13
+ /**
14
+ * Focuses the input element and sets its selection, unless it already matches. The selection is applied again
15
+ * asynchronously to work around a Chromium bug; errors on hidden or unfocusable elements are ignored.
16
+ */
9
17
  export declare function setSelection(el: HTMLInputElement, selection: GetSelectionResult): void;
18
+ /**
19
+ * Merges custom format characters into a copy of {@link DEFAULT_FORMAT_CHARACTERS}.
20
+ * A `null`/`undefined` definition removes that character; any other definition adds or overrides it.
21
+ * @returns the merged map; the defaults are not modified.
22
+ */
10
23
  export declare function mergeFormatCharacters(formatCharacters: FormatCharacters): {
11
24
  [key: string]: {
25
+ /** Converts an accepted character before it is stored (e.g. upper-casing). */
12
26
  transform?(str: string): string;
27
+ /** Whether the character may be entered at this position. */
13
28
  validate(str: string): boolean;
14
29
  };
15
30
  };
31
+ /** Prefix that makes the following pattern character a literal instead of a format character. */
16
32
  export declare const ESCAPE_CHAR = "\\";
33
+ /** Matches a single decimal digit. */
17
34
  export declare const DIGIT_RE: RegExp;
35
+ /** Matches a single ASCII letter. */
18
36
  export declare const LETTER_RE: RegExp;
37
+ /** Matches a single ASCII letter or decimal digit. */
19
38
  export declare const ALPHANNUMERIC_RE: RegExp;
39
+ /** Placeholder shown in unfilled editable positions when no other is configured. */
20
40
  export declare const DEFAULT_PLACEHOLDER_CHAR = "_";
41
+ /**
42
+ * Built-in format characters: `1` digit, `a` letter, `A` letter (upper-cased), `*` alphanumeric,
43
+ * `#` alphanumeric (upper-cased).
44
+ */
21
45
  export declare const DEFAULT_FORMAT_CHARACTERS: FormatCharacters;
46
+ /** Map from a pattern character to the rule for the editable position it marks. */
22
47
  export type FormatCharacters = {
23
48
  [key: string]: {
49
+ /** Converts an accepted character before it is stored (e.g. upper-casing). */
24
50
  transform?(str: string): string;
51
+ /** Whether the character may be entered at this position. */
25
52
  validate(str: string): boolean;
26
53
  };
27
54
  };
@@ -1,13 +1,16 @@
1
1
  let KEYCODE_Z = "KeyZ";
2
2
  let KEYCODE_Y = "KeyY";
3
+ /** Whether the keyboard event is an undo shortcut: Ctrl/Cmd+Z, or Ctrl/Cmd+Shift+Y. */
3
4
  export function isUndo(e) {
4
5
  return ((e.ctrlKey || e.metaKey) &&
5
6
  e.code === (e.shiftKey ? KEYCODE_Y : KEYCODE_Z));
6
7
  }
8
+ /** Whether the keyboard event is a redo shortcut: Ctrl/Cmd+Y, or Ctrl/Cmd+Shift+Z. */
7
9
  export function isRedo(e) {
8
10
  return ((e.ctrlKey || e.metaKey) &&
9
11
  e.code === (e.shiftKey ? KEYCODE_Z : KEYCODE_Y));
10
12
  }
13
+ /** Reads the current selection of the input element (with a fallback for legacy IE). */
11
14
  export function getSelection(el) {
12
15
  let start, end;
13
16
  if (el.selectionStart !== undefined) {
@@ -17,19 +20,26 @@ export function getSelection(el) {
17
20
  else {
18
21
  try {
19
22
  el.focus();
23
+ // @ts-ignore (IE only)
20
24
  let rangeEl = el.createTextRange();
21
25
  let clone = rangeEl.duplicate();
26
+ // @ts-ignore (IE only)
22
27
  rangeEl.moveToBookmark(document.selection.createRange().getBookmark());
23
28
  clone.setEndPoint('EndToStart', rangeEl);
24
29
  start = clone.text.length;
25
30
  end = start + rangeEl.text.length;
26
31
  }
27
32
  catch (e) {
33
+ /* not focused or not visible */
28
34
  }
29
35
  }
30
36
  return { start, end };
31
37
  }
32
38
  let selectionTimeout;
39
+ /**
40
+ * Focuses the input element and sets its selection, unless it already matches. The selection is applied again
41
+ * asynchronously to work around a Chromium bug; errors on hidden or unfocusable elements are ignored.
42
+ */
33
43
  export function setSelection(el, selection) {
34
44
  clearTimeout(selectionTimeout);
35
45
  try {
@@ -40,12 +50,14 @@ export function setSelection(el, selection) {
40
50
  if (el.selectionStart !== undefined) {
41
51
  el.focus();
42
52
  el.setSelectionRange(selection.start, selection.end);
53
+ // fix https://bugs.chromium.org/p/chromium/issues/detail?id=32865
43
54
  selectionTimeout = setTimeout(() => {
44
55
  setSelection(el, selection);
45
56
  }, 0);
46
57
  }
47
58
  else {
48
59
  el.focus();
60
+ // @ts-ignore (IE only)
49
61
  let rangeEl = el.createTextRange();
50
62
  rangeEl.collapse(true);
51
63
  rangeEl.moveStart('character', selection.start);
@@ -54,8 +66,14 @@ export function setSelection(el, selection) {
54
66
  }
55
67
  }
56
68
  catch (e) {
69
+ /* not focused or not visible */
57
70
  }
58
71
  }
72
+ /**
73
+ * Merges custom format characters into a copy of {@link DEFAULT_FORMAT_CHARACTERS}.
74
+ * A `null`/`undefined` definition removes that character; any other definition adds or overrides it.
75
+ * @returns the merged map; the defaults are not modified.
76
+ */
59
77
  export function mergeFormatCharacters(formatCharacters) {
60
78
  var merged = Object.assign({}, DEFAULT_FORMAT_CHARACTERS);
61
79
  if (formatCharacters) {
@@ -72,11 +90,20 @@ export function mergeFormatCharacters(formatCharacters) {
72
90
  }
73
91
  return merged;
74
92
  }
93
+ /** Prefix that makes the following pattern character a literal instead of a format character. */
75
94
  export const ESCAPE_CHAR = '\\';
95
+ /** Matches a single decimal digit. */
76
96
  export const DIGIT_RE = /^\d$/;
97
+ /** Matches a single ASCII letter. */
77
98
  export const LETTER_RE = /^[A-Za-z]$/;
99
+ /** Matches a single ASCII letter or decimal digit. */
78
100
  export const ALPHANNUMERIC_RE = /^[\dA-Za-z]$/;
101
+ /** Placeholder shown in unfilled editable positions when no other is configured. */
79
102
  export const DEFAULT_PLACEHOLDER_CHAR = '_';
103
+ /**
104
+ * Built-in format characters: `1` digit, `a` letter, `A` letter (upper-cased), `*` alphanumeric,
105
+ * `#` alphanumeric (upper-cased).
106
+ */
80
107
  export const DEFAULT_FORMAT_CHARACTERS = {
81
108
  '*': {
82
109
  validate: function (char) {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../components/input/mask/helpers.ts"],"names":[],"mappings":"AAEA,IAAI,SAAS,GAAG,MAAM,CAAC;AACvB,IAAI,SAAS,GAAG,MAAM,CAAC;AAEvB,MAAM,UAAU,MAAM,CAAC,CAAgB;IACnC,OAAO,CACH,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QACx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ACJ;IACD,GAAG,EAAE;QACD,QAAQ,EAAE,UAAS,IAAY;YAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QACD,SAAS,EAAE,UAAS,IAAY;YAC5B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;KACJ;CACJ,CAAC","sourcesContent":["import {KeyboardEvent} from 'react';\r\n\r\nlet KEYCODE_Z = \"KeyZ\";\r\nlet KEYCODE_Y = \"KeyY\";\r\n\r\nexport function isUndo(e: KeyboardEvent): boolean {\r\n return (\r\n (e.ctrlKey || e.metaKey) &&\r\n e.code === (e.shiftKey ? KEYCODE_Y : KEYCODE_Z)\r\n );\r\n}\r\n\r\nexport function isRedo(e: KeyboardEvent): boolean {\r\n return (\r\n (e.ctrlKey || e.metaKey) &&\r\n e.code === (e.shiftKey ? KEYCODE_Z : KEYCODE_Y)\r\n );\r\n}\r\n\r\ntype GetSelectionResult = { start: number; end: number };\r\n\r\nexport function getSelection(el: HTMLInputElement): GetSelectionResult {\r\n let start, end;\r\n if (el.selectionStart !== undefined) {\r\n start = el.selectionStart;\r\n end = el.selectionEnd;\r\n } else {\r\n try {\r\n el.focus();\r\n // @ts-ignore (IE only)\r\n let rangeEl = el.createTextRange();\r\n let clone = rangeEl.duplicate();\r\n\r\n // @ts-ignore (IE only)\r\n rangeEl.moveToBookmark(document.selection.createRange().getBookmark());\r\n clone.setEndPoint('EndToStart', rangeEl);\r\n\r\n start = clone.text.length;\r\n end = start + rangeEl.text.length;\r\n } catch (e) {\r\n /* not focused or not visible */\r\n }\r\n }\r\n\r\n return { start, end };\r\n}\r\n\r\nlet selectionTimeout: any;\r\nexport function setSelection(\r\n el: HTMLInputElement,\r\n selection: GetSelectionResult\r\n) {\r\n clearTimeout(selectionTimeout);\r\n\r\n try {\r\n if (\r\n el.selectionStart === selection.start &&\r\n el.selectionEnd === selection.end\r\n ) {\r\n return;\r\n }\r\n\r\n if (el.selectionStart !== undefined) {\r\n el.focus();\r\n el.setSelectionRange(selection.start, selection.end);\r\n\r\n // fix https://bugs.chromium.org/p/chromium/issues/detail?id=32865\r\n selectionTimeout = setTimeout(() => {\r\n setSelection(el, selection);\r\n }, 0);\r\n\r\n } else {\r\n el.focus();\r\n // @ts-ignore (IE only)\r\n let rangeEl = el.createTextRange();\r\n rangeEl.collapse(true);\r\n rangeEl.moveStart('character', selection.start);\r\n rangeEl.moveEnd('character', selection.end - selection.start);\r\n rangeEl.select();\r\n }\r\n } catch (e) {\r\n /* not focused or not visible */\r\n }\r\n}\r\n\r\n/**\r\n * Merge an object defining format characters into the defaults.\r\n * Passing null/undefined for en existing format character removes it.\r\n * Passing a definition for an existing format character overrides it.\r\n */\r\nexport function mergeFormatCharacters(formatCharacters: FormatCharacters) {\r\n var merged = { ...DEFAULT_FORMAT_CHARACTERS };\r\n if (formatCharacters) {\r\n var chars = Object.keys(formatCharacters);\r\n for (var i = 0, l = chars.length; i < l; i++) {\r\n var char = chars[i];\r\n if (formatCharacters[char] == null) {\r\n delete merged[char];\r\n } else {\r\n merged[char] = formatCharacters[char];\r\n }\r\n }\r\n }\r\n return merged;\r\n}\r\n\r\nexport const ESCAPE_CHAR = '\\\\';\r\n\r\nexport const DIGIT_RE = /^\\d$/;\r\nexport const LETTER_RE = /^[A-Za-z]$/;\r\nexport const ALPHANNUMERIC_RE = /^[\\dA-Za-z]$/;\r\n\r\nexport const DEFAULT_PLACEHOLDER_CHAR = '_';\r\n\r\nexport const DEFAULT_FORMAT_CHARACTERS: FormatCharacters = {\r\n '*': {\r\n validate: function(char: string) {\r\n return ALPHANNUMERIC_RE.test(char);\r\n }\r\n },\r\n '1': {\r\n validate: function(char: string) {\r\n return DIGIT_RE.test(char);\r\n }\r\n },\r\n a: {\r\n validate: function(char: string) {\r\n return LETTER_RE.test(char);\r\n }\r\n },\r\n A: {\r\n validate: function(char: string) {\r\n return LETTER_RE.test(char);\r\n },\r\n transform: function(char: string) {\r\n return char.toUpperCase();\r\n }\r\n },\r\n '#': {\r\n validate: function(char: string) {\r\n return ALPHANNUMERIC_RE.test(char);\r\n },\r\n transform: function(char: string) {\r\n return char.toUpperCase();\r\n }\r\n }\r\n};\r\n\r\nexport type FormatCharacters = {\r\n [key: string]: {\r\n transform?(str: string): string;\r\n validate(str: string): boolean;\r\n };\r\n};"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../components/input/mask/helpers.ts"],"names":[],"mappings":"AAEA,IAAI,SAAS,GAAG,MAAM,CAAC;AACvB,IAAI,SAAS,GAAG,MAAM,CAAC;AAEvB,uFAAuF;AACvF,MAAM,UAAU,MAAM,CAAC,CAAgB;IACnC,OAAO,CACH,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QACxB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAClD,CAAC;AACN,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,MAAM,CAAC,CAAgB;IACnC,OAAO,CACH,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QACxB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAClD,CAAC;AACN,CAAC;AAKD,wFAAwF;AACxF,MAAM,UAAU,YAAY,CAAC,EAAoB;IAC7C,IAAI,KAAK,EAAE,GAAG,CAAC;IACf,IAAI,EAAE,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAClC,KAAK,GAAG,EAAE,CAAC,cAAc,CAAC;QAC1B,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC;IAC1B,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC;YACD,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,uBAAuB;YACvB,IAAI,OAAO,GAAG,EAAE,CAAC,eAA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BAAgB,GAAG,cAAc,CAAC;AAE/C,oFAAoF;AACpF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IACvD,GAAG,EAAE;QACD,QAAQ,EAAE,UAAS,IAAY;YAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;KACJ;IACD,GAAG,EAAE;QACD,QAAQ,EAAE,UAAS,IAAY;YAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;KACJ;IACD,CAAC,EAAE;QACC,QAAQ,EAAE,UAAS,IAAY;YAC3B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;KACJ;IACD,CAAC,EAAE;QACC,QAAQ,EAAE,UAAS,IAAY;YAC3B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QACD,SAAS,EAAE,UAAS,IAAY;YAC5B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;KACJ;IACD,GAAG,EAAE;QACD,QAAQ,EAAE,UAAS,IAAY;YAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QACD,SAAS,EAAE,UAAS,IAAY;YAC5B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;KACJ;CACJ,CAAC","sourcesContent":["import {KeyboardEvent} from 'react';\r\n\r\nlet KEYCODE_Z = \"KeyZ\";\r\nlet KEYCODE_Y = \"KeyY\";\r\n\r\n/** Whether the keyboard event is an undo shortcut: Ctrl/Cmd+Z, or Ctrl/Cmd+Shift+Y. */\r\nexport function isUndo(e: KeyboardEvent): boolean {\r\n return (\r\n (e.ctrlKey || e.metaKey) &&\r\n e.code === (e.shiftKey ? KEYCODE_Y : KEYCODE_Z)\r\n );\r\n}\r\n\r\n/** Whether the keyboard event is a redo shortcut: Ctrl/Cmd+Y, or Ctrl/Cmd+Shift+Z. */\r\nexport function isRedo(e: KeyboardEvent): boolean {\r\n return (\r\n (e.ctrlKey || e.metaKey) &&\r\n e.code === (e.shiftKey ? KEYCODE_Z : KEYCODE_Y)\r\n );\r\n}\r\n\r\n/** Selection range in an input, as character offsets (`end` exclusive). */\r\ntype GetSelectionResult = { start: number; end: number };\r\n\r\n/** Reads the current selection of the input element (with a fallback for legacy IE). */\r\nexport function getSelection(el: HTMLInputElement): GetSelectionResult {\r\n let start, end;\r\n if (el.selectionStart !== undefined) {\r\n start = el.selectionStart;\r\n end = el.selectionEnd;\r\n } else {\r\n try {\r\n el.focus();\r\n // @ts-ignore (IE only)\r\n let rangeEl = el.createTextRange();\r\n let clone = rangeEl.duplicate();\r\n\r\n // @ts-ignore (IE only)\r\n rangeEl.moveToBookmark(document.selection.createRange().getBookmark());\r\n clone.setEndPoint('EndToStart', rangeEl);\r\n\r\n start = clone.text.length;\r\n end = start + rangeEl.text.length;\r\n } catch (e) {\r\n /* not focused or not visible */\r\n }\r\n }\r\n\r\n return { start, end };\r\n}\r\n\r\nlet selectionTimeout: any;\r\n/**\r\n * Focuses the input element and sets its selection, unless it already matches. The selection is applied again\r\n * asynchronously to work around a Chromium bug; errors on hidden or unfocusable elements are ignored.\r\n */\r\nexport function setSelection(\r\n el: HTMLInputElement,\r\n selection: GetSelectionResult\r\n) {\r\n clearTimeout(selectionTimeout);\r\n\r\n try {\r\n if (\r\n el.selectionStart === selection.start &&\r\n el.selectionEnd === selection.end\r\n ) {\r\n return;\r\n }\r\n\r\n if (el.selectionStart !== undefined) {\r\n el.focus();\r\n el.setSelectionRange(selection.start, selection.end);\r\n\r\n // fix https://bugs.chromium.org/p/chromium/issues/detail?id=32865\r\n selectionTimeout = setTimeout(() => {\r\n setSelection(el, selection);\r\n }, 0);\r\n\r\n } else {\r\n el.focus();\r\n // @ts-ignore (IE only)\r\n let rangeEl = el.createTextRange();\r\n rangeEl.collapse(true);\r\n rangeEl.moveStart('character', selection.start);\r\n rangeEl.moveEnd('character', selection.end - selection.start);\r\n rangeEl.select();\r\n }\r\n } catch (e) {\r\n /* not focused or not visible */\r\n }\r\n}\r\n\r\n/**\r\n * Merges custom format characters into a copy of {@link DEFAULT_FORMAT_CHARACTERS}.\r\n * A `null`/`undefined` definition removes that character; any other definition adds or overrides it.\r\n * @returns the merged map; the defaults are not modified.\r\n */\r\nexport function mergeFormatCharacters(formatCharacters: FormatCharacters) {\r\n var merged = { ...DEFAULT_FORMAT_CHARACTERS };\r\n if (formatCharacters) {\r\n var chars = Object.keys(formatCharacters);\r\n for (var i = 0, l = chars.length; i < l; i++) {\r\n var char = chars[i];\r\n if (formatCharacters[char] == null) {\r\n delete merged[char];\r\n } else {\r\n merged[char] = formatCharacters[char];\r\n }\r\n }\r\n }\r\n return merged;\r\n}\r\n\r\n/** Prefix that makes the following pattern character a literal instead of a format character. */\r\nexport const ESCAPE_CHAR = '\\\\';\r\n\r\n/** Matches a single decimal digit. */\r\nexport const DIGIT_RE = /^\\d$/;\r\n/** Matches a single ASCII letter. */\r\nexport const LETTER_RE = /^[A-Za-z]$/;\r\n/** Matches a single ASCII letter or decimal digit. */\r\nexport const ALPHANNUMERIC_RE = /^[\\dA-Za-z]$/;\r\n\r\n/** Placeholder shown in unfilled editable positions when no other is configured. */\r\nexport const DEFAULT_PLACEHOLDER_CHAR = '_';\r\n\r\n/**\r\n * Built-in format characters: `1` digit, `a` letter, `A` letter (upper-cased), `*` alphanumeric,\r\n * `#` alphanumeric (upper-cased).\r\n */\r\nexport const DEFAULT_FORMAT_CHARACTERS: FormatCharacters = {\r\n '*': {\r\n validate: function(char: string) {\r\n return ALPHANNUMERIC_RE.test(char);\r\n }\r\n },\r\n '1': {\r\n validate: function(char: string) {\r\n return DIGIT_RE.test(char);\r\n }\r\n },\r\n a: {\r\n validate: function(char: string) {\r\n return LETTER_RE.test(char);\r\n }\r\n },\r\n A: {\r\n validate: function(char: string) {\r\n return LETTER_RE.test(char);\r\n },\r\n transform: function(char: string) {\r\n return char.toUpperCase();\r\n }\r\n },\r\n '#': {\r\n validate: function(char: string) {\r\n return ALPHANNUMERIC_RE.test(char);\r\n },\r\n transform: function(char: string) {\r\n return char.toUpperCase();\r\n }\r\n }\r\n};\r\n\r\n/** Map from a pattern character to the rule for the editable position it marks. */\r\nexport type FormatCharacters = {\r\n [key: string]: {\r\n /** Converts an accepted character before it is stored (e.g. upper-casing). */\r\n transform?(str: string): string;\r\n /** Whether the character may be entered at this position. */\r\n validate(str: string): boolean;\r\n };\r\n};"]}