d2coreui 23.0.52 → 23.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +154 -0
  3. package/components/clipboard/clipboardUtils.d.ts +11 -0
  4. package/components/clipboard/clipboardUtils.js +16 -4
  5. package/components/clipboard/clipboardUtils.js.map +1 -1
  6. package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
  7. package/components/codemirror/SyntaxHighlighter.js +6 -1
  8. package/components/codemirror/SyntaxHighlighter.js.map +1 -1
  9. package/components/collapse/expandable.d.ts +10 -0
  10. package/components/collapse/expandable.js +4 -0
  11. package/components/collapse/expandable.js.map +1 -1
  12. package/components/color/colorPicker.d.ts +16 -0
  13. package/components/color/colorPicker.js +4 -0
  14. package/components/color/colorPicker.js.map +1 -1
  15. package/components/color/colorSwatch.d.ts +16 -0
  16. package/components/color/colorSwatch.js +23 -2
  17. package/components/color/colorSwatch.js.map +1 -1
  18. package/components/color/colorUtils.d.ts +9 -0
  19. package/components/color/colorUtils.js +15 -0
  20. package/components/color/colorUtils.js.map +1 -1
  21. package/components/date/dateRangeInput.d.ts +76 -0
  22. package/components/date/dateRangeInput.js +63 -12
  23. package/components/date/dateRangeInput.js.map +1 -1
  24. package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
  25. package/components/date/dateRangeInputAdvancedPanel.js +7 -0
  26. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  27. package/components/date/dateRangeInputConfirm.d.ts +18 -0
  28. package/components/date/dateRangeInputConfirm.js +12 -0
  29. package/components/date/dateRangeInputConfirm.js.map +1 -1
  30. package/components/date/dateTimeInput.d.ts +99 -0
  31. package/components/date/dateTimeInput.js +78 -6
  32. package/components/date/dateTimeInput.js.map +1 -1
  33. package/components/date/durationInput.d.ts +37 -0
  34. package/components/date/durationInput.js +26 -3
  35. package/components/date/durationInput.js.map +1 -1
  36. package/components/date/savedIntervals.d.ts +63 -0
  37. package/components/date/savedIntervals.js +37 -0
  38. package/components/date/savedIntervals.js.map +1 -1
  39. package/components/date/savedIntervalsDialog.d.ts +13 -0
  40. package/components/date/savedIntervalsDialog.js +7 -2
  41. package/components/date/savedIntervalsDialog.js.map +1 -1
  42. package/components/form/NiceFormItem.d.ts +9 -0
  43. package/components/form/NiceFormItem.js +4 -0
  44. package/components/form/NiceFormItem.js.map +1 -1
  45. package/components/grid/cell/beanAccessor.d.ts +12 -0
  46. package/components/grid/cell/beanAccessor.js +8 -0
  47. package/components/grid/cell/beanAccessor.js.map +1 -1
  48. package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
  49. package/components/grid/cell/bigNumberCellEditor.js +19 -0
  50. package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
  51. package/components/grid/cell/cellControl.d.ts +4 -0
  52. package/components/grid/cell/cellControl.js +14 -0
  53. package/components/grid/cell/cellControl.js.map +1 -1
  54. package/components/grid/cell/cellEditorUtils.d.ts +6 -0
  55. package/components/grid/cell/cellEditorUtils.js +6 -0
  56. package/components/grid/cell/cellEditorUtils.js.map +1 -1
  57. package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
  58. package/components/grid/cell/customEnumCellEditor.js +10 -0
  59. package/components/grid/cell/customEnumCellEditor.js.map +1 -1
  60. package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
  61. package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
  62. package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
  63. package/components/grid/cell/dateCellEditor.d.ts +6 -0
  64. package/components/grid/cell/dateCellEditor.js +10 -0
  65. package/components/grid/cell/dateCellEditor.js.map +1 -1
  66. package/components/grid/cell/dragListenerFeature.d.ts +6 -0
  67. package/components/grid/cell/dragListenerFeature.js +6 -0
  68. package/components/grid/cell/dragListenerFeature.js.map +1 -1
  69. package/components/grid/cell/durationCellEditor.d.ts +6 -0
  70. package/components/grid/cell/durationCellEditor.js +14 -0
  71. package/components/grid/cell/durationCellEditor.js.map +1 -1
  72. package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
  73. package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
  74. package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
  75. package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
  76. package/components/grid/cell/hexaValueCellEditor.js +14 -0
  77. package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
  78. package/components/grid/cell/numberCellEditor.d.ts +6 -0
  79. package/components/grid/cell/numberCellEditor.js +15 -0
  80. package/components/grid/cell/numberCellEditor.js.map +1 -1
  81. package/components/grid/cell/rangeSelector.d.ts +7 -0
  82. package/components/grid/cell/rangeSelector.js +59 -5
  83. package/components/grid/cell/rangeSelector.js.map +1 -1
  84. package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
  85. package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
  86. package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
  87. package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
  88. package/components/grid/cell/statusTextCellEditor.js +17 -0
  89. package/components/grid/cell/statusTextCellEditor.js.map +1 -1
  90. package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
  91. package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
  92. package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
  93. package/components/grid/cell/textCellEditor.d.ts +6 -0
  94. package/components/grid/cell/textCellEditor.js +15 -0
  95. package/components/grid/cell/textCellEditor.js.map +1 -1
  96. package/components/grid/cell/withAgGridHooks.d.ts +8 -0
  97. package/components/grid/cell/withAgGridHooks.js +8 -0
  98. package/components/grid/cell/withAgGridHooks.js.map +1 -1
  99. package/components/grid/columnUtils.d.ts +7 -0
  100. package/components/grid/columnUtils.js +7 -0
  101. package/components/grid/columnUtils.js.map +1 -1
  102. package/components/grid/config/columnTransfer.d.ts +18 -0
  103. package/components/grid/config/columnTransfer.js +14 -3
  104. package/components/grid/config/columnTransfer.js.map +1 -1
  105. package/components/grid/config/dataGridEditor.d.ts +31 -0
  106. package/components/grid/config/dataGridEditor.js +14 -2
  107. package/components/grid/config/dataGridEditor.js.map +1 -1
  108. package/components/grid/config/rowHeightCalculator.d.ts +11 -0
  109. package/components/grid/config/rowHeightCalculator.js +11 -0
  110. package/components/grid/config/rowHeightCalculator.js.map +1 -1
  111. package/components/grid/config/rowStylePicker.d.ts +19 -0
  112. package/components/grid/config/rowStylePicker.js +12 -0
  113. package/components/grid/config/rowStylePicker.js.map +1 -1
  114. package/components/grid/dataGrid.d.ts +331 -0
  115. package/components/grid/dataGrid.js +168 -11
  116. package/components/grid/dataGrid.js.map +1 -1
  117. package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
  118. package/components/grid/detail/detailHeaderPanel.js +5 -0
  119. package/components/grid/detail/detailHeaderPanel.js.map +1 -1
  120. package/components/grid/export/contextMenu.d.ts +31 -0
  121. package/components/grid/export/contextMenu.js +8 -0
  122. package/components/grid/export/contextMenu.js.map +1 -1
  123. package/components/grid/export/progressPopup.d.ts +21 -0
  124. package/components/grid/export/progressPopup.js +17 -0
  125. package/components/grid/export/progressPopup.js.map +1 -1
  126. package/components/grid/export/worker/pdfExport.js +5 -0
  127. package/components/grid/export/worker/pdfExport.js.map +1 -1
  128. package/components/grid/extendedDataGrid.d.ts +240 -0
  129. package/components/grid/extendedDataGrid.js +116 -2
  130. package/components/grid/extendedDataGrid.js.map +1 -1
  131. package/components/grid/filter/customColumnFilter.d.ts +5 -0
  132. package/components/grid/filter/customColumnFilter.js +5 -0
  133. package/components/grid/filter/customColumnFilter.js.map +1 -1
  134. package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
  135. package/components/grid/filter/dataGridColumnFilter.js +19 -0
  136. package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
  137. package/components/grid/filter/dateColumnFilter.d.ts +6 -0
  138. package/components/grid/filter/dateColumnFilter.js +6 -0
  139. package/components/grid/filter/dateColumnFilter.js.map +1 -1
  140. package/components/grid/filter/textColumnFilter.d.ts +6 -0
  141. package/components/grid/filter/textColumnFilter.js +6 -0
  142. package/components/grid/filter/textColumnFilter.js.map +1 -1
  143. package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
  144. package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
  145. package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
  146. package/components/grid/header/simpleHeader.d.ts +17 -0
  147. package/components/grid/header/simpleHeader.js +20 -0
  148. package/components/grid/header/simpleHeader.js.map +1 -1
  149. package/components/grid/panel/dataGridPagination.d.ts +10 -0
  150. package/components/grid/panel/dataGridPagination.js +5 -0
  151. package/components/grid/panel/dataGridPagination.js.map +1 -1
  152. package/components/grid/panel/loadingOverlay.d.ts +5 -0
  153. package/components/grid/panel/loadingOverlay.js +4 -0
  154. package/components/grid/panel/loadingOverlay.js.map +1 -1
  155. package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
  156. package/components/grid/panel/noRecordsOverlay.js +5 -0
  157. package/components/grid/panel/noRecordsOverlay.js.map +1 -1
  158. package/components/grid/panel/tablePagination.d.ts +4 -0
  159. package/components/grid/panel/tablePagination.js +4 -0
  160. package/components/grid/panel/tablePagination.js.map +1 -1
  161. package/components/icons/dropdownArrow.d.ts +3 -0
  162. package/components/icons/dropdownArrow.js +2 -0
  163. package/components/icons/dropdownArrow.js.map +1 -1
  164. package/components/icons/undoIcon.d.ts +2 -0
  165. package/components/icons/undoIcon.js +2 -0
  166. package/components/icons/undoIcon.js.map +1 -1
  167. package/components/input/autoCompleteInput.d.ts +29 -0
  168. package/components/input/autoCompleteInput.js +7 -0
  169. package/components/input/autoCompleteInput.js.map +1 -1
  170. package/components/input/draftUtils.d.ts +7 -0
  171. package/components/input/draftUtils.js +9 -0
  172. package/components/input/draftUtils.js.map +1 -1
  173. package/components/input/hexaFormattedInput.d.ts +9 -0
  174. package/components/input/hexaFormattedInput.js +3 -0
  175. package/components/input/hexaFormattedInput.js.map +1 -1
  176. package/components/input/mask/helpers.d.ts +27 -0
  177. package/components/input/mask/helpers.js +27 -0
  178. package/components/input/mask/helpers.js.map +1 -1
  179. package/components/input/mask/inputMaskCore.d.ts +80 -0
  180. package/components/input/mask/inputMaskCore.js +90 -0
  181. package/components/input/mask/inputMaskCore.js.map +1 -1
  182. package/components/input/mask/pattern.d.ts +24 -0
  183. package/components/input/mask/pattern.js +26 -0
  184. package/components/input/mask/pattern.js.map +1 -1
  185. package/components/input/maskedInput.d.ts +53 -0
  186. package/components/input/maskedInput.js +44 -4
  187. package/components/input/maskedInput.js.map +1 -1
  188. package/components/input/passwordInput.d.ts +7 -0
  189. package/components/input/passwordInput.js +8 -0
  190. package/components/input/passwordInput.js.map +1 -1
  191. package/components/input/simpleAutoComplete.d.ts +6 -0
  192. package/components/input/simpleAutoComplete.js +6 -0
  193. package/components/input/simpleAutoComplete.js.map +1 -1
  194. package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
  195. package/components/input/textarea/extractSpansOfClasses.js +26 -1
  196. package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
  197. package/components/input/textarea/getRanges.d.ts +7 -0
  198. package/components/input/textarea/getRanges.js +11 -0
  199. package/components/input/textarea/getRanges.js.map +1 -1
  200. package/components/input/textarea/getType.d.ts +5 -0
  201. package/components/input/textarea/getType.js +5 -0
  202. package/components/input/textarea/getType.js.map +1 -1
  203. package/components/input/textarea/highlighedContents.d.ts +4 -0
  204. package/components/input/textarea/highlighedContents.js +5 -0
  205. package/components/input/textarea/highlighedContents.js.map +1 -1
  206. package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
  207. package/components/input/textarea/mentionsWithHighlighting.js +14 -0
  208. package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
  209. package/components/keyboard/keyboardUtils.d.ts +6 -0
  210. package/components/keyboard/keyboardUtils.js +6 -0
  211. package/components/keyboard/keyboardUtils.js.map +1 -1
  212. package/components/modal/draggableModalProvider.d.ts +6 -0
  213. package/components/modal/draggableModalProvider.js +7 -0
  214. package/components/modal/draggableModalProvider.js.map +1 -1
  215. package/components/modal/impl/clamp.js +1 -0
  216. package/components/modal/impl/clamp.js.map +1 -1
  217. package/components/modal/impl/draggableModal.d.ts +1 -0
  218. package/components/modal/impl/draggableModal.js +6 -0
  219. package/components/modal/impl/draggableModal.js.map +1 -1
  220. package/components/modal/impl/draggableModalContext.js +1 -0
  221. package/components/modal/impl/draggableModalContext.js.map +1 -1
  222. package/components/modal/impl/draggableModalInner.js +12 -1
  223. package/components/modal/impl/draggableModalInner.js.map +1 -1
  224. package/components/modal/impl/draggableModalReducer.d.ts +7 -1
  225. package/components/modal/impl/draggableModalReducer.js +6 -1
  226. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  227. package/components/modal/impl/draggableModalStyles.d.ts +17 -0
  228. package/components/modal/impl/draggableModalStyles.js +31 -0
  229. package/components/modal/impl/draggableModalStyles.js.map +1 -1
  230. package/components/modal/impl/getWindowSize.js +1 -0
  231. package/components/modal/impl/getWindowSize.js.map +1 -1
  232. package/components/modal/impl/index.js +1 -0
  233. package/components/modal/impl/index.js.map +1 -1
  234. package/components/modal/impl/resizeHandle.d.ts +1 -0
  235. package/components/modal/impl/resizeHandle.js +4 -1
  236. package/components/modal/impl/resizeHandle.js.map +1 -1
  237. package/components/modal/impl/useDrag.js +1 -0
  238. package/components/modal/impl/useDrag.js.map +1 -1
  239. package/components/modal/impl/usePrevious.js +1 -0
  240. package/components/modal/impl/usePrevious.js.map +1 -1
  241. package/components/modal/impl/useResize.js +1 -0
  242. package/components/modal/impl/useResize.js.map +1 -1
  243. package/components/modal/modalDialog.d.ts +85 -0
  244. package/components/modal/modalDialog.js +80 -10
  245. package/components/modal/modalDialog.js.map +1 -1
  246. package/components/picker/enumValuePicker.d.ts +17 -0
  247. package/components/picker/enumValuePicker.js +4 -0
  248. package/components/picker/enumValuePicker.js.map +1 -1
  249. package/components/platformSpecific.d.ts +17 -0
  250. package/components/platformSpecific.js +16 -0
  251. package/components/platformSpecific.js.map +1 -1
  252. package/components/scrollTo/onlyText.d.ts +5 -0
  253. package/components/scrollTo/onlyText.js +5 -0
  254. package/components/scrollTo/onlyText.js.map +1 -1
  255. package/components/scrollTo/scrollTo.d.ts +56 -0
  256. package/components/scrollTo/scrollTo.js +40 -3
  257. package/components/scrollTo/scrollTo.js.map +1 -1
  258. package/components/style/withCss.d.ts +15 -0
  259. package/components/style/withCss.js +6 -0
  260. package/components/style/withCss.js.map +1 -1
  261. package/components/table/dragSortingTable.d.ts +15 -0
  262. package/components/table/dragSortingTable.js +12 -0
  263. package/components/table/dragSortingTable.js.map +1 -1
  264. package/components/text/impl/innerSize.js +2 -0
  265. package/components/text/impl/innerSize.js.map +1 -1
  266. package/components/text/impl/series.d.ts +10 -0
  267. package/components/text/impl/series.js +10 -0
  268. package/components/text/impl/series.js.map +1 -1
  269. package/components/text/impl/shallowEqual.js +1 -0
  270. package/components/text/impl/shallowEqual.js.map +1 -1
  271. package/components/text/impl/whilst.d.ts +7 -0
  272. package/components/text/impl/whilst.js +7 -0
  273. package/components/text/impl/whilst.js.map +1 -1
  274. package/components/text/textFit.d.ts +24 -0
  275. package/components/text/textFit.js +29 -1
  276. package/components/text/textFit.js.map +1 -1
  277. package/i18n/componentsLocaleHolder.d.ts +9 -0
  278. package/i18n/componentsLocaleHolder.js +9 -0
  279. package/i18n/componentsLocaleHolder.js.map +1 -1
  280. package/package.json +66 -65
