@pinnacle0/web-ui 0.6.46 → 0.7.0-beta.10

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 (339) hide show
  1. package/admin/AdminApp/Default/NavigatorSide/index.js +1 -1
  2. package/admin/AdminApp/Default/NavigatorSide/index.js.map +1 -1
  3. package/core/Amount/AmountPercentage.d.ts +1 -4
  4. package/core/Amount/AmountPercentage.js +5 -8
  5. package/core/Amount/AmountPercentage.js.map +1 -1
  6. package/core/Amount/index.d.ts +3 -8
  7. package/core/Amount/index.js +27 -35
  8. package/core/Amount/index.js.map +1 -1
  9. package/core/AuthenticationCodeInput/index.less +5 -1
  10. package/core/AutoCompleteInput/index.d.ts +2 -5
  11. package/core/AutoCompleteInput/index.js +5 -7
  12. package/core/AutoCompleteInput/index.js.map +1 -1
  13. package/core/BoolSwitch/index.d.ts +5 -7
  14. package/core/BoolSwitch/index.js +11 -13
  15. package/core/BoolSwitch/index.js.map +1 -1
  16. package/core/Breadcrumb/index.d.ts +1 -5
  17. package/core/Breadcrumb/index.js +8 -16
  18. package/core/Breadcrumb/index.js.map +1 -1
  19. package/core/Button/index.d.ts +2 -2
  20. package/core/Button/index.js +3 -2
  21. package/core/Button/index.js.map +1 -1
  22. package/core/Card/index.d.ts +3 -6
  23. package/core/Card/index.js +4 -7
  24. package/core/Card/index.js.map +1 -1
  25. package/core/Carousel/index.d.ts +1 -4
  26. package/core/Carousel/index.js +4 -7
  27. package/core/Carousel/index.js.map +1 -1
  28. package/core/Carousel3D/index.d.ts +1 -21
  29. package/core/Carousel3D/index.js +76 -83
  30. package/core/Carousel3D/index.js.map +1 -1
  31. package/core/Cascader/InitialNullable.d.ts +1 -4
  32. package/core/Cascader/InitialNullable.js +5 -8
  33. package/core/Cascader/InitialNullable.js.map +1 -1
  34. package/core/Cascader/Nullable.d.ts +2 -7
  35. package/core/Cascader/Nullable.js +10 -12
  36. package/core/Cascader/Nullable.js.map +1 -1
  37. package/core/Cascader/index.d.ts +4 -13
  38. package/core/Cascader/index.js +18 -20
  39. package/core/Cascader/index.js.map +1 -1
  40. package/core/Checkbox/index.d.ts +4 -7
  41. package/core/Checkbox/index.js +4 -9
  42. package/core/Checkbox/index.js.map +1 -1
  43. package/core/Collapse/index.d.ts +2 -7
  44. package/core/Collapse/index.js +4 -6
  45. package/core/Collapse/index.js.map +1 -1
  46. package/core/Countdown/SlidingDigit.d.ts +1 -10
  47. package/core/Countdown/SlidingDigit.js +16 -21
  48. package/core/Countdown/SlidingDigit.js.map +1 -1
  49. package/core/Countdown/index.d.ts +1 -18
  50. package/core/Countdown/index.js +53 -74
  51. package/core/Countdown/index.js.map +1 -1
  52. package/core/DarkOverlay/index.d.ts +1 -4
  53. package/core/DarkOverlay/index.js +4 -7
  54. package/core/DarkOverlay/index.js.map +1 -1
  55. package/core/DateCalendar/index.d.ts +2 -13
  56. package/core/DateCalendar/index.js +12 -14
  57. package/core/DateCalendar/index.js.map +1 -1
  58. package/core/DatePicker/index.d.ts +1 -7
  59. package/core/DatePicker/index.js +9 -16
  60. package/core/DatePicker/index.js.map +1 -1
  61. package/core/DateRangePicker/index.d.ts +1 -14
  62. package/core/DateRangePicker/index.js +25 -34
  63. package/core/DateRangePicker/index.js.map +1 -1
  64. package/core/DateTimePicker/index.d.ts +1 -7
  65. package/core/DateTimePicker/index.js +12 -21
  66. package/core/DateTimePicker/index.js.map +1 -1
  67. package/core/DateTimeRangePicker/index.d.ts +1 -17
  68. package/core/DateTimeRangePicker/index.js +21 -31
  69. package/core/DateTimeRangePicker/index.js.map +1 -1
  70. package/core/Descriptions/index.d.ts +3 -8
  71. package/core/Descriptions/index.js +7 -13
  72. package/core/Descriptions/index.js.map +1 -1
  73. package/core/Descriptions/index.less +0 -8
  74. package/core/DocumentTitle/index.d.ts +4 -13
  75. package/core/DocumentTitle/index.js +18 -31
  76. package/core/DocumentTitle/index.js.map +1 -1
  77. package/core/Drawer/index.d.ts +1 -3
  78. package/core/Drawer/index.js +4 -5
  79. package/core/Drawer/index.js.map +1 -1
  80. package/core/Dropdown/index.d.ts +3 -4
  81. package/core/Dropdown/index.js +4 -3
  82. package/core/Dropdown/index.js.map +1 -1
  83. package/core/EnumCheckboxGroup/Map.d.ts +1 -4
  84. package/core/EnumCheckboxGroup/Map.js +5 -9
  85. package/core/EnumCheckboxGroup/Map.js.map +1 -1
  86. package/core/EnumCheckboxGroup/index.d.ts +3 -4
  87. package/core/EnumCheckboxGroup/index.js +11 -12
  88. package/core/EnumCheckboxGroup/index.js.map +1 -1
  89. package/core/EnumRadio/InitialNullable.d.ts +1 -5
  90. package/core/EnumRadio/InitialNullable.js +6 -9
  91. package/core/EnumRadio/InitialNullable.js.map +1 -1
  92. package/core/EnumRadio/Map.d.ts +1 -4
  93. package/core/EnumRadio/Map.js +6 -9
  94. package/core/EnumRadio/Map.js.map +1 -1
  95. package/core/EnumRadio/Nullable.d.ts +1 -5
  96. package/core/EnumRadio/Nullable.js +12 -14
  97. package/core/EnumRadio/Nullable.js.map +1 -1
  98. package/core/EnumRadio/index.d.ts +5 -12
  99. package/core/EnumRadio/index.js +9 -17
  100. package/core/EnumRadio/index.js.map +1 -1
  101. package/core/EnumSelect/InitialNullable.d.ts +1 -4
  102. package/core/EnumSelect/InitialNullable.js +4 -8
  103. package/core/EnumSelect/InitialNullable.js.map +1 -1
  104. package/core/EnumSelect/Map.d.ts +1 -4
  105. package/core/EnumSelect/Map.js +6 -9
  106. package/core/EnumSelect/Map.js.map +1 -1
  107. package/core/EnumSelect/Nullable.d.ts +1 -5
  108. package/core/EnumSelect/Nullable.js +12 -14
  109. package/core/EnumSelect/Nullable.js.map +1 -1
  110. package/core/EnumSelect/index.d.ts +5 -15
  111. package/core/EnumSelect/index.js +19 -27
  112. package/core/EnumSelect/index.js.map +1 -1
  113. package/core/EnumSelect/index.less +1 -1
  114. package/core/FlatList/Content/Footer/index.js +3 -2
  115. package/core/FlatList/Content/Footer/index.js.map +1 -1
  116. package/core/FlatList/Content/index.d.ts +1 -1
  117. package/core/FlatList/Content/index.js +10 -8
  118. package/core/FlatList/Content/index.js.map +1 -1
  119. package/core/FlatList/FloatingLoader/index.js +3 -2
  120. package/core/FlatList/FloatingLoader/index.js.map +1 -1
  121. package/core/FlatList/Refresh/index.js +3 -2
  122. package/core/FlatList/Refresh/index.js.map +1 -1
  123. package/core/FlatList/index.d.ts +1 -1
  124. package/core/FlatList/index.js +10 -9
  125. package/core/FlatList/index.js.map +1 -1
  126. package/core/FlatList/shared/Loader/index.js +3 -2
  127. package/core/FlatList/shared/Loader/index.js.map +1 -1
  128. package/core/Form/Item.d.ts +1 -16
  129. package/core/Form/Item.js +28 -40
  130. package/core/Form/Item.js.map +1 -1
  131. package/core/Form/index.d.ts +6 -17
  132. package/core/Form/index.js +29 -46
  133. package/core/Form/index.js.map +1 -1
  134. package/core/Form/index.less +1 -1
  135. package/core/Grid/index.d.ts +2 -2
  136. package/core/Grid/index.js +2 -1
  137. package/core/Grid/index.js.map +1 -1
  138. package/core/HTMLContent/index.d.ts +1 -4
  139. package/core/HTMLContent/index.js +4 -7
  140. package/core/HTMLContent/index.js.map +1 -1
  141. package/core/Image/index.d.ts +3 -6
  142. package/core/Image/index.js +6 -7
  143. package/core/Image/index.js.map +1 -1
  144. package/core/ImageUploader/index.d.ts +2 -11
  145. package/core/ImageUploader/index.js +17 -25
  146. package/core/ImageUploader/index.js.map +1 -1
  147. package/core/Input/index.d.ts +12 -18
  148. package/core/Input/index.js +37 -41
  149. package/core/Input/index.js.map +1 -1
  150. package/core/LabelledSelect/index.d.ts +3 -5
  151. package/core/LabelledSelect/index.js +4 -7
  152. package/core/LabelledSelect/index.js.map +1 -1
  153. package/core/Link/index.d.ts +1 -4
  154. package/core/Link/index.js +16 -19
  155. package/core/Link/index.js.map +1 -1
  156. package/core/LocalImporter/index.d.ts +1 -10
  157. package/core/LocalImporter/index.js +11 -18
  158. package/core/LocalImporter/index.js.map +1 -1
  159. package/core/LocaleSelect/index.d.ts +1 -10
  160. package/core/LocaleSelect/index.js +16 -18
  161. package/core/LocaleSelect/index.js.map +1 -1
  162. package/core/Markdown/index.d.ts +1 -7
  163. package/core/Markdown/index.js +13 -16
  164. package/core/Markdown/index.js.map +1 -1
  165. package/core/Modal/index.less +1 -1
  166. package/core/MultipleCascader/index.d.ts +1 -9
  167. package/core/MultipleCascader/index.js +15 -19
  168. package/core/MultipleCascader/index.js.map +1 -1
  169. package/core/MultipleEnumSelect/index.d.ts +1 -8
  170. package/core/MultipleEnumSelect/index.js +9 -15
  171. package/core/MultipleEnumSelect/index.js.map +1 -1
  172. package/core/MultipleSelector/TablePopover.d.ts +1 -7
  173. package/core/MultipleSelector/TablePopover.js +23 -26
  174. package/core/MultipleSelector/TablePopover.js.map +1 -1
  175. package/core/MultipleSelector/index.d.ts +1 -9
  176. package/core/MultipleSelector/index.js +18 -26
  177. package/core/MultipleSelector/index.js.map +1 -1
  178. package/core/MutableTable/index.d.ts +1 -13
  179. package/core/MutableTable/index.js +25 -35
  180. package/core/MutableTable/index.js.map +1 -1
  181. package/core/NumberInput/NumberInputPercentage.d.ts +1 -8
  182. package/core/NumberInput/NumberInputPercentage.js +8 -25
  183. package/core/NumberInput/NumberInputPercentage.js.map +1 -1
  184. package/core/NumberInput/index.d.ts +6 -33
  185. package/core/NumberInput/index.js +45 -72
  186. package/core/NumberInput/index.js.map +1 -1
  187. package/core/OverflowableText/index.d.ts +1 -12
  188. package/core/OverflowableText/index.js +11 -28
  189. package/core/OverflowableText/index.js.map +1 -1
  190. package/core/Pagination/index.d.ts +1 -7
  191. package/core/Pagination/index.js +17 -19
  192. package/core/Pagination/index.js.map +1 -1
  193. package/core/Popover/index.d.ts +0 -1
  194. package/core/Popover/index.js +2 -5
  195. package/core/Popover/index.js.map +1 -1
  196. package/core/Progress/index.d.ts +1 -4
  197. package/core/Progress/index.js +4 -6
  198. package/core/Progress/index.js.map +1 -1
  199. package/core/Radio/index.d.ts +5 -7
  200. package/core/Radio/index.js +2 -8
  201. package/core/Radio/index.js.map +1 -1
  202. package/core/RelativeTime/index.d.ts +1 -15
  203. package/core/RelativeTime/index.js +17 -31
  204. package/core/RelativeTime/index.js.map +1 -1
  205. package/core/Resizable/index.js +3 -2
  206. package/core/Resizable/index.js.map +1 -1
  207. package/core/SearchableSelect/index.d.ts +3 -5
  208. package/core/SearchableSelect/index.js +4 -7
  209. package/core/SearchableSelect/index.js.map +1 -1
  210. package/core/Select/index.d.ts +8 -7
  211. package/core/Select/index.js +8 -8
  212. package/core/Select/index.js.map +1 -1
  213. package/core/SignedAmountInput/index.d.ts +1 -8
  214. package/core/SignedAmountInput/index.js +16 -24
  215. package/core/SignedAmountInput/index.js.map +1 -1
  216. package/core/Skeleton/index.d.ts +1 -4
  217. package/core/Skeleton/index.js +4 -7
  218. package/core/Skeleton/index.js.map +1 -1
  219. package/core/Slider/RangeSlider.d.ts +2 -6
  220. package/core/Slider/RangeSlider.js +4 -7
  221. package/core/Slider/RangeSlider.js.map +1 -1
  222. package/core/Slider/index.d.ts +3 -7
  223. package/core/Slider/index.js +15 -20
  224. package/core/Slider/index.js.map +1 -1
  225. package/core/Space/index.d.ts +3 -5
  226. package/core/Space/index.js +4 -7
  227. package/core/Space/index.js.map +1 -1
  228. package/core/Spin/index.d.ts +3 -6
  229. package/core/Spin/index.js +4 -7
  230. package/core/Spin/index.js.map +1 -1
  231. package/core/StepFormContainer/index.d.ts +2 -7
  232. package/core/StepFormContainer/index.js +13 -17
  233. package/core/StepFormContainer/index.js.map +1 -1
  234. package/core/Steps/index.d.ts +3 -6
  235. package/core/Steps/index.js +4 -6
  236. package/core/Steps/index.js.map +1 -1
  237. package/core/Table/index.d.ts +10 -34
  238. package/core/Table/index.js +73 -80
  239. package/core/Table/index.js.map +1 -1
  240. package/core/Tabs/Single.d.ts +1 -4
  241. package/core/Tabs/Single.js +4 -7
  242. package/core/Tabs/Single.js.map +1 -1
  243. package/core/Tabs/index.d.ts +3 -13
  244. package/core/Tabs/index.js +27 -35
  245. package/core/Tabs/index.js.map +1 -1
  246. package/core/Tag/index.d.ts +2 -5
  247. package/core/Tag/index.js +4 -6
  248. package/core/Tag/index.js.map +1 -1
  249. package/core/TagInput/index.d.ts +2 -15
  250. package/core/TagInput/index.js +25 -41
  251. package/core/TagInput/index.js.map +1 -1
  252. package/core/Tags/index.d.ts +1 -6
  253. package/core/Tags/index.js +9 -13
  254. package/core/Tags/index.js.map +1 -1
  255. package/core/TimePicker/index.d.ts +1 -7
  256. package/core/TimePicker/index.js +8 -11
  257. package/core/TimePicker/index.js.map +1 -1
  258. package/core/TimeRangePicker/index.d.ts +1 -14
  259. package/core/TimeRangePicker/index.js +21 -27
  260. package/core/TimeRangePicker/index.js.map +1 -1
  261. package/core/Tooltip/index.d.ts +3 -4
  262. package/core/Tooltip/index.js +2 -5
  263. package/core/Tooltip/index.js.map +1 -1
  264. package/core/TypedTabs/index.d.ts +1 -4
  265. package/core/TypedTabs/index.js +16 -18
  266. package/core/TypedTabs/index.js.map +1 -1
  267. package/core/Uploader/index.d.ts +1 -17
  268. package/core/Uploader/index.js +25 -31
  269. package/core/Uploader/index.js.map +1 -1
  270. package/core/VirtualList/index.d.ts +1 -1
  271. package/core/VirtualList/index.js +3 -2
  272. package/core/VirtualList/index.js.map +1 -1
  273. package/core/VirtualTable/{TableHeader.js → OldVirtualTable/TableHeader.js} +2 -2
  274. package/core/VirtualTable/OldVirtualTable/TableHeader.js.map +1 -0
  275. package/core/VirtualTable/{TableRow.js → OldVirtualTable/TableRow.js} +2 -2
  276. package/core/VirtualTable/OldVirtualTable/TableRow.js.map +1 -0
  277. package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnWidths.js +1 -1
  278. package/core/VirtualTable/OldVirtualTable/hooks/useColumnWidths.js.map +1 -0
  279. package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnsStickyPosition.js +1 -1
  280. package/core/VirtualTable/OldVirtualTable/hooks/useColumnsStickyPosition.js.map +1 -0
  281. package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useRowSelection.d.ts +1 -1
  282. package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useRowSelection.js +2 -2
  283. package/core/VirtualTable/OldVirtualTable/hooks/useRowSelection.js.map +1 -0
  284. package/core/VirtualTable/OldVirtualTable/hooks/useScroll.js.map +1 -0
  285. package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScrollBarSize.js +1 -1
  286. package/core/VirtualTable/OldVirtualTable/hooks/useScrollBarSize.js.map +1 -0
  287. package/core/VirtualTable/OldVirtualTable/index.d.ts +28 -0
  288. package/core/VirtualTable/OldVirtualTable/index.js +58 -0
  289. package/core/VirtualTable/OldVirtualTable/index.js.map +1 -0
  290. package/core/VirtualTable/OldVirtualTable/index.old.less +160 -0
  291. package/core/VirtualTable/OldVirtualTable/type.d.ts +45 -0
  292. package/core/VirtualTable/OldVirtualTable/type.js +2 -0
  293. package/core/VirtualTable/OldVirtualTable/type.js.map +1 -0
  294. package/core/VirtualTable/index.d.ts +19 -26
  295. package/core/VirtualTable/index.js +68 -50
  296. package/core/VirtualTable/index.js.map +1 -1
  297. package/core/VirtualTable/index.less +28 -140
  298. package/core/VirtualTable/type.d.ts +17 -43
  299. package/core/WithExplanation/index.d.ts +1 -6
  300. package/core/WithExplanation/index.js +11 -20
  301. package/core/WithExplanation/index.js.map +1 -1
  302. package/core/WithTooltipList/index.d.ts +1 -9
  303. package/core/WithTooltipList/index.js +28 -27
  304. package/core/WithTooltipList/index.js.map +1 -1
  305. package/core/YearMonthSelector/index.d.ts +1 -7
  306. package/core/YearMonthSelector/index.js +9 -15
  307. package/core/YearMonthSelector/index.js.map +1 -1
  308. package/hooks/useParentResizeObserver/index.d.ts +2 -0
  309. package/hooks/useParentResizeObserver/index.js +17 -0
  310. package/hooks/useParentResizeObserver/index.js.map +1 -0
  311. package/hooks/useResizeObserver/index.d.ts +1 -1
  312. package/hooks/useResizeObserver/index.js +6 -10
  313. package/hooks/useResizeObserver/index.js.map +1 -1
  314. package/package.json +5 -5
  315. package/util/ModalUtil/index.less +1 -1
  316. package/util/OrientationUtil/index.js +22 -37
  317. package/util/OrientationUtil/index.js.map +1 -1
  318. package/util/PromptUtil/PromptBody.d.ts +4 -13
  319. package/util/PromptUtil/PromptBody.js +19 -28
  320. package/util/PromptUtil/PromptBody.js.map +1 -1
  321. package/util/PromptUtil/index.js +1 -1
  322. package/util/PromptUtil/index.js.map +1 -1
  323. package/util/ReactUtil/index.d.ts +20 -0
  324. package/util/ReactUtil/index.js +35 -0
  325. package/util/ReactUtil/index.js.map +1 -1
  326. package/core/VirtualTable/TableHeader.js.map +0 -1
  327. package/core/VirtualTable/TableRow.js.map +0 -1
  328. package/core/VirtualTable/hooks/useColumnWidths.js.map +0 -1
  329. package/core/VirtualTable/hooks/useColumnsStickyPosition.js.map +0 -1
  330. package/core/VirtualTable/hooks/useRowSelection.js.map +0 -1
  331. package/core/VirtualTable/hooks/useScroll.js.map +0 -1
  332. package/core/VirtualTable/hooks/useScrollBarSize.js.map +0 -1
  333. /package/core/VirtualTable/{TableHeader.d.ts → OldVirtualTable/TableHeader.d.ts} +0 -0
  334. /package/core/VirtualTable/{TableRow.d.ts → OldVirtualTable/TableRow.d.ts} +0 -0
  335. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnWidths.d.ts +0 -0
  336. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnsStickyPosition.d.ts +0 -0
  337. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScroll.d.ts +0 -0
  338. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScroll.js +0 -0
  339. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScrollBarSize.d.ts +0 -0
