fan-standard-comp 3.2.0 → 3.2.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 (293) hide show
  1. package/Readme.md +1 -33
  2. package/dist/09cd8e9be7081f2166444cce393fe968.svg +54 -0
  3. package/dist/e3378c145b7db195ad068735e15fb28a.svg +165 -0
  4. package/dist/fan-standard-comp.umd.js +166 -444
  5. package/dist/fonts/iconfont.ttf +0 -0
  6. package/dist/fonts/iconfont.woff +0 -0
  7. package/dist/fonts/lg.ttf +0 -0
  8. package/dist/fonts/lg.woff +0 -0
  9. package/dist/fonts/lg.woff2 +0 -0
  10. package/es/ButtonGroup/ButtonList.d.ts +2 -1
  11. package/es/ButtonGroup/ButtonMenu.d.ts +2 -1
  12. package/es/ButtonGroup/PopConfirmTitle.js +5 -5
  13. package/es/ButtonGroup/index.d.ts +3 -1
  14. package/es/ButtonGroup/index.js +147 -178
  15. package/es/ButtonGroup/style/index.less +4 -1
  16. package/es/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
  17. package/es/CalendarCoordPicker/CalendarMonthPicker.js +26 -0
  18. package/es/CalendarCoordPicker/index.d.ts +8 -0
  19. package/es/CalendarCoordPicker/index.js +296 -0
  20. package/es/CalendarCoordPicker/index.less +31 -0
  21. package/es/ConfigContext/index.d.ts +7 -0
  22. package/es/ConfigContext/index.js +12 -0
  23. package/es/DragContent/index.d.ts +1 -1
  24. package/es/DragContent/index.js +5 -5
  25. package/es/FormComp/ChunkUploader/api.js +14 -14
  26. package/es/FormComp/ChunkUploader/index.js +132 -139
  27. package/es/FormComp/ChunkUploader/lib.js +21 -21
  28. package/es/FormComp/ChunkUploader/upload-queue.class.js +64 -66
  29. package/es/FormComp/EditButton/index.d.ts +1 -1
  30. package/es/FormComp/EditButton/index.js +15 -17
  31. package/es/FormComp/FieldComponent/ReUpload.d.ts +1 -1
  32. package/es/FormComp/FieldComponent/ReUpload.js +37 -23
  33. package/es/FormComp/FieldComponent/RefactorTextarea.js +32 -0
  34. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +72 -19
  35. package/es/FormComp/FieldComponent/TitleNode.d.ts +2 -1
  36. package/es/FormComp/FieldComponent/index.d.ts +1 -1
  37. package/es/FormComp/FieldComponent/index.js +33 -23
  38. package/es/FormComp/FieldComponent/setReadonlyValues.js +6 -6
  39. package/es/FormComp/RenderItemGroup/index.js +24 -8
  40. package/es/FormComp/Uploader/index.d.ts +3 -1
  41. package/es/FormComp/Uploader/index.js +243 -119
  42. package/es/FormComp/VarTemplate/index.js +57 -64
  43. package/es/ImageGallery/ImagePreview.d.ts +13 -0
  44. package/es/ImageGallery/ImagePreview.js +168 -0
  45. package/es/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
  46. package/es/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
  47. package/es/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
  48. package/es/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
  49. package/es/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
  50. package/es/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
  51. package/es/ImageGallery/PreviewStyles/lg-video.css +144 -0
  52. package/es/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
  53. package/es/ImageGallery/PreviewStyles/lightgallery.css +728 -0
  54. package/es/ImageGallery/SliderContent.d.ts +7 -0
  55. package/es/ImageGallery/SliderContent.js +699 -0
  56. package/es/ImageGallery/Thumbnail.d.ts +3 -0
  57. package/es/ImageGallery/Thumbnail.js +296 -0
  58. package/es/ImageGallery/hook/uniqueId.d.ts +1 -0
  59. package/es/ImageGallery/hook/uniqueId.js +10 -0
  60. package/es/ImageGallery/index.d.ts +4 -0
  61. package/es/ImageGallery/index.js +29 -0
  62. package/es/ImageGallery/style/index.less +5 -0
  63. package/es/ImageGallery/types.d.ts +5 -0
  64. package/es/ImageGallery/types.js +1 -0
  65. package/es/NavLeafScroll/index.js +94 -50
  66. package/es/RefactorTree/index.d.ts +1 -1
  67. package/es/RefactorTree/index.js +6 -6
  68. package/es/RefactorTree/indexTreeNode.d.ts +1 -1
  69. package/es/RefactorTree/indexTreeNode.js +19 -17
  70. package/es/RefactorTree/util.js +18 -18
  71. package/es/SpecIcon/fonts/demo_index.html +559 -5
  72. package/es/SpecIcon/fonts/iconfont.css +101 -3
  73. package/es/SpecIcon/fonts/iconfont.js +34 -27
  74. package/es/SpecIcon/fonts/iconfont.json +168 -0
  75. package/es/SpecIcon/fonts/iconfont.svg +163 -171
  76. package/es/SpecIcon/fonts/iconfont.ttf +0 -0
  77. package/es/SpecIcon/fonts/iconfont.woff +0 -0
  78. package/es/SpecIcon/fonts/iconfont.woff2 +0 -0
  79. package/es/SpecIcon/style/iconfont.less +106 -11
  80. package/es/SplitterLayout/Pane.d.ts +1 -1
  81. package/es/SplitterLayout/index.js +25 -26
  82. package/es/StandardContent/SplitterLayout/Pane.js +3 -3
  83. package/es/StandardContent/SplitterLayout/index.js +25 -26
  84. package/es/StandardContent/SubfieldContent.d.ts +1 -1
  85. package/es/StandardContent/WrapperContent.d.ts +1 -1
  86. package/es/StandardDragModal/index.d.ts +11 -3
  87. package/es/StandardDragModal/index.js +25 -3
  88. package/es/StandardFilter/index.d.ts +5 -16
  89. package/es/StandardFilter/index.js +212 -200
  90. package/es/StandardFilter/indexClass.d.ts +37 -0
  91. package/es/StandardFilter/indexClass.js +217 -0
  92. package/es/StandardFilter/style/index.less +82 -9
  93. package/es/StandardForm/StepForm.d.ts +1 -1
  94. package/es/StandardForm/StepForm.js +28 -22
  95. package/es/StandardForm/TabForm.d.ts +1 -1
  96. package/es/StandardForm/TabForm.js +41 -43
  97. package/es/StandardForm/index.d.ts +1 -1
  98. package/es/StandardForm/index.js +5 -5
  99. package/es/StandardModal/UpdateFormRef.js +0 -1
  100. package/es/StandardModal/index.d.ts +2 -1
  101. package/es/StandardModal/index.js +25 -39
  102. package/es/StandardPanel/index.d.ts +1 -1
  103. package/es/StandardPanel/index.js +7 -7
  104. package/es/StandardTable/index.d.ts +1 -0
  105. package/es/StandardTable/index.js +44 -26
  106. package/es/components/IconNode/index.d.ts +1 -1
  107. package/es/components/IconNode/index.js +0 -1
  108. package/es/data/general.config.js +31 -0
  109. package/es/index.d.ts +3 -1
  110. package/es/index.js +6 -2
  111. package/es/utils/filterPermission.js +7 -10
  112. package/es/utils/getParentNodes.js +101 -26
  113. package/es/utils/index.js +2 -3
  114. package/es/utils/urlUtils.js +76 -0
  115. package/lib/ButtonGroup/ButtonList.d.ts +2 -1
  116. package/lib/ButtonGroup/ButtonList.js +2 -3
  117. package/lib/ButtonGroup/ButtonMenu.d.ts +2 -1
  118. package/lib/ButtonGroup/ButtonMenu.js +2 -3
  119. package/lib/ButtonGroup/PopConfirmTitle.js +7 -8
  120. package/lib/ButtonGroup/index.d.ts +3 -1
  121. package/lib/ButtonGroup/index.js +151 -183
  122. package/lib/ButtonGroup/style/index.less +4 -1
  123. package/lib/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
  124. package/lib/CalendarCoordPicker/CalendarMonthPicker.js +36 -0
  125. package/lib/CalendarCoordPicker/index.d.ts +8 -0
  126. package/lib/CalendarCoordPicker/index.js +305 -0
  127. package/lib/CalendarCoordPicker/index.less +31 -0
  128. package/lib/ConfigContext/index.d.ts +7 -0
  129. package/lib/ConfigContext/index.js +17 -0
  130. package/lib/DragContent/DragBar.js +2 -3
  131. package/lib/DragContent/index.d.ts +1 -1
  132. package/lib/DragContent/index.js +9 -10
  133. package/lib/FormComp/ChunkUploader/api.js +15 -15
  134. package/lib/FormComp/ChunkUploader/index.js +135 -142
  135. package/lib/FormComp/ChunkUploader/lib.js +22 -22
  136. package/lib/FormComp/ChunkUploader/upload-queue.class.js +66 -69
  137. package/lib/FormComp/ChunkUploader/worker.js +1 -1
  138. package/lib/FormComp/EditButton/index.d.ts +1 -1
  139. package/lib/FormComp/EditButton/index.js +19 -22
  140. package/lib/FormComp/FieldComponent/ReUpload.d.ts +1 -1
  141. package/lib/FormComp/FieldComponent/ReUpload.js +40 -28
  142. package/lib/FormComp/FieldComponent/RefactorTextarea.js +42 -0
  143. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +75 -23
  144. package/lib/FormComp/FieldComponent/TitleNode.d.ts +2 -1
  145. package/lib/FormComp/FieldComponent/TitleNode.js +2 -3
  146. package/lib/FormComp/FieldComponent/index.d.ts +1 -1
  147. package/lib/FormComp/FieldComponent/index.js +38 -26
  148. package/lib/FormComp/FieldComponent/setReadonlyValues.js +15 -20
  149. package/lib/FormComp/RenderItemGroup/index.js +26 -11
  150. package/lib/FormComp/Uploader/index.d.ts +3 -1
  151. package/lib/FormComp/Uploader/index.js +244 -123
  152. package/lib/FormComp/VarTemplate/index.js +63 -71
  153. package/lib/FormComp/index.js +1 -1
  154. package/lib/ImageGallery/ImagePreview.d.ts +13 -0
  155. package/lib/ImageGallery/ImagePreview.js +178 -0
  156. package/lib/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
  157. package/lib/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
  158. package/lib/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
  159. package/lib/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
  160. package/lib/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
  161. package/lib/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
  162. package/lib/ImageGallery/PreviewStyles/lg-video.css +144 -0
  163. package/lib/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
  164. package/lib/ImageGallery/PreviewStyles/lightgallery.css +728 -0
  165. package/lib/ImageGallery/SliderContent.d.ts +7 -0
  166. package/lib/ImageGallery/SliderContent.js +708 -0
  167. package/lib/ImageGallery/Thumbnail.d.ts +3 -0
  168. package/lib/ImageGallery/Thumbnail.js +306 -0
  169. package/lib/ImageGallery/hook/uniqueId.d.ts +1 -0
  170. package/lib/ImageGallery/hook/uniqueId.js +17 -0
  171. package/lib/ImageGallery/index.d.ts +4 -0
  172. package/lib/ImageGallery/index.js +36 -0
  173. package/lib/ImageGallery/style/index.less +5 -0
  174. package/lib/ImageGallery/types.d.ts +5 -0
  175. package/lib/ImageGallery/types.js +5 -0
  176. package/lib/NavLeafScroll/index.js +98 -55
  177. package/lib/RefactorTree/index.d.ts +1 -1
  178. package/lib/RefactorTree/index.js +10 -11
  179. package/lib/RefactorTree/indexTreeNode.d.ts +1 -1
  180. package/lib/RefactorTree/indexTreeNode.js +23 -22
  181. package/lib/RefactorTree/util.js +18 -18
  182. package/lib/SpecIcon/fonts/demo_index.html +559 -5
  183. package/lib/SpecIcon/fonts/iconfont.css +101 -3
  184. package/lib/SpecIcon/fonts/iconfont.js +34 -27
  185. package/lib/SpecIcon/fonts/iconfont.json +168 -0
  186. package/lib/SpecIcon/fonts/iconfont.svg +163 -171
  187. package/lib/SpecIcon/fonts/iconfont.ttf +0 -0
  188. package/lib/SpecIcon/fonts/iconfont.woff +0 -0
  189. package/lib/SpecIcon/fonts/iconfont.woff2 +0 -0
  190. package/lib/SpecIcon/index.js +2 -3
  191. package/lib/SpecIcon/style/iconfont.less +106 -11
  192. package/lib/SplitterLayout/Pane.d.ts +1 -1
  193. package/lib/SplitterLayout/Pane.js +2 -3
  194. package/lib/SplitterLayout/index.js +27 -29
  195. package/lib/StandardContent/SplitterLayout/Pane.js +5 -6
  196. package/lib/StandardContent/SplitterLayout/index.js +27 -29
  197. package/lib/StandardContent/SubfieldContent.d.ts +1 -1
  198. package/lib/StandardContent/SubfieldContent.js +2 -3
  199. package/lib/StandardContent/WrapperContent.d.ts +1 -1
  200. package/lib/StandardContent/WrapperContent.js +2 -3
  201. package/lib/StandardDragModal/index.d.ts +11 -3
  202. package/lib/StandardDragModal/index.js +27 -33
  203. package/lib/StandardFilter/index.d.ts +5 -16
  204. package/lib/StandardFilter/index.js +215 -201
  205. package/lib/StandardFilter/indexClass.d.ts +37 -0
  206. package/lib/StandardFilter/indexClass.js +223 -0
  207. package/lib/StandardFilter/style/index.less +82 -9
  208. package/lib/StandardForm/ActionList.js +2 -3
  209. package/lib/StandardForm/StepForm.d.ts +1 -1
  210. package/lib/StandardForm/StepForm.js +32 -27
  211. package/lib/StandardForm/TabForm.d.ts +1 -1
  212. package/lib/StandardForm/TabForm.js +45 -48
  213. package/lib/StandardForm/index.d.ts +1 -1
  214. package/lib/StandardForm/index.js +9 -10
  215. package/lib/StandardModal/UpdateFormRef.js +3 -4
  216. package/lib/StandardModal/index.d.ts +2 -1
  217. package/lib/StandardModal/index.js +29 -43
  218. package/lib/StandardPanel/index.d.ts +1 -1
  219. package/lib/StandardPanel/index.js +11 -12
  220. package/lib/StandardTable/index.d.ts +1 -0
  221. package/lib/StandardTable/index.js +49 -29
  222. package/lib/components/IconNode/index.d.ts +1 -1
  223. package/lib/components/IconNode/index.js +2 -4
  224. package/lib/components/index.js +1 -1
  225. package/lib/data/func.code.js +2 -3
  226. package/lib/data/general.config.js +33 -3
  227. package/lib/data/index.js +1 -1
  228. package/lib/index.d.ts +3 -1
  229. package/lib/index.js +30 -10
  230. package/lib/utils/ValueFormat.js +1 -2
  231. package/lib/utils/filterPermission.js +11 -18
  232. package/lib/utils/getParentNodes.js +103 -29
  233. package/lib/utils/index.js +5 -27
  234. package/lib/utils/urlUtils.js +82 -0
  235. package/package.json +14 -9
  236. package/dist/f26952c118ab6cdcd23dc0028ee98c11.svg +0 -173
  237. package/dist/fonts/iconfont.eot +0 -0
  238. package/es/StandardDragModal/ChangeStandardModal.d.ts +0 -44
  239. package/es/StandardDragModal/ChangeStandardModal.js +0 -493
  240. package/es/StandardDragModal/DraggableModal.d.ts +0 -7
  241. package/es/StandardDragModal/DraggableModal.js +0 -31
  242. package/es/StandardDragModal/DraggableModalContext.d.ts +0 -9
  243. package/es/StandardDragModal/DraggableModalContext.js +0 -5
  244. package/es/StandardDragModal/DraggableModalInner.d.ts +0 -16
  245. package/es/StandardDragModal/DraggableModalInner.js +0 -114
  246. package/es/StandardDragModal/DraggableModalProvider.d.ts +0 -4
  247. package/es/StandardDragModal/DraggableModalProvider.js +0 -40
  248. package/es/StandardDragModal/Modal.d.ts +0 -11
  249. package/es/StandardDragModal/Modal.js +0 -24
  250. package/es/StandardDragModal/ResizeHandle.d.ts +0 -2
  251. package/es/StandardDragModal/ResizeHandle.js +0 -8
  252. package/es/StandardDragModal/clamp.d.ts +0 -1
  253. package/es/StandardDragModal/clamp.js +0 -3
  254. package/es/StandardDragModal/draggableModalReducer.d.ts +0 -66
  255. package/es/StandardDragModal/draggableModalReducer.js +0 -157
  256. package/es/StandardDragModal/getWindowSize.d.ts +0 -4
  257. package/es/StandardDragModal/getWindowSize.js +0 -6
  258. package/es/StandardDragModal/index.less +0 -65
  259. package/es/StandardDragModal/useDrag.d.ts +0 -5
  260. package/es/StandardDragModal/useDrag.js +0 -66
  261. package/es/StandardDragModal/usePrevious.d.ts +0 -1
  262. package/es/StandardDragModal/usePrevious.js +0 -8
  263. package/es/StandardDragModal/useResize.d.ts +0 -7
  264. package/es/StandardDragModal/useResize.js +0 -74
  265. package/es/utils/dictSelectUtil.js +0 -153
  266. package/lib/StandardDragModal/ChangeStandardModal.d.ts +0 -44
  267. package/lib/StandardDragModal/ChangeStandardModal.js +0 -502
  268. package/lib/StandardDragModal/DraggableModal.d.ts +0 -7
  269. package/lib/StandardDragModal/DraggableModal.js +0 -40
  270. package/lib/StandardDragModal/DraggableModalContext.d.ts +0 -9
  271. package/lib/StandardDragModal/DraggableModalContext.js +0 -15
  272. package/lib/StandardDragModal/DraggableModalInner.d.ts +0 -16
  273. package/lib/StandardDragModal/DraggableModalInner.js +0 -124
  274. package/lib/StandardDragModal/DraggableModalProvider.d.ts +0 -4
  275. package/lib/StandardDragModal/DraggableModalProvider.js +0 -48
  276. package/lib/StandardDragModal/Modal.d.ts +0 -11
  277. package/lib/StandardDragModal/Modal.js +0 -32
  278. package/lib/StandardDragModal/ResizeHandle.d.ts +0 -2
  279. package/lib/StandardDragModal/ResizeHandle.js +0 -18
  280. package/lib/StandardDragModal/clamp.d.ts +0 -1
  281. package/lib/StandardDragModal/clamp.js +0 -10
  282. package/lib/StandardDragModal/draggableModalReducer.d.ts +0 -66
  283. package/lib/StandardDragModal/draggableModalReducer.js +0 -167
  284. package/lib/StandardDragModal/getWindowSize.d.ts +0 -4
  285. package/lib/StandardDragModal/getWindowSize.js +0 -13
  286. package/lib/StandardDragModal/index.less +0 -65
  287. package/lib/StandardDragModal/useDrag.d.ts +0 -5
  288. package/lib/StandardDragModal/useDrag.js +0 -73
  289. package/lib/StandardDragModal/usePrevious.d.ts +0 -1
  290. package/lib/StandardDragModal/usePrevious.js +0 -15
  291. package/lib/StandardDragModal/useResize.d.ts +0 -7
  292. package/lib/StandardDragModal/useResize.js +0 -81
  293. package/lib/utils/dictSelectUtil.js +0 -161
