vue-devui 1.0.0-beta.18 → 1.0.0-beta.220801

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 (403) hide show
  1. package/README.md +94 -118
  2. package/alert/index.es.js +74 -45
  3. package/alert/index.umd.js +1 -1
  4. package/alert/style.css +1 -1
  5. package/auto-complete/index.es.js +8349 -426
  6. package/auto-complete/index.umd.js +29 -1
  7. package/auto-complete/style.css +1 -1
  8. package/avatar/index.es.js +153 -146
  9. package/avatar/index.umd.js +1 -1
  10. package/avatar/style.css +1 -1
  11. package/badge/index.es.js +45 -20
  12. package/badge/index.umd.js +1 -1
  13. package/badge/style.css +1 -1
  14. package/button/index.es.js +5743 -127
  15. package/button/index.umd.js +27 -1
  16. package/button/style.css +1 -1
  17. package/card/index.es.js +63 -35
  18. package/card/index.umd.js +1 -1
  19. package/card/style.css +1 -1
  20. package/checkbox/index.es.js +8070 -255
  21. package/checkbox/index.umd.js +27 -1
  22. package/checkbox/style.css +1 -1
  23. package/{accordion → collapse}/index.d.ts +0 -0
  24. package/collapse/index.es.js +213 -0
  25. package/collapse/index.umd.js +1 -0
  26. package/{back-top → collapse}/package.json +1 -1
  27. package/collapse/style.css +1 -0
  28. package/countdown/index.es.js +60 -19
  29. package/countdown/index.umd.js +1 -1
  30. package/{anchor → date-picker-pro}/index.d.ts +0 -0
  31. package/date-picker-pro/index.es.js +12018 -0
  32. package/date-picker-pro/index.umd.js +27 -0
  33. package/date-picker-pro/package.json +7 -0
  34. package/date-picker-pro/style.css +1 -0
  35. package/drawer/index.es.js +184 -5736
  36. package/drawer/index.umd.js +1 -27
  37. package/drawer/style.css +1 -1
  38. package/dropdown/index.es.js +615 -396
  39. package/dropdown/index.umd.js +1 -1
  40. package/dropdown/style.css +1 -1
  41. package/editable-select/index.es.js +786 -195
  42. package/editable-select/index.umd.js +1 -1
  43. package/editable-select/style.css +1 -1
  44. package/form/index.es.js +2360 -2094
  45. package/form/index.umd.js +17 -17
  46. package/form/style.css +1 -1
  47. package/fullscreen/index.es.js +137 -134
  48. package/fullscreen/index.umd.js +1 -1
  49. package/fullscreen/style.css +1 -1
  50. package/grid/index.es.js +101 -86
  51. package/grid/index.umd.js +1 -1
  52. package/grid/style.css +1 -1
  53. package/icon/index.es.js +199 -56
  54. package/icon/index.umd.js +1 -1
  55. package/icon/style.css +1 -0
  56. package/image-preview/index.es.js +55 -31
  57. package/image-preview/index.umd.js +1 -1
  58. package/image-preview/style.css +1 -1
  59. package/input/index.es.js +8254 -144
  60. package/input/index.umd.js +27 -1
  61. package/input/style.css +1 -1
  62. package/input-number/index.es.js +270 -187
  63. package/input-number/index.umd.js +1 -1
  64. package/input-number/style.css +1 -1
  65. package/layout/index.es.js +40 -25
  66. package/layout/index.umd.js +1 -1
  67. package/layout/style.css +1 -1
  68. package/loading/index.es.js +74 -35
  69. package/loading/index.umd.js +1 -1
  70. package/loading/style.css +1 -1
  71. package/{back-top → mention}/index.d.ts +0 -0
  72. package/{color-picker → mention}/index.es.js +2983 -2861
  73. package/mention/index.umd.js +36 -0
  74. package/{anchor → mention}/package.json +1 -1
  75. package/mention/style.css +1 -0
  76. package/{breadcrumb → menu}/index.d.ts +0 -0
  77. package/menu/index.es.js +870 -0
  78. package/menu/index.umd.js +1 -0
  79. package/{toast → menu}/package.json +1 -1
  80. package/menu/style.css +1 -0
  81. package/{carousel → message}/index.d.ts +0 -0
  82. package/message/index.es.js +538 -0
  83. package/message/index.umd.js +1 -0
  84. package/{comment → message}/package.json +1 -1
  85. package/message/style.css +1 -0
  86. package/modal/index.es.js +598 -1025
  87. package/modal/index.umd.js +1 -1
  88. package/modal/style.css +1 -1
  89. package/{cascader → notification}/index.d.ts +0 -0
  90. package/notification/index.es.js +545 -0
  91. package/notification/index.umd.js +1 -0
  92. package/{accordion → notification}/package.json +1 -1
  93. package/notification/style.css +1 -0
  94. package/nuxt/components/ButtonGroup.js +3 -0
  95. package/nuxt/components/CheckboxButton.js +3 -0
  96. package/nuxt/components/CheckboxGroup.js +3 -0
  97. package/nuxt/components/Collapse.js +3 -0
  98. package/nuxt/components/CollapseItem.js +3 -0
  99. package/nuxt/components/DRangeDatePickerPro.js +3 -0
  100. package/nuxt/components/DatePickerPro.js +3 -0
  101. package/nuxt/components/DropdownMenu.js +3 -0
  102. package/nuxt/components/DropdownPropsKey.js +3 -0
  103. package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
  104. package/nuxt/components/FORM_TOKEN.js +3 -0
  105. package/nuxt/components/IFileOptions.js +3 -0
  106. package/nuxt/components/IUploadOptions.js +3 -0
  107. package/nuxt/components/Icon.js +1 -0
  108. package/nuxt/components/IconGroup.js +3 -0
  109. package/nuxt/components/LABEL_DATA.js +3 -0
  110. package/nuxt/components/LoadingOptions.js +3 -0
  111. package/nuxt/components/Mention.js +3 -0
  112. package/nuxt/components/Menu.js +3 -0
  113. package/nuxt/components/MenuItem.js +3 -0
  114. package/nuxt/components/Message.js +3 -0
  115. package/nuxt/components/Notification.js +3 -0
  116. package/nuxt/components/NotificationService.js +3 -0
  117. package/nuxt/components/Option.js +3 -0
  118. package/nuxt/components/OptionGroup.js +3 -0
  119. package/nuxt/components/PanelBody.js +3 -0
  120. package/nuxt/components/PanelFooter.js +3 -0
  121. package/nuxt/components/PanelHeader.js +3 -0
  122. package/nuxt/components/RadioButton.js +3 -0
  123. package/nuxt/components/Step.js +3 -0
  124. package/nuxt/components/Steps.js +3 -0
  125. package/nuxt/components/SubMenu.js +3 -0
  126. package/nuxt/components/TABLE_TOKEN.js +3 -0
  127. package/nuxt/components/Tab.js +3 -0
  128. package/nuxt/components/TimeSelect.js +3 -0
  129. package/nuxt/components/Timeline.js +3 -0
  130. package/nuxt/components/TimelineItem.js +3 -0
  131. package/nuxt/components/UploadStatus.js +3 -0
  132. package/nuxt/components/alertProps.js +3 -0
  133. package/nuxt/components/animationInjectionKey.js +3 -0
  134. package/nuxt/components/autoCompleteProps.js +3 -0
  135. package/nuxt/components/avatarProps.js +3 -0
  136. package/nuxt/components/badgeProps.js +3 -0
  137. package/nuxt/components/buttonGroupInjectionKey.js +3 -0
  138. package/nuxt/components/buttonGroupProps.js +3 -0
  139. package/nuxt/components/cardProps.js +3 -0
  140. package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
  141. package/nuxt/components/checkboxGroupProps.js +3 -0
  142. package/nuxt/components/checkboxProps.js +3 -0
  143. package/nuxt/components/colProps.js +3 -0
  144. package/nuxt/components/colPropsBaseClass.js +3 -0
  145. package/nuxt/components/colPropsBaseStyle.js +3 -0
  146. package/nuxt/components/collapseItemProps.js +3 -0
  147. package/nuxt/components/collapseProps.js +3 -0
  148. package/nuxt/components/countdownProps.js +3 -0
  149. package/nuxt/components/datePickerProCommonProps.js +3 -0
  150. package/nuxt/components/datePickerProPanelProps.js +3 -0
  151. package/nuxt/components/datePickerProProps.js +3 -0
  152. package/nuxt/components/dropdownMenuProps.js +3 -0
  153. package/nuxt/components/editableSelectProps.js +3 -0
  154. package/nuxt/components/fixedOverlayProps.js +3 -0
  155. package/nuxt/components/flexibleOverlayProps.js +3 -0
  156. package/nuxt/components/formItemProps.js +3 -0
  157. package/nuxt/components/formProps.js +3 -0
  158. package/nuxt/components/fullscreenProps.js +3 -0
  159. package/nuxt/components/iconProps.js +3 -0
  160. package/nuxt/components/imagePreviewProps.js +3 -0
  161. package/nuxt/components/inputProps.js +3 -0
  162. package/nuxt/components/loadingProps.js +3 -0
  163. package/nuxt/components/mentionProps.js +3 -0
  164. package/nuxt/components/messageProps.js +3 -0
  165. package/nuxt/components/modalProps.js +3 -0
  166. package/nuxt/components/notificationProps.js +3 -0
  167. package/nuxt/components/paginationProps.js +3 -0
  168. package/nuxt/components/panelProps.js +3 -0
  169. package/nuxt/components/popoverProps.js +3 -0
  170. package/nuxt/components/progressProps.js +3 -0
  171. package/nuxt/components/rateProps.js +3 -0
  172. package/nuxt/components/resultProps.js +3 -0
  173. package/nuxt/components/roundInjectionKey.js +3 -0
  174. package/nuxt/components/rowProps.js +3 -0
  175. package/nuxt/components/screenSizes.js +3 -0
  176. package/nuxt/components/searchProps.js +3 -0
  177. package/nuxt/components/skeletonItemProps.js +3 -0
  178. package/nuxt/components/skeletonProps.js +3 -0
  179. package/nuxt/components/sliderProps.js +3 -0
  180. package/nuxt/components/splitterProps.js +3 -0
  181. package/nuxt/components/statisticProps.js +3 -0
  182. package/nuxt/components/stepProps.js +3 -0
  183. package/nuxt/components/stepsProps.js +3 -0
  184. package/nuxt/components/svgIconProps.js +3 -0
  185. package/nuxt/components/switchProps.js +3 -0
  186. package/nuxt/components/tableProps.js +3 -0
  187. package/nuxt/components/tabsProps.js +3 -0
  188. package/nuxt/components/tagProps.js +3 -0
  189. package/nuxt/components/textareaProps.js +3 -0
  190. package/nuxt/components/timeAxisProps.js +3 -0
  191. package/nuxt/components/timerPickerPanelProps.js +3 -0
  192. package/nuxt/components/tooltipProps.js +3 -0
  193. package/nuxt/components/treeNodeProps.js +3 -0
  194. package/nuxt/components/treeProps.js +3 -0
  195. package/nuxt/components/uploadProps.js +3 -0
  196. package/overlay/index.es.js +239 -314
  197. package/overlay/index.umd.js +1 -1
  198. package/overlay/style.css +1 -1
  199. package/package.json +44 -87
  200. package/pagination/index.es.js +331 -153
  201. package/pagination/index.umd.js +1 -1
  202. package/pagination/style.css +1 -1
  203. package/panel/index.es.js +45 -32
  204. package/panel/index.umd.js +1 -1
  205. package/panel/style.css +1 -1
  206. package/popover/index.es.js +6034 -215
  207. package/popover/index.umd.js +27 -1
  208. package/popover/style.css +1 -1
  209. package/progress/index.es.js +110 -56
  210. package/progress/index.umd.js +3 -3
  211. package/progress/style.css +1 -1
  212. package/radio/index.es.js +7974 -157
  213. package/radio/index.umd.js +27 -1
  214. package/radio/style.css +1 -1
  215. package/rate/index.es.js +77 -55
  216. package/rate/index.umd.js +1 -1
  217. package/rate/style.css +1 -1
  218. package/result/index.es.js +186 -57
  219. package/result/index.umd.js +1 -1
  220. package/result/style.css +1 -1
  221. package/ripple/index.es.js +47 -42
  222. package/ripple/index.umd.js +1 -1
  223. package/search/index.es.js +3868 -1149
  224. package/search/index.umd.js +18 -18
  225. package/search/style.css +1 -1
  226. package/select/index.es.js +9191 -493
  227. package/select/index.umd.js +27 -1
  228. package/select/style.css +1 -1
  229. package/skeleton/index.es.js +113 -265
  230. package/skeleton/index.umd.js +1 -1
  231. package/skeleton/style.css +1 -1
  232. package/slider/index.es.js +144 -137
  233. package/slider/index.umd.js +1 -1
  234. package/slider/style.css +1 -1
  235. package/splitter/index.es.js +6220 -226
  236. package/splitter/index.umd.js +27 -1
  237. package/splitter/style.css +1 -1
  238. package/statistic/index.es.js +41 -34
  239. package/statistic/index.umd.js +1 -1
  240. package/statistic/style.css +1 -1
  241. package/status/index.es.js +27 -6
  242. package/status/index.umd.js +1 -1
  243. package/status/style.css +1 -1
  244. package/{color-picker → steps}/index.d.ts +0 -0
  245. package/steps/index.es.js +386 -0
  246. package/steps/index.umd.js +1 -0
  247. package/{gantt → steps}/package.json +1 -1
  248. package/steps/style.css +1 -0
  249. package/style.css +1 -1
  250. package/switch/index.es.js +7804 -64
  251. package/switch/index.umd.js +27 -1
  252. package/switch/style.css +1 -1
  253. package/table/index.es.js +11010 -1367
  254. package/table/index.umd.js +27 -1
  255. package/table/style.css +1 -1
  256. package/tabs/index.es.js +356 -144
  257. package/tabs/index.umd.js +1 -1
  258. package/tabs/style.css +1 -1
  259. package/tag/index.es.js +49 -24
  260. package/tag/index.umd.js +1 -1
  261. package/tag/style.css +1 -1
  262. package/textarea/index.es.js +7924 -83
  263. package/textarea/index.umd.js +35 -1
  264. package/textarea/style.css +1 -1
  265. package/time-picker/index.es.js +8914 -602
  266. package/time-picker/index.umd.js +27 -1
  267. package/time-picker/style.css +1 -1
  268. package/{comment → time-select}/index.d.ts +0 -0
  269. package/{transfer → time-select}/index.es.js +4912 -2667
  270. package/time-select/index.umd.js +27 -0
  271. package/{breadcrumb → time-select}/package.json +1 -1
  272. package/time-select/style.css +1 -0
  273. package/{date-picker → timeline}/index.d.ts +0 -0
  274. package/timeline/index.es.js +427 -0
  275. package/timeline/index.umd.js +1 -0
  276. package/{carousel → timeline}/package.json +1 -1
  277. package/timeline/style.css +1 -0
  278. package/tooltip/index.es.js +5871 -96
  279. package/tooltip/index.umd.js +27 -1
  280. package/tooltip/style.css +1 -1
  281. package/tree/index.es.js +7556 -2491
  282. package/tree/index.umd.js +18 -18
  283. package/tree/style.css +1 -1
  284. package/upload/index.es.js +865 -6117
  285. package/upload/index.umd.js +1 -27
  286. package/upload/style.css +1 -1
  287. package/vue-devui.es.js +20283 -18856
  288. package/vue-devui.umd.js +30 -19
  289. package/accordion/index.es.js +0 -508
  290. package/accordion/index.umd.js +0 -1
  291. package/accordion/style.css +0 -1
  292. package/anchor/index.es.js +0 -263
  293. package/anchor/index.umd.js +0 -1
  294. package/anchor/style.css +0 -1
  295. package/back-top/index.es.js +0 -128
  296. package/back-top/index.umd.js +0 -1
  297. package/back-top/style.css +0 -1
  298. package/breadcrumb/index.es.js +0 -127
  299. package/breadcrumb/index.umd.js +0 -1
  300. package/breadcrumb/style.css +0 -1
  301. package/carousel/index.es.js +0 -329
  302. package/carousel/index.umd.js +0 -1
  303. package/carousel/style.css +0 -1
  304. package/cascader/index.es.js +0 -5963
  305. package/cascader/index.umd.js +0 -27
  306. package/cascader/package.json +0 -7
  307. package/cascader/style.css +0 -1
  308. package/color-picker/index.umd.js +0 -27
  309. package/color-picker/package.json +0 -7
  310. package/color-picker/style.css +0 -1
  311. package/comment/index.es.js +0 -86
  312. package/comment/index.umd.js +0 -1
  313. package/comment/style.css +0 -1
  314. package/date-picker/index.es.js +0 -1171
  315. package/date-picker/index.umd.js +0 -1
  316. package/date-picker/package.json +0 -7
  317. package/date-picker/style.css +0 -1
  318. package/dragdrop/index.d.ts +0 -7
  319. package/dragdrop/index.es.js +0 -157
  320. package/dragdrop/index.umd.js +0 -1
  321. package/dragdrop/package.json +0 -7
  322. package/gantt/index.d.ts +0 -7
  323. package/gantt/index.es.js +0 -523
  324. package/gantt/index.umd.js +0 -1
  325. package/gantt/style.css +0 -1
  326. package/input-icon/index.d.ts +0 -7
  327. package/input-icon/index.es.js +0 -331
  328. package/input-icon/index.umd.js +0 -1
  329. package/input-icon/package.json +0 -7
  330. package/input-icon/style.css +0 -1
  331. package/nav-sprite/index.d.ts +0 -7
  332. package/nav-sprite/index.es.js +0 -68
  333. package/nav-sprite/index.umd.js +0 -1
  334. package/nav-sprite/package.json +0 -7
  335. package/nuxt/components/Accordion.js +0 -3
  336. package/nuxt/components/Anchor.js +0 -3
  337. package/nuxt/components/BackTop.js +0 -3
  338. package/nuxt/components/Breadcrumb.js +0 -3
  339. package/nuxt/components/Carousel.js +0 -3
  340. package/nuxt/components/CarouselItem.js +0 -3
  341. package/nuxt/components/Cascader.js +0 -3
  342. package/nuxt/components/ColorPicker.js +0 -3
  343. package/nuxt/components/Comment.js +0 -3
  344. package/nuxt/components/DatePicker.js +0 -3
  345. package/nuxt/components/FormControl.js +0 -3
  346. package/nuxt/components/FormLabel.js +0 -3
  347. package/nuxt/components/Gantt.js +0 -3
  348. package/nuxt/components/InputIcon.js +0 -3
  349. package/nuxt/components/NavSprite.js +0 -2
  350. package/nuxt/components/QuadrantDiagram.js +0 -3
  351. package/nuxt/components/ReadTip.js +0 -3
  352. package/nuxt/components/StepsGuide.js +0 -3
  353. package/nuxt/components/StickSlider.js +0 -3
  354. package/nuxt/components/Sticky.js +0 -2
  355. package/nuxt/components/TagInput.js +0 -3
  356. package/nuxt/components/TimeAxis.js +0 -3
  357. package/nuxt/components/TimeAxisItem.js +0 -3
  358. package/nuxt/components/Toast.js +0 -3
  359. package/nuxt/components/ToastService.js +0 -3
  360. package/nuxt/components/Transfer.js +0 -3
  361. package/nuxt/components/TreeSelect.js +0 -3
  362. package/quadrant-diagram/index.d.ts +0 -7
  363. package/quadrant-diagram/index.es.js +0 -5728
  364. package/quadrant-diagram/index.umd.js +0 -27
  365. package/quadrant-diagram/package.json +0 -7
  366. package/quadrant-diagram/style.css +0 -1
  367. package/read-tip/index.d.ts +0 -7
  368. package/read-tip/index.es.js +0 -258
  369. package/read-tip/index.umd.js +0 -1
  370. package/read-tip/package.json +0 -7
  371. package/read-tip/style.css +0 -1
  372. package/steps-guide/index.d.ts +0 -7
  373. package/steps-guide/index.es.js +0 -239
  374. package/steps-guide/index.umd.js +0 -1
  375. package/steps-guide/package.json +0 -7
  376. package/steps-guide/style.css +0 -1
  377. package/sticky/index.d.ts +0 -7
  378. package/sticky/index.es.js +0 -197
  379. package/sticky/index.umd.js +0 -1
  380. package/sticky/package.json +0 -7
  381. package/tag-input/index.d.ts +0 -7
  382. package/tag-input/index.es.js +0 -329
  383. package/tag-input/index.umd.js +0 -1
  384. package/tag-input/package.json +0 -7
  385. package/tag-input/style.css +0 -1
  386. package/time-axis/index.d.ts +0 -7
  387. package/time-axis/index.es.js +0 -299
  388. package/time-axis/index.umd.js +0 -1
  389. package/time-axis/package.json +0 -7
  390. package/time-axis/style.css +0 -1
  391. package/toast/index.d.ts +0 -7
  392. package/toast/index.es.js +0 -5918
  393. package/toast/index.umd.js +0 -27
  394. package/toast/style.css +0 -1
  395. package/transfer/index.d.ts +0 -7
  396. package/transfer/index.umd.js +0 -27
  397. package/transfer/package.json +0 -7
  398. package/transfer/style.css +0 -1
  399. package/tree-select/index.d.ts +0 -7
  400. package/tree-select/index.es.js +0 -623
  401. package/tree-select/index.umd.js +0 -1
  402. package/tree-select/package.json +0 -7
  403. package/tree-select/style.css +0 -1
