d2coreui 23.0.52 → 23.0.54

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 +40 -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 +10 -1
  100. package/components/grid/columnUtils.js +11 -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 +45 -29
  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 +361 -12
  115. package/components/grid/dataGrid.js +201 -28
  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 +249 -4
  129. package/components/grid/extendedDataGrid.js +160 -19
  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":"statusTextCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/statusTextCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,MAAM,CAAC;AACzC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAC,YAAY,EAAC,MAAM,0B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AoB,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {InputNumber, Select} from \"antd\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {LocaleHolder} from \"d2core/i18n/localeHolder\";\r\nimport scrollIntoView from \"dom-scroll-into-view\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\ninterface StatusTextCellEditorProperties extends CustomCellEditorProps {\r\n decimalSeparator?: string\r\n precision?: number\r\n statusTexts: { text: string, value: number }[];\r\n}\r\n\r\ninterface StatusTextCellEditorState {\r\n value: number | null\r\n opened: boolean\r\n}\r\n\r\nclass StatusTextCellEditor extends DataGridCellEditorComponent<StatusTextCellEditorProperties, StatusTextCellEditorState> {\r\n private inputComponent: HTMLInputElement | null = null;\r\n private containerRef = React.createRef<HTMLDivElement>();\r\n\r\n constructor(props: Readonly<StatusTextCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<StatusTextCellEditorProperties>): StatusTextCellEditorState {\r\n let value: number | null;\r\n\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n const parsedValue = Number.parseInt(props.eventKey);\r\n value = isNaN(parsedValue) ? props.value : parsedValue;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.initialValue;\r\n }\r\n return {value: value} as StatusTextCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.value ? this.inputComponent?.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n isCancelBeforeStart(): boolean {\r\n return !!this.props.eventKey && this.props.eventKey.length === 1 && '1234567890'.indexOf(this.props.eventKey) < 0;\r\n }\r\n\r\n // noinspection DuplicatedCode\r\n getScrollParent(element: HTMLElement, includeHidden = false): HTMLElement {\r\n var style = getComputedStyle(element);\r\n var excludeStaticParent = style.position === \"absolute\";\r\n var overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;\r\n if (style.position === \"fixed\") return document.body;\r\n let parent: HTMLElement | null;\r\n for (parent = element; (parent = parent.parentElement);) {\r\n style = getComputedStyle(parent);\r\n if (excludeStaticParent && style.position === \"static\") {\r\n continue;\r\n }\r\n if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;\r\n }\r\n return document.body;\r\n }\r\n\r\n scrollTo(value: number) {\r\n const elementToScroll = document.getElementById(\"select-value-\" + value);\r\n if (elementToScroll) {\r\n const parent = this.getScrollParent(elementToScroll, true);\r\n scrollIntoView(elementToScroll, parent, {\r\n onlyScrollIfNeeded: true,\r\n allowHorizontalScroll: false,\r\n alignWithTop: true,\r\n offsetTop: 20,\r\n offsetBottom: 20,\r\n });\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n <div style={{width: \"100%\", minWidth: 150}} ref={this.containerRef}>\r\n <Select<number>\r\n size={\"small\"}\r\n virtual={false}\r\n popupMatchSelectWidth={false}\r\n className={\"select-with-one-item\"}\r\n style={{width: \"100%\", overflow: \"auto\", visibility: \"hidden\"}}\r\n styles={{popup: {root: {maxHeight: 400, overflow: 'auto'}}}}\r\n allowClear\r\n dropdownAlign={{points: [\"tl\", \"tr\"], offset: [0, -100], overflow: {adjustX: true, adjustY: true}}}\r\n filterOption={(inputValue, option) => {\r\n const inputToSearch = inputValue.toLocaleLowerCase(LocaleHolder.formattingLocale);\r\n const value: number = option?.value as number;\r\n return (value?.toString().indexOf(inputToSearch) >= 0) || ((option?.title?.toLocaleLowerCase(LocaleHolder.formattingLocale).indexOf(inputToSearch) ?? -1) >= 0);\r\n }}\r\n value={this.state.value !== null ? this.state.value : undefined}\r\n onChange={(value) => {\r\n this.setState({value: value});\r\n this.props.onValueChange(value);\r\n }}\r\n open={this.state.opened}\r\n onOpenChange={(visible) => {\r\n this.setState({opened: visible});\r\n }}\r\n getPopupContainer={() => {\r\n // very nasty trick how to keep select's popup within focusable area of ag-grid cell editor popup (prevent closing cell editor when we click in select's dropdown area)\r\n return (this.containerRef.current?.parentNode ?? document.body) as HTMLElement;\r\n }}\r\n >\r\n {this.props.statusTexts?.map((statusTextItem) => {\r\n return <Select.Option\r\n id={\"select-value-\" + statusTextItem.value}\r\n key={\"\" + statusTextItem.value}\r\n value={statusTextItem.value}\r\n title={statusTextItem.text}\r\n >\r\n <span style={{\r\n color: \"rgba(0, 0, 0, 0.85)\",\r\n whiteSpace: \"nowrap\"\r\n }}>{`${statusTextItem.text} (${statusTextItem.value})`}</span>\r\n </Select.Option>;\r\n })}\r\n </Select>\r\n <InputNumber\r\n ref={(component) => {\r\n this.inputComponent = component;\r\n }}\r\n size=\"small\"\r\n style={{\r\n position: \"absolute\",\r\n top: 0,\r\n bottom: 0,\r\n left: 0,\r\n right: 0,\r\n width: \"100%\"\r\n }}\r\n autoFocus\r\n decimalSeparator={this.props.decimalSeparator}\r\n precision={this.props.precision}\r\n placeholder={this.state.value === null ? \"NULL\" : \"\"}\r\n value={this.state.value !== undefined && this.state.value !== null ? this.state.value : undefined}\r\n onChange={value => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n if (typeof value === \"number\") {\r\n this.setState({value: value, opened: true});\r\n this.scrollTo(value);\r\n this.props.onValueChange(value);\r\n } else if (value === undefined || value === \"\") {\r\n this.setState({value: null, opened: true});\r\n this.props.onValueChange(null);\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.ArrowUp || e.key === Key.ArrowDown) {\r\n this.props.onKeyDown(e.nativeEvent);\r\n e.preventDefault();\r\n }\r\n }}\r\n onFocus={() => {\r\n this.setState({opened: true});\r\n }}\r\n onClick={() => {\r\n this.setState({opened: true});\r\n }}\r\n />\r\n </div>\r\n );\r\n }\r\n}\r\n\r\nexport default withAgGridHooks(StatusTextCellEditor)"]}