@@ -1,493 +0,0 @@
1
- import "antd/es/modal/style";
2
- import _Modal from "antd/es/modal";
3
- import "antd/es/button/style";
4
- import _Button from "antd/es/button";
5
- import "antd/es/col/style";
6
- import _Col from "antd/es/col";
7
- import "antd/es/row/style";
8
- import _Row from "antd/es/row";
9
- import "antd/es/form/style";
10
- import _Form from "antd/es/form";
11
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
17
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- import { __rest } from "tslib";
19
- import React, { useEffect, useMemo, useState } from 'react';
20
- import { general } from '../data';
21
- import RenderItemGroup from '../FormComp/RenderItemGroup';
22
- import UtilValueFormat from '../utils/ValueFormat.js';
23
- import IconNode from "../components/IconNode";
24
- import TabForm from '../StandardForm/TabForm';
25
- import StepForm from '../StandardForm/StepForm';
26
- import ActionList from '../StandardForm/ActionList.js';
27
- import './style/index.less';
28
- // import { DraggableModal, DraggableModalProvider } from '../StandardDragModal/index'
29
- import StandardDragModal from '../StandardDragModal/Modal';
30
- import '../StandardDragModal/index.less';
31
- var StandardModal = function StandardModal(props) {
32
- var children = props.children,
33
- className = props.className,
34
- style = props.style,
35
- _props$size = props.size,
36
- size = _props$size === void 0 ? 'md' : _props$size,
37
- type = props.type,
38
- formItemGroup = props.formItemGroup,
39
- title = props.title,
40
- visible = props.visible,
41
- formPrefix = props.formPrefix,
42
- formPostfix = props.formPostfix,
43
- initialValues = props.initialValues,
44
- hideRequiredMark = props.hideRequiredMark,
45
- bodyStyle = props.bodyStyle,
46
- footer = props.footer,
47
- footerButtonGroup = props.footerButtonGroup,
48
- hideFooter = props.hideFooter,
49
- _getFormFields = props.getFormFields,
50
- _props$fieldStatus = props.fieldStatus,
51
- fieldStatus = _props$fieldStatus === void 0 ? 'default' : _props$fieldStatus,
52
- _props$formLayout = props.formLayout,
53
- formLayout = _props$formLayout === void 0 ? 'horizontal' : _props$formLayout,
54
- tabsConfig = props.tabsConfig,
55
- stepsConfig = props.stepsConfig,
56
- displayLayout = props.displayLayout,
57
- _props$dragAble = props.dragAble,
58
- dragAble = _props$dragAble === void 0 ? false : _props$dragAble,
59
- otherProps = __rest(props, ["children", "className", "style", "size", "type", "formItemGroup", "title", "visible", "formPrefix", "formPostfix", "initialValues", "hideRequiredMark", "bodyStyle", "footer", "footerButtonGroup", "hideFooter", "getFormFields", "fieldStatus", "formLayout", "tabsConfig", "stepsConfig", "displayLayout", "dragAble"]);
60
- var _Form$useForm = _Form.useForm(),
61
- _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
62
- modalForm = _Form$useForm2[0];
63
- var _useState = useState(),
64
- _useState2 = _slicedToArray(_useState, 2),
65
- modalFormRef = _useState2[0],
66
- setModalFormRef = _useState2[1]; // <---- set the ref when Form Rendered
67
- var _useState3 = useState(0),
68
- _useState4 = _slicedToArray(_useState3, 2),
69
- bodyMaxHeight = _useState4[0],
70
- setBodyMaxHeight = _useState4[1]; // setTabFormChild
71
- var _useState5 = useState(),
72
- _useState6 = _slicedToArray(_useState5, 2),
73
- formChild = _useState6[0],
74
- setFormChild = _useState6[1]; // <---- set the ref when Form Rendered
75
- // 按钮栏是否有显示(默认显示)
76
- var hasFooterBar = useMemo(function () {
77
- var _a, _b, _c, _d, _e;
78
- var openLog = false;
79
- if (type === 'tabForm' || type === 'stepForm') {
80
- if (type === 'tabForm') {
81
- var activeTabInfo = formItemGroup.find(function (fItem) {
82
- return fItem.key === (tabsConfig === null || tabsConfig === void 0 ? void 0 : tabsConfig.activeKey);
83
- });
84
- openLog && console.log('rule 0-1', ((_a = activeTabInfo === null || activeTabInfo === void 0 ? void 0 : activeTabInfo.actions) === null || _a === void 0 ? void 0 : _a.length) > 0);
85
- return ((_b = activeTabInfo === null || activeTabInfo === void 0 ? void 0 : activeTabInfo.actions) === null || _b === void 0 ? void 0 : _b.length) > 0;
86
- }
87
- if (type === 'stepForm') {
88
- var currentStepInfo = formItemGroup[stepsConfig.current];
89
- openLog && console.log('rule 0-2', ((_c = currentStepInfo === null || currentStepInfo === void 0 ? void 0 : currentStepInfo.actions) === null || _c === void 0 ? void 0 : _c.length) > 0);
90
- return ((_d = currentStepInfo === null || currentStepInfo === void 0 ? void 0 : currentStepInfo.actions) === null || _d === void 0 ? void 0 : _d.length) > 0;
91
- }
92
- return true;
93
- } else {
94
- if (hideFooter) {
95
- openLog && console.log('rule 1');
96
- return false;
97
- }
98
- if (fieldStatus && fieldStatus !== 'default') {
99
- if (props.hasOwnProperty('footerButtonGroup')) {
100
- // 如果有配置按钮组件,则还是要显示按钮
101
- return true;
102
- }
103
- openLog && console.log('rule 2');
104
- // disabled/viewOnly都不显示按钮
105
- return false;
106
- }
107
- if (props.hasOwnProperty('footerButtonGroup') && footerButtonGroup) {
108
- if (Array.isArray(footerButtonGroup) && footerButtonGroup.length === 0) {
109
- openLog && console.log('rule 4');
110
- // 返回为空数组不占用按钮栏
111
- return false;
112
- } else if (typeof footerButtonGroup === 'function' && (!footerButtonGroup() || ((_e = footerButtonGroup()) === null || _e === void 0 ? void 0 : _e.length) === 0)) {
113
- openLog && console.log('rule 5');
114
- // 配置类型为Function且返回值为null或者返回数组长度为0时,不显示按钮栏
115
- return false;
116
- }
117
- openLog && console.log('rule 3');
118
- return true;
119
- } else if (footerButtonGroup === false) {
120
- openLog && console.log('rule 7');
121
- // 显示
122
- return true;
123
- }
124
- if (props.hasOwnProperty('footer') && !footer) {
125
- openLog && console.log('rule 8');
126
- return false;
127
- }
128
- openLog && console.log('rule 9');
129
- return true;
130
- }
131
- }, [fieldStatus, hideFooter, footer, footerButtonGroup, type, tabsConfig, stepsConfig, formItemGroup]);
132
- // 设置限制弹窗高度
133
- var initBodyMaxHeight = function initBodyMaxHeight() {
134
- var title = props.title;
135
- var bodyHeight = document.body.offsetHeight;
136
- var baseReduce = 80 + 32; // 默认需要减去的高度(上下空白间距150及内部内容间距16*2
137
- // console.log('弹窗是否有按钮:', hasFooterBar ? '是' : '否')
138
- setBodyMaxHeight("".concat(bodyHeight - (title ? 55 : 0) - (hasFooterBar ? 55 : 0) - baseReduce, "px"));
139
- // setBodyMaxHeight(`${bodyHeight - (title ? 55 : 0) - ((footer || footerButtonGroup) ? 55 : 0) - baseReduce +
140
- // ((fieldStatus && fieldStatus !== 'default' && !footerButtonGroup) || hideFooter ? 55 : 0)}px`)
141
- };
142
- // fill Form when modal open 此处可解决获取 Form.useForm warning
143
- useEffect(function () {
144
- if (visible && modalFormRef) {
145
- // <---- check ref before use the form instance
146
- if (initialValues && _typeof(initialValues) === 'object') {
147
- initialValues && modalForm.setFieldsValue(Object.assign({}, initialValues));
148
- forceUpdateForm();
149
- }
150
- }
151
- // if (!visible && modalFormRef) {
152
- // clearAllFieldsValue() // 清空表单传参数
153
- // }
154
- }, [modalFormRef, visible]);
155
- useEffect(function () {
156
- if (visible) {
157
- initBodyMaxHeight();
158
- // 让resize事件触发 initBodyMaxHeight
159
- window.addEventListener('resize', initBodyMaxHeight);
160
- } else {
161
- window.removeEventListener('resize', initBodyMaxHeight);
162
- }
163
- }, [fieldStatus, title, visible, hideFooter, footer, footerButtonGroup]);
164
- var handleSubmit = function handleSubmit() {
165
- var type = props.type,
166
- formItemGroup = props.formItemGroup,
167
- onSubmit = props.onSubmit;
168
- if (type === 'form' || type === 'gridForm') {
169
- modalForm.validateFields().then(function (values) {
170
- if (Object.prototype.hasOwnProperty.call(values, 'false')) {
171
- delete values.false; // 自定义结构会莫名的出来一个false字段
172
- }
173
-
174
- var resultValues = UtilValueFormat(values, formItemGroup);
175
- if (onSubmit) {
176
- onSubmit(Object.assign({}, resultValues));
177
- }
178
- }).catch(function () {
179
- // 定位到第一条表单异常的
180
- var errorCollection = Array.prototype.slice.call(document.getElementsByClassName('ant-form-item-has-error'));
181
- if (errorCollection[0] && errorCollection[0].getElementsByTagName('input')) {
182
- Array.prototype.slice.call(errorCollection[0].getElementsByTagName('input'))[0].focus();
183
- }
184
- // console.error('表单填写有误', errorInfo, '第一条数据',errorInfo.errorFields[0].name[0])
185
- });
186
- } else if (type === 'stepForm' || type === 'tabForm') {
187
- // onSubmit && onSubmit()
188
- formChild.validateFields().then(function (values) {
189
- // console.log(values)
190
- if (Object.prototype.hasOwnProperty.call(values, 'false')) {
191
- delete values.false; // 自定义结构会莫名的出来一个false字段
192
- }
193
-
194
- var resultValues = UtilValueFormat(values, formItemGroup);
195
- if (onSubmit) {
196
- onSubmit(Object.assign({}, resultValues));
197
- }
198
- }).catch(function () {
199
- // 定位到第一条表单异常的
200
- var errorCollection = Array.prototype.slice.call(document.getElementsByClassName('ant-form-item-has-error'));
201
- if (errorCollection[0] && errorCollection[0].getElementsByTagName('input')) {
202
- Array.prototype.slice.call(errorCollection[0].getElementsByTagName('input'))[0].focus();
203
- }
204
- // console.error('表单填写有误', errorInfo, '第一条数据',errorInfo.errorFields[0].name[0])
205
- });
206
- } else {
207
- // 没有表单数组 formItemGroup 配置
208
- onSubmit && onSubmit();
209
- }
210
- };
211
- // 重置所有表单
212
- var clearAllFieldsValue = function clearAllFieldsValue() {
213
- // let allFields = {}
214
- // Object.keys(modalForm.getFieldsValue()).map((item) => allFields[item] = undefined)
215
- // modalForm.setFieldsValue(allFields) // 直接清空表单的赋值(initialValues传值如果没有前后赋值没有全部带上所有字段,则会默认又使用之前的部分未传参字段)
216
- modalForm.resetFields(); // 直接使用这个无效
217
- };
218
-
219
- var onAfterClose = function onAfterClose() {
220
- var afterClose = props.afterClose;
221
- if (type === 'form') clearAllFieldsValue();
222
- if (afterClose) afterClose();
223
- };
224
- var handleCancel = function handleCancel() {
225
- var onCancel = props.onCancel;
226
- if (onCancel) onCancel();
227
- };
228
- // 强制更新表单值,用于赋初始化实例值
229
- var forceUpdateForm = function forceUpdateForm() {
230
- _getFormFields && _getFormFields(modalForm.getFieldsValue() || {}, modalForm);
231
- };
232
- var renderFormItemGroup = function renderFormItemGroup() {
233
- var fieldStatus = props.fieldStatus,
234
- formItemGroup = props.formItemGroup,
235
- _props$size2 = props.size,
236
- size = _props$size2 === void 0 ? 'md' : _props$size2,
237
- type = props.type;
238
- if (Array.isArray(formItemGroup)) {
239
- if (type === 'gridForm') {
240
- // 栅格组
241
- return /*#__PURE__*/React.createElement(_Row, {
242
- gutter: 20
243
- }, formItemGroup.map(function (item, index) {
244
- var childrenFields = item.fields || [];
245
- if (item.label) {
246
- childrenFields = [{
247
- type: item.type,
248
- label: item.label,
249
- protoConfig: Object.assign({}, item.protoConfig)
250
- }].concat(childrenFields);
251
- }
252
- return /*#__PURE__*/React.createElement(_Col, {
253
- key: index,
254
- span: item.gridSpan || 24
255
- }, /*#__PURE__*/React.createElement(RenderItemGroup, {
256
- size: size,
257
- layout: formLayout,
258
- doUpdateFormFields: function doUpdateFormFields() {
259
- return forceUpdateForm();
260
- },
261
- displayLayout: item.displayLayout || displayLayout,
262
- itemGroup: childrenFields,
263
- fieldStatus: fieldStatus,
264
- form: modalForm
265
- }));
266
- }));
267
- }
268
- return /*#__PURE__*/React.createElement(RenderItemGroup, {
269
- size: size,
270
- layout: formLayout,
271
- doUpdateFormFields: function doUpdateFormFields() {
272
- return forceUpdateForm();
273
- },
274
- displayLayout: displayLayout,
275
- itemGroup: formItemGroup,
276
- fieldStatus: fieldStatus,
277
- form: modalForm
278
- });
279
- }
280
- return formItemGroup;
281
- };
282
- var handleStepType = function handleStepType(type, extraFunc) {
283
- var current = stepsConfig.current;
284
- switch (type) {
285
- case 'submit':
286
- case 'next':
287
- // 获取当前步骤的表单配置下有 rules 的控件进行校验(自定义的控件则自己有业务层面处理添加校验)
288
- // console.log('执行下一步骤,需要优先进行校验')
289
- var currentFields = formItemGroup[current].fields;
290
- var validatorGroup = currentFields && Array.isArray(currentFields) ? currentFields.map(function (fItem) {
291
- return fItem.rules ? fItem.filedName : null;
292
- }) : [];
293
- formChild.validateFields(validatorGroup).then(function () {
294
- // if (stepClick) stepClick(type, formChild, values);
295
- extraFunc();
296
- }).catch(function () {
297
- // console.log('表单校验不通过 ', errorFields.map(err => err))
298
- });
299
- break;
300
- case 'prev':
301
- // if (stepClick) stepClick(type, formChild);
302
- extraFunc();
303
- break;
304
- case 'cancel':
305
- // if (stepClick) stepClick(type, formChild);
306
- extraFunc();
307
- break;
308
- default:
309
- // extraFunc()
310
- break;
311
- }
312
- };
313
- var renderButtonGroup = function renderButtonGroup() {
314
- var footerButtonGroup = props.footerButtonGroup,
315
- confirmLoading = props.confirmLoading,
316
- cancelText = props.cancelText,
317
- confirmText = props.confirmText,
318
- okText = props.okText,
319
- okButtonProps = props.okButtonProps,
320
- confirmButtonProps = props.confirmButtonProps,
321
- cancelButtonProps = props.cancelButtonProps;
322
- if (footerButtonGroup) {
323
- if (Array.isArray(footerButtonGroup)) {
324
- if (footerButtonGroup.length === 0) return null; // <div>按钮组合配置为空</div>
325
- return /*#__PURE__*/React.createElement(React.Fragment, null, footerButtonGroup.map(function (item) {
326
- if (_typeof(item) === 'object') {
327
- if (item.isHide) return null;
328
- var name = item.name,
329
- _type = item.type,
330
- icon = item.icon,
331
- ghost = item.ghost,
332
- disabled = item.disabled,
333
- loading = item.loading,
334
- fn = item.fn,
335
- others = __rest(item, ["name", "type", "icon", "ghost", "disabled", "loading", "fn"]);
336
- return /*#__PURE__*/React.createElement(_Button, Object.assign({
337
- key: name,
338
- type: _type || 'primary',
339
- icon: /*#__PURE__*/React.createElement(IconNode, {
340
- icon: icon
341
- }),
342
- ghost: ghost,
343
- disabled: disabled,
344
- loading: loading,
345
- onClick: fn ? function (e) {
346
- return fn(item, modalForm, props, e);
347
- } : null
348
- }, others), name);
349
- } else {
350
- return item; // 如果是DOM,则直接渲染
351
- }
352
- }));
353
- }
354
-
355
- if (typeof footerButtonGroup === 'function') {
356
- return footerButtonGroup(modalForm, props);
357
- }
358
- return footerButtonGroup;
359
- }
360
- if (footer) return footer;
361
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Button, Object.assign({
362
- key: "submit",
363
- type: 'primary',
364
- loading: confirmLoading,
365
- onClick: handleSubmit
366
- }, confirmButtonProps, okButtonProps), confirmText || okText || '确定'), /*#__PURE__*/React.createElement(_Button, Object.assign({
367
- key: "back",
368
- onClick: handleCancel
369
- }, cancelButtonProps), cancelText || '取消'));
370
- };
371
- var renderFooter = function renderFooter() {
372
- var _a, _b;
373
- if (type === 'stepForm') {
374
- var currentStepInfo = formItemGroup[stepsConfig.current];
375
- return ((_a = currentStepInfo === null || currentStepInfo === void 0 ? void 0 : currentStepInfo.actions) === null || _a === void 0 ? void 0 : _a.length) > 0 ? /*#__PURE__*/React.createElement(ActionList, {
376
- list: currentStepInfo.actions || [],
377
- onStep: handleStepType,
378
- form: formChild,
379
- other: props
380
- }) : null;
381
- }
382
- if (type === 'tabForm') {
383
- var activeTabInfo = formItemGroup.find(function (fItem) {
384
- return fItem.key === (tabsConfig === null || tabsConfig === void 0 ? void 0 : tabsConfig.activeKey);
385
- });
386
- return ((_b = activeTabInfo === null || activeTabInfo === void 0 ? void 0 : activeTabInfo.actions) === null || _b === void 0 ? void 0 : _b.length) > 0 ? /*#__PURE__*/React.createElement(ActionList, {
387
- list: activeTabInfo.actions || [],
388
- form: formChild,
389
- other: props
390
- }) : null;
391
- }
392
- return hasFooterBar ? renderButtonGroup() : null;
393
- };
394
- // 内容渲染
395
- var renderChildrenNodes = function renderChildrenNodes() {
396
- return /*#__PURE__*/React.createElement(React.Fragment, null, children, (type === 'form' || type === 'gridForm') && /*#__PURE__*/React.createElement(_Form, {
397
- layout: formLayout,
398
- ref: setModalFormRef,
399
- form: modalForm,
400
- onFinish: handleSubmit,
401
- hideRequiredMark: fieldStatus === 'viewOnly' || hideRequiredMark,
402
- // initialValues={{ ...initialValues }}
403
- scrollToFirstError: true,
404
- className: "modalForm"
405
- }, formPrefix && /*#__PURE__*/React.createElement(_Row, null, formPrefix(modalForm, props, forceUpdateForm)), formItemGroup ? renderFormItemGroup() : null, formPostfix && /*#__PURE__*/React.createElement(_Row, null, formPostfix(modalForm, props, forceUpdateForm), " ")), type === 'tabForm' && /*#__PURE__*/React.createElement(TabForm, {
406
- grid: size,
407
- layout: formLayout,
408
- fieldStatus: fieldStatus,
409
- actionHide: true,
410
- // @ts-ignore
411
- getFormFields: function getFormFields(fields, form) {
412
- setFormChild(form);
413
- _getFormFields && _getFormFields(fields, form);
414
- },
415
- formItemGroup: formItemGroup,
416
- tabsConfig: tabsConfig,
417
- onSubmit: handleSubmit,
418
- initialValues: Object.assign({}, initialValues),
419
- displayLayout: displayLayout
420
- }), type === 'stepForm' && /*#__PURE__*/React.createElement(StepForm, {
421
- grid: size,
422
- layout: formLayout,
423
- fieldStatus: fieldStatus,
424
- actionHide: true,
425
- // @ts-ignore
426
- getFormFields: function getFormFields(fields, form) {
427
- setFormChild(form);
428
- _getFormFields && _getFormFields(fields, form);
429
- },
430
- formItemGroup: formItemGroup,
431
- stepsConfig: stepsConfig,
432
- onSubmit: handleSubmit,
433
- initialValues: Object.assign({}, initialValues),
434
- displayLayout: displayLayout
435
- }));
436
- };
437
- // 可拖动及缩放
438
- if (dragAble) {
439
- return /*#__PURE__*/React.createElement(StandardDragModal, Object.assign({
440
- destroyOnClose: true,
441
- initialWidth: otherProps.width || general.modalSize[size].width,
442
- initialHeight: otherProps.height,
443
- zIndex: 1001
444
- }, otherProps, {
445
- visible: visible,
446
- className: "standardModal ".concat(className || '', " ").concat(fieldStatus === 'viewOnly' ? 'is-view' : ''),
447
- onCancel: handleCancel,
448
- afterClose: onAfterClose,
449
- onOk: handleSubmit,
450
- title: title,
451
- footer: renderFooter()
452
- }), renderChildrenNodes());
453
- /* return <DraggableModalProvider>
454
- <DraggableModal destroyOnClose
455
- initialWidth={otherProps.width || general.modalSize[size].width}
456
- initialHeight={otherProps.height}
457
- zIndex={1001}
458
- {...otherProps}
459
- visible={visible}
460
- className={`standardModal ${className || ''} ${fieldStatus === 'viewOnly' ? 'is-view' : ''}`}
461
- onCancel={handleCancel}
462
- afterClose={onAfterClose}
463
- onOk={handleSubmit}
464
- title={title}
465
- footer={renderFooter()}
466
- >
467
- {renderChildrenNodes()}
468
- </DraggableModal>
469
- </DraggableModalProvider>*/
470
- }
471
-
472
- return /*#__PURE__*/React.createElement(_Modal, Object.assign({
473
- destroyOnClose: true,
474
- maskClosable: false,
475
- width: general.modalSize[size].width
476
- }, otherProps, {
477
- open: visible,
478
- title: title,
479
- footer: renderFooter(),
480
- className: "standardModal ".concat(className || '', " ").concat(fieldStatus === 'viewOnly' ? 'is-view' : ''),
481
- style: Object.assign({
482
- top: '80px'
483
- }, style),
484
- bodyStyle: Object.assign({
485
- maxHeight: bodyMaxHeight,
486
- overflowY: 'scroll'
487
- }, bodyStyle),
488
- onCancel: handleCancel,
489
- afterClose: onAfterClose,
490
- onOk: handleSubmit
491
- }), renderChildrenNodes());
492
- };
493
- export default StandardModal;
@@ -1,7 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { ModalProps } from 'antd/lib/modal';
3
- export interface DraggableModalProps extends ModalProps {
4
- initialWidth?: number;
5
- initialHeight?: number;
6
- }
7
- export declare const DraggableModal: FunctionComponent<DraggableModalProps>;
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- import { useContext } from 'react';
3
- import { useUID } from 'react-uid';
4
- import { DraggableModalContext } from './DraggableModalContext';
5
- import { DraggableModalInner } from './DraggableModalInner';
6
- import { getModalState } from './draggableModalReducer';
7
- export var DraggableModal = function DraggableModal(props) {
8
- // Get the unique ID of this modal.
9
- var id = useUID();
10
- // Get modal provider.
11
- var modalProvider = useContext(DraggableModalContext);
12
- if (!modalProvider) {
13
- throw new Error('No Provider');
14
- }
15
- var dispatch = modalProvider.dispatch,
16
- state = modalProvider.state;
17
- var modalState = getModalState({
18
- state: state,
19
- id: id,
20
- initialHeight: props.initialHeight,
21
- initialWidth: props.initialWidth
22
- });
23
- // We do this so that we don't re-render all modals for every state change.
24
- // DraggableModalInner uses React.memo, so it only re-renders if
25
- // if props change (e.g. modalState).
26
- return /*#__PURE__*/React.createElement(DraggableModalInner, Object.assign({
27
- id: id,
28
- dispatch: dispatch,
29
- modalState: modalState
30
- }, props));
31
- };
@@ -1,9 +0,0 @@
1
- import * as React from 'react';
2
- import { Action, ModalsState } from './draggableModalReducer';
3
- export interface DraggableModalContextMethods {
4
- dispatch: (action: Action) => void;
5
- }
6
- export interface DraggableModalContextValue extends DraggableModalContextMethods {
7
- state: ModalsState;
8
- }
9
- export declare const DraggableModalContext: React.Context<DraggableModalContextValue>;
@@ -1,5 +0,0 @@
1
- import * as React from 'react';
2
- export var DraggableModalContext = /*#__PURE__*/React.createContext(null);
3
- if (process.env.NODE_ENV !== 'production') {
4
- DraggableModalContext.displayName = 'DraggableModalContext';
5
- }
@@ -1,16 +0,0 @@
1
- import * as React from 'react';
2
- import { ModalProps } from 'antd/lib/modal';
3
- import { DraggableModalContextMethods } from './DraggableModalContext';
4
- import { ModalID, ModalState } from './draggableModalReducer';
5
- interface ContextProps extends DraggableModalContextMethods {
6
- id: ModalID;
7
- modalState: ModalState;
8
- initialWidth?: number;
9
- initialHeight?: number;
10
- }
11
- export declare type DraggableModalInnerProps = ModalProps & {
12
- children?: React.ReactNode;
13
- } & ContextProps;
14
- declare function DraggableModalInnerNonMemo({ id, modalState, dispatch, visible, children, title, initialWidth, initialHeight, ...otherProps }: DraggableModalInnerProps): JSX.Element;
15
- export declare const DraggableModalInner: React.MemoExoticComponent<typeof DraggableModalInnerNonMemo>;
16
- export {};
@@ -1,114 +0,0 @@
1
- import "antd/es/modal/style";
2
- import _Modal from "antd/es/modal";
3
- import { __rest } from "tslib";
4
- import * as React from 'react';
5
- import { useEffect, useMemo, useCallback, memo } from 'react';
6
- import { ResizeHandle } from './ResizeHandle';
7
- import { useDrag } from './useDrag';
8
- import { usePrevious } from './usePrevious';
9
- import { useResize } from './useResize';
10
- var modalStyle = {
11
- margin: 0,
12
- paddingBottom: 0,
13
- pointerEvents: 'auto'
14
- };
15
- function DraggableModalInnerNonMemo(_a) {
16
- var id = _a.id,
17
- modalState = _a.modalState,
18
- dispatch = _a.dispatch,
19
- visible = _a.visible,
20
- children = _a.children,
21
- title = _a.title,
22
- initialWidth = _a.initialWidth,
23
- initialHeight = _a.initialHeight,
24
- otherProps = __rest(_a, ["id", "modalState", "dispatch", "visible", "children", "title", "initialWidth", "initialHeight"]); // Call on mount and unmount.
25
- useEffect(function () {
26
- dispatch({
27
- type: 'mount',
28
- id: id,
29
- intialState: {
30
- initialWidth: initialWidth,
31
- initialHeight: initialHeight
32
- }
33
- });
34
- return function () {
35
- return dispatch({
36
- type: 'unmount',
37
- id: id
38
- });
39
- };
40
- }, [dispatch, id, initialWidth, initialHeight]);
41
- // Bring this to the front if it's been opened with props.
42
- var visiblePrevious = usePrevious(visible);
43
- useEffect(function () {
44
- if (visible !== visiblePrevious) {
45
- if (visible) {
46
- dispatch({
47
- type: 'show',
48
- id: id
49
- });
50
- } else {
51
- dispatch({
52
- type: 'hide',
53
- id: id
54
- });
55
- }
56
- }
57
- }, [visible, visiblePrevious, id, dispatch]);
58
- var zIndex = modalState.zIndex,
59
- x = modalState.x,
60
- y = modalState.y,
61
- width = modalState.width,
62
- height = modalState.height;
63
- var style = useMemo(function () {
64
- return Object.assign(Object.assign({}, modalStyle), {
65
- top: y,
66
- left: x,
67
- height: height
68
- });
69
- }, [y, x, height]);
70
- var onFocus = useCallback(function () {
71
- return dispatch({
72
- type: 'focus',
73
- id: id
74
- });
75
- }, [id, dispatch]);
76
- var onDragWithID = useCallback(function (args) {
77
- return dispatch(Object.assign({
78
- type: 'drag',
79
- id: id
80
- }, args));
81
- }, [dispatch, id]);
82
- var onResizeWithID = useCallback(function (args) {
83
- return dispatch(Object.assign({
84
- type: 'resize',
85
- id: id
86
- }, args));
87
- }, [dispatch, id]);
88
- var onMouseDrag = useDrag(x, y, onDragWithID);
89
- var onMouseResize = useResize(x, y, width, height, onResizeWithID);
90
- var titleElement = useMemo(function () {
91
- return /*#__PURE__*/React.createElement("div", {
92
- className: "ant-design-draggable-modal-title",
93
- onMouseDown: onMouseDrag,
94
- onClick: onFocus
95
- }, title);
96
- }, [onMouseDrag, onFocus, title]);
97
- return /*#__PURE__*/React.createElement(_Modal, Object.assign({
98
- wrapClassName: "ant-design-draggable-modal",
99
- style: style,
100
- width: width,
101
- destroyOnClose: true,
102
- mask: false,
103
- maskClosable: false,
104
- zIndex: zIndex,
105
- title: titleElement,
106
- open: visible
107
- }, otherProps), children, /*#__PURE__*/React.createElement(ResizeHandle, {
108
- onMouseDown: onMouseResize
109
- }));
110
- }
111
- export var DraggableModalInner = /*#__PURE__*/memo(DraggableModalInnerNonMemo);
112
- if (process.env.NODE_ENV !== 'production') {
113
- DraggableModalInner.displayName = 'DraggableModalInner';
114
- }