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

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 (340) 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 +1 -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 +5 -33
  185. package/core/NumberInput/index.js +44 -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 +6 -34
  238. package/core/Table/index.js +64 -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.js.map +1 -0
  292. package/core/VirtualTable/index.d.ts +24 -23
  293. package/core/VirtualTable/index.js +36 -50
  294. package/core/VirtualTable/index.js.map +1 -1
  295. package/core/VirtualTable/index.less +28 -140
  296. package/core/WithExplanation/index.d.ts +1 -6
  297. package/core/WithExplanation/index.js +11 -20
  298. package/core/WithExplanation/index.js.map +1 -1
  299. package/core/WithTooltipList/index.d.ts +1 -9
  300. package/core/WithTooltipList/index.js +28 -27
  301. package/core/WithTooltipList/index.js.map +1 -1
  302. package/core/YearMonthSelector/index.d.ts +1 -7
  303. package/core/YearMonthSelector/index.js +9 -15
  304. package/core/YearMonthSelector/index.js.map +1 -1
  305. package/css/global.less +0 -9
  306. package/hooks/useParentResizeObserver/index.d.ts +2 -0
  307. package/hooks/useParentResizeObserver/index.js +17 -0
  308. package/hooks/useParentResizeObserver/index.js.map +1 -0
  309. package/hooks/useResizeObserver/index.d.ts +1 -1
  310. package/hooks/useResizeObserver/index.js +6 -10
  311. package/hooks/useResizeObserver/index.js.map +1 -1
  312. package/package.json +6 -6
  313. package/util/ModalUtil/index.less +1 -1
  314. package/util/OrientationUtil/index.js +22 -37
  315. package/util/OrientationUtil/index.js.map +1 -1
  316. package/util/PromptUtil/PromptBody.d.ts +4 -13
  317. package/util/PromptUtil/PromptBody.js +19 -28
  318. package/util/PromptUtil/PromptBody.js.map +1 -1
  319. package/util/PromptUtil/index.js +1 -1
  320. package/util/PromptUtil/index.js.map +1 -1
  321. package/util/ReactUtil/index.d.ts +20 -0
  322. package/util/ReactUtil/index.js +35 -0
  323. package/util/ReactUtil/index.js.map +1 -1
  324. package/core/VirtualTable/TableHeader.js.map +0 -1
  325. package/core/VirtualTable/TableRow.js.map +0 -1
  326. package/core/VirtualTable/hooks/useColumnWidths.js.map +0 -1
  327. package/core/VirtualTable/hooks/useColumnsStickyPosition.js.map +0 -1
  328. package/core/VirtualTable/hooks/useRowSelection.js.map +0 -1
  329. package/core/VirtualTable/hooks/useScroll.js.map +0 -1
  330. package/core/VirtualTable/hooks/useScrollBarSize.js.map +0 -1
  331. package/core/VirtualTable/type.js.map +0 -1
  332. /package/core/VirtualTable/{TableHeader.d.ts → OldVirtualTable/TableHeader.d.ts} +0 -0
  333. /package/core/VirtualTable/{TableRow.d.ts → OldVirtualTable/TableRow.d.ts} +0 -0
  334. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnWidths.d.ts +0 -0
  335. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnsStickyPosition.d.ts +0 -0
  336. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScroll.d.ts +0 -0
  337. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScroll.js +0 -0
  338. /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScrollBarSize.d.ts +0 -0
  339. /package/core/VirtualTable/{type.d.ts → OldVirtualTable/type.d.ts} +0 -0
  340. /package/core/VirtualTable/{type.js → OldVirtualTable/type.js} +0 -0
package/core/Form/Item.js CHANGED
@@ -2,45 +2,33 @@ import React from "react";
2
2
  import { classNames } from "../../util/ClassNames";
3
3
  import { Tooltip } from "../Tooltip";
4
4
  import { FormValidationContext } from "./context";