1
+ {"version":3,"file":"statusTextCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/statusTextCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,MAAM,CAAC;AACzC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAiB3F,MAAM,oBAAqB,SAAQ,2BAAsF;IAIrH,YAAY,KAA+C;QACvD,KAAK,CAAC,KAAK,CAAC,CAAC;QAJT,mBAAc,GAA4B,IAAI,CAAC;QAC/C,iBAAY,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAIrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,eAAe,CAAC,KAA+C;QAC3D,IAAI,KAAoB,CAAC;QAEzB,IAAI,KAAK,CAAC,QAAQ,KAAK,GAAG,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;YACpE,oDAAoD;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S,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;wBAC7C,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;wBAC3C,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;oBACnC,CAAC;gBACL,CAAC,EACD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,SAAS,EAAE,CAAC;wBACnD,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;wBACpC,CAAC,CAAC,cAAc,EAAE,CAAC;oBACvB,CAAC;gBACL,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;oBACV,IAAI,CAAC,QAAQ,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;gBAClC,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;oBACV,IAAI,CAAC,QAAQ,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;gBAClC,CAAC,GACH,CACA,CACT,CAAC;IACN,CAAC;CACJ;AAED;;;;;;GAMG;AACH,eAAe,eAAe,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {InputNumber, Select} from \"antd\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {LocaleHolder} from \"d2core/i18n/localeHolder\";\r\nimport scrollIntoView from \"dom-scroll-into-view\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\n/** Props of {@link StatusTextCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface StatusTextCellEditorProperties extends CustomCellEditorProps {\r\n /** Decimal separator of the numeric input. */\r\n decimalSeparator?: string\r\n /** Number of decimal places of the numeric input. */\r\n precision?: number\r\n /** Items offered in the dropdown; `value` is the number stored in the cell and `text` its label (shown as `text (value)`). */\r\n statusTexts: { text: string, value: number }[];\r\n}\r\n\r\ninterface StatusTextCellEditorState {\r\n value: number | null\r\n opened: boolean\r\n}\r\n\r\nclass StatusTextCellEditor extends DataGridCellEditorComponent<StatusTextCellEditorProperties, StatusTextCellEditorState> {\r\n private inputComponent: HTMLInputElement | null = null;\r\n private containerRef = React.createRef<HTMLDivElement>();\r\n\r\n constructor(props: Readonly<StatusTextCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<StatusTextCellEditorProperties>): StatusTextCellEditorState {\r\n let value: number | null;\r\n\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n const parsedValue = Number.parseInt(props.eventKey);\r\n value = isNaN(parsedValue) ? props.value : parsedValue;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.initialValue;\r\n }\r\n return {value: value} as StatusTextCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.value ? this.inputComponent?.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n isCancelBeforeStart(): boolean {\r\n return !!this.props.eventKey && this.props.eventKey.length === 1 && '1234567890'.indexOf(this.props.eventKey) < 0;\r\n }\r\n\r\n // noinspection DuplicatedCode\r\n getScrollParent(element: HTMLElement, includeHidden = false): HTMLElement {\r\n var style = getComputedStyle(element);\r\n var excludeStaticParent = style.position === \"absolute\";\r\n var overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;\r\n if (style.position === \"fixed\") return document.body;\r\n let parent: HTMLElement | null;\r\n for (parent = element; (parent = parent.parentElement);) {\r\n style = getComputedStyle(parent);\r\n if (excludeStaticParent && style.position === \"static\") {\r\n continue;\r\n }\r\n if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;\r\n }\r\n return document.body;\r\n }\r\n\r\n scrollTo(value: number) {\r\n const elementToScroll = document.getElementById(\"select-value-\" + value);\r\n if (elementToScroll) {\r\n const parent = this.getScrollParent(elementToScroll, true);\r\n scrollIntoView(elementToScroll, parent, {\r\n onlyScrollIfNeeded: true,\r\n allowHorizontalScroll: false,\r\n alignWithTop: true,\r\n offsetTop: 20,\r\n offsetBottom: 20,\r\n });\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n <div style={{width: \"100%\", minWidth: 150}} ref={this.containerRef}>\r\n <Select<number>\r\n size={\"small\"}\r\n virtual={false}\r\n popupMatchSelectWidth={false}\r\n className={\"select-with-one-item\"}\r\n style={{width: \"100%\", overflow: \"auto\", visibility: \"hidden\"}}\r\n styles={{popup: {root: {maxHeight: 400, overflow: 'auto'}}}}\r\n allowClear\r\n dropdownAlign={{points: [\"tl\", \"tr\"], offset: [0, -100], overflow: {adjustX: true, adjustY: true}}}\r\n filterOption={(inputValue, option) => {\r\n const inputToSearch = inputValue.toLocaleLowerCase(LocaleHolder.formattingLocale);\r\n const value: number = option?.value as number;\r\n return (value?.toString().indexOf(inputToSearch) >= 0) || ((option?.title?.toLocaleLowerCase(LocaleHolder.formattingLocale).indexOf(inputToSearch) ?? -1) >= 0);\r\n }}\r\n value={this.state.value !== null ? this.state.value : undefined}\r\n onChange={(value) => {\r\n this.setState({value: value});\r\n this.props.onValueChange(value);\r\n }}\r\n open={this.state.opened}\r\n onOpenChange={(visible) => {\r\n this.setState({opened: visible});\r\n }}\r\n getPopupContainer={() => {\r\n // very nasty trick how to keep select's popup within focusable area of ag-grid cell editor popup (prevent closing cell editor when we click in select's dropdown area)\r\n return (this.containerRef.current?.parentNode ?? document.body) as HTMLElement;\r\n }}\r\n >\r\n {this.props.statusTexts?.map((statusTextItem) => {\r\n return <Select.Option\r\n id={\"select-value-\" + statusTextItem.value}\r\n key={\"\" + statusTextItem.value}\r\n value={statusTextItem.value}\r\n title={statusTextItem.text}\r\n >\r\n <span style={{\r\n color: \"rgba(0, 0, 0, 0.85)\",\r\n whiteSpace: \"nowrap\"\r\n }}>{`${statusTextItem.text} (${statusTextItem.value})`}</span>\r\n </Select.Option>;\r\n })}\r\n </Select>\r\n <InputNumber\r\n ref={(component) => {\r\n this.inputComponent = component;\r\n }}\r\n size=\"small\"\r\n style={{\r\n position: \"absolute\",\r\n top: 0,\r\n bottom: 0,\r\n left: 0,\r\n right: 0,\r\n width: \"100%\"\r\n }}\r\n autoFocus\r\n decimalSeparator={this.props.decimalSeparator}\r\n precision={this.props.precision}\r\n placeholder={this.state.value === null ? \"NULL\" : \"\"}\r\n value={this.state.value !== undefined && this.state.value !== null ? this.state.value : undefined}\r\n onChange={value => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n if (typeof value === \"number\") {\r\n this.setState({value: value, opened: true});\r\n this.scrollTo(value);\r\n this.props.onValueChange(value);\r\n } else if (value === undefined || value === \"\") {\r\n this.setState({value: null, opened: true});\r\n this.props.onValueChange(null);\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.ArrowUp || e.key === Key.ArrowDown) {\r\n this.props.onKeyDown(e.nativeEvent);\r\n e.preventDefault();\r\n }\r\n }}\r\n onFocus={() => {\r\n this.setState({opened: true});\r\n }}\r\n onClick={() => {\r\n this.setState({opened: true});\r\n }}\r\n />\r\n </div>\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor for a number with a list of status texts as a hint (registered in `DataGrid` as\r\n * `statusTextCellEditor`). The user types a number into an `InputNumber` and the dropdown scrolls to the matching\r\n * status text, or picks an item from the dropdown. Starts from `initialValue`, from the typed digit, or from `null` on\r\n * Backspace/Delete; other printable keys cancel editing. Reports `number | null` through `onValueChange`; Arrow\r\n * Up/Down are forwarded to the grid.\r\n */\r\nexport default withAgGridHooks(StatusTextCellEditor)"]}
@@ -1,20 +1,51 @@
1
1
  import { RGBColor } from "react-color";
2
+ /**
3
+ * CSS style of a grid row, keyed by camelCase CSS property (`fontSize`, `color`, `backgroundColor`, `fontWeight`, ...).
4
+ * `color` and `backgroundColor` may be `react-color` {@link RGBColor} objects and `fontSize` a number of pixels;
5
+ * `DataGrid` converts these to CSS. The non-CSS key `rowHeightDelta` is the vertical padding in pixels above and
6
+ * below the text (row height = font size + 2 * delta) and is turned into `lineHeight`.
7
+ */
2
8
  export interface GridRowStyle {
9
+ /** Value of the CSS property (string, number or {@link RGBColor}). */
3
10
  [cssProperty: string]: string | number | RGBColor;
4
11
  }