@@ -0,0 +1,45 @@
1
+ type ColumnIndex = number;
2
+ export type ColumnFixedPosition = "left" | "right";
3
+ export interface StickyPosition {
4
+ value: number;
5
+ isLast: boolean;
6
+ }
7
+ export type ColumnsStickyPosition = Record<ColumnIndex, StickyPosition>;
8
+ /**
9
+ * Similar usage of Antd Table but only support partial features: fixed columns, row selection, on row click
10
+ */
11
+ export type VirtualTableRowSelection<RowType extends object> = {
12
+ width: number;
13
+ selectedRowKeys: React.Key[];
14
+ onChange: (selectedRowKeys: React.Key[], selectedRows: RowType[]) => void;
15
+ /**
16
+ * Can only sticky in left
17
+ */
18
+ fixed?: boolean;
19
+ isDisabled?: (data: RowType, rowIndex: number) => boolean;
20
+ isSelectAllDisabled?: boolean;
21
+ /**
22
+ * Attention:
23
+ * If title is provided, the select all checkbox wil be overridden
24
+ */
25
+ title?: React.ReactElement | string | number | null;
26
+ };
27
+ export type VirtualTableColumn<RowType extends object> = {
28
+ title: React.ReactElement | string | number;
29
+ width: number;
30
+ /**
31
+ * Attention:
32
+ * If renderData return null, the corresponding table cell will not render
33
+ */
34
+ renderData: (record: RowType, rowIndex: number) => React.ReactNode | undefined;
35
+ align?: "left" | "right" | "center";
36
+ display?: "default" | "hidden";
37
+ fixed?: "left" | "right";
38
+ /**
39
+ * Attention:
40
+ * The overridden cell should return null in renderData props:
41
+ * e.g. [{colSpan: 3, renderData: () => <div />}, {renderData: () => null}], {renderData: () => null}
42
+ */
43
+ colSpan?: (record: RowType, rowIndex: number, colIndex: number) => number;
44
+ };
45
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../../src/core/VirtualTable/OldVirtualTable/type.ts"],"names":[],"mappings":""}
@@ -1,28 +1,21 @@
1
1
  import React from "react";