@@ -1,7 +1,16 @@
1
+ /** Conversions between D2000 integer colors and CSS colors. D2000 encodes colors as `0xBBGGRR` integers. */
1
2
  export default class ColorUtils {
3
+ /** Converts a D2000 color (`0xBBGGRR`) to a CSS `rgb(r,g,b)` string. */
2
4
  static d2IntToRGB(num: number): string;
5
+ /** Converts a D2000 color (`0xBBGGRR`) to a CSS `#rrggbb` string. */
3
6
  static d2IntToHex(num: number): string;
7
+ /** Converts a CSS `#rrggbb` string (6 hex digits with the leading `#`) to a D2000 color (`0xBBGGRR`). */
4
8
  static hexToD2Int(hex: string): number;
5
9
  private static padZero;
10
+ /**
11
+ * Returns the inverse of a hex color (`#rrggbb` or `#rgb`, the `#` is optional) as `#rrggbb`.
12
+ * @param bw when `true`, returns `#000000` or `#FFFFFF`, whichever contrasts better with the color
13
+ * @throws Error when the color is not a valid 3- or 6-digit hex color
14
+ */
6
15
  static invertColor(hex: string, bw: boolean): string;
7
16
  }
@@ -1,12 +1,18 @@
1
+ /** Conversions between D2000 integer colors and CSS colors. D2000 encodes colors as `0xBBGGRR` integers. */
1
2
  export default class ColorUtils {
3
+ /** Converts a D2000 color (`0xBBGGRR`) to a CSS `rgb(r,g,b)` string. */
2
4
  static d2IntToRGB(num) {
5
+ // d2000 posiela farbu vo formate bgr
3
6
  const b = (num & 0xFF0000) >>> 16, g = (num & 0xFF00) >>> 8, r = num & 0xFF;
4
7
  return "rgb(" + [r, g, b].join(",") + ")";
5
8
  }
9
+ /** Converts a D2000 color (`0xBBGGRR`) to a CSS `#rrggbb` string. */
6
10
  static d2IntToHex(num) {
11
+ // d2000 posiela farbu vo formate bgr
7
12
  const b = (num & 0xFF0000) >>> 16, g = (num & 0xFF00) >>> 8, r = num & 0xFF;
8
13
  return "#" + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0');
9
14
  }
15
+ /** Converts a CSS `#rrggbb` string (6 hex digits with the leading `#`) to a D2000 color (`0xBBGGRR`). */
10
16
  static hexToD2Int(hex) {
11
17
  const r = parseInt(hex.slice(1, 1 + 2), 16), g = (parseInt(hex.slice(3, 3 + 2), 16) << 8), b = (parseInt(hex.slice(5, 5 + 2), 16) << 16);
12
18
  return r + g + b;
@@ -17,10 +23,16 @@ export default class ColorUtils {
17
23
  }
18
24
  return s;
19
25
  }
26
+ /**
27
+ * Returns the inverse of a hex color (`#rrggbb` or `#rgb`, the `#` is optional) as `#rrggbb`.
28
+ * @param bw when `true`, returns `#000000` or `#FFFFFF`, whichever contrasts better with the color
29
+ * @throws Error when the color is not a valid 3- or 6-digit hex color
30
+ */
20
31
  static invertColor(hex, bw) {
21
32
  if (hex.indexOf('#') === 0) {
22
33
  hex = hex.slice(1);
23
34
  }
35
+ // convert 3-digit hex to 6-digits.
24
36
  if (hex.length === 3) {
25
37
  hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
26
38
  }
@@ -31,13 +43,16 @@ export default class ColorUtils {
31
43
  const g = parseInt(hex.slice(2, 4), 16);
32
44
  const b = parseInt(hex.slice(4, 6), 16);
33
45
  if (bw) {
46
+ // http://stackoverflow.com/a/3943023/112731
34
47
  return (r * 0.299 + g * 0.587 + b * 0.114) > 186
35
48
  ? '#000000'
36
49
  : '#FFFFFF';
37
50
  }
51
+ // invert color components
38
52
  const rString = (255 - r).toString(16);
39
53
  const gString = (255 - g).toString(16);
40
54
  const bString = (255 - b).toString(16);
55
+ // pad each with zeros and return
41
56
  return "#" + this.padZero(rString) + this.padZero(gString) + this.padZero(bString);
42
57
  }
43
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"colorUtils.js","sourceRoot":"","sources":["../../../../components/color/colorUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,MAAM,CAAC,UAAU,CAAC,GAAW;QAEzB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAC7B,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,EACxB,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;QACnB,OAAO,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAW;QAEzB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAC7B,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,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AO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvF,CAAC;CACJ","sourcesContent":["export default class ColorUtils {\r\n static d2IntToRGB(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"rgb(\" + [r, g, b].join(\",\") + \")\";\r\n }\r\n\r\n static d2IntToHex(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"#\" + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0');\r\n }\r\n\r\n static hexToD2Int(hex: string): number {\r\n const r = parseInt(hex.slice(1, 1 + 2), 16),\r\n g = (parseInt(hex.slice(3, 3 + 2), 16) << 8),\r\n b = (parseInt(hex.slice(5, 5 + 2), 16) << 16);\r\n\r\n return r + g + b;\r\n }\r\n\r\n private static padZero(s: string, length: number = 2) {\r\n while (s.length < length) {\r\n s = '0' + s;\r\n }\r\n return s;\r\n }\r\n\r\n static invertColor(hex: string, bw: boolean) {\r\n if (hex.indexOf('#') === 0) {\r\n hex = hex.slice(1);\r\n }\r\n // convert 3-digit hex to 6-digits.\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\r\n }\r\n if (hex.length !== 6) {\r\n throw new Error('Invalid HEX color.');\r\n }\r\n const r = parseInt(hex.slice(0, 2), 16);\r\n const g = parseInt(hex.slice(2, 4), 16);\r\n const b = parseInt(hex.slice(4, 6), 16);\r\n if (bw) {\r\n // http://stackoverflow.com/a/3943023/112731\r\n return (r * 0.299 + g * 0.587 + b * 0.114) > 186\r\n ? '#000000'\r\n : '#FFFFFF';\r\n }\r\n // invert color components\r\n const rString = (255 - r).toString(16);\r\n const gString = (255 - g).toString(16);\r\n const bString = (255 - b).toString(16);\r\n // pad each with zeros and return\r\n return \"#\" + this.padZero(rString) + this.padZero(gString) + this.padZero(bString);\r\n }\r\n}"]}
1
+ {"version":3,"file":"colorUtils.js","sourceRoot":"","sources":["../../../../components/color/colorUtils.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,wEAAwE;IACxE,MAAM,CAAC,UAAU,CAAC,GAAW;QACzB,qCAAqC;QACrC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAC7B,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,EACxB,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;QACnB,OAAO,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC9C,CAAC;IAED,qEAAqE;IACrE,MAAM,CAAC,UAAU,CAAC,GAAW;QACzB,qCAAqC;QACrC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAC7B,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,EACxB,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;QACnB,OAAO,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrH,CAAC;IAED,yGAAyG;IACzG,MAAM,CAAC,UAAU,CAAC,GAAW;QACzB,MAAM,CAAC,GAAG,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AM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,EAAE,EAAE,CAAC;YACL,4CAA4C;YAC5C,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG;gBAC5C,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,SAAS,CAAC;QACpB,CAAC;QACD,0BAA0B;QAC1B,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvC,iCAAiC;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvF,CAAC;CACJ","sourcesContent":["/** Conversions between D2000 integer colors and CSS colors. D2000 encodes colors as `0xBBGGRR` integers. */\r\nexport default class ColorUtils {\r\n /** Converts a D2000 color (`0xBBGGRR`) to a CSS `rgb(r,g,b)` string. */\r\n static d2IntToRGB(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"rgb(\" + [r, g, b].join(\",\") + \")\";\r\n }\r\n\r\n /** Converts a D2000 color (`0xBBGGRR`) to a CSS `#rrggbb` string. */\r\n static d2IntToHex(num: number): string {\r\n // d2000 posiela farbu vo formate bgr\r\n const b = (num & 0xFF0000) >>> 16,\r\n g = (num & 0xFF00) >>> 8,\r\n r = num & 0xFF;\r\n return \"#\" + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0');\r\n }\r\n\r\n /** Converts a CSS `#rrggbb` string (6 hex digits with the leading `#`) to a D2000 color (`0xBBGGRR`). */\r\n static hexToD2Int(hex: string): number {\r\n const r = parseInt(hex.slice(1, 1 + 2), 16),\r\n g = (parseInt(hex.slice(3, 3 + 2), 16) << 8),\r\n b = (parseInt(hex.slice(5, 5 + 2), 16) << 16);\r\n\r\n return r + g + b;\r\n }\r\n\r\n private static padZero(s: string, length: number = 2) {\r\n while (s.length < length) {\r\n s = '0' + s;\r\n }\r\n return s;\r\n }\r\n\r\n /**\r\n * Returns the inverse of a hex color (`#rrggbb` or `#rgb`, the `#` is optional) as `#rrggbb`.\r\n * @param bw when `true`, returns `#000000` or `#FFFFFF`, whichever contrasts better with the color\r\n * @throws Error when the color is not a valid 3- or 6-digit hex color\r\n */\r\n static invertColor(hex: string, bw: boolean) {\r\n if (hex.indexOf('#') === 0) {\r\n hex = hex.slice(1);\r\n }\r\n // convert 3-digit hex to 6-digits.\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\r\n }\r\n if (hex.length !== 6) {\r\n throw new Error('Invalid HEX color.');\r\n }\r\n const r = parseInt(hex.slice(0, 2), 16);\r\n const g = parseInt(hex.slice(2, 4), 16);\r\n const b = parseInt(hex.slice(4, 6), 16);\r\n if (bw) {\r\n // http://stackoverflow.com/a/3943023/112731\r\n return (r * 0.299 + g * 0.587 + b * 0.114) > 186\r\n ? '#000000'\r\n : '#FFFFFF';\r\n }\r\n // invert color components\r\n const rString = (255 - r).toString(16);\r\n const gString = (255 - g).toString(16);\r\n const bString = (255 - b).toString(16);\r\n // pad each with zeros and return\r\n return \"#\" + this.padZero(rString) + this.padZero(gString) + this.padZero(bString);\r\n }\r\n}"]}
@@ -5,30 +5,63 @@ import { SizeType } from "antd/lib/config-provider/SizeContext";
5
5
  import { InputStatus } from "antd/es/_util/statusUtils";
6
6
  import { Variant } from "antd/es/config-provider";
7
7
  import { IntervalStorage, QuickRange, SavedInterval } from "./savedIntervals";
8
+ /** Layout of the {@link DateRangeInput} popup. */
8
9
  export declare enum DateRangeInputMode {
10
+ /** Two month calendars (click a day or drag across days) plus the {@link DateRangeInputProps.ranges} presets. */
9
11
  SIMPLE = 0,
12
+ /** Two date-time inputs plus buttons for interval begin/end, duration and time shift. */
10
13
  ADVANCED = 1
11
14
  }
15
+ /**
16
+ * Props of {@link DateRangeInput}. Remaining HTML attributes are forwarded to the inner {@link DateTimeInput}s,
17
+ * except `style` and `className`, which apply to the root element.
18
+ */
12
19
  export interface DateRangeInputProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
20
+ /** dayjs format of both bounds - see {@link DateTimeInput} `mask` for the supported tokens. */
13
21
  mask: string;
22
+ /** Start of the range (controlled), in local time. */
14
23
  fromValue: Dayjs | null;
24
+ /** End of the range (controlled), in local time. The component does not enforce `fromValue <= toValue`. */
15
25
  toValue: Dayjs | null;
26
+ /**
27
+ * Called with both bounds whenever either one changes: typing in one of the inputs, picking or dragging
28
+ * days in the calendars (the time of day of the current bounds is kept - 00:00:00.000 / 23:59:59.999 when
29
+ * they are `null`), a preset from {@link DateRangeInputProps.ranges}, an advanced-mode button or a saved interval.
30
+ * Advanced-mode buttons and saved intervals clamp the result to {@link DateRangeInputProps.minDateTime}/{@link DateRangeInputProps.maxDateTime}.
31
+ */
16
32
  onChange?: (fromValue: Dayjs | null, toValue: Dayjs | null) => void;
33
+ /** Called with the raw text of a bound whose typed text is not a valid (or allowed) value. */
17
34
  onInvalidValue?: (input: string) => void;
35
+ /** Disables both inputs and the popup. */
18
36
  disabled?: boolean;
37
+ /** Earliest allowed value of both bounds (inclusive). */
19
38
  minDateTime?: Dayjs;
39
+ /** Latest allowed value of both bounds (inclusive). */
20
40
  maxDateTime?: Dayjs;
41
+ /** Allows a bound to be cleared by emptying its input; it is then reported as `null`. */
21
42
  allowClear?: boolean;
43
+ /** Preset ranges shown as clickable tags in the {@link DateRangeInputMode.SIMPLE} popup; the key is the label, the function returns `[from, to]` when clicked. */
22
44
  ranges?: {
23
45
  [rangeName: string]: () => [Dayjs, Dayjs];
24
46
  };
47
+ /** antd control size. */
25
48
  size?: SizeType;
49
+ /** antd validation status of the whole range input. */
26
50
  status?: InputStatus;
51
+ /** antd input variant of the whole range input; defaults to the `ConfigProvider` one. */
27
52
  variant?: Variant;
53
+ /**
54
+ * Compact popup: always the advanced layout without the mode switch, the separator and the "Interval End"
55
+ * column; {@link DateRangeInputProps.defaultMode} is ignored.
56
+ */
28
57
  compact?: boolean;
58
+ /** Renders only the two inputs - no calendar icon and no popup. */
29
59
  hidePopup?: boolean;
60
+ /** Renders only the popup content inline, without the inputs. */
30
61
  renderAsCalendar?: boolean;
62
+ /** Placement of the popup relative to the input. */
31
63
  placement?: TooltipPlacement;
64
+ /** Fine alignment of the popup (rc-trigger `align`), applied on top of {@link DateRangeInputProps.placement}. */
32
65
  align?: {
33
66
  points?: [string, string];
34
67
  offset?: [number, number];
@@ -41,13 +74,32 @@ export interface DateRangeInputProps extends Omit<HTMLAttributes<HTMLDivElement>
41
74
  useCssBottom?: boolean;
42
75
  useCssTransform?: boolean;
43
76
  };
77
+ /**
78
+ * Initial popup mode (uncontrolled - read only on mount); the user switches it with the switch in the popup.
79
+ * @default DateRangeInputMode.SIMPLE
80
+ */
44
81
  defaultMode?: DateRangeInputMode;
82
+ /**
83
+ * Shows an icon opening a dropdown with: saving the current range to quick access (the latest
84
+ * `MAX_QUICK_RANGES` are kept), the quick-access ranges, the {@link SavedIntervalsDialog} and the
85
+ * saved relative intervals. Intervals are loaded when this becomes `true` and whenever {@link DateRangeInputProps.intervalStorage} changes.
86
+ */
45
87
  showCustomIntervals?: boolean;
88
+ /**
89
+ * Where quick-access ranges and saved intervals are persisted - see {@link IntervalStorage}. Compared by
90
+ * reference, so pass a stable object: a new one reloads the intervals.
91
+ * @default true
92
+ */
46
93
  intervalStorage?: IntervalStorage;
94
+ /** Called when the user toggles the popup between {@link DateRangeInputMode.SIMPLE} and {@link DateRangeInputMode.ADVANCED}. */
47
95
  onModeChange?(mode: DateRangeInputMode): void;
96
+ /** Called when the popup opens and when focus enters the inputs or the popup content. */
48
97
  onFocus?(): void;
98
+ /** Called when the popup closes and when focus leaves the inputs or the popup content. */
49
99
  onBlur?(): void;
100
+ /** Renders extra content (e.g. confirm buttons) at the right side of the popup footer. */
50
101
  confirmButtonsRenderer?(): React.ReactNode;
102
+ /** Called when the popup opens or closes. */
51
103
  onPopupVisibleChange?(visible: boolean): void;
52
104
  }
53
105
  interface DateRangeInputState {
@@ -61,6 +113,23 @@ interface DateRangeInputState {
61
113
  intervalsLoading: boolean;
62
114
  configDialogOpen: boolean;
63
115
  }
116
+ /**
117
+ * Controlled date-time range input: two masked {@link DateTimeInput}s in one antd-styled box with a popup
118
+ * that opens on right-click or via the calendar icon. The popup offers calendars and presets
119
+ * ({@link DateRangeInputMode.SIMPLE}) or interval shortcuts ({@link DateRangeInputMode.ADVANCED}).
120
+ * Every change is reported immediately; use `DateRangeInputConfirm` to apply changes only on confirmation.
121
+ *
122
+ * @example
123
+ * const [range, setRange] = useState<[Dayjs | null, Dayjs | null]>([dayjs().startOf("day"), dayjs().endOf("day")]);
124
+ *
125
+ * <DateRangeInput
126
+ * mask={LocaleHolder.getDateTimeFormat(true, true)}
127
+ * fromValue={range[0]}
128
+ * toValue={range[1]}
129
+ * onChange={(from, to) => setRange([from, to])}
130
+ * ranges={DateTimeUtils.getRanges([DateTimeInterval.DAY_ACT, DateTimeInterval.WEEK_ACT])}
131
+ * />
132
+ */
64
133
  export default class DateRangeInput extends React.Component<DateRangeInputProps, DateRangeInputState> {
65
134
  private storageProvider;
66
135
  constructor(props: Readonly<DateRangeInputProps>);
@@ -71,14 +140,21 @@ export default class DateRangeInput extends React.Component<DateRangeInputProps,
71
140
  private saveCurrentRangeToQuickAccess;
72
141
  private buildIntervalMenu;
73
142
  private onIntervalMenuClick;
143
+ /**
144
+ * Day whose month the left ("from") calendar shows: one month before `fromDate` when both bounds fall on the
145
+ * same day (so the two calendars show different months), otherwise `fromDate` (one month before today when `null`).
146
+ */
74
147
  getDefaultSelectedDateForFromPanel(fromDate: Dayjs | null, toDate: Dayjs | null): Dayjs;
75
148
  private getFromValue;
76
149
  private getToValue;
150
+ /** Closes the popup and calls {@link DateRangeInputProps.onPopupVisibleChange} with `false`. */
77
151
  closePopup(): void;
78
152
  private onChange;
79
153
  private renderSimplePart;
80
154
  private renderAdvancedPart;
155
+ /** Renders the popup content - the whole component with {@link DateRangeInputProps.renderAsCalendar}. */
81
156
  renderPopup(): React.ReactElement;
157
+ /** Renders the two inputs with their icons and the saved-intervals dialog, without the popup. */
82
158
  renderInput(): React.JSX.Element;
83
159
  render(): any;
84
160
  }
@@ -30,11 +30,17 @@ const useStyles = createStyles(({ token, css }, props) => {
30
30
  middle: token.controlHeight,
31
31
  large: token.controlHeightLG,
32
32
  };
33
+ // mirrors antd input component tokens `paddingInline(SM|LG)`
33
34
  const paddingInlineMap = {
34
35
  small: token.controlPaddingHorizontalSM - token.lineWidth,
35
36
  middle: token.paddingSM - token.lineWidth,
36
37
  large: token.controlPaddingHorizontal - token.lineWidth,
37
38
  };
39
+ /**
40
+ * One block per antd input variant, mirroring `antd/es/input/style/variants.js`.
41
+ * `.focused` stands for the open-popup state, which antd renders as active - not disabled.
42
+ */
43
+ // genOutlinedStyle + genOutlinedStatusStyle
38
44
  const outlined = css `
39
45
  background-color: ${token.colorBgContainer};
40
46
  border: ${token.lineWidth}px ${token.lineType} ${token.colorBorder};
@@ -96,6 +102,8 @@ const useStyles = createStyles(({ token, css }, props) => {
96
102
  }
97
103
  }
98
104
  `;
105
+ // genUnderlinedStyle - bottom border only, no radius, no focus shadow and, notably,
106
+ // no disabled background fill
99
107
  const underlined = css `
100
108
  background-color: ${token.colorBgContainer};
101
109
  border-width: ${token.lineWidth}px 0;
@@ -145,6 +153,7 @@ const useStyles = createStyles(({ token, css }, props) => {
145
153
  }
146
154
  }
147
155
  `;
156
+ // genFilledStyle + genFilledStatusStyle
148
157
  const filled = css `
149
158
  background: ${token.colorFillTertiary};
150
159
  border: ${token.lineWidth}px ${token.lineType} transparent;
@@ -207,6 +216,7 @@ const useStyles = createStyles(({ token, css }, props) => {
207
216
  }
208
217
  }
209
218
  `;
219
+ // genBorderlessStyle - only the text colour reacts to status, the affix is left alone
210
220
  const borderless = css `
211
221
  background: transparent;
212
222
  border: none;
@@ -235,8 +245,11 @@ const useStyles = createStyles(({ token, css }, props) => {
235
245
  }
236
246
  `;
237
247
  const variantStyles = { outlined, underlined, filled, borderless }[variant];
248
+ // underlined is the only variant antd renders without a radius
238
249
  const hasRadius = variant !== "underlined";
250
+ // antd derives the height from padding + border, so a borderless input ends up 2 * lineWidth shorter
239
251
  const height = heightMap[size] - (variant === "borderless" ? 2 * token.lineWidth : 0);
252
+ // antd colours prefix/suffix by status in every variant except borderless
240
253
  const statusAffix = variant !== "borderless";
241
254
  return {
242
255
  baseLayout: css `
@@ -355,11 +368,50 @@ const usePopupStyles = createStyles(({ token, css }) => {
355
368
  `,
356
369
  };
357
370
  });
371
+ /** Layout of the {@link DateRangeInput} popup. */
358
372
  export var DateRangeInputMode;
359
373
  (function (DateRangeInputMode) {
374
+ /** Two month calendars (click a day or drag across days) plus the {@link DateRangeInputProps.ranges} presets. */
360
375
  DateRangeInputMode[DateRangeInputMode["SIMPLE"] = 0] = "SIMPLE";
376
+ /** Two date-time inputs plus buttons for interval begin/end, duration and time shift. */
361
377
  DateRangeInputMode[DateRangeInputMode["ADVANCED"] = 1] = "ADVANCED";
362
378
  })(DateRangeInputMode || (DateRangeInputMode = {}));
379
+ // a value within 1 minute before the end of a month (23:59, 23:59:59, 23:59:59.999) counts as the end of the month
380
+ const MONTH_END_TOLERANCE_MS = 60000;
381
+ // units whose length depends on the length of a month
382
+ const MONTH_BASED_UNITS = ["month", "months", "M", "year", "years", "y"];
383
+ /**
384
+ * Shifts the value by `amount` units of `unit`. If the value lies at the end of a month and is shifted by a month
385
+ * or a year, it stays at the end of the month after the shift (30.09. 23:59:59.999 - 1 month = 31.08. 23:59:59.999, not 30.08.).
386
+ * Other values are shifted normally (15.09. - 1 month = 15.08.).
387
+ */
388
+ function shiftDateValue(value, amount, unit) {
389
+ if (MONTH_BASED_UNITS.includes(unit)) {
390
+ const nextMonthStart = value.endOf("month").add(1, "millisecond");
391
+ const gap = nextMonthStart.diff(value);
392
+ if (gap <= MONTH_END_TOLERANCE_MS) {
393
+ return nextMonthStart.add(amount, unit).subtract(gap, "millisecond");
394
+ }
395
+ }
396
+ return value.add(amount, unit);
397
+ }
398
+ /**
399
+ * Controlled date-time range input: two masked {@link DateTimeInput}s in one antd-styled box with a popup
400
+ * that opens on right-click or via the calendar icon. The popup offers calendars and presets
401
+ * ({@link DateRangeInputMode.SIMPLE}) or interval shortcuts ({@link DateRangeInputMode.ADVANCED}).
402
+ * Every change is reported immediately; use `DateRangeInputConfirm` to apply changes only on confirmation.
403
+ *
404
+ * @example
405
+ * const [range, setRange] = useState<[Dayjs | null, Dayjs | null]>([dayjs().startOf("day"), dayjs().endOf("day")]);
406
+ *
407
+ * <DateRangeInput
408
+ * mask={LocaleHolder.getDateTimeFormat(true, true)}
409
+ * fromValue={range[0]}
410
+ * toValue={range[1]}
411
+ * onChange={(from, to) => setRange([from, to])}
412
+ * ranges={DateTimeUtils.getRanges([DateTimeInterval.DAY_ACT, DateTimeInterval.WEEK_ACT])}
413
+ * />
414
+ */
363
415
  export default class DateRangeInput extends React.Component {
364
416
  constructor(props) {
365
417
  var _a;
@@ -493,6 +545,10 @@ export default class DateRangeInput extends React.Component {
493
545
  }
494
546
  }
495
547
  }
548
+ /**
549
+ * Day whose month the left ("from") calendar shows: one month before `fromDate` when both bounds fall on the
550
+ * same day (so the two calendars show different months), otherwise `fromDate` (one month before today when `null`).
551
+ */
496
552
  getDefaultSelectedDateForFromPanel(fromDate, toDate) {
497
553
  if (!!fromDate && !!toDate && fromDate.isSame(toDate, "date")) {
498
554
  return fromDate.clone().subtract(1, "month");
@@ -509,8 +565,10 @@ export default class DateRangeInput extends React.Component {
509
565
  var _a, _b;
510
566
  return ((_b = (_a = this.props.toValue) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : dayjs().endOf("day")).year(date.year()).month(date.month()).date(date.date());
511
567
  }
568
+ /** Closes the popup and calls {@link DateRangeInputProps.onPopupVisibleChange} with `false`. */
512
569
  closePopup() {
513
570
  var _a, _b;
571
+ // close tooltip
514
572
  this.setState({ popupKeyIndex: this.state.popupKeyIndex + 1, popupVisible: false });
515
573
  (_b = (_a = this.props).onPopupVisibleChange) === null || _b === void 0 ? void 0 : _b.call(_a, false);
516
574
  }
@@ -640,21 +698,12 @@ export default class DateRangeInput extends React.Component {
640
698
  var _a, _b;
641
699
  let fromValue = (_a = this.props.fromValue) !== null && _a !== void 0 ? _a : null;
642
700
  let toValue = (_b = this.props.toValue) !== null && _b !== void 0 ? _b : null;
701
+ const amount = type === TimeShiftDirection.INCREMENT ? 1 : -1;
643
702
  if (shiftBegin && fromValue) {
644
- if (type === TimeShiftDirection.INCREMENT) {
645
- fromValue = fromValue.add(1, unitOfTime);
646
- }
647
- else if (type === TimeShiftDirection.DECREMENT) {
648
- fromValue = fromValue.subtract(1, unitOfTime);
649
- }
703
+ fromValue = shiftDateValue(fromValue, amount, unitOfTime);
650
704
  }
651
705
  if (shiftEnd && toValue) {
652
- if (type === TimeShiftDirection.INCREMENT) {
653
- toValue = toValue.add(1, unitOfTime);
654
- }
655
- else if (type === TimeShiftDirection.DECREMENT) {
656
- toValue = toValue.subtract(1, unitOfTime);
657
- }
706
+ toValue = shiftDateValue(toValue, amount, unitOfTime);
658
707
  }
659
708
  this.onChange(fromValue, toValue);
660
709
  }, onEndIntervalChange: unit => {
@@ -669,6 +718,7 @@ export default class DateRangeInput extends React.Component {
669
718
  this.onChange(this.props.fromValue, to);
670
719
  } }))));
671
720
  }
721
+ /** Renders the popup content - the whole component with {@link DateRangeInputProps.renderAsCalendar}. */
672
722
  renderPopup() {
673
723
  var _a, _b;
674
724
  return (React.createElement("div", { onFocus: this.props.onFocus, onBlur: this.props.onBlur },
@@ -685,6 +735,7 @@ export default class DateRangeInput extends React.Component {
685
735
  }, checkedChildren: i18n("Advanced Mode"), unCheckedChildren: i18n("Simple Mode") })), (_b = (_a = this.props).confirmButtonsRenderer) === null || _b === void 0 ? void 0 :
686
736
  _b.call(_a))));
687
737
  }
738
+ /** Renders the two inputs with their icons and the saved-intervals dialog, without the popup. */
688
739
  renderInput() {
689
740
  const _a = this.props, { className, fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, disabled, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange, showCustomIntervals, intervalStorage, size, status, variant } = _a, props = __rest(_a, ["className", "fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "disabled", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange", "showCustomIntervals", "intervalStorage", "size", "status", "variant"]);
690
741
  return (React.createElement("div", { style: Object.assign(Object.assign({}, style), { padding: 0, position: "relative" }), className: className, onFocus: this.props.onFocus, onBlur: this.props.onBlur },