5
- export class Item extends React.PureComponent {
6
- static displayName = "Form.Item";
7
- static contextType = FormValidationContext;
8
- overlayStyle = { color: "red" };
9
- constructor(props) {
10
- super(props);
11
- this.state = { errorMessage: null };
12
- }
13
- componentDidMount() {
14
- this.context.registerValidator(this.validate);
15
- }
16
- componentWillUnmount() {
17
- this.context.unregisterValidator(this.validate);
18
- }
19
- validate = async () => {
20
- const { validator } = this.props;
21
- if (validator) {
22
- const errorMessage = await validator();
23
- this.setState({ errorMessage });
24
- return errorMessage === null;
25
- }
26
- else {
5
+ import { ReactUtil } from "../../util/ReactUtil";
6
+ const overlayStyle = { color: "red" };
7
+ export const Item = ReactUtil.memo("Item", (props) => {
8
+ const { label, children, className, required, extra, labelStyle, widthMode, validator } = props;
9
+ const { registerValidator, unregisterValidator, errorDisplayMode } = React.useContext(FormValidationContext);
10
+ const [errorMessage, setErrorMessage] = React.useState(null);
11
+ const validate = React.useCallback(async () => {
12
+ if (!validator)
27
13
  return true;
28
- }
29
- };
30
- render() {
31
- const { label, children, className, required, extra, labelStyle, widthMode } = this.props;
32
- const { errorMessage } = this.state;
33
- const errorDisplayMode = this.context.errorDisplayMode();
34
- const childrenNode = typeof children === "number" || typeof children === "string" ? React.createElement("span", { className: "pure-text" }, children) : children;
35
- const extraMessageNode = extra && React.createElement("div", { className: "message" }, extra);
36
- return (React.createElement("div", { className: classNames("g-form-item", className) },
37
- React.createElement("div", { className: classNames("g-form-item-label", { required }), style: labelStyle }, label && React.createElement("label", null, label)),
38
- React.createElement("div", { className: classNames("g-form-item-children", { "has-error": errorMessage }, widthMode ? `width-${widthMode}` : "") }, errorDisplayMode.type === "extra" ? (React.createElement(React.Fragment, null,
39
- childrenNode,
40
- extraMessageNode,
41
- errorMessage && React.createElement("div", { className: "message error" }, errorMessage))) : (React.createElement(React.Fragment, null,
42
- React.createElement(Tooltip, { title: errorMessage, open: errorMessage !== null, placement: errorDisplayMode.placement || "right", color: "white", styles: { body: this.overlayStyle } }, childrenNode),
43
- extraMessageNode)))));
44
- }
45
- }
14
+ const errorMessage = await validator();
15
+ setErrorMessage(errorMessage);
16
+ return errorMessage === null;
17
+ }, [validator]);
18
+ React.useEffect(() => {
19
+ registerValidator(validate);
20
+ return () => unregisterValidator(validate);
21
+ }, [registerValidator, unregisterValidator, validate]);
22
+ const childrenNode = typeof children === "number" || typeof children === "string" ? React.createElement("span", { className: "pure-text" }, children) : children;
23
+ const extraMessageNode = extra && React.createElement("div", { className: "message" }, extra);
24
+ const errorDisplay = errorDisplayMode();
25
+ return (React.createElement("div", { className: classNames("g-form-item", className) },
26
+ React.createElement("div", { className: classNames("g-form-item-label", { required }), style: labelStyle }, label && React.createElement("label", null, label)),
27
+ React.createElement("div", { className: classNames("g-form-item-children", { "has-error": errorMessage }, widthMode ? `width-${widthMode}` : "") }, errorDisplay.type === "extra" ? (React.createElement(React.Fragment, null,
28
+ childrenNode,
29
+ extraMessageNode,
30
+ errorMessage && React.createElement("div", { className: "message error" }, errorMessage))) : (React.createElement(React.Fragment, null,
31
+ React.createElement(Tooltip, { title: errorMessage, open: errorMessage !== null, placement: errorDisplay.placement || "right", color: "white", styles: { container: overlayStyle } }, childrenNode),
32
+ extraMessageNode)))));
33
+ });
46
34
  //# sourceMappingURL=Item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../src/core/Form/Item.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;AACnC,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAmBhD,MAAM,OAAO,IAAK,SAAQ,KAAK,CAAC,aAA2B;IACvD,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,MAAM,CAAC,WAAW,GAAG,qBAAqB,CAAC;IAG1B,YAAY,GAAwB,EAAC,KAAK,EAAE,K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,KAAK,IAAI,6BAAK,SAAS,EAAC,SAAS,IAAE,KAAK,CAAO,CAAC;IACzE,MAAM,YAAY,GAAG,gBAAgB,EAAE,CAAC;IAExC,OAAO,CACH,6BAAK,SAAS,EAAE,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC;QAChD,6BAAK,SAAS,EAAE,UAAU,CAAC,mBAAmB,EAAE,EAAC,QAAQ,EAAC,CAAC,EAAE,KAAK,EAAE,UAAU,IACzE,KAAK,IAAI,mCAAQ,KAAK,CAAS,CAC9B;QACN,6BAAK,SAAS,EAAE,UAAU,CAAC,sBAAsB,EAAE,EAAC,WAAW,EAAE,YAAY,EAAC,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IACjH,YAAY,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAC7B,oBAAC,KAAK,CAAC,QAAQ;YACV,YAAY;YACZ,gBAAgB;YAChB,YAAY,IAAI,6BAAK,SAAS,EAAC,eAAe,IAAE,YAAY,CAAO,CACvD,CACpB,CAAC,CAAC,CAAC,CACA,oBAAC,KAAK,CAAC,QAAQ;YACX,oBAAC,OAAO,IAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,SAAS,IAAI,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,MAAM,EAAE,EAAC,SAAS,EAAE,YAAY,EAAC,IACnJ,YAAY,CACP;YACT,gBAAgB,CACJ,CACpB,CACC,CACJ,CACT,CAAC;AACN,CAAC,CAAC,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