2
- import type { StringKey } from "../../internal/type";
3
- import type { VirtualTableColumn, VirtualTableRowSelection } from "./type";
4
2
  import "./index.less";
5
- export type { VirtualTableColumn, VirtualTableRowSelection } from "./type";
6
- export interface VirtualTableProps<RowType extends object> {
7
- dataSource: RowType[];
8
- columns: VirtualTableColumn<RowType>[];
9
- rowHeight: number;
10
- className?: string;
11
- rowClassName?: string;
12
- /**
13
- * if scrollX and scrollY is not provided, height: 100% and width: 100% will be used and please wrap the table with a container
14
- */
15
- scrollY?: number;
16
- scrollX?: number;
17
- overscan?: number;
18
- loading?: boolean;
19
- emptyPlaceholder?: React.ReactElement | string | number;
20
- onRowClick?: (record: RowType, rowIndex: number) => void;
21
- /**
22
- * Default: index
23
- */
24
- rowKey?: StringKey<RowType> | "index";
25
- headerHeight?: number;
26
- rowSelection?: VirtualTableRowSelection<RowType>;
27
- }
28
- export declare const VirtualTable: <RowType extends object>({ columns, rowHeight, dataSource, className, rowClassName, loading, emptyPlaceholder, onRowClick, scrollY, scrollX, overscan, rowSelection, headerHeight, rowKey }: VirtualTableProps<RowType>) => React.JSX.Element;
3
+ import type { VirtualTableProps } from "./type";
4
+ export type { TableRowSelection as VirtualTableRowSelection, TableHandler as VirtualTableHandler } from "../Table";
5
+ export type { VirtualTableProps, VirtualTableColumns } from "./type";
6
+ /**
7
+ * Antd Table's scrollX behaviour is different from scrollY
8
+ *
9
+ * scrollY:
10
+ * the height of the scrollable (visible/rendered) container
11
+ * If scrollY > container height, it will overflow the container
12
+ * We cannot use overflow: hidden on container since it will cause the last few rows to be hidden
13
+ *
14
+ * scrollX:
15
+ * It is the total of column width of all columns that are not hidden
16
+ * If scrollX > all columns width, all columns will be expanded and lose the width property
17
+ * In order to calculate the scrollX, we need to sum up the width of all columns
18
+ *
19
+ * If scrollX is not provided, all column must provide width, ref: ./type.ts
20
+ */
21
+ export declare const VirtualTable: <RowType extends object>(props: VirtualTableProps<RowType>) => React.JSX.Element;
@@ -1,58 +1,76 @@
1
1
  import React from "react";
