d2coreui 23.0.51 → 23.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +154 -0
  3. package/components/clipboard/clipboardUtils.d.ts +11 -0
  4. package/components/clipboard/clipboardUtils.js +16 -4
  5. package/components/clipboard/clipboardUtils.js.map +1 -1
  6. package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
  7. package/components/codemirror/SyntaxHighlighter.js +6 -1
  8. package/components/codemirror/SyntaxHighlighter.js.map +1 -1
  9. package/components/collapse/expandable.d.ts +10 -0
  10. package/components/collapse/expandable.js +4 -0
  11. package/components/collapse/expandable.js.map +1 -1
  12. package/components/color/colorPicker.d.ts +16 -0
  13. package/components/color/colorPicker.js +4 -0
  14. package/components/color/colorPicker.js.map +1 -1
  15. package/components/color/colorSwatch.d.ts +16 -0
  16. package/components/color/colorSwatch.js +23 -2
  17. package/components/color/colorSwatch.js.map +1 -1
  18. package/components/color/colorUtils.d.ts +9 -0
  19. package/components/color/colorUtils.js +15 -0
  20. package/components/color/colorUtils.js.map +1 -1
  21. package/components/date/dateRangeInput.d.ts +76 -0
  22. package/components/date/dateRangeInput.js +63 -12
  23. package/components/date/dateRangeInput.js.map +1 -1
  24. package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
  25. package/components/date/dateRangeInputAdvancedPanel.js +7 -0
  26. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  27. package/components/date/dateRangeInputConfirm.d.ts +18 -0
  28. package/components/date/dateRangeInputConfirm.js +12 -0
  29. package/components/date/dateRangeInputConfirm.js.map +1 -1
  30. package/components/date/dateTimeInput.d.ts +99 -0
  31. package/components/date/dateTimeInput.js +78 -6
  32. package/components/date/dateTimeInput.js.map +1 -1
  33. package/components/date/durationInput.d.ts +37 -0
  34. package/components/date/durationInput.js +26 -3
  35. package/components/date/durationInput.js.map +1 -1
  36. package/components/date/savedIntervals.d.ts +63 -0
  37. package/components/date/savedIntervals.js +37 -0
  38. package/components/date/savedIntervals.js.map +1 -1
  39. package/components/date/savedIntervalsDialog.d.ts +13 -0
  40. package/components/date/savedIntervalsDialog.js +7 -2
  41. package/components/date/savedIntervalsDialog.js.map +1 -1
  42. package/components/form/NiceFormItem.d.ts +9 -0
  43. package/components/form/NiceFormItem.js +4 -0
  44. package/components/form/NiceFormItem.js.map +1 -1
  45. package/components/grid/cell/beanAccessor.d.ts +12 -0
  46. package/components/grid/cell/beanAccessor.js +8 -0
  47. package/components/grid/cell/beanAccessor.js.map +1 -1
  48. package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
  49. package/components/grid/cell/bigNumberCellEditor.js +19 -0
  50. package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
  51. package/components/grid/cell/cellControl.d.ts +4 -0
  52. package/components/grid/cell/cellControl.js +14 -0
  53. package/components/grid/cell/cellControl.js.map +1 -1
  54. package/components/grid/cell/cellEditorUtils.d.ts +6 -0
  55. package/components/grid/cell/cellEditorUtils.js +6 -0
  56. package/components/grid/cell/cellEditorUtils.js.map +1 -1
  57. package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
  58. package/components/grid/cell/customEnumCellEditor.js +10 -0
  59. package/components/grid/cell/customEnumCellEditor.js.map +1 -1
  60. package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
  61. package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
  62. package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
  63. package/components/grid/cell/dateCellEditor.d.ts +6 -0
  64. package/components/grid/cell/dateCellEditor.js +10 -0
  65. package/components/grid/cell/dateCellEditor.js.map +1 -1
  66. package/components/grid/cell/dragListenerFeature.d.ts +6 -0
  67. package/components/grid/cell/dragListenerFeature.js +6 -0
  68. package/components/grid/cell/dragListenerFeature.js.map +1 -1
  69. package/components/grid/cell/durationCellEditor.d.ts +6 -0
  70. package/components/grid/cell/durationCellEditor.js +14 -0
  71. package/components/grid/cell/durationCellEditor.js.map +1 -1
  72. package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
  73. package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
  74. package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
  75. package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
  76. package/components/grid/cell/hexaValueCellEditor.js +14 -0
  77. package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
  78. package/components/grid/cell/numberCellEditor.d.ts +6 -0
  79. package/components/grid/cell/numberCellEditor.js +15 -0
  80. package/components/grid/cell/numberCellEditor.js.map +1 -1
  81. package/components/grid/cell/rangeSelector.d.ts +7 -0
  82. package/components/grid/cell/rangeSelector.js +59 -5
  83. package/components/grid/cell/rangeSelector.js.map +1 -1
  84. package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
  85. package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
  86. package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
  87. package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
  88. package/components/grid/cell/statusTextCellEditor.js +17 -0
  89. package/components/grid/cell/statusTextCellEditor.js.map +1 -1
  90. package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
  91. package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
  92. package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
  93. package/components/grid/cell/textCellEditor.d.ts +6 -0
  94. package/components/grid/cell/textCellEditor.js +15 -0
  95. package/components/grid/cell/textCellEditor.js.map +1 -1
  96. package/components/grid/cell/withAgGridHooks.d.ts +8 -0
  97. package/components/grid/cell/withAgGridHooks.js +8 -0
  98. package/components/grid/cell/withAgGridHooks.js.map +1 -1
  99. package/components/grid/columnUtils.d.ts +7 -0
  100. package/components/grid/columnUtils.js +7 -0
  101. package/components/grid/columnUtils.js.map +1 -1
  102. package/components/grid/config/columnTransfer.d.ts +18 -0
  103. package/components/grid/config/columnTransfer.js +14 -3
  104. package/components/grid/config/columnTransfer.js.map +1 -1
  105. package/components/grid/config/dataGridEditor.d.ts +31 -0
  106. package/components/grid/config/dataGridEditor.js +14 -2
  107. package/components/grid/config/dataGridEditor.js.map +1 -1
  108. package/components/grid/config/rowHeightCalculator.d.ts +11 -0
  109. package/components/grid/config/rowHeightCalculator.js +11 -0
  110. package/components/grid/config/rowHeightCalculator.js.map +1 -1
  111. package/components/grid/config/rowStylePicker.d.ts +19 -0
  112. package/components/grid/config/rowStylePicker.js +12 -0
  113. package/components/grid/config/rowStylePicker.js.map +1 -1
  114. package/components/grid/dataGrid.d.ts +331 -0
  115. package/components/grid/dataGrid.js +168 -11
  116. package/components/grid/dataGrid.js.map +1 -1
  117. package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
  118. package/components/grid/detail/detailHeaderPanel.js +5 -0
  119. package/components/grid/detail/detailHeaderPanel.js.map +1 -1
  120. package/components/grid/export/contextMenu.d.ts +31 -0
  121. package/components/grid/export/contextMenu.js +8 -0
  122. package/components/grid/export/contextMenu.js.map +1 -1
  123. package/components/grid/export/progressPopup.d.ts +21 -0
  124. package/components/grid/export/progressPopup.js +17 -0
  125. package/components/grid/export/progressPopup.js.map +1 -1
  126. package/components/grid/export/worker/pdfExport.js +5 -0
  127. package/components/grid/export/worker/pdfExport.js.map +1 -1
  128. package/components/grid/extendedDataGrid.d.ts +241 -0
  129. package/components/grid/extendedDataGrid.js +121 -2
  130. package/components/grid/extendedDataGrid.js.map +1 -1
  131. package/components/grid/filter/customColumnFilter.d.ts +5 -0
  132. package/components/grid/filter/customColumnFilter.js +5 -0
  133. package/components/grid/filter/customColumnFilter.js.map +1 -1
  134. package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
  135. package/components/grid/filter/dataGridColumnFilter.js +19 -0
  136. package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
  137. package/components/grid/filter/dateColumnFilter.d.ts +6 -0
  138. package/components/grid/filter/dateColumnFilter.js +6 -0
  139. package/components/grid/filter/dateColumnFilter.js.map +1 -1
  140. package/components/grid/filter/textColumnFilter.d.ts +6 -0
  141. package/components/grid/filter/textColumnFilter.js +6 -0
  142. package/components/grid/filter/textColumnFilter.js.map +1 -1
  143. package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
  144. package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
  145. package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
  146. package/components/grid/header/simpleHeader.d.ts +17 -0
  147. package/components/grid/header/simpleHeader.js +20 -0
  148. package/components/grid/header/simpleHeader.js.map +1 -1
  149. package/components/grid/panel/dataGridPagination.d.ts +10 -0
  150. package/components/grid/panel/dataGridPagination.js +5 -0
  151. package/components/grid/panel/dataGridPagination.js.map +1 -1
  152. package/components/grid/panel/loadingOverlay.d.ts +5 -0
  153. package/components/grid/panel/loadingOverlay.js +4 -0
  154. package/components/grid/panel/loadingOverlay.js.map +1 -1
  155. package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
  156. package/components/grid/panel/noRecordsOverlay.js +5 -0
  157. package/components/grid/panel/noRecordsOverlay.js.map +1 -1
  158. package/components/grid/panel/tablePagination.d.ts +4 -0
  159. package/components/grid/panel/tablePagination.js +4 -0
  160. package/components/grid/panel/tablePagination.js.map +1 -1
  161. package/components/icons/dropdownArrow.d.ts +3 -0
  162. package/components/icons/dropdownArrow.js +2 -0
  163. package/components/icons/dropdownArrow.js.map +1 -1
  164. package/components/icons/undoIcon.d.ts +2 -0
  165. package/components/icons/undoIcon.js +2 -0
  166. package/components/icons/undoIcon.js.map +1 -1
  167. package/components/input/autoCompleteInput.d.ts +29 -0
  168. package/components/input/autoCompleteInput.js +7 -0
  169. package/components/input/autoCompleteInput.js.map +1 -1
  170. package/components/input/draftUtils.d.ts +7 -0
  171. package/components/input/draftUtils.js +9 -0
  172. package/components/input/draftUtils.js.map +1 -1
  173. package/components/input/hexaFormattedInput.d.ts +9 -0
  174. package/components/input/hexaFormattedInput.js +3 -0
  175. package/components/input/hexaFormattedInput.js.map +1 -1
  176. package/components/input/mask/helpers.d.ts +27 -0
  177. package/components/input/mask/helpers.js +27 -0
  178. package/components/input/mask/helpers.js.map +1 -1
  179. package/components/input/mask/inputMaskCore.d.ts +80 -0
  180. package/components/input/mask/inputMaskCore.js +90 -0
  181. package/components/input/mask/inputMaskCore.js.map +1 -1
  182. package/components/input/mask/pattern.d.ts +24 -0
  183. package/components/input/mask/pattern.js +26 -0
  184. package/components/input/mask/pattern.js.map +1 -1
  185. package/components/input/maskedInput.d.ts +53 -0
  186. package/components/input/maskedInput.js +44 -4
  187. package/components/input/maskedInput.js.map +1 -1
  188. package/components/input/passwordInput.d.ts +7 -0
  189. package/components/input/passwordInput.js +8 -0
  190. package/components/input/passwordInput.js.map +1 -1
  191. package/components/input/simpleAutoComplete.d.ts +6 -0
  192. package/components/input/simpleAutoComplete.js +6 -0
  193. package/components/input/simpleAutoComplete.js.map +1 -1
  194. package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
  195. package/components/input/textarea/extractSpansOfClasses.js +26 -1
  196. package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
  197. package/components/input/textarea/getRanges.d.ts +7 -0
  198. package/components/input/textarea/getRanges.js +11 -0
  199. package/components/input/textarea/getRanges.js.map +1 -1
  200. package/components/input/textarea/getType.d.ts +5 -0
  201. package/components/input/textarea/getType.js +5 -0
  202. package/components/input/textarea/getType.js.map +1 -1
  203. package/components/input/textarea/highlighedContents.d.ts +4 -0
  204. package/components/input/textarea/highlighedContents.js +5 -0
  205. package/components/input/textarea/highlighedContents.js.map +1 -1
  206. package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
  207. package/components/input/textarea/mentionsWithHighlighting.js +14 -0
  208. package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
  209. package/components/keyboard/keyboardUtils.d.ts +6 -0
  210. package/components/keyboard/keyboardUtils.js +6 -0
  211. package/components/keyboard/keyboardUtils.js.map +1 -1
  212. package/components/modal/draggableModalProvider.d.ts +6 -0
  213. package/components/modal/draggableModalProvider.js +7 -0
  214. package/components/modal/draggableModalProvider.js.map +1 -1
  215. package/components/modal/impl/clamp.js +1 -0
  216. package/components/modal/impl/clamp.js.map +1 -1
  217. package/components/modal/impl/draggableModal.d.ts +1 -0
  218. package/components/modal/impl/draggableModal.js +6 -0
  219. package/components/modal/impl/draggableModal.js.map +1 -1
  220. package/components/modal/impl/draggableModalContext.js +1 -0
  221. package/components/modal/impl/draggableModalContext.js.map +1 -1
  222. package/components/modal/impl/draggableModalInner.js +12 -1
  223. package/components/modal/impl/draggableModalInner.js.map +1 -1
  224. package/components/modal/impl/draggableModalReducer.d.ts +7 -1
  225. package/components/modal/impl/draggableModalReducer.js +6 -1
  226. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  227. package/components/modal/impl/draggableModalStyles.d.ts +17 -0
  228. package/components/modal/impl/draggableModalStyles.js +157 -126
  229. package/components/modal/impl/draggableModalStyles.js.map +1 -1
  230. package/components/modal/impl/getWindowSize.js +1 -0
  231. package/components/modal/impl/getWindowSize.js.map +1 -1
  232. package/components/modal/impl/index.js +1 -0
  233. package/components/modal/impl/index.js.map +1 -1
  234. package/components/modal/impl/resizeHandle.d.ts +1 -0
  235. package/components/modal/impl/resizeHandle.js +4 -1
  236. package/components/modal/impl/resizeHandle.js.map +1 -1
  237. package/components/modal/impl/useDrag.js +1 -0
  238. package/components/modal/impl/useDrag.js.map +1 -1
  239. package/components/modal/impl/usePrevious.js +1 -0
  240. package/components/modal/impl/usePrevious.js.map +1 -1
  241. package/components/modal/impl/useResize.js +1 -0
  242. package/components/modal/impl/useResize.js.map +1 -1
  243. package/components/modal/modalDialog.d.ts +85 -0
  244. package/components/modal/modalDialog.js +80 -10
  245. package/components/modal/modalDialog.js.map +1 -1
  246. package/components/picker/enumValuePicker.d.ts +17 -0
  247. package/components/picker/enumValuePicker.js +4 -0
  248. package/components/picker/enumValuePicker.js.map +1 -1
  249. package/components/platformSpecific.d.ts +17 -0
  250. package/components/platformSpecific.js +16 -0
  251. package/components/platformSpecific.js.map +1 -1
  252. package/components/scrollTo/onlyText.d.ts +5 -0
  253. package/components/scrollTo/onlyText.js +5 -0
  254. package/components/scrollTo/onlyText.js.map +1 -1
  255. package/components/scrollTo/scrollTo.d.ts +56 -0
  256. package/components/scrollTo/scrollTo.js +40 -3
  257. package/components/scrollTo/scrollTo.js.map +1 -1
  258. package/components/style/withCss.d.ts +15 -0
  259. package/components/style/withCss.js +6 -0
  260. package/components/style/withCss.js.map +1 -1
  261. package/components/table/dragSortingTable.d.ts +15 -0
  262. package/components/table/dragSortingTable.js +12 -0
  263. package/components/table/dragSortingTable.js.map +1 -1
  264. package/components/text/impl/innerSize.js +2 -0
  265. package/components/text/impl/innerSize.js.map +1 -1
  266. package/components/text/impl/series.d.ts +10 -0
  267. package/components/text/impl/series.js +10 -0
  268. package/components/text/impl/series.js.map +1 -1
  269. package/components/text/impl/shallowEqual.js +1 -0
  270. package/components/text/impl/shallowEqual.js.map +1 -1
  271. package/components/text/impl/whilst.d.ts +7 -0
  272. package/components/text/impl/whilst.js +7 -0
  273. package/components/text/impl/whilst.js.map +1 -1
  274. package/components/text/textFit.d.ts +24 -0
  275. package/components/text/textFit.js +29 -1
  276. package/components/text/textFit.js.map +1 -1
  277. package/i18n/componentsLocaleHolder.d.ts +9 -0
  278. package/i18n/componentsLocaleHolder.js +9 -0
  279. package/i18n/componentsLocaleHolder.js.map +1 -1
  280. package/package.json +4 -3
  281. package/style/index.less +240 -240