- import { Item } from "./Item";
3
- import type { PickOptional } from "../../internal/type";
4
2
  import type { FormErrorDisplayMode } from "./context";
5
3
  import "./index.less";
6
4
  export type { Props as FormItemProps, FormValidator } from "./Item";
5
+ export interface FormHandler {
6
+ triggerSubmit: () => Promise<boolean>;
7
+ }
7
8
  export interface Props {
8
9
  children: React.ReactNode;
9
10
  id?: string;
@@ -20,18 +21,6 @@ export interface Props {
20
21
  buttonRenderer?: ((submitButton: React.ReactElement, isValidating: boolean, loading?: boolean) => React.ReactElement) | null;
21
22
  allowBrowserAutoComplete?: boolean;
22
23
  }
23
- interface State {
24
- isValidating: boolean;
25
- }
26
- export declare class Form extends React.PureComponent<Props, State> {
27
- static displayName: string;
28
- static defaultProps: PickOptional<Props>;
29
- static Item: typeof Item;
30
- private readonly validationContext;
31
- private validators;
32
- constructor(props: Props);
33
- triggerSubmit: () => Promise<boolean>;
34
- onSubmit: (event: React.FormEvent) => Promise<void>;
35
- renderSubmitButton(): React.JSX.Element | null;
36
- render(): React.JSX.Element;
37
- }
24
+ export declare const Form: React.ForwardRefExoticComponent<Props & React.RefAttributes<FormHandler>> & {
25
+ Item: (props: import("./Item").Props) => React.JSX.Element;
26
+ };
@@ -5,37 +5,30 @@ import { FormValidationContext } from "./context";
5
5
  import { i18n } from "../../internal/i18n/core";
6
6
  import { Item } from "./Item";
7
7
  import "./index.less";
8
- export class Form extends React.PureComponent {
9
- static displayName = "Form";
10
- static defaultProps = {
11
- layout: "horizontal",
12
- errorDisplayMode: { type: "extra" },
8
+ import { ReactUtil } from "../../util/ReactUtil";
9
+ export const Form = ReactUtil.compound("Form", { Item }, React.forwardRef((props, forwardRef) => {
10
+ const { children, id, className, style, layout = "horizontal", allowBrowserAutoComplete, loading, buttonRenderer: defaultButtonRenderer, buttonStyle, buttonText, buttonIcon, buttonDisabled, onFinish, errorDisplayMode = { type: "extra" }, } = props;
11
+ const [isValidating, setIsValidating] = React.useState(false);
12
+ const [validators, setValidators] = React.useState([]);
13
+ const registerValidator = React.useCallback((validator) => setValidators(prev => [...prev, validator]), []);
14
+ const unregisterValidator = React.useCallback((validator) => setValidators(prev => prev.filter(v => v !== validator)), []);
15
+ const validationContext = {
16
+ registerValidator,
17
+ unregisterValidator,
18
+ errorDisplayMode: () => errorDisplayMode,
13
19
  };
14
- static Item = Item;
15
- validationContext;
16
- validators = [];
17
- constructor(props) {
18
- super(props);
19
- this.state = {
20
- isValidating: false,
21
- };
22
- this.validationContext = {
23
- registerValidator: validator => this.validators.push(validator),
24
- unregisterValidator: validator => {
25
- const index = this.validators.indexOf(validator);
26
- if (index >= 0) {
27
- this.validators.splice(index, 1);
28
- }
29
- },
30
- errorDisplayMode: () => this.props.errorDisplayMode,
31
- };
32
- }
33
- // Exposed for outer ref use, not recommended
34
- triggerSubmit = async () => {
35
- const { onFinish } = this.props;
20
+ React.useImperativeHandle(forwardRef, () => ({
21
+ triggerSubmit,
22
+ }));
23
+ const onSubmit = async (event) => {
24
+ event.preventDefault();
25
+ event.stopPropagation();
26
+ await triggerSubmit();
27
+ };
28
+ const triggerSubmit = async () => {
36
29
  try {
37
- this.setState({ isValidating: true });
38
- const validatorResults = await Promise.all(this.validators.map(_ => _()));
30
+ setIsValidating(true);
31
+ const validatorResults = await Promise.all(validators.map(_ => _()));
39
32
  if (validatorResults.every(_ => _)) {
40
33
  // Also true even if validatorResults is []
41
34
  onFinish?.();
@@ -44,27 +37,17 @@ export class Form extends React.PureComponent {
44
37
  return false;
45
38
  }
46
39
  finally {
47
- this.setState({ isValidating: false });
40
+ setIsValidating(false);
48
41
  }
49
42
  };
50
- onSubmit = async (event) => {
51
- event.preventDefault();
52
- event.stopPropagation();
53
- await this.triggerSubmit();
54
- };
55
- renderSubmitButton() {
56
- const { loading, buttonRenderer: defaultButtonRenderer, buttonStyle, buttonText, buttonIcon, buttonDisabled } = this.props;
57
- const { isValidating } = this.state;
43
+ const renderSubmitButton = () => {
58
44
  const buttonRenderer = defaultButtonRenderer === undefined ? (submitButton) => submitButton : defaultButtonRenderer;
59
45
  const t = i18n();
60
46
  const submitButton = (React.createElement(Button, { className: "g-form-submit-button", htmlType: "submit", type: "primary", key: "submitButton", style: buttonStyle, loading: isValidating || loading, icon: buttonIcon, disabled: buttonDisabled || isValidating || loading }, buttonText || t.submit));
61
47
  return buttonRenderer !== null ? React.createElement(Form.Item, { className: "g-form-submit-form-item" }, buttonRenderer(submitButton, isValidating, loading)) : null;
62
- }
63
- render() {
64
- const { children, id, className, style, layout, allowBrowserAutoComplete } = this.props;
65
- return (React.createElement("form", { autoComplete: allowBrowserAutoComplete ? undefined : "off", id: id, className: classNames("g-form", `g-form-${layout}`, className), style: style, onSubmit: this.onSubmit },
66
- React.createElement(FormValidationContext.Provider, { value: this.validationContext }, children),
67
- this.renderSubmitButton()));
68
- }
69
- }
48
+ };
49
+ return (React.createElement("form", { autoComplete: allowBrowserAutoComplete ? undefined : "off", id: id, className: classNames("g-form", `g-form-${layout}`, className), style: style, onSubmit: onSubmit },
50
+ React.createElement(FormValidationContext.Provider, { value: validationContext }, children),
51
+ renderSubmitButton()));
52
+ }));
70
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Form/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,cAAc,CAAC;AAyBtB,MAAM,OAAO,IAAK,SAAQ,KAAK,CAAC,aAA2B;IACvD,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,YAAY,GAAwB;QACvC,MAAM,EAAE,YAAY;QACpB,gBAAgB,EAAE,EAAC,IAAI,EAAE,OAAO,EAAC;KACpC,CAAC;IACF,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IAEF,iBAAiB,CAA4B;IACtD,UAAU,GAAkC,EAAE,CAAC;IAEvD,YAAY,KAA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,CAAC,QAAQ,EAAE,UAAU,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ;QACtK,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,iBAAiB,IAAG,QAAQ,CAAkC;QACpG,kBAAkB,EAAE,CAClB,CACV,CAAC;AACN,CAAC,CAAC,CACL,CAAC"}
@@ -97,7 +97,7 @@
97
97
  &.has-error {
98
98
  textarea,
99
99
  input,
100
- .ant-select-selector,
100
+ .ant-select-content,
101
101
  .ant-descriptions-view,
102
102
  .ant-input-affix-wrapper,
103
103
  .ant-upload {
@@ -1,4 +1,4 @@
1
- export declare const Grid: Readonly<{
1
+ export declare const Grid: {
2
2
  Row: import("react").ForwardRefExoticComponent<import("antd").RowProps & import("react").RefAttributes<HTMLDivElement>>;
3
3
  Column: import("react").ForwardRefExoticComponent<import("antd").ColProps & import("react").RefAttributes<HTMLDivElement>>;
4
- }>;
4
+ };
@@ -1,5 +1,6 @@
1
1
  import { Row, Col } from "antd";
2
- export const Grid = Object.freeze({
2
+ import { ReactUtil } from "../../util/ReactUtil";
3
+ export const Grid = ReactUtil.statics("Grid", {
3
4
  Row,
4
5
  Column: Col,
5
6
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Grid/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,GAAG,EAAC,MAAM,MAAM,CAAC;AAE9B,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,GAAG;IACH,MAAM,EAAE,GAAG;CACd,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Grid/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,GAAG,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAE/C,MAAM,CAAC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE;IAC1C,GAAG;IACH,MAAM,EAAE,GAAG;CACd,CAAC,CAAC"}
@@ -4,8 +4,5 @@ interface Props {
4
4
  html: string;
5
5
  className?: string;
6
6
  }
7
- export declare class HTMLContent extends React.PureComponent<Props> {
8
- static displayName: string;
9
- render(): React.JSX.Element;
10
- }
7
+ export declare const HTMLContent: ({ html, className }: Props) => React.JSX.Element;
11
8
  export {};
@@ -1,11 +1,8 @@
1
1
  import React from "react";
2
2
  import { classNames } from "../../util/ClassNames";
3
+ import { ReactUtil } from "../../util/ReactUtil";
3
4
  import "./index.less";
4
- export class HTMLContent extends React.PureComponent {
5
- static displayName = "HTMLContent";
6
- render() {
7
- const { html, className } = this.props;
8
- return React.createElement("div", { className: classNames("g-html-content", className), dangerouslySetInnerHTML: { __html: html } });
9
- }
10
- }
5
+ export const HTMLContent = ReactUtil.memo("HTMLContent", ({ html, className }) => {
6
+ return React.createElement("div", { className: classNames("g-html-content", className), dangerouslySetInnerHTML: { __html: html } });
7
+ });
11
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/HTMLContent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,cAAc,CAAC;AAOtB,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAAoB;IACvD,MAAM,CAAC,WAAW,GAAG,aAAa,CAAC;IAEnC,MAAM;QACF,MAAM,EAAC,IAAI,EAAE,SAAS,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACrC,OAAO,6BAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,uBAAuB,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,GAAI,CAAC;IAChH,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/HTMLContent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,cAAc,CAAC;AAOtB,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,SAAS,EAAQ,EAAE,EAAE;IAClF,OAAO,6BAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,uBAAuB,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,GAAI,CAAC;AAChH,CAAC,CAAC,CAAC"}
@@ -1,10 +1,7 @@
1
1
  import type { ImageProps } from "antd/es/image";
2
- import AntImage from "antd/es/image";
3
2
  import React from "react";
4
3
  export interface Props extends ImageProps {
5
4
  }
6
- export declare class Image extends React.PureComponent<Props> {
7
- static displayName: string;
8
- static PreviewGroup: typeof AntImage.PreviewGroup;
9
- render(): React.JSX.Element;
10
- }
5
+ export declare const Image: ((props: Props) => React.JSX.Element) & {
6
+ PreviewGroup: React.FC<import("antd/es/image/PreviewGroup").PreviewGroupProps>;
7
+ };
@@ -1,10 +1,9 @@
1
1
  import AntImage from "antd/es/image";
2
2
  import React from "react";
3
- export class Image extends React.PureComponent {
4
- static displayName = "Image";
5
- static PreviewGroup = AntImage.PreviewGroup;
6
- render() {
7
- return React.createElement(AntImage, { ...this.props });
8
- }
9
- }
3
+ import { ReactUtil } from "../../util/ReactUtil";
4
+ export const Image = ReactUtil.compound("Image", {
5
+ PreviewGroup: AntImage.PreviewGroup,
6
+ }, (props) => {
7
+ return React.createElement(AntImage, { ...props });
8
+ });
10
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Image/index.tsx"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,OAAO,KAAM,SAAQ,KAAK,CAAC,aAAoB;IACjD,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC;IAE7B,MAAM,CAAC,YAAY,GAAiC,QAAQ,CAAC,YAAY,CAAC;IAE1E,MAAM;QACF,OAAO,oBAAC,QAAQ,OAAK,IAAI,CAAC,KAAK,GAAI,CAAC;IACxC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Image/index.tsx"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAI/C,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CACnC,OAAO,EACP;IACI,YAAY,EAAE,QAAQ,CAAC,YAAY;CACtC,EACD,CAAC,KAAY,EAAE,EAAE;IACb,OAAO,oBAAC,QAAQ,OAAK,KAAK,GAAI,CAAC;AACnC,CAAC,CACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { UploaderProps, UploadSuccessLogEntry } from "../../util/UploadUtil/type";
2
+ import type { UploaderProps } from "../../util/UploadUtil/type";
3
3
  import "./index.less";
4
4
  export interface Props<SuccessResponseType, ErrorResponseType> extends UploaderProps<SuccessResponseType, ErrorResponseType> {
5
5
  imageURL: string | null;
@@ -12,13 +12,4 @@ export interface Props<SuccessResponseType, ErrorResponseType> extends UploaderP
12
12
  className?: string;
13
13
  style?: React.CSSProperties;
14
14
  }
15
- export declare class ImageUploader<SuccessResponseType, ErrorResponseType> extends React.PureComponent<Props<SuccessResponseType, ErrorResponseType>> {
16
- static displayName: string;
17
- openPreviewModal: (e: React.MouseEvent) => Promise<void>;
18
- removeImage: (e: React.MouseEvent) => Promise<void>;
19
- beforeUpload: (file: File) => boolean;
20
- preventUploadBehavior: (e: React.MouseEvent) => void;
21
- onUploadSuccess: (logEntry: UploadSuccessLogEntry, response: SuccessResponseType) => void;
22
- renderActionIcon: (name: string, icon: React.ReactElement) => React.JSX.Element;
23
- render(): React.JSX.Element;
24
- }
15
+ export declare const ImageUploader: <Res, Err>(props: Props<Res, Err>) => React.JSX.Element;
@@ -8,53 +8,45 @@ import { MediaUtil } from "../../util/MediaUtil";
8
8
  import { i18n } from "../../internal/i18n/core";
9
9
  import { Uploader } from "../../core/Uploader";
10
10
  import { Tooltip } from "../../core/Tooltip";
11
+ import { ReactUtil } from "../../util/ReactUtil";
11
12
  import "./index.less";
12
- export class ImageUploader extends React.PureComponent {
13
- static displayName = "ImageUploader";
14
- openPreviewModal = async (e) => {
13
+ export const ImageUploader = ReactUtil.memo("ImageUploader", (props) => {
14
+ const { uploadURL, formField, className, style, imageURL, disabled, width, height, onRemove, onUploadFailure, fileSizeLimitMB, onChange, onUploadSuccess } = props;
15
+ const t = i18n();
16
+ const openPreviewModal = async (e) => {
15
17
  e.stopPropagation();
16
- const { imageURL } = this.props;
17
- if (imageURL) {
18
+ if (imageURL)
18
19
  await MediaUtil.openImage(imageURL);
19
- }
20
20
  };
21
- removeImage = async (e) => {
21
+ const removeImage = async (e) => {
22
22
  e.stopPropagation();
23
- const { onRemove } = this.props;
24
- const t = i18n();
25
23
  if (await ModalUtil.confirm(t.confirmImageRemoval)) {
26
24
  onRemove?.();
27
25
  }
28
26
  };
29
- beforeUpload = (file) => {
30
- const { fileSizeLimitMB } = this.props;
27
+ const beforeUpload = (file) => {
31
28
  if (fileSizeLimitMB && file.size > 1024 * 1024 * fileSizeLimitMB) {
32
29
  return false;
33
30
  }
34
31
  return true;
35
32
  };
36
- preventUploadBehavior = (e) => {
33
+ const preventUploadBehavior = (e) => {
37
34
  if (e.target === e.currentTarget) {
38
35
  // Only trigger for clicking "Upload" icon
39
36
  e.stopPropagation();
40
37
  }
41
38
  };
42
- onUploadSuccess = (logEntry, response) => {
43
- const { onChange, onUploadSuccess } = this.props;
39
+ const onAntUploadSuccess = (logEntry, response) => {
44
40
  onChange(response);
45
41
  onUploadSuccess?.(logEntry, response);
46
42
  };
47
- renderActionIcon = (name, icon) => {
43
+ const renderActionIcon = (name, icon) => {
48
44
  return (React.createElement(Tooltip, { title: name, childContainerProps: { className: "action" } }, icon));
49
45
  };
50
- render() {
51
- const { uploadURL, formField, className, style, imageURL, disabled, width, height, onRemove, onUploadFailure } = this.props;
52
- const t = i18n();
53
- return (React.createElement(Uploader, { accept: "image/*", formField: formField, uploadURL: uploadURL, onUploadFailure: onUploadFailure, onUploadSuccess: this.onUploadSuccess, style: { ...style, width, height }, className: classNames("g-image-uploader", className), disabled: disabled, beforeUpload: this.beforeUpload }, imageURL ? (React.createElement("div", { className: "image-container", style: { backgroundImage: `url(${imageURL})`, height } },
54
- React.createElement("div", { className: "overlay", onClick: this.preventUploadBehavior },
55
- this.renderActionIcon(t.preview, React.createElement(EyeOutlined, { onClick: this.openPreviewModal })),
56
- !disabled && this.renderActionIcon(t.upload, React.createElement(CloudUploadOutlined, null)),
57
- !disabled && onRemove && this.renderActionIcon(t.delete, React.createElement(DeleteOutlined, { onClick: this.removeImage }))))) : (t.uploadHint)));
58
- }
59
- }
46
+ return (React.createElement(Uploader, { accept: "image/*", formField: formField, uploadURL: uploadURL, onUploadFailure: onUploadFailure, onUploadSuccess: onAntUploadSuccess, style: { ...style, width, height }, className: classNames("g-image-uploader", className), disabled: disabled, beforeUpload: beforeUpload }, imageURL ? (React.createElement("div", { className: "image-container", style: { backgroundImage: `url(${imageURL})`, height } },
47
+ React.createElement("div", { className: "overlay", onClick: preventUploadBehavior },
48
+ renderActionIcon(t.preview, React.createElement(EyeOutlined, { onClick: openPreviewModal })),
49
+ !disabled && renderActionIcon(t.upload, React.createElement(CloudUploadOutlined, null)),
50
+ !disabled && onRemove && renderActionIcon(t.delete, React.createElement(DeleteOutlined, { onClick: removeImage }))))) : (t.uploadHint)));
51
+ });
60
52
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/ImageUploader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,cAAc,CAAC;AActB,MAAM,OAAO,aAAsD,SAAQ,KAAK,CAAC,aAA4D;IACzI,MAAM,CAAC,WAAW,GAAG,eAAe,CAAC;IAErC,gBAAgB,GAAG,KAAK,EAAE,CAAmB,EAAE,EAAE;QAC7C,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;IACL,CAAC,CAAC;IAEF,WAAW,GAAG,KAAK,EAAE,CAAmB,EAAE,EAAE;QACxC,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;QACjB,IAAI,MAAM,SAAS,CAAC,OAAO,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;QACjF,6BAAK,SAAS,EAAC,SAAS,EAAC,OAAO,EAAE,qBAAqB;YAClD,gBAAgB,CAAC,CAAC,CAAC,OAAO,EAAE,oBAAC,WAAW,IAAC,OAAO,EAAE,gBAAgB,GAAI,CAAC;YACvE,CAAC,QAAQ,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,EAAE,oBAAC,mBAAmB,OAAG,CAAC;YAChE,CAAC,QAAQ,IAAI,QAAQ,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,EAAE,oBAAC,cAAc,IAAC,OAAO,EAAE,WAAW,GAAI,CAAC,CAC5F,CACJ,CACT,CAAC,CAAC,CAAC,CACA,CAAC,CAAC,UAAU,CACf,CACM,CACd,CAAC;AACN,CAAC,CAAC,CAAC"}
@@ -22,22 +22,16 @@ export interface Props extends Omit<InputProps, ExcludedAntInputKeys>, Controlle
22
22
  focus?: FocusType;
23
23
  inputRef?: React.RefObject<InputRef | null>;
24
24
  }
25
- export declare class Input extends React.PureComponent<Props> {
26
- static displayName: string;
27
- static Readonly: (props: InputReadonlyProps) => React.JSX.Element;
28
- static Search: ({ onChange, ...rest }: InputSearchProps) => React.JSX.Element;
29
- static TextArea: ({ onChange, ...rest }: InputTextAreaProps) => React.JSX.Element;
30
- static Password: ({ onChange, ...rest }: InputPasswordProps) => React.JSX.Element;
31
- static Nullable: ({ value, onChange, ...rest }: InputNullableProps) => React.JSX.Element;
32
- static NullableTextArea: ({ value, onChange, ...rest }: InputNullableTextAreaProps) => React.JSX.Element;
33
- private static onChange;
34
- private antInputRef;
35
- private getRef;
36
- private createFocusOptions;
37
- private handleClick;
38
- componentDidMount(): void;
39
- blur: () => void | undefined;
40
- focus: (focusType?: FocusType) => void | undefined;
41
- render(): React.JSX.Element;
42
- }
25
+ export interface InputHandler {
26
+ blur: () => void;
27
+ focus: (focusType?: FocusType) => void;
28
+ }
29
+ export declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<InputHandler>> & {
30
+ Readonly: (props: InputReadonlyProps) => React.JSX.Element;
31
+ Search: ({ onChange, ...rest }: InputSearchProps) => React.JSX.Element;
32
+ TextArea: ({ onChange, ...rest }: InputTextAreaProps) => React.JSX.Element;
33
+ Password: ({ onChange, ...rest }: InputPasswordProps) => React.JSX.Element;
34
+ Nullable: ({ value, onChange, ...rest }: InputNullableProps) => React.JSX.Element;
35
+ NullableTextArea: ({ value, onChange, ...rest }: InputNullableTextAreaProps) => React.JSX.Element;
36
+ };
43
37
  export {};
@@ -1,50 +1,46 @@
1
1
  import React from "react";
2
2
  import AntInput from "antd/es/input";
3
- export class Input extends React.PureComponent {
4
- static displayName = "Input";
5
- static Readonly = (props) => React.createElement(AntInput, { onChange: () => { }, readOnly: true, disabled: true, ...props });
6
- static Search = ({ onChange, ...rest }) => React.createElement(AntInput.Search, { onChange: e => Input.onChange(e, onChange), ...rest });
7
- static TextArea = ({ onChange, ...rest }) => React.createElement(AntInput.TextArea, { onChange: e => Input.onChange(e, onChange), ...rest });
8
- static Password = ({ onChange, ...rest }) => React.createElement(AntInput.Password, { onChange: e => Input.onChange(e, onChange), ...rest });
9
- static Nullable = ({ value, onChange, ...rest }) => React.createElement(Input, { value: value || "", onChange: value => onChange(value.trim() ? value : null), ...rest });
10
- static NullableTextArea = ({ value, onChange, ...rest }) => React.createElement(Input.TextArea, { value: value || "", onChange: value => onChange(value.trim() ? value : null), ...rest });
11
- static onChange = (e, onValueChange, autoTrim) => {
12
- if (autoTrim) {
13
- e.target.value = e.target.value.trim();
14
- }
15
- onValueChange(e.target.value);
16
- };
17
- antInputRef = React.createRef();
18
- getRef = () => this.props.inputRef ?? this.antInputRef;
19
- createFocusOptions(focus) {
20
- const type = focus || this.props.focus;
21
- if (!type)
3
+ import { ReactUtil } from "../../util/ReactUtil";
4
+ import { useDidMountEffect } from "../../hooks/useDidMountEffect";
5
+ const handleInputChange = (e, onValueChange, autoTrim) => {
6
+ if (autoTrim) {
7
+ e.target.value = e.target.value.trim();
8
+ }
9
+ onValueChange(e.target.value);
10
+ };
11
+ export const Input = ReactUtil.compound("Input", {
12
+ Readonly: (props) => React.createElement(AntInput, { onChange: () => { }, readOnly: true, disabled: true, ...props }),
13
+ Search: ({ onChange, ...rest }) => React.createElement(AntInput.Search, { onChange: e => handleInputChange(e, onChange), ...rest }),
14
+ TextArea: ({ onChange, ...rest }) => React.createElement(AntInput.TextArea, { onChange: e => handleInputChange(e, onChange), ...rest }),
15
+ Password: ({ onChange, ...rest }) => React.createElement(AntInput.Password, { onChange: e => handleInputChange(e, onChange), ...rest }),
16
+ Nullable: ({ value, onChange, ...rest }) => React.createElement(Input, { value: value || "", onChange: value => onChange(value.trim() ? value : null), ...rest }),
17
+ NullableTextArea: ({ value, onChange, ...rest }) => React.createElement(Input.TextArea, { value: value || "", onChange: value => onChange(value.trim() ? value : null), ...rest }),
18
+ }, React.forwardRef((props, forwardRef) => {
19
+ const { onChange, autoFocus, autoTrim, inputRef, focus: focusProp, onClick, ...restProps } = props;
20
+ const antInputRef = React.useRef(null);
21
+ const ref = inputRef ?? antInputRef;
22
+ const createFocusOptions = (focusType) => {
23
+ if (!focusType)
22
24
  return undefined;
23
- if (type === "prevent-scroll") {
25
+ if (focusType === "prevent-scroll") {
24
26
  return { preventScroll: true };
25
27
  }
26
28
  else {
27
- return { cursor: type === "cursor-at-start" ? "start" : type === "cursor-at-last" ? "end" : "all" };
29
+ return { cursor: focusType === "cursor-at-start" ? "start" : focusType === "cursor-at-last" ? "end" : "all" };
28
30
  }
29
- }
30
- handleClick = event => {
31
- this.getRef().current?.focus(this.createFocusOptions());
32
- this.props.onClick?.(event);
33
31
  };
34
- componentDidMount() {
35
- if (this.props.autoFocus) {
36
- this.getRef().current?.focus(this.createFocusOptions());
37
- }
38
- }
39
- blur = () => this.getRef().current?.blur();
40
- focus = (focusType) => (this.props.inputRef || this.antInputRef).current?.focus(this.createFocusOptions(focusType));
41
- render() {
42
- const { onChange,
43
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- not included in restProps
44
- autoFocus, autoTrim, inputRef,
45
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- not included in restProps
46
- onClick, ...restProps } = this.props;
47
- return React.createElement(AntInput, { ...restProps, ref: inputRef || this.antInputRef, onClick: this.handleClick, onChange: e => Input.onChange(e, onChange, autoTrim) });
48
- }
49
- }
32
+ React.useImperativeHandle(forwardRef, () => ({
33
+ blur: () => ref.current?.blur(),
34
+ focus: (focusType) => ref.current?.focus(createFocusOptions(focusType || focusProp)),
35
+ }));
36
+ useDidMountEffect(() => {
37
+ if (autoFocus)
38
+ ref.current?.focus(createFocusOptions(focusProp));
39
+ });
40
+ const handleClick = event => {
41
+ ref.current?.focus(createFocusOptions(focusProp));
42
+ onClick?.(event);
43
+ };
44
+ return React.createElement(AntInput, { ...restProps, ref: inputRef || antInputRef, onClick: handleClick, onChange: e => handleInputChange(e, onChange, autoTrim) });
45
+ }));
50
46
  //# sourceMappingURL=index.js.map