package/form/index.es.js CHANGED
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,27 +16,25 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
17
- import { defineComponent, provide, createVNode, ref, toRefs, reactive, watch, withDirectives, resolveDirective, resolveComponent, inject, computed, onMounted, onBeforeUnmount, Teleport } from "vue";
18
- function mitt(n) {
19
- return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
20
- var i = n.get(t);
21
- i ? i.push(e) : n.set(t, [e]);
22
- }, off: function(t, e) {
23
- var i = n.get(t);
24
- i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
25
- }, emit: function(t, e) {
26
- var i = n.get(t);
27
- i && i.slice().map(function(n2) {
28
- n2(e);
29
- }), (i = n.get("*")) && i.slice().map(function(n2) {
30
- n2(t, e);
31
- });
32
- } };
33
- }
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { defineComponent, watch, provide, reactive, toRefs, createVNode, onUnmounted, Transition, mergeProps, ref, unref, nextTick, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, computed, onMounted, Teleport, withModifiers, createTextVNode, onBeforeUnmount } from "vue";
33
+ import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
34
34
  const formProps = {
35
- formData: {
35
+ data: {
36
36
  type: Object,
37
- default: {}
37
+ default: () => ({})
38
38
  },
39
39
  layout: {
40
40
  type: String,
@@ -42,1560 +42,73 @@ const formProps = {
42
42
  },
43
43
  labelSize: {
44
44
  type: String,
45
- default: ""
45
+ default: "md"
46
46
  },
47
47
  labelAlign: {
48
48
  type: String,
49
49
  default: "start"
50
50
  },
51
51
  rules: {
52
- type: Object,
53
- default: {}
52
+ type: Object
54
53
  },
55
- columnsClass: {
54
+ messageType: {
56
55
  type: String,
57
- default: ""
56
+ default: "popover"
58
57
  },
59
- name: {
60
- type: String,
61
- default: ""
58
+ popPosition: {
59
+ type: Array,
60
+ default: ["right", "bottom"]
62
61
  },
63
- messageShowType: {
64
- type: String,
65
- default: "popover"
66
- }
67
- };
68
- const formItemProps = {
69
- dHasFeedback: {
62
+ validateOnRuleChange: {
70
63
  type: Boolean,
71
64
  default: false
72
65
  },
73
- prop: {
74
- type: String,
75
- default: ""
76
- }
77
- };
78
- const formLabelProps = {
79
- required: {
66
+ showFeedback: {
80
67
  type: Boolean,
81
68
  default: false
82
69
  },
83
- hasHelp: {
70
+ disabled: {
84
71
  type: Boolean,
85
72
  default: false
86
73
  },
87
- helpTips: {
88
- type: String,
89
- default: ""
90
- }
91
- };
92
- const formControlProps = {
93
- feedbackStatus: {
94
- type: String,
95
- default: ""
96
- },
97
- extraInfo: {
98
- type: String,
99
- default: ""
100
- }
101
- };
102
- const dFormEvents = {
103
- addField: "d.form.addField",
104
- removeField: "d.form.removeField"
105
- };
106
- const formInjectionKey = Symbol("dForm");
107
- const formItemInjectionKey = Symbol("dFormItem");
108
- const dFormItemEvents = {
109
- blur: "d.form.blur",
110
- change: "d.form.change",
111
- input: "d.form.input"
112
- };
113
- var eventBus = mitt();
114
- const EventBus = eventBus;
115
- function isObject(obj) {
116
- return Object.prototype.toString.call(obj).slice(8, -1) === "Object";
117
- }
118
- function hasKey(obj, key) {
119
- if (!isObject(obj))
120
- return false;
121
- return Object.prototype.hasOwnProperty.call(obj, key);
122
- }
123
- function getElOffset(curEl) {
124
- let totalLeft = 0;
125
- let totalTop = 0;
126
- let par = curEl.offsetParent;
127
- totalLeft += curEl.offsetLeft;
128
- totalTop += curEl.offsetTop;
129
- while (par) {
130
- if (navigator.userAgent.indexOf("MSIE 8.0") === -1) {
131
- totalTop += par.clientTop;
132
- totalLeft += par.clientLeft;
133
- }
134
- totalTop += par.offsetTop;
135
- totalLeft += par.offsetLeft;
136
- par = par.offsetParent;
137
- }
138
- return { left: totalLeft, top: totalTop };
139
- }
140
- var form = "";
141
- var Form = defineComponent({
142
- name: "DForm",
143
- props: formProps,
144
- emits: ["submit"],
145
- setup(props, ctx2) {
146
- const formMitt = mitt();
147
- const fields = [];
148
- const resetFormFields = () => {
149
- fields.forEach((field) => {
150
- field.resetField();
151
- });
152
- };
153
- formMitt.on(dFormEvents.addField, (field) => {
154
- if (field) {
155
- fields.push(field);
156
- }
157
- });
158
- formMitt.on(dFormEvents.removeField, (field) => {
159
- if (field.prop) {
160
- fields.splice(fields.indexOf(field), 1);
161
- }
162
- });
163
- provide(formInjectionKey, {
164
- formData: props.formData,
165
- formMitt,
166
- labelData: {
167
- layout: props.layout,
168
- labelSize: props.labelSize,
169
- labelAlign: props.labelAlign
170
- },
171
- rules: props.rules,
172
- columnsClass: props.columnsClass,
173
- messageShowType: "popover"
174
- });
175
- const onSubmit = (e) => {
176
- e.preventDefault();
177
- ctx2.emit("submit", e);
178
- EventBus.emit(`formSubmit:${props.name}`);
179
- };
180
- return {
181
- fields,
182
- formMitt,
183
- onSubmit,
184
- resetFormFields
185
- };
186
- },
187
- render() {
188
- var _a, _b;
189
- const {
190
- onSubmit
191
- } = this;
192
- return createVNode("form", {
193
- "onSubmit": onSubmit,
194
- "class": "d-form"
195
- }, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)]);
196
- }
197
- });
198
- var Icon = defineComponent({
199
- name: "DIcon",
200
- props: {
201
- name: {
202
- type: String,
203
- required: true
204
- },
205
- size: {
206
- type: String,
207
- default: "inherit"
208
- },
209
- color: {
210
- type: String,
211
- default: "inherit"
212
- },
213
- classPrefix: {
214
- type: String,
215
- default: "icon"
216
- }
217
- },
218
- setup(props) {
219
- return __spreadValues({}, props);
220
- },
221
- render() {
222
- const {
223
- name,
224
- size,
225
- color,
226
- classPrefix
227
- } = this;
228
- return /^((https?):)?\/\//.test(name) ? createVNode("img", {
229
- "src": name,
230
- "alt": name.split("/")[name.split("/").length - 1],
231
- "style": {
232
- width: size,
233
- verticalAlign: "text-bottom"
234
- }
235
- }, null) : createVNode("i", {
236
- "class": `${classPrefix} ${classPrefix}-${name}`,
237
- "style": {
238
- fontSize: size,
239
- color
240
- }
241
- }, null);
242
- }
243
- });
244
- var debounce = (callBack, wait) => {
245
- let time = null;
246
- return () => {
247
- time && clearTimeout(time);
248
- time = setTimeout(() => {
249
- callBack == null ? void 0 : callBack();
250
- }, wait);
251
- };
252
- };
253
- const inBrowser = typeof window !== "undefined";
254
- function on(element, eventName, handler) {
255
- if (document.addEventListener) {
256
- if (element && eventName && handler) {
257
- element.addEventListener(eventName, handler, false);
258
- }
259
- } else {
260
- if (element && eventName && handler) {
261
- element.attachEvent("on" + eventName, handler);
262
- }
263
- }
264
- }
265
- const ctx = Symbol("@@clickoutside");
266
- const nodeList = /* @__PURE__ */ new Map();
267
- let startClick;
268
- let nid = 0;
269
- let isFirst = true;
270
- function createDocumentHandler(el, binding, vnode) {
271
- if (inBrowser && isFirst) {
272
- isFirst = false;
273
- on(document, "mousedown", (e) => {
274
- startClick = e;
275
- });
276
- on(document, "mouseup", (e) => {
277
- for (const [id, node] of nodeList) {
278
- node[ctx].documentHandler(e, startClick);
279
- }
280
- });
281
- }
282
- return function(mouseup, mousedown) {
283
- if (!vnode || !binding.instance || !mouseup.target || !mousedown.target || el.contains(mouseup.target) || el.contains(mousedown.target) || el === mouseup.target) {
284
- return;
285
- }
286
- el[ctx].bindingFn && el[ctx].bindingFn();
287
- };
288
- }
289
- const clickoutsideDirective = {
290
- beforeMount: function(el, binding, vnode) {
291
- nid++;
292
- nodeList.set(nid, el);
293
- el[ctx] = {
294
- nid,
295
- documentHandler: createDocumentHandler(el, binding, vnode),
296
- bindingFn: binding.value
297
- };
298
- },
299
- updated: function(el, binding, vnode) {
300
- el[ctx].documentHandler = createDocumentHandler(el, binding, vnode);
301
- el[ctx].bindingFn = binding.value;
302
- },
303
- unmounted: function(el) {
304
- nodeList.delete(el[ctx].nid);
305
- delete el[ctx];
74
+ size: {
75
+ type: String
306
76
  }
307
77
  };
308
- var popover = "";
309
- const popTypeClass = {
310
- success: {
311
- name: "right-o",
312
- color: "rgb(61, 204, 166)"
313
- },
314
- error: {
315
- name: "error-o",
316
- color: "rgb(249, 95, 91)"
317
- },
318
- info: {
319
- name: "info-o",
320
- color: "rgb(81, 112, 255)"
321
- },
322
- warning: {
323
- name: "warning-o",
324
- color: "rgb(254, 204, 85)"
325
- },
326
- default: {}
327
- };
328
- var Popover = defineComponent({
329
- name: "DPopover",
330
- directives: {
331
- clickoutside: clickoutsideDirective
332
- },
333
- props: {
334
- visible: {
335
- type: Boolean,
336
- default: false
337
- },
338
- position: {
339
- type: String,
340
- default: "bottom"
341
- },
342
- content: {
343
- type: String,
344
- default: "default"
345
- },
346
- trigger: {
347
- type: String,
348
- default: "click"
349
- },
350
- zIndex: {
351
- type: Number,
352
- default: 1060
353
- },
354
- controlled: {
355
- type: Boolean,
356
- default: false
357
- },
358
- popType: {
359
- type: String,
360
- default: "default"
361
- },
362
- showAnimation: {
363
- type: Boolean,
364
- default: true
365
- },
366
- mouseEnterDelay: {
367
- type: Number,
368
- default: 150
369
- },
370
- mouseLeaveDelay: {
371
- type: Number,
372
- default: 100
373
- },
374
- popMaxWidth: {
375
- type: Number,
376
- default: void 0
377
- },
378
- popoverStyle: {
379
- type: Object,
380
- default: () => ({})
381
- }
382
- },
383
- setup(props, ctx2) {
384
- const {
385
- slots
386
- } = ctx2;
387
- const visible = ref(props.visible);
388
- const {
389
- position,
390
- content,
391
- zIndex,
392
- trigger,
393
- popType,
394
- popoverStyle,
395
- mouseEnterDelay,
396
- mouseLeaveDelay,
397
- showAnimation,
398
- popMaxWidth,
399
- controlled
400
- } = toRefs(props);
401
- const style2 = __spreadValues({
402
- zIndex: zIndex.value
403
- }, popoverStyle.value);
404
- const isClick = trigger.value === "click";
405
- const iconType = reactive(popTypeClass[popType.value]);
406
- const event = function() {
407
- if (visible.value) {
408
- visible.value = false;
409
- return;
410
- }
411
- visible.value = true;
412
- };
413
- const onClick = isClick && controlled.value ? event : null;
414
- const enter = debounce(() => {
415
- visible.value = true;
416
- }, mouseEnterDelay.value);
417
- const leave = debounce(() => {
418
- visible.value = false;
419
- }, mouseLeaveDelay.value);
420
- const onMouseenter = !isClick && controlled.value ? enter : null;
421
- const onMouseleave = !isClick && controlled.value ? leave : null;
422
- const hiddenContext = () => {
423
- if (!controlled.value)
424
- return;
425
- visible.value = false;
426
- };
427
- popMaxWidth.value && (style2.maxWidth = `${popMaxWidth.value}px`);
428
- watch(() => props.visible, (newVal) => {
429
- if (controlled.value)
430
- return;
431
- visible.value = newVal;
432
- });
433
- return () => {
434
- var _a, _b;
435
- return createVNode("div", {
436
- "class": ["devui-popover", position.value, {
437
- "devui-popover-animation": showAnimation.value,
438
- "devui-popover-isVisible": visible.value
439
- }]
440
- }, [withDirectives(createVNode("div", {
441
- "class": "devui-popover-reference",
442
- "onMouseenter": onMouseenter,
443
- "onMouseleave": onMouseleave,
444
- "onClick": onClick
445
- }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), [[resolveDirective("clickoutside"), hiddenContext]]), createVNode("div", {
446
- "class": ["devui-popover-content", iconType.name ? "is-icon" : ""],
447
- "style": style2
448
- }, [iconType.name && createVNode(resolveComponent("d-icon"), {
449
- "name": iconType.name,
450
- "color": iconType.color,
451
- "class": "devui-popover-icon",
452
- "size": "16px"
453
- }, null), ((_b = slots.content) == null ? void 0 : _b.call(slots)) || createVNode("span", null, [content.value]), createVNode("span", {
454
- "class": "after",
455
- "style": style2
456
- }, null)])]);
457
- };
78
+ const FORM_TOKEN = Symbol("dForm");
79
+ function createBem(namespace, element, modifier) {
80
+ let cls = namespace;
81
+ if (element) {
82
+ cls += `__${element}`;
458
83
  }
459
- });
460
- var formLabel = "";
461
- var FormLabel = defineComponent({
462
- name: "DFormLabel",
463
- props: formLabelProps,
464
- setup(props, ctx2) {
465
- const dForm = reactive(inject(formInjectionKey, {}));
466
- const labelData = reactive(dForm.labelData);
467
- const isHorizontal = computed(() => labelData.layout === "horizontal").value;
468
- const isLg = computed(() => labelData.labelSize === "lg").value;
469
- const isSm = computed(() => labelData.labelSize === "sm").value;
470
- const isCenter = computed(() => labelData.labelAlign === "center").value;
471
- const isEnd = computed(() => labelData.labelAlign === "end").value;
472
- const wrapperCls = `form-label${isHorizontal ? isSm ? " form-label_sm" : isLg ? " form-label_lg" : " form-label_sd" : ""}${isCenter ? " form-label_center" : isEnd ? " form-label_end" : ""}`;
473
- const className = `${props.required ? " devui-required" : ""}`;
474
- const style2 = {
475
- display: isHorizontal ? "inline" : "inline-block"
476
- };
477
- return () => {
478
- var _a, _b;
479
- return createVNode("span", {
480
- "class": wrapperCls,
481
- "style": style2
482
- }, [createVNode("span", {
483
- "class": className
484
- }, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a), props.hasHelp && props.helpTips && createVNode(Popover, {
485
- "content": props.helpTips,
486
- "showAnimation": false,
487
- "position": "top",
488
- "trigger": "hover"
489
- }, {
490
- reference: () => createVNode("span", {
491
- "class": "form-label-help"
492
- }, [createVNode(Icon, {
493
- "name": "helping",
494
- "color": "#252b3a"
495
- }, null)])
496
- })])]);
497
- };
84
+ if (modifier) {
85
+ cls += `--${modifier}`;
498
86
  }
499
- });
500
- function _extends() {
501
- _extends = Object.assign || function(target) {
502
- for (var i = 1; i < arguments.length; i++) {
503
- var source = arguments[i];
504
- for (var key in source) {
505
- if (Object.prototype.hasOwnProperty.call(source, key)) {
506
- target[key] = source[key];
507
- }
508
- }
509
- }
510
- return target;
511
- };
512
- return _extends.apply(this, arguments);
87
+ return cls;
513
88
  }
514
- function _inheritsLoose(subClass, superClass) {
515
- subClass.prototype = Object.create(superClass.prototype);
516
- subClass.prototype.constructor = subClass;
517
- _setPrototypeOf(subClass, superClass);
518
- }
519
- function _getPrototypeOf(o) {
520
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
521
- return o2.__proto__ || Object.getPrototypeOf(o2);
89
+ function useNamespace(block, needDot = false) {
90
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
91
+ const b = () => createBem(namespace);
92
+ const e = (element) => element ? createBem(namespace, element) : "";
93
+ const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
94
+ const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
95
+ return {
96
+ b,
97
+ e,
98
+ m,
99
+ em
522
100
  };
523
- return _getPrototypeOf(o);
524
101
  }
525
- function _setPrototypeOf(o, p) {
526
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
527
- o2.__proto__ = p2;
528
- return o2;
102
+ function useFieldCollection() {
103
+ const itemContexts = [];
104
+ const addItemContext = (field) => {
105
+ itemContexts.push(field);
529
106
  };
530
- return _setPrototypeOf(o, p);
531
- }
532
- function _isNativeReflectConstruct() {
533
- if (typeof Reflect === "undefined" || !Reflect.construct)
534
- return false;
535
- if (Reflect.construct.sham)
536
- return false;
537
- if (typeof Proxy === "function")
538
- return true;
539
- try {
540
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
541
- }));
542
- return true;
543
- } catch (e) {
544
- return false;
545
- }
546
- }
547
- function _construct(Parent, args, Class) {
548
- if (_isNativeReflectConstruct()) {
549
- _construct = Reflect.construct;
550
- } else {
551
- _construct = function _construct2(Parent2, args2, Class2) {
552
- var a = [null];
553
- a.push.apply(a, args2);
554
- var Constructor = Function.bind.apply(Parent2, a);
555
- var instance = new Constructor();
556
- if (Class2)
557
- _setPrototypeOf(instance, Class2.prototype);
558
- return instance;
559
- };
560
- }
561
- return _construct.apply(null, arguments);
562
- }
563
- function _isNativeFunction(fn) {
564
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
565
- }
566
- function _wrapNativeSuper(Class) {
567
- var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
568
- _wrapNativeSuper = function _wrapNativeSuper2(Class2) {
569
- if (Class2 === null || !_isNativeFunction(Class2))
570
- return Class2;
571
- if (typeof Class2 !== "function") {
572
- throw new TypeError("Super expression must either be null or a function");
573
- }
574
- if (typeof _cache !== "undefined") {
575
- if (_cache.has(Class2))
576
- return _cache.get(Class2);
577
- _cache.set(Class2, Wrapper);
578
- }
579
- function Wrapper() {
580
- return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
581
- }
582
- Wrapper.prototype = Object.create(Class2.prototype, {
583
- constructor: {
584
- value: Wrapper,
585
- enumerable: false,
586
- writable: true,
587
- configurable: true
588
- }
589
- });
590
- return _setPrototypeOf(Wrapper, Class2);
107
+ const removeItemContext = (field) => {
108
+ itemContexts.splice(itemContexts.indexOf(field), 1);
591
109
  };
592
- return _wrapNativeSuper(Class);
110
+ return { itemContexts, addItemContext, removeItemContext };
593
111
  }
594
- var formatRegExp = /%[sdj%]/g;
595
- var warning = function warning2() {
596
- };
597
- if (typeof process !== "undefined" && process.env && false) {
598
- warning = function warning3(type4, errors) {
599
- if (typeof console !== "undefined" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === "undefined") {
600
- if (errors.every(function(e) {
601
- return typeof e === "string";
602
- })) {
603
- console.warn(type4, errors);
604
- }
605
- }
606
- };
607
- }
608
- function convertFieldsError(errors) {
609
- if (!errors || !errors.length)
610
- return null;
611
- var fields = {};
612
- errors.forEach(function(error) {
613
- var field = error.field;
614
- fields[field] = fields[field] || [];
615
- fields[field].push(error);
616
- });
617
- return fields;
618
- }
619
- function format(template) {
620
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
621
- args[_key - 1] = arguments[_key];
622
- }
623
- var i = 0;
624
- var len = args.length;
625
- if (typeof template === "function") {
626
- return template.apply(null, args);
627
- }
628
- if (typeof template === "string") {
629
- var str = template.replace(formatRegExp, function(x) {
630
- if (x === "%%") {
631
- return "%";
632
- }
633
- if (i >= len) {
634
- return x;
635
- }
636
- switch (x) {
637
- case "%s":
638
- return String(args[i++]);
639
- case "%d":
640
- return Number(args[i++]);
641
- case "%j":
642
- try {
643
- return JSON.stringify(args[i++]);
644
- } catch (_) {
645
- return "[Circular]";
646
- }
647
- break;
648
- default:
649
- return x;
650
- }
651
- });
652
- return str;
653
- }
654
- return template;
655
- }
656
- function isNativeStringType(type4) {
657
- return type4 === "string" || type4 === "url" || type4 === "hex" || type4 === "email" || type4 === "date" || type4 === "pattern";
658
- }
659
- function isEmptyValue(value, type4) {
660
- if (value === void 0 || value === null) {
661
- return true;
662
- }
663
- if (type4 === "array" && Array.isArray(value) && !value.length) {
664
- return true;
665
- }
666
- if (isNativeStringType(type4) && typeof value === "string" && !value) {
667
- return true;
668
- }
669
- return false;
670
- }
671
- function asyncParallelArray(arr, func, callback) {
672
- var results = [];
673
- var total = 0;
674
- var arrLength = arr.length;
675
- function count(errors) {
676
- results.push.apply(results, errors || []);
677
- total++;
678
- if (total === arrLength) {
679
- callback(results);
680
- }
681
- }
682
- arr.forEach(function(a) {
683
- func(a, count);
684
- });
685
- }
686
- function asyncSerialArray(arr, func, callback) {
687
- var index2 = 0;
688
- var arrLength = arr.length;
689
- function next(errors) {
690
- if (errors && errors.length) {
691
- callback(errors);
692
- return;
693
- }
694
- var original = index2;
695
- index2 = index2 + 1;
696
- if (original < arrLength) {
697
- func(arr[original], next);
698
- } else {
699
- callback([]);
700
- }
701
- }
702
- next([]);
703
- }
704
- function flattenObjArr(objArr) {
705
- var ret = [];
706
- Object.keys(objArr).forEach(function(k) {
707
- ret.push.apply(ret, objArr[k] || []);
708
- });
709
- return ret;
710
- }
711
- var AsyncValidationError = /* @__PURE__ */ function(_Error) {
712
- _inheritsLoose(AsyncValidationError2, _Error);
713
- function AsyncValidationError2(errors, fields) {
714
- var _this;
715
- _this = _Error.call(this, "Async Validation Error") || this;
716
- _this.errors = errors;
717
- _this.fields = fields;
718
- return _this;
719
- }
720
- return AsyncValidationError2;
721
- }(/* @__PURE__ */ _wrapNativeSuper(Error));
722
- function asyncMap(objArr, option, func, callback, source) {
723
- if (option.first) {
724
- var _pending = new Promise(function(resolve, reject) {
725
- var next = function next2(errors) {
726
- callback(errors);
727
- return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
728
- };
729
- var flattenArr = flattenObjArr(objArr);
730
- asyncSerialArray(flattenArr, func, next);
731
- });
732
- _pending["catch"](function(e) {
733
- return e;
734
- });
735
- return _pending;
736
- }
737
- var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
738
- var objArrKeys = Object.keys(objArr);
739
- var objArrLength = objArrKeys.length;
740
- var total = 0;
741
- var results = [];
742
- var pending = new Promise(function(resolve, reject) {
743
- var next = function next2(errors) {
744
- results.push.apply(results, errors);
745
- total++;
746
- if (total === objArrLength) {
747
- callback(results);
748
- return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
749
- }
750
- };
751
- if (!objArrKeys.length) {
752
- callback(results);
753
- resolve(source);
754
- }
755
- objArrKeys.forEach(function(key) {
756
- var arr = objArr[key];
757
- if (firstFields.indexOf(key) !== -1) {
758
- asyncSerialArray(arr, func, next);
759
- } else {
760
- asyncParallelArray(arr, func, next);
761
- }
762
- });
763
- });
764
- pending["catch"](function(e) {
765
- return e;
766
- });
767
- return pending;
768
- }
769
- function isErrorObj(obj) {
770
- return !!(obj && obj.message !== void 0);
771
- }
772
- function getValue(value, path) {
773
- var v = value;
774
- for (var i = 0; i < path.length; i++) {
775
- if (v == void 0) {
776
- return v;
777
- }
778
- v = v[path[i]];
779
- }
780
- return v;
781
- }
782
- function complementError(rule, source) {
783
- return function(oe) {
784
- var fieldValue;
785
- if (rule.fullFields) {
786
- fieldValue = getValue(source, rule.fullFields);
787
- } else {
788
- fieldValue = source[oe.field || rule.fullField];
789
- }
790
- if (isErrorObj(oe)) {
791
- oe.field = oe.field || rule.fullField;
792
- oe.fieldValue = fieldValue;
793
- return oe;
794
- }
795
- return {
796
- message: typeof oe === "function" ? oe() : oe,
797
- fieldValue,
798
- field: oe.field || rule.fullField
799
- };
800
- };
801
- }
802
- function deepMerge(target, source) {
803
- if (source) {
804
- for (var s in source) {
805
- if (source.hasOwnProperty(s)) {
806
- var value = source[s];
807
- if (typeof value === "object" && typeof target[s] === "object") {
808
- target[s] = _extends({}, target[s], value);
809
- } else {
810
- target[s] = value;
811
- }
812
- }
813
- }
814
- }
815
- return target;
816
- }
817
- var required$1 = function required(rule, value, source, errors, options, type4) {
818
- if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type4 || rule.type))) {
819
- errors.push(format(options.messages.required, rule.fullField));
820
- }
821
- };
822
- var whitespace = function whitespace2(rule, value, source, errors, options) {
823
- if (/^\s+$/.test(value) || value === "") {
824
- errors.push(format(options.messages.whitespace, rule.fullField));
825
- }
826
- };
827
- var pattern$2 = {
828
- email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
829
- url: new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", "i"),
830
- hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
831
- };
832
- var types = {
833
- integer: function integer(value) {
834
- return types.number(value) && parseInt(value, 10) === value;
835
- },
836
- "float": function float(value) {
837
- return types.number(value) && !types.integer(value);
838
- },
839
- array: function array(value) {
840
- return Array.isArray(value);
841
- },
842
- regexp: function regexp(value) {
843
- if (value instanceof RegExp) {
844
- return true;
845
- }
846
- try {
847
- return !!new RegExp(value);
848
- } catch (e) {
849
- return false;
850
- }
851
- },
852
- date: function date(value) {
853
- return typeof value.getTime === "function" && typeof value.getMonth === "function" && typeof value.getYear === "function" && !isNaN(value.getTime());
854
- },
855
- number: function number(value) {
856
- if (isNaN(value)) {
857
- return false;
858
- }
859
- return typeof value === "number";
860
- },
861
- object: function object(value) {
862
- return typeof value === "object" && !types.array(value);
863
- },
864
- method: function method(value) {
865
- return typeof value === "function";
866
- },
867
- email: function email(value) {
868
- return typeof value === "string" && value.length <= 320 && !!value.match(pattern$2.email);
869
- },
870
- url: function url(value) {
871
- return typeof value === "string" && value.length <= 2048 && !!value.match(pattern$2.url);
872
- },
873
- hex: function hex(value) {
874
- return typeof value === "string" && !!value.match(pattern$2.hex);
875
- }
876
- };
877
- var type$1 = function type(rule, value, source, errors, options) {
878
- if (rule.required && value === void 0) {
879
- required$1(rule, value, source, errors, options);
880
- return;
881
- }
882
- var custom = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"];
883
- var ruleType = rule.type;
884
- if (custom.indexOf(ruleType) > -1) {
885
- if (!types[ruleType](value)) {
886
- errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
887
- }
888
- } else if (ruleType && typeof value !== rule.type) {
889
- errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
890
- }
891
- };
892
- var range = function range2(rule, value, source, errors, options) {
893
- var len = typeof rule.len === "number";
894
- var min = typeof rule.min === "number";
895
- var max = typeof rule.max === "number";
896
- var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
897
- var val = value;
898
- var key = null;
899
- var num = typeof value === "number";
900
- var str = typeof value === "string";
901
- var arr = Array.isArray(value);
902
- if (num) {
903
- key = "number";
904
- } else if (str) {
905
- key = "string";
906
- } else if (arr) {
907
- key = "array";
908
- }
909
- if (!key) {
910
- return false;
911
- }
912
- if (arr) {
913
- val = value.length;
914
- }
915
- if (str) {
916
- val = value.replace(spRegexp, "_").length;
917
- }
918
- if (len) {
919
- if (val !== rule.len) {
920
- errors.push(format(options.messages[key].len, rule.fullField, rule.len));
921
- }
922
- } else if (min && !max && val < rule.min) {
923
- errors.push(format(options.messages[key].min, rule.fullField, rule.min));
924
- } else if (max && !min && val > rule.max) {
925
- errors.push(format(options.messages[key].max, rule.fullField, rule.max));
926
- } else if (min && max && (val < rule.min || val > rule.max)) {
927
- errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
928
- }
929
- };
930
- var ENUM$1 = "enum";
931
- var enumerable$1 = function enumerable(rule, value, source, errors, options) {
932
- rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
933
- if (rule[ENUM$1].indexOf(value) === -1) {
934
- errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(", ")));
935
- }
936
- };
937
- var pattern$1 = function pattern(rule, value, source, errors, options) {
938
- if (rule.pattern) {
939
- if (rule.pattern instanceof RegExp) {
940
- rule.pattern.lastIndex = 0;
941
- if (!rule.pattern.test(value)) {
942
- errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
943
- }
944
- } else if (typeof rule.pattern === "string") {
945
- var _pattern = new RegExp(rule.pattern);
946
- if (!_pattern.test(value)) {
947
- errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
948
- }
949
- }
950
- }
951
- };
952
- var rules = {
953
- required: required$1,
954
- whitespace,
955
- type: type$1,
956
- range,
957
- "enum": enumerable$1,
958
- pattern: pattern$1
959
- };
960
- var string = function string2(rule, value, callback, source, options) {
961
- var errors = [];
962
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
963
- if (validate) {
964
- if (isEmptyValue(value, "string") && !rule.required) {
965
- return callback();
966
- }
967
- rules.required(rule, value, source, errors, options, "string");
968
- if (!isEmptyValue(value, "string")) {
969
- rules.type(rule, value, source, errors, options);
970
- rules.range(rule, value, source, errors, options);
971
- rules.pattern(rule, value, source, errors, options);
972
- if (rule.whitespace === true) {
973
- rules.whitespace(rule, value, source, errors, options);
974
- }
975
- }
976
- }
977
- callback(errors);
978
- };
979
- var method2 = function method3(rule, value, callback, source, options) {
980
- var errors = [];
981
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
982
- if (validate) {
983
- if (isEmptyValue(value) && !rule.required) {
984
- return callback();
985
- }
986
- rules.required(rule, value, source, errors, options);
987
- if (value !== void 0) {
988
- rules.type(rule, value, source, errors, options);
989
- }
990
- }
991
- callback(errors);
992
- };
993
- var number2 = function number3(rule, value, callback, source, options) {
994
- var errors = [];
995
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
996
- if (validate) {
997
- if (value === "") {
998
- value = void 0;
999
- }
1000
- if (isEmptyValue(value) && !rule.required) {
1001
- return callback();
1002
- }
1003
- rules.required(rule, value, source, errors, options);
1004
- if (value !== void 0) {
1005
- rules.type(rule, value, source, errors, options);
1006
- rules.range(rule, value, source, errors, options);
1007
- }
1008
- }
1009
- callback(errors);
1010
- };
1011
- var _boolean = function _boolean2(rule, value, callback, source, options) {
1012
- var errors = [];
1013
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1014
- if (validate) {
1015
- if (isEmptyValue(value) && !rule.required) {
1016
- return callback();
1017
- }
1018
- rules.required(rule, value, source, errors, options);
1019
- if (value !== void 0) {
1020
- rules.type(rule, value, source, errors, options);
1021
- }
1022
- }
1023
- callback(errors);
1024
- };
1025
- var regexp2 = function regexp3(rule, value, callback, source, options) {
1026
- var errors = [];
1027
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1028
- if (validate) {
1029
- if (isEmptyValue(value) && !rule.required) {
1030
- return callback();
1031
- }
1032
- rules.required(rule, value, source, errors, options);
1033
- if (!isEmptyValue(value)) {
1034
- rules.type(rule, value, source, errors, options);
1035
- }
1036
- }
1037
- callback(errors);
1038
- };
1039
- var integer2 = function integer3(rule, value, callback, source, options) {
1040
- var errors = [];
1041
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1042
- if (validate) {
1043
- if (isEmptyValue(value) && !rule.required) {
1044
- return callback();
1045
- }
1046
- rules.required(rule, value, source, errors, options);
1047
- if (value !== void 0) {
1048
- rules.type(rule, value, source, errors, options);
1049
- rules.range(rule, value, source, errors, options);
1050
- }
1051
- }
1052
- callback(errors);
1053
- };
1054
- var floatFn = function floatFn2(rule, value, callback, source, options) {
1055
- var errors = [];
1056
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1057
- if (validate) {
1058
- if (isEmptyValue(value) && !rule.required) {
1059
- return callback();
1060
- }
1061
- rules.required(rule, value, source, errors, options);
1062
- if (value !== void 0) {
1063
- rules.type(rule, value, source, errors, options);
1064
- rules.range(rule, value, source, errors, options);
1065
- }
1066
- }
1067
- callback(errors);
1068
- };
1069
- var array2 = function array3(rule, value, callback, source, options) {
1070
- var errors = [];
1071
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1072
- if (validate) {
1073
- if ((value === void 0 || value === null) && !rule.required) {
1074
- return callback();
1075
- }
1076
- rules.required(rule, value, source, errors, options, "array");
1077
- if (value !== void 0 && value !== null) {
1078
- rules.type(rule, value, source, errors, options);
1079
- rules.range(rule, value, source, errors, options);
1080
- }
1081
- }
1082
- callback(errors);
1083
- };
1084
- var object2 = function object3(rule, value, callback, source, options) {
1085
- var errors = [];
1086
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1087
- if (validate) {
1088
- if (isEmptyValue(value) && !rule.required) {
1089
- return callback();
1090
- }
1091
- rules.required(rule, value, source, errors, options);
1092
- if (value !== void 0) {
1093
- rules.type(rule, value, source, errors, options);
1094
- }
1095
- }
1096
- callback(errors);
1097
- };
1098
- var ENUM = "enum";
1099
- var enumerable2 = function enumerable3(rule, value, callback, source, options) {
1100
- var errors = [];
1101
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1102
- if (validate) {
1103
- if (isEmptyValue(value) && !rule.required) {
1104
- return callback();
1105
- }
1106
- rules.required(rule, value, source, errors, options);
1107
- if (value !== void 0) {
1108
- rules[ENUM](rule, value, source, errors, options);
1109
- }
1110
- }
1111
- callback(errors);
1112
- };
1113
- var pattern2 = function pattern3(rule, value, callback, source, options) {
1114
- var errors = [];
1115
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1116
- if (validate) {
1117
- if (isEmptyValue(value, "string") && !rule.required) {
1118
- return callback();
1119
- }
1120
- rules.required(rule, value, source, errors, options);
1121
- if (!isEmptyValue(value, "string")) {
1122
- rules.pattern(rule, value, source, errors, options);
1123
- }
1124
- }
1125
- callback(errors);
1126
- };
1127
- var date2 = function date3(rule, value, callback, source, options) {
1128
- var errors = [];
1129
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1130
- if (validate) {
1131
- if (isEmptyValue(value, "date") && !rule.required) {
1132
- return callback();
1133
- }
1134
- rules.required(rule, value, source, errors, options);
1135
- if (!isEmptyValue(value, "date")) {
1136
- var dateObject;
1137
- if (value instanceof Date) {
1138
- dateObject = value;
1139
- } else {
1140
- dateObject = new Date(value);
1141
- }
1142
- rules.type(rule, dateObject, source, errors, options);
1143
- if (dateObject) {
1144
- rules.range(rule, dateObject.getTime(), source, errors, options);
1145
- }
1146
- }
1147
- }
1148
- callback(errors);
1149
- };
1150
- var required2 = function required3(rule, value, callback, source, options) {
1151
- var errors = [];
1152
- var type4 = Array.isArray(value) ? "array" : typeof value;
1153
- rules.required(rule, value, source, errors, options, type4);
1154
- callback(errors);
1155
- };
1156
- var type2 = function type3(rule, value, callback, source, options) {
1157
- var ruleType = rule.type;
1158
- var errors = [];
1159
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1160
- if (validate) {
1161
- if (isEmptyValue(value, ruleType) && !rule.required) {
1162
- return callback();
1163
- }
1164
- rules.required(rule, value, source, errors, options, ruleType);
1165
- if (!isEmptyValue(value, ruleType)) {
1166
- rules.type(rule, value, source, errors, options);
1167
- }
1168
- }
1169
- callback(errors);
1170
- };
1171
- var any = function any2(rule, value, callback, source, options) {
1172
- var errors = [];
1173
- var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
1174
- if (validate) {
1175
- if (isEmptyValue(value) && !rule.required) {
1176
- return callback();
1177
- }
1178
- rules.required(rule, value, source, errors, options);
1179
- }
1180
- callback(errors);
1181
- };
1182
- var validators = {
1183
- string,
1184
- method: method2,
1185
- number: number2,
1186
- "boolean": _boolean,
1187
- regexp: regexp2,
1188
- integer: integer2,
1189
- "float": floatFn,
1190
- array: array2,
1191
- object: object2,
1192
- "enum": enumerable2,
1193
- pattern: pattern2,
1194
- date: date2,
1195
- url: type2,
1196
- hex: type2,
1197
- email: type2,
1198
- required: required2,
1199
- any
1200
- };
1201
- function newMessages() {
1202
- return {
1203
- "default": "Validation error on field %s",
1204
- required: "%s is required",
1205
- "enum": "%s must be one of %s",
1206
- whitespace: "%s cannot be empty",
1207
- date: {
1208
- format: "%s date %s is invalid for format %s",
1209
- parse: "%s date could not be parsed, %s is invalid ",
1210
- invalid: "%s date %s is invalid"
1211
- },
1212
- types: {
1213
- string: "%s is not a %s",
1214
- method: "%s is not a %s (function)",
1215
- array: "%s is not an %s",
1216
- object: "%s is not an %s",
1217
- number: "%s is not a %s",
1218
- date: "%s is not a %s",
1219
- "boolean": "%s is not a %s",
1220
- integer: "%s is not an %s",
1221
- "float": "%s is not a %s",
1222
- regexp: "%s is not a valid %s",
1223
- email: "%s is not a valid %s",
1224
- url: "%s is not a valid %s",
1225
- hex: "%s is not a valid %s"
1226
- },
1227
- string: {
1228
- len: "%s must be exactly %s characters",
1229
- min: "%s must be at least %s characters",
1230
- max: "%s cannot be longer than %s characters",
1231
- range: "%s must be between %s and %s characters"
1232
- },
1233
- number: {
1234
- len: "%s must equal %s",
1235
- min: "%s cannot be less than %s",
1236
- max: "%s cannot be greater than %s",
1237
- range: "%s must be between %s and %s"
1238
- },
1239
- array: {
1240
- len: "%s must be exactly %s in length",
1241
- min: "%s cannot be less than %s in length",
1242
- max: "%s cannot be greater than %s in length",
1243
- range: "%s must be between %s and %s in length"
1244
- },
1245
- pattern: {
1246
- mismatch: "%s value %s does not match pattern %s"
1247
- },
1248
- clone: function clone() {
1249
- var cloned = JSON.parse(JSON.stringify(this));
1250
- cloned.clone = this.clone;
1251
- return cloned;
1252
- }
1253
- };
1254
- }
1255
- var messages = newMessages();
1256
- var Schema = /* @__PURE__ */ function() {
1257
- function Schema2(descriptor) {
1258
- this.rules = null;
1259
- this._messages = messages;
1260
- this.define(descriptor);
1261
- }
1262
- var _proto = Schema2.prototype;
1263
- _proto.define = function define(rules2) {
1264
- var _this = this;
1265
- if (!rules2) {
1266
- throw new Error("Cannot configure a schema with no rules");
1267
- }
1268
- if (typeof rules2 !== "object" || Array.isArray(rules2)) {
1269
- throw new Error("Rules must be an object");
1270
- }
1271
- this.rules = {};
1272
- Object.keys(rules2).forEach(function(name) {
1273
- var item = rules2[name];
1274
- _this.rules[name] = Array.isArray(item) ? item : [item];
1275
- });
1276
- };
1277
- _proto.messages = function messages2(_messages) {
1278
- if (_messages) {
1279
- this._messages = deepMerge(newMessages(), _messages);
1280
- }
1281
- return this._messages;
1282
- };
1283
- _proto.validate = function validate(source_, o, oc) {
1284
- var _this2 = this;
1285
- if (o === void 0) {
1286
- o = {};
1287
- }
1288
- if (oc === void 0) {
1289
- oc = function oc2() {
1290
- };
1291
- }
1292
- var source = source_;
1293
- var options = o;
1294
- var callback = oc;
1295
- if (typeof options === "function") {
1296
- callback = options;
1297
- options = {};
1298
- }
1299
- if (!this.rules || Object.keys(this.rules).length === 0) {
1300
- if (callback) {
1301
- callback(null, source);
1302
- }
1303
- return Promise.resolve(source);
1304
- }
1305
- function complete(results) {
1306
- var errors = [];
1307
- var fields = {};
1308
- function add(e) {
1309
- if (Array.isArray(e)) {
1310
- var _errors;
1311
- errors = (_errors = errors).concat.apply(_errors, e);
1312
- } else {
1313
- errors.push(e);
1314
- }
1315
- }
1316
- for (var i = 0; i < results.length; i++) {
1317
- add(results[i]);
1318
- }
1319
- if (!errors.length) {
1320
- callback(null, source);
1321
- } else {
1322
- fields = convertFieldsError(errors);
1323
- callback(errors, fields);
1324
- }
1325
- }
1326
- if (options.messages) {
1327
- var messages$1 = this.messages();
1328
- if (messages$1 === messages) {
1329
- messages$1 = newMessages();
1330
- }
1331
- deepMerge(messages$1, options.messages);
1332
- options.messages = messages$1;
1333
- } else {
1334
- options.messages = this.messages();
1335
- }
1336
- var series = {};
1337
- var keys = options.keys || Object.keys(this.rules);
1338
- keys.forEach(function(z) {
1339
- var arr = _this2.rules[z];
1340
- var value = source[z];
1341
- arr.forEach(function(r) {
1342
- var rule = r;
1343
- if (typeof rule.transform === "function") {
1344
- if (source === source_) {
1345
- source = _extends({}, source);
1346
- }
1347
- value = source[z] = rule.transform(value);
1348
- }
1349
- if (typeof rule === "function") {
1350
- rule = {
1351
- validator: rule
1352
- };
1353
- } else {
1354
- rule = _extends({}, rule);
1355
- }
1356
- rule.validator = _this2.getValidationMethod(rule);
1357
- if (!rule.validator) {
1358
- return;
1359
- }
1360
- rule.field = z;
1361
- rule.fullField = rule.fullField || z;
1362
- rule.type = _this2.getType(rule);
1363
- series[z] = series[z] || [];
1364
- series[z].push({
1365
- rule,
1366
- value,
1367
- source,
1368
- field: z
1369
- });
1370
- });
1371
- });
1372
- var errorFields = {};
1373
- return asyncMap(series, options, function(data, doIt) {
1374
- var rule = data.rule;
1375
- var deep = (rule.type === "object" || rule.type === "array") && (typeof rule.fields === "object" || typeof rule.defaultField === "object");
1376
- deep = deep && (rule.required || !rule.required && data.value);
1377
- rule.field = data.field;
1378
- function addFullField(key, schema) {
1379
- return _extends({}, schema, {
1380
- fullField: rule.fullField + "." + key,
1381
- fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key]
1382
- });
1383
- }
1384
- function cb(e) {
1385
- if (e === void 0) {
1386
- e = [];
1387
- }
1388
- var errorList = Array.isArray(e) ? e : [e];
1389
- if (!options.suppressWarning && errorList.length) {
1390
- Schema2.warning("async-validator:", errorList);
1391
- }
1392
- if (errorList.length && rule.message !== void 0) {
1393
- errorList = [].concat(rule.message);
1394
- }
1395
- var filledErrors = errorList.map(complementError(rule, source));
1396
- if (options.first && filledErrors.length) {
1397
- errorFields[rule.field] = 1;
1398
- return doIt(filledErrors);
1399
- }
1400
- if (!deep) {
1401
- doIt(filledErrors);
1402
- } else {
1403
- if (rule.required && !data.value) {
1404
- if (rule.message !== void 0) {
1405
- filledErrors = [].concat(rule.message).map(complementError(rule, source));
1406
- } else if (options.error) {
1407
- filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
1408
- }
1409
- return doIt(filledErrors);
1410
- }
1411
- var fieldsSchema = {};
1412
- if (rule.defaultField) {
1413
- Object.keys(data.value).map(function(key) {
1414
- fieldsSchema[key] = rule.defaultField;
1415
- });
1416
- }
1417
- fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
1418
- var paredFieldsSchema = {};
1419
- Object.keys(fieldsSchema).forEach(function(field) {
1420
- var fieldSchema = fieldsSchema[field];
1421
- var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
1422
- paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
1423
- });
1424
- var schema = new Schema2(paredFieldsSchema);
1425
- schema.messages(options.messages);
1426
- if (data.rule.options) {
1427
- data.rule.options.messages = options.messages;
1428
- data.rule.options.error = options.error;
1429
- }
1430
- schema.validate(data.value, data.rule.options || options, function(errs) {
1431
- var finalErrors = [];
1432
- if (filledErrors && filledErrors.length) {
1433
- finalErrors.push.apply(finalErrors, filledErrors);
1434
- }
1435
- if (errs && errs.length) {
1436
- finalErrors.push.apply(finalErrors, errs);
1437
- }
1438
- doIt(finalErrors.length ? finalErrors : null);
1439
- });
1440
- }
1441
- }
1442
- var res;
1443
- if (rule.asyncValidator) {
1444
- res = rule.asyncValidator(rule, data.value, cb, data.source, options);
1445
- } else if (rule.validator) {
1446
- res = rule.validator(rule, data.value, cb, data.source, options);
1447
- if (res === true) {
1448
- cb();
1449
- } else if (res === false) {
1450
- cb(typeof rule.message === "function" ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails");
1451
- } else if (res instanceof Array) {
1452
- cb(res);
1453
- } else if (res instanceof Error) {
1454
- cb(res.message);
1455
- }
1456
- }
1457
- if (res && res.then) {
1458
- res.then(function() {
1459
- return cb();
1460
- }, function(e) {
1461
- return cb(e);
1462
- });
1463
- }
1464
- }, function(results) {
1465
- complete(results);
1466
- }, source);
1467
- };
1468
- _proto.getType = function getType(rule) {
1469
- if (rule.type === void 0 && rule.pattern instanceof RegExp) {
1470
- rule.type = "pattern";
1471
- }
1472
- if (typeof rule.validator !== "function" && rule.type && !validators.hasOwnProperty(rule.type)) {
1473
- throw new Error(format("Unknown rule type %s", rule.type));
1474
- }
1475
- return rule.type || "string";
1476
- };
1477
- _proto.getValidationMethod = function getValidationMethod(rule) {
1478
- if (typeof rule.validator === "function") {
1479
- return rule.validator;
1480
- }
1481
- var keys = Object.keys(rule);
1482
- var messageIndex = keys.indexOf("message");
1483
- if (messageIndex !== -1) {
1484
- keys.splice(messageIndex, 1);
1485
- }
1486
- if (keys.length === 1 && keys[0] === "required") {
1487
- return validators.required;
1488
- }
1489
- return validators[this.getType(rule)] || void 0;
1490
- };
1491
- return Schema2;
1492
- }();
1493
- Schema.register = function register(type4, validator) {
1494
- if (typeof validator !== "function") {
1495
- throw new Error("Cannot register a validator by type, validator is not a function");
1496
- }
1497
- validators[type4] = validator;
1498
- };
1499
- Schema.warning = warning;
1500
- Schema.messages = messages;
1501
- Schema.validators = validators;
1502
- var formItem = "";
1503
- var FormItem = defineComponent({
1504
- name: "DFormItem",
1505
- props: formItemProps,
1506
- setup(props, ctx2) {
1507
- const formItemMitt = mitt();
1508
- const dForm = reactive(inject(formInjectionKey, {}));
1509
- const formData = reactive(dForm.formData);
1510
- const columnsClass = ref(dForm.columnsClass);
1511
- const initFormItemData = formData[props.prop];
1512
- const labelData = reactive(dForm.labelData);
1513
- const rules2 = reactive(dForm.rules);
1514
- const resetField = () => {
1515
- if (Array.isArray(initFormItemData)) {
1516
- formData[props.prop] = [...initFormItemData];
1517
- } else {
1518
- formData[props.prop] = initFormItemData;
1519
- }
1520
- };
1521
- const formItem2 = reactive({
1522
- dHasFeedback: props.dHasFeedback,
1523
- prop: props.prop,
1524
- formItemMitt,
1525
- resetField
1526
- });
1527
- provide(formItemInjectionKey, formItem2);
1528
- const isHorizontal = labelData.layout === "horizontal";
1529
- const isVertical = labelData.layout === "vertical";
1530
- const isColumns = labelData.layout === "columns";
1531
- const showMessage = ref(false);
1532
- const tipMessage = ref("");
1533
- const validate = (trigger) => {
1534
- const ruleKey = props.prop;
1535
- const ruleItem = rules2[ruleKey];
1536
- const descriptor = {};
1537
- descriptor[ruleKey] = ruleItem;
1538
- const validator = new Schema(descriptor);
1539
- validator.validate({
1540
- [ruleKey]: formData[ruleKey]
1541
- }).then(() => {
1542
- showMessage.value = false;
1543
- tipMessage.value = "";
1544
- }).catch(({
1545
- errors
1546
- }) => {
1547
- showMessage.value = true;
1548
- tipMessage.value = errors[0].message;
1549
- });
1550
- };
1551
- const validateEvents = [];
1552
- const addValidateEvents = () => {
1553
- if (rules2 && rules2[props.prop]) {
1554
- const ruleItem = rules2[props.prop];
1555
- let eventName = ruleItem["trigger"];
1556
- if (Array.isArray(ruleItem)) {
1557
- ruleItem.forEach((item) => {
1558
- eventName = item["trigger"];
1559
- const cb = () => validate();
1560
- validateEvents.push({
1561
- eventName: cb
1562
- });
1563
- formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
1564
- });
1565
- } else {
1566
- const cb = () => validate();
1567
- validateEvents.push({
1568
- eventName: cb
1569
- });
1570
- ruleItem && formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
1571
- }
1572
- }
1573
- };
1574
- const removeValidateEvents = () => {
1575
- if (rules2 && rules2[props.prop] && validateEvents.length > 0) {
1576
- validateEvents.forEach((item) => {
1577
- formItem2.formItemMitt.off(item.eventName, item.cb);
1578
- });
1579
- }
1580
- };
1581
- onMounted(() => {
1582
- dForm.formMitt.emit(dFormEvents.addField, formItem2);
1583
- addValidateEvents();
1584
- });
1585
- onBeforeUnmount(() => {
1586
- dForm.formMitt.emit(dFormEvents.removeField, formItem2);
1587
- removeValidateEvents();
1588
- });
1589
- return () => {
1590
- var _a, _b;
1591
- return createVNode("div", {
1592
- "class": `form-item${isHorizontal ? "" : isVertical ? " form-item-vertical" : " form-item-columns"}${isColumns ? " column-item " + columnsClass.value : ""}`
1593
- }, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a), createVNode("div", {
1594
- "class": `d-validate-tip${isHorizontal ? " d-validate-tip-horizontal" : ""}`
1595
- }, [showMessage.value && tipMessage.value])]);
1596
- };
1597
- }
1598
- });
1599
112
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1600
113
  var lodash = { exports: {} };