@@ -12,6 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import React from "react";
13
13
  import { Select } from "antd";
14
14
  import i18n from "d2core/i18n/i18n";
15
+ /**
16
+ * antd `Select` offering the values of an enum, labelled by the (optionally translated) enum keys.
17
+ * Numeric keys (reverse mappings of numeric TypeScript enums) are skipped.
18
+ */
15
19
  export default class EnumValuePicker extends React.Component {
16
20
  constructor(props) {
17
21
  super(props);
@@ -1 +1 @@
1
- {"version":3,"file":"enumValuePicker.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\"antd\";\r\nimport {DefaultOptionType} from \"rc-select/lib/Select\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\n\r\ntype EnumTypes = string | number;\r\ntype EnumRepresentation<T extends EnumTypes> = { [key in string]: T };\r\n\r\ninterface EnumValuePickerProps<T extends EnumTypes> extends Omit<SelectProps<T>, \"onChange\"> {\r\n allowedValueTypes?: T[]\r\n values: EnumRepresentation<T>\r\n translateValue?: boolean\r\n translationPrefix?: string\r\n\r\n onChange?: (value?: T) => void\r\n}\r\n\r\ninterface EnumValuePickerState {\r\n options: DefaultOptionType[]\r\n}\r\n\r\nexport default class EnumValuePicker<T extends EnumTypes> extends React.Component<EnumValuePickerProps<T>, EnumValuePickerState> {\r\n constructor(props: Readonly<EnumValuePickerProps<T>>) {\r\n super(props);\r\n this.state = {\r\n options: this.getOptions(props.values, props.allowedValueTypes, props.translateValue, props.translationPrefix),\r\n }\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<EnumValuePickerProps<T>>) {\r\n if (prevProps.values !== this.props.values) {\r\n const {values, allowedValueTypes, translateValue, translationPrefix} = this.props;\r\n this.setState({options: this.getOptions(values, allowedValueTypes, translateValue, translationPrefix)});\r\n }\r\n }\r\n\r\n render() {\r\n const {value, allowedValueTypes, onChange, translationPrefix, values, translateValue, ...others} = this.props;\r\n let selectValue: T | null | undefined = value;\r\n\r\n if (selectValue !== undefined && selectValue !== null && allowedValueTypes) {\r\n if (!allowedValueTypes.includes(selectValue)) {\r\n selectValue = undefined;\r\n }\r\n }\r\n\r\n return (\r\n <Select<T> value={selectValue}\r\n onChange={(value) => {\r\n onChange?.(value !== \"\" ? value : undefined);\r\n }}\r\n options={this.state.options}\r\n {...others} />\r\n );\r\n }\r\n\r\n private getOptions(enumValue: EnumRepresentation<T>, allowedValueTypes?: T[], translateValue?: boolean, translationPrefix?: string): DefaultOptionType[] {\r\n return Object.keys(enumValue)\r\n .filter((key) => isNaN(Number(key)) && (!allowedValueTypes || allowedValueTypes.includes(enumValue[key])))\r\n .map((key) => [enumValue[key], key])\r\n .map(([k, v]) => {\r\n let text: EnumTypes = v;\r\n\r\n if (translateValue) {\r\n text = i18n((translationPrefix ?? \"\") + text);\r\n }\r\n\r\n return {\r\n value: k,\r\n label: text,\r\n } as DefaultOptionType\r\n });\r\n }\r\n}"]}
1
+ {"version":3,"file":"enumValuePicker.js","sourceRoot":"","sources":["../../../../components/picker/enumValuePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAc,MAAM,MAAM,CAAC;AAEzC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AA+BpC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,eAAqC,SAAQ,KAAK,CAAC,SAAwD;IAC5H,YAAY,KAAwC;QAChD,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC;SACjH,CAAA;IACL,CAAC;IAED,kBAAkB,CAAC,SAA4C;QAC3D,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACzC,MAAM,EAAC,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAClF,IAAI,CAAC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,CAAC,EAAC,CAAC,CAAC;QAC5G,CAAC;IACL,CAAC;IAED,MAAM;QACF,MAAM,KAA6F,IAAI,CAAC,KAAK,EAAvG,EAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,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,iBAAiB,cAAjB,iBAAiB,GAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAClD,CAAC;YAED,OAAO;gBACH,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,IAAI;aACO,CAAA;QAC1B,CAAC,CAAC,CAAC;IACX,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Select, SelectProps} from \"antd\";\r\nimport {DefaultOptionType} from \"rc-select/lib/Select\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\n\r\n/** Type of enum values supported by {@link EnumValuePicker}. */\r\ntype EnumTypes = string | number;\r\n/** Enum object mapping enum keys to their values. */\r\ntype EnumRepresentation<T extends EnumTypes> = { [key in string]: T };\r\n\r\n/** Props of {@link EnumValuePicker}; other props are passed to antd `Select`. */\r\ninterface EnumValuePickerProps<T extends EnumTypes> extends Omit<SelectProps<T>, \"onChange\"> {\r\n /**\r\n * Restricts the offered options to these values; a current `value` not in the list is displayed as empty.\r\n * Options are rebuilt only when `values` changes, not when this list changes.\r\n */\r\n allowedValueTypes?: T[]\r\n /** The enum object (TypeScript enum or plain key-to-value map); one option per key, labelled by the key. */\r\n values: EnumRepresentation<T>\r\n /** Translates option labels with `i18n`. */\r\n translateValue?: boolean\r\n /** Prefix prepended to the key to form the translation key when {@link EnumValuePickerProps.translateValue} is set. */\r\n translationPrefix?: string\r\n\r\n /** Called with the selected enum value; `undefined` when the selection is cleared. */\r\n onChange?: (value?: T) => void\r\n}\r\n\r\n/** State of {@link EnumValuePicker}. */\r\ninterface EnumValuePickerState {\r\n /** Select options built from the enum. */\r\n options: DefaultOptionType[]\r\n}\r\n\r\n/**\r\n * antd `Select` offering the values of an enum, labelled by the (optionally translated) enum keys.\r\n * Numeric keys (reverse mappings of numeric TypeScript enums) are skipped.\r\n */\r\nexport default class EnumValuePicker<T extends EnumTypes> extends React.Component<EnumValuePickerProps<T>, EnumValuePickerState> {\r\n constructor(props: Readonly<EnumValuePickerProps<T>>) {\r\n super(props);\r\n this.state = {\r\n options: this.getOptions(props.values, props.allowedValueTypes, props.translateValue, props.translationPrefix),\r\n }\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<EnumValuePickerProps<T>>) {\r\n if (prevProps.values !== this.props.values) {\r\n const {values, allowedValueTypes, translateValue, translationPrefix} = this.props;\r\n this.setState({options: this.getOptions(values, allowedValueTypes, translateValue, translationPrefix)});\r\n }\r\n }\r\n\r\n render() {\r\n const {value, allowedValueTypes, onChange, translationPrefix, values, translateValue, ...others} = this.props;\r\n let selectValue: T | null | undefined = value;\r\n\r\n if (selectValue !== undefined && selectValue !== null && allowedValueTypes) {\r\n if (!allowedValueTypes.includes(selectValue)) {\r\n selectValue = undefined;\r\n }\r\n }\r\n\r\n return (\r\n <Select<T> value={selectValue}\r\n onChange={(value) => {\r\n onChange?.(value !== \"\" ? value : undefined);\r\n }}\r\n options={this.state.options}\r\n {...others} />\r\n );\r\n }\r\n\r\n private getOptions(enumValue: EnumRepresentation<T>, allowedValueTypes?: T[], translateValue?: boolean, translationPrefix?: string): DefaultOptionType[] {\r\n return Object.keys(enumValue)\r\n .filter((key) => isNaN(Number(key)) && (!allowedValueTypes || allowedValueTypes.includes(enumValue[key])))\r\n .map((key) => [enumValue[key], key])\r\n .map(([k, v]) => {\r\n let text: EnumTypes = v;\r\n\r\n if (translateValue) {\r\n text = i18n((translationPrefix ?? \"\") + text);\r\n }\r\n\r\n return {\r\n value: k,\r\n label: text,\r\n } as DefaultOptionType\r\n });\r\n }\r\n}"]}
@@ -1,10 +1,27 @@
1
+ /**
2
+ * Hooks through which d2coreui components (e.g. the data grid configuration and export) call into the hosting
3
+ * application. This base implementation is a browser-only fallback with mostly no-op methods; the host replaces
4
+ * {@link PlatformSpecific.INSTANCE} with a subclass at startup.
5
+ */
1
6
  export default class PlatformSpecific {
7
+ /** The implementation used by the components; assign a subclass instance to customize the behavior. */
2
8
  static INSTANCE: PlatformSpecific;
9
+ /** Returns the display name of the current window (used e.g. in saved configuration names); `""` in the base implementation. */
3
10
  getCurrentWindowName(): string;
11
+ /** Returns `true` when the user must not change and save configurations (e.g. grid layout, row styles); `false` in the base implementation. */
4
12
  configurationChangesDisabled(): boolean;
13
+ /** Reloads the current window with its predefined (saved) configuration; no-op in the base implementation. */
5
14
  reloadPageInPredefinedState(): void;
15
+ /** Reloads the current window with its factory (default) configuration; no-op in the base implementation. */
6
16
  reloadPageInFactoryState(): void;
17
+ /** Saves the configuration of the current window; no-op in the base implementation. */
7
18
  saveWindowConfiguration(): void;
19
+ /** Exports the configuration of the current window to a file; no-op in the base implementation. */
8
20
  exportWindowConfiguration(): void;
21
+ /**
22
+ * Saves content to a file. The base implementation triggers a browser download of a `data:text/plain` URL.
23
+ * @param encodeContent `true` when `content` is raw text that the implementation must encode (the base one
24
+ * URI-encodes it); `false` when it is already encoded
25
+ */
9
26
  saveContent(fileName: string, content: string, encodeContent?: boolean): void;
10
27
  }
@@ -1,18 +1,34 @@
1
+ /**
2
+ * Hooks through which d2coreui components (e.g. the data grid configuration and export) call into the hosting
3
+ * application. This base implementation is a browser-only fallback with mostly no-op methods; the host replaces
4
+ * {@link PlatformSpecific.INSTANCE} with a subclass at startup.
5
+ */
1
6
  export default class PlatformSpecific {
7
+ /** Returns the display name of the current window (used e.g. in saved configuration names); `""` in the base implementation. */
2
8
  getCurrentWindowName() {
3
9
  return "";
4
10
  }
11
+ /** Returns `true` when the user must not change and save configurations (e.g. grid layout, row styles); `false` in the base implementation. */
5
12
  configurationChangesDisabled() {
6
13
  return false;
7
14
  }
15
+ /** Reloads the current window with its predefined (saved) configuration; no-op in the base implementation. */
8
16
  reloadPageInPredefinedState() {
9
17
  }
18
+ /** Reloads the current window with its factory (default) configuration; no-op in the base implementation. */
10
19
  reloadPageInFactoryState() {
11
20
  }
21
+ /** Saves the configuration of the current window; no-op in the base implementation. */
12
22
  saveWindowConfiguration() {
13
23
  }
24
+ /** Exports the configuration of the current window to a file; no-op in the base implementation. */
14
25
  exportWindowConfiguration() {
15
26
  }
27
+ /**
28
+ * Saves content to a file. The base implementation triggers a browser download of a `data:text/plain` URL.
29
+ * @param encodeContent `true` when `content` is raw text that the implementation must encode (the base one
30
+ * URI-encodes it); `false` when it is already encoded
31
+ */
16
32
  saveContent(fileName, content, encodeContent) {
17
33
  var element = document.createElement('a');
18
34
  const encodedContent = encodeContent ? encodeURIComponent(content) : content;
@@ -1 +1 @@
1
- {"version":3,"file":"platformSpecific.js","sourceRoot":"","sources":["../../../components/platformSpecific.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAGjC,oBAAoB;QAChB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,4BAA4B;QACxB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,2BAA2B;IAC3B,CAAC;IAED,wBAAwB;IAExB,CAAC;IAED,uBAAuB;IAEvB,CAAC;IAED,yBAAyB;IAEzB,CAAC;IAED,WAAW,CAAC,QAAgB,EAAE,OAAe,EAAE,aAAuB;QAClE,IAAI,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7E,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,gCAAgC,GAAG,cAAc,CAAC,CAAC;QAChF,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ;AAED,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC","sourcesContent":["export default class PlatformSpecific {\r\n static INSTANCE: PlatformSpecific;\r\n\r\n getCurrentWindowName(): string {\r\n return \"\";\r\n }\r\n\r\n configurationChangesDisabled(): boolean {\r\n return false;\r\n }\r\n\r\n reloadPageInPredefinedState(): void {\r\n }\r\n\r\n reloadPageInFactoryState(): void {\r\n\r\n }\r\n\r\n saveWindowConfiguration(): void {\r\n\r\n }\r\n\r\n exportWindowConfiguration(): void {\r\n\r\n }\r\n\r\n saveContent(fileName: string, content: string, encodeContent?: boolean) {\r\n var element = document.createElement('a');\r\n const encodedContent = encodeContent ? encodeURIComponent(content) : content;\r\n element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodedContent);\r\n element.setAttribute('download', fileName);\r\n element.style.display = 'none';\r\n document.body.appendChild(element);\r\n element.click();\r\n document.body.removeChild(element);\r\n }\r\n}\r\n\r\nPlatformSpecific.INSTANCE = new PlatformSpecific();"]}
1
+ {"version":3,"file":"platformSpecific.js","sourceRoot":"","sources":["../../../components/platformSpecific.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAIjC,gIAAgI;IAChI,oBAAoB;QAChB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,+IAA+I;IAC/I,4BAA4B;QACxB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,8GAA8G;IAC9G,2BAA2B;IAC3B,CAAC;IAED,6GAA6G;IAC7G,wBAAwB;IAExB,CAAC;IAED,uFAAuF;IACvF,uBAAuB;IAEvB,CAAC;IAED,mGAAmG;IACnG,yBAAyB;IAEzB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,QAAgB,EAAE,OAAe,EAAE,aAAuB;QAClE,IAAI,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7E,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,gCAAgC,GAAG,cAAc,CAAC,CAAC;QAChF,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ;AAED,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC","sourcesContent":["/**\r\n * Hooks through which d2coreui components (e.g. the data grid configuration and export) call into the hosting\r\n * application. This base implementation is a browser-only fallback with mostly no-op methods; the host replaces\r\n * {@link PlatformSpecific.INSTANCE} with a subclass at startup.\r\n */\r\nexport default class PlatformSpecific {\r\n /** The implementation used by the components; assign a subclass instance to customize the behavior. */\r\n static INSTANCE: PlatformSpecific;\r\n\r\n /** Returns the display name of the current window (used e.g. in saved configuration names); `\"\"` in the base implementation. */\r\n getCurrentWindowName(): string {\r\n return \"\";\r\n }\r\n\r\n /** Returns `true` when the user must not change and save configurations (e.g. grid layout, row styles); `false` in the base implementation. */\r\n configurationChangesDisabled(): boolean {\r\n return false;\r\n }\r\n\r\n /** Reloads the current window with its predefined (saved) configuration; no-op in the base implementation. */\r\n reloadPageInPredefinedState(): void {\r\n }\r\n\r\n /** Reloads the current window with its factory (default) configuration; no-op in the base implementation. */\r\n reloadPageInFactoryState(): void {\r\n\r\n }\r\n\r\n /** Saves the configuration of the current window; no-op in the base implementation. */\r\n saveWindowConfiguration(): void {\r\n\r\n }\r\n\r\n /** Exports the configuration of the current window to a file; no-op in the base implementation. */\r\n exportWindowConfiguration(): void {\r\n\r\n }\r\n\r\n /**\r\n * Saves content to a file. The base implementation triggers a browser download of a `data:text/plain` URL.\r\n * @param encodeContent `true` when `content` is raw text that the implementation must encode (the base one\r\n * URI-encodes it); `false` when it is already encoded\r\n */\r\n saveContent(fileName: string, content: string, encodeContent?: boolean) {\r\n var element = document.createElement('a');\r\n const encodedContent = encodeContent ? encodeURIComponent(content) : content;\r\n element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodedContent);\r\n element.setAttribute('download', fileName);\r\n element.style.display = 'none';\r\n document.body.appendChild(element);\r\n element.click();\r\n document.body.removeChild(element);\r\n }\r\n}\r\n\r\nPlatformSpecific.INSTANCE = new PlatformSpecific();"]}
@@ -1,4 +1,9 @@
1
1
  import type { ReactNode } from 'react';
2
+ /** Converts a primitive React child to text; `undefined`, `null`, booleans and empty objects give an empty string. */
2
3
  export declare const childToString: (child?: React.Key | boolean | {} | null) => string;
4
+ /**
5
+ * Extracts the plain text of React children by concatenating all nested string and number children; elements
6
+ * without children (e.g. `<br/>`, icons) contribute nothing.
7
+ */
3
8
  declare const onlyText: (children: ReactNode) => string;
4
9
  export default onlyText;
@@ -1,5 +1,6 @@
1
1
  import { Children, isValidElement } from 'react';
2
2
  const hasChildren = (element) => isValidElement(element) && Boolean(element.props.children);
3
+ /** Converts a primitive React child to text; `undefined`, `null`, booleans and empty objects give an empty string. */
3
4
  export const childToString = (child) => {
4
5
  if (typeof child === 'undefined' || child === null || typeof child === 'boolean') {
5
6
  return '';
@@ -9,6 +10,10 @@ export const childToString = (child) => {
9
10
  }
10
11
  return child.toString();
11
12
  };
13
+ /**
14
+ * Extracts the plain text of React children by concatenating all nested string and number children; elements
15
+ * without children (e.g. `<br/>`, icons) contribute nothing.
16
+ */
12
17
  const onlyText = (children) => {
13
18
  if (!(children instanceof Array) && !isValidElement(children)) {
14
19
  return childToString(children);
@@ -1 +1 @@
1
- {"version":3,"file":"onlyText.js","sourceRoot":"","sources":["../../../../components/scrollTo/onlyText.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAC,MAAM,OAAO,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,OAAkB,E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AAC,CAAC;IAChC,CAAC,EAAE,EAAE,CAAW,CAAC;AACrB,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import type {ReactElement, ReactNode} from 'react';\r\nimport {Children, isValidElement} from 'react';\r\n\r\nconst hasChildren = (element: ReactNode): element is ReactElement<{ children: ReactNode[] }> =>\r\n isValidElement<{ children?: ReactNode[] }>(element) && Boolean(element.props.children);\r\n\r\nexport const childToString = (child?: React.Key | boolean | {} | null): string => {\r\n if (typeof child === 'undefined' || child === null || typeof child === 'boolean') {\r\n return '';\r\n }\r\n\r\n if (JSON.stringify(child) === '{}') {\r\n return '';\r\n }\r\n\r\n return (child as number | string).toString();\r\n};\r\n\r\nconst onlyText = (children: ReactNode): string => {\r\n if (!(children instanceof Array) && !isValidElement(children)) {\r\n return childToString(children);\r\n }\r\n return Children.toArray(children).reduce((text: string, child: ReactNode): string => {\r\n let newText = '';\r\n if (isValidElement(child) && hasChildren(child)) {\r\n newText = onlyText(child.props.children);\r\n } else if (isValidElement(child) && !hasChildren(child)) {\r\n newText = '';\r\n } else {\r\n newText = childToString(child);\r\n }\r\n return text.concat(newText);\r\n }, '') as string;\r\n};\r\n\r\nexport default onlyText;"]}
1
+ {"version":3,"file":"onlyText.js","sourceRoot":"","sources":["../../../../components/scrollTo/onlyText.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAC,MAAM,OAAO,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,OAAkB,EAAsD,EAAE,CAC3F,cAAc,CAA6B,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAE3F,sHAAsH;AACtH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAuC,EAAU,EAAE;IAC7E,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/E,OAAO,EAAE,CAAC;IACd,CAAC;IAED,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAQ,KAAyB,CAAC,QAAQ,EAAE,CAAC;AACjD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG,CAAC,QAAmB,EAAU,EAAE;IAC7C,IAAI,CAAC,CAAC,QAAQ,YAAY,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5D,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAY,EAAE,KAAgB,EAAU,EAAE;QAChF,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;aAAM,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO,GAAG,EAAE,CAAC;QACjB,CAAC;aAAM,CAAC;YACJ,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,EAAE,EAAE,CAAW,CAAC;AACrB,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import type {ReactElement, ReactNode} from 'react';\r\nimport {Children, isValidElement} from 'react';\r\n\r\nconst hasChildren = (element: ReactNode): element is ReactElement<{ children: ReactNode[] }> =>\r\n isValidElement<{ children?: ReactNode[] }>(element) && Boolean(element.props.children);\r\n\r\n/** Converts a primitive React child to text; `undefined`, `null`, booleans and empty objects give an empty string. */\r\nexport const childToString = (child?: React.Key | boolean | {} | null): string => {\r\n if (typeof child === 'undefined' || child === null || typeof child === 'boolean') {\r\n return '';\r\n }\r\n\r\n if (JSON.stringify(child) === '{}') {\r\n return '';\r\n }\r\n\r\n return (child as number | string).toString();\r\n};\r\n\r\n/**\r\n * Extracts the plain text of React children by concatenating all nested string and number children; elements\r\n * without children (e.g. `<br/>`, icons) contribute nothing.\r\n */\r\nconst onlyText = (children: ReactNode): string => {\r\n if (!(children instanceof Array) && !isValidElement(children)) {\r\n return childToString(children);\r\n }\r\n return Children.toArray(children).reduce((text: string, child: ReactNode): string => {\r\n let newText = '';\r\n if (isValidElement(child) && hasChildren(child)) {\r\n newText = onlyText(child.props.children);\r\n } else if (isValidElement(child) && !hasChildren(child)) {\r\n newText = '';\r\n } else {\r\n newText = childToString(child);\r\n }\r\n return text.concat(newText);\r\n }, '') as string;\r\n};\r\n\r\nexport default onlyText;"]}
@@ -1,12 +1,31 @@
1
1
  import * as React from 'react';
2
2
  import { Component } from 'react';
3
3
  interface ScrollToItemProps {
4
+ /**
5
+ * Marks the item as selected (CSS class `selected`); {@link ScrollTo} scrolls to it on mount and starts arrow-key
6
+ * navigation from it.
7
+ */
4
8
  selected?: boolean;
9
+ /** Identifier exposed as `data-key` and passed to {@link ScrollToProps.supressKeyboardEvent}. */
5
10
  selectionKey?: string;
11
+ /**
12
+ * CSS class of the span that wraps the type-ahead match inside the item.
13
+ * @default "marked-text"
14
+ */
6
15
  markedTextClassName?: string;
16
+ /**
17
+ * HTML string rendered instead of `children`; its text without tags is used for the type-ahead search. Unlike the
18
+ * React prop of the same name, this is a plain string.
19
+ */
7
20
  dangerouslySetInnerHTML?: string;
21
+ /** Item content; its text is used for the type-ahead search. */
8
22
  children?: React.ReactNode;
9
23
  }
24
+ /**
25
+ * Focusable item inside {@link ScrollTo}, reachable by arrow keys and type-ahead search. While a search is active,
26
+ * the first occurrence of the search text in the item is highlighted; the children are then rendered as static HTML
27
+ * (via `ReactDOMServer`), so their event handlers and state are not active during the search.
28
+ */
10
29
  export declare class ScrollToItem extends Component<ScrollToItemProps> {
11
30
  static contextType: React.Context<string>;
12
31
  constructor(props: Readonly<ScrollToItemProps>);
@@ -16,25 +35,62 @@ export declare class ScrollToItem extends Component<ScrollToItemProps> {
16
35
  render(): React.JSX.Element;
17
36
  }
18
37
  interface ScrollToProps {
38
+ /** Scrolls the first selected {@link ScrollToItem} into view after mount. */
19
39
  scrollOnMount?: boolean;
40
+ /**
41
+ * Called on each handled key press with the `selectionKey` of the focused item; return true to cancel the
42
+ * event's default action and skip the built-in keyboard handling.
43
+ */
20
44
  supressKeyboardEvent?(selectionKey: string | undefined, event: React.KeyboardEvent): boolean;
45
+ /** Content containing {@link ScrollToItem}s, at any depth. */
21
46
  children?: React.ReactNode;
22
47
  }
23
48
  interface ScrollToState {
24
49
  searchString: string;
25
50
  searchStringFound: boolean;
26
51
  }
52
+ /**
53
+ * Keyboard-navigable area of {@link ScrollToItem}s. ArrowUp/ArrowDown move the focus between items and scroll them
54
+ * into view; typing printable characters builds a type-ahead search (shown in a tooltip) that focuses the first
55
+ * matching item, after which the arrows cycle through the matches only. Backspace edits the search, Escape or a click
56
+ * clears it, and Enter clicks the focused item. Keys are ignored while an `input` has focus or Ctrl/Alt is pressed.
57
+ */
27
58
  export default class ScrollTo extends Component<ScrollToProps, ScrollToState> {
59
+ /** The wrapping element of the items. */
28
60
  scrollWrapper: HTMLElement | null;
61
+ /** The nearest scrollable ancestor of the wrapper, or `document.body`. */
29
62
  scrollParent: HTMLElement | null;
30
63
  constructor(props: Readonly<ScrollToProps>);
31
64
  componentDidMount(): void;
65
+ /**
66
+ * Scrolls `scrollToElem` into view within {@link ScrollTo.scrollParent} if it is not visible, keeping a 50 px margin.
67
+ * Debounced (400 ms).
68
+ * @param scrollingUp align the element with the top instead of the bottom.
69
+ */
32
70
  scrollToElement(scrollToElem: HTMLElement, scrollingUp?: boolean): void;
71
+ /**
72
+ * Finds the nearest ancestor of `element` with `auto`/`scroll` overflow (also `hidden` when `includeHidden`).
73
+ * @returns the ancestor, or `document.body` when there is none or `element` is fixed.
74
+ */
33
75
  getScrollParent(element: HTMLElement, includeHidden?: boolean): HTMLElement;
76
+ /**
77
+ * Focuses and scrolls to the item after `currentElement` in `selectables`; does nothing at the last one and starts
78
+ * at the first item when `currentElement` is not in the list.
79
+ */
34
80
  focusNext(currentElement: HTMLElement, selectables: HTMLElement[]): void;
81
+ /** Scrolls the last item into view without focusing it. */
35
82
  scrollToLast(): void;
83
+ /** Focuses the last item and scrolls it into view. */
36
84
  focusToLast(): void;
85
+ /**
86
+ * Focuses and scrolls to the item before `currentElement` in `selectables`; does nothing at the first one and starts
87
+ * at the last item when `currentElement` is not in the list.
88
+ */
37
89
  focusPrev(currentElement: HTMLElement, selectables: HTMLElement[]): void;
90
+ /**
91
+ * Focuses and scrolls to the first item whose text contains `searchString` (case-insensitive).
92
+ * @returns the focused item, or a nullish value when none matches.
93
+ */
38
94
  focusBySearchString(searchString: string): HTMLElement;
39
95
  render(): React.JSX.Element;
40
96
  }
@@ -9,6 +9,11 @@ import ReactDOMServer from "react-dom/server";
9
9
  import { Key } from "ts-key-enum";
10
10
  import KeyboardUtils from "../keyboard/keyboardUtils";
11
11
  const MarkTextContext = React.createContext("");
12
+ /**
13
+ * Focusable item inside {@link ScrollTo}, reachable by arrow keys and type-ahead search. While a search is active,
14
+ * the first occurrence of the search text in the item is highlighted; the children are then rendered as static HTML
15
+ * (via `ReactDOMServer`), so their event handlers and state are not active during the search.
16
+ */
12
17
  export class ScrollToItem extends Component {
13
18
  constructor(props) {
14
19
  super(props);
@@ -70,10 +75,18 @@ export class ScrollToItem extends Component {
70
75
  }
71
76
  }
72
77
  ScrollToItem.contextType = MarkTextContext;
78
+ /**
79
+ * Keyboard-navigable area of {@link ScrollToItem}s. ArrowUp/ArrowDown move the focus between items and scroll them
80
+ * into view; typing printable characters builds a type-ahead search (shown in a tooltip) that focuses the first
81
+ * matching item, after which the arrows cycle through the matches only. Backspace edits the search, Escape or a click
82
+ * clears it, and Enter clicks the focused item. Keys are ignored while an `input` has focus or Ctrl/Alt is pressed.
83
+ */
73
84
  export default class ScrollTo extends Component {
74
85
  constructor(props) {
75
86
  super(props);
87
+ /** The wrapping element of the items. */
76
88
  this.scrollWrapper = null;
89
+ /** The nearest scrollable ancestor of the wrapper, or `document.body`. */
77
90
  this.scrollParent = null;
78
91
  this.state = {
79
92
  searchString: "",
@@ -82,6 +95,7 @@ export default class ScrollTo extends Component {
82
95
  this.scrollToElement = debounce(this.scrollToElement, 400, { maxWait: 400 });
83
96
  }
84
97
  componentDidMount() {
98
+ // initial scrolling to position of selected node
85
99
  if (this.props.scrollOnMount && this.scrollWrapper) {
86
100
  const scrollToElement = this.scrollWrapper.querySelector(".selected");
87
101
  if (scrollToElement) {
@@ -89,6 +103,11 @@ export default class ScrollTo extends Component {
89
103
  }
90
104
  }
91
105
  }
106
+ /**
107
+ * Scrolls `scrollToElem` into view within {@link ScrollTo.scrollParent} if it is not visible, keeping a 50 px margin.
108
+ * Debounced (400 ms).
109
+ * @param scrollingUp align the element with the top instead of the bottom.
110
+ */
92
111
  scrollToElement(scrollToElem, scrollingUp = false) {
93
112
  scrollIntoView(scrollToElem, this.scrollParent, {
94
113
  onlyScrollIfNeeded: true,
@@ -98,6 +117,10 @@ export default class ScrollTo extends Component {
98
117
  offsetBottom: 50,
99
118
  });
100
119
  }
120
+ /**
121
+ * Finds the nearest ancestor of `element` with `auto`/`scroll` overflow (also `hidden` when `includeHidden`).
122
+ * @returns the ancestor, or `document.body` when there is none or `element` is fixed.
123
+ */
101
124
  getScrollParent(element, includeHidden = false) {
102
125
  var style = getComputedStyle(element);
103
126
  var excludeStaticParent = style.position === "absolute";
@@ -115,6 +138,10 @@ export default class ScrollTo extends Component {
115
138
  }
116
139
  return document.body;
117
140
  }
141
+ /**
142
+ * Focuses and scrolls to the item after `currentElement` in `selectables`; does nothing at the last one and starts
143
+ * at the first item when `currentElement` is not in the list.
144
+ */
118
145
  focusNext(currentElement, selectables) {
119
146
  if (currentElement) {
120
147
  const currentElementIndex = selectables.indexOf(currentElement);
@@ -133,18 +160,20 @@ export default class ScrollTo extends Component {
133
160
  this.scrollToElement(selectables[0]);
134
161
  }
135
162
  }
163
+ /** Scrolls the last item into view without focusing it. */
136
164
  scrollToLast() {
137
165
  if (!!this.scrollWrapper) {
138
- let selectables = Array.from(this.scrollWrapper.getElementsByClassName("selectable"));
166
+ let selectables = Array.from(this.scrollWrapper.getElementsByClassName("selectable")); //get all selectable elements
139
167
  if (selectables.length > 0) {
140
168
  const focusedElement = selectables[selectables.length - 1];
141
169
  this.scrollToElement(focusedElement, false);
142
170
  }
143
171
  }
144
172
  }
173
+ /** Focuses the last item and scrolls it into view. */
145
174
  focusToLast() {
146
175
  if (!!this.scrollWrapper) {
147
- let selectables = Array.from(this.scrollWrapper.getElementsByClassName("selectable"));
176
+ let selectables = Array.from(this.scrollWrapper.getElementsByClassName("selectable")); //get all selectable elements
148
177
  if (selectables.length > 0) {
149
178
  const focusedElement = selectables[selectables.length - 1];
150
179
  focusedElement.focus();
@@ -152,6 +181,10 @@ export default class ScrollTo extends Component {
152
181
  }
153
182
  }
154
183
  }
184
+ /**
185
+ * Focuses and scrolls to the item before `currentElement` in `selectables`; does nothing at the first one and starts
186
+ * at the last item when `currentElement` is not in the list.
187
+ */
155
188
  focusPrev(currentElement, selectables) {
156
189
  if (currentElement) {
157
190
  const currentElementIndex = selectables.indexOf(currentElement);
@@ -171,6 +204,10 @@ export default class ScrollTo extends Component {
171
204
  this.scrollToElement(scrollToElem);
172
205
  }
173
206
  }
207
+ /**
208
+ * Focuses and scrolls to the first item whose text contains `searchString` (case-insensitive).
209
+ * @returns the focused item, or a nullish value when none matches.
210
+ */
174
211
  focusBySearchString(searchString) {
175
212
  var _a;
176
213
  const elementToFocus = (_a = this.scrollWrapper) === null || _a === void 0 ? void 0 : _a.querySelector(`.selectable[data-content*="${searchString.toLowerCase()}"]`);
@@ -211,7 +248,7 @@ export default class ScrollTo extends Component {
211
248
  selectables = Array.from(this.scrollWrapper.querySelectorAll(`.selectable[data-content*="${this.state.searchString.toLowerCase()}"]`));
212
249
  }
213
250
  else {
214
- selectables = Array.from(this.scrollWrapper.getElementsByClassName("selectable"));
251
+ selectables = Array.from(this.scrollWrapper.getElementsByClassName("selectable")); //get all selectable elements
215
252
  }
216
253
  const focusedElementIndex = selectables.indexOf(focusedElement);
217
254
  if (e.key === Key.ArrowDown || e.key === Key.ArrowUp) {
@@ -1 +1 @@
1
- {"version":3,"file":"scrollTo.js","sourceRoot":"","sources":["../../../../components/scrollTo/scrollTo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,SAAS,EAAe,MAAM,OAAO,CAAA;AAC7C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,QAAQ,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAC7B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAEtD,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;AAkBhD,MAAM,OAAO,YAAa,SAAQ,SAA4B;IAG1D,YAAY,KAAkC;QAC1C,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,sBAAsB,GAAG,UAAU,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjF,IAAI,CAAC,sBAAsB,GAAG,UAAU,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAA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AC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,EACvF,KAAK,EAAE,EAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,EAAC,EACvE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;oBAC/D,iCAAO,CACD,CACR;YACN,oBAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IACnD,IAAI,CAAC,KAAK,CAAC,QAAQ,CACG,CACzB,CAAC,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import * as React from 'react'\r\nimport {Component, ReactElement} from 'react'\r\nimport scrollIntoView from \"dom-scroll-into-view\";\r\nimport debounce from \"lodash/debounce\"\r\nimport {Tooltip} from \"antd\";\r\nimport onlyText from './onlyText';\r\nimport memoizeOne from \"memoize-one\";\r\nimport ReactDOMServer from \"react-dom/server\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"../keyboard/keyboardUtils\";\r\n\r\nconst MarkTextContext = React.createContext(\"\");\r\n\r\ninterface ScrollToItemProps {\r\n /* flag to notify currently selected item*/\r\n selected?: boolean\r\n\r\n selectionKey?: string\r\n\r\n markedTextClassName?: string\r\n\r\n dangerouslySetInnerHTML?: string\r\n\r\n children?: React.ReactNode;\r\n}\r\n\r\n/*\r\n* Item component where user can be scrolled in\r\n*/\r\nexport class ScrollToItem extends Component<ScrollToItemProps> {\r\n static contextType = MarkTextContext;\r\n\r\n constructor(props: Readonly<ScrollToItemProps>) {\r\n super(props);\r\n this.getChildrenTextContent = memoizeOne(this.getChildrenTextContent.bind(this));\r\n this.getChildrenHtmlContent = memoizeOne(this.getChildrenHtmlContent.bind(this));\r\n }\r\n\r\n getChildrenTextContent(children: React.ReactNode | undefined) {\r\n if (!!this.props.dangerouslySetInnerHTML) {\r\n return this.props.dangerouslySetInnerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();\r\n } else if (children === undefined) {\r\n return \"\";\r\n } else {\r\n return onlyText(children).toLowerCase();\r\n }\r\n }\r\n\r\n getChildrenHtmlContent(children: React.ReactNode | undefined, markedString: string) {\r\n let htmlCode: string;\r\n if (!!this.props.dangerouslySetInnerHTML) {\r\n htmlCode = this.props.dangerouslySetInnerHTML;\r\n } else {\r\n switch (typeof children) {\r\n case \"string\":\r\n htmlCode = children;\r\n break;\r\n case \"undefined\":\r\n htmlCode = \"\";\r\n break;\r\n default:\r\n htmlCode = ReactDOMServer.renderToString(children as ReactElement);\r\n }\r\n }\r\n\r\n const markedStringIndex = htmlCode.toLowerCase().indexOf(markedString);\r\n if (markedStringIndex >= 0) {\r\n const markedTextClassName = this.props.markedTextClassName ? this.props.markedTextClassName : \"marked-text\";\r\n return htmlCode.substring(0, markedStringIndex) + \"<span class=\\\"\" + markedTextClassName + \"\\\">\" + htmlCode.substring(markedStringIndex, markedStringIndex + markedString.length) + \"</span>\" + htmlCode.substring(markedStringIndex + markedString.length);\r\n } else {\r\n return htmlCode;\r\n }\r\n }\r\n\r\n renderChildren() {\r\n if (this.context) {\r\n const childrenHtmlContent = this.getChildrenHtmlContent(this.props.children, this.context as string);\r\n return <span dangerouslySetInnerHTML={{__html: childrenHtmlContent}}/>\r\n } else if (!!this.props.dangerouslySetInnerHTML) {\r\n return <span dangerouslySetInnerHTML={{__html: this.props.dangerouslySetInnerHTML}}/>\r\n } else {\r\n return this.props.children;\r\n }\r\n }\r\n\r\n render() {\r\n const textContent = this.getChildrenTextContent(this.props.children);\r\n return (\r\n <span tabIndex={0}\r\n className={`selectable ${this.props.selected ? \"selected\" : \"\"}`}\r\n data-content={textContent}\r\n data-key={this.props.selectionKey}\r\n >\r\n {this.renderChildren()}\r\n </span>\r\n );\r\n }\r\n}\r\n\r\ninterface ScrollToProps {\r\n /* scroll to position of first selected ScrollToItem element after initialization*/\r\n scrollOnMount?: boolean\r\n\r\n supressKeyboardEvent?(selectionKey: string | undefined, event: React.KeyboardEvent): boolean\r\n\r\n children?: React.ReactNode;\r\n}\r\n\r\ninterface ScrollToState {\r\n /* current search string entered by user*/\r\n searchString: string\r\n /* checks if search string is found in at least one item */\r\n searchStringFound: boolean\r\n}\r\n\r\n/**\r\n * Wrapper component for area with items where user can be scrolled in\r\n */\r\nexport default class ScrollTo extends Component<ScrollToProps, ScrollToState> {\r\n /* internal reference to wrapping element of container with items*/\r\n scrollWrapper: HTMLElement | null = null;\r\n /* internal reference to parent element with enabled scrolling */\r\n scrollParent: HTMLElement | null = null;\r\n\r\n constructor(props: Readonly<ScrollToProps>) {\r\n super(props);\r\n this.state = {\r\n searchString: \"\",\r\n searchStringFound: false,\r\n };\r\n this.scrollToElement = debounce(this.scrollToElement, 400, {maxWait: 400});\r\n }\r\n\r\n componentDidMount(): void {\r\n // initial scrolling to position of selected node\r\n if (this.props.scrollOnMount && this.scrollWrapper) {\r\n const scrollToElement = this.scrollWrapper.querySelector(\".selected\");\r\n if (scrollToElement) {\r\n this.scrollToElement(scrollToElement as HTMLElement);\r\n }\r\n }\r\n }\r\n\r\n scrollToElement(scrollToElem: HTMLElement, scrollingUp = false): void {\r\n scrollIntoView(scrollToElem, this.scrollParent, {\r\n onlyScrollIfNeeded: true,\r\n allowHorizontalScroll: false,\r\n alignWithTop: scrollingUp,\r\n offsetTop: 50,\r\n offsetBottom: 50,\r\n });\r\n }\r\n\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 focusNext(currentElement: HTMLElement, selectables: HTMLElement[]): void {\r\n if (currentElement) {\r\n const currentElementIndex = selectables.indexOf(currentElement);\r\n if (currentElementIndex >= 0 && currentElementIndex < selectables.length - 1) {\r\n const scrollToElem = selectables[currentElementIndex + 1];\r\n scrollToElem.focus();\r\n this.scrollToElement(scrollToElem);\r\n return;\r\n } else if (currentElementIndex === selectables.length - 1) {\r\n return;\r\n }\r\n }\r\n if (selectables.length > 0) {\r\n selectables[0].focus();\r\n this.scrollToElement(selectables[0])\r\n }\r\n }\r\n\r\n scrollToLast(): void {\r\n if (!!this.scrollWrapper) {\r\n let selectables: HTMLElement[] = Array.from(this.scrollWrapper.getElementsByClassName(\"selectable\")) as HTMLElement[]; //get all selectable elements\r\n if (selectables.length > 0) {\r\n const focusedElement = selectables[selectables.length - 1];\r\n this.scrollToElement(focusedElement, false);\r\n }\r\n }\r\n }\r\n\r\n focusToLast(): void {\r\n if (!!this.scrollWrapper) {\r\n let selectables: HTMLElement[] = Array.from(this.scrollWrapper.getElementsByClassName(\"selectable\")) as HTMLElement[]; //get all selectable elements\r\n if (selectables.length > 0) {\r\n const focusedElement = selectables[selectables.length - 1];\r\n focusedElement.focus();\r\n this.scrollToElement(focusedElement, false);\r\n }\r\n }\r\n }\r\n\r\n focusPrev(currentElement: HTMLElement, selectables: HTMLElement[]): void {\r\n if (currentElement) {\r\n const currentElementIndex = selectables.indexOf(currentElement);\r\n if (currentElementIndex > 0) {\r\n const scrollToElem = selectables[currentElementIndex - 1];\r\n scrollToElem.focus();\r\n this.scrollToElement(scrollToElem);\r\n return;\r\n } else if (currentElementIndex === 0) {\r\n return;\r\n }\r\n }\r\n if (selectables.length > 0) {\r\n const scrollToElem = selectables[selectables.length - 1];\r\n scrollToElem.focus();\r\n this.scrollToElement(scrollToElem);\r\n }\r\n }\r\n\r\n focusBySearchString(searchString: string): HTMLElement {\r\n const elementToFocus = this.scrollWrapper?.querySelector(`.selectable[data-content*=\"${searchString.toLowerCase()}\"]`) as any;\r\n if (elementToFocus) {\r\n elementToFocus.focus();\r\n this.scrollToElement(elementToFocus as HTMLElement);\r\n }\r\n return elementToFocus;\r\n }\r\n\r\n render() {\r\n return (\r\n <div ref={(scrollWrapper) => {\r\n this.scrollWrapper = scrollWrapper;\r\n if (this.scrollWrapper) {\r\n this.scrollParent = this.getScrollParent(this.scrollWrapper);\r\n } else {\r\n this.scrollParent = null;\r\n }\r\n }}\r\n tabIndex={-1}\r\n onKeyDown={(e: React.KeyboardEvent<HTMLDivElement>) => {\r\n if (e.target instanceof HTMLInputElement) {\r\n return;\r\n }\r\n if (!this.scrollWrapper) {\r\n return;\r\n }\r\n if (KeyboardUtils.isKeyPressed(Key.Control) || KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n return;\r\n }\r\n const supressKeyboardEvent = this.props.supressKeyboardEvent?.((document.activeElement as any)?.dataset?.key, e);\r\n if (supressKeyboardEvent) {\r\n e.preventDefault();\r\n return;\r\n }\r\n let focusedElement: HTMLElement | null = document.activeElement as HTMLElement;\r\n let selectables: HTMLElement[];\r\n if (this.state.searchString && this.state.searchStringFound) {\r\n selectables = Array.from(this.scrollWrapper.querySelectorAll(`.selectable[data-content*=\"${this.state.searchString.toLowerCase()}\"]`));\r\n } else {\r\n selectables = Array.from(this.scrollWrapper.getElementsByClassName(\"selectable\")) as HTMLElement[]; //get all selectable elements\r\n }\r\n const focusedElementIndex = selectables.indexOf(focusedElement);\r\n if (e.key === Key.ArrowDown || e.key === Key.ArrowUp) {\r\n e.preventDefault();\r\n if (!focusedElement || focusedElementIndex < 0) {\r\n const selectedElements = Array.from(this.scrollWrapper.getElementsByClassName(\"selected\"));\r\n focusedElement = selectedElements.length > 0 ? selectedElements[0] as HTMLElement : null;\r\n }\r\n if (e.key === Key.ArrowDown && focusedElement) {\r\n this.focusNext(focusedElement, selectables);\r\n } else if (e.key === Key.ArrowUp && focusedElement) {\r\n this.focusPrev(focusedElement, selectables);\r\n }\r\n } else if (e.key === Key.Enter && focusedElementIndex >= 0) {\r\n if (typeof focusedElement.click == \"function\") {\r\n focusedElement.click.apply(focusedElement);\r\n }\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n } else if (e.key.length === 1) {\r\n const searchString = this.state.searchString + e.key;\r\n const focusedElement = this.focusBySearchString(searchString);\r\n this.setState({searchString: searchString, searchStringFound: !!focusedElement},);\r\n } else if (e.key === Key.Backspace) {\r\n const searchString = this.state.searchString.slice(0, -1);\r\n const focusedElement = this.focusBySearchString(searchString);\r\n this.setState({searchString: searchString, searchStringFound: !!focusedElement})\r\n } else if (e.key === Key.Escape) {\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n }\r\n }}\r\n onClick={() => {\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n }}\r\n onBlur={(_: React.FocusEvent<HTMLDivElement>) => {\r\n setTimeout(() => {\r\n if (!document.activeElement?.className?.includes(\"selectable\") && (this.state.searchString !== \"\" || this.state.searchStringFound)) {\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n }\r\n }, 0);\r\n\r\n }}\r\n >\r\n <div style={{position: \"fixed\", top: 16, left: 16}}>\r\n <Tooltip\r\n overlayClassName={!this.state.searchStringFound ? \"search-string-not-found\" : undefined}\r\n align={{points: [\"tl\", \"tl\"], overflow: {adjustX: true, adjustY: true}}}\r\n open={!!this.state.searchString} title={this.state.searchString}>\r\n <span/>\r\n </Tooltip>\r\n </div>\r\n <MarkTextContext.Provider value={this.state.searchString}>\r\n {this.props.children}\r\n </MarkTextContext.Provider>\r\n </div>);\r\n }\r\n}"]}
1
+ {"version":3,"file":"scrollTo.js","sourceRoot":"","sources":["../../../../components/scrollTo/scrollTo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,SAA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,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;oBAC/D,iCAAO,CACD,CACR;YACN,oBAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IACnD,IAAI,CAAC,KAAK,CAAC,QAAQ,CACG,CACzB,CAAC,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import * as React from 'react'\r\nimport {Component, ReactElement} from 'react'\r\nimport scrollIntoView from \"dom-scroll-into-view\";\r\nimport debounce from \"lodash/debounce\"\r\nimport {Tooltip} from \"antd\";\r\nimport onlyText from './onlyText';\r\nimport memoizeOne from \"memoize-one\";\r\nimport ReactDOMServer from \"react-dom/server\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"../keyboard/keyboardUtils\";\r\n\r\nconst MarkTextContext = React.createContext(\"\");\r\n\r\ninterface ScrollToItemProps {\r\n /**\r\n * Marks the item as selected (CSS class `selected`); {@link ScrollTo} scrolls to it on mount and starts arrow-key\r\n * navigation from it.\r\n */\r\n selected?: boolean\r\n\r\n /** Identifier exposed as `data-key` and passed to {@link ScrollToProps.supressKeyboardEvent}. */\r\n selectionKey?: string\r\n\r\n /**\r\n * CSS class of the span that wraps the type-ahead match inside the item.\r\n * @default \"marked-text\"\r\n */\r\n markedTextClassName?: string\r\n\r\n /**\r\n * HTML string rendered instead of `children`; its text without tags is used for the type-ahead search. Unlike the\r\n * React prop of the same name, this is a plain string.\r\n */\r\n dangerouslySetInnerHTML?: string\r\n\r\n /** Item content; its text is used for the type-ahead search. */\r\n children?: React.ReactNode;\r\n}\r\n\r\n/**\r\n * Focusable item inside {@link ScrollTo}, reachable by arrow keys and type-ahead search. While a search is active,\r\n * the first occurrence of the search text in the item is highlighted; the children are then rendered as static HTML\r\n * (via `ReactDOMServer`), so their event handlers and state are not active during the search.\r\n */\r\nexport class ScrollToItem extends Component<ScrollToItemProps> {\r\n static contextType = MarkTextContext;\r\n\r\n constructor(props: Readonly<ScrollToItemProps>) {\r\n super(props);\r\n this.getChildrenTextContent = memoizeOne(this.getChildrenTextContent.bind(this));\r\n this.getChildrenHtmlContent = memoizeOne(this.getChildrenHtmlContent.bind(this));\r\n }\r\n\r\n getChildrenTextContent(children: React.ReactNode | undefined) {\r\n if (!!this.props.dangerouslySetInnerHTML) {\r\n return this.props.dangerouslySetInnerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();\r\n } else if (children === undefined) {\r\n return \"\";\r\n } else {\r\n return onlyText(children).toLowerCase();\r\n }\r\n }\r\n\r\n getChildrenHtmlContent(children: React.ReactNode | undefined, markedString: string) {\r\n let htmlCode: string;\r\n if (!!this.props.dangerouslySetInnerHTML) {\r\n htmlCode = this.props.dangerouslySetInnerHTML;\r\n } else {\r\n switch (typeof children) {\r\n case \"string\":\r\n htmlCode = children;\r\n break;\r\n case \"undefined\":\r\n htmlCode = \"\";\r\n break;\r\n default:\r\n htmlCode = ReactDOMServer.renderToString(children as ReactElement);\r\n }\r\n }\r\n\r\n const markedStringIndex = htmlCode.toLowerCase().indexOf(markedString);\r\n if (markedStringIndex >= 0) {\r\n const markedTextClassName = this.props.markedTextClassName ? this.props.markedTextClassName : \"marked-text\";\r\n return htmlCode.substring(0, markedStringIndex) + \"<span class=\\\"\" + markedTextClassName + \"\\\">\" + htmlCode.substring(markedStringIndex, markedStringIndex + markedString.length) + \"</span>\" + htmlCode.substring(markedStringIndex + markedString.length);\r\n } else {\r\n return htmlCode;\r\n }\r\n }\r\n\r\n renderChildren() {\r\n if (this.context) {\r\n const childrenHtmlContent = this.getChildrenHtmlContent(this.props.children, this.context as string);\r\n return <span dangerouslySetInnerHTML={{__html: childrenHtmlContent}}/>\r\n } else if (!!this.props.dangerouslySetInnerHTML) {\r\n return <span dangerouslySetInnerHTML={{__html: this.props.dangerouslySetInnerHTML}}/>\r\n } else {\r\n return this.props.children;\r\n }\r\n }\r\n\r\n render() {\r\n const textContent = this.getChildrenTextContent(this.props.children);\r\n return (\r\n <span tabIndex={0}\r\n className={`selectable ${this.props.selected ? \"selected\" : \"\"}`}\r\n data-content={textContent}\r\n data-key={this.props.selectionKey}\r\n >\r\n {this.renderChildren()}\r\n </span>\r\n );\r\n }\r\n}\r\n\r\ninterface ScrollToProps {\r\n /** Scrolls the first selected {@link ScrollToItem} into view after mount. */\r\n scrollOnMount?: boolean\r\n\r\n /**\r\n * Called on each handled key press with the `selectionKey` of the focused item; return true to cancel the\r\n * event's default action and skip the built-in keyboard handling.\r\n */\r\n supressKeyboardEvent?(selectionKey: string | undefined, event: React.KeyboardEvent): boolean\r\n\r\n /** Content containing {@link ScrollToItem}s, at any depth. */\r\n children?: React.ReactNode;\r\n}\r\n\r\ninterface ScrollToState {\r\n /* current search string entered by user*/\r\n searchString: string\r\n /* checks if search string is found in at least one item */\r\n searchStringFound: boolean\r\n}\r\n\r\n/**\r\n * Keyboard-navigable area of {@link ScrollToItem}s. ArrowUp/ArrowDown move the focus between items and scroll them\r\n * into view; typing printable characters builds a type-ahead search (shown in a tooltip) that focuses the first\r\n * matching item, after which the arrows cycle through the matches only. Backspace edits the search, Escape or a click\r\n * clears it, and Enter clicks the focused item. Keys are ignored while an `input` has focus or Ctrl/Alt is pressed.\r\n */\r\nexport default class ScrollTo extends Component<ScrollToProps, ScrollToState> {\r\n /** The wrapping element of the items. */\r\n scrollWrapper: HTMLElement | null = null;\r\n /** The nearest scrollable ancestor of the wrapper, or `document.body`. */\r\n scrollParent: HTMLElement | null = null;\r\n\r\n constructor(props: Readonly<ScrollToProps>) {\r\n super(props);\r\n this.state = {\r\n searchString: \"\",\r\n searchStringFound: false,\r\n };\r\n this.scrollToElement = debounce(this.scrollToElement, 400, {maxWait: 400});\r\n }\r\n\r\n componentDidMount(): void {\r\n // initial scrolling to position of selected node\r\n if (this.props.scrollOnMount && this.scrollWrapper) {\r\n const scrollToElement = this.scrollWrapper.querySelector(\".selected\");\r\n if (scrollToElement) {\r\n this.scrollToElement(scrollToElement as HTMLElement);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Scrolls `scrollToElem` into view within {@link ScrollTo.scrollParent} if it is not visible, keeping a 50 px margin.\r\n * Debounced (400 ms).\r\n * @param scrollingUp align the element with the top instead of the bottom.\r\n */\r\n scrollToElement(scrollToElem: HTMLElement, scrollingUp = false): void {\r\n scrollIntoView(scrollToElem, this.scrollParent, {\r\n onlyScrollIfNeeded: true,\r\n allowHorizontalScroll: false,\r\n alignWithTop: scrollingUp,\r\n offsetTop: 50,\r\n offsetBottom: 50,\r\n });\r\n }\r\n\r\n /**\r\n * Finds the nearest ancestor of `element` with `auto`/`scroll` overflow (also `hidden` when `includeHidden`).\r\n * @returns the ancestor, or `document.body` when there is none or `element` is fixed.\r\n */\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 /**\r\n * Focuses and scrolls to the item after `currentElement` in `selectables`; does nothing at the last one and starts\r\n * at the first item when `currentElement` is not in the list.\r\n */\r\n focusNext(currentElement: HTMLElement, selectables: HTMLElement[]): void {\r\n if (currentElement) {\r\n const currentElementIndex = selectables.indexOf(currentElement);\r\n if (currentElementIndex >= 0 && currentElementIndex < selectables.length - 1) {\r\n const scrollToElem = selectables[currentElementIndex + 1];\r\n scrollToElem.focus();\r\n this.scrollToElement(scrollToElem);\r\n return;\r\n } else if (currentElementIndex === selectables.length - 1) {\r\n return;\r\n }\r\n }\r\n if (selectables.length > 0) {\r\n selectables[0].focus();\r\n this.scrollToElement(selectables[0])\r\n }\r\n }\r\n\r\n /** Scrolls the last item into view without focusing it. */\r\n scrollToLast(): void {\r\n if (!!this.scrollWrapper) {\r\n let selectables: HTMLElement[] = Array.from(this.scrollWrapper.getElementsByClassName(\"selectable\")) as HTMLElement[]; //get all selectable elements\r\n if (selectables.length > 0) {\r\n const focusedElement = selectables[selectables.length - 1];\r\n this.scrollToElement(focusedElement, false);\r\n }\r\n }\r\n }\r\n\r\n /** Focuses the last item and scrolls it into view. */\r\n focusToLast(): void {\r\n if (!!this.scrollWrapper) {\r\n let selectables: HTMLElement[] = Array.from(this.scrollWrapper.getElementsByClassName(\"selectable\")) as HTMLElement[]; //get all selectable elements\r\n if (selectables.length > 0) {\r\n const focusedElement = selectables[selectables.length - 1];\r\n focusedElement.focus();\r\n this.scrollToElement(focusedElement, false);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Focuses and scrolls to the item before `currentElement` in `selectables`; does nothing at the first one and starts\r\n * at the last item when `currentElement` is not in the list.\r\n */\r\n focusPrev(currentElement: HTMLElement, selectables: HTMLElement[]): void {\r\n if (currentElement) {\r\n const currentElementIndex = selectables.indexOf(currentElement);\r\n if (currentElementIndex > 0) {\r\n const scrollToElem = selectables[currentElementIndex - 1];\r\n scrollToElem.focus();\r\n this.scrollToElement(scrollToElem);\r\n return;\r\n } else if (currentElementIndex === 0) {\r\n return;\r\n }\r\n }\r\n if (selectables.length > 0) {\r\n const scrollToElem = selectables[selectables.length - 1];\r\n scrollToElem.focus();\r\n this.scrollToElement(scrollToElem);\r\n }\r\n }\r\n\r\n /**\r\n * Focuses and scrolls to the first item whose text contains `searchString` (case-insensitive).\r\n * @returns the focused item, or a nullish value when none matches.\r\n */\r\n focusBySearchString(searchString: string): HTMLElement {\r\n const elementToFocus = this.scrollWrapper?.querySelector(`.selectable[data-content*=\"${searchString.toLowerCase()}\"]`) as any;\r\n if (elementToFocus) {\r\n elementToFocus.focus();\r\n this.scrollToElement(elementToFocus as HTMLElement);\r\n }\r\n return elementToFocus;\r\n }\r\n\r\n render() {\r\n return (\r\n <div ref={(scrollWrapper) => {\r\n this.scrollWrapper = scrollWrapper;\r\n if (this.scrollWrapper) {\r\n this.scrollParent = this.getScrollParent(this.scrollWrapper);\r\n } else {\r\n this.scrollParent = null;\r\n }\r\n }}\r\n tabIndex={-1}\r\n onKeyDown={(e: React.KeyboardEvent<HTMLDivElement>) => {\r\n if (e.target instanceof HTMLInputElement) {\r\n return;\r\n }\r\n if (!this.scrollWrapper) {\r\n return;\r\n }\r\n if (KeyboardUtils.isKeyPressed(Key.Control) || KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n return;\r\n }\r\n const supressKeyboardEvent = this.props.supressKeyboardEvent?.((document.activeElement as any)?.dataset?.key, e);\r\n if (supressKeyboardEvent) {\r\n e.preventDefault();\r\n return;\r\n }\r\n let focusedElement: HTMLElement | null = document.activeElement as HTMLElement;\r\n let selectables: HTMLElement[];\r\n if (this.state.searchString && this.state.searchStringFound) {\r\n selectables = Array.from(this.scrollWrapper.querySelectorAll(`.selectable[data-content*=\"${this.state.searchString.toLowerCase()}\"]`));\r\n } else {\r\n selectables = Array.from(this.scrollWrapper.getElementsByClassName(\"selectable\")) as HTMLElement[]; //get all selectable elements\r\n }\r\n const focusedElementIndex = selectables.indexOf(focusedElement);\r\n if (e.key === Key.ArrowDown || e.key === Key.ArrowUp) {\r\n e.preventDefault();\r\n if (!focusedElement || focusedElementIndex < 0) {\r\n const selectedElements = Array.from(this.scrollWrapper.getElementsByClassName(\"selected\"));\r\n focusedElement = selectedElements.length > 0 ? selectedElements[0] as HTMLElement : null;\r\n }\r\n if (e.key === Key.ArrowDown && focusedElement) {\r\n this.focusNext(focusedElement, selectables);\r\n } else if (e.key === Key.ArrowUp && focusedElement) {\r\n this.focusPrev(focusedElement, selectables);\r\n }\r\n } else if (e.key === Key.Enter && focusedElementIndex >= 0) {\r\n if (typeof focusedElement.click == \"function\") {\r\n focusedElement.click.apply(focusedElement);\r\n }\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n } else if (e.key.length === 1) {\r\n const searchString = this.state.searchString + e.key;\r\n const focusedElement = this.focusBySearchString(searchString);\r\n this.setState({searchString: searchString, searchStringFound: !!focusedElement},);\r\n } else if (e.key === Key.Backspace) {\r\n const searchString = this.state.searchString.slice(0, -1);\r\n const focusedElement = this.focusBySearchString(searchString);\r\n this.setState({searchString: searchString, searchStringFound: !!focusedElement})\r\n } else if (e.key === Key.Escape) {\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n }\r\n }}\r\n onClick={() => {\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n }}\r\n onBlur={(_: React.FocusEvent<HTMLDivElement>) => {\r\n setTimeout(() => {\r\n if (!document.activeElement?.className?.includes(\"selectable\") && (this.state.searchString !== \"\" || this.state.searchStringFound)) {\r\n this.setState({searchString: \"\", searchStringFound: false});\r\n }\r\n }, 0);\r\n\r\n }}\r\n >\r\n <div style={{position: \"fixed\", top: 16, left: 16}}>\r\n <Tooltip\r\n overlayClassName={!this.state.searchStringFound ? \"search-string-not-found\" : undefined}\r\n align={{points: [\"tl\", \"tl\"], overflow: {adjustX: true, adjustY: true}}}\r\n open={!!this.state.searchString} title={this.state.searchString}>\r\n <span/>\r\n </Tooltip>\r\n </div>\r\n <MarkTextContext.Provider value={this.state.searchString}>\r\n {this.props.children}\r\n </MarkTextContext.Provider>\r\n </div>);\r\n }\r\n}"]}
@@ -2,19 +2,34 @@ import { BaseReturnType } from 'antd-style';
2
2
  import { ReturnStyles } from "antd-style/lib/factories/createStyles/types";
3
3
  import { SizeType } from "antd/lib/config-provider/SizeContext";
4
4
  import { Variant } from "antd/es/config-provider";
5
+ /** Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...). */
5
6
  type WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>) => any;
7
+ /** Props that {@link WithCss} resolves before passing them to `useStyles`. */
6
8
  type WithCssOwnProps = {
7
9
  size?: SizeType;
8
10
  variant?: Variant;
9
11
  };
12
+ /**
13
+ * Props always passed to `useStyles` by {@link WithCss}. `size` and `variant` are resolved from the passed props
14
+ * and the antd context, so they are never `undefined`.
15
+ */
10
16
  export type WithCssInjectedProps = {
11
17
  size: NonNullable<SizeType>;
12
18
  variant: Variant;
13
19
  };
20
+ /** Props of {@link WithCss}. */
14
21
  interface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps> {
22
+ /** Render function called with the computed styles. */
15
23
  children: WithCssChildren<T>;
24
+ /** Style hook created by antd-style `createStyles`. */
16
25
  useStyles: (props?: P & WithCssInjectedProps) => ReturnStyles<T>;
26
+ /** Props passed to `useStyles`, merged with the resolved `size` and `variant`. */
17
27
  props?: P;
18
28
  }
29
+ /**
30
+ * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.
31
+ * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then `'middle'`; `variant` as
32
+ * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.
33
+ */
19
34
  export default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}>({ useStyles, children, props }: WithCssProperties<T, P>): any;
20
35
  export {};
@@ -1,11 +1,17 @@
1
1
  import { useContext } from "react";
2
2
  import { SpaceCompactItemContext } from "antd/es/space/Compact";
3
3
  import { ConfigContext } from "antd/es/config-provider";
4
+ /**
5
+ * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.
6
+ * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then `'middle'`; `variant` as
7
+ * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.
8
+ */
4
9
  export default function WithCss({ useStyles, children, props }) {
5
10
  var _a, _b;
6
11
  const contextSize = useContext(SpaceCompactItemContext);
7
12
  const { variant: configVariant } = useContext(ConfigContext);
8
13
  const mergedSize = (props === null || props === void 0 ? void 0 : props.size) || (contextSize === null || contextSize === void 0 ? void 0 : contextSize.compactSize) || 'middle';
14
+ // same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined
9
15
  const mergedVariant = (_b = (_a = props === null || props === void 0 ? void 0 : props.variant) !== null && _a !== void 0 ? _a : configVariant) !== null && _b !== void 0 ? _b : 'outlined';
10
16
  const css = useStyles(Object.assign(Object.assign({}, props), { size: mergedSize, variant: mergedVariant }));
11
17
  return children(css);
@@ -1 +1 @@
1
- {"version":3,"file":"withCss.js","sourceRoot":"","sources":["../../../../components/style/withCss.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAC,aAAa,EAAU,MAAM,yBAAyB,CAAC;AAkB/D,MAAM,CAAC,OAAO,UAAU,OAAO,CAA4D,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAA0B;;IAC5I,MAAM,WAAW,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACxD,MAAM,EAAC,OAAO,EAAE,aAAa,EAAC,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,MAAM,UAAU,GAA0B,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAA,IAAI,QAAQ,CAAC;IAE9F,MAAM,aAAa,GAAY,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,aAAa,mCAAI,UAAU,CAAC;IAC7E,MAAM,GAAG,GAAG,SAAS,iCAAM,KAAW,KAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,IAAE,CAAC;IACnF,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAAA,CAAC","sourcesContent":["import {BaseReturnType} from 'antd-style';\nimport {ReturnStyles} from \"antd-style/lib/factories/createStyles/types\";\nimport {useContext} from \"react\";\nimport {SpaceCompactItemContext} from \"antd/es/space/Compact\";\nimport {SizeType} from \"antd/lib/config-provider/SizeContext\";\nimport {ConfigContext, Variant} from \"antd/es/config-provider\";\n\ntype WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>) => any;\n\ntype WithCssOwnProps = { size?: SizeType, variant?: Variant };\n\n/**\n * props always passed to useStyles - size and variant are resolved by WithCss from the\n * component props / antd context, so they are never undefined\n */\nexport type WithCssInjectedProps = { size: NonNullable<SizeType>, variant: Variant };\n\ninterface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps> {\n children: WithCssChildren<T>;\n useStyles: (props?: P & WithCssInjectedProps) => ReturnStyles<T>\n props?: P;\n}\n\nexport default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}> ({useStyles, children, props}: WithCssProperties<T, P>) {\n const contextSize = useContext(SpaceCompactItemContext);\n const {variant: configVariant} = useContext(ConfigContext);\n const mergedSize: NonNullable<SizeType> = props?.size || contextSize?.compactSize || 'middle';\n // same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined\n const mergedVariant: Variant = props?.variant ?? configVariant ?? 'outlined';\n const css = useStyles({...(props as P), size: mergedSize, variant: mergedVariant});\n return children(css);\n};\n"]}
1
+ {"version":3,"file":"withCss.js","sourceRoot":"","sources":["../../../../components/style/withCss.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAC,aAAa,EAAU,MAAM,yBAAyB,CAAC;AAwB/D;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAA4D,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAA0B;;IAC5I,MAAM,WAAW,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACxD,MAAM,EAAC,OAAO,EAAE,aAAa,EAAC,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,MAAM,UAAU,GAA0B,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAA,IAAI,QAAQ,CAAC;IAC9F,sFAAsF;IACtF,MAAM,aAAa,GAAY,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,aAAa,mCAAI,UAAU,CAAC;IAC7E,MAAM,GAAG,GAAG,SAAS,iCAAM,KAAW,KAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,IAAE,CAAC;IACnF,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAAA,CAAC","sourcesContent":["import {BaseReturnType} from 'antd-style';\r\nimport {ReturnStyles} from \"antd-style/lib/factories/createStyles/types\";\r\nimport {useContext} from \"react\";\r\nimport {SpaceCompactItemContext} from \"antd/es/space/Compact\";\r\nimport {SizeType} from \"antd/lib/config-provider/SizeContext\";\r\nimport {ConfigContext, Variant} from \"antd/es/config-provider\";\r\n\r\n/** Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...). */\r\ntype WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>) => any;\r\n\r\n/** Props that {@link WithCss} resolves before passing them to `useStyles`. */\r\ntype WithCssOwnProps = { size?: SizeType, variant?: Variant };\r\n\r\n/**\r\n * Props always passed to `useStyles` by {@link WithCss}. `size` and `variant` are resolved from the passed props\r\n * and the antd context, so they are never `undefined`.\r\n */\r\nexport type WithCssInjectedProps = { size: NonNullable<SizeType>, variant: Variant };\r\n\r\n/** Props of {@link WithCss}. */\r\ninterface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps> {\r\n /** Render function called with the computed styles. */\r\n children: WithCssChildren<T>;\r\n /** Style hook created by antd-style `createStyles`. */\r\n useStyles: (props?: P & WithCssInjectedProps) => ReturnStyles<T>\r\n /** Props passed to `useStyles`, merged with the resolved `size` and `variant`. */\r\n props?: P;\r\n}\r\n\r\n/**\r\n * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.\r\n * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then `'middle'`; `variant` as\r\n * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.\r\n */\r\nexport default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}> ({useStyles, children, props}: WithCssProperties<T, P>) {\r\n const contextSize = useContext(SpaceCompactItemContext);\r\n const {variant: configVariant} = useContext(ConfigContext);\r\n const mergedSize: NonNullable<SizeType> = props?.size || contextSize?.compactSize || 'middle';\r\n // same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined\r\n const mergedVariant: Variant = props?.variant ?? configVariant ?? 'outlined';\r\n const css = useStyles({...(props as P), size: mergedSize, variant: mergedVariant});\r\n return children(css);\r\n};\r\n"]}
@@ -1,12 +1,27 @@
1
1
  import React from 'react';
2
2
  import { TableProps } from "antd/es/table";
3
+ /** Props of {@link DragSortingTable}; other props are passed to antd `Table` (`onRow` is overridden). */
3
4
  interface DragSortingTableProps<T> extends TableProps<T> {
5
+ /** Table rows. */
4
6
  dataSource: T[];
7
+ /**
8
+ * Called when a row is dropped onto another row. The table does not reorder the rows itself;
9
+ * update `dataSource` accordingly.
10
+ * @param dragRow the dragged row
11
+ * @param dragIndex original index of the dragged row
12
+ * @param hoverIndex index of the row it was dropped on (its new index)
13
+ */
5
14
  onMoveRow: (dragRow: T, dragIndex: number, hoverIndex: number) => void;
6
15
  }
16
+ /**
17
+ * antd `Table` whose rows can be reordered by drag and drop (react-dnd, HTML5 backend, its own `DndProvider`).
18
+ * The drop position is indicated by a dashed line. Custom `components` are shallow-merged over the draggable body row.
19
+ */
7
20
  export default class DragSortingTable<T extends object> extends React.Component<DragSortingTableProps<T>> {
21
+ /** Table `components` override providing the draggable body row. */
8
22
  components: any;
9
23
  constructor(props: Readonly<DragSortingTableProps<T>>);
24
+ /** Calls {@link DragSortingTableProps.onMoveRow} for the row at `dragIndex`. */
10
25
  moveRow(dragIndex: number, hoverIndex: number): void;
11
26
  render(): React.JSX.Element;
12
27
  }