d2coreui 23.0.51 → 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 (281) 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 +241 -0
  129. package/components/grid/extendedDataGrid.js +121 -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 +157 -126
  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 +4 -3
  281. package/style/index.less +240 -240
@@ -1,11 +1,22 @@
1
1
  import React from "react";
2
+ /** Properties of {@link DetailHeaderPanel}. */
2
3
  interface Props {
4
+ /** Style merged over the default header style. */
3
5
  style?: React.CSSProperties;
6
+ /** Hide the previous/next record buttons. */
4
7
  hidePrevNextButton?: boolean;
8
+ /** Called when the previous record button is clicked. */
5
9
  onPrevRecord?(): void;
10
+ /** Called when the next record button is clicked. */
6
11
  onNextRecord?(): void;
12
+ /** Called when the close button is clicked. */
7
13
  onClose?(): void;
8
14
  }
15
+ /**
16
+ * Header of a record detail panel: a "Detail" title, previous/next record buttons and a close button.
17
+ * Typically rendered at the top of `ExtendedDataGrid`'s `detailPanel`, with the navigation buttons wired to
18
+ * `ExtendedDataGrid.selectNextPreviousRecord` and close to `ExtendedDataGrid.showDetailPanel(false)`.
19
+ */
9
20
  export default class DetailHeaderPanel extends React.Component<Props> {
10
21
  constructor(props: Readonly<Props>);
11
22
  render(): React.JSX.Element;
@@ -2,6 +2,11 @@ import React from "react";
2
2
  import { ArrowDownOutlined, ArrowUpOutlined, CloseOutlined, ProfileOutlined } from "@ant-design/icons";
3
3
  import i18n from "d2core/i18n/i18n";
4
4
  import { Button } from "antd";
5
+ /**
6
+ * Header of a record detail panel: a "Detail" title, previous/next record buttons and a close button.
7
+ * Typically rendered at the top of `ExtendedDataGrid`'s `detailPanel`, with the navigation buttons wired to
8
+ * `ExtendedDataGrid.selectNextPreviousRecord` and close to `ExtendedDataGrid.showDetailPanel(false)`.
9
+ */
5
10
  export default class DetailHeaderPanel extends React.Component {
6
11
  constructor(props) {
7
12
  super(props);
@@ -1 +1 @@
1
- {"version":3,"file":"detailHeaderPanel.js","sourceRoot":"","sources":["../../../../../components/grid/detail/detailHeaderPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AACrG,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAa5B,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAgB;IACjE,YAAY,KAAsB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,OAAO,CACH,6BACI,SAAS,EAAC,kBAAkB,EAC5B,KAAK,kBACD,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,eAAe,EAC/B,UAAU,EAAE,QAAQ,IACjB,IAAI,CAAC,KAAK,CAAC,KAAK;YAGvB;gBACI,oBAAC,eAAe,OAAE;;gBAAE,IAAI,CAAC,QAAQ,CAAC,CAChC;YACN;gBACK,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB;oBAC3B,oBAAC,MAAM,CAAC,KAAK,IAAC,KAAK,EAAE,EAAC,SAAS,EAAE,CAAC,CAAC,EAAC;wBAChC,oBAAC,MAAM,IAAC,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;4BACpE,oBAAC,eAAe,OAAE,CACb;wBACT,oBAAC,MAAM,IAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;4BAChE,oBAAC,iBAAiB,OAAE,CACf,CACE;gBAEnB,oBAAC,MAAM,IACH,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,EACpB,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;oBAE3B,oBAAC,aAAa,OAAE,CACX,CACP,CACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {ArrowDownOutlined, ArrowUpOutlined, CloseOutlined, ProfileOutlined} from \"@ant-design/icons\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {Button} from \"antd\";\r\n\r\ninterface Props {\r\n style?: React.CSSProperties\r\n hidePrevNextButton?: boolean\r\n\r\n onPrevRecord?(): void\r\n\r\n onNextRecord?(): void\r\n\r\n onClose?(): void\r\n}\r\n\r\nexport default class DetailHeaderPanel extends React.Component<Props> {\r\n constructor(props: Readonly<Props>) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n return (\r\n <div\r\n className=\"d2-drawer-header\"\r\n style={{\r\n padding: \"8px 4px 8px 12px\",\r\n display: \"flex\",\r\n justifyContent: \"space-between\",\r\n alignItems: \"center\",\r\n ...this.props.style\r\n }}\r\n >\r\n <div>\r\n <ProfileOutlined/> {i18n(\"Detail\")}\r\n </div>\r\n <div>\r\n {!this.props.hidePrevNextButton &&\r\n <Button.Group style={{marginTop: -4}}>\r\n <Button title={i18n(\"Previous Record\")} onClick={this.props.onPrevRecord}>\r\n <ArrowUpOutlined/>\r\n </Button>\r\n <Button title={i18n(\"Next Record\")} onClick={this.props.onNextRecord}>\r\n <ArrowDownOutlined/>\r\n </Button>\r\n </Button.Group>\r\n }\r\n <Button\r\n title={i18n(\"Close\")}\r\n type=\"text\"\r\n onClick={this.props.onClose}\r\n >\r\n <CloseOutlined/>\r\n </Button>\r\n </div>\r\n </div>\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"detailHeaderPanel.js","sourceRoot":"","sources":["../../../../../components/grid/detail/detailHeaderPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AACrG,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAmB5B;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAgB;IACjE,YAAY,KAAsB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,OAAO,CACH,6BACI,SAAS,EAAC,kBAAkB,EAC5B,KAAK,kBACD,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,eAAe,EAC/B,UAAU,EAAE,QAAQ,IACjB,IAAI,CAAC,KAAK,CAAC,KAAK;YAGvB;gBACI,oBAAC,eAAe,OAAE;;gBAAE,IAAI,CAAC,QAAQ,CAAC,CAChC;YACN;gBACK,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB;oBAC3B,oBAAC,MAAM,CAAC,KAAK,IAAC,KAAK,EAAE,EAAC,SAAS,EAAE,CAAC,CAAC,EAAC;wBAChC,oBAAC,MAAM,IAAC,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;4BACpE,oBAAC,eAAe,OAAE,CACb;wBACT,oBAAC,MAAM,IAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;4BAChE,oBAAC,iBAAiB,OAAE,CACf,CACE;gBAEnB,oBAAC,MAAM,IACH,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,EACpB,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;oBAE3B,oBAAC,aAAa,OAAE,CACX,CACP,CACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {ArrowDownOutlined, ArrowUpOutlined, CloseOutlined, ProfileOutlined} from \"@ant-design/icons\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {Button} from \"antd\";\r\n\r\n/** Properties of {@link DetailHeaderPanel}. */\r\ninterface Props {\r\n /** Style merged over the default header style. */\r\n style?: React.CSSProperties\r\n /** Hide the previous/next record buttons. */\r\n hidePrevNextButton?: boolean\r\n\r\n /** Called when the previous record button is clicked. */\r\n onPrevRecord?(): void\r\n\r\n /** Called when the next record button is clicked. */\r\n onNextRecord?(): void\r\n\r\n /** Called when the close button is clicked. */\r\n onClose?(): void\r\n}\r\n\r\n/**\r\n * Header of a record detail panel: a \"Detail\" title, previous/next record buttons and a close button.\r\n * Typically rendered at the top of `ExtendedDataGrid`'s `detailPanel`, with the navigation buttons wired to\r\n * `ExtendedDataGrid.selectNextPreviousRecord` and close to `ExtendedDataGrid.showDetailPanel(false)`.\r\n */\r\nexport default class DetailHeaderPanel extends React.Component<Props> {\r\n constructor(props: Readonly<Props>) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n return (\r\n <div\r\n className=\"d2-drawer-header\"\r\n style={{\r\n padding: \"8px 4px 8px 12px\",\r\n display: \"flex\",\r\n justifyContent: \"space-between\",\r\n alignItems: \"center\",\r\n ...this.props.style\r\n }}\r\n >\r\n <div>\r\n <ProfileOutlined/> {i18n(\"Detail\")}\r\n </div>\r\n <div>\r\n {!this.props.hidePrevNextButton &&\r\n <Button.Group style={{marginTop: -4}}>\r\n <Button title={i18n(\"Previous Record\")} onClick={this.props.onPrevRecord}>\r\n <ArrowUpOutlined/>\r\n </Button>\r\n <Button title={i18n(\"Next Record\")} onClick={this.props.onNextRecord}>\r\n <ArrowDownOutlined/>\r\n </Button>\r\n </Button.Group>\r\n }\r\n <Button\r\n title={i18n(\"Close\")}\r\n type=\"text\"\r\n onClick={this.props.onClose}\r\n >\r\n <CloseOutlined/>\r\n </Button>\r\n </div>\r\n </div>\r\n );\r\n }\r\n}"]}
@@ -1,20 +1,51 @@
1
1
  import { MenuProps } from "antd";
2
2
  import ProgressPopup from "./progressPopup";
3
3
  import { MenuElement } from "../dataGrid";
4
+ /** Properties of {@link getContextMenu}. The whole object is also passed to `getExportContent`. */
4
5
  export interface ContextMenuProps {
6
+ /** Hint for `getExportContent` to export only the selected rows. */
5
7
  onlySelectedNodes?: boolean;
8
+ /** Hint for `getExportContent` to format date-time values with milliseconds. */
6
9
  showMilliseconds: boolean;
10
+ /** Hint for `getExportContent` to format dates with the year. */
7
11
  showYear: boolean;
12
+ /** Hint for `getExportContent` to format date-time values with the UTC offset. */
8
13
  showUtcOffset: boolean;
14
+ /** Copy to the clipboard without the progress (and error) notification. */
9
15
  hideNotificationOnClipboardCopy?: boolean;
16
+ /** Page orientation of the PDF export, shown by the switch in the PDF menu item. */
10
17
  pageOrientation: PageOrientation;
18
+ /** Disables the export items, e.g. while an export is running. */
11
19
  exporting: boolean;
20
+ /**
21
+ * Produces the exported table: an array of rows of cell texts, the first row being the column headers.
22
+ * It may report progress through `progressPopup`, which is `null` for a clipboard copy with
23
+ * `hideNotificationOnClipboardCopy`.
24
+ */
12
25
  getExportContent: (progressPopup: ProgressPopup | null, props: ContextMenuProps) => Promise<string[][]>;
26
+ /** Called when the user toggles the PDF orientation switch; the caller is expected to pass the new `pageOrientation` back. */
13
27
  onPageOrientationChange: (pageOrientation: PageOrientation) => void;
28
+ /**
29
+ * Called with `true` when any menu item is clicked and with `false` when the item has been processed. For the PDF
30
+ * export, `false` comes before the PDF is produced (it is generated asynchronously), and it is not called at all when the
31
+ * export fails.
32
+ */
14
33
  onExport: (start: boolean) => void;
34
+ /** Receives the built-in menu items and returns the items to show, e.g. with custom items added. */
15
35
  renderer?(menuElements: MenuElement[]): MenuElement[];
36
+ /** Called with the key of every clicked item, built-in ones (`txtExport`, `csvExport`, `pdfExport`, `clipboardCopy`) included. */
16
37
  onClick?(key: string): void;
38
+ /** Called after a successful export with the number of exported data rows and the file name, or `"[CLIPBOARD]"` for a clipboard copy. */
17
39
  onExported?: (rowCount: number, destination: string) => void;
18
40
  }
41
+ /** Page orientation of the PDF export. */
19
42
  export type PageOrientation = "PORTRAIT" | "LANDSCAPE";
43
+ /**
44
+ * Builds the export menu of a grid as antd `MenuProps` (for a `Dropdown`): export to TXT, CSV and PDF files and copy to
45
+ * the clipboard. Content comes from `getExportContent` and is converted in a web worker; progress is shown by a
46
+ * {@link ProgressPopup}, and files named `export_YYYYMMDD_HHmm.<ext>` are saved through {@link PlatformSpecific}.
47
+ *
48
+ * The workers are started with `new Worker(new URL(..., import.meta.url))`, so the consuming bundler must emit them as
49
+ * separate chunks; a webpack application emitting its chunks into a subdirectory needs `output.publicPath: "auto"`.
50
+ */
20
51
  export default function getContextMenu(props: ContextMenuProps): MenuProps;
@@ -7,6 +7,14 @@ import dayjs from "dayjs";
7
7
  import ProgressPopup from "./progressPopup";
8
8
  import { ClipboardUtils } from "d2coreui/components/clipboard/clipboardUtils";
9
9
  import PlatformSpecific from "d2coreui/components/platformSpecific";
10
+ /**
11
+ * Builds the export menu of a grid as antd `MenuProps` (for a `Dropdown`): export to TXT, CSV and PDF files and copy to
12
+ * the clipboard. Content comes from `getExportContent` and is converted in a web worker; progress is shown by a
13
+ * {@link ProgressPopup}, and files named `export_YYYYMMDD_HHmm.<ext>` are saved through {@link PlatformSpecific}.
14
+ *
15
+ * The workers are started with `new Worker(new URL(..., import.meta.url))`, so the consuming bundler must emit them as
16
+ * separate chunks; a webpack application emitting its chunks into a subdirectory needs `output.publicPath: "auto"`.
17
+ */
10
18
  export default function getContextMenu(props) {
11
19
  const { hideNotificationOnClipboardCopy, getExportContent, renderer, onClick } = props;
12
20
  const onExportMenuClick = async (menuKey) => {
@@ -1 +1 @@
1
- {"version":3,"file":"contextMenu.js","sourceRoot":"","sources":["../../../../../components/grid/export/contextMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAY,MAAM,EAAE,UAAU,EAAC,MAAM,MAAM,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAC5E,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AA4BpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAuB;IAC1D,MAAM,EAAC,+BAA+B,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IAErF,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAe,EA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AAE,UAAU;YACf,IAAI,EAAE,SAAS;SAClB;QACD;YACI,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,oBAAC,YAAY,OAAE;YACrB,QAAQ,EAAE,KAAK,CAAC,SAAS;YACzB,KAAK,EAAE;gBACF,IAAI,CAAC,mBAAmB,CAAC;gBAC1B,oBAAC,UAAU,CAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,aAA0B,CACxE;SACN;KACJ,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACX,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACH,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACd,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC","sourcesContent":["import {CopyOutlined, FileOutlined, FilePdfOutlined, FileTextOutlined} from \"@ant-design/icons\";\nimport {MenuProps, Switch, Typography} from \"antd\";\nimport React from \"react\";\nimport i18n from \"d2core/i18n/i18n\";\nimport {spawn, Thread, Worker} from \"threads\"\nimport dayjs from \"dayjs\";\nimport ProgressPopup from \"./progressPopup\";\nimport {MenuElement} from \"../dataGrid\";\nimport {ClipboardUtils} from \"d2coreui/components/clipboard/clipboardUtils\";\nimport PlatformSpecific from \"d2coreui/components/platformSpecific\";\n\n\nexport interface ContextMenuProps {\n onlySelectedNodes?: boolean\n showMilliseconds: boolean\n showYear: boolean\n showUtcOffset: boolean\n hideNotificationOnClipboardCopy?: boolean\n pageOrientation: PageOrientation\n exporting: boolean\n\n getExportContent: (progressPopup: ProgressPopup | null, props: ContextMenuProps) => Promise<string[][]>\n onPageOrientationChange:(pageOrientation: PageOrientation)=>void\n onExport:(start: boolean)=>void\n\n // overrides context menu rendering\n renderer?(menuElements: MenuElement[]): MenuElement[]\n\n // handler for custom context menu items click\n onClick?(key: string): void\n\n // export finished callback\n onExported?: (rowCount: number, destination: string) => void\n}\n\nexport type PageOrientation = \"PORTRAIT\" | \"LANDSCAPE\";\n\nexport default function getContextMenu(props: ContextMenuProps): MenuProps {\n const {hideNotificationOnClipboardCopy, getExportContent, renderer, onClick} = props;\n\n const onExportMenuClick = async (menuKey: string) => {\n props.onExport(true);\n switch (menuKey) {\n case \"txtExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" TXT\");\n const tableContent = await getExportContent(progressPopup, props);\n const txtExport = await spawn(new Worker(new URL('./worker/txtExport.js', import.meta.url) as any, {type: 'module'}));\n const textContent = await txtExport(tableContent);\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.txt`;\n await Thread.terminate(txtExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(fileName, textContent, true);\n props.onExported?.(tableContent.length - 1, fileName);\n break;\n }\n case \"csvExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" CSV\");\n const tableContent = await getExportContent(progressPopup, props);\n const csvExport = await spawn(new Worker(new URL('./worker/csvExport.js', import.meta.url) as any, {type: 'module'}));\n const csvContent = await csvExport(tableContent);\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.csv`;\n await Thread.terminate(csvExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(fileName, csvContent, true);\n props.onExported?.(tableContent.length - 1, fileName);\n break;\n }\n case \"clipboardCopy\": {\n const progressPopup = !hideNotificationOnClipboardCopy ? new ProgressPopup(i18n(\"Export List to\") + \" \" + i18n(\"Clipboard\")) : null;\n const tableContent = await getExportContent(progressPopup, props);\n const clipboardExport = await spawn(new Worker(new URL('./worker/clipboardExport.js', import.meta.url) as any, {type: 'module'}));\n const clipboardContent = await clipboardExport(tableContent);\n const success = ClipboardUtils.copyToClipboard(clipboardContent);\n if (success) {\n await Thread.terminate(clipboardExport);\n await progressPopup?.update(100);\n props.onExported?.(tableContent.length - 1, \"[CLIPBOARD]\");\n } else {\n progressPopup?.error();\n }\n break;\n }\n case \"pdfExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" PDF\");\n const tableContent = await getExportContent(progressPopup, props);\n const pdfExport = await spawn(new Worker(new URL('./worker/pdfExport.js', import.meta.url) as any, {type: 'module'}));\n pdfExport.handler().subscribe(async (data: string) => {\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.pdf`;\n Thread.terminate(pdfExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(fileName, data, false);\n props.onExported?.(tableContent.length - 1, fileName);\n });\n pdfExport.export(tableContent, {pageOrientation: props.pageOrientation});\n break;\n }\n }\n props.onExport(false);\n }\n\n let menuItems: MenuElement[] = [\n {\n key: \"txtExport\",\n icon: <FileOutlined/>,\n disabled: props.exporting,\n label: i18n(\"Export List to\") + \" TXT\",\n },\n {\n key: \"csvExport\",\n icon: <FileTextOutlined/>,\n disabled: props.exporting,\n label: i18n(\"Export List to\") + \" CSV\",\n },\n {\n key: \"pdfExport\",\n icon: <FilePdfOutlined/>,\n disabled: props.exporting,\n label: <>\n {i18n(\"Export List to\") + \" PDF\"}\n <Switch\n style={{marginLeft: 8}}\n checkedChildren={i18n(\"Landscape\") + \" \"}\n unCheckedChildren={\"\" + i18n(\"Portrait\")}\n checked={props.pageOrientation !== \"PORTRAIT\"}\n onChange={(checked, e) => {\n e.stopPropagation();\n (e as any).nativeEvent.stopImmediatePropagation();\n props.onPageOrientationChange(checked ? \"LANDSCAPE\" : \"PORTRAIT\")\n }}\n />\n </>\n },\n {\n key: \"divider1\",\n type: \"divider\",\n },\n {\n key: \"clipboardCopy\",\n icon: <CopyOutlined/>,\n disabled: props.exporting,\n label: <>\n {i18n(\"Copy to Clipboard\")}\n <Typography.Text code style={{float: \"right\"}}>CTRL+C</Typography.Text>\n </>,\n }\n ];\n\n if (renderer) {\n menuItems = renderer(menuItems);\n }\n\n return {\n items: menuItems,\n onClick: (item) => {\n onExportMenuClick(item.key);\n if (onClick) {\n onClick(item.key.toString());\n }\n },\n }\n}\n"]}
1
+ {"version":3,"file":"contextMenu.js","sourceRoot":"","sources":["../../../../../components/grid/export/contextMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAY,MAAM,EAAE,UAAU,EAAC,MAAM,MAAM,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAC5E,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAgDpE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAuB;IAC1D,MAAM,EAAC,+BAA+B,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IAErF,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAe,EAAE,EAAE;;QAChD,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrB,QAAQ,OAAO,EAAE,CAAC;YAClB,KAAK,WAAW,CAAC,CAAC,CAAC;gBACX,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC,CAAC;gBACzE,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;gBAClE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N;KACJ,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACX,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACH,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACd,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC","sourcesContent":["import {CopyOutlined, FileOutlined, FilePdfOutlined, FileTextOutlined} from \"@ant-design/icons\";\r\nimport {MenuProps, Switch, Typography} from \"antd\";\r\nimport React from \"react\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {spawn, Thread, Worker} from \"threads\"\r\nimport dayjs from \"dayjs\";\r\nimport ProgressPopup from \"./progressPopup\";\r\nimport {MenuElement} from \"../dataGrid\";\r\nimport {ClipboardUtils} from \"d2coreui/components/clipboard/clipboardUtils\";\r\nimport PlatformSpecific from \"d2coreui/components/platformSpecific\";\r\n\r\n\r\n/** Properties of {@link getContextMenu}. The whole object is also passed to `getExportContent`. */\r\nexport interface ContextMenuProps {\r\n /** Hint for `getExportContent` to export only the selected rows. */\r\n onlySelectedNodes?: boolean\r\n /** Hint for `getExportContent` to format date-time values with milliseconds. */\r\n showMilliseconds: boolean\r\n /** Hint for `getExportContent` to format dates with the year. */\r\n showYear: boolean\r\n /** Hint for `getExportContent` to format date-time values with the UTC offset. */\r\n showUtcOffset: boolean\r\n /** Copy to the clipboard without the progress (and error) notification. */\r\n hideNotificationOnClipboardCopy?: boolean\r\n /** Page orientation of the PDF export, shown by the switch in the PDF menu item. */\r\n pageOrientation: PageOrientation\r\n /** Disables the export items, e.g. while an export is running. */\r\n exporting: boolean\r\n\r\n /**\r\n * Produces the exported table: an array of rows of cell texts, the first row being the column headers.\r\n * It may report progress through `progressPopup`, which is `null` for a clipboard copy with\r\n * `hideNotificationOnClipboardCopy`.\r\n */\r\n getExportContent: (progressPopup: ProgressPopup | null, props: ContextMenuProps) => Promise<string[][]>\r\n /** Called when the user toggles the PDF orientation switch; the caller is expected to pass the new `pageOrientation` back. */\r\n onPageOrientationChange:(pageOrientation: PageOrientation)=>void\r\n /**\r\n * Called with `true` when any menu item is clicked and with `false` when the item has been processed. For the PDF\r\n * export, `false` comes before the PDF is produced (it is generated asynchronously), and it is not called at all when the\r\n * export fails.\r\n */\r\n onExport:(start: boolean)=>void\r\n\r\n /** Receives the built-in menu items and returns the items to show, e.g. with custom items added. */\r\n renderer?(menuElements: MenuElement[]): MenuElement[]\r\n\r\n /** Called with the key of every clicked item, built-in ones (`txtExport`, `csvExport`, `pdfExport`, `clipboardCopy`) included. */\r\n onClick?(key: string): void\r\n\r\n /** Called after a successful export with the number of exported data rows and the file name, or `\"[CLIPBOARD]\"` for a clipboard copy. */\r\n onExported?: (rowCount: number, destination: string) => void\r\n}\r\n\r\n/** Page orientation of the PDF export. */\r\nexport type PageOrientation = \"PORTRAIT\" | \"LANDSCAPE\";\r\n\r\n/**\r\n * Builds the export menu of a grid as antd `MenuProps` (for a `Dropdown`): export to TXT, CSV and PDF files and copy to\r\n * the clipboard. Content comes from `getExportContent` and is converted in a web worker; progress is shown by a\r\n * {@link ProgressPopup}, and files named `export_YYYYMMDD_HHmm.<ext>` are saved through {@link PlatformSpecific}.\r\n *\r\n * The workers are started with `new Worker(new URL(..., import.meta.url))`, so the consuming bundler must emit them as\r\n * separate chunks; a webpack application emitting its chunks into a subdirectory needs `output.publicPath: \"auto\"`.\r\n */\r\nexport default function getContextMenu(props: ContextMenuProps): MenuProps {\r\n const {hideNotificationOnClipboardCopy, getExportContent, renderer, onClick} = props;\r\n\r\n const onExportMenuClick = async (menuKey: string) => {\r\n props.onExport(true);\r\n switch (menuKey) {\r\n case \"txtExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" TXT\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const txtExport = await spawn(new Worker(new URL('./worker/txtExport.js', import.meta.url) as any, {type: 'module'}));\r\n const textContent = await txtExport(tableContent);\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.txt`;\r\n await Thread.terminate(txtExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, textContent, true);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n break;\r\n }\r\n case \"csvExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" CSV\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const csvExport = await spawn(new Worker(new URL('./worker/csvExport.js', import.meta.url) as any, {type: 'module'}));\r\n const csvContent = await csvExport(tableContent);\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.csv`;\r\n await Thread.terminate(csvExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, csvContent, true);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n break;\r\n }\r\n case \"clipboardCopy\": {\r\n const progressPopup = !hideNotificationOnClipboardCopy ? new ProgressPopup(i18n(\"Export List to\") + \" \" + i18n(\"Clipboard\")) : null;\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const clipboardExport = await spawn(new Worker(new URL('./worker/clipboardExport.js', import.meta.url) as any, {type: 'module'}));\r\n const clipboardContent = await clipboardExport(tableContent);\r\n const success = ClipboardUtils.copyToClipboard(clipboardContent);\r\n if (success) {\r\n await Thread.terminate(clipboardExport);\r\n await progressPopup?.update(100);\r\n props.onExported?.(tableContent.length - 1, \"[CLIPBOARD]\");\r\n } else {\r\n progressPopup?.error();\r\n }\r\n break;\r\n }\r\n case \"pdfExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" PDF\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const pdfExport = await spawn(new Worker(new URL('./worker/pdfExport.js', import.meta.url) as any, {type: 'module'}));\r\n pdfExport.handler().subscribe(async (data: string) => {\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.pdf`;\r\n Thread.terminate(pdfExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, data, false);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n });\r\n pdfExport.export(tableContent, {pageOrientation: props.pageOrientation});\r\n break;\r\n }\r\n }\r\n props.onExport(false);\r\n }\r\n\r\n let menuItems: MenuElement[] = [\r\n {\r\n key: \"txtExport\",\r\n icon: <FileOutlined/>,\r\n disabled: props.exporting,\r\n label: i18n(\"Export List to\") + \" TXT\",\r\n },\r\n {\r\n key: \"csvExport\",\r\n icon: <FileTextOutlined/>,\r\n disabled: props.exporting,\r\n label: i18n(\"Export List to\") + \" CSV\",\r\n },\r\n {\r\n key: \"pdfExport\",\r\n icon: <FilePdfOutlined/>,\r\n disabled: props.exporting,\r\n label: <>\r\n {i18n(\"Export List to\") + \" PDF\"}\r\n <Switch\r\n style={{marginLeft: 8}}\r\n checkedChildren={i18n(\"Landscape\") + \" \"}\r\n unCheckedChildren={\"\" + i18n(\"Portrait\")}\r\n checked={props.pageOrientation !== \"PORTRAIT\"}\r\n onChange={(checked, e) => {\r\n e.stopPropagation();\r\n (e as any).nativeEvent.stopImmediatePropagation();\r\n props.onPageOrientationChange(checked ? \"LANDSCAPE\" : \"PORTRAIT\")\r\n }}\r\n />\r\n </>\r\n },\r\n {\r\n key: \"divider1\",\r\n type: \"divider\",\r\n },\r\n {\r\n key: \"clipboardCopy\",\r\n icon: <CopyOutlined/>,\r\n disabled: props.exporting,\r\n label: <>\r\n {i18n(\"Copy to Clipboard\")}\r\n <Typography.Text code style={{float: \"right\"}}>CTRL+C</Typography.Text>\r\n </>,\r\n }\r\n ];\r\n\r\n if (renderer) {\r\n menuItems = renderer(menuItems);\r\n }\r\n\r\n return {\r\n items: menuItems,\r\n onClick: (item) => {\r\n onExportMenuClick(item.key);\r\n if (onClick) {\r\n onClick(item.key.toString());\r\n }\r\n },\r\n }\r\n}\r\n"]}
@@ -1,29 +1,50 @@
1
1
  import React from "react";
2
2
  import { ProgressProps } from "antd/lib/progress/progress";
3
+ /** Properties of {@link ProgressBar}: antd `Progress` properties plus the registration of the update handler. */
3
4
  interface ProgressBarProps extends ProgressProps {
5
+ /** Called on mount with a function that sets the displayed percentage, and with `null` on unmount. */
4
6
  registerUpdateHandler(updateHandler: ((percent: number) => void) | null): void;
5
7
  }
6
8
  interface ProgressBarState {
7
9
  percent: number;
8
10
  }
11
+ /** antd `Progress` whose percentage is set imperatively through the function passed to `registerUpdateHandler`; used by {@link ProgressPopup}. */
9
12
  export declare class ProgressBar extends React.Component<ProgressBarProps, ProgressBarState> {
10
13
  constructor(props: Readonly<ProgressBarProps>);
11
14
  componentDidMount(): void;
12
15
  componentWillUnmount(): void;
16
+ /** Sets the displayed percentage. */
13
17
  makeProgress(percent: number): void;
14
18
  render(): React.JSX.Element;
15
19
  }
20
+ /**
21
+ * Progress notification of a long-running operation such as a grid export, shown as an antd notification in the
22
+ * corner. All instances share one notification key, so only one progress notification is shown at a time.
23
+ *
24
+ * The notification opens on the first {@link update}; `update(100)` replaces it with a success notification.
25
+ */
16
26
  export default class ProgressPopup {
27
+ /** Notification title, followed by the record count when {@link setRecordCount} was called. */
17
28
  title: string;
29
+ /** Record count shown in the title. */
18
30
  recordCount?: number;
31
+ /** Sets the percentage of the shown progress bar; `null` while no progress bar is mounted. */
19
32
  makeProgress: ((percent: number) => void) | null;
33
+ /** Whether the progress notification is open. */
20
34
  progressVisible: boolean;
35
+ /** @param title - notification title, e.g. the name of the operation */
21
36
  constructor(title: string);
37
+ /** Opens the progress notification (without auto-close) and waits 100 ms for the progress bar to mount. */
22
38
  initializeProgressPopup(): Promise<void>;
39
+ /** Sets the record count shown in the title; takes effect for notifications shown afterwards. */
23
40
  setRecordCount(recordCount: number): void;
41
+ /** Opens the notification if it is not open and sets the progress; `100` closes it with a success notification. */
24
42
  update(progressPercent: number): Promise<void>;
43
+ /** Replaces the progress notification with a success notification. */
25
44
  close(): void;
45
+ /** Replaces the progress notification with an error notification. */
26
46
  error(): void;
47
+ /** Returns a promise resolved after `ms` milliseconds. */
27
48
  sleep(ms: number): Promise<void>;
28
49
  }
29
50
  export {};
@@ -13,6 +13,7 @@ import React from "react";
13
13
  import { LoadingOutlined } from "@ant-design/icons";
14
14
  import { notification, Progress } from "antd";
15
15
  import i18n from "d2core/i18n/i18n";
16
+ /** antd `Progress` whose percentage is set imperatively through the function passed to `registerUpdateHandler`; used by {@link ProgressPopup}. */
16
17
  export class ProgressBar extends React.Component {
17
18
  constructor(props) {
18
19
  super(props);
@@ -30,6 +31,7 @@ export class ProgressBar extends React.Component {
30
31
  this.props.registerUpdateHandler(null);
31
32
  }
32
33
  }
34
+ /** Sets the displayed percentage. */
33
35
  makeProgress(percent) {
34
36
  this.setState({ percent: percent });
35
37
  }
@@ -38,12 +40,22 @@ export class ProgressBar extends React.Component {
38
40
  return React.createElement(Progress, Object.assign({ percent: this.state.percent }, rest));
39
41
  }
40
42
  }
43
+ /**
44
+ * Progress notification of a long-running operation such as a grid export, shown as an antd notification in the
45
+ * corner. All instances share one notification key, so only one progress notification is shown at a time.
46
+ *
47
+ * The notification opens on the first {@link update}; `update(100)` replaces it with a success notification.
48
+ */
41
49
  export default class ProgressPopup {
50
+ /** @param title - notification title, e.g. the name of the operation */
42
51
  constructor(title) {
52
+ /** Sets the percentage of the shown progress bar; `null` while no progress bar is mounted. */
43
53
  this.makeProgress = null;
54
+ /** Whether the progress notification is open. */
44
55
  this.progressVisible = false;
45
56
  this.title = title;
46
57
  }
58
+ /** Opens the progress notification (without auto-close) and waits 100 ms for the progress bar to mount. */
47
59
  async initializeProgressPopup() {
48
60
  notification.open({
49
61
  message: this.title + (this.recordCount === undefined ? "" : i18n(" (%{n} records)", { n: "" + this.recordCount })),
@@ -57,9 +69,11 @@ export default class ProgressPopup {
57
69
  this.progressVisible = true;
58
70
  await this.sleep(100);
59
71
  }
72
+ /** Sets the record count shown in the title; takes effect for notifications shown afterwards. */
60
73
  setRecordCount(recordCount) {
61
74
  this.recordCount = recordCount;
62
75
  }
76
+ /** Opens the notification if it is not open and sets the progress; `100` closes it with a success notification. */
63
77
  async update(progressPercent) {
64
78
  if (!this.progressVisible) {
65
79
  await this.initializeProgressPopup();
@@ -71,6 +85,7 @@ export default class ProgressPopup {
71
85
  this.makeProgress(progressPercent);
72
86
  }
73
87
  }
88
+ /** Replaces the progress notification with a success notification. */
74
89
  close() {
75
90
  notification.success({
76
91
  message: this.title + (this.recordCount === undefined ? "" : i18n(" (%{n} records)", { n: "" + this.recordCount })),
@@ -79,6 +94,7 @@ export default class ProgressPopup {
79
94
  });
80
95
  this.progressVisible = false;
81
96
  }
97
+ /** Replaces the progress notification with an error notification. */
82
98
  error() {
83
99
  notification.error({
84
100
  message: this.title + (this.recordCount === undefined ? "" : i18n(" (%{n} records)", { n: "" + this.recordCount })),
@@ -87,6 +103,7 @@ export default class ProgressPopup {
87
103
  });
88
104
  this.progressVisible = false;
89
105
  }
106
+ /** Returns a promise resolved after `ms` milliseconds. */
90
107
  sleep(ms) {
91
108
  return new Promise(resolve => setTimeout(resolve, ms));
92
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"progressPopup.js","sourceRoot":"","sources":["../../../../../components/grid/export/progressPopup.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAWpC,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAA6C;IAChF,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,OAAO,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AK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,WAAW,EAAC,CAAC,CAAC;YACjH,GAAG,EAAE,QAAQ;YACb,WAAW,EAAE,oBAAC,QAAQ,IAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,GAAG;SAC9D,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,EAAU;QACZ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {LoadingOutlined} from \"@ant-design/icons\";\r\nimport {notification, Progress} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {ProgressProps} from \"antd/lib/progress/progress\";\r\n\r\ninterface ProgressBarProps extends ProgressProps {\r\n registerUpdateHandler(updateHandler: ((percent: number) => void) | null): void\r\n}\r\n\r\ninterface ProgressBarState {\r\n percent: number\r\n}\r\n\r\nexport class ProgressBar extends React.Component<ProgressBarProps, ProgressBarState> {\r\n constructor(props: Readonly<ProgressBarProps>) {\r\n super(props);\r\n this.state = {\r\n percent: 0,\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n if (this.props.registerUpdateHandler) {\r\n this.props.registerUpdateHandler(this.makeProgress.bind(this));\r\n }\r\n }\r\n\r\n componentWillUnmount() {\r\n if (this.props.registerUpdateHandler) {\r\n this.props.registerUpdateHandler(null);\r\n }\r\n }\r\n\r\n makeProgress(percent: number) {\r\n this.setState({percent: percent});\r\n }\r\n\r\n render() {\r\n const {registerUpdateHandler, ...rest} = this.props;\r\n return <Progress percent={this.state.percent} {...rest}/>;\r\n }\r\n}\r\n\r\nexport default class ProgressPopup {\r\n title: string;\r\n recordCount?: number;\r\n makeProgress: ((percent: number) => void) | null = null;\r\n progressVisible: boolean = false;\r\n\r\n constructor(title: string) {\r\n this.title = title;\r\n }\r\n\r\n async initializeProgressPopup() {\r\n notification.open({\r\n message: this.title + (this.recordCount === undefined ? \"\" : i18n(\" (%{n} records)\", {n: \"\" + this.recordCount})),\r\n key: \"export\",\r\n description: <ProgressBar registerUpdateHandler={(makeProgress) => {\r\n this.makeProgress = makeProgress;\r\n }}/>,\r\n icon: <LoadingOutlined/>,\r\n duration: 0\r\n });\r\n this.progressVisible = true;\r\n await this.sleep(100);\r\n }\r\n\r\n setRecordCount(recordCount: number) {\r\n this.recordCount = recordCount;\r\n }\r\n\r\n async update(progressPercent: number) {\r\n if (!this.progressVisible) {\r\n await this.initializeProgressPopup();\r\n }\r\n if (progressPercent === 100) {\r\n this.close();\r\n }\r\n if (this.makeProgress) {\r\n this.makeProgress(progressPercent);\r\n }\r\n }\r\n\r\n close() {\r\n notification.success({\r\n message: this.title + (this.recordCount === undefined ? \"\" : i18n(\" (%{n} records)\", {n: \"\" + this.recordCount})),\r\n key: \"export\",\r\n description: <Progress percent={100}/>\r\n });\r\n this.progressVisible = false;\r\n }\r\n\r\n error() {\r\n notification.error({\r\n message: this.title + (this.recordCount === undefined ? \"\" : i18n(\" (%{n} records)\", {n: \"\" + this.recordCount})),\r\n key: \"export\",\r\n description: <Progress status={\"exception\"} percent={100}/>\r\n });\r\n this.progressVisible = false;\r\n }\r\n\r\n sleep(ms: number): Promise<void> {\r\n return new Promise(resolve => setTimeout(resolve, ms));\r\n }\r\n}"]}
1
+ {"version":3,"file":"progressPopup.js","sourceRoot":"","sources":["../../../../../components/grid/export/progressPopup.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,IAAI,MAAM,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E,GAAG,IAAI,CAAC,WAAW,EAAC,CAAC,CAAC;YACjH,GAAG,EAAE,QAAQ;YACb,WAAW,EAAE,oBAAC,QAAQ,IAAC,OAAO,EAAE,GAAG,GAAG;SACzC,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IACjC,CAAC;IAED,qEAAqE;IACrE,KAAK;QACD,YAAY,CAAC,KAAK,CAAC;YACf,OAAO,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,WAAW,EAAC,CAAC,CAAC;YACjH,GAAG,EAAE,QAAQ;YACb,WAAW,EAAE,oBAAC,QAAQ,IAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,GAAG;SAC9D,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IACjC,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,EAAU;QACZ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {LoadingOutlined} from \"@ant-design/icons\";\r\nimport {notification, Progress} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {ProgressProps} from \"antd/lib/progress/progress\";\r\n\r\n/** Properties of {@link ProgressBar}: antd `Progress` properties plus the registration of the update handler. */\r\ninterface ProgressBarProps extends ProgressProps {\r\n /** Called on mount with a function that sets the displayed percentage, and with `null` on unmount. */\r\n registerUpdateHandler(updateHandler: ((percent: number) => void) | null): void\r\n}\r\n\r\ninterface ProgressBarState {\r\n percent: number\r\n}\r\n\r\n/** antd `Progress` whose percentage is set imperatively through the function passed to `registerUpdateHandler`; used by {@link ProgressPopup}. */\r\nexport class ProgressBar extends React.Component<ProgressBarProps, ProgressBarState> {\r\n constructor(props: Readonly<ProgressBarProps>) {\r\n super(props);\r\n this.state = {\r\n percent: 0,\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n if (this.props.registerUpdateHandler) {\r\n this.props.registerUpdateHandler(this.makeProgress.bind(this));\r\n }\r\n }\r\n\r\n componentWillUnmount() {\r\n if (this.props.registerUpdateHandler) {\r\n this.props.registerUpdateHandler(null);\r\n }\r\n }\r\n\r\n /** Sets the displayed percentage. */\r\n makeProgress(percent: number) {\r\n this.setState({percent: percent});\r\n }\r\n\r\n render() {\r\n const {registerUpdateHandler, ...rest} = this.props;\r\n return <Progress percent={this.state.percent} {...rest}/>;\r\n }\r\n}\r\n\r\n/**\r\n * Progress notification of a long-running operation such as a grid export, shown as an antd notification in the\r\n * corner. All instances share one notification key, so only one progress notification is shown at a time.\r\n *\r\n * The notification opens on the first {@link update}; `update(100)` replaces it with a success notification.\r\n */\r\nexport default class ProgressPopup {\r\n /** Notification title, followed by the record count when {@link setRecordCount} was called. */\r\n title: string;\r\n /** Record count shown in the title. */\r\n recordCount?: number;\r\n /** Sets the percentage of the shown progress bar; `null` while no progress bar is mounted. */\r\n makeProgress: ((percent: number) => void) | null = null;\r\n /** Whether the progress notification is open. */\r\n progressVisible: boolean = false;\r\n\r\n /** @param title - notification title, e.g. the name of the operation */\r\n constructor(title: string) {\r\n this.title = title;\r\n }\r\n\r\n /** Opens the progress notification (without auto-close) and waits 100 ms for the progress bar to mount. */\r\n async initializeProgressPopup() {\r\n notification.open({\r\n message: this.title + (this.recordCount === undefined ? \"\" : i18n(\" (%{n} records)\", {n: \"\" + this.recordCount})),\r\n key: \"export\",\r\n description: <ProgressBar registerUpdateHandler={(makeProgress) => {\r\n this.makeProgress = makeProgress;\r\n }}/>,\r\n icon: <LoadingOutlined/>,\r\n duration: 0\r\n });\r\n this.progressVisible = true;\r\n await this.sleep(100);\r\n }\r\n\r\n /** Sets the record count shown in the title; takes effect for notifications shown afterwards. */\r\n setRecordCount(recordCount: number) {\r\n this.recordCount = recordCount;\r\n }\r\n\r\n /** Opens the notification if it is not open and sets the progress; `100` closes it with a success notification. */\r\n async update(progressPercent: number) {\r\n if (!this.progressVisible) {\r\n await this.initializeProgressPopup();\r\n }\r\n if (progressPercent === 100) {\r\n this.close();\r\n }\r\n if (this.makeProgress) {\r\n this.makeProgress(progressPercent);\r\n }\r\n }\r\n\r\n /** Replaces the progress notification with a success notification. */\r\n close() {\r\n notification.success({\r\n message: this.title + (this.recordCount === undefined ? \"\" : i18n(\" (%{n} records)\", {n: \"\" + this.recordCount})),\r\n key: \"export\",\r\n description: <Progress percent={100}/>\r\n });\r\n this.progressVisible = false;\r\n }\r\n\r\n /** Replaces the progress notification with an error notification. */\r\n error() {\r\n notification.error({\r\n message: this.title + (this.recordCount === undefined ? \"\" : i18n(\" (%{n} records)\", {n: \"\" + this.recordCount})),\r\n key: \"export\",\r\n description: <Progress status={\"exception\"} percent={100}/>\r\n });\r\n this.progressVisible = false;\r\n }\r\n\r\n /** Returns a promise resolved after `ms` milliseconds. */\r\n sleep(ms: number): Promise<void> {\r\n return new Promise(resolve => setTimeout(resolve, ms));\r\n }\r\n}"]}
@@ -6,9 +6,11 @@ import { Observable, Subject } from "threads/observable";
6
6
  import { LocaleHolder } from "d2core/i18n/localeHolder";
7
7
  pdfMake.vfs = pdfFonts;
8
8
  function getPdfConfig(tableData, pageConfig) {
9
+ // styling header
9
10
  tableData[0] = tableData[0].map((value) => {
10
11
  return { text: value, style: 'tableHeader' };
11
12
  });
13
+ // escaping empty data
12
14
  tableData.forEach((row) => {
13
15
  row.forEach((value, index) => {
14
16
  if (value === undefined || value === null) {
@@ -21,6 +23,8 @@ function getPdfConfig(tableData, pageConfig) {
21
23
  style: 'tableExample',
22
24
  table: {
23
25
  headerRows: 1,
26
+ // dontBreakRows: true,
27
+ // keepWithHeaderRows: 1,
24
28
  body: tableData
25
29
  }
26
30
  }],
@@ -44,6 +48,7 @@ function getPdfConfig(tableData, pageConfig) {
44
48
  }
45
49
  },
46
50
  defaultStyle: {
51
+ // alignment: 'justify',
47
52
  fontSize: 10,
48
53
  },
49
54
  footer: function (currentPage, pageCount) {
@@ -1 +1 @@
1
- {"version":3,"file":"pdfExport.js","sourceRoot":"","sources":["../../../../../../components/grid/export/worker/pdfExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAA;AACrC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAE5C,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAE,OAAO,EAAC,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEtD,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC;AAQvB,SAAS,YAAY,CAAC,SAAwB,EAAE,UAAsB;IAElE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACtC,OAAO,EAAC,IAAI,EAAE,KAAe,EAAE,KAAK,EAAE,aAAa,EAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACtB,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACzB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACxC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACpB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO;QACH,OAAO,EAAE,CAAC;gBACN,KAAK,EAAE,cAAc;gBACrB,KAAK,EAAE;oBACH,UAAU,EAAE,CAAC;oBAGb,IAAI,EAAE,SAA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AAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YACtE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import {expose} from \"threads/worker\"\nimport pdfMake from \"pdfmake/build/pdfmake\";\nimport {PageOrientation, TDocumentDefinitions} from \"pdfmake/interfaces\";\nimport pdfFonts from \"pdfmake/build/vfs_fonts\";\nimport dayjs from \"dayjs\";\nimport {Observable, Subject} from \"threads/observable\"\nimport {LocaleHolder} from \"d2core/i18n/localeHolder\";\n\npdfMake.vfs = pdfFonts;\n\ninterface PageConfig {\n pageOrientation: PageOrientation\n}\n\ntype TableCell = string | { text: string, style: string }\n\nfunction getPdfConfig(tableData: TableCell[][], pageConfig: PageConfig): TDocumentDefinitions {\n // styling header\n tableData[0] = tableData[0].map((value) => {\n return {text: value as string, style: 'tableHeader'};\n });\n // escaping empty data\n tableData.forEach((row) => {\n row.forEach((value, index) => {\n if (value === undefined || value === null) {\n row[index] = \"\";\n }\n });\n });\n return {\n content: [{\n style: 'tableExample',\n table: {\n headerRows: 1,\n // dontBreakRows: true,\n // keepWithHeaderRows: 1,\n body: tableData\n }\n }],\n styles: {\n header: {\n fontSize: 10,\n bold: true,\n margin: [0, 0, 0, 10]\n },\n subheader: {\n fontSize: 9,\n bold: true,\n margin: [0, 10, 0, 5]\n },\n tableExample: {\n margin: [0, 5, 0, 15],\n\n },\n tableHeader: {\n bold: true,\n fontSize: 10,\n }\n },\n defaultStyle: {\n // alignment: 'justify',\n fontSize: 10,\n },\n footer: function (currentPage: number, pageCount: number) {\n return {\n table: {\n widths: ['*'],\n body: [\n [\n {text: `${currentPage}/${pageCount}`, alignment: 'center'},\n ]\n ]\n },\n layout: 'noBorders'\n };\n },\n info: {\n title: `Export ${dayjs().format(LocaleHolder.getDateTimeFormat(true, true))}`,\n author: 'D2000',\n },\n pageOrientation: pageConfig.pageOrientation\n };\n}\n\nconst subject = new Subject();\nconst pdfExport = {\n export(tableData: TableCell[][], pageConfig: PageConfig) {\n pdfMake.createPdf(getPdfConfig(tableData, pageConfig)).getBase64((data) => {\n subject.next(data);\n subject.complete();\n });\n },\n handler() {\n return Observable.from(subject);\n },\n};\n\nexpose(pdfExport);"]}
1
+ {"version":3,"file":"pdfExport.js","sourceRoot":"","sources":["../../../../../../components/grid/export/worker/pdfExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAA;AACrC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAE5C,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAE,OAAO,EAAC,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEtD,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC;AAQvB,SAAS,YAAY,CAAC,SAAwB,EAAE,UAAsB;IAClE,iBAAiB;IACjB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACtC,OAAO,EAAC,IAAI,EAAE,KAAe,EAAE,KAAK,EAAE,aAAa,EAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,sBAAsB;IACtB,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACtB,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACzB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACxC,GAAG,CAAC,KAAK,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,EAAE,OAAO;SAClB;QACD,eAAe,EAAE,UAAU,CAAC,eAAe;KAC9C,CAAC;AACN,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,MAAM,SAAS,GAAG;IACd,MAAM,CAAC,SAAwB,EAAE,UAAsB;QACnD,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YACtE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import {expose} from \"threads/worker\"\r\nimport pdfMake from \"pdfmake/build/pdfmake\";\r\nimport {PageOrientation, TDocumentDefinitions} from \"pdfmake/interfaces\";\r\nimport pdfFonts from \"pdfmake/build/vfs_fonts\";\r\nimport dayjs from \"dayjs\";\r\nimport {Observable, Subject} from \"threads/observable\"\r\nimport {LocaleHolder} from \"d2core/i18n/localeHolder\";\r\n\r\npdfMake.vfs = pdfFonts;\r\n\r\ninterface PageConfig {\r\n pageOrientation: PageOrientation\r\n}\r\n\r\ntype TableCell = string | { text: string, style: string }\r\n\r\nfunction getPdfConfig(tableData: TableCell[][], pageConfig: PageConfig): TDocumentDefinitions {\r\n // styling header\r\n tableData[0] = tableData[0].map((value) => {\r\n return {text: value as string, style: 'tableHeader'};\r\n });\r\n // escaping empty data\r\n tableData.forEach((row) => {\r\n row.forEach((value, index) => {\r\n if (value === undefined || value === null) {\r\n row[index] = \"\";\r\n }\r\n });\r\n });\r\n return {\r\n content: [{\r\n style: 'tableExample',\r\n table: {\r\n headerRows: 1,\r\n // dontBreakRows: true,\r\n // keepWithHeaderRows: 1,\r\n body: tableData\r\n }\r\n }],\r\n styles: {\r\n header: {\r\n fontSize: 10,\r\n bold: true,\r\n margin: [0, 0, 0, 10]\r\n },\r\n subheader: {\r\n fontSize: 9,\r\n bold: true,\r\n margin: [0, 10, 0, 5]\r\n },\r\n tableExample: {\r\n margin: [0, 5, 0, 15],\r\n\r\n },\r\n tableHeader: {\r\n bold: true,\r\n fontSize: 10,\r\n }\r\n },\r\n defaultStyle: {\r\n // alignment: 'justify',\r\n fontSize: 10,\r\n },\r\n footer: function (currentPage: number, pageCount: number) {\r\n return {\r\n table: {\r\n widths: ['*'],\r\n body: [\r\n [\r\n {text: `${currentPage}/${pageCount}`, alignment: 'center'},\r\n ]\r\n ]\r\n },\r\n layout: 'noBorders'\r\n };\r\n },\r\n info: {\r\n title: `Export ${dayjs().format(LocaleHolder.getDateTimeFormat(true, true))}`,\r\n author: 'D2000',\r\n },\r\n pageOrientation: pageConfig.pageOrientation\r\n };\r\n}\r\n\r\nconst subject = new Subject();\r\nconst pdfExport = {\r\n export(tableData: TableCell[][], pageConfig: PageConfig) {\r\n pdfMake.createPdf(getPdfConfig(tableData, pageConfig)).getBase64((data) => {\r\n subject.next(data);\r\n subject.complete();\r\n });\r\n },\r\n handler() {\r\n return Observable.from(subject);\r\n },\r\n};\r\n\r\nexpose(pdfExport);"]}