1601
114
  /**
@@ -2026,9 +539,9 @@ var lodash = { exports: {} };
2026
539
  return result;
2027
540
  }
2028
541
  function arrayPush(array4, values) {
2029
- var index2 = -1, length = values.length, offset = array4.length;
542
+ var index2 = -1, length = values.length, offset2 = array4.length;
2030
543
  while (++index2 < length) {
2031
- array4[offset + index2] = values[index2];
544
+ array4[offset2 + index2] = values[index2];
2032
545
  }
2033
546
  return array4;
2034
547
  }
@@ -2776,7 +1289,7 @@ var lodash = { exports: {} };
2776
1289
  if (typeof func != "function") {
2777
1290
  throw new TypeError2(FUNC_ERROR_TEXT);
2778
1291
  }
2779
- return setTimeout2(function() {
1292
+ return setTimeout(function() {
2780
1293
  func.apply(undefined$1, args);
2781
1294
  }, wait);
2782
1295
  }
@@ -3556,7 +2069,7 @@ var lodash = { exports: {} };
3556
2069
  end = end === undefined$1 ? length : end;
3557
2070
  return !start && end >= length ? array4 : baseSlice(array4, start, end);
3558
2071
  }
3559
- var clearTimeout2 = ctxClearTimeout || function(id) {
2072
+ var clearTimeout = ctxClearTimeout || function(id) {
3560
2073
  return root.clearTimeout(id);
3561
2074
  };
3562
2075
  function cloneBuffer(buffer, isDeep) {
@@ -3635,13 +2148,13 @@ var lodash = { exports: {} };
3635
2148
  while (++argsIndex < rangeLength) {
3636
2149
  result2[argsIndex] = args[argsIndex];
3637
2150
  }
3638
- var offset = argsIndex;
2151
+ var offset2 = argsIndex;
3639
2152
  while (++rightIndex < rightLength) {
3640
- result2[offset + rightIndex] = partials[rightIndex];
2153
+ result2[offset2 + rightIndex] = partials[rightIndex];
3641
2154
  }
3642
2155
  while (++holdersIndex < holdersLength) {
3643
2156
  if (isUncurried || argsIndex < argsLength) {
3644
- result2[offset + holders[holdersIndex]] = args[argsIndex++];
2157
+ result2[offset2 + holders[holdersIndex]] = args[argsIndex++];
3645
2158
  }
3646
2159
  }
3647
2160
  return result2;
@@ -4585,7 +3098,7 @@ var lodash = { exports: {} };
4585
3098
  return object4[key];
4586
3099
  }
4587
3100
  var setData = shortOut(baseSetData);
4588
- var setTimeout2 = ctxSetTimeout || function(func, wait) {
3101
+ var setTimeout = ctxSetTimeout || function(func, wait) {
4589
3102
  return root.setTimeout(func, wait);
4590
3103
  };
4591
3104
  var setToString = shortOut(baseSetToString);
@@ -5356,7 +3869,7 @@ var lodash = { exports: {} };
5356
3869
  result2.placeholder = curryRight.placeholder;
5357
3870
  return result2;
5358
3871
  }
5359
- function debounce2(func, wait, options) {
3872
+ function debounce(func, wait, options) {
5360
3873
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
5361
3874
  if (typeof func != "function") {
5362
3875
  throw new TypeError2(FUNC_ERROR_TEXT);
@@ -5377,7 +3890,7 @@ var lodash = { exports: {} };
5377
3890
  }
5378
3891
  function leadingEdge(time) {
5379
3892
  lastInvokeTime = time;
5380
- timerId = setTimeout2(timerExpired, wait);
3893
+ timerId = setTimeout(timerExpired, wait);
5381
3894
  return leading ? invokeFunc(time) : result2;
5382
3895
  }
5383
3896
  function remainingWait(time) {
@@ -5393,7 +3906,7 @@ var lodash = { exports: {} };
5393
3906
  if (shouldInvoke(time)) {
5394
3907
  return trailingEdge(time);
5395
3908
  }
5396
- timerId = setTimeout2(timerExpired, remainingWait(time));
3909
+ timerId = setTimeout(timerExpired, remainingWait(time));
5397
3910
  }
5398
3911
  function trailingEdge(time) {
5399
3912
  timerId = undefined$1;
@@ -5405,7 +3918,7 @@ var lodash = { exports: {} };
5405
3918
  }
5406
3919
  function cancel() {
5407
3920
  if (timerId !== undefined$1) {
5408
- clearTimeout2(timerId);
3921
+ clearTimeout(timerId);
5409
3922
  }
5410
3923
  lastInvokeTime = 0;
5411
3924
  lastArgs = lastCallTime = lastThis = timerId = undefined$1;
@@ -5423,13 +3936,13 @@ var lodash = { exports: {} };
5423
3936
  return leadingEdge(lastCallTime);
5424
3937
  }
5425
3938
  if (maxing) {
5426
- clearTimeout2(timerId);
5427
- timerId = setTimeout2(timerExpired, wait);
3939
+ clearTimeout(timerId);
3940
+ timerId = setTimeout(timerExpired, wait);
5428
3941
  return invokeFunc(lastCallTime);
5429
3942
  }
5430
3943
  }
5431
3944
  if (timerId === undefined$1) {
5432
- timerId = setTimeout2(timerExpired, wait);
3945
+ timerId = setTimeout(timerExpired, wait);
5433
3946
  }
5434
3947
  return result2;
5435
3948
  }
@@ -5536,7 +4049,7 @@ var lodash = { exports: {} };
5536
4049
  leading = "leading" in options ? !!options.leading : leading;
5537
4050
  trailing = "trailing" in options ? !!options.trailing : trailing;
5538
4051
  }
5539
- return debounce2(func, wait, {
4052
+ return debounce(func, wait, {
5540
4053
  "leading": leading,
5541
4054
  "maxWait": wait,
5542
4055
  "trailing": trailing
@@ -6188,9 +4701,9 @@ var lodash = { exports: {} };
6188
4701
  var isEscaping, isEvaluating, index2 = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '";
6189
4702
  var reDelimiters = RegExp2((options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$", "g");
6190
4703
  var sourceURL = "//# sourceURL=" + (hasOwnProperty.call(options, "sourceURL") ? (options.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
6191
- string3.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
4704
+ string3.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset2) {
6192
4705
  interpolateValue || (interpolateValue = esTemplateValue);
6193
- source += string3.slice(index2, offset).replace(reUnescapedString, escapeStringChar);
4706
+ source += string3.slice(index2, offset2).replace(reUnescapedString, escapeStringChar);
6194
4707
  if (escapeValue) {
6195
4708
  isEscaping = true;
6196
4709
  source += "' +\n__e(" + escapeValue + ") +\n'";
@@ -6202,7 +4715,7 @@ var lodash = { exports: {} };
6202
4715
  if (interpolateValue) {
6203
4716
  source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
6204
4717
  }
6205
- index2 = offset + match.length;
4718
+ index2 = offset2 + match.length;
6206
4719
  return match;
6207
4720
  });
6208
4721
  source += "';\n";
@@ -6547,7 +5060,7 @@ var lodash = { exports: {} };
6547
5060
  lodash2.create = create;
6548
5061
  lodash2.curry = curry;
6549
5062
  lodash2.curryRight = curryRight;
6550
- lodash2.debounce = debounce2;
5063
+ lodash2.debounce = debounce;
6551
5064
  lodash2.defaults = defaults;
6552
5065
  lodash2.defaultsDeep = defaultsDeep;
6553
5066
  lodash2.defer = defer;
@@ -6898,576 +5411,2329 @@ var lodash = { exports: {} };
6898
5411
  if (typeof path == "function") {
6899
5412
  return new LazyWrapper(this);
6900
5413
  }
6901
- return this.map(function(value) {
6902
- return baseInvoke(value, path, args);
6903
- });
6904
- });
6905
- LazyWrapper.prototype.reject = function(predicate) {
6906
- return this.filter(negate(getIteratee(predicate)));
5414
+ return this.map(function(value) {
5415
+ return baseInvoke(value, path, args);
5416
+ });
5417
+ });
5418
+ LazyWrapper.prototype.reject = function(predicate) {
5419
+ return this.filter(negate(getIteratee(predicate)));
5420
+ };
5421
+ LazyWrapper.prototype.slice = function(start, end) {
5422
+ start = toInteger(start);
5423
+ var result2 = this;
5424
+ if (result2.__filtered__ && (start > 0 || end < 0)) {
5425
+ return new LazyWrapper(result2);
5426
+ }
5427
+ if (start < 0) {
5428
+ result2 = result2.takeRight(-start);
5429
+ } else if (start) {
5430
+ result2 = result2.drop(start);
5431
+ }
5432
+ if (end !== undefined$1) {
5433
+ end = toInteger(end);
5434
+ result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start);
5435
+ }
5436
+ return result2;
5437
+ };
5438
+ LazyWrapper.prototype.takeRightWhile = function(predicate) {
5439
+ return this.reverse().takeWhile(predicate).reverse();
5440
+ };
5441
+ LazyWrapper.prototype.toArray = function() {
5442
+ return this.take(MAX_ARRAY_LENGTH);
5443
+ };
5444
+ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
5445
+ var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash2[isTaker ? "take" + (methodName == "last" ? "Right" : "") : methodName], retUnwrapped = isTaker || /^find/.test(methodName);
5446
+ if (!lodashFunc) {
5447
+ return;
5448
+ }
5449
+ lodash2.prototype[methodName] = function() {
5450
+ var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray(value);
5451
+ var interceptor = function(value2) {
5452
+ var result3 = lodashFunc.apply(lodash2, arrayPush([value2], args));
5453
+ return isTaker && chainAll ? result3[0] : result3;
5454
+ };
5455
+ if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
5456
+ isLazy = useLazy = false;
5457
+ }
5458
+ var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
5459
+ if (!retUnwrapped && useLazy) {
5460
+ value = onlyLazy ? value : new LazyWrapper(this);
5461
+ var result2 = func.apply(value, args);
5462
+ result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined$1 });
5463
+ return new LodashWrapper(result2, chainAll);
5464
+ }
5465
+ if (isUnwrapped && onlyLazy) {
5466
+ return func.apply(this, args);
5467
+ }
5468
+ result2 = this.thru(interceptor);
5469
+ return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
5470
+ };
5471
+ });
5472
+ arrayEach(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
5473
+ var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
5474
+ lodash2.prototype[methodName] = function() {
5475
+ var args = arguments;
5476
+ if (retUnwrapped && !this.__chain__) {
5477
+ var value = this.value();
5478
+ return func.apply(isArray(value) ? value : [], args);
5479
+ }
5480
+ return this[chainName](function(value2) {
5481
+ return func.apply(isArray(value2) ? value2 : [], args);
5482
+ });
5483
+ };
5484
+ });
5485
+ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
5486
+ var lodashFunc = lodash2[methodName];
5487
+ if (lodashFunc) {
5488
+ var key = lodashFunc.name + "";
5489
+ if (!hasOwnProperty.call(realNames, key)) {
5490
+ realNames[key] = [];
5491
+ }
5492
+ realNames[key].push({ "name": methodName, "func": lodashFunc });
5493
+ }
5494
+ });
5495
+ realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
5496
+ "name": "wrapper",
5497
+ "func": undefined$1
5498
+ }];
5499
+ LazyWrapper.prototype.clone = lazyClone;
5500
+ LazyWrapper.prototype.reverse = lazyReverse;
5501
+ LazyWrapper.prototype.value = lazyValue;
5502
+ lodash2.prototype.at = wrapperAt;
5503
+ lodash2.prototype.chain = wrapperChain;
5504
+ lodash2.prototype.commit = wrapperCommit;
5505
+ lodash2.prototype.next = wrapperNext;
5506
+ lodash2.prototype.plant = wrapperPlant;
5507
+ lodash2.prototype.reverse = wrapperReverse;
5508
+ lodash2.prototype.toJSON = lodash2.prototype.valueOf = lodash2.prototype.value = wrapperValue;
5509
+ lodash2.prototype.first = lodash2.prototype.head;
5510
+ if (symIterator) {
5511
+ lodash2.prototype[symIterator] = wrapperToIterator;
5512
+ }
5513
+ return lodash2;
5514
+ };
5515
+ var _ = runInContext();
5516
+ if (freeModule) {
5517
+ (freeModule.exports = _)._ = _;
5518
+ freeExports._ = _;
5519
+ } else {
5520
+ root._ = _;
5521
+ }
5522
+ }).call(commonjsGlobal);
5523
+ })(lodash, lodash.exports);
5524
+ function useFormValidation(itemContexts) {
5525
+ const getValidateFields = (fields) => {
5526
+ if (!itemContexts.length) {
5527
+ return [];
5528
+ }
5529
+ const normalizedFields = lodash.exports.castArray(fields);
5530
+ const filteredFields = normalizedFields.length ? itemContexts.filter((context) => context.field && normalizedFields.includes(context.field)) : itemContexts;
5531
+ if (!filteredFields.length) {
5532
+ return [];
5533
+ }
5534
+ return filteredFields;
5535
+ };
5536
+ const execValidateFields = async (fields = []) => {
5537
+ const validateFields2 = getValidateFields(fields);
5538
+ if (!validateFields2.length) {
5539
+ return true;
5540
+ }
5541
+ let errors = {};
5542
+ for (const field of validateFields2) {
5543
+ try {
5544
+ await field.validate("");
5545
+ } catch (err) {
5546
+ errors = __spreadValues(__spreadValues({}, errors), err);
5547
+ }
5548
+ }
5549
+ if (!Object.keys(errors).length) {
5550
+ return true;
5551
+ }
5552
+ return Promise.reject(errors);
5553
+ };
5554
+ const validateFields = async (fields = [], callback) => {
5555
+ try {
5556
+ const result = await execValidateFields(fields);
5557
+ if (result) {
5558
+ callback == null ? void 0 : callback(result);
5559
+ }
5560
+ return result;
5561
+ } catch (err) {
5562
+ const invalidFields = err;
5563
+ callback == null ? void 0 : callback(false, invalidFields);
5564
+ return !callback && Promise.reject(invalidFields);
5565
+ }
5566
+ };
5567
+ const validate = async (callback) => validateFields(void 0, callback);
5568
+ const clearValidate = (fields = []) => {
5569
+ getValidateFields(fields).forEach((field) => field.clearValidate());
5570
+ };
5571
+ const resetFields = (fields = []) => {
5572
+ getValidateFields(fields).forEach((field) => field.resetField());
5573
+ };
5574
+ return { validate, validateFields, resetFields, clearValidate };
5575
+ }
5576
+ var Form = defineComponent({
5577
+ name: "DForm",
5578
+ props: formProps,
5579
+ emits: ["validate"],
5580
+ setup(props, ctx) {
5581
+ const ns2 = useNamespace("form");
5582
+ const {
5583
+ itemContexts,
5584
+ addItemContext,
5585
+ removeItemContext
5586
+ } = useFieldCollection();
5587
+ const {
5588
+ validate,
5589
+ validateFields,
5590
+ resetFields,
5591
+ clearValidate
5592
+ } = useFormValidation(itemContexts);
5593
+ const onSubmit = (e) => {
5594
+ e.preventDefault();
5595
+ };
5596
+ watch(() => props.rules, () => {
5597
+ if (props.validateOnRuleChange) {
5598
+ validate();
5599
+ }
5600
+ }, {
5601
+ deep: true
5602
+ });
5603
+ provide(FORM_TOKEN, reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
5604
+ emit: ctx.emit,
5605
+ addItemContext,
5606
+ removeItemContext
5607
+ })));
5608
+ ctx.expose({
5609
+ validate,
5610
+ validateFields,
5611
+ resetFields,
5612
+ clearValidate
5613
+ });
5614
+ return () => {
5615
+ var _a, _b;
5616
+ return createVNode("form", {
5617
+ "onSubmit": onSubmit,
5618
+ "class": ns2.b()
5619
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
5620
+ };
5621
+ }
5622
+ });
5623
+ const formItemProps = {
5624
+ label: {
5625
+ type: String
5626
+ },
5627
+ field: {
5628
+ type: String,
5629
+ default: ""
5630
+ },
5631
+ required: {
5632
+ type: Boolean,
5633
+ default: false
5634
+ },
5635
+ messageType: {
5636
+ type: String
5637
+ },
5638
+ popPosition: {
5639
+ type: Array
5640
+ },
5641
+ rules: {
5642
+ type: [Object, Array]
5643
+ },
5644
+ showFeedback: {
5645
+ type: Boolean,
5646
+ default: void 0
5647
+ },
5648
+ helpTips: {
5649
+ type: String,
5650
+ default: ""
5651
+ },
5652
+ feedbackStatus: {
5653
+ type: String
5654
+ },
5655
+ extraInfo: {
5656
+ type: String,
5657
+ default: ""
5658
+ }
5659
+ };
5660
+ const FORM_ITEM_TOKEN = Symbol("dFormItem");
5661
+ const LABEL_DATA = Symbol("labelData");
5662
+ const formLabelProps = {
5663
+ helpTips: {
5664
+ type: String,
5665
+ default: ""
5666
+ }
5667
+ };
5668
+ const fixedOverlayProps = {
5669
+ modelValue: {
5670
+ type: Boolean,
5671
+ default: false
5672
+ },
5673
+ lockScroll: {
5674
+ type: Boolean,
5675
+ default: true
5676
+ },
5677
+ closeOnClickOverlay: {
5678
+ type: Boolean,
5679
+ default: true
5680
+ }
5681
+ };
5682
+ function lockScroll() {
5683
+ if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
5684
+ const scrollTop = document.documentElement.scrollTop;
5685
+ const style = document.documentElement.getAttribute("style");
5686
+ document.documentElement.style.position = "fixed";
5687
+ document.documentElement.style.top = `-${scrollTop}px`;
5688
+ document.documentElement.style.width = document.documentElement.style.width || "100%";
5689
+ document.documentElement.style.overflowY = "scroll";
5690
+ return () => {
5691
+ if (style) {
5692
+ document.documentElement.setAttribute("style", style);
5693
+ } else {
5694
+ document.documentElement.removeAttribute("style");
5695
+ }
5696
+ document.documentElement.scrollTop = scrollTop;
5697
+ };
5698
+ }
5699
+ return;
5700
+ }
5701
+ function useFixedOverlay(props, ctx) {
5702
+ let lockScrollCb;
5703
+ const onClick = (event) => {
5704
+ event.preventDefault();
5705
+ ctx.emit("click", event);
5706
+ if (props.closeOnClickOverlay) {
5707
+ ctx.emit("update:modelValue", false);
5708
+ }
5709
+ };
5710
+ const removeBodyAdditions = () => {
5711
+ lockScrollCb == null ? void 0 : lockScrollCb();
5712
+ };
5713
+ watch(() => props.modelValue, (val) => {
5714
+ if (val) {
5715
+ props.lockScroll && (lockScrollCb = lockScroll());
5716
+ } else {
5717
+ removeBodyAdditions();
5718
+ }
5719
+ });
5720
+ onUnmounted(removeBodyAdditions);
5721
+ return { onClick };
5722
+ }
5723
+ var fixedOverlay = "";
5724
+ defineComponent({
5725
+ name: "DFixedOverlay",
5726
+ inheritAttrs: false,
5727
+ props: fixedOverlayProps,
5728
+ emits: ["update:modelValue", "click"],
5729
+ setup(props, ctx) {
5730
+ const {
5731
+ modelValue
5732
+ } = toRefs(props);
5733
+ const ns2 = useNamespace("fixed-overlay");
5734
+ const {
5735
+ onClick
5736
+ } = useFixedOverlay(props, ctx);
5737
+ return () => createVNode(Transition, {
5738
+ "name": ns2.m("fade")
5739
+ }, {
5740
+ default: () => {
5741
+ var _a, _b;
5742
+ return [modelValue.value && createVNode("div", mergeProps({
5743
+ "class": ns2.b()
5744
+ }, ctx.attrs, {
5745
+ "onClick": onClick
5746
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
5747
+ }
5748
+ });
5749
+ }
5750
+ });
5751
+ const flexibleOverlayProps = {
5752
+ modelValue: {
5753
+ type: Boolean,
5754
+ default: false
5755
+ },
5756
+ origin: {
5757
+ type: Object,
5758
+ require: true
5759
+ },
5760
+ position: {
5761
+ type: Array,
5762
+ default: ["bottom"]
5763
+ },
5764
+ offset: {
5765
+ type: [Number, Object],
5766
+ default: 8
5767
+ },
5768
+ shiftOffset: {
5769
+ type: Number
5770
+ },
5771
+ align: {
5772
+ type: String,
5773
+ default: null
5774
+ },
5775
+ showArrow: {
5776
+ type: Boolean,
5777
+ default: false
5778
+ },
5779
+ isArrowCenter: {
5780
+ type: Boolean,
5781
+ default: true
5782
+ }
5783
+ };
5784
+ function getScrollParent(element) {
5785
+ const overflowRegex = /(auto|scroll|hidden)/;
5786
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
5787
+ const style = window.getComputedStyle(parent);
5788
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
5789
+ return parent;
5790
+ }
5791
+ }
5792
+ return window;
5793
+ }
5794
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
5795
+ let { x, y } = point;
5796
+ if (!isArrowCenter) {
5797
+ const { width, height } = originRect;
5798
+ if (x && placement.includes("start")) {
5799
+ x = 12;
5800
+ }
5801
+ if (x && placement.includes("end")) {
5802
+ x = Math.round(width - 24);
5803
+ }
5804
+ if (y && placement.includes("start")) {
5805
+ y = 10;
5806
+ }
5807
+ if (y && placement.includes("end")) {
5808
+ y = height - 14;
5809
+ }
5810
+ }
5811
+ return { x, y };
5812
+ }
5813
+ function useOverlay(props, emit) {
5814
+ const overlayRef = ref();
5815
+ const arrowRef = ref();
5816
+ let originParent = null;
5817
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
5818
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
5819
+ const staticSide = {
5820
+ top: "bottom",
5821
+ right: "left",
5822
+ bottom: "top",
5823
+ left: "right"
5824
+ }[placement.split("-")[0]];
5825
+ Object.assign(arrowEl.style, {
5826
+ left: x ? `${x}px` : "",
5827
+ top: y ? `${y}px` : "",
5828
+ right: "",
5829
+ bottom: "",
5830
+ [staticSide]: "-4px"
5831
+ });
5832
+ };
5833
+ const updatePosition = async () => {
5834
+ const hostEl = props.origin;
5835
+ const overlayEl = unref(overlayRef.value);
5836
+ const arrowEl = unref(arrowRef.value);
5837
+ const middleware = [
5838
+ offset(props.offset),
5839
+ autoPlacement({
5840
+ alignment: props.align,
5841
+ allowedPlacements: props.position
5842
+ })
5843
+ ];
5844
+ props.showArrow && middleware.push(arrow({ element: arrowEl }));
5845
+ props.shiftOffset !== void 0 && middleware.push(shift());
5846
+ const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
5847
+ strategy: "fixed",
5848
+ middleware
5849
+ });
5850
+ let applyX = x;
5851
+ let applyY = y;
5852
+ if (props.shiftOffset !== void 0) {
5853
+ const { x: shiftX, y: shiftY } = middlewareData.shift;
5854
+ shiftX < 0 && (applyX -= props.shiftOffset);
5855
+ shiftX > 0 && (applyX += props.shiftOffset);
5856
+ shiftY < 0 && (applyY -= props.shiftOffset);
5857
+ shiftY > 0 && (applyY += props.shiftOffset);
5858
+ }
5859
+ emit("positionChange", placement);
5860
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
5861
+ props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
5862
+ };
5863
+ watch(() => props.modelValue, () => {
5864
+ if (props.modelValue && props.origin) {
5865
+ originParent = getScrollParent(props.origin);
5866
+ nextTick(updatePosition);
5867
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
5868
+ originParent !== window && window.addEventListener("scroll", updatePosition);
5869
+ window.addEventListener("resize", updatePosition);
5870
+ } else {
5871
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
5872
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
5873
+ window.removeEventListener("resize", updatePosition);
5874
+ }
5875
+ });
5876
+ onUnmounted(() => {
5877
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
5878
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
5879
+ window.removeEventListener("resize", updatePosition);
5880
+ });
5881
+ return { arrowRef, overlayRef, updatePosition };
5882
+ }
5883
+ var flexibleOverlay = "";
5884
+ const FlexibleOverlay = defineComponent({
5885
+ name: "DFlexibleOverlay",
5886
+ inheritAttrs: false,
5887
+ props: flexibleOverlayProps,
5888
+ emits: ["update:modelValue", "positionChange"],
5889
+ setup(props, {
5890
+ slots,
5891
+ attrs,
5892
+ emit,
5893
+ expose
5894
+ }) {
5895
+ const ns2 = useNamespace("flexible-overlay");
5896
+ const {
5897
+ arrowRef,
5898
+ overlayRef,
5899
+ updatePosition
5900
+ } = useOverlay(props, emit);
5901
+ expose({
5902
+ updatePosition
5903
+ });
5904
+ return () => {
5905
+ var _a;
5906
+ return props.modelValue && createVNode("div", mergeProps({
5907
+ "ref": overlayRef,
5908
+ "class": ns2.b()
5909
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
5910
+ "ref": arrowRef,
5911
+ "class": ns2.e("arrow")
5912
+ }, null)]);
5913
+ };
5914
+ }
5915
+ });
5916
+ const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
5917
+ const isObject = (val) => val !== null && typeof val === "object";
5918
+ const ns$1 = useNamespace("popper-trigger");
5919
+ function wrapContent(content) {
5920
+ return h("span", { class: ns$1.b() }, content);
5921
+ }
5922
+ function getFirstValidChild(nodes) {
5923
+ for (const child of nodes) {
5924
+ if (isObject(child)) {
5925
+ if (child.type === Comment) {
5926
+ continue;
5927
+ }
5928
+ if (child.type === "svg" || child.type === Text) {
5929
+ return wrapContent(child);
5930
+ }
5931
+ if (child.type === Fragment) {
5932
+ return getFirstValidChild(child.children);
5933
+ }
5934
+ return child;
5935
+ }
5936
+ return wrapContent(child);
5937
+ }
5938
+ return null;
5939
+ }
5940
+ var PopperTrigger = defineComponent({
5941
+ name: "DPopperTrigger",
5942
+ setup(_, ctx) {
5943
+ const {
5944
+ slots,
5945
+ attrs
5946
+ } = ctx;
5947
+ return () => {
5948
+ var _a;
5949
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
5950
+ const triggerRef = inject(POPPER_TRIGGER_TOKEN);
5951
+ if (!defaultSlot) {
5952
+ return null;
5953
+ }
5954
+ const firstValidChild = getFirstValidChild(defaultSlot);
5955
+ if (!firstValidChild) {
5956
+ return null;
5957
+ }
5958
+ return withDirectives(cloneVNode(firstValidChild, attrs), [[{
5959
+ mounted(el) {
5960
+ triggerRef.value = el;
5961
+ },
5962
+ updated(el) {
5963
+ triggerRef.value = el;
5964
+ },
5965
+ unmounted() {
5966
+ triggerRef.value = null;
5967
+ }
5968
+ }]]);
5969
+ };
5970
+ }
5971
+ });
5972
+ const popoverProps = {
5973
+ isOpen: {
5974
+ type: Boolean,
5975
+ default: false
5976
+ },
5977
+ position: {
5978
+ type: Array,
5979
+ default: ["bottom"]
5980
+ },
5981
+ align: {
5982
+ type: String,
5983
+ default: null
5984
+ },
5985
+ offset: {
5986
+ type: [Number, Object],
5987
+ default: 8
5988
+ },
5989
+ content: {
5990
+ type: String,
5991
+ default: ""
5992
+ },
5993
+ trigger: {
5994
+ type: String,
5995
+ default: "click"
5996
+ },
5997
+ popType: {
5998
+ type: String,
5999
+ default: "default"
6000
+ },
6001
+ showAnimation: {
6002
+ type: Boolean,
6003
+ default: true
6004
+ },
6005
+ mouseEnterDelay: {
6006
+ type: Number,
6007
+ default: 150
6008
+ },
6009
+ mouseLeaveDelay: {
6010
+ type: Number,
6011
+ default: 100
6012
+ },
6013
+ disabled: {
6014
+ type: Boolean,
6015
+ default: false
6016
+ }
6017
+ };
6018
+ const TransformOriginMap = {
6019
+ top: "50% calc(100% + 8px)",
6020
+ bottom: "50% -8px",
6021
+ left: "calc(100% + 8px)",
6022
+ right: "-8px 50%"
6023
+ };
6024
+ function usePopover(props, visible, placement, origin, popoverRef) {
6025
+ const { trigger, isOpen } = toRefs(props);
6026
+ const overlayStyles = computed(() => ({
6027
+ zIndex: 1060,
6028
+ transformOrigin: TransformOriginMap[placement.value]
6029
+ }));
6030
+ const onDocumentClick = (e) => {
6031
+ var _a, _b;
6032
+ if (!((_a = origin.value) == null ? void 0 : _a.contains(e.target)) && !((_b = popoverRef.value.$el) == null ? void 0 : _b.contains(e.target))) {
6033
+ visible.value = false;
6034
+ }
6035
+ };
6036
+ watch(isOpen, (isOpenVal) => {
6037
+ visible.value = isOpenVal;
6038
+ });
6039
+ watch(visible, () => {
6040
+ if (visible.value && trigger.value !== "manually") {
6041
+ document.addEventListener("click", onDocumentClick);
6042
+ } else {
6043
+ document.removeEventListener("click", onDocumentClick);
6044
+ }
6045
+ });
6046
+ onUnmounted(() => {
6047
+ document.removeEventListener("click", onDocumentClick);
6048
+ });
6049
+ return { overlayStyles };
6050
+ }
6051
+ function usePopoverEvent(props, visible, origin) {
6052
+ const { trigger, position, mouseEnterDelay, mouseLeaveDelay, disabled } = toRefs(props);
6053
+ const isClick = computed(() => trigger.value === "click");
6054
+ const placement = ref(position.value[0].split("-")[0]);
6055
+ const isEnter = ref(false);
6056
+ const onClick = () => {
6057
+ if (disabled.value) {
6058
+ return;
6059
+ }
6060
+ isClick.value && (visible.value = !visible.value);
6061
+ };
6062
+ const enter = lodash.exports.debounce(() => {
6063
+ isEnter.value && (visible.value = true);
6064
+ }, mouseEnterDelay.value);
6065
+ const leave = lodash.exports.debounce(() => {
6066
+ !isEnter.value && (visible.value = false);
6067
+ }, mouseLeaveDelay.value);
6068
+ const onMouseenter = () => {
6069
+ if (disabled.value) {
6070
+ return;
6071
+ }
6072
+ if (!isClick.value) {
6073
+ isEnter.value = true;
6074
+ enter();
6075
+ }
6076
+ };
6077
+ const onMouseleave = () => {
6078
+ if (!isClick.value) {
6079
+ isEnter.value = false;
6080
+ leave();
6081
+ }
6082
+ };
6083
+ const quickLeave = () => {
6084
+ isEnter.value = false;
6085
+ visible.value = false;
6086
+ };
6087
+ watch(disabled, (newVal) => {
6088
+ if (newVal && visible.value) {
6089
+ quickLeave();
6090
+ }
6091
+ });
6092
+ const handlePositionChange = (pos) => {
6093
+ placement.value = pos.split("-")[0];
6094
+ };
6095
+ onMounted(() => {
6096
+ if (trigger.value === "click") {
6097
+ origin.value.addEventListener("click", onClick);
6098
+ } else if (trigger.value === "hover") {
6099
+ origin.value.addEventListener("mouseenter", onMouseenter);
6100
+ origin.value.addEventListener("mouseleave", onMouseleave);
6101
+ }
6102
+ });
6103
+ return { placement, handlePositionChange, onMouseenter, onMouseleave };
6104
+ }
6105
+ const ns = useNamespace("popover");
6106
+ function SuccessIcon$1() {
6107
+ return createVNode("svg", {
6108
+ "class": [ns.e("icon"), ns.em("icon", "success")],
6109
+ "viewBox": "0 0 16 16",
6110
+ "version": "1.1",
6111
+ "xmlns": "http://www.w3.org/2000/svg"
6112
+ }, [createVNode("g", {
6113
+ "stroke": "none",
6114
+ "stroke-width": "1",
6115
+ "fill": "none",
6116
+ "fill-rule": "evenodd"
6117
+ }, [createVNode("circle", {
6118
+ "cx": "8",
6119
+ "cy": "8",
6120
+ "r": "7"
6121
+ }, null), createVNode("path", {
6122
+ "d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z",
6123
+ "fill-rule": "nonzero"
6124
+ }, null), createVNode("polygon", {
6125
+ "stroke-width": "0.4",
6126
+ "fill-rule": "nonzero",
6127
+ "points": "8.16 10.48 7.32 11.32 6.48 10.48 6.48 10.48 3.6 7.68 4.44 6.84 7.28 9.68 11.52 5.44 12.36 6.28"
6128
+ }, null)])]);
6129
+ }
6130
+ function WarningIcon() {
6131
+ return createVNode("svg", {
6132
+ "class": [ns.e("icon"), ns.em("icon", "warning")],
6133
+ "viewBox": "0 0 16 16",
6134
+ "version": "1.1",
6135
+ "xmlns": "http://www.w3.org/2000/svg"
6136
+ }, [createVNode("g", {
6137
+ "stroke": "none",
6138
+ "stroke-width": "1",
6139
+ "fill": "none",
6140
+ "fill-rule": "evenodd"
6141
+ }, [createVNode("polygon", {
6142
+ "points": "7.5 1.74501946 1.39184847 13.5954649 7.08947368 14.2207621 13.9973698 13.5954649 10.9383683 5.61273879 8.40084114 1.27624313"
6143
+ }, null), createVNode("path", {
6144
+ "d": "M8.51325441,0.127397589 C8.70423071,0.228333932 8.8605922,0.383286648 8.96244623,0.57254229 L15.8714442,13.4101975 C16.1549662,13.9370117 15.9538562,14.5918482 15.4222523,14.8728158 C15.2642579,14.9563203 15.0879506,15 14.9088903,15 L1.09089441,15 C0.488410063,15 0,14.5159904 0,13.9189343 C0,13.7414873 0.0440768395,13.5667684 0.128340519,13.4101975 L7.03733844,0.57254229 C7.32086049,0.0457280838 7.98165058,-0.153569987 8.51325441,0.127397589 Z M8.87894737,11.2105263 L7.08947368,11.2105263 L7.08947368,13 L8.87894737,13 L8.87894737,11.2105263 Z M8.96842105,4.5 L7,4.5 L7.08947368,9.86842105 L8.87894737,9.86842105 L8.96842105,4.5 Z"
6145
+ }, null)])]);
6146
+ }
6147
+ function InfoIcon() {
6148
+ return createVNode("svg", {
6149
+ "class": [ns.e("icon"), ns.em("icon", "info")],
6150
+ "viewBox": "0 0 16 16",
6151
+ "version": "1.1",
6152
+ "xmlns": "http://www.w3.org/2000/svg"
6153
+ }, [createVNode("g", {
6154
+ "stroke": "none",
6155
+ "stroke-width": "1",
6156
+ "fill": "none",
6157
+ "fill-rule": "evenodd"
6158
+ }, [createVNode("circle", {
6159
+ "cx": "8",
6160
+ "cy": "8",
6161
+ "r": "7"
6162
+ }, null), createVNode("g", {
6163
+ "stroke-width": "1"
6164
+ }, [createVNode("path", {
6165
+ "d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z M9,5 L7,5 L7,3 L9,3 L9,5 Z M9,12.6 L7,12.6 L7,6.6 L9,6.6 L9,12.6 Z"
6166
+ }, null)])])]);
6167
+ }
6168
+ function ErrorIcon$1() {
6169
+ return createVNode("svg", {
6170
+ "class": [ns.e("icon"), ns.em("icon", "error")],
6171
+ "width": "16px",
6172
+ "height": "16px",
6173
+ "viewBox": "0 0 16 16",
6174
+ "version": "1.1",
6175
+ "xmlns": "http://www.w3.org/2000/svg"
6176
+ }, [createVNode("g", {
6177
+ "stroke": "none",
6178
+ "stroke-width": "1",
6179
+ "fill": "none",
6180
+ "fill-rule": "evenodd"
6181
+ }, [createVNode("circle", {
6182
+ "cx": "8",
6183
+ "cy": "8",
6184
+ "r": "7"
6185
+ }, null), createVNode("path", {
6186
+ "d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z M9,12.6 L7,12.6 L7,10.6 L9,10.6 L9,12.6 Z M9,9.1 L7,9.1 L6.9,3.1 L9.1,3.1 L9,9.1 Z",
6187
+ "fill-rule": "nonzero"
6188
+ }, null)])]);
6189
+ }
6190
+ var popoverIcon = "";
6191
+ var PopoverIcon = defineComponent({
6192
+ props: {
6193
+ type: {
6194
+ type: String,
6195
+ default: "default"
6196
+ }
6197
+ },
6198
+ setup(props) {
6199
+ const ns2 = useNamespace("popover");
6200
+ return () => props.type && props.type !== "default" && createVNode("span", {
6201
+ "class": ns2.e("icon-wrap")
6202
+ }, [props.type === "success" && createVNode(SuccessIcon$1, null, null), props.type === "warning" && createVNode(WarningIcon, null, null), props.type === "info" && createVNode(InfoIcon, null, null), props.type === "error" && createVNode(ErrorIcon$1, null, null)]);
6203
+ }
6204
+ });
6205
+ var popover = "";
6206
+ var Popover = defineComponent({
6207
+ name: "DPopover",
6208
+ inheritAttrs: false,
6209
+ props: popoverProps,
6210
+ emits: ["show", "hide"],
6211
+ setup(props, {
6212
+ slots,
6213
+ attrs,
6214
+ emit
6215
+ }) {
6216
+ const {
6217
+ content,
6218
+ popType,
6219
+ position,
6220
+ align,
6221
+ offset: offset2,
6222
+ showAnimation
6223
+ } = toRefs(props);
6224
+ const origin = ref();
6225
+ const popoverRef = ref();
6226
+ const visible = ref(false);
6227
+ const {
6228
+ placement,
6229
+ handlePositionChange,
6230
+ onMouseenter,
6231
+ onMouseleave
6232
+ } = usePopoverEvent(props, visible, origin);
6233
+ const {
6234
+ overlayStyles
6235
+ } = usePopover(props, visible, placement, origin, popoverRef);
6236
+ const ns2 = useNamespace("popover");
6237
+ provide(POPPER_TRIGGER_TOKEN, origin);
6238
+ watch(visible, (newVal) => {
6239
+ if (newVal) {
6240
+ emit("show");
6241
+ } else {
6242
+ emit("hide");
6243
+ }
6244
+ });
6245
+ return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
6246
+ default: () => {
6247
+ var _a;
6248
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
6249
+ }
6250
+ }), createVNode(Teleport, {
6251
+ "to": "body"
6252
+ }, {
6253
+ default: () => [createVNode(Transition, {
6254
+ "name": showAnimation.value ? ns2.m(`fade-${placement.value}`) : ""
6255
+ }, {
6256
+ default: () => [createVNode(FlexibleOverlay, mergeProps({
6257
+ "modelValue": visible.value,
6258
+ "onUpdate:modelValue": ($event) => visible.value = $event,
6259
+ "ref": popoverRef,
6260
+ "origin": origin.value,
6261
+ "position": position.value,
6262
+ "align": align.value,
6263
+ "offset": offset2.value,
6264
+ "class": [ns2.e("content"), popType.value !== "default" ? "is-icon" : ""],
6265
+ "show-arrow": true,
6266
+ "is-arrow-center": false,
6267
+ "style": overlayStyles.value
6268
+ }, attrs, {
6269
+ "onPositionChange": handlePositionChange,
6270
+ "onClick": withModifiers(() => ({}), ["stop"]),
6271
+ "onPointerup": withModifiers(() => ({}), ["stop"]),
6272
+ "onMouseenter": onMouseenter,
6273
+ "onMouseleave": onMouseleave
6274
+ }), {
6275
+ default: () => {
6276
+ var _a;
6277
+ return [createVNode(PopoverIcon, {
6278
+ "type": popType.value
6279
+ }, null), ((_a = slots.content) == null ? void 0 : _a.call(slots)) || createVNode("span", null, [content.value])];
6280
+ }
6281
+ })]
6282
+ })]
6283
+ })]);
6284
+ }
6285
+ });
6286
+ function HelpTipsIcon() {
6287
+ return createVNode("svg", {
6288
+ "width": "16px",
6289
+ "height": "16px",
6290
+ "viewBox": "0 0 16 16"
6291
+ }, [createVNode("g", {
6292
+ "stroke": "none",
6293
+ "stroke-width": "1",
6294
+ "fill": "none",
6295
+ "fill-rule": "evenodd"
6296
+ }, [createVNode("g", null, [createVNode("path", {
6297
+ "d": "M8.5,8.95852078 L8.5,11 L7.5,11 L7.5,8.5 C7.5,8.22385763 7.72385763,8 8,8 C9.1045695,8 10,7.1045695 10,6 C10,4.8954305 9.1045695,4 8,4 C6.8954305,4 6,4.8954305 6,6 L5,6 C5,4.34314575 6.34314575,3 8,3 C9.65685425,3 11,4.34314575 11,6 C11,7.48649814 9.91885667,8.72048173 8.5,8.95852078 L8.5,8.95852078 Z M8,16 C3.581722,16 0,12.418278 0,8 C0,3.581722 3.581722,0 8,0 C12.418278,0 16,3.581722 16,8 C16,12.418278 12.418278,16 8,16 Z M8,15 C11.8659932,15 15,11.8659932 15,8 C15,4.13400675 11.8659932,1 8,1 C4.13400675,1 1,4.13400675 1,8 C1,11.8659932 4.13400675,15 8,15 Z M7.5,12 L8.5,12 L8.5,13 L7.5,13 L7.5,12 Z",
6298
+ "fill": "#293040",
6299
+ "fill-rule": "nonzero"
6300
+ }, null)])])]);
6301
+ }
6302
+ function ErrorIcon() {
6303
+ return createVNode("svg", {
6304
+ "width": "14px",
6305
+ "height": "14px",
6306
+ "viewBox": "0 0 16 16"
6307
+ }, [createVNode("g", {
6308
+ "stroke": "none",
6309
+ "stroke-width": "1",
6310
+ "fill": "none",
6311
+ "fill-rule": "evenodd"
6312
+ }, [createVNode("circle", {
6313
+ "cx": "8",
6314
+ "cy": "8",
6315
+ "r": "8"
6316
+ }, null), createVNode("polygon", {
6317
+ "points": "8.07106781 6.65685425 10.8994949 3.82842712 12.3137085 5.24264069 9.48528137 8.07106781 12.3137085 10.8994949 10.8994949 12.3137085 8.07106781 9.48528137 5.24264069 12.3137085 3.82842712 10.8994949 6.65685425 8.07106781 3.82842712 5.24264069 5.24264069 3.82842712"
6318
+ }, null)])]);
6319
+ }
6320
+ function SuccessIcon() {
6321
+ return createVNode("svg", {
6322
+ "width": "14px",
6323
+ "height": "14px",
6324
+ "viewBox": "0 0 16 16"
6325
+ }, [createVNode("g", {
6326
+ "stroke": "none",
6327
+ "stroke-width": "1",
6328
+ "fill": "none",
6329
+ "fill-rule": "evenodd"
6330
+ }, [createVNode("circle", {
6331
+ "cx": "8",
6332
+ "cy": "8",
6333
+ "r": "8"
6334
+ }, null), createVNode("polygon", {
6335
+ "points": "6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459"
6336
+ }, null)])]);
6337
+ }
6338
+ function PendingIcon() {
6339
+ return createVNode("svg", {
6340
+ "width": "14px",
6341
+ "height": "14px",
6342
+ "viewBox": "0 0 16 16"
6343
+ }, [createVNode("g", {
6344
+ "id": "loading",
6345
+ "stroke": "none",
6346
+ "stroke-width": "1",
6347
+ "fill": "none",
6348
+ "fill-rule": "evenodd"
6349
+ }, [createVNode("path", {
6350
+ "d": "M8,0 C12.4,0 16,3.6 16,8 C16,12.4 12.4,16 8,16 C3.6,16 0,12.4 0,8 C0,3.6 3.6,0 8,0 Z M8,1 C4.15,1 1,4.15 1,8 C1,11.85 4.15,15 8,15 C11.85,15 15,11.85 15,8 C15,4.15 11.85,1 8,1 Z",
6351
+ "fill-rule": "nonzero"
6352
+ }, null), createVNode("path", {
6353
+ "d": "M8,0 C12.4,0 16,3.6 16,8 L15,8 C15,4.15 11.85,1 8,1 L8,0 Z",
6354
+ "fill-rule": "nonzero"
6355
+ }, null)])]);
6356
+ }
6357
+ function useFormLabel() {
6358
+ const formItemContext = inject(FORM_ITEM_TOKEN);
6359
+ const labelData = inject(LABEL_DATA);
6360
+ const ns2 = useNamespace("form");
6361
+ const labelClasses = computed(() => ({
6362
+ [`${ns2.e("label")}`]: true,
6363
+ [`${ns2.em("label", "vertical")}`]: labelData.value.layout === "vertical",
6364
+ [`${ns2.em("label", labelData.value.labelSize)}`]: labelData.value.layout === "horizontal",
6365
+ [`${ns2.em("label", labelData.value.labelAlign)}`]: labelData.value.layout === "horizontal"
6366
+ }));
6367
+ const labelInnerClasses = computed(() => ({
6368
+ [`${ns2.e("label-span")}`]: true,
6369
+ [`${ns2.em("label", "required")}`]: formItemContext.isRequired
6370
+ }));
6371
+ return { labelClasses, labelInnerClasses };
6372
+ }
6373
+ var formLabel = "";
6374
+ var FormLabel = defineComponent({
6375
+ name: "DFormLabel",
6376
+ props: formLabelProps,
6377
+ setup(props, ctx) {
6378
+ const ns2 = useNamespace("form");
6379
+ const {
6380
+ labelClasses,
6381
+ labelInnerClasses
6382
+ } = useFormLabel();
6383
+ return () => {
6384
+ var _a, _b;
6385
+ return createVNode("span", {
6386
+ "class": labelClasses.value
6387
+ }, [createVNode("span", {
6388
+ "class": labelInnerClasses.value
6389
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), props.helpTips && createVNode(Popover, {
6390
+ "content": props.helpTips,
6391
+ "position": ["top"],
6392
+ "trigger": "hover",
6393
+ "pop-type": "info"
6394
+ }, {
6395
+ default: () => [createVNode(HelpTipsIcon, {
6396
+ "class": ns2.e("label-help")
6397
+ }, null), createTextVNode(",")]
6398
+ })]);
6399
+ };
6400
+ }
6401
+ });
6402
+ const formControlProps = {
6403
+ feedbackStatus: {
6404
+ type: String
6405
+ },
6406
+ extraInfo: {
6407
+ type: String,
6408
+ default: ""
6409
+ }
6410
+ };
6411
+ function useFormControl(props) {
6412
+ const labelData = inject(LABEL_DATA);
6413
+ const ns2 = useNamespace("form");
6414
+ const { feedbackStatus } = toRefs(props);
6415
+ const controlClasses = computed(() => ({
6416
+ [ns2.e("control")]: true,
6417
+ [ns2.em("control", "horizontal")]: labelData.value.layout === "horizontal"
6418
+ }));
6419
+ const controlContainerClasses = computed(() => ({
6420
+ [ns2.e("control-container")]: true,
6421
+ [ns2.em("control-container", "horizontal")]: labelData.value.layout === "horizontal",
6422
+ [ns2.em("control-container", "has-feedback")]: Boolean(feedbackStatus == null ? void 0 : feedbackStatus.value),
6423
+ [ns2.em("control-container", "feedback-error")]: Boolean((feedbackStatus == null ? void 0 : feedbackStatus.value) === "error")
6424
+ }));
6425
+ return { controlClasses, controlContainerClasses };
6426
+ }
6427
+ function useFormControlValidate() {
6428
+ const formItemContext = inject(FORM_ITEM_TOKEN);
6429
+ const feedbackStatus = computed(() => formItemContext.validateState);
6430
+ const showFeedback = computed(() => formItemContext.showFeedback && Boolean(formItemContext.validateState));
6431
+ const showPopover = computed(() => formItemContext.messageType === "popover" && formItemContext.validateState === "error");
6432
+ const showMessage = computed(() => formItemContext.messageType === "text" && formItemContext.validateState === "error");
6433
+ const errorMessage = computed(() => formItemContext.validateMessage);
6434
+ const popPosition = computed(() => formItemContext.popPosition);
6435
+ return { feedbackStatus, showFeedback, showPopover, showMessage, errorMessage, popPosition };
6436
+ }
6437
+ var formControl = "";
6438
+ var FormControl = defineComponent({
6439
+ name: "DFormControl",
6440
+ props: formControlProps,
6441
+ setup(props, ctx) {
6442
+ const formControl2 = ref();
6443
+ const ns2 = useNamespace("form");
6444
+ const {
6445
+ controlClasses,
6446
+ controlContainerClasses
6447
+ } = useFormControl(props);
6448
+ const {
6449
+ feedbackStatus,
6450
+ showFeedback,
6451
+ showPopover,
6452
+ showMessage,
6453
+ errorMessage,
6454
+ popPosition
6455
+ } = useFormControlValidate();
6456
+ return () => createVNode("div", {
6457
+ "class": controlClasses.value,
6458
+ "ref": formControl2
6459
+ }, [createVNode("div", {
6460
+ "class": controlContainerClasses.value
6461
+ }, [createVNode(Popover, {
6462
+ "is-open": showPopover.value,
6463
+ "trigger": "manually",
6464
+ "content": errorMessage.value,
6465
+ "pop-type": "error",
6466
+ "position": popPosition.value
6467
+ }, {
6468
+ default: () => {
6469
+ var _a, _b;
6470
+ return [createVNode("div", {
6471
+ "class": ns2.e("control-content")
6472
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createTextVNode(",")];
6473
+ }
6474
+ }), showFeedback.value && createVNode("span", {
6475
+ "class": [ns2.e("feedback-icon"), ns2.em("feedback-icon", feedbackStatus.value)]
6476
+ }, [feedbackStatus.value === "error" && createVNode(ErrorIcon, null, null), feedbackStatus.value === "success" && createVNode(SuccessIcon, null, null), feedbackStatus.value === "pending" && createVNode(PendingIcon, null, null)])]), createVNode("div", {
6477
+ "class": ns2.e("control-info")
6478
+ }, [showMessage.value && createVNode("div", {
6479
+ "class": "error-message"
6480
+ }, [errorMessage.value]), props.extraInfo && createVNode("div", {
6481
+ "class": ns2.e("control-extra")
6482
+ }, [props.extraInfo])])]);
6483
+ }
6484
+ });
6485
+ function _extends() {
6486
+ _extends = Object.assign || function(target) {
6487
+ for (var i = 1; i < arguments.length; i++) {
6488
+ var source = arguments[i];
6489
+ for (var key in source) {
6490
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
6491
+ target[key] = source[key];
6492
+ }
6493
+ }
6494
+ }
6495
+ return target;
6496
+ };
6497
+ return _extends.apply(this, arguments);
6498
+ }
6499
+ function _inheritsLoose(subClass, superClass) {
6500
+ subClass.prototype = Object.create(superClass.prototype);
6501
+ subClass.prototype.constructor = subClass;
6502
+ _setPrototypeOf(subClass, superClass);
6503
+ }
6504
+ function _getPrototypeOf(o) {
6505
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
6506
+ return o2.__proto__ || Object.getPrototypeOf(o2);
6507
+ };
6508
+ return _getPrototypeOf(o);
6509
+ }
6510
+ function _setPrototypeOf(o, p) {
6511
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
6512
+ o2.__proto__ = p2;
6513
+ return o2;
6514
+ };
6515
+ return _setPrototypeOf(o, p);
6516
+ }
6517
+ function _isNativeReflectConstruct() {
6518
+ if (typeof Reflect === "undefined" || !Reflect.construct)
6519
+ return false;
6520
+ if (Reflect.construct.sham)
6521
+ return false;
6522
+ if (typeof Proxy === "function")
6523
+ return true;
6524
+ try {
6525
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
6526
+ }));
6527
+ return true;
6528
+ } catch (e) {
6529
+ return false;
6530
+ }
6531
+ }
6532
+ function _construct(Parent, args, Class) {
6533
+ if (_isNativeReflectConstruct()) {
6534
+ _construct = Reflect.construct;
6535
+ } else {
6536
+ _construct = function _construct2(Parent2, args2, Class2) {
6537
+ var a = [null];
6538
+ a.push.apply(a, args2);
6539
+ var Constructor = Function.bind.apply(Parent2, a);
6540
+ var instance = new Constructor();
6541
+ if (Class2)
6542
+ _setPrototypeOf(instance, Class2.prototype);
6543
+ return instance;
6544
+ };
6545
+ }
6546
+ return _construct.apply(null, arguments);
6547
+ }
6548
+ function _isNativeFunction(fn) {
6549
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
6550
+ }
6551
+ function _wrapNativeSuper(Class) {
6552
+ var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
6553
+ _wrapNativeSuper = function _wrapNativeSuper2(Class2) {
6554
+ if (Class2 === null || !_isNativeFunction(Class2))
6555
+ return Class2;
6556
+ if (typeof Class2 !== "function") {
6557
+ throw new TypeError("Super expression must either be null or a function");
6558
+ }
6559
+ if (typeof _cache !== "undefined") {
6560
+ if (_cache.has(Class2))
6561
+ return _cache.get(Class2);
6562
+ _cache.set(Class2, Wrapper);
6563
+ }
6564
+ function Wrapper() {
6565
+ return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
6566
+ }
6567
+ Wrapper.prototype = Object.create(Class2.prototype, {
6568
+ constructor: {
6569
+ value: Wrapper,
6570
+ enumerable: false,
6571
+ writable: true,
6572
+ configurable: true
6573
+ }
6574
+ });
6575
+ return _setPrototypeOf(Wrapper, Class2);
6576
+ };
6577
+ return _wrapNativeSuper(Class);
6578
+ }
6579
+ var formatRegExp = /%[sdj%]/g;
6580
+ var warning = function warning2() {
6581
+ };
6582
+ if (typeof process !== "undefined" && process.env && false) {
6583
+ warning = function warning3(type4, errors) {
6584
+ if (typeof console !== "undefined" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === "undefined") {
6585
+ if (errors.every(function(e) {
6586
+ return typeof e === "string";
6587
+ })) {
6588
+ console.warn(type4, errors);
6589
+ }
6590
+ }
6591
+ };
6592
+ }
6593
+ function convertFieldsError(errors) {
6594
+ if (!errors || !errors.length)
6595
+ return null;
6596
+ var fields = {};
6597
+ errors.forEach(function(error) {
6598
+ var field = error.field;
6599
+ fields[field] = fields[field] || [];
6600
+ fields[field].push(error);
6601
+ });
6602
+ return fields;
6603
+ }
6604
+ function format(template) {
6605
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
6606
+ args[_key - 1] = arguments[_key];
6607
+ }
6608
+ var i = 0;
6609
+ var len = args.length;
6610
+ if (typeof template === "function") {
6611
+ return template.apply(null, args);
6612
+ }
6613
+ if (typeof template === "string") {
6614
+ var str = template.replace(formatRegExp, function(x) {
6615
+ if (x === "%%") {
6616
+ return "%";
6617
+ }
6618
+ if (i >= len) {
6619
+ return x;
6620
+ }
6621
+ switch (x) {
6622
+ case "%s":
6623
+ return String(args[i++]);
6624
+ case "%d":
6625
+ return Number(args[i++]);
6626
+ case "%j":
6627
+ try {
6628
+ return JSON.stringify(args[i++]);
6629
+ } catch (_) {
6630
+ return "[Circular]";
6631
+ }
6632
+ break;
6633
+ default:
6634
+ return x;
6635
+ }
6636
+ });
6637
+ return str;
6638
+ }
6639
+ return template;
6640
+ }
6641
+ function isNativeStringType(type4) {
6642
+ return type4 === "string" || type4 === "url" || type4 === "hex" || type4 === "email" || type4 === "date" || type4 === "pattern";
6643
+ }
6644
+ function isEmptyValue(value, type4) {
6645
+ if (value === void 0 || value === null) {
6646
+ return true;
6647
+ }
6648
+ if (type4 === "array" && Array.isArray(value) && !value.length) {
6649
+ return true;
6650
+ }
6651
+ if (isNativeStringType(type4) && typeof value === "string" && !value) {
6652
+ return true;
6653
+ }
6654
+ return false;
6655
+ }
6656
+ function asyncParallelArray(arr, func, callback) {
6657
+ var results = [];
6658
+ var total = 0;
6659
+ var arrLength = arr.length;
6660
+ function count(errors) {
6661
+ results.push.apply(results, errors || []);
6662
+ total++;
6663
+ if (total === arrLength) {
6664
+ callback(results);
6665
+ }
6666
+ }
6667
+ arr.forEach(function(a) {
6668
+ func(a, count);
6669
+ });
6670
+ }
6671
+ function asyncSerialArray(arr, func, callback) {
6672
+ var index2 = 0;
6673
+ var arrLength = arr.length;
6674
+ function next(errors) {
6675
+ if (errors && errors.length) {
6676
+ callback(errors);
6677
+ return;
6678
+ }
6679
+ var original = index2;
6680
+ index2 = index2 + 1;
6681
+ if (original < arrLength) {
6682
+ func(arr[original], next);
6683
+ } else {
6684
+ callback([]);
6685
+ }
6686
+ }
6687
+ next([]);
6688
+ }
6689
+ function flattenObjArr(objArr) {
6690
+ var ret = [];
6691
+ Object.keys(objArr).forEach(function(k) {
6692
+ ret.push.apply(ret, objArr[k] || []);
6693
+ });
6694
+ return ret;
6695
+ }
6696
+ var AsyncValidationError = /* @__PURE__ */ function(_Error) {
6697
+ _inheritsLoose(AsyncValidationError2, _Error);
6698
+ function AsyncValidationError2(errors, fields) {
6699
+ var _this;
6700
+ _this = _Error.call(this, "Async Validation Error") || this;
6701
+ _this.errors = errors;
6702
+ _this.fields = fields;
6703
+ return _this;
6704
+ }
6705
+ return AsyncValidationError2;
6706
+ }(/* @__PURE__ */ _wrapNativeSuper(Error));
6707
+ function asyncMap(objArr, option, func, callback, source) {
6708
+ if (option.first) {
6709
+ var _pending = new Promise(function(resolve, reject) {
6710
+ var next = function next2(errors) {
6711
+ callback(errors);
6712
+ return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
6907
6713
  };
6908
- LazyWrapper.prototype.slice = function(start, end) {
6909
- start = toInteger(start);
6910
- var result2 = this;
6911
- if (result2.__filtered__ && (start > 0 || end < 0)) {
6912
- return new LazyWrapper(result2);
6913
- }
6914
- if (start < 0) {
6915
- result2 = result2.takeRight(-start);
6916
- } else if (start) {
6917
- result2 = result2.drop(start);
6918
- }
6919
- if (end !== undefined$1) {
6920
- end = toInteger(end);
6921
- result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start);
6714
+ var flattenArr = flattenObjArr(objArr);
6715
+ asyncSerialArray(flattenArr, func, next);
6716
+ });
6717
+ _pending["catch"](function(e) {
6718
+ return e;
6719
+ });
6720
+ return _pending;
6721
+ }
6722
+ var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
6723
+ var objArrKeys = Object.keys(objArr);
6724
+ var objArrLength = objArrKeys.length;
6725
+ var total = 0;
6726
+ var results = [];
6727
+ var pending = new Promise(function(resolve, reject) {
6728
+ var next = function next2(errors) {
6729
+ results.push.apply(results, errors);
6730
+ total++;
6731
+ if (total === objArrLength) {
6732
+ callback(results);
6733
+ return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
6734
+ }
6735
+ };
6736
+ if (!objArrKeys.length) {
6737
+ callback(results);
6738
+ resolve(source);
6739
+ }
6740
+ objArrKeys.forEach(function(key) {
6741
+ var arr = objArr[key];
6742
+ if (firstFields.indexOf(key) !== -1) {
6743
+ asyncSerialArray(arr, func, next);
6744
+ } else {
6745
+ asyncParallelArray(arr, func, next);
6746
+ }
6747
+ });
6748
+ });
6749
+ pending["catch"](function(e) {
6750
+ return e;
6751
+ });
6752
+ return pending;
6753
+ }
6754
+ function isErrorObj(obj) {
6755
+ return !!(obj && obj.message !== void 0);
6756
+ }
6757
+ function getValue(value, path) {
6758
+ var v = value;
6759
+ for (var i = 0; i < path.length; i++) {
6760
+ if (v == void 0) {
6761
+ return v;
6762
+ }
6763
+ v = v[path[i]];
6764
+ }
6765
+ return v;
6766
+ }
6767
+ function complementError(rule, source) {
6768
+ return function(oe) {
6769
+ var fieldValue;
6770
+ if (rule.fullFields) {
6771
+ fieldValue = getValue(source, rule.fullFields);
6772
+ } else {
6773
+ fieldValue = source[oe.field || rule.fullField];
6774
+ }
6775
+ if (isErrorObj(oe)) {
6776
+ oe.field = oe.field || rule.fullField;
6777
+ oe.fieldValue = fieldValue;
6778
+ return oe;
6779
+ }
6780
+ return {
6781
+ message: typeof oe === "function" ? oe() : oe,
6782
+ fieldValue,
6783
+ field: oe.field || rule.fullField
6784
+ };
6785
+ };
6786
+ }
6787
+ function deepMerge(target, source) {
6788
+ if (source) {
6789
+ for (var s in source) {
6790
+ if (source.hasOwnProperty(s)) {
6791
+ var value = source[s];
6792
+ if (typeof value === "object" && typeof target[s] === "object") {
6793
+ target[s] = _extends({}, target[s], value);
6794
+ } else {
6795
+ target[s] = value;
6922
6796
  }
6923
- return result2;
6924
- };
6925
- LazyWrapper.prototype.takeRightWhile = function(predicate) {
6926
- return this.reverse().takeWhile(predicate).reverse();
6927
- };
6928
- LazyWrapper.prototype.toArray = function() {
6929
- return this.take(MAX_ARRAY_LENGTH);
6797
+ }
6798
+ }
6799
+ }
6800
+ return target;
6801
+ }
6802
+ var required$1 = function required(rule, value, source, errors, options, type4) {
6803
+ if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type4 || rule.type))) {
6804
+ errors.push(format(options.messages.required, rule.fullField));
6805
+ }
6806
+ };
6807
+ var whitespace = function whitespace2(rule, value, source, errors, options) {
6808
+ if (/^\s+$/.test(value) || value === "") {
6809
+ errors.push(format(options.messages.whitespace, rule.fullField));
6810
+ }
6811
+ };
6812
+ var pattern$2 = {
6813
+ email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
6814
+ url: new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", "i"),
6815
+ hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
6816
+ };
6817
+ var types = {
6818
+ integer: function integer(value) {
6819
+ return types.number(value) && parseInt(value, 10) === value;
6820
+ },
6821
+ "float": function float(value) {
6822
+ return types.number(value) && !types.integer(value);
6823
+ },
6824
+ array: function array(value) {
6825
+ return Array.isArray(value);
6826
+ },
6827
+ regexp: function regexp(value) {
6828
+ if (value instanceof RegExp) {
6829
+ return true;
6830
+ }
6831
+ try {
6832
+ return !!new RegExp(value);
6833
+ } catch (e) {
6834
+ return false;
6835
+ }
6836
+ },
6837
+ date: function date(value) {
6838
+ return typeof value.getTime === "function" && typeof value.getMonth === "function" && typeof value.getYear === "function" && !isNaN(value.getTime());
6839
+ },
6840
+ number: function number(value) {
6841
+ if (isNaN(value)) {
6842
+ return false;
6843
+ }
6844
+ return typeof value === "number";
6845
+ },
6846
+ object: function object(value) {
6847
+ return typeof value === "object" && !types.array(value);
6848
+ },
6849
+ method: function method(value) {
6850
+ return typeof value === "function";
6851
+ },
6852
+ email: function email(value) {
6853
+ return typeof value === "string" && value.length <= 320 && !!value.match(pattern$2.email);
6854
+ },
6855
+ url: function url(value) {
6856
+ return typeof value === "string" && value.length <= 2048 && !!value.match(pattern$2.url);
6857
+ },
6858
+ hex: function hex(value) {
6859
+ return typeof value === "string" && !!value.match(pattern$2.hex);
6860
+ }
6861
+ };
6862
+ var type$1 = function type(rule, value, source, errors, options) {
6863
+ if (rule.required && value === void 0) {
6864
+ required$1(rule, value, source, errors, options);
6865
+ return;
6866
+ }
6867
+ var custom = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"];
6868
+ var ruleType = rule.type;
6869
+ if (custom.indexOf(ruleType) > -1) {
6870
+ if (!types[ruleType](value)) {
6871
+ errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
6872
+ }
6873
+ } else if (ruleType && typeof value !== rule.type) {
6874
+ errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
6875
+ }
6876
+ };
6877
+ var range = function range2(rule, value, source, errors, options) {
6878
+ var len = typeof rule.len === "number";
6879
+ var min = typeof rule.min === "number";
6880
+ var max = typeof rule.max === "number";
6881
+ var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
6882
+ var val = value;
6883
+ var key = null;
6884
+ var num = typeof value === "number";
6885
+ var str = typeof value === "string";
6886
+ var arr = Array.isArray(value);
6887
+ if (num) {
6888
+ key = "number";
6889
+ } else if (str) {
6890
+ key = "string";
6891
+ } else if (arr) {
6892
+ key = "array";
6893
+ }
6894
+ if (!key) {
6895
+ return false;
6896
+ }
6897
+ if (arr) {
6898
+ val = value.length;
6899
+ }
6900
+ if (str) {
6901
+ val = value.replace(spRegexp, "_").length;
6902
+ }
6903
+ if (len) {
6904
+ if (val !== rule.len) {
6905
+ errors.push(format(options.messages[key].len, rule.fullField, rule.len));
6906
+ }
6907
+ } else if (min && !max && val < rule.min) {
6908
+ errors.push(format(options.messages[key].min, rule.fullField, rule.min));
6909
+ } else if (max && !min && val > rule.max) {
6910
+ errors.push(format(options.messages[key].max, rule.fullField, rule.max));
6911
+ } else if (min && max && (val < rule.min || val > rule.max)) {
6912
+ errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
6913
+ }
6914
+ };
6915
+ var ENUM$1 = "enum";
6916
+ var enumerable$1 = function enumerable(rule, value, source, errors, options) {
6917
+ rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
6918
+ if (rule[ENUM$1].indexOf(value) === -1) {
6919
+ errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(", ")));
6920
+ }
6921
+ };
6922
+ var pattern$1 = function pattern(rule, value, source, errors, options) {
6923
+ if (rule.pattern) {
6924
+ if (rule.pattern instanceof RegExp) {
6925
+ rule.pattern.lastIndex = 0;
6926
+ if (!rule.pattern.test(value)) {
6927
+ errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
6928
+ }
6929
+ } else if (typeof rule.pattern === "string") {
6930
+ var _pattern = new RegExp(rule.pattern);
6931
+ if (!_pattern.test(value)) {
6932
+ errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
6933
+ }
6934
+ }
6935
+ }
6936
+ };
6937
+ var rules = {
6938
+ required: required$1,
6939
+ whitespace,
6940
+ type: type$1,
6941
+ range,
6942
+ "enum": enumerable$1,
6943
+ pattern: pattern$1
6944
+ };
6945
+ var string = function string2(rule, value, callback, source, options) {
6946
+ var errors = [];
6947
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
6948
+ if (validate) {
6949
+ if (isEmptyValue(value, "string") && !rule.required) {
6950
+ return callback();
6951
+ }
6952
+ rules.required(rule, value, source, errors, options, "string");
6953
+ if (!isEmptyValue(value, "string")) {
6954
+ rules.type(rule, value, source, errors, options);
6955
+ rules.range(rule, value, source, errors, options);
6956
+ rules.pattern(rule, value, source, errors, options);
6957
+ if (rule.whitespace === true) {
6958
+ rules.whitespace(rule, value, source, errors, options);
6959
+ }
6960
+ }
6961
+ }
6962
+ callback(errors);
6963
+ };
6964
+ var method2 = function method3(rule, value, callback, source, options) {
6965
+ var errors = [];
6966
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
6967
+ if (validate) {
6968
+ if (isEmptyValue(value) && !rule.required) {
6969
+ return callback();
6970
+ }
6971
+ rules.required(rule, value, source, errors, options);
6972
+ if (value !== void 0) {
6973
+ rules.type(rule, value, source, errors, options);
6974
+ }
6975
+ }
6976
+ callback(errors);
6977
+ };
6978
+ var number2 = function number3(rule, value, callback, source, options) {
6979
+ var errors = [];
6980
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
6981
+ if (validate) {
6982
+ if (value === "") {
6983
+ value = void 0;
6984
+ }
6985
+ if (isEmptyValue(value) && !rule.required) {
6986
+ return callback();
6987
+ }
6988
+ rules.required(rule, value, source, errors, options);
6989
+ if (value !== void 0) {
6990
+ rules.type(rule, value, source, errors, options);
6991
+ rules.range(rule, value, source, errors, options);
6992
+ }
6993
+ }
6994
+ callback(errors);
6995
+ };
6996
+ var _boolean = function _boolean2(rule, value, callback, source, options) {
6997
+ var errors = [];
6998
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
6999
+ if (validate) {
7000
+ if (isEmptyValue(value) && !rule.required) {
7001
+ return callback();
7002
+ }
7003
+ rules.required(rule, value, source, errors, options);
7004
+ if (value !== void 0) {
7005
+ rules.type(rule, value, source, errors, options);
7006
+ }
7007
+ }
7008
+ callback(errors);
7009
+ };
7010
+ var regexp2 = function regexp3(rule, value, callback, source, options) {
7011
+ var errors = [];
7012
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7013
+ if (validate) {
7014
+ if (isEmptyValue(value) && !rule.required) {
7015
+ return callback();
7016
+ }
7017
+ rules.required(rule, value, source, errors, options);
7018
+ if (!isEmptyValue(value)) {
7019
+ rules.type(rule, value, source, errors, options);
7020
+ }
7021
+ }
7022
+ callback(errors);
7023
+ };
7024
+ var integer2 = function integer3(rule, value, callback, source, options) {
7025
+ var errors = [];
7026
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7027
+ if (validate) {
7028
+ if (isEmptyValue(value) && !rule.required) {
7029
+ return callback();
7030
+ }
7031
+ rules.required(rule, value, source, errors, options);
7032
+ if (value !== void 0) {
7033
+ rules.type(rule, value, source, errors, options);
7034
+ rules.range(rule, value, source, errors, options);
7035
+ }
7036
+ }
7037
+ callback(errors);
7038
+ };
7039
+ var floatFn = function floatFn2(rule, value, callback, source, options) {
7040
+ var errors = [];
7041
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7042
+ if (validate) {
7043
+ if (isEmptyValue(value) && !rule.required) {
7044
+ return callback();
7045
+ }
7046
+ rules.required(rule, value, source, errors, options);
7047
+ if (value !== void 0) {
7048
+ rules.type(rule, value, source, errors, options);
7049
+ rules.range(rule, value, source, errors, options);
7050
+ }
7051
+ }
7052
+ callback(errors);
7053
+ };
7054
+ var array2 = function array3(rule, value, callback, source, options) {
7055
+ var errors = [];
7056
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7057
+ if (validate) {
7058
+ if ((value === void 0 || value === null) && !rule.required) {
7059
+ return callback();
7060
+ }
7061
+ rules.required(rule, value, source, errors, options, "array");
7062
+ if (value !== void 0 && value !== null) {
7063
+ rules.type(rule, value, source, errors, options);
7064
+ rules.range(rule, value, source, errors, options);
7065
+ }
7066
+ }
7067
+ callback(errors);
7068
+ };
7069
+ var object2 = function object3(rule, value, callback, source, options) {
7070
+ var errors = [];
7071
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7072
+ if (validate) {
7073
+ if (isEmptyValue(value) && !rule.required) {
7074
+ return callback();
7075
+ }
7076
+ rules.required(rule, value, source, errors, options);
7077
+ if (value !== void 0) {
7078
+ rules.type(rule, value, source, errors, options);
7079
+ }
7080
+ }
7081
+ callback(errors);
7082
+ };
7083
+ var ENUM = "enum";
7084
+ var enumerable2 = function enumerable3(rule, value, callback, source, options) {
7085
+ var errors = [];
7086
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7087
+ if (validate) {
7088
+ if (isEmptyValue(value) && !rule.required) {
7089
+ return callback();
7090
+ }
7091
+ rules.required(rule, value, source, errors, options);
7092
+ if (value !== void 0) {
7093
+ rules[ENUM](rule, value, source, errors, options);
7094
+ }
7095
+ }
7096
+ callback(errors);
7097
+ };
7098
+ var pattern2 = function pattern3(rule, value, callback, source, options) {
7099
+ var errors = [];
7100
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7101
+ if (validate) {
7102
+ if (isEmptyValue(value, "string") && !rule.required) {
7103
+ return callback();
7104
+ }
7105
+ rules.required(rule, value, source, errors, options);
7106
+ if (!isEmptyValue(value, "string")) {
7107
+ rules.pattern(rule, value, source, errors, options);
7108
+ }
7109
+ }
7110
+ callback(errors);
7111
+ };
7112
+ var date2 = function date3(rule, value, callback, source, options) {
7113
+ var errors = [];
7114
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7115
+ if (validate) {
7116
+ if (isEmptyValue(value, "date") && !rule.required) {
7117
+ return callback();
7118
+ }
7119
+ rules.required(rule, value, source, errors, options);
7120
+ if (!isEmptyValue(value, "date")) {
7121
+ var dateObject;
7122
+ if (value instanceof Date) {
7123
+ dateObject = value;
7124
+ } else {
7125
+ dateObject = new Date(value);
7126
+ }
7127
+ rules.type(rule, dateObject, source, errors, options);
7128
+ if (dateObject) {
7129
+ rules.range(rule, dateObject.getTime(), source, errors, options);
7130
+ }
7131
+ }
7132
+ }
7133
+ callback(errors);
7134
+ };
7135
+ var required2 = function required3(rule, value, callback, source, options) {
7136
+ var errors = [];
7137
+ var type4 = Array.isArray(value) ? "array" : typeof value;
7138
+ rules.required(rule, value, source, errors, options, type4);
7139
+ callback(errors);
7140
+ };
7141
+ var type2 = function type3(rule, value, callback, source, options) {
7142
+ var ruleType = rule.type;
7143
+ var errors = [];
7144
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7145
+ if (validate) {
7146
+ if (isEmptyValue(value, ruleType) && !rule.required) {
7147
+ return callback();
7148
+ }
7149
+ rules.required(rule, value, source, errors, options, ruleType);
7150
+ if (!isEmptyValue(value, ruleType)) {
7151
+ rules.type(rule, value, source, errors, options);
7152
+ }
7153
+ }
7154
+ callback(errors);
7155
+ };
7156
+ var any = function any2(rule, value, callback, source, options) {
7157
+ var errors = [];
7158
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
7159
+ if (validate) {
7160
+ if (isEmptyValue(value) && !rule.required) {
7161
+ return callback();
7162
+ }
7163
+ rules.required(rule, value, source, errors, options);
7164
+ }
7165
+ callback(errors);
7166
+ };
7167
+ var validators = {
7168
+ string,
7169
+ method: method2,
7170
+ number: number2,
7171
+ "boolean": _boolean,
7172
+ regexp: regexp2,
7173
+ integer: integer2,
7174
+ "float": floatFn,
7175
+ array: array2,
7176
+ object: object2,
7177
+ "enum": enumerable2,
7178
+ pattern: pattern2,
7179
+ date: date2,
7180
+ url: type2,
7181
+ hex: type2,
7182
+ email: type2,
7183
+ required: required2,
7184
+ any
7185
+ };
7186
+ function newMessages() {
7187
+ return {
7188
+ "default": "Validation error on field %s",
7189
+ required: "%s is required",
7190
+ "enum": "%s must be one of %s",
7191
+ whitespace: "%s cannot be empty",
7192
+ date: {
7193
+ format: "%s date %s is invalid for format %s",
7194
+ parse: "%s date could not be parsed, %s is invalid ",
7195
+ invalid: "%s date %s is invalid"
7196
+ },
7197
+ types: {
7198
+ string: "%s is not a %s",
7199
+ method: "%s is not a %s (function)",
7200
+ array: "%s is not an %s",
7201
+ object: "%s is not an %s",
7202
+ number: "%s is not a %s",
7203
+ date: "%s is not a %s",
7204
+ "boolean": "%s is not a %s",
7205
+ integer: "%s is not an %s",
7206
+ "float": "%s is not a %s",
7207
+ regexp: "%s is not a valid %s",
7208
+ email: "%s is not a valid %s",
7209
+ url: "%s is not a valid %s",
7210
+ hex: "%s is not a valid %s"
7211
+ },
7212
+ string: {
7213
+ len: "%s must be exactly %s characters",
7214
+ min: "%s must be at least %s characters",
7215
+ max: "%s cannot be longer than %s characters",
7216
+ range: "%s must be between %s and %s characters"
7217
+ },
7218
+ number: {
7219
+ len: "%s must equal %s",
7220
+ min: "%s cannot be less than %s",
7221
+ max: "%s cannot be greater than %s",
7222
+ range: "%s must be between %s and %s"
7223
+ },
7224
+ array: {
7225
+ len: "%s must be exactly %s in length",
7226
+ min: "%s cannot be less than %s in length",
7227
+ max: "%s cannot be greater than %s in length",
7228
+ range: "%s must be between %s and %s in length"
7229
+ },
7230
+ pattern: {
7231
+ mismatch: "%s value %s does not match pattern %s"
7232
+ },
7233
+ clone: function clone() {
7234
+ var cloned = JSON.parse(JSON.stringify(this));
7235
+ cloned.clone = this.clone;
7236
+ return cloned;
7237
+ }
7238
+ };
7239
+ }
7240
+ var messages = newMessages();
7241
+ var Schema = /* @__PURE__ */ function() {
7242
+ function Schema2(descriptor) {
7243
+ this.rules = null;
7244
+ this._messages = messages;
7245
+ this.define(descriptor);
7246
+ }
7247
+ var _proto = Schema2.prototype;
7248
+ _proto.define = function define(rules2) {
7249
+ var _this = this;
7250
+ if (!rules2) {
7251
+ throw new Error("Cannot configure a schema with no rules");
7252
+ }
7253
+ if (typeof rules2 !== "object" || Array.isArray(rules2)) {
7254
+ throw new Error("Rules must be an object");
7255
+ }
7256
+ this.rules = {};
7257
+ Object.keys(rules2).forEach(function(name) {
7258
+ var item = rules2[name];
7259
+ _this.rules[name] = Array.isArray(item) ? item : [item];
7260
+ });
7261
+ };
7262
+ _proto.messages = function messages2(_messages) {
7263
+ if (_messages) {
7264
+ this._messages = deepMerge(newMessages(), _messages);
7265
+ }
7266
+ return this._messages;
7267
+ };
7268
+ _proto.validate = function validate(source_, o, oc) {
7269
+ var _this2 = this;
7270
+ if (o === void 0) {
7271
+ o = {};
7272
+ }
7273
+ if (oc === void 0) {
7274
+ oc = function oc2() {
6930
7275
  };
6931
- baseForOwn(LazyWrapper.prototype, function(func, methodName) {
6932
- var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash2[isTaker ? "take" + (methodName == "last" ? "Right" : "") : methodName], retUnwrapped = isTaker || /^find/.test(methodName);
6933
- if (!lodashFunc) {
6934
- return;
6935
- }
6936
- lodash2.prototype[methodName] = function() {
6937
- var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray(value);
6938
- var interceptor = function(value2) {
6939
- var result3 = lodashFunc.apply(lodash2, arrayPush([value2], args));
6940
- return isTaker && chainAll ? result3[0] : result3;
6941
- };
6942
- if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
6943
- isLazy = useLazy = false;
6944
- }
6945
- var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
6946
- if (!retUnwrapped && useLazy) {
6947
- value = onlyLazy ? value : new LazyWrapper(this);
6948
- var result2 = func.apply(value, args);
6949
- result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined$1 });
6950
- return new LodashWrapper(result2, chainAll);
6951
- }
6952
- if (isUnwrapped && onlyLazy) {
6953
- return func.apply(this, args);
6954
- }
6955
- result2 = this.thru(interceptor);
6956
- return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
6957
- };
6958
- });
6959
- arrayEach(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
6960
- var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
6961
- lodash2.prototype[methodName] = function() {
6962
- var args = arguments;
6963
- if (retUnwrapped && !this.__chain__) {
6964
- var value = this.value();
6965
- return func.apply(isArray(value) ? value : [], args);
6966
- }
6967
- return this[chainName](function(value2) {
6968
- return func.apply(isArray(value2) ? value2 : [], args);
6969
- });
6970
- };
6971
- });
6972
- baseForOwn(LazyWrapper.prototype, function(func, methodName) {
6973
- var lodashFunc = lodash2[methodName];
6974
- if (lodashFunc) {
6975
- var key = lodashFunc.name + "";
6976
- if (!hasOwnProperty.call(realNames, key)) {
6977
- realNames[key] = [];
6978
- }
6979
- realNames[key].push({ "name": methodName, "func": lodashFunc });
7276
+ }
7277
+ var source = source_;
7278
+ var options = o;
7279
+ var callback = oc;
7280
+ if (typeof options === "function") {
7281
+ callback = options;
7282
+ options = {};
7283
+ }
7284
+ if (!this.rules || Object.keys(this.rules).length === 0) {
7285
+ if (callback) {
7286
+ callback(null, source);
7287
+ }
7288
+ return Promise.resolve(source);
7289
+ }
7290
+ function complete(results) {
7291
+ var errors = [];
7292
+ var fields = {};
7293
+ function add(e) {
7294
+ if (Array.isArray(e)) {
7295
+ var _errors;
7296
+ errors = (_errors = errors).concat.apply(_errors, e);
7297
+ } else {
7298
+ errors.push(e);
6980
7299
  }
6981
- });
6982
- realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
6983
- "name": "wrapper",
6984
- "func": undefined$1
6985
- }];
6986
- LazyWrapper.prototype.clone = lazyClone;
6987
- LazyWrapper.prototype.reverse = lazyReverse;
6988
- LazyWrapper.prototype.value = lazyValue;
6989
- lodash2.prototype.at = wrapperAt;
6990
- lodash2.prototype.chain = wrapperChain;
6991
- lodash2.prototype.commit = wrapperCommit;
6992
- lodash2.prototype.next = wrapperNext;
6993
- lodash2.prototype.plant = wrapperPlant;
6994
- lodash2.prototype.reverse = wrapperReverse;
6995
- lodash2.prototype.toJSON = lodash2.prototype.valueOf = lodash2.prototype.value = wrapperValue;
6996
- lodash2.prototype.first = lodash2.prototype.head;
6997
- if (symIterator) {
6998
- lodash2.prototype[symIterator] = wrapperToIterator;
6999
7300
  }