2
- import { useVirtualizer } from "@tanstack/react-virtual";
3
2
  import { classNames } from "../../util/ClassNames";
4
- import { Spin } from "../Spin";
5
- import { TableRow } from "./TableRow";
6
- import { TableHeader } from "./TableHeader";
7
- import { useRowSelection } from "./hooks/useRowSelection";
8
- import { useColumnWidths } from "./hooks/useColumnWidths";
9
- import { useScrollBarSize } from "./hooks/useScrollBarSize";
10
- import { useScrollToEdge, useSyncScroll, useScrollable } from "./hooks/useScroll";
11
- import { useColumnsStickyPosition } from "./hooks/useColumnsStickyPosition";
12
3
  import { ReactUtil } from "../../util/ReactUtil";
4
+ import { Table } from "../Table";
13
5
  import "./index.less";
14
- export const VirtualTable = ReactUtil.memo("VirtualTable", function ({ columns, rowHeight, dataSource, className, rowClassName, loading, emptyPlaceholder, onRowClick, scrollY, scrollX, overscan, rowSelection, headerHeight = 50, rowKey = "index" }) {
15
- const count = dataSource.length;
16
- const scrollContentRef = React.useRef(null);
17
- const totalSize = count * rowHeight;
18
- const emptyElement = emptyPlaceholder || "暂无数据";
19
- const transformedColumns = useRowSelection({ columns, dataSource, rowKey, rowSelection });
20
- const rowVirtualizer = useVirtualizer({
21
- count,
22
- getScrollElement: () => scrollContentRef.current,
23
- estimateSize: () => rowHeight,
24
- overscan,
25
- });
26
- const { headerRef, getHeaderRef, columnWidths, calcColumnWidths } = useColumnWidths();
27
- const scrollBarSize = useScrollBarSize();
28
- const syncScroll = useSyncScroll(scrollContentRef, headerRef);
29
- const checkIsScrollToEdge = useScrollToEdge(scrollContentRef);
30
- const { scrollable, checkScrollable } = useScrollable(scrollContentRef);
31
- const columnsStickyPosition = useColumnsStickyPosition(transformedColumns, columnWidths);
32
- const onScroll = React.useCallback(() => {
33
- syncScroll();
34
- checkIsScrollToEdge();
35
- }, [syncScroll, checkIsScrollToEdge]);
36
- React.useEffect(() => {
37
- checkIsScrollToEdge();
38
- }, [columnWidths, checkIsScrollToEdge]);
6
+ import { useResizeObserver } from "../../hooks/useResizeObserver";
7
+ import { useDebounce } from "../../hooks/useDebounce";
8
+ /**
9
+ * Antd Table's scrollX behaviour is different from scrollY
10
+ *
11
+ * scrollY:
12
+ * the height of the scrollable (visible/rendered) container
13
+ * If scrollY > container height, it will overflow the container
14
+ * We cannot use overflow: hidden on container since it will cause the last few rows to be hidden
15
+ *
16
+ * scrollX:
17
+ * It is the total of column width of all columns that are not hidden
18
+ * If scrollX > all columns width, all columns will be expanded and lose the width property
19
+ * In order to calculate the scrollX, we need to sum up the width of all columns
20
+ *
21
+ * If scrollX is not provided, all column must provide width, ref: ./type.ts
22
+ */
23
+ export const VirtualTable = ReactUtil.memo("VirtualTable", function (props) {
24
+ const { dataSource, className, width = "100%", scrollY: propScrollY, emptyPlaceholder, debounceDelay = 0, ...restProps } = props;
25
+ const [scrollY, setScrollY] = React.useState(propScrollY ?? 300);
26
+ const [headerHeight, setHeaderHeight] = React.useState(0);
27
+ const containerRef = React.useRef(null);
28
+ const updateScrollY = useDebounce((entries) => {
29
+ const parentHeight = entries[0].contentRect.height;
30
+ let newScrollY = Math.max(0, parentHeight - headerHeight);
31
+ if (propScrollY)
32
+ newScrollY = Math.min(newScrollY, propScrollY);
33
+ setScrollY(newScrollY);
34
+ }, debounceDelay);
39
35
  React.useEffect(() => {
40
- checkScrollable();
41
- }, [totalSize, columnWidths, checkScrollable]);
36
+ const parent = containerRef.current?.parentElement;
37
+ if (!parent)
38
+ return;
39
+ const observer = new ResizeObserver(updateScrollY);
40
+ observer.observe(parent);
41
+ return () => {
42
+ observer.unobserve(parent);
43
+ observer.disconnect();
44
+ };
45
+ }, [headerHeight, updateScrollY]);
46
+ // Need to listen to header change onMount so we can calculate the scrollY correctly
47
+ const headerRef = useResizeObserver(({ height }) => {
48
+ setHeaderHeight(height);
49
+ });
42
50
  React.useEffect(() => {
43
- calcColumnWidths();
44
- }, [calcColumnWidths, transformedColumns]);
45
- const containerHeight = scrollY ? scrollY + headerHeight + (scrollable.horizontal ? scrollBarSize : 0) : "100%";
46
- return (React.createElement("div", { className: classNames("g-virtual-table", className), style: { width: scrollX || "100%", height: containerHeight } },
47
- loading && (React.createElement("div", { className: "mask" },
48
- React.createElement(Spin, { spinning: loading }))),
49
- React.createElement("div", { className: "scroll-content", ref: scrollContentRef, style: { height: `calc(100% - ${headerHeight}px)`, top: headerHeight }, onScroll: onScroll },
50
- React.createElement("div", { className: "table", style: { height: totalSize } },
51
- React.createElement(TableHeader, { headerRef: getHeaderRef, headerHeight: headerHeight, columns: transformedColumns, columnsStickyPosition: columnsStickyPosition }),
52
- columnWidths.length > 0 && (React.createElement("div", { className: "table-body" }, dataSource.length === 0
53
- ? emptyElement
54
- : rowVirtualizer
55
- .getVirtualItems()
56
- .map(virtualItem => (React.createElement(TableRow, { key: virtualItem.key, rowHeight: rowHeight, onRowClick: onRowClick, virtualItem: virtualItem, data: dataSource[virtualItem.index], columns: transformedColumns, columnWidths: columnWidths, scrollBarSize: scrollable.vertical ? scrollBarSize : 0, columnsStickyPosition: columnsStickyPosition, rowClassName: rowClassName })))))))));
51
+ headerRef.current = containerRef.current?.querySelector(".ant-table-header") ?? null;
52
+ }, [containerRef, headerRef]);
53
+ const containerStyle = React.useMemo(() => {
54
+ return {
55
+ width,
56
+ height: "100%",
57
+ };
58
+ }, [width]);
59
+ const scrollX = React.useMemo(() => {
60
+ if ("scrollX" in restProps)
61
+ return restProps.scrollX;
62
+ return restProps.columns.reduce((acc, column) => acc + (column.hidden ? 0 : column.width), 0);
63
+ }, [restProps]);
64
+ const emptyElement = React.createElement("div", { style: { height: scrollY } }, emptyPlaceholder || "暂无数据");
65
+ return (React.createElement("div", { ref: containerRef, className: classNames("g-virtual-table", className), style: containerStyle },
66
+ React.createElement(Table
67
+ // @ts-ignore: using our Table component with virtual props from antd
68
+ , {
69
+ // @ts-ignore: using our Table component with virtual props from antd
70
+ virtual: true, dataSource: dataSource,
71
+ /**
72
+ * Antd <Table virtual /> must use number scrollX or number scrollY to work
73
+ */
74
+ scrollY: scrollY, scrollX: scrollX, emptyPlaceholder: emptyElement, ...restProps })));
57
75
  });