12
+ /**
13
+ * Conditional row style used by `DataGrid`'s `rowStyleRules`. Rules are applied in order and a later matching rule
14
+ * overrides properties set by an earlier one. The rules with keys `table-font-size` and `table-line-indentation`
15
+ * also determine the grid's row height.
16
+ */
5
17
  export interface RowStyleRule {
18
+ /** Label shown in the row style editor; translated through `i18n`. */
6
19
  name: string;
20
+ /** When set, the row style editor shows a divider with this (translated) caption above the rule. */
7
21
  divider?: string;
22
+ /** Unique identifier of the rule. */
8
23
  key: string;
24
+ /**
25
+ * `filtrex` expression evaluated against the row's data object; the style is applied only when it is truthy.
26
+ * `null` (or empty) applies the style to all rows.
27
+ */
9
28
  expression: string | null;
29
+ /** Style applied to matching rows. */
10
30
  style: GridRowStyle;
31
+ /** Which style properties the user may edit for this rule in the row style editor; omitted means none. */
11
32
  styleEditor?: {
33
+ /** Allow editing the background color. */
12
34
  backgroundColor?: boolean;
35
+ /** Allow editing the text color. */
13
36
  color?: boolean;
37
+ /** Allow editing the font size. */
14
38
  fontSize?: boolean;
39
+ /** Allow editing the font weight. */
15
40
  fontWeight?: boolean;
41
+ /** Allow editing the row height delta (line indentation). */
16
42
  rowHeightDelta?: boolean;
17
43
  };
18
44
  }
45
+ /**
46
+ * Creates the default row style rules of a grid: `table-font-size` (font size {@link GRID_DEFAULT_FONT_SIZE}) and
47
+ * `table-line-indentation` (row height delta {@link GRID_DEFAULT_ROW_HEIGHT_DELTA}), both applying to all rows.
48
+ * Returns a new array on every call, so callers may extend or mutate it.
49
+ */
19
50
  declare const tableDefaultRowStyleRules: () => RowStyleRule[];
20
51
  export default tableDefaultRowStyleRules;
@@ -1,4 +1,9 @@
1
1
  import { GRID_DEFAULT_FONT_SIZE, GRID_DEFAULT_ROW_HEIGHT_DELTA } from "../config/rowHeightCalculator";