7000
- return lodash2;
7001
- };
7002
- var _ = runInContext();
7003
- if (freeModule) {
7004
- (freeModule.exports = _)._ = _;
7005
- freeExports._ = _;
7301
+ for (var i = 0; i < results.length; i++) {
7302
+ add(results[i]);
7303
+ }
7304
+ if (!errors.length) {
7305
+ callback(null, source);
7306
+ } else {
7307
+ fields = convertFieldsError(errors);
7308
+ callback(errors, fields);
7309
+ }
7310
+ }
7311
+ if (options.messages) {
7312
+ var messages$1 = this.messages();
7313
+ if (messages$1 === messages) {
7314
+ messages$1 = newMessages();
7315
+ }
7316
+ deepMerge(messages$1, options.messages);
7317
+ options.messages = messages$1;
7006
7318
  } else {
7007
- root._ = _;
7319
+ options.messages = this.messages();
7008
7320
  }
7009
- }).call(commonjsGlobal);
7010
- })(lodash, lodash.exports);
7011
- var formControl = "";
7012
- var FormControl = defineComponent({
7013
- name: "DFormControl",
7014
- directives: {
7015
- clickoutside: clickoutsideDirective
7016
- },
7017
- props: formControlProps,
7018
- setup(props, ctx2) {
7019
- const formControl2 = ref();
7020
- const dForm = reactive(inject(formInjectionKey, {}));
7021
- const labelData = reactive(dForm.labelData);
7022
- const isHorizontal = labelData.layout === "horizontal";
7023
- const uid = lodash.exports.uniqueId("dfc-");
7024
- const showPopover = ref(false);
7025
- const updateOn = ref("change");
7026
- const tipMessage = ref("");
7027
- const popPosition = ref("bottom");
7028
- let rectInfo = {
7029
- width: 0,
7030
- height: 0
7031
- };
7032
- let elOffset = {
7033
- left: 0,
7034
- top: 0
7035
- };
7036
- let popoverLeftPosition = 0;
7037
- let popoverTopPosition = 0;
7038
- onMounted(() => {
7039
- const el = document.getElementById(uid);
7040
- elOffset = getElOffset(el);
7041
- EventBus.on("showPopoverErrorMessage", (data) => {
7042
- var _a;
7043
- if (uid === data.uid) {
7044
- rectInfo = el.getBoundingClientRect();
7045
- showPopover.value = data.showPopover;
7046
- tipMessage.value = data.message;
7047
- popPosition.value = data.popPosition;
7048
- popoverLeftPosition = popPosition.value === "top" || popPosition.value === "bottom" ? rectInfo.right - rectInfo.width / 2 : rectInfo.right;
7049
- popoverTopPosition = popPosition.value === "top" ? elOffset.top + rectInfo.height / 2 - rectInfo.height : elOffset.top + rectInfo.height / 2;
7050
- updateOn.value = (_a = data.updateOn) != null ? _a : "change";
7321
+ var series = {};
7322
+ var keys = options.keys || Object.keys(this.rules);
7323
+ keys.forEach(function(z) {
7324
+ var arr = _this2.rules[z];
7325
+ var value = source[z];
7326
+ arr.forEach(function(r) {
7327
+ var rule = r;
7328
+ if (typeof rule.transform === "function") {
7329
+ if (source === source_) {
7330
+ source = _extends({}, source);
7331
+ }
7332
+ value = source[z] = rule.transform(value);
7051
7333
  }
7052
- });
7053
- });
7054
- const iconData = computed(() => {
7055
- switch (props.feedbackStatus) {
7056
- case "pending":
7057
- return {
7058
- name: "priority",
7059
- color: "#e9edfa"
7060
- };
7061
- case "success":
7062
- return {
7063
- name: "right-o",
7064
- color: "rgb(61, 204, 166)"
7065
- };
7066
- case "error":
7067
- return {
7068
- name: "error-o",
7069
- color: "rgb(249, 95, 91)"
7070
- };
7071
- default:
7072
- return {
7073
- name: "",
7074
- color: ""
7334
+ if (typeof rule === "function") {
7335
+ rule = {
7336
+ validator: rule
7075
7337
  };
7076
- }
7338
+ } else {
7339
+ rule = _extends({}, rule);
7340
+ }
7341
+ rule.validator = _this2.getValidationMethod(rule);
7342
+ if (!rule.validator) {
7343
+ return;
7344
+ }
7345
+ rule.field = z;
7346
+ rule.fullField = rule.fullField || z;
7347
+ rule.type = _this2.getType(rule);
7348
+ series[z] = series[z] || [];
7349
+ series[z].push({
7350
+ rule,
7351
+ value,
7352
+ source,
7353
+ field: z
7354
+ });
7355
+ });
7077
7356
  });
7078
- const handleClickOutside = () => {
7079
- if (updateOn.value !== "change") {
7080
- showPopover.value = false;
7357
+ var errorFields = {};
7358
+ return asyncMap(series, options, function(data, doIt) {
7359
+ var rule = data.rule;
7360
+ var deep = (rule.type === "object" || rule.type === "array") && (typeof rule.fields === "object" || typeof rule.defaultField === "object");
7361
+ deep = deep && (rule.required || !rule.required && data.value);
7362
+ rule.field = data.field;
7363
+ function addFullField(key, schema) {
7364
+ return _extends({}, schema, {
7365
+ fullField: rule.fullField + "." + key,
7366
+ fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key]
7367
+ });
7081
7368
  }
7082
- };
7083
- return () => {
7084
- var _a, _b, _c, _d, _e, _f, _g, _h;
7085
- const {
7086
- feedbackStatus,
7087
- extraInfo
7088
- } = props;
7089
- return withDirectives(createVNode("div", {
7090
- "class": "form-control",
7091
- "ref": formControl2,
7092
- "data-uid": uid
7093
- }, [showPopover.value && createVNode(Teleport, {
7094
- "to": "body"
7095
- }, {
7096
- default: () => [createVNode("div", {
7097
- "style": {
7098
- position: "absolute",
7099
- left: popoverLeftPosition + "px",
7100
- top: popoverTopPosition + "px",
7101
- width: rectInfo.width + "px",
7102
- height: rectInfo.height + "px"
7103
- }
7104
- }, [createVNode(Popover, {
7105
- "controlled": updateOn.value !== "change",
7106
- "visible": showPopover.value,
7107
- "content": tipMessage.value,
7108
- "popType": "error",
7109
- "position": popPosition.value
7110
- }, null)])]
7111
- }), createVNode("div", {
7112
- "class": `devui-form-control-container${isHorizontal ? " devui-form-control-container-horizontal" : ""}${feedbackStatus ? " has-feedback" : ""}${feedbackStatus === "error" ? " feedback-error" : ""}`
7113
- }, [createVNode("div", {
7114
- "class": "devui-control-content-wrapper",
7115
- "id": uid
7116
- }, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]), (feedbackStatus || ((_d = (_c = ctx2.slots).suffixTemplate) == null ? void 0 : _d.call(_c))) && createVNode("span", {
7117
- "class": "feedback-status"
7118
- }, [((_f = (_e = ctx2.slots).suffixTemplate) == null ? void 0 : _f.call(_e)) ? (_h = (_g = ctx2.slots).suffixTemplate) == null ? void 0 : _h.call(_g) : createVNode(Icon, {
7119
- "name": iconData.value.name,
7120
- "color": iconData.value.color
7121
- }, null)])]), extraInfo && createVNode("div", {
7122
- "class": "devui-form-control-extra-info"
7123
- }, [extraInfo])]), [[resolveDirective("clickoutside"), handleClickOutside]]);
7124
- };
7125
- }
7126
- });
7127
- var formOperation = "";
7128
- var FormOperation = defineComponent({
7129
- name: "DFormOperation",
7130
- props: {},
7131
- setup(props, ctx2) {
7132
- return () => {
7133
- var _a, _b;
7134
- return createVNode("div", {
7135
- "class": "form-operation"
7136
- }, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]);
7137
- };
7138
- }
7139
- });
7140
- var style = "";
7141
- function getAvaliableRuleObj(ruleName, value) {
7142
- if (!ruleName) {
7143
- console.error("[v-d-validate] validator's key is invalid");
7144
- return null;
7145
- }
7146
- switch (ruleName) {
7147
- case "maxlength":
7148
- return {
7149
- type: "string",
7150
- max: value,
7151
- asyncValidator: (rule, val) => {
7152
- return new Promise((resolve, reject) => {
7153
- if (val.length > value) {
7154
- reject("\u6700\u5927\u957F\u5EA6\u4E3A" + value);
7155
- } else {
7156
- resolve("\u6821\u9A8C\u901A\u8FC7");
7157
- }
7158
- });
7369
+ function cb(e) {
7370
+ if (e === void 0) {
7371
+ e = [];
7159
7372
  }
7160
- };
7161
- case "minlength":
7162
- return {
7163
- type: "string",
7164
- min: value,
7165
- asyncValidator: (rule, val) => {
7166
- return new Promise((resolve, reject) => {
7167
- if (val.length < value) {
7168
- reject("\u6700\u5C0F\u957F\u5EA6\u4E3A" + value);
7169
- } else {
7170
- resolve("\u6821\u9A8C\u901A\u8FC7");
7171
- }
7172
- });
7373
+ var errorList = Array.isArray(e) ? e : [e];
7374
+ if (!options.suppressWarning && errorList.length) {
7375
+ Schema2.warning("async-validator:", errorList);
7173
7376
  }
7174
- };
7175
- case "min":
7176
- return {
7177
- type: "number",
7178
- asyncValidator: (rule, val) => {
7179
- return new Promise((resolve, reject) => {
7180
- if (val < value) {
7181
- reject("\u6700\u5C0F\u503C\u4E3A" + value);
7182
- } else {
7183
- resolve("\u6821\u9A8C\u901A\u8FC7");
7184
- }
7185
- });
7377
+ if (errorList.length && rule.message !== void 0) {
7378
+ errorList = [].concat(rule.message);
7186
7379
  }
7187
- };
7188
- case "max":
7189
- return {
7190
- type: "number",
7191
- asyncValidator: (rule, val) => {
7192
- return new Promise((resolve, reject) => {
7193
- if (val > value) {
7194
- reject("\u6700\u5927\u503C\u4E3A" + value);
7195
- } else {
7196
- resolve("\u6821\u9A8C\u901A\u8FC7");
7197
- }
7198
- });
7380
+ var filledErrors = errorList.map(complementError(rule, source));
7381
+ if (options.first && filledErrors.length) {
7382
+ errorFields[rule.field] = 1;
7383
+ return doIt(filledErrors);
7199
7384
  }
7200
- };
7201
- case "required":
7202
- return {
7203
- reqiured: true,
7204
- asyncValidator: (rule, val) => {
7205
- return new Promise((resolve, reject) => {
7206
- if (!val) {
7207
- reject("\u5FC5\u586B\u9879");
7208
- } else {
7209
- resolve("\u6821\u9A8C\u901A\u8FC7");
7385
+ if (!deep) {
7386
+ doIt(filledErrors);
7387
+ } else {
7388
+ if (rule.required && !data.value) {
7389
+ if (rule.message !== void 0) {
7390
+ filledErrors = [].concat(rule.message).map(complementError(rule, source));
7391
+ } else if (options.error) {
7392
+ filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
7210
7393
  }
7394
+ return doIt(filledErrors);
7395
+ }
7396
+ var fieldsSchema = {};
7397
+ if (rule.defaultField) {
7398
+ Object.keys(data.value).map(function(key) {
7399
+ fieldsSchema[key] = rule.defaultField;
7400
+ });
7401
+ }
7402
+ fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
7403
+ var paredFieldsSchema = {};
7404
+ Object.keys(fieldsSchema).forEach(function(field) {
7405
+ var fieldSchema = fieldsSchema[field];
7406
+ var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
7407
+ paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
7211
7408
  });
7212
- }
7213
- };
7214
- case "requiredTrue":
7215
- return {
7216
- asyncValidator: (rule, val) => {
7217
- return new Promise((resolve, reject) => {
7218
- if (!val) {
7219
- reject("\u5FC5\u987B\u4E3Atrue\u503C");
7220
- } else {
7221
- resolve("\u6821\u9A8C\u901A\u8FC7");
7409
+ var schema = new Schema2(paredFieldsSchema);
7410
+ schema.messages(options.messages);
7411
+ if (data.rule.options) {
7412
+ data.rule.options.messages = options.messages;
7413
+ data.rule.options.error = options.error;
7414
+ }
7415
+ schema.validate(data.value, data.rule.options || options, function(errs) {
7416
+ var finalErrors = [];
7417
+ if (filledErrors && filledErrors.length) {
7418
+ finalErrors.push.apply(finalErrors, filledErrors);
7419
+ }
7420
+ if (errs && errs.length) {
7421
+ finalErrors.push.apply(finalErrors, errs);
7222
7422
  }
7423
+ doIt(finalErrors.length ? finalErrors : null);
7223
7424
  });
7224
7425
  }
7225
- };
7226
- case "email":
7227
- return {
7228
- type: "email",
7229
- message: "\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E"
7230
- };
7231
- case "pattern":
7232
- return {
7233
- type: "regexp",
7234
- pattern: value,
7235
- message: "\u53EA\u80FD\u5305\u542B\u6570\u5B57\u4E0E\u5927\u5C0F\u5199\u5B57\u7B26",
7236
- validator: (rule, val) => value.test(val)
7237
- };
7238
- case "whitespace":
7239
- return {
7240
- message: "\u8F93\u5165\u4E0D\u80FD\u5168\u90E8\u4E3A\u7A7A\u683C\u6216\u7A7A\u5B57\u7B26",
7241
- validator: (rule, val) => !!val.trim()
7242
- };
7243
- default:
7244
- return {
7245
- [ruleName]: value
7246
- };
7247
- }
7248
- }
7249
- function getKeyValueOfObjectList(obj) {
7250
- const kvArr = [];
7251
- for (const key in obj) {
7252
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
7253
- kvArr.push({
7254
- key,
7255
- value: obj[key]
7256
- });
7426
+ }
7427
+ var res;
7428
+ if (rule.asyncValidator) {
7429
+ res = rule.asyncValidator(rule, data.value, cb, data.source, options);
7430
+ } else if (rule.validator) {
7431
+ res = rule.validator(rule, data.value, cb, data.source, options);
7432
+ if (res === true) {
7433
+ cb();
7434
+ } else if (res === false) {
7435
+ cb(typeof rule.message === "function" ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails");
7436
+ } else if (res instanceof Array) {
7437
+ cb(res);
7438
+ } else if (res instanceof Error) {
7439
+ cb(res.message);
7440
+ }
7441
+ }
7442
+ if (res && res.then) {
7443
+ res.then(function() {
7444
+ return cb();
7445
+ }, function(e) {
7446
+ return cb(e);
7447
+ });
7448
+ }
7449
+ }, function(results) {
7450
+ complete(results);
7451
+ }, source);
7452
+ };
7453
+ _proto.getType = function getType(rule) {
7454
+ if (rule.type === void 0 && rule.pattern instanceof RegExp) {
7455
+ rule.type = "pattern";
7257
7456
  }
7457
+ if (typeof rule.validator !== "function" && rule.type && !validators.hasOwnProperty(rule.type)) {
7458
+ throw new Error(format("Unknown rule type %s", rule.type));
7459
+ }
7460
+ return rule.type || "string";
7461
+ };
7462
+ _proto.getValidationMethod = function getValidationMethod(rule) {
7463
+ if (typeof rule.validator === "function") {
7464
+ return rule.validator;
7465
+ }
7466
+ var keys = Object.keys(rule);
7467
+ var messageIndex = keys.indexOf("message");
7468
+ if (messageIndex !== -1) {
7469
+ keys.splice(messageIndex, 1);
7470
+ }
7471
+ if (keys.length === 1 && keys[0] === "required") {
7472
+ return validators.required;
7473
+ }
7474
+ return validators[this.getType(rule)] || void 0;
7475
+ };
7476
+ return Schema2;
7477
+ }();
7478
+ Schema.register = function register(type4, validator) {
7479
+ if (typeof validator !== "function") {
7480
+ throw new Error("Cannot register a validator by type, validator is not a function");
7258
7481
  }
7259
- return kvArr;
7260
- }
7261
- function handleErrorStrategy(el) {
7262
- const classList = [...el.classList];
7263
- classList.push("d-validate-rules-error-pristine");
7264
- el.setAttribute("class", classList.join(" "));
7265
- }
7266
- function handleErrorStrategyPass(el) {
7267
- const classList = [...el.classList];
7268
- const index2 = classList.indexOf("d-validate-rules-error-pristine");
7269
- index2 !== -1 && classList.splice(index2, 1);
7270
- el.setAttribute("class", classList.join(" "));
7271
- }
7272
- function getFormControlUID(el) {
7273
- if (el.tagName.toLocaleLowerCase() === "body")
7274
- return "";
7275
- if (el.parentElement.id.startsWith("dfc-")) {
7276
- return el.parentElement.id;
7277
- } else {
7278
- getFormControlUID(el.parentElement);
7279
- }
7280
- }
7281
- function handleValidateError({ el, tipEl, message = "", isFormTag, messageShowType, dfcUID, popPosition = "right-bottom", updateOn }) {
7282
- if (isFormTag && messageShowType === "toast") {
7283
- alert(message);
7284
- return;
7285
- }
7286
- if (!dfcUID) {
7287
- dfcUID = getFormControlUID(el);
7288
- }
7289
- if (messageShowType === "popover") {
7290
- EventBus.emit("showPopoverErrorMessage", { showPopover: true, message, uid: dfcUID, popPosition, updateOn });
7291
- return;
7292
- }
7293
- tipEl.innerText = "" + message;
7294
- tipEl.style.display = "inline-flex";
7295
- tipEl.setAttribute("class", "d-validate-tip");
7296
- handleErrorStrategy(el);
7297
- }
7298
- function handleValidatePass(el, tipEl) {
7299
- tipEl.style.display = "none";
7300
- handleErrorStrategyPass(el);
7482
+ validators[type4] = validator;
7483
+ };
7484
+ Schema.warning = warning;
7485
+ Schema.messages = messages;
7486
+ Schema.validators = validators;
7487
+ function getFieldValue(obj, path) {
7488
+ return {
7489
+ get value() {
7490
+ return lodash.exports.get(obj, path);
7491
+ },
7492
+ set value(val) {
7493
+ lodash.exports.set(obj, path, val);
7494
+ }
7495
+ };
7301
7496
  }
7302
- function getRefName(binding) {
7303
- const _refs = binding.instance.$refs;
7304
- const refName = Object.keys(_refs)[0];
7305
- return refName;
7497
+ function useFormItem(messageType, _rules, validateState) {
7498
+ const formContext = inject(FORM_TOKEN);
7499
+ const ns2 = useNamespace("form");
7500
+ const itemClasses = computed(() => ({
7501
+ [`${ns2.em("item", "horizontal")}`]: formContext.layout === "horizontal",
7502
+ [`${ns2.em("item", "vertical")}`]: formContext.layout === "vertical",
7503
+ [`${ns2.em("item", "error")}`]: messageType.value === "text" && validateState.value === "error"
7504
+ }));
7505
+ const isRequired = computed(() => _rules.value.some((rule) => Boolean(rule.required)));
7506
+ return { itemClasses, isRequired };
7306
7507
  }
7307
- function getFormName(binding) {
7308
- const _refs = binding.instance.$refs;
7309
- const key = Object.keys(_refs)[0];
7310
- return _refs[key]["name"];
7508
+ function useFormItemRule(props) {
7509
+ const formContext = inject(FORM_TOKEN);
7510
+ const _rules = computed(() => {
7511
+ const rules2 = props.rules ? lodash.exports.castArray(props.rules) : [];
7512
+ const formRules = formContext.rules;
7513
+ if (formRules && props.field) {
7514
+ const _itemRules = lodash.exports.get(formRules, props.field, void 0);
7515
+ if (_itemRules) {
7516
+ rules2.push(...lodash.exports.castArray(_itemRules));
7517
+ }
7518
+ }
7519
+ if (props.required) {
7520
+ rules2.push({ required: Boolean(props.required) });
7521
+ }
7522
+ return rules2;
7523
+ });
7524
+ return { _rules };
7311
7525
  }
7312
- function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, dfcUID, popPosition, updateOn }) {
7313
- validator.validate({ modelName: modelValue }).then(() => {
7314
- handleValidatePass(el, tipEl);
7315
- }).catch((err) => {
7316
- const { errors } = err;
7317
- if (!errors || errors.length === 0)
7526
+ function useFormItemValidate(props, _rules) {
7527
+ const formContext = inject(FORM_TOKEN);
7528
+ const validateState = ref("");
7529
+ const validateMessage = ref("");
7530
+ let initFieldValue = void 0;
7531
+ let isResetting = false;
7532
+ const computedField = computed(() => {
7533
+ return typeof props.field === "string" ? props.field : "";
7534
+ });
7535
+ const fieldValue = computed(() => {
7536
+ const formData = formContext.data;
7537
+ if (!formData || !props.field) {
7318
7538
  return;
7319
- let msg = "";
7320
- if (typeof errors[0].message === "object") {
7321
- msg = errors[0].message.default;
7322
- } else {
7323
- msg = errors[0].message;
7324
7539
  }
7325
- handleValidateError({ el, tipEl, message: msg, isFormTag, messageShowType, dfcUID, popPosition, updateOn });
7540
+ return getFieldValue(formData, props.field).value;
7326
7541
  });
7327
- }
7328
- function checkValidPopsition(positionStr) {
7329
- const validPosition = ["left", "right", "top", "bottom", "left-top", "left-bottom", "top-left", "top-right", "right-top", "right-bottom", "bottom-left", "bottom-right"];
7330
- const isValid = validPosition.includes(positionStr);
7331
- !isValid && console.warn(`invalid popPosition value '${positionStr}'.`);
7332
- return isValid;
7333
- }
7334
- var dValidateRules = {
7335
- mounted(el, binding, vnode) {
7542
+ const getRuleByTrigger = (triggerVal) => {
7543
+ return _rules.value.filter((rule) => {
7544
+ if (!rule.trigger || !triggerVal) {
7545
+ return true;
7546
+ }
7547
+ if (Array.isArray(rule.trigger)) {
7548
+ return rule.trigger.includes(triggerVal);
7549
+ } else {
7550
+ return rule.trigger === triggerVal;
7551
+ }
7552
+ }).map((_a) => {
7553
+ var rule = __objRest(_a, []);
7554
+ return rule;
7555
+ });
7556
+ };
7557
+ const onValidateSuccess = () => {
7558
+ validateState.value = "success";
7559
+ validateMessage.value = "";
7560
+ formContext.emit("validate", props.field, true, "");
7561
+ };
7562
+ const onValidateError = ({ errors }) => {
7336
7563
  var _a;
7337
- const isFormTag = el.tagName === "FORM";
7338
- const dfcUID = el.parentNode.parentNode.parentElement.dataset.uid;
7339
- const refName = getRefName(binding);
7340
- const hasOptions = isObject(binding.value) && hasKey(binding.value, "options");
7341
- let {
7342
- rules: bindingRules,
7343
- options = {},
7344
- messageShowType = "popover"
7345
- } = binding.value;
7346
- let { errorStrategy } = binding.value;
7347
- if (refName) {
7348
- messageShowType = (_a = binding.instance[refName]["messageShowType"]) != null ? _a : "popover";
7349
- }
7350
- let {
7351
- updateOn = "change",
7352
- errorStrategy: ErrorStrategy = "dirty",
7353
- asyncDebounceTime = 300,
7354
- popPosition = ["right", "bottom"]
7355
- } = options;
7356
- if (messageShowType === "popover") {
7357
- if (Array.isArray(popPosition)) {
7358
- popPosition = popPosition.length > 1 ? popPosition.join("-") : popPosition[0];
7359
- if (!checkValidPopsition(popPosition)) {
7360
- popPosition = "right-bottom";
7361
- }
7362
- } else if (!checkValidPopsition(popPosition)) {
7363
- popPosition = "right-bottom";
7364
- }
7365
- }
7366
- if (!errorStrategy) {
7367
- errorStrategy = ErrorStrategy;
7368
- }
7369
- let customRule = {};
7370
- if (hasOptions) {
7371
- customRule = bindingRules != null ? bindingRules : binding.value;
7372
- } else {
7373
- customRule = binding.value;
7564
+ validateState.value = "error";
7565
+ validateMessage.value = ((_a = errors == null ? void 0 : errors[0]) == null ? void 0 : _a.message) || "";
7566
+ formContext.emit("validate", props.field, false, validateMessage.value);
7567
+ };
7568
+ const execValidate = async (rules2) => {
7569
+ const ruleName = computedField.value;
7570
+ const validator = new Schema({
7571
+ [ruleName]: rules2
7572
+ });
7573
+ return validator.validate({ [ruleName]: fieldValue.value }, { firstFields: true }).then(() => {
7574
+ onValidateSuccess();
7575
+ return true;
7576
+ }).catch((error) => {
7577
+ onValidateError(error);
7578
+ return Promise.reject(error);
7579
+ });
7580
+ };
7581
+ const validate = async (trigger, callback) => {
7582
+ if (isResetting) {
7583
+ isResetting = false;
7584
+ return false;
7374
7585
  }
7375
- const isCustomValidator = customRule && isObject(customRule) && (hasKey(customRule, "validators") || hasKey(customRule, "asyncValidators"));
7376
- const rules2 = Array.isArray(customRule) ? customRule : [customRule];
7377
- const tipEl = document.createElement("span");
7378
- if (messageShowType !== "none") {
7379
- el.parentNode.append(tipEl);
7586
+ const rules2 = getRuleByTrigger(trigger);
7587
+ if (!rules2.length) {
7588
+ callback == null ? void 0 : callback(true);
7589
+ return true;
7380
7590
  }
7381
- const descriptor = {
7382
- modelName: []
7383
- };
7384
- rules2.forEach((rule) => {
7385
- const kvObjList = !Array.isArray(rule) && getKeyValueOfObjectList(rule);
7386
- let ruleObj = {};
7387
- let avaliableRuleObj = {};
7388
- kvObjList.forEach((item) => {
7389
- avaliableRuleObj = getAvaliableRuleObj(item.key, item.value);
7390
- ruleObj = __spreadValues(__spreadValues({}, ruleObj), avaliableRuleObj);
7391
- });
7392
- descriptor.modelName.push(ruleObj);
7591
+ validateState.value = "pending";
7592
+ return execValidate(rules2).then(() => {
7593
+ callback == null ? void 0 : callback(true);
7594
+ return true;
7595
+ }).catch((error) => {
7596
+ const { fields } = error;
7597
+ callback == null ? void 0 : callback(false, fields);
7598
+ return lodash.exports.isFunction(callback) ? false : Promise.reject(fields);
7393
7599
  });
7394
- if (isCustomValidator) {
7395
- const { validators: validators2, asyncValidators } = customRule;
7396
- validators2 && validators2.forEach((item) => {
7397
- const ruleObj = {
7398
- message: (item == null ? void 0 : item.message) || "",
7399
- validator: (rule, value) => item.validator(rule, value)
7400
- };
7401
- descriptor.modelName.push(ruleObj);
7402
- });
7403
- asyncValidators && asyncValidators.forEach((item) => {
7404
- const ruleObj = {
7405
- message: (item == null ? void 0 : item.message) || "",
7406
- asyncValidator: (rule, value) => {
7407
- return new Promise(lodash.exports.debounce((resolve, reject) => {
7408
- const res = item.asyncValidator(rule, value);
7409
- if (res) {
7410
- resolve("");
7411
- } else {
7412
- reject(rule.message);
7413
- }
7414
- }, asyncDebounceTime));
7415
- }
7416
- };
7417
- descriptor.modelName.push(ruleObj);
7418
- });
7419
- }
7420
- const validator = new Schema(descriptor);
7421
- const htmlEventValidateHandler = (e) => {
7422
- const modelValue = e.target.value;
7423
- if (messageShowType === "popover") {
7424
- EventBus.emit("showPopoverErrorMessage", { showPopover: false, message: "", uid: dfcUID, popPosition, updateOn });
7425
- }
7426
- validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
7427
- };
7428
- vnode.children[0].el.addEventListener(updateOn, htmlEventValidateHandler);
7429
- if (messageShowType === "popover" && updateOn === "change") {
7430
- vnode.children[0].el.addEventListener("focus", () => {
7431
- EventBus.emit("showPopoverErrorMessage", { showPopover: false, uid: dfcUID, updateOn });
7432
- });
7600
+ };
7601
+ const clearValidate = () => {
7602
+ validateState.value = "";
7603
+ validateMessage.value = "";
7604
+ };
7605
+ const resetField = async () => {
7606
+ if (!formContext.data || !props.field) {
7607
+ return;
7433
7608
  }
7434
- if (errorStrategy === "pristine") {
7435
- handleErrorStrategy(el);
7436
- vnode.children[0].props.value = "" + vnode.children[0].props.value;
7609
+ const currentValue = getFieldValue(formContext.data, props.field);
7610
+ if (!lodash.exports.isEqual(currentValue.value, initFieldValue)) {
7611
+ isResetting = true;
7437
7612
  }
7438
- const formName = getFormName(binding);
7439
- formName && EventBus.on(`formSubmit:${formName}`, () => {
7440
- const modelValue = isFormTag ? "" : vnode.children[0].el.value;
7441
- validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, updateOn: "submit" });
7613
+ currentValue.value = initFieldValue;
7614
+ await nextTick();
7615
+ clearValidate();
7616
+ };
7617
+ onMounted(() => {
7618
+ initFieldValue = lodash.exports.clone(fieldValue.value);
7619
+ });
7620
+ return { validateState, validateMessage, validate, resetField, clearValidate };
7621
+ }
7622
+ var formItem = "";
7623
+ var FormItem = defineComponent({
7624
+ name: "DFormItem",
7625
+ props: formItemProps,
7626
+ setup(props, ctx) {
7627
+ const formContext = inject(FORM_TOKEN);
7628
+ const _a = toRefs(props), {
7629
+ messageType: itemMessageType,
7630
+ popPosition: itemPopPosition,
7631
+ showFeedback: itemShowFeedback
7632
+ } = _a, otherProps = __objRest(_a, [
7633
+ "messageType",
7634
+ "popPosition",
7635
+ "showFeedback"
7636
+ ]);
7637
+ const {
7638
+ label,
7639
+ helpTips,
7640
+ feedbackStatus,
7641
+ extraInfo
7642
+ } = toRefs(props);
7643
+ const showFeedback = computed(() => (itemShowFeedback == null ? void 0 : itemShowFeedback.value) !== void 0 ? itemShowFeedback.value : formContext.showFeedback);
7644
+ const messageType = computed(() => (itemMessageType == null ? void 0 : itemMessageType.value) || formContext.messageType);
7645
+ const popPosition = computed(() => (itemPopPosition == null ? void 0 : itemPopPosition.value) || formContext.popPosition);
7646
+ const {
7647
+ _rules
7648
+ } = useFormItemRule(props);
7649
+ const {
7650
+ validateState,
7651
+ validateMessage,
7652
+ validate,
7653
+ resetField,
7654
+ clearValidate
7655
+ } = useFormItemValidate(props, _rules);
7656
+ const {
7657
+ itemClasses,
7658
+ isRequired
7659
+ } = useFormItem(messageType, _rules, validateState);
7660
+ const labelData = computed(() => ({
7661
+ layout: formContext.layout,
7662
+ labelSize: formContext.labelSize,
7663
+ labelAlign: formContext.labelAlign
7664
+ }));
7665
+ provide(LABEL_DATA, labelData);
7666
+ const context = reactive(__spreadProps(__spreadValues({}, otherProps), {
7667
+ showFeedback,
7668
+ messageType,
7669
+ popPosition,
7670
+ isRequired,
7671
+ validateState,
7672
+ validateMessage,
7673
+ validate,
7674
+ resetField,
7675
+ clearValidate
7676
+ }));
7677
+ provide(FORM_ITEM_TOKEN, context);
7678
+ ctx.expose({
7679
+ resetField,
7680
+ clearValidate
7681
+ });
7682
+ onMounted(() => {
7683
+ if (props.field) {
7684
+ formContext == null ? void 0 : formContext.addItemContext(context);
7685
+ }
7442
7686
  });
7687
+ onBeforeUnmount(() => {
7688
+ formContext == null ? void 0 : formContext.removeItemContext(context);
7689
+ });
7690
+ return () => createVNode("div", {
7691
+ "class": itemClasses.value
7692
+ }, [createVNode(FormLabel, {
7693
+ "help-tips": helpTips.value
7694
+ }, {
7695
+ default: () => [label == null ? void 0 : label.value]
7696
+ }), createVNode(FormControl, {
7697
+ "feedback-status": feedbackStatus == null ? void 0 : feedbackStatus.value,
7698
+ "extra-info": extraInfo.value
7699
+ }, {
7700
+ default: () => {
7701
+ var _a2, _b;
7702
+ return [(_b = (_a2 = ctx.slots).default) == null ? void 0 : _b.call(_a2)];
7703
+ }
7704
+ })]);
7443
7705
  }
7444
- };
7445
- Form.install = function(app) {
7446
- app.component(Form.name, Form);
7447
- app.directive("d-validate-rules", dValidateRules);
7448
- };
7449
- FormLabel.install = function(app) {
7450
- app.component(FormLabel.name, FormLabel);
7451
- };
7452
- FormItem.install = function(app) {
7453
- app.component(FormItem.name, FormItem);
7454
- };
7455
- FormControl.install = function(app) {
7456
- app.component(FormControl.name, FormControl);
7457
- };
7458
- FormOperation.install = function(app) {
7459
- app.component(FormOperation.name, FormOperation);
7460
- };
7706
+ });
7707
+ var formOperation = "";
7708
+ var FormOperation = defineComponent({
7709
+ name: "DFormOperation",
7710
+ setup(props, ctx) {
7711
+ const formContext = inject(FORM_TOKEN);
7712
+ const LabelSizeMap = {
7713
+ sm: 80,
7714
+ md: 100,
7715
+ lg: 150
7716
+ };
7717
+ const styles = computed(() => ({
7718
+ marginLeft: formContext.layout === "horizontal" ? `${LabelSizeMap[formContext.labelSize] + 16}px` : void 0
7719
+ }));
7720
+ return () => {
7721
+ var _a, _b;
7722
+ return createVNode("div", {
7723
+ "class": "devui-form-operation",
7724
+ "style": styles.value
7725
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
7726
+ };
7727
+ }
7728
+ });
7461
7729
  var index = {
7462
7730
  title: "Form \u8868\u5355",
7463
7731
  category: "\u6570\u636E\u5F55\u5165",
7464
7732
  status: "75%",
7465
7733
  install(app) {
7466
- app.use(Form);
7467
- app.use(FormLabel);
7468
- app.use(FormItem);
7469
- app.use(FormControl);
7470
- app.use(FormOperation);
7734
+ app.component(Form.name, Form);
7735
+ app.component(FormItem.name, FormItem);
7736
+ app.component(FormOperation.name, FormOperation);
7471
7737
  }
7472
7738
  };
7473
- export { Form, FormControl, FormItem, FormLabel, FormOperation, index as default };
7739
+ export { FORM_ITEM_TOKEN, FORM_TOKEN, Form, FormItem, FormOperation, LABEL_DATA, index as default, formItemProps, formProps };