58
76
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/VirtualTable/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAC,UAAU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AC,OAAO,CAAC,GAAG,EAAE;QAC/B,IAAI,SAAS,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC,OAAO,CAAC;QACrD,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,MAAM,YAAY,GAAG,6BAAK,KAAK,EAAE,EAAC,MAAM,EAAE,OAAO,EAAC,IAAG,gBAAgB,IAAI,MAAM,CAAO,CAAC;IAEvF,OAAO,CACH,6BAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,cAAc;QAC9F,oBAAC,KAAK;QACF,qEAAqE;;YAArE,qEAAqE;YACrE,OAAO,QACP,UAAU,EAAE,UAAU;YACtB;;eAEG;YACH,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,YAAY,KAC1B,SAAS,GACf,CACA,CACT,CAAC;AACN,CAAC,CAAC,CAAC"}
@@ -1,157 +1,45 @@
1
- .fixed-column-shadow(@position) {
2
- content: "";
3
- position: absolute;
4
- width: 30px;
5
- height: 100%;
6
- pointer-events: none;
7
- background-color: transparent;
8
- top: 0;
9
- bottom: -1px;
10
- transition: box-shadow 0.3s;
11
-
12
- & when (@position = "right") {
13
- left: 0;
14
- transform: translate(-100%);
15
- box-shadow: inset -10px 0 8px -8px #00000026;
16
- }
17
-
18
- & when (@position = "left") {
19
- right: 0;
20
- transform: translate(100%);
21
- box-shadow: inset 10px 0 8px -8px #00000026;
22
- }
23
- }
24
-
25
1
  .g-virtual-table {
26
- position: relative;
27
- transform: translateX(0);
28
-
29
- .mask {
30
- position: absolute;
31
- top: 0;
32
- left: 0;
33
- width: 100%;
34
- height: 100%;
35
- display: flex;
36
- justify-content: center;
37
- align-items: center;
38
- background: rgb(255 255 255 / 70%);
39
- z-index: 15;
40
- }
2
+ max-width: 100%;
3
+ max-height: 100%;
41
4
 
42
- .scroll-content {
43
- position: relative;
44
- overflow: auto;
45
- scrollbar-width: thin;
5
+ .ant-table {
6
+ .ant-table-tbody {
7
+ .ant-table-cell {
8
+ display: flex;
9
+ align-items: center;
46
10
 
47
- &.scroll-to-left {
48
- .table-header.fixed,
49
- .table-cell.fixed {
50
- &.last.left::after {
51
- box-shadow: none !important;
11
+ &.ant-table-selection-column {
12
+ justify-content: center;
52
13
  }
53
- }
54
- }
55
14
 
56
- &.scroll-to-right {
57
- .table-header.fixed,
58
- .table-cell.fixed {
59
- &.last.right::after {
60
- box-shadow: none !important;
15
+ &[style*="text-align: right"] {
16
+ justify-content: flex-end;
61
17
  }
62
- }
63
- }
64
-
65
- .table {
66
- min-height: 100%;
67
18
 
68
- .table-headers {
69
- display: flex;
70
- flex-wrap: nowrap;
71
- position: fixed;
72
- top: 0;
73
- z-index: 10;
74
- min-width: 100%;
75
- overflow-x: hidden;
76
-
77
- .table-header {
78
- display: flex;
79
- align-items: center;
80
- background-color: #f2f2f2;
81
- height: 100%;
82
- position: relative;
83
-
84
- &:not(:last-of-type)::before {
85
- background-color: rgb(0 0 0 / 6%);
86
- content: "";
87
- height: 60%;
88
- position: absolute;
89
- right: 0;
90
- top: 50%;
91
- transform: translateY(-50%);
92
- transition: background-color 0.3s;
93
- width: 1px;
94
- }
95
-
96
- &.fixed {
97
- position: sticky;
98
- z-index: 5;
99
-
100
- &.last {
101
- &.left {
102
- &::after {
103
- .fixed-column-shadow("left");
104
- }
105
- }
19
+ &[style*="text-align: center"] {
20
+ justify-content: center;
21
+ }
106
22
 
107
- &.right {
108
- &::after {
109
- .fixed-column-shadow("right");
110
- }
111
- }
112
- }
113
- }
23
+ &[style*="text-align: left"] {
24
+ justify-content: flex-start;
114
25
  }
115
26
  }
27
+ }
116
28
 
117
- .table-body {
118
- display: flex;
119
- justify-content: center;
120
- align-items: center;
121
- position: relative;
122
- height: 100%;
123
-
124
- .table-row {
125
- width: max-content;
126
- position: absolute;
127
- top: 0;
128
- left: 0;
129
-
130
- .table-cell {
131
- display: inline-flex;
132
- align-items: center;
133
- background-color: #fff;
134
- overflow-wrap: anywhere;
135
- vertical-align: bottom;
29
+ &.ant-table-empty .ant-table-container .ant-table-body {
30
+ overflow: hidden !important;
136
31
 
137
- &.fixed {
138
- position: sticky;
139
- z-index: 5;
32
+ .ant-table-cell {
33
+ padding: 0;
140
34
 
141
- &.last {
142
- &.left {
143
- &::after {
144
- .fixed-column-shadow("left");
145
- }
146
- }
35
+ .ant-table-expanded-row-fixed {
36
+ margin: 0;
37
+ padding: 0;
147
38
 
148
- &.right {
149
- &::after {
150
- .fixed-column-shadow("right");
151
- }
152
- }
153
- }
154
- }
39
+ .empty-text-node {
40
+ display: flex;
41
+ justify-content: center;
42
+ align-items: center;
155
43
  }
156
44
  }
157
45
  }
@@ -1,45 +1,19 @@
1
- type ColumnIndex = number;
2
- export type ColumnFixedPosition = "left" | "right";
3
- export interface StickyPosition {
4
- value: number;
5
- isLast: boolean;
6
- }
7
- export type ColumnsStickyPosition = Record<ColumnIndex, StickyPosition>;
8
- /**
9
- * Similar usage of Antd Table but only support partial features: fixed columns, row selection, on row click
10
- */
11
- export type VirtualTableRowSelection<RowType extends object> = {
12
- width: number;
13
- selectedRowKeys: React.Key[];
14
- onChange: (selectedRowKeys: React.Key[], selectedRows: RowType[]) => void;
15
- /**
16
- * Can only sticky in left
17
- */
18
- fixed?: boolean;
19
- isDisabled?: (data: RowType, rowIndex: number) => boolean;
20
- isSelectAllDisabled?: boolean;
21
- /**
22
- * Attention:
23
- * If title is provided, the select all checkbox wil be overridden
24
- */
25
- title?: React.ReactElement | string | number | null;
26
- };
27
- export type VirtualTableColumn<RowType extends object> = {
28
- title: React.ReactElement | string | number;
1
+ import type { TableColumn, TableProps } from "../Table";
2
+ interface TableColumnWithWidth<RowType extends object> extends Omit<TableColumn<RowType>, "width"> {
29
3
  width: number;
30
- /**
31
- * Attention:
32
- * If renderData return null, the corresponding table cell will not render
33
- */
34
- renderData: (record: RowType, rowIndex: number) => React.ReactNode | undefined;
35
- align?: "left" | "right" | "center";
36
- display?: "default" | "hidden";
37
- fixed?: "left" | "right";
38
- /**
39
- * Attention:
40
- * The overridden cell should return null in renderData props:
41
- * e.g. [{colSpan: 3, renderData: () => <div />}, {renderData: () => null}], {renderData: () => null}
42
- */
43
- colSpan?: (record: RowType, rowIndex: number, colIndex: number) => number;
44
- };
4
+ }
5
+ export type VirtualTableColumns<RowType extends object, UseScrollX = false> = UseScrollX extends true ? TableColumn<RowType>[] : TableColumnWithWidth<RowType>[];
6
+ interface VirtualTableBaseProps<RowType extends object> extends Omit<TableProps<RowType, undefined>, "columns" | "scrollX" | "scrollY"> {
7
+ width?: number | string;
8
+ scrollY?: number;
9
+ debounceDelay?: number;
10
+ }
11
+ interface VirtualTablePropsWithScrollX<RowType extends object> extends VirtualTableBaseProps<RowType> {
12
+ columns: VirtualTableColumns<RowType, true>;
13
+ scrollX: number;
14
+ }
15
+ interface VirtualTablePropsWithColumnWidth<RowType extends object> extends VirtualTableBaseProps<RowType> {
16
+ columns: VirtualTableColumns<RowType, false>;
17
+ }
18
+ export type VirtualTableProps<RowType extends object> = VirtualTablePropsWithScrollX<RowType> | VirtualTablePropsWithColumnWidth<RowType>;
45
19
  export {};
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import type { PickOptional } from "../../internal/type";
3
2
  import type { TooltipPlacement } from "../Tooltip";
4
3
  import "./index.less";
5
4
  export interface Props {
@@ -14,8 +13,4 @@ export interface Props {
14
13
  placement?: TooltipPlacement;
15
14
  iconPosition?: "left" | "right";
16
15
  }
17
- export declare class WithExplanation extends React.PureComponent<Props> {
18
- static displayName: string;
19
- static defaultProps: PickOptional<Props>;
20
- render(): string | number | bigint | true | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element;
21
- }
16
+ export declare const WithExplanation: ({ children, explanation, iconPosition }: Props) => string | number | bigint | true | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element;
@@ -1,25 +1,16 @@
1
1
  import React from "react";
2
2
  import { classNames } from "../../util/ClassNames";
3
3
  import { Tooltip } from "../Tooltip";
4
+ import { ReactUtil } from "../../util/ReactUtil";
4
5
  import "./index.less";
5
- export class WithExplanation extends React.PureComponent {
6
- static displayName = "WithExplanation";
7
- static defaultProps = {
8
- iconPosition: "right",
9
- };
10
- render() {
11
- const { children, explanation, iconPosition } = this.props;
12
- if (explanation) {
13
- return (React.createElement("div", { className: classNames("g-with-explanation", `with-icon-${iconPosition}`) },
14
- children,
15
- React.createElement(Tooltip, { className: "g-with-explanation-tooltip", title: Array.isArray(explanation) ? explanation.map((_, index) => React.createElement("p", { key: index }, _)) : explanation, childContainerProps: { className: "icon-container" } },
16
- React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 26 24" },
17
- React.createElement("circle", { cx: "8", cy: "8", r: "8", style: { strokeMiterlimit: 10 }, transform: "translate(3.5 4)" }),
18
- React.createElement("path", { d: "M2.338 9.9a.972.972 0 0 1-.294-.715.929.929 0 0 1 .294-.714.991.991 0 0 1 .728-.28 1 1 0 0 1 .742.28.929.929 0 0 1 .294.714.994.994 0 0 1-.308.728 1.049 1.049 0 0 1-.728.28 1 1 0 0 1-.728-.293zm-.014-2.466V7.2a2.794 2.794 0 0 1 .28-1.33 6.938 6.938 0 0 1 1.582-1.74l.239-.266a1.638 1.638 0 0 0 .391-1.022 1.593 1.593 0 0 0-.406-1.148 1.624 1.624 0 0 0-1.19-.419 1.549 1.549 0 0 0-1.373.6A2.345 2.345 0 0 0 1.47 3.3H0A3.247 3.247 0 0 1 .882.9 3.245 3.245 0 0 1 3.318 0 3.131 3.131 0 0 1 5.5.742a2.53 2.53 0 0 1 .841 2 2.71 2.71 0 0 1-.531 1.71 14.388 14.388 0 0 1-1.176 1.092 2.319 2.319 0 0 0-.588.728 1.871 1.871 0 0 0-.224.924v.238z", transform: "translate(8.336 6.808)" })))));
19
- }
20
- else {
21
- return children || "";
22
- }
23
- }
24
- }
6
+ export const WithExplanation = ReactUtil.memo("WithExplanation", ({ children, explanation, iconPosition = "right" }) => {
7
+ if (!explanation)
8
+ return children || "";
9
+ return (React.createElement("div", { className: classNames("g-with-explanation", `with-icon-${iconPosition}`) },
10
+ children,
11
+ React.createElement(Tooltip, { className: "g-with-explanation-tooltip", title: Array.isArray(explanation) ? explanation.map((_, index) => React.createElement("p", { key: index }, _)) : explanation, childContainerProps: { className: "icon-container" } },
12
+ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 26 24" },
13
+ React.createElement("circle", { cx: "8", cy: "8", r: "8", style: { strokeMiterlimit: 10 }, transform: "translate(3.5 4)" }),
14
+ React.createElement("path", { d: "M2.338 9.9a.972.972 0 0 1-.294-.715.929.929 0 0 1 .294-.714.991.991 0 0 1 .728-.28 1 1 0 0 1 .742.28.929.929 0 0 1 .294.714.994.994 0 0 1-.308.728 1.049 1.049 0 0 1-.728.28 1 1 0 0 1-.728-.293zm-.014-2.466V7.2a2.794 2.794 0 0 1 .28-1.33 6.938 6.938 0 0 1 1.582-1.74l.239-.266a1.638 1.638 0 0 0 .391-1.022 1.593 1.593 0 0 0-.406-1.148 1.624 1.624 0 0 0-1.19-.419 1.549 1.549 0 0 0-1.373.6A2.345 2.345 0 0 0 1.47 3.3H0A3.247 3.247 0 0 1 .882.9 3.245 3.245 0 0 1 3.318 0 3.131 3.131 0 0 1 5.5.742a2.53 2.53 0 0 1 .841 2 2.71 2.71 0 0 1-.531 1.71 14.388 14.388 0 0 1-1.176 1.092 2.319 2.319 0 0 0-.588.728 1.871 1.871 0 0 0-.224.924v.238z", transform: "translate(8.336 6.808)" })))));
15
+ });
25
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/WithExplanation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAGnC,OAAO,cAAc,CAAC;AAetB,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,aAAoB;IAC3D,MAAM,CAAC,WAAW,GAAG,iBAAiB,CAAC;IAEvC,MAAM,CAAC,YAAY,GAAwB;QACvC,YAAY,EAAE,OAAO;KACxB,CAAC;IAEF,MAAM;QACF,MAAM,EAAC,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACzD,IAAI,WAAW,EAAE,CAAC;YACd,OAAO,CACH,6BAAK,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,aAAa,YAAY,EAAE,CAAC;gBACxE,QAAQ;gBACT,oBAAC,OAAO,IACJ,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,2BAAG,GAAG,EAAE,KAAK,IAAG,CAAC,CAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EACvG,mBAAmB,EAAE,EAAC,SAAS,EAAE,gBAAgB,EAAC;oBAElD,6BAAK,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,WAAW;wBACvD,gCAAQ,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC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C,OAAO,EAAC,WAAW;gBACvD,gCAAQ,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,KAAK,EAAE,EAAC,gBAAgB,EAAE,EAAE,EAAC,EAAE,SAAS,EAAC,kBAAkB,GAAG;gBAC1F,8BACI,CAAC,EAAC,4nBAA4nB,EAC9nB,SAAS,EAAC,wBAAwB,GACpC,CACA,CACA,CACR,CACT,CAAC;AACN,CAAC,CAAC,CAAC"}
@@ -13,12 +13,4 @@ export interface Props {
13
13
  onClick?: () => void;
14
14
  onOpenChange?: (open: boolean) => void;
15
15
  }
16
- export declare class WithTooltipList extends React.PureComponent<Props> {
17
- static displayName: string;
18
- private readonly labelStyle;
19
- private readonly wrapperStyle;
20
- private readonly childContainerProps;
21
- renderTooltip: () => React.JSX.Element;
22
- render(): string | React.JSX.Element;
23
- private readonly dummyClick;
24
- }
16
+ export declare const WithTooltipList: ({ list, children, onClick, onOpenChange }: Props) => string | React.JSX.Element;