2
+ /**
3
+ * Creates the default row style rules of a grid: `table-font-size` (font size {@link GRID_DEFAULT_FONT_SIZE}) and
4
+ * `table-line-indentation` (row height delta {@link GRID_DEFAULT_ROW_HEIGHT_DELTA}), both applying to all rows.
5
+ * Returns a new array on every call, so callers may extend or mutate it.
6
+ */
2
7
  const tableDefaultRowStyleRules = function () {
3
8
  return [
4
9
  {
@@ -1 +1 @@
1
- {"version":3,"file":"tableDefaultRowStyleRules.js","sourceRoot":"","sources":["../../../../../components/grid/cell/tableDefaultRowStyleRules.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAE,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAqBpG,MAAM,yBAAyB,GAAG;IAC9B,OAAO;QACH;YACI,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,UAAU;YACnB,GAAG,EAAE,iBAAiB;YACtB,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE;gBACH,QAAQ,EAAE,sBAAsB;aACnC;YACD,WAAW,EAAE;gBACT,QAAQ,EAAE,IAAI;aACjB;SACJ;QACD;YACI,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,wBAAwB;YAC7B,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE;gBACH,cAAc,EAAE,6BAA6B;aAChD;YACD,WAAW,EAAE;gBACT,cAAc,EAAE,IAAI;aACvB;SACJ;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC","sourcesContent":["import {RGBColor} from \"react-color\";\r\nimport {GRID_DEFAULT_FONT_SIZE, GRID_DEFAULT_ROW_HEIGHT_DELTA} from \"../config/rowHeightCalculator\";\r\n\r\nexport interface GridRowStyle {\r\n [cssProperty: string]: string | number | RGBColor\r\n}\r\n\r\nexport interface RowStyleRule {\r\n name: string\r\n divider?: string\r\n key: string\r\n expression: string | null\r\n style: GridRowStyle\r\n styleEditor?: {\r\n backgroundColor?: boolean\r\n color?: boolean\r\n fontSize?: boolean\r\n fontWeight?: boolean\r\n rowHeightDelta?: boolean\r\n }\r\n}\r\n\r\nconst tableDefaultRowStyleRules = function (): RowStyleRule[] {\r\n return [\r\n {\r\n name: \"Font Size\",\r\n divider: \"All Rows\",\r\n key: \"table-font-size\",\r\n expression: null,\r\n style: {\r\n fontSize: GRID_DEFAULT_FONT_SIZE\r\n },\r\n styleEditor: {\r\n fontSize: true,\r\n }\r\n },\r\n {\r\n name: \"Line Indentation\",\r\n key: \"table-line-indentation\",\r\n expression: null,\r\n style: {\r\n rowHeightDelta: GRID_DEFAULT_ROW_HEIGHT_DELTA\r\n },\r\n styleEditor: {\r\n rowHeightDelta: true,\r\n }\r\n }\r\n ];\r\n};\r\n\r\nexport default tableDefaultRowStyleRules;"]}
1
+ {"version":3,"file":"tableDefaultRowStyleRules.js","sourceRoot":"","sources":["../../../../../components/grid/cell/tableDefaultRowStyleRules.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAE,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AA+CpG;;;;GAIG;AACH,MAAM,yBAAyB,GAAG;IAC9B,OAAO;QACH;YACI,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,UAAU;YACnB,GAAG,EAAE,iBAAiB;YACtB,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE;gBACH,QAAQ,EAAE,sBAAsB;aACnC;YACD,WAAW,EAAE;gBACT,QAAQ,EAAE,IAAI;aACjB;SACJ;QACD;YACI,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,wBAAwB;YAC7B,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE;gBACH,cAAc,EAAE,6BAA6B;aAChD;YACD,WAAW,EAAE;gBACT,cAAc,EAAE,IAAI;aACvB;SACJ;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC","sourcesContent":["import {RGBColor} from \"react-color\";\r\nimport {GRID_DEFAULT_FONT_SIZE, GRID_DEFAULT_ROW_HEIGHT_DELTA} from \"../config/rowHeightCalculator\";\r\n\r\n/**\r\n * CSS style of a grid row, keyed by camelCase CSS property (`fontSize`, `color`, `backgroundColor`, `fontWeight`, ...).\r\n * `color` and `backgroundColor` may be `react-color` {@link RGBColor} objects and `fontSize` a number of pixels;\r\n * `DataGrid` converts these to CSS. The non-CSS key `rowHeightDelta` is the vertical padding in pixels above and\r\n * below the text (row height = font size + 2 * delta) and is turned into `lineHeight`.\r\n */\r\nexport interface GridRowStyle {\r\n /** Value of the CSS property (string, number or {@link RGBColor}). */\r\n [cssProperty: string]: string | number | RGBColor\r\n}\r\n\r\n/**\r\n * Conditional row style used by `DataGrid`'s `rowStyleRules`. Rules are applied in order and a later matching rule\r\n * overrides properties set by an earlier one. The rules with keys `table-font-size` and `table-line-indentation`\r\n * also determine the grid's row height.\r\n */\r\nexport interface RowStyleRule {\r\n /** Label shown in the row style editor; translated through `i18n`. */\r\n name: string\r\n /** When set, the row style editor shows a divider with this (translated) caption above the rule. */\r\n divider?: string\r\n /** Unique identifier of the rule. */\r\n key: string\r\n /**\r\n * `filtrex` expression evaluated against the row's data object; the style is applied only when it is truthy.\r\n * `null` (or empty) applies the style to all rows.\r\n */\r\n expression: string | null\r\n /** Style applied to matching rows. */\r\n style: GridRowStyle\r\n /** Which style properties the user may edit for this rule in the row style editor; omitted means none. */\r\n styleEditor?: {\r\n /** Allow editing the background color. */\r\n backgroundColor?: boolean\r\n /** Allow editing the text color. */\r\n color?: boolean\r\n /** Allow editing the font size. */\r\n fontSize?: boolean\r\n /** Allow editing the font weight. */\r\n fontWeight?: boolean\r\n /** Allow editing the row height delta (line indentation). */\r\n rowHeightDelta?: boolean\r\n }\r\n}\r\n\r\n/**\r\n * Creates the default row style rules of a grid: `table-font-size` (font size {@link GRID_DEFAULT_FONT_SIZE}) and\r\n * `table-line-indentation` (row height delta {@link GRID_DEFAULT_ROW_HEIGHT_DELTA}), both applying to all rows.\r\n * Returns a new array on every call, so callers may extend or mutate it.\r\n */\r\nconst tableDefaultRowStyleRules = function (): RowStyleRule[] {\r\n return [\r\n {\r\n name: \"Font Size\",\r\n divider: \"All Rows\",\r\n key: \"table-font-size\",\r\n expression: null,\r\n style: {\r\n fontSize: GRID_DEFAULT_FONT_SIZE\r\n },\r\n styleEditor: {\r\n fontSize: true,\r\n }\r\n },\r\n {\r\n name: \"Line Indentation\",\r\n key: \"table-line-indentation\",\r\n expression: null,\r\n style: {\r\n rowHeightDelta: GRID_DEFAULT_ROW_HEIGHT_DELTA\r\n },\r\n styleEditor: {\r\n rowHeightDelta: true,\r\n }\r\n }\r\n ];\r\n};\r\n\r\nexport default tableDefaultRowStyleRules;"]}
@@ -1,4 +1,10 @@
1
1
  import React from 'react';
2
2
  import { CustomCellEditorProps } from "ag-grid-react";
3
+ /**
4
+ * ag-grid cell editor for free text (registered in `DataGrid` as `textCellEditor`). Starts from `initialValue`, from the
5
+ * typed character when editing was started by typing, or from `null` on Backspace/Delete; reports `string | null`
6
+ * through `onValueChange` on every change (the placeholder shows `NULL` for a null value). Arrow Up/Down are forwarded
7
+ * to the grid and Delete does not propagate beyond the editor.
8
+ */
3
9
  declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
4
10
  export default _default;
@@ -12,14 +12,17 @@ class TextCellEditorComponent extends DataGridCellEditorComponent {
12
12
  getInitialState(props) {
13
13
  let value;
14
14
  if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
15
+ // if backspace or delete pressed, we clear the cell
15
16
  value = null;
16
17
  props.onValueChange(null);
17
18
  }
18
19
  else if (props.eventKey && props.eventKey.length === 1) {
20
+ // if a letter was pressed, we start with the letter
19
21
  value = props.eventKey;
20
22
  props.onValueChange(value);
21
23
  }
22
24
  else {
25
+ // otherwise we start with the current value
23
26
  value = props.initialValue;
24
27
  }
25
28
  return { value: value };
@@ -34,6 +37,10 @@ class TextCellEditorComponent extends DataGridCellEditorComponent {
34
37
  }
35
38
  placeCursorToEnd() {
36
39
  var _a, _b, _c, _d, _e;
40
+ // when we started editing, we want the carot at the end, not the start.
41
+ // this comes into play in two scenarios: a) when user hits F2 and b)
42
+ // when user hits a printable character, then on IE (and only IE) the carot
43
+ // was placed after the first character, thus 'apply' would end up as 'pplea'
37
44
  const length = ((_b = (_a = this.inputComponent) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.value) ? (_c = this.inputComponent) === null || _c === void 0 ? void 0 : _c.input.value.length : 0;
38
45
  if (length > 0) {
39
46
  (_e = (_d = this.inputComponent) === null || _d === void 0 ? void 0 : _d.input) === null || _e === void 0 ? void 0 : _e.setSelectionRange(length, length);
@@ -45,6 +52,7 @@ class TextCellEditorComponent extends DataGridCellEditorComponent {
45
52
  this.inputComponent = component;
46
53
  }, size: "small", autoFocus: true, placeholder: this.state.value === null ? "NULL" : "", value: this.state.value != undefined ? this.state.value : undefined, onChange: (event) => {
47
54
  if (KeyboardUtils.isKeyPressed(Key.Alt)) {
55
+ // ignore navigational keystrokes ALT+cursor arrow
48
56
  return;
49
57
  }
50
58
  this.setState({ value: event.target.value });
@@ -54,11 +62,18 @@ class TextCellEditorComponent extends DataGridCellEditorComponent {
54
62
  this.props.onKeyDown(e.nativeEvent);
55
63
  e.preventDefault();
56
64
  }
65
+ // In watch panel Delete propagation cause remove of line
57
66
  if (e.key === Key.Delete) {
58
67
  e.stopPropagation();
59
68
  }
60
69
  }, style: { width: '100%', minWidth: `min( 85vw, ${inputWidth}ch)` } }));
61
70
  }
62
71
  }
72
+ /**
73
+ * ag-grid cell editor for free text (registered in `DataGrid` as `textCellEditor`). Starts from `initialValue`, from the
74
+ * typed character when editing was started by typing, or from `null` on Backspace/Delete; reports `string | null`
75
+ * through `onValueChange` on every change (the placeholder shows `NULL` for a null value). Arrow Up/Down are forwarded
76
+ * to the grid and Delete does not propagate beyond the editor.
77
+ */
63
78
  export default withAgGridHooks(TextCellEditorComponent);
64
79
  //# sourceMappingURL=textCellEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"textCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/textCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAW,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AAEvE,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAS3F,MAAM,uBAAwB,SAAQ,2BAA0E;IAG5G,YAAY,KAAyC;QACjD,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,mBAAc,GAAoB,IAAI,CAAC;QAI3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,eAAe,CAAC,KAAyC;QACrD,IAAI,KAAoB,CAAC;QACzB,IAAI,KAAK,CAAC,QAAQ,KAAK,GAAG,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,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,GACjE,CACL,CAAC;IACN,CAAC;CACJ;AAED,eAAe,eAAe,CAAC,uBAAuB,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {Input, InputRef} from \"antd\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\ninterface TextCellEditorProperties extends CustomCellEditorProps {\r\n}\r\n\r\ninterface TextCellEditorState {\r\n value: string | null\r\n}\r\n\r\nclass TextCellEditorComponent extends DataGridCellEditorComponent<TextCellEditorProperties, TextCellEditorState> {\r\n private inputComponent: InputRef | null = null;\r\n\r\n constructor(props: Readonly<TextCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<TextCellEditorProperties>): TextCellEditorState {\r\n let value: string | null;\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n value = props.eventKey;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.initialValue;\r\n }\r\n return {value: value} as TextCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.input?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.input?.value ? this.inputComponent?.input.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.input?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n render() {\r\n const inputWidth = !!this.state.value && this.state.value.length > 40 ? this.state.value.length : 40;\r\n return (\r\n <Input\r\n ref={(component) => {\r\n this.inputComponent = component as InputRef | null;\r\n }}\r\n size=\"small\"\r\n autoFocus\r\n placeholder={this.state.value === null ? \"NULL\" : \"\"}\r\n value={this.state.value != undefined ? this.state.value : undefined}\r\n onChange={(event) => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n this.setState({value: event.target.value});\r\n this.props.onValueChange(event.target.value);\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.ArrowUp || e.key === Key.ArrowDown) {\r\n this.props.onKeyDown(e.nativeEvent);\r\n e.preventDefault();\r\n }\r\n // In watch panel Delete propagation cause remove of line\r\n if (e.key === Key.Delete) {\r\n e.stopPropagation();\r\n }\r\n }}\r\n style={{width: '100%', minWidth: `min( 85vw, ${inputWidth}ch)`}}\r\n />\r\n );\r\n }\r\n}\r\n\r\nexport default withAgGridHooks(TextCellEditorComponent)"]}
1
+ {"version":3,"file":"textCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/textCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAW,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AAEvE,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAU3F,MAAM,uBAAwB,SAAQ,2BAA0E;IAG5G,YAAY,KAAyC;QACjD,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,mBAAc,GAAoB,IAAI,CAAC;QAI3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,eAAe,CAAC,KAAyC;QACrD,IAAI,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ACD,yDAAyD;gBACzD,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;oBACvB,CAAC,CAAC,eAAe,EAAE,CAAC;gBACxB,CAAC;YACL,CAAC,EACD,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,UAAU,KAAK,EAAC,GACjE,CACL,CAAC;IACN,CAAC;CACJ;AAED;;;;;GAKG;AACH,eAAe,eAAe,CAAC,uBAAuB,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {Input, InputRef} from \"antd\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\n/** Props of {@link TextCellEditor}: ag-grid cell editor props; the editor takes no extra `cellEditorParams`. */\r\ninterface TextCellEditorProperties extends CustomCellEditorProps {\r\n}\r\n\r\ninterface TextCellEditorState {\r\n value: string | null\r\n}\r\n\r\nclass TextCellEditorComponent extends DataGridCellEditorComponent<TextCellEditorProperties, TextCellEditorState> {\r\n private inputComponent: InputRef | null = null;\r\n\r\n constructor(props: Readonly<TextCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<TextCellEditorProperties>): TextCellEditorState {\r\n let value: string | null;\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n value = props.eventKey;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.initialValue;\r\n }\r\n return {value: value} as TextCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.input?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.input?.value ? this.inputComponent?.input.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.input?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n render() {\r\n const inputWidth = !!this.state.value && this.state.value.length > 40 ? this.state.value.length : 40;\r\n return (\r\n <Input\r\n ref={(component) => {\r\n this.inputComponent = component as InputRef | null;\r\n }}\r\n size=\"small\"\r\n autoFocus\r\n placeholder={this.state.value === null ? \"NULL\" : \"\"}\r\n value={this.state.value != undefined ? this.state.value : undefined}\r\n onChange={(event) => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n this.setState({value: event.target.value});\r\n this.props.onValueChange(event.target.value);\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.ArrowUp || e.key === Key.ArrowDown) {\r\n this.props.onKeyDown(e.nativeEvent);\r\n e.preventDefault();\r\n }\r\n // In watch panel Delete propagation cause remove of line\r\n if (e.key === Key.Delete) {\r\n e.stopPropagation();\r\n }\r\n }}\r\n style={{width: '100%', minWidth: `min( 85vw, ${inputWidth}ch)`}}\r\n />\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor for free text (registered in `DataGrid` as `textCellEditor`). Starts from `initialValue`, from the\r\n * typed character when editing was started by typing, or from `null` on Backspace/Delete; reports `string | null`\r\n * through `onValueChange` on every change (the placeholder shows `NULL` for a null value). Arrow Up/Down are forwarded\r\n * to the grid and Delete does not propagate beyond the editor.\r\n */\r\nexport default withAgGridHooks(TextCellEditorComponent)"]}
@@ -1,3 +1,11 @@
1
1
  import { CustomCellEditorProps } from "ag-grid-react";
2
2
  import React from "react";
3
+ /**
4
+ * Wraps a class-based {@link DataGridCellEditorComponent} subclass into a function component usable as an
5
+ * ag-grid React `cellEditor`. It registers the ag-grid editor hooks via `useGridCellEditor`, forwarding
6
+ * `isCancelBeforeStart` to the class instance, and passes all ag-grid props (including `cellEditorParams`) through.
7
+ * Identical to `withAgGridHooks` exported from `dataGridCellEditorComponent`.
8
+ *
9
+ * @param Component - the editor class to wrap.
10
+ */
3
11
  export declare function withAgGridHooks<P extends CustomCellEditorProps, S>(Component: any): (props: CustomCellEditorProps) => React.JSX.Element;
@@ -1,5 +1,13 @@
1
1
  import { useGridCellEditor } from "ag-grid-react";
2
2
  import React, { useRef } from "react";
3
+ /**
4
+ * Wraps a class-based {@link DataGridCellEditorComponent} subclass into a function component usable as an
5
+ * ag-grid React `cellEditor`. It registers the ag-grid editor hooks via `useGridCellEditor`, forwarding
6
+ * `isCancelBeforeStart` to the class instance, and passes all ag-grid props (including `cellEditorParams`) through.
7
+ * Identical to `withAgGridHooks` exported from `dataGridCellEditorComponent`.
8
+ *
9
+ * @param Component - the editor class to wrap.
10
+ */
3
11
  export function withAgGridHooks(Component) {
4
12
  return (props) => {
5
13
  const componentRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"withAgGridHooks.js","sourceRoot":"","sources":["../../../../../components/grid/cell/withAgGridHooks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,EAAC,MAAM,EAAC,MAAM,OAAO,CAAC;AAGpC,MAAM,UAAU,eAAe,CAAqC,SAAc;IAC9E,OAAO,CAAC,KAA4B,EAAE,EAAE;QACpC,MAAM,YAAY,GAAqE,MAAM,CAAC,IAAI,CAAC,CAAC;QACpG,iBAAiB,CAAC;YACd,mBAAmB,EAAE,GAAG,EAAE;;gBACtB,OAAO,MAAA,MAAA,MAAA,YAAY,CAAC,OAAO,0CAAE,mBAAmB,kDAAI,mCAAI,KAAK,CAAC;YAClE,CAAC;SACJ,CAAC,CAAC;QACH,OAAO,oBAAC,SAAS,kBAAC,GAAG,EAAE,YAAY,IAAM,KAAK,EAAI,CAAC;IACvD,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {CustomCellEditorProps, useGridCellEditor} from \"ag-grid-react\";\r\nimport React, {useRef} from \"react\";\r\nimport {DataGridCellEditorComponent} from \"./dataGridCellEditorComponent\";\r\n\r\nexport function withAgGridHooks<P extends CustomCellEditorProps, S>(Component: any) {\r\n return (props: CustomCellEditorProps) => {\r\n const componentRef: React.MutableRefObject<DataGridCellEditorComponent<P, S> | null> = useRef(null);\r\n useGridCellEditor({\r\n isCancelBeforeStart: () => {\r\n return componentRef.current?.isCancelBeforeStart?.() ?? false;\r\n }\r\n });\r\n return <Component ref={componentRef} {...props} />;\r\n };\r\n}"]}
1
+ {"version":3,"file":"withAgGridHooks.js","sourceRoot":"","sources":["../../../../../components/grid/cell/withAgGridHooks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,EAAC,MAAM,EAAC,MAAM,OAAO,CAAC;AAGpC;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAqC,SAAc;IAC9E,OAAO,CAAC,KAA4B,EAAE,EAAE;QACpC,MAAM,YAAY,GAAqE,MAAM,CAAC,IAAI,CAAC,CAAC;QACpG,iBAAiB,CAAC;YACd,mBAAmB,EAAE,GAAG,EAAE;;gBACtB,OAAO,MAAA,MAAA,MAAA,YAAY,CAAC,OAAO,0CAAE,mBAAmB,kDAAI,mCAAI,KAAK,CAAC;YAClE,CAAC;SACJ,CAAC,CAAC;QACH,OAAO,oBAAC,SAAS,kBAAC,GAAG,EAAE,YAAY,IAAM,KAAK,EAAI,CAAC;IACvD,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {CustomCellEditorProps, useGridCellEditor} from \"ag-grid-react\";\r\nimport React, {useRef} from \"react\";\r\nimport {DataGridCellEditorComponent} from \"./dataGridCellEditorComponent\";\r\n\r\n/**\r\n * Wraps a class-based {@link DataGridCellEditorComponent} subclass into a function component usable as an\r\n * ag-grid React `cellEditor`. It registers the ag-grid editor hooks via `useGridCellEditor`, forwarding\r\n * `isCancelBeforeStart` to the class instance, and passes all ag-grid props (including `cellEditorParams`) through.\r\n * Identical to `withAgGridHooks` exported from `dataGridCellEditorComponent`.\r\n *\r\n * @param Component - the editor class to wrap.\r\n */\r\nexport function withAgGridHooks<P extends CustomCellEditorProps, S>(Component: any) {\r\n return (props: CustomCellEditorProps) => {\r\n const componentRef: React.MutableRefObject<DataGridCellEditorComponent<P, S> | null> = useRef(null);\r\n useGridCellEditor({\r\n isCancelBeforeStart: () => {\r\n return componentRef.current?.isCancelBeforeStart?.() ?? false;\r\n }\r\n });\r\n return <Component ref={componentRef} {...props} />;\r\n };\r\n}"]}
@@ -1,5 +1,14 @@
1
1
  import { ColDef, ColumnState } from "ag-grid-community";
2
- import { DataGridColDef } from "./dataGrid";
2
+ import type { DataGridColDef, DataGridColGroupDef } from "./dataGrid";
3
+ /** Helpers for ag-grid column state. */
3
4
  export declare class ColumnUtils {
5
+ /** Returns the columns of `columnDefs` with every column group replaced by its columns. */
6
+ static getLeafColumnDefs(columnDefs: (DataGridColDef | DataGridColGroupDef)[]): DataGridColDef[];
7
+ /**
8
+ * Adds a state for every column definition whose `colId` is missing in `columnsState` (e.g. a column added after the
9
+ * state was saved). The added state is built from the definition's `initial*` properties and inserted, in place,
10
+ * at the definition's index. Existing entries are left unchanged.
11
+ * @param columnsState - saved column state; modified in place
12
+ */
4
13
  static mergeColumnsState(columnsState: ColumnState[], columnsDefinition: ColDef[] | DataGridColDef[]): void;
5
14
  }
@@ -1,4 +1,15 @@
1
+ /** Helpers for ag-grid column state. */
1
2
  export class ColumnUtils {
3
+ /** Returns the columns of `columnDefs` with every column group replaced by its columns. */
4
+ static getLeafColumnDefs(columnDefs) {
5
+ return columnDefs.flatMap((columnDef) => "children" in columnDef ? ColumnUtils.getLeafColumnDefs(columnDef.children) : [columnDef]);
6
+ }
7
+ /**
8
+ * Adds a state for every column definition whose `colId` is missing in `columnsState` (e.g. a column added after the
9
+ * state was saved). The added state is built from the definition's `initial*` properties and inserted, in place,
10
+ * at the definition's index. Existing entries are left unchanged.
11
+ * @param columnsState - saved column state; modified in place
12
+ */
2
13
  static mergeColumnsState(columnsState, columnsDefinition) {
3
14
  const defaultState = columnsDefinition.map(columnDef => {
4
15
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"columnUtils.js","sourceRoot":"","sources":["../../../../components/grid/columnUtils.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAW;IACpB,MAAM,CAAC,iBAAiB,CAAC,YAA0B,EAAE,iBAA8C;QAC/F,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAA,EAAE;YAClD,OAAO;gBACH,OAAO,EAAE,SAAS,CAAC,OAAO;gBAC1B,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,IAAI,EAAE,SAAS,CAAC,WAAW;gBAC3B,IAAI,EAAE,SAAS,CAAC,WAAW;gBAC3B,MAAM,EAAE,SAAS,CAAC,aAAa;gBAC/B,KAAK,EAAE,SAAS,CAAC,YAAY;gBAC7B,UAAU,EAAE,SAAS,CAAC,iBAAiB;gBACvC,QAAQ,EAAE,SAAS,CAAC,eAAe;gBACnC,aAAa,EAAE,SAAS,CAAC,oBAAoB;gBAC7C,IAAI,EAAE,SAAS,CAAC,WAAW;gBAC3B,SAAS,EAAE,SAAS,CAAC,gBAAgB;gBACrC,KAAK,EAAE,SAAS,CAAC,YAAY;aACjB,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,KAAK,EAAC,EAAE;YAC9C,MAAM,kBAAkB,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAA,EAAE,CAAC,WAAW,CAAC,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC3G,IAAG,CAAC,kBAAkB,EAAE,CAAC;gBACrB,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC;YACtD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import {ColDef, ColumnState} from \"ag-grid-community\";\r\nimport {DataGridColDef} from \"./dataGrid\";\r\n\r\nexport class ColumnUtils {\r\n static mergeColumnsState(columnsState:ColumnState[], columnsDefinition: ColDef[] | DataGridColDef[]) {\r\n const defaultState = columnsDefinition.map(columnDef=> {\r\n return {\r\n aggFunc: columnDef.aggFunc,\r\n colId: columnDef.colId,\r\n flex: columnDef.initialFlex,\r\n hide: columnDef.initialHide,\r\n pinned: columnDef.initialPinned,\r\n pivot: columnDef.initialPivot,\r\n pivotIndex: columnDef.initialPivotIndex,\r\n rowGroup: columnDef.initialRowGroup,\r\n rowGroupIndex: columnDef.initialRowGroupIndex,\r\n sort: columnDef.initialSort,\r\n sortIndex: columnDef.initialSortIndex,\r\n width: columnDef.initialWidth,\r\n } as ColumnState;\r\n });\r\n defaultState.forEach((defaultColumnState, index)=>{\r\n const definedColumnState = columnsState.find(columnState=> columnState.colId === defaultColumnState.colId);\r\n if(!definedColumnState) {\r\n columnsState.splice(index, 0, defaultColumnState);\r\n }\r\n });\r\n }\r\n}"]}
1
+ {"version":3,"file":"columnUtils.js","sourceRoot":"","sources":["../../../../components/grid/columnUtils.ts"],"names":[],"mappings":"AAGA,wCAAwC;AACxC,MAAM,OAAO,WAAW;IACpB,2FAA2F;IAC3F,MAAM,CAAC,iBAAiB,CAAC,UAAoD;QACzE,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,IAAI,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACxI,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,YAA0B,EAAE,iBAA8C;QAC/F,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAA,EAAE;YAClD,OAAO;gBACH,OAAO,EAAE,SAAS,CAAC,OAAO;gBAC1B,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,IAAI,EAAE,SAAS,CAAC,WAAW;gBAC3B,IAAI,EAAE,SAAS,CAAC,WAAW;gBAC3B,MAAM,EAAE,SAAS,CAAC,aAAa;gBAC/B,KAAK,EAAE,SAAS,CAAC,YAAY;gBAC7B,UAAU,EAAE,SAAS,CAAC,iBAAiB;gBACvC,QAAQ,EAAE,SAAS,CAAC,eAAe;gBACnC,aAAa,EAAE,SAAS,CAAC,oBAAoB;gBAC7C,IAAI,EAAE,SAAS,CAAC,WAAW;gBAC3B,SAAS,EAAE,SAAS,CAAC,gBAAgB;gBACrC,KAAK,EAAE,SAAS,CAAC,YAAY;aACjB,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,KAAK,EAAC,EAAE;YAC9C,MAAM,kBAAkB,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAA,EAAE,CAAC,WAAW,CAAC,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC3G,IAAG,CAAC,kBAAkB,EAAE,CAAC;gBACrB,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC;YACtD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import {ColDef, ColumnState} from \"ag-grid-community\";\r\nimport type {DataGridColDef, DataGridColGroupDef} from \"./dataGrid\";\r\n\r\n/** Helpers for ag-grid column state. */\r\nexport class ColumnUtils {\r\n /** Returns the columns of `columnDefs` with every column group replaced by its columns. */\r\n static getLeafColumnDefs(columnDefs: (DataGridColDef | DataGridColGroupDef)[]): DataGridColDef[] {\r\n return columnDefs.flatMap((columnDef) => \"children\" in columnDef ? ColumnUtils.getLeafColumnDefs(columnDef.children) : [columnDef]);\r\n }\r\n\r\n /**\r\n * Adds a state for every column definition whose `colId` is missing in `columnsState` (e.g. a column added after the\r\n * state was saved). The added state is built from the definition's `initial*` properties and inserted, in place,\r\n * at the definition's index. Existing entries are left unchanged.\r\n * @param columnsState - saved column state; modified in place\r\n */\r\n static mergeColumnsState(columnsState:ColumnState[], columnsDefinition: ColDef[] | DataGridColDef[]) {\r\n const defaultState = columnsDefinition.map(columnDef=> {\r\n return {\r\n aggFunc: columnDef.aggFunc,\r\n colId: columnDef.colId,\r\n flex: columnDef.initialFlex,\r\n hide: columnDef.initialHide,\r\n pinned: columnDef.initialPinned,\r\n pivot: columnDef.initialPivot,\r\n pivotIndex: columnDef.initialPivotIndex,\r\n rowGroup: columnDef.initialRowGroup,\r\n rowGroupIndex: columnDef.initialRowGroupIndex,\r\n sort: columnDef.initialSort,\r\n sortIndex: columnDef.initialSortIndex,\r\n width: columnDef.initialWidth,\r\n } as ColumnState;\r\n });\r\n defaultState.forEach((defaultColumnState, index)=>{\r\n const definedColumnState = columnsState.find(columnState=> columnState.colId === defaultColumnState.colId);\r\n if(!definedColumnState) {\r\n columnsState.splice(index, 0, defaultColumnState);\r\n }\r\n });\r\n }\r\n}"]}
@@ -1,21 +1,39 @@
1
1
  import React from "react";
2
2
  import { ColDef, ColumnState, GridApi } from "ag-grid-community";
3
+ /** Layout of {@link ColumnTransfer}. */
3
4
  export declare const enum ColumnTransferType {
5
+ /** Checkable tree of columns grouped by `DataGridColDef.group`; checking a column shows it. Column order cannot be changed. */
4
6
  SIMPLE = "simple",
7
+ /** Two-list transfer: hidden columns as a grouped tree on the left, shown columns on the right, where they can be reordered by drag and drop. */
5
8
  FULL = "full"
6
9
  }
10
+ /** Properties of {@link ColumnTransfer}. */
7
11
  export interface ColumnTransferProps {
12
+ /** Column definitions of the grid; a column is identified by `colId`, or by `field` when `colId` is not set, and grouped by its `group` (see `DataGridColDef`). */
8
13
  columnDefinitions: ColDef[];
14
+ /** Current column state of the grid; columns without `hide` are shown as visible. */
9
15
  columnModel: ColumnState[];
16
+ /** API of the grid whose columns are edited; every change is applied to it immediately. */
10
17
  gridApi: GridApi;
18
+ /**
19
+ * Layout of the editor.
20
+ * @default ColumnTransferType.FULL
21
+ */
11
22
  type?: ColumnTransferType;
23
+ /** Height in pixels of the {@link ColumnTransferType.FULL} layout; the lists get 100 pixels less. Also forwarded to the antd `Transfer`. */
12
24
  height?: number;
13
25
  }
26
+ /**
27
+ * Editor of the visibility and order of ag-grid columns, used by the grid's column configuration dialog and settings drawer.
28
+ * It does not keep its own copy of the changes: showing, hiding and moving a column is applied to `gridApi` at once,
29
+ * so the caller re-renders it with the new `columnModel` (e.g. from ag-grid column events).
30
+ */
14
31
  export default class ColumnTransfer extends React.Component<ColumnTransferProps> {
15
32
  static defaultProps: {
16
33
  type: ColumnTransferType;
17
34
  };
18
35
  constructor(props: Readonly<ColumnTransferProps>);
36
+ /** antd `Transfer` change handler: shows (`direction` `"right"`) or hides the moved columns; a moved group key applies to all columns of the group. */
19
37
  onChange(_: React.Key[], direction: string, moveKeys: React.Key[]): void;
20
38
  render(): React.JSX.Element;
21
39
  }
@@ -15,6 +15,7 @@ import _head from "lodash/head";
15
15
  import i18n from "d2core/i18n/i18n";
16
16
  import DragSortingTable from "d2coreui/components/table/dragSortingTable";
17
17
  import difference from "lodash/difference";
18
+ // Customize ColumnNode Transfer
18
19
  const isChecked = (selectedKeys, eventKey) => {
19
20
  return selectedKeys.indexOf(eventKey) !== -1;
20
21
  };
@@ -30,13 +31,15 @@ function generateSimpleTree(treeNodes = []) {
30
31
  return (Object.assign(Object.assign({}, props), { key: props.key, children: generateSimpleTree(children) }));
31
32
  });
32
33
  }
33
- function getColumns(columnDefinitions) {
34
+ function getColumns(columnDefinitions, gridApi) {
35
+ // noinspection UnnecessaryLocalVariableJS
34
36
  const columns = columnDefinitions.map((columnDef) => {
35
37
  const id = columnDef.colId ? columnDef.colId : (columnDef.field ? columnDef.field : "");
36
38
  const group = columnDef.group;
39
+ const column = id ? gridApi.getColumn(id) : null;
37
40
  return {
38
41
  key: id,
39
- title: columnDef.headerName ? columnDef.headerName : "unknown",
42
+ title: (column && gridApi.getDisplayNameForColumn(column, "columnToolPanel")) || columnDef.headerName || id,
40
43
  description: columnDef.headerTooltip,
41
44
  group: group
42
45
  };
@@ -52,9 +55,13 @@ function getColumnsTree(columns, filteredItems = undefined) {
52
55
  if (!itemPresent) {
53
56
  return;
54
57
  }
58
+ if (!column.group) {
59
+ columnsDefinitionTree.push({ key: column.key, title: column.title });
60
+ return;
61
+ }
55
62
  let parent = _head(columnsDefinitionTree.filter((parentNode) => parentNode.key === ("_group_" + column.group)));
56
63
  if (!parent) {
57
- parent = { key: "_group_" + column.group, title: column.group ? column.group : "unknown" };
64
+ parent = { key: "_group_" + column.group, title: column.group };
58
65
  columnsDefinitionTree.push(parent);
59
66
  }
60
67
  if (!parent.children) {
@@ -64,21 +71,30 @@ function getColumnsTree(columns, filteredItems = undefined) {
64
71
  });
65
72
  return columnsDefinitionTree;
66
73
  }
74
+ /** Layout of {@link ColumnTransfer}. */
67
75
  export var ColumnTransferType;
68
76
  (function (ColumnTransferType) {
77
+ /** Checkable tree of columns grouped by `DataGridColDef.group`; checking a column shows it. Column order cannot be changed. */
69
78
  ColumnTransferType["SIMPLE"] = "simple";
79
+ /** Two-list transfer: hidden columns as a grouped tree on the left, shown columns on the right, where they can be reordered by drag and drop. */
70
80
  ColumnTransferType["FULL"] = "full";
71
81
  })(ColumnTransferType || (ColumnTransferType = {}));
82
+ /**
83
+ * Editor of the visibility and order of ag-grid columns, used by the grid's column configuration dialog and settings drawer.
84
+ * It does not keep its own copy of the changes: showing, hiding and moving a column is applied to `gridApi` at once,
85
+ * so the caller re-renders it with the new `columnModel` (e.g. from ag-grid column events).
86
+ */
72
87
  class ColumnTransfer extends React.Component {
73
88
  constructor(props) {
74
89
  super(props);
75
90
  this.onChange = this.onChange.bind(this);
76
91
  }
92
+ /** antd `Transfer` change handler: shows (`direction` `"right"`) or hides the moved columns; a moved group key applies to all columns of the group. */
77
93
  onChange(_, direction, moveKeys) {
78
94
  moveKeys.forEach((columnKey) => {
79
95
  if (typeof columnKey === "string") {
80
96
  if (columnKey.indexOf("_group_") >= 0) {
81
- const columnsTree = getColumnsTree(getColumns(this.props.columnDefinitions));
97
+ const columnsTree = getColumnsTree(getColumns(this.props.columnDefinitions, this.props.gridApi));
82
98
  const columnGroup = _head(columnsTree.filter((columnGroup) => {
83
99
  return columnGroup.key === columnKey;
84
100
  }));
@@ -97,9 +113,9 @@ class ColumnTransfer extends React.Component {
97
113
  ;
98
114
  render() {
99
115
  const _a = this.props, { columnDefinitions, columnModel, gridApi, type } = _a, restProps = __rest(_a, ["columnDefinitions", "columnModel", "gridApi", "type"]);
100
- const columns = getColumns(columnDefinitions);
116
+ const columns = getColumns(columnDefinitions, gridApi);
101
117
  const visibleColumnIds = columnModel.filter((column) => !column.hide).map((column) => column.colId);
102
- if (type === "simple") {
118
+ if (type === "simple" /* ColumnTransferType.SIMPLE */) {
103
119
  const columnsTree = getColumnsTree(columns);
104
120
  return (React.createElement(Tree, { blockNode: true, checkable: true, defaultExpandAll: true, checkedKeys: visibleColumnIds, onCheck: (selectedKeys, { node, }) => {
105
121
  var _a;
@@ -125,7 +141,7 @@ class ColumnTransfer extends React.Component {
125
141
  i18n("Hidden Columns"),
126
142
  ":"), React.createElement("b", null,
127
143
  i18n("Shown Columns"),
128
- ":")];
144
+ ":")]; // special hack to overcome typescript titles attribute in Transfer component could be also [ReactElement, ReactElement]
129
145
  return (React.createElement(Transfer, Object.assign({}, restProps, { style: { height: this.props.height, minHeight: 100 }, locale: {
130
146
  itemUnit: "",
131
147
  itemsUnit: "",
@@ -135,20 +151,25 @@ class ColumnTransfer extends React.Component {
135
151
  if (direction === 'left') {
136
152
  const checkedKeys = [...selectedKeys];
137
153
  const columnsTree = getColumnsTree(columns, filteredItems);
154
+ const selectNode = (node, checked) => {
155
+ var _a;
156
+ if ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) {
157
+ onItemSelectAll(node.children.map((child) => child.key), checked);
158
+ }
159
+ else {
160
+ onItemSelect(node.key, checked);
161
+ }
162
+ };
138
163
  return (React.createElement("div", { style: {
139
164
  overflowY: "auto",
140
165
  height: (this.props.height ? this.props.height : 100) - 100
141
166
  } },
142
- React.createElement(Tree, { blockNode: true, checkable: true, defaultExpandAll: true, checkedKeys: checkedKeys, onCheck: (_, { node, }) => {
143
- var _a;
144
- if ((_a = node.props) === null || _a === void 0 ? void 0 : _a.eventKey) {
145
- onItemSelect(node.props.eventKey, !isChecked(checkedKeys, node.props.eventKey));
146
- }
167
+ React.createElement(Tree, { key: columnsTree.filter((node) => node.children).map((node) => node.key).join(), blockNode: true, checkable: true, defaultExpandAll: true, checkedKeys: checkedKeys, onCheck: (_, { node, checked }) => {
168
+ selectNode(node, checked);
147
169
  }, onSelect: (_, { node }) => {
148
170
  var _a;
149
- if ((_a = node.props) === null || _a === void 0 ? void 0 : _a.eventKey) {
150
- onItemSelect(node.props.eventKey, !isChecked(checkedKeys, node.props.eventKey));
151
- }
171
+ const keys = ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) ? node.children.map((child) => child.key) : [node.key];
172
+ selectNode(node, !keys.every((key) => isChecked(checkedKeys, key)));
152
173
  }, treeData: generateTree(columnsTree, visibleColumnIds) })));
153
174
  }
154
175
  else {
@@ -156,22 +177,17 @@ class ColumnTransfer extends React.Component {
156
177
  getCheckboxProps: item => {
157
178
  return { disabled: !!item.disabled };
158
179
  },
159
- onSelectAll(selected, selectedRows) {
160
- const treeSelectedKeys = selectedRows
161
- .filter(item => !item.disabled)
162
- .map(({ key }) => key);
163
- let diffKeys;
164
- if (selected) {
165
- diffKeys = difference(treeSelectedKeys, selectedKeys);
180
+ onChange(selectedRowKeys) {
181
+ const addedKeys = difference(selectedRowKeys, selectedKeys);
182
+ const removedKeys = difference(selectedKeys, selectedRowKeys);
183
+ if (addedKeys.length > 0) {
184
+ onItemSelectAll(addedKeys, true);
166
185
  }
167
- else {
168
- diffKeys = difference(selectedKeys, treeSelectedKeys);
186
+ if (removedKeys.length > 0) {
187
+ onItemSelectAll(removedKeys, false);
169
188
  }
170
- onItemSelectAll(diffKeys, selected);
171
- },
172
- onSelect({ key }, selected) {
173
- onItemSelect(key, selected);
174
189
  },
190
+ preserveSelectedRowKeys: true,
175
191
  selectedRowKeys: selectedKeys,
176
192
  };
177
193
  return (React.createElement("div", { style: {
@@ -200,7 +216,7 @@ class ColumnTransfer extends React.Component {
200
216
  ;
201
217
  }
202
218
  ColumnTransfer.defaultProps = {
203
- type: "full"
219
+ type: "full" /* ColumnTransferType.FULL */
204
220
  };
205
221
  export default ColumnTransfer;
206
222
  //# sourceMappingURL=columnTransfer.js.map