@fewangsit/wangsvue 1.5.219-alpha.1 → 1.5.219-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (588) hide show
  1. package/animation/index.es.js +54 -37
  2. package/assets/lottiejs/loading-page.es.js +14 -9
  3. package/assets/lottiejs/loading-plane.es.js +2 -2
  4. package/assets/lottiejs/loading-table.es.js +14 -9
  5. package/assets/lottiejs/no-data.es.js +14 -9
  6. package/backgroundimagecropper/index.es.js +61 -37
  7. package/badge/index.es.js +77 -67
  8. package/badgegroup/index.es.js +62 -50
  9. package/basecalendar/index.es.js +1258 -735
  10. package/basetree/index.es.js +213 -113
  11. package/breadcrumb/index.es.js +46 -38
  12. package/button/index.es.js +60 -54
  13. package/buttonbulkaction/index.es.js +168 -117
  14. package/buttoncopy/index.es.js +25 -22
  15. package/buttondownload/index.es.js +125 -76
  16. package/buttonfilter/index.es.js +21 -15
  17. package/buttonradio/index.es.js +91 -67
  18. package/buttonsearch/index.es.js +62 -46
  19. package/buttonselecttree/index.es.js +233 -172
  20. package/buttontoggle/index.es.js +8 -6
  21. package/calendar/index.es.js +113 -58
  22. package/card/index.es.js +44 -42
  23. package/checkbox/index.es.js +105 -74
  24. package/codesnippet/index.es.js +91 -71
  25. package/codesnippetadapter/index.es.js +25 -21
  26. package/columnlist/index.es.js +249 -171
  27. package/components.d.ts +0 -21
  28. package/config/defaultProps.es.js +9 -9
  29. package/config/index.es.js +11 -10
  30. package/config/locale.es.js +2 -2
  31. package/customcolumn/index.es.js +95 -78
  32. package/datatable/index.es.js +1071 -732
  33. package/dialog/index.es.js +54 -54
  34. package/dialogconfirm/index.es.js +90 -75
  35. package/dialogform/index.es.js +170 -133
  36. package/dialogselecttree/index.es.js +242 -194
  37. package/directives/focus.es.js +13 -8
  38. package/dropdown/index.es.js +250 -196
  39. package/editor/index.es.js +694 -498
  40. package/editorbutton/index.es.js +21 -19
  41. package/event-bus/index.es.js +3 -3
  42. package/event-bus/mitt.es.js +37 -20
  43. package/fieldwrapper/index.es.js +30 -25
  44. package/fileupload/index.es.js +230 -140
  45. package/filtercontainer/index.es.js +299 -222
  46. package/form/index.es.js +176 -126
  47. package/gallerypreview/index.es.js +138 -101
  48. package/icon/index.es.js +38 -36
  49. package/image/index.es.js +161 -108
  50. package/imagecompressor/index.es.js +616 -449
  51. package/imageinputinfo/index.es.js +26 -22
  52. package/inlinemessage/index.es.js +77 -65
  53. package/inputbadge/index.es.js +230 -156
  54. package/inputcurrency/index.es.js +146 -109
  55. package/inputemail/index.es.js +18 -16
  56. package/inputgroup/index.es.js +19 -16
  57. package/inputnumber/index.es.js +252 -182
  58. package/inputpassword/index.es.js +120 -94
  59. package/inputphonenumber/index.es.js +1017 -550
  60. package/inputrangenumber/index.es.js +129 -98
  61. package/inputtext/index.es.js +264 -189
  62. package/inputurl/index.es.js +31 -29
  63. package/invisiblefield/index.es.js +24 -16
  64. package/litedropdown/index.es.js +87 -81
  65. package/loading/index.es.js +21 -19
  66. package/loading-page-BXZ4fLOS.js +8 -0
  67. package/loading-page-BuLpsb_1.js +8 -0
  68. package/loading-page-CNqVBg__.js +4 -0
  69. package/loading-page-DbhhZih2.js +4 -0
  70. package/loading-page-DjfWXoOy.js +8 -0
  71. package/loading-page-S-KRY5zm.js +4 -0
  72. package/loading-plane-C1mi7Whv.js +4 -0
  73. package/loading-plane-CWq1hz_l.js +8 -0
  74. package/loading-table-B7LAXzAp.js +4 -0
  75. package/loading-table-BLmgKUsR.js +4 -0
  76. package/loading-table-CG7-cuhv.js +8 -0
  77. package/loading-table-CUPS49ta.js +4 -0
  78. package/loading-table-CuWWrTbv.js +8 -0
  79. package/loading-table-DbBzVwaZ.js +8 -0
  80. package/mentionlist/index.es.js +77 -44
  81. package/mentionsection/index.es.js +53 -43
  82. package/menu/index.es.js +65 -51
  83. package/menuitem/index.es.js +39 -37
  84. package/multirow/index.es.js +29 -28
  85. package/multiselect/index.es.js +184 -152
  86. package/no-data-B781skt3.js +4 -0
  87. package/no-data-CAksOnDl.js +4 -0
  88. package/no-data-DCsjBXQR.js +4 -0
  89. package/no-data-Dz0QOe7Q.js +8 -0
  90. package/no-data-_Huxiv9q.js +8 -0
  91. package/no-data-ybRQontJ.js +8 -0
  92. package/overlaypanel/index.es.js +49 -36
  93. package/package.json +1 -1
  94. package/paginator/index.es.js +36 -33
  95. package/plugins/WangsVue.es.js +63 -45
  96. package/plugins/formValidation.es.js +15 -11
  97. package/progressbar/index.es.js +39 -32
  98. package/quickfilter/index.es.js +94 -81
  99. package/stats.html +1 -1
  100. package/style.css +1 -1
  101. package/tabmenu/index.es.js +18 -16
  102. package/textarea/index.es.js +94 -72
  103. package/timeline/index.es.js +124 -102
  104. package/timelinecontentbytype/index.es.js +114 -92
  105. package/toast/index.es.js +67 -54
  106. package/toggleswitch/index.es.js +83 -66
  107. package/tree/index.es.js +306 -198
  108. package/treenode/index.es.js +464 -339
  109. package/treesearchinput/index.es.js +32 -26
  110. package/usergroup/index.es.js +83 -67
  111. package/username/index.es.js +99 -85
  112. package/utils/addAttachment.util.es.js +47 -21
  113. package/utils/baseToast.util.es.js +41 -33
  114. package/utils/convertJsonImage.util.es.js +24 -24
  115. package/utils/date.util.es.js +131 -106
  116. package/utils/exportToExcel.util.es.js +81 -47
  117. package/utils/filterOptions.util.es.js +8 -2
  118. package/utils/genPlaceholder.util.es.js +30 -16
  119. package/utils/getProjectPermission.util.es.js +15 -12
  120. package/utils/getSalesRole.util.es.js +4 -4
  121. package/utils/getUser.util.es.js +2 -2
  122. package/utils/getUserType.util.es.js +13 -8
  123. package/utils/isIntersect.es.js +4 -2
  124. package/utils/mergePropsWithDefaults.util.es.js +7 -6
  125. package/utils/object.util.es.js +88 -54
  126. package/utils/queryParamsStringfy.util.es.js +19 -11
  127. package/utils/role.util.es.js +5 -4
  128. package/utils/statusSeverity.util.es.js +20 -5
  129. package/utils/textFormatter.util.es.js +28 -50
  130. package/utils/toast.util.es.js +8 -5
  131. package/utils/xlsx.util.es.js +12 -6
  132. package/validatormessage/index.es.js +9 -9
  133. package/vendor/@popperjs/core/lib/createPopper.es.js +110 -83
  134. package/vendor/@popperjs/core/lib/dom-utils/contains.es.js +14 -13
  135. package/vendor/@popperjs/core/lib/dom-utils/getBoundingClientRect.es.js +33 -18
  136. package/vendor/@popperjs/core/lib/dom-utils/getClippingRect.es.js +55 -31
  137. package/vendor/@popperjs/core/lib/dom-utils/getCompositeRect.es.js +43 -22
  138. package/vendor/@popperjs/core/lib/dom-utils/getComputedStyle.es.js +4 -4
  139. package/vendor/@popperjs/core/lib/dom-utils/getDocumentElement.es.js +5 -5
  140. package/vendor/@popperjs/core/lib/dom-utils/getDocumentRect.es.js +23 -13
  141. package/vendor/@popperjs/core/lib/dom-utils/getHTMLElementScroll.es.js +4 -4
  142. package/vendor/@popperjs/core/lib/dom-utils/getLayoutRect.es.js +17 -9
  143. package/vendor/@popperjs/core/lib/dom-utils/getNodeName.es.js +3 -3
  144. package/vendor/@popperjs/core/lib/dom-utils/getNodeScroll.es.js +11 -7
  145. package/vendor/@popperjs/core/lib/dom-utils/getOffsetParent.es.js +42 -26
  146. package/vendor/@popperjs/core/lib/dom-utils/getParentNode.es.js +13 -10
  147. package/vendor/@popperjs/core/lib/dom-utils/getScrollParent.es.js +13 -7
  148. package/vendor/@popperjs/core/lib/dom-utils/getViewportRect.es.js +25 -15
  149. package/vendor/@popperjs/core/lib/dom-utils/getWindow.es.js +8 -7
  150. package/vendor/@popperjs/core/lib/dom-utils/getWindowScroll.es.js +8 -6
  151. package/vendor/@popperjs/core/lib/dom-utils/getWindowScrollBarX.es.js +6 -6
  152. package/vendor/@popperjs/core/lib/dom-utils/instanceOf.es.js +16 -15
  153. package/vendor/@popperjs/core/lib/dom-utils/isLayoutViewport.es.js +4 -4
  154. package/vendor/@popperjs/core/lib/dom-utils/isScrollParent.es.js +5 -5
  155. package/vendor/@popperjs/core/lib/dom-utils/isTableElement.es.js +4 -4
  156. package/vendor/@popperjs/core/lib/dom-utils/listScrollParents.es.js +17 -11
  157. package/vendor/@popperjs/core/lib/enums.es.js +43 -20
  158. package/vendor/@popperjs/core/lib/modifiers/applyStyles.es.js +49 -25
  159. package/vendor/@popperjs/core/lib/modifiers/arrow.es.js +61 -26
  160. package/vendor/@popperjs/core/lib/modifiers/computeStyles.es.js +101 -69
  161. package/vendor/@popperjs/core/lib/modifiers/eventListeners.es.js +30 -16
  162. package/vendor/@popperjs/core/lib/modifiers/flip.es.js +99 -60
  163. package/vendor/@popperjs/core/lib/modifiers/hide.es.js +44 -31
  164. package/vendor/@popperjs/core/lib/modifiers/offset.es.js +32 -20
  165. package/vendor/@popperjs/core/lib/modifiers/popperOffsets.es.js +11 -11
  166. package/vendor/@popperjs/core/lib/modifiers/preventOverflow.es.js +91 -40
  167. package/vendor/@popperjs/core/lib/popper.es.js +14 -13
  168. package/vendor/@popperjs/core/lib/utils/computeAutoPlacement.es.js +29 -21
  169. package/vendor/@popperjs/core/lib/utils/computeOffsets.es.js +41 -36
  170. package/vendor/@popperjs/core/lib/utils/debounce.es.js +11 -7
  171. package/vendor/@popperjs/core/lib/utils/detectOverflow.es.js +42 -28
  172. package/vendor/@popperjs/core/lib/utils/expandToHashMap.es.js +5 -4
  173. package/vendor/@popperjs/core/lib/utils/getAltAxis.es.js +3 -3
  174. package/vendor/@popperjs/core/lib/utils/getBasePlacement.es.js +3 -3
  175. package/vendor/@popperjs/core/lib/utils/getFreshSideObject.es.js +2 -2
  176. package/vendor/@popperjs/core/lib/utils/getMainAxisFromPlacement.es.js +3 -3
  177. package/vendor/@popperjs/core/lib/utils/getOppositePlacement.es.js +5 -5
  178. package/vendor/@popperjs/core/lib/utils/getOppositeVariationPlacement.es.js +5 -5
  179. package/vendor/@popperjs/core/lib/utils/getVariation.es.js +3 -3
  180. package/vendor/@popperjs/core/lib/utils/math.es.js +6 -4
  181. package/vendor/@popperjs/core/lib/utils/mergeByName.es.js +11 -10
  182. package/vendor/@popperjs/core/lib/utils/mergePaddingObject.es.js +4 -4
  183. package/vendor/@popperjs/core/lib/utils/orderModifiers.es.js +30 -22
  184. package/vendor/@popperjs/core/lib/utils/rectToClientRect.es.js +7 -7
  185. package/vendor/@popperjs/core/lib/utils/userAgent.es.js +9 -6
  186. package/vendor/@popperjs/core/lib/utils/within.es.js +8 -8
  187. package/vendor/@tiptap/core/dist/index.es.js +3494 -2000
  188. package/vendor/@tiptap/extension-bold/dist/index.es.js +29 -19
  189. package/vendor/@tiptap/extension-bubble-menu/dist/index.es.js +145 -71
  190. package/vendor/@tiptap/extension-bullet-list/dist/index.es.js +32 -19
  191. package/vendor/@tiptap/extension-code/dist/index.es.js +22 -14
  192. package/vendor/@tiptap/extension-document/dist/index.es.js +4 -4
  193. package/vendor/@tiptap/extension-floating-menu/dist/index.es.js +106 -51
  194. package/vendor/@tiptap/extension-heading/dist/index.es.js +38 -22
  195. package/vendor/@tiptap/extension-history/dist/index.es.js +11 -7
  196. package/vendor/@tiptap/extension-image/dist/index.es.js +20 -17
  197. package/vendor/@tiptap/extension-italic/dist/index.es.js +28 -18
  198. package/vendor/@tiptap/extension-link/dist/index.es.js +236 -147
  199. package/vendor/@tiptap/extension-list-item/dist/index.es.js +6 -6
  200. package/vendor/@tiptap/extension-mention/dist/index.es.js +98 -63
  201. package/vendor/@tiptap/extension-ordered-list/dist/index.es.js +38 -25
  202. package/vendor/@tiptap/extension-paragraph/dist/index.es.js +8 -6
  203. package/vendor/@tiptap/extension-placeholder/dist/index.es.js +34 -27
  204. package/vendor/@tiptap/extension-text/dist/index.es.js +3 -3
  205. package/vendor/@tiptap/extension-underline/dist/index.es.js +16 -10
  206. package/vendor/@tiptap/suggestion/dist/index.es.js +174 -90
  207. package/vendor/@tiptap/vue-3/dist/index.es.js +287 -188
  208. package/vendor/@wangs-ui/core/components/p-BU8h34na.es.js +17 -14
  209. package/vendor/@wangs-ui/core/components/p-C5lMEBcj.es.js +69 -55
  210. package/vendor/@wangs-ui/core/components/p-CKYwZoTo.es.js +26 -22
  211. package/vendor/@wangs-ui/core/components/p-CsoK-EWG.es.js +147 -102
  212. package/vendor/@wangs-ui/core/components/p-DPHEi31J.es.js +102 -77
  213. package/vendor/@wangs-ui/core/components/p-DTTCzifR.es.js +1298 -551
  214. package/vendor/@wangs-ui/core/components/p-Duri5p90.es.js +60 -49
  215. package/vendor/@wangs-ui/core/components/wangs-button.es.js +19 -15
  216. package/vendor/@wangs-ui/core/components/wangs-icon.es.js +3 -3
  217. package/vendor/@wangs-ui/core/components/wangs-input-otp.es.js +3 -3
  218. package/vendor/@wangs-ui/core/components/wangs-tab-menu.es.js +3 -3
  219. package/vendor/@wangs-ui/core/dist/esm/index-DCkh3cGv.es.js +116 -102
  220. package/vendor/@wangs-ui/vue/dist/index.es.js +77 -77
  221. package/vendor/base64toblob/base64toblob.es.js +31 -15
  222. package/vendor/highlight.js/es/core.es.js +5 -5
  223. package/vendor/highlight.js/es/languages/javascript.es.js +237 -193
  224. package/vendor/highlight.js/es/languages/json.es.js +18 -15
  225. package/vendor/highlight.js/es/languages/typescript.es.js +288 -228
  226. package/vendor/highlight.js/es/languages/vbscript-html.es.js +2 -2
  227. package/vendor/highlight.js/lib/core.es.js +1144 -666
  228. package/vendor/linkifyjs/dist/linkify.es.es.js +858 -405
  229. package/vendor/lodash/_Symbol.es.js +11 -8
  230. package/vendor/lodash/_baseGetTag.es.js +19 -12
  231. package/vendor/lodash/_baseTrim.es.js +13 -10
  232. package/vendor/lodash/_freeGlobal.es.js +10 -8
  233. package/vendor/lodash/_getRawTag.es.js +28 -15
  234. package/vendor/lodash/_objectToString.es.js +12 -9
  235. package/vendor/lodash/_root.es.js +12 -8
  236. package/vendor/lodash/_trimmedEndIndex.es.js +14 -11
  237. package/vendor/lodash/debounce.es.js +92 -54
  238. package/vendor/lodash/isObject.es.js +11 -9
  239. package/vendor/lodash/isObjectLike.es.js +10 -8
  240. package/vendor/lodash/isSymbol.es.js +14 -11
  241. package/vendor/lodash/now.es.js +12 -9
  242. package/vendor/lodash/throttle.es.js +25 -17
  243. package/vendor/lodash/toNumber.es.js +33 -23
  244. package/vendor/lodash-es/_DataView.es.js +4 -4
  245. package/vendor/lodash-es/_Hash.es.js +17 -16
  246. package/vendor/lodash-es/_ListCache.es.js +17 -16
  247. package/vendor/lodash-es/_Map.es.js +4 -4
  248. package/vendor/lodash-es/_MapCache.es.js +17 -16
  249. package/vendor/lodash-es/_Promise.es.js +4 -4
  250. package/vendor/lodash-es/_Set.es.js +4 -4
  251. package/vendor/lodash-es/_SetCache.es.js +12 -10
  252. package/vendor/lodash-es/_Stack.es.js +15 -15
  253. package/vendor/lodash-es/_Symbol.es.js +3 -3
  254. package/vendor/lodash-es/_Uint8Array.es.js +3 -3
  255. package/vendor/lodash-es/_WeakMap.es.js +4 -4
  256. package/vendor/lodash-es/_arrayEach.es.js +9 -5
  257. package/vendor/lodash-es/_arrayFilter.es.js +9 -6
  258. package/vendor/lodash-es/_arrayLikeKeys.es.js +21 -17
  259. package/vendor/lodash-es/_arrayPush.es.js +7 -5
  260. package/vendor/lodash-es/_arraySome.es.js +9 -6
  261. package/vendor/lodash-es/_assignValue.es.js +10 -7
  262. package/vendor/lodash-es/_assocIndexOf.es.js +9 -6
  263. package/vendor/lodash-es/_baseAssignValue.es.js +13 -9
  264. package/vendor/lodash-es/_baseClone.es.js +67 -49
  265. package/vendor/lodash-es/_baseCreate.es.js +15 -11
  266. package/vendor/lodash-es/_baseGetAllKeys.es.js +6 -6
  267. package/vendor/lodash-es/_baseGetTag.es.js +11 -7
  268. package/vendor/lodash-es/_baseIsArguments.es.js +6 -6
  269. package/vendor/lodash-es/_baseIsEqual.es.js +11 -5
  270. package/vendor/lodash-es/_baseIsEqualDeep.es.js +39 -26
  271. package/vendor/lodash-es/_baseIsMap.es.js +6 -6
  272. package/vendor/lodash-es/_baseIsNative.es.js +18 -12
  273. package/vendor/lodash-es/_baseIsSet.es.js +6 -6
  274. package/vendor/lodash-es/_baseIsTypedArray.es.js +11 -9
  275. package/vendor/lodash-es/_baseKeys.es.js +16 -11
  276. package/vendor/lodash-es/_baseTimes.es.js +7 -5
  277. package/vendor/lodash-es/_baseTrim.es.js +5 -5
  278. package/vendor/lodash-es/_baseUnary.es.js +4 -4
  279. package/vendor/lodash-es/_cacheHas.es.js +3 -3
  280. package/vendor/lodash-es/_cloneArrayBuffer.es.js +6 -5
  281. package/vendor/lodash-es/_cloneBuffer.es.js +11 -6
  282. package/vendor/lodash-es/_cloneDataView.es.js +5 -5
  283. package/vendor/lodash-es/_cloneRegExp.es.js +6 -5
  284. package/vendor/lodash-es/_cloneSymbol.es.js +5 -5
  285. package/vendor/lodash-es/_cloneTypedArray.es.js +5 -5
  286. package/vendor/lodash-es/_coreJsData.es.js +3 -3
  287. package/vendor/lodash-es/_defineProperty.es.js +7 -6
  288. package/vendor/lodash-es/_equalArrays.es.js +38 -28
  289. package/vendor/lodash-es/_equalByTag.es.js +55 -41
  290. package/vendor/lodash-es/_equalObjects.es.js +42 -28
  291. package/vendor/lodash-es/_freeGlobal.es.js +2 -2
  292. package/vendor/lodash-es/_getAllKeys.es.js +6 -6
  293. package/vendor/lodash-es/_getMapData.es.js +5 -5
  294. package/vendor/lodash-es/_getNative.es.js +6 -6
  295. package/vendor/lodash-es/_getPrototype.es.js +3 -3
  296. package/vendor/lodash-es/_getRawTag.es.js +20 -10
  297. package/vendor/lodash-es/_getSymbols.es.js +15 -8
  298. package/vendor/lodash-es/_getTag.es.js +31 -25
  299. package/vendor/lodash-es/_getValue.es.js +3 -3
  300. package/vendor/lodash-es/_hashClear.es.js +5 -4
  301. package/vendor/lodash-es/_hashDelete.es.js +5 -4
  302. package/vendor/lodash-es/_hashGet.es.js +11 -9
  303. package/vendor/lodash-es/_hashHas.es.js +7 -6
  304. package/vendor/lodash-es/_hashSet.es.js +8 -6
  305. package/vendor/lodash-es/_initCloneArray.es.js +10 -5
  306. package/vendor/lodash-es/_initCloneByTag.es.js +39 -38
  307. package/vendor/lodash-es/_initCloneObject.es.js +6 -6
  308. package/vendor/lodash-es/_isIndex.es.js +7 -5
  309. package/vendor/lodash-es/_isKeyable.es.js +4 -4
  310. package/vendor/lodash-es/_isMasked.es.js +7 -7
  311. package/vendor/lodash-es/_isPrototype.es.js +5 -5
  312. package/vendor/lodash-es/_listCacheClear.es.js +4 -3
  313. package/vendor/lodash-es/_listCacheDelete.es.js +17 -9
  314. package/vendor/lodash-es/_listCacheGet.es.js +5 -5
  315. package/vendor/lodash-es/_listCacheHas.es.js +4 -4
  316. package/vendor/lodash-es/_listCacheSet.es.js +11 -5
  317. package/vendor/lodash-es/_mapCacheClear.es.js +10 -9
  318. package/vendor/lodash-es/_mapCacheDelete.es.js +6 -5
  319. package/vendor/lodash-es/_mapCacheGet.es.js +4 -4
  320. package/vendor/lodash-es/_mapCacheHas.es.js +4 -4
  321. package/vendor/lodash-es/_mapCacheSet.es.js +7 -5
  322. package/vendor/lodash-es/_mapToArray.es.js +7 -6
  323. package/vendor/lodash-es/_nativeCreate.es.js +3 -3
  324. package/vendor/lodash-es/_nativeKeys.es.js +3 -3
  325. package/vendor/lodash-es/_nodeUtil.es.js +13 -6
  326. package/vendor/lodash-es/_objectToString.es.js +5 -4
  327. package/vendor/lodash-es/_overArg.es.js +4 -4
  328. package/vendor/lodash-es/_root.es.js +4 -3
  329. package/vendor/lodash-es/_setCacheAdd.es.js +5 -4
  330. package/vendor/lodash-es/_setCacheHas.es.js +3 -3
  331. package/vendor/lodash-es/_setToArray.es.js +7 -6
  332. package/vendor/lodash-es/_stackClear.es.js +5 -4
  333. package/vendor/lodash-es/_stackDelete.es.js +5 -4
  334. package/vendor/lodash-es/_stackGet.es.js +3 -3
  335. package/vendor/lodash-es/_stackHas.es.js +3 -3
  336. package/vendor/lodash-es/_stackSet.es.js +18 -13
  337. package/vendor/lodash-es/_toSource.es.js +9 -8
  338. package/vendor/lodash-es/_trimmedEndIndex.es.js +7 -6
  339. package/vendor/lodash-es/cloneDeep.es.js +5 -5
  340. package/vendor/lodash-es/debounce.es.js +84 -49
  341. package/vendor/lodash-es/eq.es.js +3 -3
  342. package/vendor/lodash-es/isArguments.es.js +9 -6
  343. package/vendor/lodash-es/isArray.es.js +2 -2
  344. package/vendor/lodash-es/isArrayLike.es.js +5 -5
  345. package/vendor/lodash-es/isBuffer.es.js +9 -4
  346. package/vendor/lodash-es/isEqual.es.js +4 -4
  347. package/vendor/lodash-es/isFunction.es.js +10 -9
  348. package/vendor/lodash-es/isLength.es.js +4 -4
  349. package/vendor/lodash-es/isMap.es.js +6 -5
  350. package/vendor/lodash-es/isObject.es.js +4 -4
  351. package/vendor/lodash-es/isObjectLike.es.js +3 -3
  352. package/vendor/lodash-es/isSet.es.js +6 -5
  353. package/vendor/lodash-es/isSymbol.es.js +6 -6
  354. package/vendor/lodash-es/isTypedArray.es.js +6 -5
  355. package/vendor/lodash-es/keys.es.js +6 -6
  356. package/vendor/lodash-es/now.es.js +4 -4
  357. package/vendor/lodash-es/stubArray.es.js +2 -2
  358. package/vendor/lodash-es/stubFalse.es.js +3 -3
  359. package/vendor/lodash-es/toNumber.es.js +25 -18
  360. package/vendor/lodash-es/toString.es.js +2 -2
  361. package/vendor/lodash-es/uniqueId.es.js +6 -6
  362. package/vendor/orderedmap/dist/index.es.js +65 -49
  363. package/vendor/primevue/api/api.esm.es.js +214 -121
  364. package/vendor/primevue/avatar/avatar.esm.es.js +44 -41
  365. package/vendor/primevue/avatar/style/avatarstyle.esm.es.js +12 -11
  366. package/vendor/primevue/avatargroup/avatargroup.esm.es.js +17 -16
  367. package/vendor/primevue/avatargroup/style/avatargroupstyle.esm.es.js +6 -5
  368. package/vendor/primevue/badge/badge.esm.es.js +21 -20
  369. package/vendor/primevue/badge/style/badgestyle.esm.es.js +19 -18
  370. package/vendor/primevue/base/style/basestyle.esm.es.js +88 -99
  371. package/vendor/primevue/basecomponent/basecomponent.esm.es.js +327 -261
  372. package/vendor/primevue/basedirective/basedirective.esm.es.js +257 -186
  373. package/vendor/primevue/baseicon/baseicon.esm.es.js +55 -49
  374. package/vendor/primevue/baseicon/style/baseiconstyle.esm.es.js +5 -35
  375. package/vendor/primevue/button/button.esm.es.js +76 -72
  376. package/vendor/primevue/button/style/buttonstyle.esm.es.js +46 -39
  377. package/vendor/primevue/card/card.esm.es.js +30 -29
  378. package/vendor/primevue/card/style/cardstyle.esm.es.js +6 -5
  379. package/vendor/primevue/checkbox/checkbox.esm.es.js +109 -101
  380. package/vendor/primevue/checkbox/style/checkboxstyle.esm.es.js +12 -11
  381. package/vendor/primevue/config/config.esm.es.js +76 -58
  382. package/vendor/primevue/dialog/dialog.esm.es.js +421 -281
  383. package/vendor/primevue/dialog/style/dialogstyle.esm.es.js +26 -22
  384. package/vendor/primevue/dropdown/dropdown.esm.es.js +956 -742
  385. package/vendor/primevue/dropdown/style/dropdownstyle.esm.es.js +33 -31
  386. package/vendor/primevue/fileupload/fileupload.esm.es.js +559 -450
  387. package/vendor/primevue/fileupload/style/fileuploadstyle.esm.es.js +14 -13
  388. package/vendor/primevue/focustrap/focustrap.esm.es.js +128 -90
  389. package/vendor/primevue/focustrap/style/focustrapstyle.esm.es.js +2 -2
  390. package/vendor/primevue/icons/angledoubleleft/index.esm.es.js +13 -11
  391. package/vendor/primevue/icons/angledoubleright/index.esm.es.js +13 -11
  392. package/vendor/primevue/icons/angledown/index.esm.es.js +13 -11
  393. package/vendor/primevue/icons/angleleft/index.esm.es.js +13 -11
  394. package/vendor/primevue/icons/angleright/index.esm.es.js +13 -11
  395. package/vendor/primevue/icons/angleup/index.esm.es.js +13 -11
  396. package/vendor/primevue/icons/blank/index.esm.es.js +13 -11
  397. package/vendor/primevue/icons/check/index.esm.es.js +13 -11
  398. package/vendor/primevue/icons/chevrondown/index.esm.es.js +13 -11
  399. package/vendor/primevue/icons/exclamationtriangle/index.esm.es.js +17 -13
  400. package/vendor/primevue/icons/eye/index.esm.es.js +13 -11
  401. package/vendor/primevue/icons/eyeslash/index.esm.es.js +13 -11
  402. package/vendor/primevue/icons/infocircle/index.esm.es.js +13 -11
  403. package/vendor/primevue/icons/plus/index.esm.es.js +13 -11
  404. package/vendor/primevue/icons/refresh/index.esm.es.js +13 -11
  405. package/vendor/primevue/icons/search/index.esm.es.js +13 -11
  406. package/vendor/primevue/icons/searchminus/index.esm.es.js +13 -11
  407. package/vendor/primevue/icons/searchplus/index.esm.es.js +13 -11
  408. package/vendor/primevue/icons/spinner/index.esm.es.js +13 -11
  409. package/vendor/primevue/icons/times/index.esm.es.js +13 -11
  410. package/vendor/primevue/icons/timescircle/index.esm.es.js +13 -11
  411. package/vendor/primevue/icons/undo/index.esm.es.js +13 -11
  412. package/vendor/primevue/icons/upload/index.esm.es.js +13 -11
  413. package/vendor/primevue/icons/windowmaximize/index.esm.es.js +13 -11
  414. package/vendor/primevue/icons/windowminimize/index.esm.es.js +13 -11
  415. package/vendor/primevue/image/image.esm.es.js +280 -235
  416. package/vendor/primevue/image/style/imagestyle.esm.es.js +18 -17
  417. package/vendor/primevue/inputgroup/inputgroup.esm.es.js +17 -16
  418. package/vendor/primevue/inputgroup/style/inputgroupstyle.esm.es.js +6 -5
  419. package/vendor/primevue/inputgroupaddon/inputgroupaddon.esm.es.js +17 -16
  420. package/vendor/primevue/inputgroupaddon/style/inputgroupaddonstyle.esm.es.js +6 -5
  421. package/vendor/primevue/inputnumber/inputnumber.esm.es.js +834 -566
  422. package/vendor/primevue/inputnumber/style/inputnumberstyle.esm.es.js +23 -22
  423. package/vendor/primevue/inputtext/inputtext.esm.es.js +32 -30
  424. package/vendor/primevue/inputtext/style/inputtextstyle.esm.es.js +13 -12
  425. package/vendor/primevue/menu/menu.esm.es.js +402 -304
  426. package/vendor/primevue/menu/style/menustyle.esm.es.js +14 -13
  427. package/vendor/primevue/message/message.esm.es.js +126 -112
  428. package/vendor/primevue/message/style/messagestyle.esm.es.js +9 -8
  429. package/vendor/primevue/multiselect/multiselect.esm.es.js +1083 -835
  430. package/vendor/primevue/multiselect/style/multiselectstyle.esm.es.js +38 -36
  431. package/vendor/primevue/overlayeventbus/overlayeventbus.esm.es.js +3 -3
  432. package/vendor/primevue/overlaypanel/overlaypanel.esm.es.js +275 -169
  433. package/vendor/primevue/overlaypanel/style/overlaypanelstyle.esm.es.js +9 -8
  434. package/vendor/primevue/paginator/paginator.esm.es.js +513 -469
  435. package/vendor/primevue/paginator/style/paginatorstyle.esm.es.js +50 -43
  436. package/vendor/primevue/password/password.esm.es.js +306 -233
  437. package/vendor/primevue/password/style/passwordstyle.esm.es.js +26 -24
  438. package/vendor/primevue/portal/portal.esm.es.js +17 -17
  439. package/vendor/primevue/progressbar/progressbar.esm.es.js +37 -35
  440. package/vendor/primevue/progressbar/style/progressbarstyle.esm.es.js +10 -9
  441. package/vendor/primevue/ripple/ripple.esm.es.js +90 -62
  442. package/vendor/primevue/ripple/style/ripplestyle.esm.es.js +6 -5
  443. package/vendor/primevue/selectbutton/selectbutton.esm.es.js +213 -167
  444. package/vendor/primevue/selectbutton/style/selectbuttonstyle.esm.es.js +14 -13
  445. package/vendor/primevue/skeleton/skeleton.esm.es.js +28 -26
  446. package/vendor/primevue/skeleton/style/skeletonstyle.esm.es.js +13 -11
  447. package/vendor/primevue/textarea/style/textareastyle.esm.es.js +12 -11
  448. package/vendor/primevue/textarea/textarea.esm.es.js +49 -33
  449. package/vendor/primevue/timeline/style/timelinestyle.esm.es.js +9 -8
  450. package/vendor/primevue/timeline/timeline.esm.es.js +53 -52
  451. package/vendor/primevue/toast/style/toaststyle.esm.es.js +54 -46
  452. package/vendor/primevue/toast/toast.esm.es.js +309 -260
  453. package/vendor/primevue/toasteventbus/toasteventbus.esm.es.js +3 -3
  454. package/vendor/primevue/toastservice/toastservice.esm.es.js +16 -15
  455. package/vendor/primevue/tooltip/style/tooltipstyle.esm.es.js +6 -5
  456. package/vendor/primevue/tooltip/tooltip.esm.es.js +383 -186
  457. package/vendor/primevue/usestyle/usestyle.esm.es.js +94 -64
  458. package/vendor/primevue/usetoast/usetoast.esm.es.js +9 -8
  459. package/vendor/primevue/utils/utils.esm.es.js +1078 -772
  460. package/vendor/primevue/virtualscroller/style/virtualscrollerstyle.esm.es.js +5 -67
  461. package/vendor/primevue/virtualscroller/virtualscroller.esm.es.js +655 -428
  462. package/vendor/prosemirror-commands/dist/index.es.js +454 -316
  463. package/vendor/prosemirror-history/dist/index.es.js +286 -178
  464. package/vendor/prosemirror-keymap/dist/index.es.js +68 -48
  465. package/vendor/prosemirror-model/dist/index.es.js +1905 -1436
  466. package/vendor/prosemirror-schema-list/dist/index.es.js +115 -73
  467. package/vendor/prosemirror-state/dist/index.es.js +467 -353
  468. package/vendor/prosemirror-transform/dist/index.es.js +1146 -829
  469. package/vendor/prosemirror-view/dist/index.es.js +4127 -2719
  470. package/vendor/rope-sequence/dist/index.es.js +165 -82
  471. package/vendor/simplebar-core/dist/index.es.js +670 -242
  472. package/vendor/simplebar-vue/dist/simplebar-vue.esm.es.js +73 -60
  473. package/vendor/single-spa/lib/es2015/esm/single-spa.min.es.js +511 -510
  474. package/vendor/tippy.js/dist/tippy.esm.es.js +971 -525
  475. package/vendor/vee-validate/dist/vee-validate.esm.es.js +1830 -1097
  476. package/vendor/vue-advanced-cropper/dist/index.esm-bundler.es.js +740 -738
  477. package/vendor/w3c-keyname/index.es.js +25 -13
  478. package/wangsvue.es.js +167 -208
  479. package/wangsvue.esm.browser.js +67705 -0
  480. package/wangsvue.system.js +67600 -234
  481. package/api/index.es.js +0 -149
  482. package/apiitem/index.es.js +0 -611
  483. package/assignmember/index.es.js +0 -434
  484. package/attachment/index.es.js +0 -118
  485. package/attachmentchangelog/index.es.js +0 -79
  486. package/attachmentitem/index.es.js +0 -231
  487. package/attachmentthumbnail/index.es.js +0 -83
  488. package/changelog/index.d.ts +0 -164
  489. package/changelog/index.es.js +0 -85
  490. package/changelogfilter/index.es.js +0 -113
  491. package/changelogpage/index.d.ts +0 -184
  492. package/changelogpage/index.es.js +0 -176
  493. package/checklist/index.es.js +0 -571
  494. package/checklistchangelog/index.es.js +0 -85
  495. package/comment/index.d.ts +0 -187
  496. package/comment/index.es.js +0 -267
  497. package/commentblock/index.es.js +0 -337
  498. package/confirmdeploy/index.es.js +0 -64
  499. package/dependencycol/index.es.js +0 -32
  500. package/description/index.es.js +0 -135
  501. package/descriptiontab/index.es.js +0 -30
  502. package/detailmember/index.d.ts +0 -77
  503. package/detailmember/index.es.js +0 -32
  504. package/detailmemberadmin/index.es.js +0 -210
  505. package/detailmemberleader/index.es.js +0 -164
  506. package/detailmemberlog/index.es.js +0 -117
  507. package/detailsprint/index.d.ts +0 -86
  508. package/detailsprint/index.es.js +0 -414
  509. package/dialogaddattachment/index.es.js +0 -273
  510. package/dialogaddchecklist/index.es.js +0 -120
  511. package/dialogaddeditapi/index.es.js +0 -87
  512. package/dialogaddpbi/index.es.js +0 -197
  513. package/dialogadjustmenttask/index.es.js +0 -484
  514. package/dialogadjustmenttaskheader/index.es.js +0 -193
  515. package/dialogapichangelog/index.es.js +0 -83
  516. package/dialogassignmember/index.es.js +0 -171
  517. package/dialogconfirmapproval/index.es.js +0 -54
  518. package/dialogconfirmchecklist/index.es.js +0 -189
  519. package/dialogconfirmdeletetask/index.es.js +0 -70
  520. package/dialogconfirmdeletetaskpermanently/index.es.js +0 -50
  521. package/dialogconfirmedit/index.es.js +0 -50
  522. package/dialogconfirmfinishtask/index.es.js +0 -50
  523. package/dialogconfirmrestoretask/index.es.js +0 -46
  524. package/dialogconfirmsprint/index.es.js +0 -42
  525. package/dialogcopyapi/index.es.js +0 -130
  526. package/dialogcustomdependency/index.es.js +0 -55
  527. package/dialogdetailchecklisttemplate/index.es.js +0 -214
  528. package/dialogdetailcomponent/index.es.js +0 -121
  529. package/dialogdetailpbi/index.es.js +0 -192
  530. package/dialogfinishreview/index.es.js +0 -126
  531. package/dialogimprovementtask/index.es.js +0 -191
  532. package/dialogmemberadmin/index.es.js +0 -93
  533. package/dialogpreparepbi/index.es.js +0 -93
  534. package/dialogpriorityvalue/index.es.js +0 -85
  535. package/dialogreportbug/index.es.js +0 -207
  536. package/dialogreviewleader/index.es.js +0 -280
  537. package/dialogsavechecklisttemplate/index.es.js +0 -127
  538. package/dialogselectproject/index.es.js +0 -69
  539. package/dialogsetduration/index.es.js +0 -109
  540. package/dialogsettasklink/index.es.js +0 -153
  541. package/dialogtestapi/index.es.js +0 -389
  542. package/eventlogtab/index.es.js +0 -50
  543. package/infotasktab/index.es.js +0 -186
  544. package/inputadditional/index.es.js +0 -62
  545. package/inputinitialname/index.d.ts +0 -118
  546. package/inputinitialname/index.es.js +0 -95
  547. package/inputrepositoryname/index.d.ts +0 -86
  548. package/inputrepositoryname/index.es.js +0 -41
  549. package/isrequiredtext/index.es.js +0 -16
  550. package/legend/index.es.js +0 -727
  551. package/legendlist/index.es.js +0 -33
  552. package/loading-page-BrQattYE.js +0 -1
  553. package/loading-page-CgfbWppy.js +0 -1
  554. package/loading-page-DbLuqCHa.js +0 -1
  555. package/loading-plane-CgfbWppy.js +0 -1
  556. package/loading-table-Bdr9ZhtP.js +0 -1
  557. package/loading-table-BzrSQlA0.js +0 -1
  558. package/loading-table-chOgXi94.js +0 -1
  559. package/no-data-Cgze_Rvp.js +0 -1
  560. package/no-data-Dep79CBh.js +0 -1
  561. package/no-data-y1X5WtcQ.js +0 -1
  562. package/notificationitem/index.d.ts +0 -107
  563. package/notificationitem/index.es.js +0 -333
  564. package/reviewitem/index.es.js +0 -65
  565. package/reviewtab/index.es.js +0 -44
  566. package/services/calendar.service.es.js +0 -32
  567. package/sonarqubesummary/index.es.js +0 -234
  568. package/sprintsummary/index.es.js +0 -73
  569. package/summaryaccordion/index.d.ts +0 -121
  570. package/summaryaccordion/index.es.js +0 -365
  571. package/taskdependency/index.es.js +0 -686
  572. package/taskdetail/index.d.ts +0 -82
  573. package/taskdetail/index.es.js +0 -491
  574. package/taskdetailpbi/index.d.ts +0 -35
  575. package/taskdetailpbi/index.es.js +0 -172
  576. package/taskdetailunassignedpbi/index.es.js +0 -261
  577. package/tasklink/index.es.js +0 -257
  578. package/tasklinkchangelog/index.es.js +0 -93
  579. package/tasklist/index.es.js +0 -92
  580. package/taskmore/index.es.js +0 -52
  581. package/taskstatusbadge/index.es.js +0 -18
  582. package/tasktable/index.d.ts +0 -87
  583. package/tasktable/index.es.js +0 -832
  584. package/ticket/index.es.js +0 -151
  585. package/tooltipspan/index.es.js +0 -30
  586. package/utils/updateSprintStatus.util.es.js +0 -17
  587. package/valueformdatainput/index.es.js +0 -70
  588. package/workcalendar/index.es.js +0 -351
@@ -1,1309 +1,2042 @@
1
- import { ref as Y, reactive as Pe, computed as j, unref as w, onMounted as ft, isRef as Fe, watch as se, provide as vt, toValue as O, readonly as Mt, getCurrentInstance as Ne, onBeforeUnmount as Tt, watchEffect as kt, nextTick as ee, shallowRef as Rt, inject as Ut } from "vue";
1
+ import { ref, reactive, computed, unref, onMounted, isRef, watch, provide, toValue, readonly, getCurrentInstance, onBeforeUnmount, watchEffect, nextTick, shallowRef, inject } from "vue";
2
2
  /**
3
3
  * vee-validate v4.13.2
4
4
  * (c) 2024 Abdelrahman Awad
5
5
  * @license MIT
6
6
  */
7
- function x(e) {
8
- return typeof e == "function";
9
- }
10
- function ht(e) {
11
- return e == null;
12
- }
13
- const ce = (e) => e !== null && !!e && typeof e == "object" && !Array.isArray(e);
14
- function Ye(e) {
15
- return Number(e) >= 0;
16
- }
17
- function Bt(e) {
18
- const t = parseFloat(e);
19
- return isNaN(t) ? e : t;
20
- }
21
- function Dt(e) {
22
- return typeof e == "object" && e !== null;
23
- }
24
- function zt(e) {
25
- return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
26
- }
27
- function rt(e) {
28
- if (!Dt(e) || zt(e) !== "[object Object]")
29
- return !1;
30
- if (Object.getPrototypeOf(e) === null)
31
- return !0;
32
- let t = e;
33
- for (; Object.getPrototypeOf(t) !== null; )
34
- t = Object.getPrototypeOf(t);
35
- return Object.getPrototypeOf(e) === t;
36
- }
37
- function Oe(e, t) {
38
- return Object.keys(t).forEach((n) => {
39
- if (rt(t[n]) && rt(e[n])) {
40
- e[n] || (e[n] = {}), Oe(e[n], t[n]);
7
+ function isCallable(fn) {
8
+ return typeof fn === "function";
9
+ }
10
+ function isNullOrUndefined(value) {
11
+ return value === null || value === void 0;
12
+ }
13
+ const isObject = (obj) => obj !== null && !!obj && typeof obj === "object" && !Array.isArray(obj);
14
+ function isIndex(value) {
15
+ return Number(value) >= 0;
16
+ }
17
+ function toNumber(value) {
18
+ const n = parseFloat(value);
19
+ return isNaN(n) ? value : n;
20
+ }
21
+ function isObjectLike(value) {
22
+ return typeof value === "object" && value !== null;
23
+ }
24
+ function getTag(value) {
25
+ if (value == null) {
26
+ return value === void 0 ? "[object Undefined]" : "[object Null]";
27
+ }
28
+ return Object.prototype.toString.call(value);
29
+ }
30
+ function isPlainObject(value) {
31
+ if (!isObjectLike(value) || getTag(value) !== "[object Object]") {
32
+ return false;
33
+ }
34
+ if (Object.getPrototypeOf(value) === null) {
35
+ return true;
36
+ }
37
+ let proto = value;
38
+ while (Object.getPrototypeOf(proto) !== null) {
39
+ proto = Object.getPrototypeOf(proto);
40
+ }
41
+ return Object.getPrototypeOf(value) === proto;
42
+ }
43
+ function merge(target, source) {
44
+ Object.keys(source).forEach((key) => {
45
+ if (isPlainObject(source[key]) && isPlainObject(target[key])) {
46
+ if (!target[key]) {
47
+ target[key] = {};
48
+ }
49
+ merge(target[key], source[key]);
41
50
  return;
42
51
  }
43
- e[n] = t[n];
44
- }), e;
52
+ target[key] = source[key];
53
+ });
54
+ return target;
45
55
  }
46
- function be(e) {
47
- const t = e.split(".");
48
- if (!t.length)
56
+ function normalizeFormPath(path) {
57
+ const pathArr = path.split(".");
58
+ if (!pathArr.length) {
49
59
  return "";
50
- let n = String(t[0]);
51
- for (let l = 1; l < t.length; l++) {
52
- if (Ye(t[l])) {
53
- n += `[${t[l]}]`;
60
+ }
61
+ let fullPath = String(pathArr[0]);
62
+ for (let i = 1; i < pathArr.length; i++) {
63
+ if (isIndex(pathArr[i])) {
64
+ fullPath += `[${pathArr[i]}]`;
54
65
  continue;
55
66
  }
56
- n += `.${t[l]}`;
57
- }
58
- return n;
59
- }
60
- const xt = {};
61
- function Lt(e) {
62
- return xt[e];
63
- }
64
- function it(e, t, n) {
65
- typeof n.value == "object" && (n.value = E(n.value)), !n.enumerable || n.get || n.set || !n.configurable || !n.writable || t === "__proto__" ? Object.defineProperty(e, t, n) : e[t] = n.value;
66
- }
67
- function E(e) {
68
- if (typeof e != "object") return e;
69
- var t = 0, n, l, u, a = Object.prototype.toString.call(e);
70
- if (a === "[object Object]" ? u = Object.create(e.__proto__ || null) : a === "[object Array]" ? u = Array(e.length) : a === "[object Set]" ? (u = /* @__PURE__ */ new Set(), e.forEach(function(h) {
71
- u.add(E(h));
72
- })) : a === "[object Map]" ? (u = /* @__PURE__ */ new Map(), e.forEach(function(h, v) {
73
- u.set(E(v), E(h));
74
- })) : a === "[object Date]" ? u = /* @__PURE__ */ new Date(+e) : a === "[object RegExp]" ? u = new RegExp(e.source, e.flags) : a === "[object DataView]" ? u = new e.constructor(E(e.buffer)) : a === "[object ArrayBuffer]" ? u = e.slice(0) : a.slice(-6) === "Array]" && (u = new e.constructor(e)), u) {
75
- for (l = Object.getOwnPropertySymbols(e); t < l.length; t++)
76
- it(u, l[t], Object.getOwnPropertyDescriptor(e, l[t]));
77
- for (t = 0, l = Object.getOwnPropertyNames(e); t < l.length; t++)
78
- Object.hasOwnProperty.call(u, n = l[t]) && u[n] === e[n] || it(u, n, Object.getOwnPropertyDescriptor(e, n));
79
- }
80
- return u || e;
81
- }
82
- const Xe = Symbol("vee-validate-form"), $t = Symbol("vee-validate-field-instance"), lt = Symbol("Default empty value"), Wt = typeof window < "u";
83
- function qe(e) {
84
- return x(e) && !!e.__locatorRef;
85
- }
86
- function X(e) {
87
- return !!e && x(e.parse) && e.__type === "VVTypedSchema";
88
- }
89
- function Ie(e) {
90
- return !!e && x(e.validate);
91
- }
92
- function mt(e) {
93
- return e === "checkbox" || e === "radio";
94
- }
95
- function qt(e) {
96
- return ce(e) || Array.isArray(e);
97
- }
98
- function Gt(e) {
99
- return Array.isArray(e) ? e.length === 0 : ce(e) && Object.keys(e).length === 0;
100
- }
101
- function Me(e) {
102
- return /^\[.+\]$/i.test(e);
103
- }
104
- function Ht(e) {
105
- return yt(e) && e.multiple;
106
- }
107
- function yt(e) {
108
- return e.tagName === "SELECT";
109
- }
110
- function Kt(e) {
111
- return gt(e) && e.target && "submit" in e.target;
112
- }
113
- function gt(e) {
114
- return e ? !!(typeof Event < "u" && x(Event) && e instanceof Event || e && e.srcElement) : !1;
115
- }
116
- function U(e, t) {
117
- if (e === t)
118
- return !0;
119
- if (e && t && typeof e == "object" && typeof t == "object") {
120
- if (e.constructor !== t.constructor)
121
- return !1;
122
- var n, l, u;
123
- if (Array.isArray(e)) {
124
- if (n = e.length, n != t.length)
125
- return !1;
126
- for (l = n; l-- !== 0; )
127
- if (!U(e[l], t[l]))
128
- return !1;
129
- return !0;
130
- }
131
- if (e instanceof Map && t instanceof Map) {
132
- if (e.size !== t.size)
133
- return !1;
134
- for (l of e.entries())
135
- if (!t.has(l[0]))
136
- return !1;
137
- for (l of e.entries())
138
- if (!U(l[1], t.get(l[0])))
139
- return !1;
140
- return !0;
141
- }
142
- if (at(e) && at(t))
143
- return !(e.size !== t.size || e.name !== t.name || e.lastModified !== t.lastModified || e.type !== t.type);
144
- if (e instanceof Set && t instanceof Set) {
145
- if (e.size !== t.size)
146
- return !1;
147
- for (l of e.entries())
148
- if (!t.has(l[0]))
149
- return !1;
150
- return !0;
151
- }
152
- if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
153
- if (n = e.length, n != t.length)
154
- return !1;
155
- for (l = n; l-- !== 0; )
156
- if (e[l] !== t[l])
157
- return !1;
158
- return !0;
159
- }
160
- if (e.constructor === RegExp)
161
- return e.source === t.source && e.flags === t.flags;
162
- if (e.valueOf !== Object.prototype.valueOf)
163
- return e.valueOf() === t.valueOf();
164
- if (e.toString !== Object.prototype.toString)
165
- return e.toString() === t.toString();
166
- for (u = Object.keys(e), n = u.length, l = n; l-- !== 0; ) {
167
- var a = u[l];
168
- if (!U(e[a], t[a]))
169
- return !1;
170
- }
171
- return !0;
172
- }
173
- return e !== e && t !== t;
174
- }
175
- function at(e) {
176
- return Wt ? e instanceof File : !1;
177
- }
178
- function Je(e) {
179
- return Me(e) ? e.replace(/\[|\]/gi, "") : e;
180
- }
181
- function L(e, t, n) {
182
- return e ? Me(t) ? e[Je(t)] : (t || "").split(/\.|\[(\d+)\]/).filter(Boolean).reduce((u, a) => qt(u) && a in u ? u[a] : n, e) : n;
183
- }
184
- function re(e, t, n) {
185
- if (Me(t)) {
186
- e[Je(t)] = n;
67
+ fullPath += `.${pathArr[i]}`;
68
+ }
69
+ return fullPath;
70
+ }
71
+ const RULES = {};
72
+ function resolveRule(id) {
73
+ return RULES[id];
74
+ }
75
+ function set(obj, key, val) {
76
+ if (typeof val.value === "object") val.value = klona(val.value);
77
+ if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
78
+ Object.defineProperty(obj, key, val);
79
+ } else obj[key] = val.value;
80
+ }
81
+ function klona(x) {
82
+ if (typeof x !== "object") return x;
83
+ var i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
84
+ if (str === "[object Object]") {
85
+ tmp = Object.create(x.__proto__ || null);
86
+ } else if (str === "[object Array]") {
87
+ tmp = Array(x.length);
88
+ } else if (str === "[object Set]") {
89
+ tmp = /* @__PURE__ */ new Set();
90
+ x.forEach(function(val) {
91
+ tmp.add(klona(val));
92
+ });
93
+ } else if (str === "[object Map]") {
94
+ tmp = /* @__PURE__ */ new Map();
95
+ x.forEach(function(val, key) {
96
+ tmp.set(klona(key), klona(val));
97
+ });
98
+ } else if (str === "[object Date]") {
99
+ tmp = /* @__PURE__ */ new Date(+x);
100
+ } else if (str === "[object RegExp]") {
101
+ tmp = new RegExp(x.source, x.flags);
102
+ } else if (str === "[object DataView]") {
103
+ tmp = new x.constructor(klona(x.buffer));
104
+ } else if (str === "[object ArrayBuffer]") {
105
+ tmp = x.slice(0);
106
+ } else if (str.slice(-6) === "Array]") {
107
+ tmp = new x.constructor(x);
108
+ }
109
+ if (tmp) {
110
+ for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
111
+ set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
112
+ }
113
+ for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
114
+ if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
115
+ set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
116
+ }
117
+ }
118
+ return tmp || x;
119
+ }
120
+ const FormContextKey = Symbol("vee-validate-form");
121
+ const FieldContextKey = Symbol("vee-validate-field-instance");
122
+ const IS_ABSENT = Symbol("Default empty value");
123
+ const isClient = typeof window !== "undefined";
124
+ function isLocator(value) {
125
+ return isCallable(value) && !!value.__locatorRef;
126
+ }
127
+ function isTypedSchema(value) {
128
+ return !!value && isCallable(value.parse) && value.__type === "VVTypedSchema";
129
+ }
130
+ function isYupValidator(value) {
131
+ return !!value && isCallable(value.validate);
132
+ }
133
+ function hasCheckedAttr(type) {
134
+ return type === "checkbox" || type === "radio";
135
+ }
136
+ function isContainerValue(value) {
137
+ return isObject(value) || Array.isArray(value);
138
+ }
139
+ function isEmptyContainer(value) {
140
+ if (Array.isArray(value)) {
141
+ return value.length === 0;
142
+ }
143
+ return isObject(value) && Object.keys(value).length === 0;
144
+ }
145
+ function isNotNestedPath(path) {
146
+ return /^\[.+\]$/i.test(path);
147
+ }
148
+ function isNativeMultiSelect(el) {
149
+ return isNativeSelect(el) && el.multiple;
150
+ }
151
+ function isNativeSelect(el) {
152
+ return el.tagName === "SELECT";
153
+ }
154
+ function isFormSubmitEvent(evt) {
155
+ return isEvent(evt) && evt.target && "submit" in evt.target;
156
+ }
157
+ function isEvent(evt) {
158
+ if (!evt) {
159
+ return false;
160
+ }
161
+ if (typeof Event !== "undefined" && isCallable(Event) && evt instanceof Event) {
162
+ return true;
163
+ }
164
+ if (evt && evt.srcElement) {
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+ function isEqual(a, b) {
170
+ if (a === b)
171
+ return true;
172
+ if (a && b && typeof a === "object" && typeof b === "object") {
173
+ if (a.constructor !== b.constructor)
174
+ return false;
175
+ var length, i, keys;
176
+ if (Array.isArray(a)) {
177
+ length = a.length;
178
+ if (length != b.length)
179
+ return false;
180
+ for (i = length; i-- !== 0; )
181
+ if (!isEqual(a[i], b[i]))
182
+ return false;
183
+ return true;
184
+ }
185
+ if (a instanceof Map && b instanceof Map) {
186
+ if (a.size !== b.size)
187
+ return false;
188
+ for (i of a.entries())
189
+ if (!b.has(i[0]))
190
+ return false;
191
+ for (i of a.entries())
192
+ if (!isEqual(i[1], b.get(i[0])))
193
+ return false;
194
+ return true;
195
+ }
196
+ if (isFile(a) && isFile(b)) {
197
+ if (a.size !== b.size)
198
+ return false;
199
+ if (a.name !== b.name)
200
+ return false;
201
+ if (a.lastModified !== b.lastModified)
202
+ return false;
203
+ if (a.type !== b.type)
204
+ return false;
205
+ return true;
206
+ }
207
+ if (a instanceof Set && b instanceof Set) {
208
+ if (a.size !== b.size)
209
+ return false;
210
+ for (i of a.entries())
211
+ if (!b.has(i[0]))
212
+ return false;
213
+ return true;
214
+ }
215
+ if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
216
+ length = a.length;
217
+ if (length != b.length)
218
+ return false;
219
+ for (i = length; i-- !== 0; )
220
+ if (a[i] !== b[i])
221
+ return false;
222
+ return true;
223
+ }
224
+ if (a.constructor === RegExp)
225
+ return a.source === b.source && a.flags === b.flags;
226
+ if (a.valueOf !== Object.prototype.valueOf)
227
+ return a.valueOf() === b.valueOf();
228
+ if (a.toString !== Object.prototype.toString)
229
+ return a.toString() === b.toString();
230
+ keys = Object.keys(a);
231
+ length = keys.length;
232
+ for (i = length; i-- !== 0; ) {
233
+ var key = keys[i];
234
+ if (!isEqual(a[key], b[key]))
235
+ return false;
236
+ }
237
+ return true;
238
+ }
239
+ return a !== a && b !== b;
240
+ }
241
+ function isFile(a) {
242
+ if (!isClient) {
243
+ return false;
244
+ }
245
+ return a instanceof File;
246
+ }
247
+ function cleanupNonNestedPath(path) {
248
+ if (isNotNestedPath(path)) {
249
+ return path.replace(/\[|\]/gi, "");
250
+ }
251
+ return path;
252
+ }
253
+ function getFromPath(object, path, fallback) {
254
+ if (!object) {
255
+ return fallback;
256
+ }
257
+ if (isNotNestedPath(path)) {
258
+ return object[cleanupNonNestedPath(path)];
259
+ }
260
+ const resolvedValue = (path || "").split(/\.|\[(\d+)\]/).filter(Boolean).reduce((acc, propKey) => {
261
+ if (isContainerValue(acc) && propKey in acc) {
262
+ return acc[propKey];
263
+ }
264
+ return fallback;
265
+ }, object);
266
+ return resolvedValue;
267
+ }
268
+ function setInPath(object, path, value) {
269
+ if (isNotNestedPath(path)) {
270
+ object[cleanupNonNestedPath(path)] = value;
187
271
  return;
188
272
  }
189
- const l = t.split(/\.|\[(\d+)\]/).filter(Boolean);
190
- let u = e;
191
- for (let a = 0; a < l.length; a++) {
192
- if (a === l.length - 1) {
193
- u[l[a]] = n;
273
+ const keys = path.split(/\.|\[(\d+)\]/).filter(Boolean);
274
+ let acc = object;
275
+ for (let i = 0; i < keys.length; i++) {
276
+ if (i === keys.length - 1) {
277
+ acc[keys[i]] = value;
194
278
  return;
195
279
  }
196
- (!(l[a] in u) || ht(u[l[a]])) && (u[l[a]] = Ye(l[a + 1]) ? [] : {}), u = u[l[a]];
280
+ if (!(keys[i] in acc) || isNullOrUndefined(acc[keys[i]])) {
281
+ acc[keys[i]] = isIndex(keys[i + 1]) ? [] : {};
282
+ }
283
+ acc = acc[keys[i]];
197
284
  }
198
285
  }
199
- function $e(e, t) {
200
- if (Array.isArray(e) && Ye(t)) {
201
- e.splice(Number(t), 1);
286
+ function unset(object, key) {
287
+ if (Array.isArray(object) && isIndex(key)) {
288
+ object.splice(Number(key), 1);
202
289
  return;
203
290
  }
204
- ce(e) && delete e[t];
291
+ if (isObject(object)) {
292
+ delete object[key];
293
+ }
205
294
  }
206
- function ut(e, t) {
207
- if (Me(t)) {
208
- delete e[Je(t)];
295
+ function unsetPath(object, path) {
296
+ if (isNotNestedPath(path)) {
297
+ delete object[cleanupNonNestedPath(path)];
209
298
  return;
210
299
  }
211
- const n = t.split(/\.|\[(\d+)\]/).filter(Boolean);
212
- let l = e;
213
- for (let a = 0; a < n.length; a++) {
214
- if (a === n.length - 1) {
215
- $e(l, n[a]);
300
+ const keys = path.split(/\.|\[(\d+)\]/).filter(Boolean);
301
+ let acc = object;
302
+ for (let i = 0; i < keys.length; i++) {
303
+ if (i === keys.length - 1) {
304
+ unset(acc, keys[i]);
216
305
  break;
217
306
  }
218
- if (!(n[a] in l) || ht(l[n[a]]))
307
+ if (!(keys[i] in acc) || isNullOrUndefined(acc[keys[i]])) {
219
308
  break;
220
- l = l[n[a]];
309
+ }
310
+ acc = acc[keys[i]];
221
311
  }
222
- const u = n.map((a, h) => L(e, n.slice(0, h).join(".")));
223
- for (let a = u.length - 1; a >= 0; a--)
224
- if (Gt(u[a])) {
225
- if (a === 0) {
226
- $e(e, n[0]);
227
- continue;
228
- }
229
- $e(u[a - 1], n[a - 1]);
312
+ const pathValues = keys.map((_, idx) => {
313
+ return getFromPath(object, keys.slice(0, idx).join("."));
314
+ });
315
+ for (let i = pathValues.length - 1; i >= 0; i--) {
316
+ if (!isEmptyContainer(pathValues[i])) {
317
+ continue;
318
+ }
319
+ if (i === 0) {
320
+ unset(object, keys[0]);
321
+ continue;
230
322
  }
323
+ unset(pathValues[i - 1], keys[i - 1]);
324
+ }
231
325
  }
232
- function q(e) {
233
- return Object.keys(e);
326
+ function keysOf(record) {
327
+ return Object.keys(record);
234
328
  }
235
- function pt(e, t = void 0) {
236
- const n = Ne();
237
- return (n == null ? void 0 : n.provides[e]) || Ut(e, t);
329
+ function injectWithSelf(symbol, def = void 0) {
330
+ const vm = getCurrentInstance();
331
+ return (vm === null || vm === void 0 ? void 0 : vm.provides[symbol]) || inject(symbol, def);
238
332
  }
239
- function ot(e, t, n) {
240
- if (Array.isArray(e)) {
241
- const l = [...e], u = l.findIndex((a) => U(a, t));
242
- return u >= 0 ? l.splice(u, 1) : l.push(t), l;
333
+ function resolveNextCheckboxValue(currentValue, checkedValue, uncheckedValue) {
334
+ if (Array.isArray(currentValue)) {
335
+ const newVal = [...currentValue];
336
+ const idx = newVal.findIndex((v) => isEqual(v, checkedValue));
337
+ idx >= 0 ? newVal.splice(idx, 1) : newVal.push(checkedValue);
338
+ return newVal;
243
339
  }
244
- return U(e, t) ? n : t;
245
- }
246
- function st(e, t = 0) {
247
- let n = null, l = [];
248
- return function(...u) {
249
- return n && clearTimeout(n), n = setTimeout(() => {
250
- const a = e(...u);
251
- l.forEach((h) => h(a)), l = [];
252
- }, t), new Promise((a) => l.push(a));
340
+ return isEqual(currentValue, checkedValue) ? uncheckedValue : checkedValue;
341
+ }
342
+ function debounceAsync(inner, ms = 0) {
343
+ let timer = null;
344
+ let resolves = [];
345
+ return function(...args) {
346
+ if (timer) {
347
+ clearTimeout(timer);
348
+ }
349
+ timer = setTimeout(() => {
350
+ const result = inner(...args);
351
+ resolves.forEach((r) => r(result));
352
+ resolves = [];
353
+ }, ms);
354
+ return new Promise((resolve) => resolves.push(resolve));
253
355
  };
254
356
  }
255
- function Yt(e, t) {
256
- return ce(t) && t.number ? Bt(e) : e;
257
- }
258
- function Ge(e, t) {
259
- let n;
260
- return async function(...u) {
261
- const a = e(...u);
262
- n = a;
263
- const h = await a;
264
- return a !== n ? h : (n = void 0, t(h, u));
357
+ function applyModelModifiers(value, modifiers) {
358
+ if (!isObject(modifiers)) {
359
+ return value;
360
+ }
361
+ if (modifiers.number) {
362
+ return toNumber(value);
363
+ }
364
+ return value;
365
+ }
366
+ function withLatest(fn, onDone) {
367
+ let latestRun;
368
+ return async function runLatest(...args) {
369
+ const pending = fn(...args);
370
+ latestRun = pending;
371
+ const result = await pending;
372
+ if (pending !== latestRun) {
373
+ return result;
374
+ }
375
+ latestRun = void 0;
376
+ return onDone(result, args);
265
377
  };
266
378
  }
267
- function He(e) {
268
- return Array.isArray(e) ? e : e ? [e] : [];
379
+ function normalizeErrorItem(message) {
380
+ return Array.isArray(message) ? message : message ? [message] : [];
269
381
  }
270
- function Ee(e, t) {
271
- const n = {};
272
- for (const l in e)
273
- t.includes(l) || (n[l] = e[l]);
274
- return n;
275
- }
276
- function Xt(e) {
277
- let t = null, n = [];
278
- return function(...l) {
279
- const u = ee(() => {
280
- if (t !== u)
382
+ function omit(obj, keys) {
383
+ const target = {};
384
+ for (const key in obj) {
385
+ if (!keys.includes(key)) {
386
+ target[key] = obj[key];
387
+ }
388
+ }
389
+ return target;
390
+ }
391
+ function debounceNextTick(inner) {
392
+ let lastTick = null;
393
+ let resolves = [];
394
+ return function(...args) {
395
+ const thisTick = nextTick(() => {
396
+ if (lastTick !== thisTick) {
281
397
  return;
282
- const a = e(...l);
283
- n.forEach((h) => h(a)), n = [], t = null;
398
+ }
399
+ const result = inner(...args);
400
+ resolves.forEach((r) => r(result));
401
+ resolves = [];
402
+ lastTick = null;
284
403
  });
285
- return t = u, new Promise((a) => n.push(a));
404
+ lastTick = thisTick;
405
+ return new Promise((resolve) => resolves.push(resolve));
286
406
  };
287
407
  }
288
- function We(e) {
289
- if (bt(e))
290
- return e._value;
291
- }
292
- function bt(e) {
293
- return "_value" in e;
294
- }
295
- function Jt(e) {
296
- return e.type === "number" || e.type === "range" ? Number.isNaN(e.valueAsNumber) ? e.value : e.valueAsNumber : e.value;
297
- }
298
- function Ce(e) {
299
- if (!gt(e))
300
- return e;
301
- const t = e.target;
302
- if (mt(t.type) && bt(t))
303
- return We(t);
304
- if (t.type === "file" && t.files) {
305
- const n = Array.from(t.files);
306
- return t.multiple ? n : n[0];
307
- }
308
- if (Ht(t))
309
- return Array.from(t.options).filter((n) => n.selected && !n.disabled).map(We);
310
- if (yt(t)) {
311
- const n = Array.from(t.options).find((l) => l.selected);
312
- return n ? We(n) : t.value;
313
- }
314
- return Jt(t);
315
- }
316
- function Vt(e) {
317
- const t = {};
318
- return Object.defineProperty(t, "_$$isNormalized", {
319
- value: !0,
320
- writable: !1,
321
- enumerable: !1,
322
- configurable: !1
323
- }), e ? ce(e) && e._$$isNormalized ? e : ce(e) ? Object.keys(e).reduce((n, l) => {
324
- const u = Qt(e[l]);
325
- return e[l] !== !1 && (n[l] = ct(u)), n;
326
- }, t) : typeof e != "string" ? t : e.split("|").reduce((n, l) => {
327
- const u = Zt(l);
328
- return u.name && (n[u.name] = ct(u.params)), n;
329
- }, t) : t;
330
- }
331
- function Qt(e) {
332
- return e === !0 ? [] : Array.isArray(e) || ce(e) ? e : [e];
333
- }
334
- function ct(e) {
335
- const t = (n) => typeof n == "string" && n[0] === "@" ? en(n.slice(1)) : n;
336
- return Array.isArray(e) ? e.map(t) : e instanceof RegExp ? [e] : Object.keys(e).reduce((n, l) => (n[l] = t(e[l]), n), {});
337
- }
338
- const Zt = (e) => {
339
- let t = [];
340
- const n = e.split(":")[0];
341
- return e.includes(":") && (t = e.split(":").slice(1).join(":").split(",")), { name: n, params: t };
408
+ function getBoundValue(el) {
409
+ if (hasValueBinding(el)) {
410
+ return el._value;
411
+ }
412
+ return void 0;
413
+ }
414
+ function hasValueBinding(el) {
415
+ return "_value" in el;
416
+ }
417
+ function parseInputValue(el) {
418
+ if (el.type === "number") {
419
+ return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
420
+ }
421
+ if (el.type === "range") {
422
+ return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
423
+ }
424
+ return el.value;
425
+ }
426
+ function normalizeEventValue(value) {
427
+ if (!isEvent(value)) {
428
+ return value;
429
+ }
430
+ const input = value.target;
431
+ if (hasCheckedAttr(input.type) && hasValueBinding(input)) {
432
+ return getBoundValue(input);
433
+ }
434
+ if (input.type === "file" && input.files) {
435
+ const files = Array.from(input.files);
436
+ return input.multiple ? files : files[0];
437
+ }
438
+ if (isNativeMultiSelect(input)) {
439
+ return Array.from(input.options).filter((opt) => opt.selected && !opt.disabled).map(getBoundValue);
440
+ }
441
+ if (isNativeSelect(input)) {
442
+ const selectedOption = Array.from(input.options).find((opt) => opt.selected);
443
+ return selectedOption ? getBoundValue(selectedOption) : input.value;
444
+ }
445
+ return parseInputValue(input);
446
+ }
447
+ function normalizeRules(rules) {
448
+ const acc = {};
449
+ Object.defineProperty(acc, "_$$isNormalized", {
450
+ value: true,
451
+ writable: false,
452
+ enumerable: false,
453
+ configurable: false
454
+ });
455
+ if (!rules) {
456
+ return acc;
457
+ }
458
+ if (isObject(rules) && rules._$$isNormalized) {
459
+ return rules;
460
+ }
461
+ if (isObject(rules)) {
462
+ return Object.keys(rules).reduce((prev, curr) => {
463
+ const params = normalizeParams(rules[curr]);
464
+ if (rules[curr] !== false) {
465
+ prev[curr] = buildParams(params);
466
+ }
467
+ return prev;
468
+ }, acc);
469
+ }
470
+ if (typeof rules !== "string") {
471
+ return acc;
472
+ }
473
+ return rules.split("|").reduce((prev, rule) => {
474
+ const parsedRule = parseRule(rule);
475
+ if (!parsedRule.name) {
476
+ return prev;
477
+ }
478
+ prev[parsedRule.name] = buildParams(parsedRule.params);
479
+ return prev;
480
+ }, acc);
481
+ }
482
+ function normalizeParams(params) {
483
+ if (params === true) {
484
+ return [];
485
+ }
486
+ if (Array.isArray(params)) {
487
+ return params;
488
+ }
489
+ if (isObject(params)) {
490
+ return params;
491
+ }
492
+ return [params];
493
+ }
494
+ function buildParams(provided) {
495
+ const mapValueToLocator = (value) => {
496
+ if (typeof value === "string" && value[0] === "@") {
497
+ return createLocator(value.slice(1));
498
+ }
499
+ return value;
500
+ };
501
+ if (Array.isArray(provided)) {
502
+ return provided.map(mapValueToLocator);
503
+ }
504
+ if (provided instanceof RegExp) {
505
+ return [provided];
506
+ }
507
+ return Object.keys(provided).reduce((prev, key) => {
508
+ prev[key] = mapValueToLocator(provided[key]);
509
+ return prev;
510
+ }, {});
511
+ }
512
+ const parseRule = (rule) => {
513
+ let params = [];
514
+ const name = rule.split(":")[0];
515
+ if (rule.includes(":")) {
516
+ params = rule.split(":").slice(1).join(":").split(",");
517
+ }
518
+ return { name, params };
342
519
  };
343
- function en(e) {
344
- const t = (n) => L(n, e) || n[e];
345
- return t.__locatorRef = e, t;
346
- }
347
- function tn(e) {
348
- return Array.isArray(e) ? e.filter(qe) : q(e).filter((t) => qe(e[t])).map((t) => e[t]);
349
- }
350
- const nn = {
351
- generateMessage: ({ field: e }) => `${e} is not valid.`,
352
- bails: !0,
353
- validateOnBlur: !0,
354
- validateOnChange: !0,
355
- validateOnInput: !1,
356
- validateOnModelUpdate: !0
520
+ function createLocator(value) {
521
+ const locator = (crossTable) => {
522
+ const val = getFromPath(crossTable, value) || crossTable[value];
523
+ return val;
524
+ };
525
+ locator.__locatorRef = value;
526
+ return locator;
527
+ }
528
+ function extractLocators(params) {
529
+ if (Array.isArray(params)) {
530
+ return params.filter(isLocator);
531
+ }
532
+ return keysOf(params).filter((key) => isLocator(params[key])).map((key) => params[key]);
533
+ }
534
+ const DEFAULT_CONFIG = {
535
+ generateMessage: ({ field }) => `${field} is not valid.`,
536
+ bails: true,
537
+ validateOnBlur: true,
538
+ validateOnChange: true,
539
+ validateOnInput: false,
540
+ validateOnModelUpdate: true
357
541
  };
358
- let rn = Object.assign({}, nn);
359
- const Ve = () => rn;
360
- async function Ot(e, t, n = {}) {
361
- const l = n == null ? void 0 : n.bails, u = {
362
- name: (n == null ? void 0 : n.name) || "{field}",
363
- rules: t,
364
- label: n == null ? void 0 : n.label,
365
- bails: l ?? !0,
366
- formData: (n == null ? void 0 : n.values) || {}
367
- }, a = await ln(u, e);
368
- return Object.assign(Object.assign({}, a), { valid: !a.errors.length });
369
- }
370
- async function ln(e, t) {
371
- const n = e.rules;
372
- if (X(n) || Ie(n))
373
- return un(t, Object.assign(Object.assign({}, e), { rules: n }));
374
- if (x(n) || Array.isArray(n)) {
375
- const v = {
376
- field: e.label || e.name,
377
- name: e.name,
378
- label: e.label,
379
- form: e.formData,
380
- value: t
381
- }, c = Array.isArray(n) ? n : [n], s = c.length, S = [];
382
- for (let b = 0; b < s; b++) {
383
- const F = c[b], g = await F(t, v);
384
- if (!(typeof g != "string" && !Array.isArray(g) && g)) {
385
- if (Array.isArray(g))
386
- S.push(...g);
387
- else {
388
- const J = typeof g == "string" ? g : St(v);
389
- S.push(J);
390
- }
391
- if (e.bails)
392
- return {
393
- errors: S
394
- };
542
+ let currentConfig = Object.assign({}, DEFAULT_CONFIG);
543
+ const getConfig = () => currentConfig;
544
+ async function validate(value, rules, options = {}) {
545
+ const shouldBail = options === null || options === void 0 ? void 0 : options.bails;
546
+ const field = {
547
+ name: (options === null || options === void 0 ? void 0 : options.name) || "{field}",
548
+ rules,
549
+ label: options === null || options === void 0 ? void 0 : options.label,
550
+ bails: shouldBail !== null && shouldBail !== void 0 ? shouldBail : true,
551
+ formData: (options === null || options === void 0 ? void 0 : options.values) || {}
552
+ };
553
+ const result = await _validate(field, value);
554
+ return Object.assign(Object.assign({}, result), { valid: !result.errors.length });
555
+ }
556
+ async function _validate(field, value) {
557
+ const rules = field.rules;
558
+ if (isTypedSchema(rules) || isYupValidator(rules)) {
559
+ return validateFieldWithTypedSchema(value, Object.assign(Object.assign({}, field), { rules }));
560
+ }
561
+ if (isCallable(rules) || Array.isArray(rules)) {
562
+ const ctx = {
563
+ field: field.label || field.name,
564
+ name: field.name,
565
+ label: field.label,
566
+ form: field.formData,
567
+ value
568
+ };
569
+ const pipeline = Array.isArray(rules) ? rules : [rules];
570
+ const length2 = pipeline.length;
571
+ const errors2 = [];
572
+ for (let i = 0; i < length2; i++) {
573
+ const rule = pipeline[i];
574
+ const result = await rule(value, ctx);
575
+ const isValid = typeof result !== "string" && !Array.isArray(result) && result;
576
+ if (isValid) {
577
+ continue;
578
+ }
579
+ if (Array.isArray(result)) {
580
+ errors2.push(...result);
581
+ } else {
582
+ const message = typeof result === "string" ? result : _generateFieldError(ctx);
583
+ errors2.push(message);
584
+ }
585
+ if (field.bails) {
586
+ return {
587
+ errors: errors2
588
+ };
395
589
  }
396
590
  }
397
591
  return {
398
- errors: S
592
+ errors: errors2
399
593
  };
400
594
  }
401
- const l = Object.assign(Object.assign({}, e), { rules: Vt(n) }), u = [], a = Object.keys(l.rules), h = a.length;
402
- for (let v = 0; v < h; v++) {
403
- const c = a[v], s = await on(l, t, {
404
- name: c,
405
- params: l.rules[c]
595
+ const normalizedContext = Object.assign(Object.assign({}, field), { rules: normalizeRules(rules) });
596
+ const errors = [];
597
+ const rulesKeys = Object.keys(normalizedContext.rules);
598
+ const length = rulesKeys.length;
599
+ for (let i = 0; i < length; i++) {
600
+ const rule = rulesKeys[i];
601
+ const result = await _test(normalizedContext, value, {
602
+ name: rule,
603
+ params: normalizedContext.rules[rule]
406
604
  });
407
- if (s.error && (u.push(s.error), e.bails))
408
- return {
409
- errors: u
410
- };
605
+ if (result.error) {
606
+ errors.push(result.error);
607
+ if (field.bails) {
608
+ return {
609
+ errors
610
+ };
611
+ }
612
+ }
411
613
  }
412
614
  return {
413
- errors: u
615
+ errors
414
616
  };
415
617
  }
416
- function an(e) {
417
- return !!e && e.name === "ValidationError";
618
+ function isYupError(err) {
619
+ return !!err && err.name === "ValidationError";
418
620
  }
419
- function _t(e) {
420
- return {
621
+ function yupToTypedSchema(yupSchema) {
622
+ const schema = {
421
623
  __type: "VVTypedSchema",
422
- async parse(n, l) {
423
- var u;
624
+ async parse(values, context) {
625
+ var _a;
424
626
  try {
627
+ const output = await yupSchema.validate(values, { abortEarly: false, context: (context === null || context === void 0 ? void 0 : context.formData) || {} });
425
628
  return {
426
- output: await e.validate(n, { abortEarly: !1, context: (l == null ? void 0 : l.formData) || {} }),
629
+ output,
427
630
  errors: []
428
631
  };
429
- } catch (a) {
430
- if (!an(a))
431
- throw a;
432
- if (!(!((u = a.inner) === null || u === void 0) && u.length) && a.errors.length)
433
- return { errors: [{ path: a.path, errors: a.errors }] };
434
- const h = a.inner.reduce((v, c) => {
435
- const s = c.path || "";
436
- return v[s] || (v[s] = { errors: [], path: s }), v[s].errors.push(...c.errors), v;
632
+ } catch (err) {
633
+ if (!isYupError(err)) {
634
+ throw err;
635
+ }
636
+ if (!((_a = err.inner) === null || _a === void 0 ? void 0 : _a.length) && err.errors.length) {
637
+ return { errors: [{ path: err.path, errors: err.errors }] };
638
+ }
639
+ const errors = err.inner.reduce((acc, curr) => {
640
+ const path = curr.path || "";
641
+ if (!acc[path]) {
642
+ acc[path] = { errors: [], path };
643
+ }
644
+ acc[path].errors.push(...curr.errors);
645
+ return acc;
437
646
  }, {});
438
- return { errors: Object.values(h) };
647
+ return { errors: Object.values(errors) };
439
648
  }
440
649
  }
441
650
  };
442
- }
443
- async function un(e, t) {
444
- const l = await (X(t.rules) ? t.rules : _t(t.rules)).parse(e, { formData: t.formData }), u = [];
445
- for (const a of l.errors)
446
- a.errors.length && u.push(...a.errors);
651
+ return schema;
652
+ }
653
+ async function validateFieldWithTypedSchema(value, context) {
654
+ const typedSchema = isTypedSchema(context.rules) ? context.rules : yupToTypedSchema(context.rules);
655
+ const result = await typedSchema.parse(value, { formData: context.formData });
656
+ const messages = [];
657
+ for (const error of result.errors) {
658
+ if (error.errors.length) {
659
+ messages.push(...error.errors);
660
+ }
661
+ }
447
662
  return {
448
- value: l.value,
449
- errors: u
663
+ value: result.value,
664
+ errors: messages
450
665
  };
451
666
  }
452
- async function on(e, t, n) {
453
- const l = Lt(n.name);
454
- if (!l)
455
- throw new Error(`No such validator '${n.name}' exists.`);
456
- const u = sn(n.params, e.formData), a = {
457
- field: e.label || e.name,
458
- name: e.name,
459
- label: e.label,
460
- value: t,
461
- form: e.formData,
462
- rule: Object.assign(Object.assign({}, n), { params: u })
463
- }, h = await l(t, u, a);
464
- return typeof h == "string" ? {
465
- error: h
466
- } : {
467
- error: h ? void 0 : St(a)
667
+ async function _test(field, value, rule) {
668
+ const validator = resolveRule(rule.name);
669
+ if (!validator) {
670
+ throw new Error(`No such validator '${rule.name}' exists.`);
671
+ }
672
+ const params = fillTargetValues(rule.params, field.formData);
673
+ const ctx = {
674
+ field: field.label || field.name,
675
+ name: field.name,
676
+ label: field.label,
677
+ value,
678
+ form: field.formData,
679
+ rule: Object.assign(Object.assign({}, rule), { params })
680
+ };
681
+ const result = await validator(value, params, ctx);
682
+ if (typeof result === "string") {
683
+ return {
684
+ error: result
685
+ };
686
+ }
687
+ return {
688
+ error: result ? void 0 : _generateFieldError(ctx)
468
689
  };
469
690
  }
470
- function St(e) {
471
- const t = Ve().generateMessage;
472
- return t ? t(e) : "Field is invalid";
473
- }
474
- function sn(e, t) {
475
- const n = (l) => qe(l) ? l(t) : l;
476
- return Array.isArray(e) ? e.map(n) : Object.keys(e).reduce((l, u) => (l[u] = n(e[u]), l), {});
691
+ function _generateFieldError(fieldCtx) {
692
+ const message = getConfig().generateMessage;
693
+ if (!message) {
694
+ return "Field is invalid";
695
+ }
696
+ return message(fieldCtx);
477
697
  }
478
- async function cn(e, t) {
479
- const l = await (X(e) ? e : _t(e)).parse(E(t)), u = {}, a = {};
480
- for (const h of l.errors) {
481
- const v = h.errors, c = (h.path || "").replace(/\["(\d+)"\]/g, (s, S) => `[${S}]`);
482
- u[c] = { valid: !v.length, errors: v }, v.length && (a[c] = v[0]);
698
+ function fillTargetValues(params, crossTable) {
699
+ const normalize = (value) => {
700
+ if (isLocator(value)) {
701
+ return value(crossTable);
702
+ }
703
+ return value;
704
+ };
705
+ if (Array.isArray(params)) {
706
+ return params.map(normalize);
707
+ }
708
+ return Object.keys(params).reduce((acc, param) => {
709
+ acc[param] = normalize(params[param]);
710
+ return acc;
711
+ }, {});
712
+ }
713
+ async function validateTypedSchema(schema, values) {
714
+ const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
715
+ const validationResult = await typedSchema.parse(klona(values));
716
+ const results = {};
717
+ const errors = {};
718
+ for (const error of validationResult.errors) {
719
+ const messages = error.errors;
720
+ const path = (error.path || "").replace(/\["(\d+)"\]/g, (_, m) => {
721
+ return `[${m}]`;
722
+ });
723
+ results[path] = { valid: !messages.length, errors: messages };
724
+ if (messages.length) {
725
+ errors[path] = messages[0];
726
+ }
483
727
  }
484
728
  return {
485
- valid: !l.errors.length,
486
- results: u,
487
- errors: a,
488
- values: l.value,
729
+ valid: !validationResult.errors.length,
730
+ results,
731
+ errors,
732
+ values: validationResult.value,
489
733
  source: "schema"
490
734
  };
491
735
  }
492
- async function dn(e, t, n) {
493
- const u = q(e).map(async (s) => {
494
- var S, b, F;
495
- const g = (S = n == null ? void 0 : n.names) === null || S === void 0 ? void 0 : S[s], T = await Ot(L(t, s), e[s], {
496
- name: (g == null ? void 0 : g.name) || s,
497
- label: g == null ? void 0 : g.label,
498
- values: t,
499
- bails: (F = (b = n == null ? void 0 : n.bailsMap) === null || b === void 0 ? void 0 : b[s]) !== null && F !== void 0 ? F : !0
736
+ async function validateObjectSchema(schema, values, opts) {
737
+ const paths = keysOf(schema);
738
+ const validations = paths.map(async (path) => {
739
+ var _a, _b, _c;
740
+ const strings = (_a = opts === null || opts === void 0 ? void 0 : opts.names) === null || _a === void 0 ? void 0 : _a[path];
741
+ const fieldResult = await validate(getFromPath(values, path), schema[path], {
742
+ name: (strings === null || strings === void 0 ? void 0 : strings.name) || path,
743
+ label: strings === null || strings === void 0 ? void 0 : strings.label,
744
+ values,
745
+ bails: (_c = (_b = opts === null || opts === void 0 ? void 0 : opts.bailsMap) === null || _b === void 0 ? void 0 : _b[path]) !== null && _c !== void 0 ? _c : true
500
746
  });
501
- return Object.assign(Object.assign({}, T), { path: s });
747
+ return Object.assign(Object.assign({}, fieldResult), { path });
502
748
  });
503
- let a = !0;
504
- const h = await Promise.all(u), v = {}, c = {};
505
- for (const s of h)
506
- v[s.path] = {
507
- valid: s.valid,
508
- errors: s.errors
509
- }, s.valid || (a = !1, c[s.path] = s.errors[0]);
749
+ let isAllValid = true;
750
+ const validationResults = await Promise.all(validations);
751
+ const results = {};
752
+ const errors = {};
753
+ for (const result of validationResults) {
754
+ results[result.path] = {
755
+ valid: result.valid,
756
+ errors: result.errors
757
+ };
758
+ if (!result.valid) {
759
+ isAllValid = false;
760
+ errors[result.path] = result.errors[0];
761
+ }
762
+ }
510
763
  return {
511
- valid: a,
512
- results: v,
513
- errors: c,
764
+ valid: isAllValid,
765
+ results,
766
+ errors,
514
767
  source: "schema"
515
768
  };
516
769
  }
517
- let dt = 0;
518
- function fn(e, t) {
519
- const { value: n, initialValue: l, setInitialValue: u } = vn(e, t.modelValue, t.form);
520
- if (!t.form) {
521
- let c = function(g) {
522
- var T;
523
- "value" in g && (n.value = g.value), "errors" in g && S(g.errors), "touched" in g && (F.touched = (T = g.touched) !== null && T !== void 0 ? T : F.touched), "initialValue" in g && u(g.initialValue);
770
+ let ID_COUNTER = 0;
771
+ function useFieldState(path, init) {
772
+ const { value, initialValue, setInitialValue } = _useFieldValue(path, init.modelValue, init.form);
773
+ if (!init.form) {
774
+ let setState2 = function(state2) {
775
+ var _a;
776
+ if ("value" in state2) {
777
+ value.value = state2.value;
778
+ }
779
+ if ("errors" in state2) {
780
+ setErrors(state2.errors);
781
+ }
782
+ if ("touched" in state2) {
783
+ meta.touched = (_a = state2.touched) !== null && _a !== void 0 ? _a : meta.touched;
784
+ }
785
+ if ("initialValue" in state2) {
786
+ setInitialValue(state2.initialValue);
787
+ }
524
788
  };
525
- const { errors: s, setErrors: S } = yn(), b = dt >= Number.MAX_SAFE_INTEGER ? 0 : ++dt, F = mn(n, l, s, t.schema);
789
+ const { errors: errors2, setErrors } = createFieldErrors();
790
+ const id = ID_COUNTER >= Number.MAX_SAFE_INTEGER ? 0 : ++ID_COUNTER;
791
+ const meta = createFieldMeta(value, initialValue, errors2, init.schema);
526
792
  return {
527
- id: b,
528
- path: e,
529
- value: n,
530
- initialValue: l,
531
- meta: F,
532
- flags: { pendingUnmount: { [b]: !1 }, pendingReset: !1 },
533
- errors: s,
534
- setState: c
793
+ id,
794
+ path,
795
+ value,
796
+ initialValue,
797
+ meta,
798
+ flags: { pendingUnmount: { [id]: false }, pendingReset: false },
799
+ errors: errors2,
800
+ setState: setState2
535
801
  };
536
802
  }
537
- const a = t.form.createPathState(e, {
538
- bails: t.bails,
539
- label: t.label,
540
- type: t.type,
541
- validate: t.validate,
542
- schema: t.schema
543
- }), h = j(() => a.errors);
544
- function v(c) {
545
- var s, S, b;
546
- "value" in c && (n.value = c.value), "errors" in c && ((s = t.form) === null || s === void 0 || s.setFieldError(w(e), c.errors)), "touched" in c && ((S = t.form) === null || S === void 0 || S.setFieldTouched(w(e), (b = c.touched) !== null && b !== void 0 ? b : !1)), "initialValue" in c && u(c.initialValue);
803
+ const state = init.form.createPathState(path, {
804
+ bails: init.bails,
805
+ label: init.label,
806
+ type: init.type,
807
+ validate: init.validate,
808
+ schema: init.schema
809
+ });
810
+ const errors = computed(() => state.errors);
811
+ function setState(state2) {
812
+ var _a, _b, _c;
813
+ if ("value" in state2) {
814
+ value.value = state2.value;
815
+ }
816
+ if ("errors" in state2) {
817
+ (_a = init.form) === null || _a === void 0 ? void 0 : _a.setFieldError(unref(path), state2.errors);
818
+ }
819
+ if ("touched" in state2) {
820
+ (_b = init.form) === null || _b === void 0 ? void 0 : _b.setFieldTouched(unref(path), (_c = state2.touched) !== null && _c !== void 0 ? _c : false);
821
+ }
822
+ if ("initialValue" in state2) {
823
+ setInitialValue(state2.initialValue);
824
+ }
547
825
  }
548
826
  return {
549
- id: Array.isArray(a.id) ? a.id[a.id.length - 1] : a.id,
550
- path: e,
551
- value: n,
552
- errors: h,
553
- meta: a,
554
- initialValue: l,
555
- flags: a.__flags,
556
- setState: v
827
+ id: Array.isArray(state.id) ? state.id[state.id.length - 1] : state.id,
828
+ path,
829
+ value,
830
+ errors,
831
+ meta: state,
832
+ initialValue,
833
+ flags: state.__flags,
834
+ setState
557
835
  };
558
836
  }
559
- function vn(e, t, n) {
560
- const l = Y(w(t));
561
- function u() {
562
- return n ? L(n.initialValues.value, w(e), w(l)) : w(l);
837
+ function _useFieldValue(path, modelValue, form) {
838
+ const modelRef = ref(unref(modelValue));
839
+ function resolveInitialValue2() {
840
+ if (!form) {
841
+ return unref(modelRef);
842
+ }
843
+ return getFromPath(form.initialValues.value, unref(path), unref(modelRef));
563
844
  }
564
- function a(s) {
565
- if (!n) {
566
- l.value = s;
845
+ function setInitialValue(value2) {
846
+ if (!form) {
847
+ modelRef.value = value2;
567
848
  return;
568
849
  }
569
- n.setFieldInitialValue(w(e), s, !0);
850
+ form.setFieldInitialValue(unref(path), value2, true);
570
851
  }
571
- const h = j(u);
572
- if (!n)
852
+ const initialValue = computed(resolveInitialValue2);
853
+ if (!form) {
854
+ const value2 = ref(resolveInitialValue2());
573
855
  return {
574
- value: Y(u()),
575
- initialValue: h,
576
- setInitialValue: a
856
+ value: value2,
857
+ initialValue,
858
+ setInitialValue
577
859
  };
578
- const v = hn(t, n, h, e);
579
- return n.stageInitialValue(w(e), v, !0), {
580
- value: j({
581
- get() {
582
- return L(n.values, w(e));
583
- },
584
- set(s) {
585
- n.setFieldValue(w(e), s, !1);
586
- }
587
- }),
588
- initialValue: h,
589
- setInitialValue: a
860
+ }
861
+ const currentValue = resolveModelValue(modelValue, form, initialValue, path);
862
+ form.stageInitialValue(unref(path), currentValue, true);
863
+ const value = computed({
864
+ get() {
865
+ return getFromPath(form.values, unref(path));
866
+ },
867
+ set(newVal) {
868
+ form.setFieldValue(unref(path), newVal, false);
869
+ }
870
+ });
871
+ return {
872
+ value,
873
+ initialValue,
874
+ setInitialValue
590
875
  };
591
876
  }
592
- function hn(e, t, n, l) {
593
- return Fe(e) ? w(e) : e !== void 0 ? e : L(t.values, w(l), w(n));
594
- }
595
- function mn(e, t, n, l) {
596
- const u = j(() => {
597
- var h, v, c;
598
- return (c = (v = (h = O(l)) === null || h === void 0 ? void 0 : h.describe) === null || v === void 0 ? void 0 : v.call(h).required) !== null && c !== void 0 ? c : !1;
599
- }), a = Pe({
600
- touched: !1,
601
- pending: !1,
602
- valid: !0,
603
- required: u,
604
- validated: !!w(n).length,
605
- initialValue: j(() => w(t)),
606
- dirty: j(() => !U(w(e), w(t)))
877
+ function resolveModelValue(modelValue, form, initialValue, path) {
878
+ if (isRef(modelValue)) {
879
+ return unref(modelValue);
880
+ }
881
+ if (modelValue !== void 0) {
882
+ return modelValue;
883
+ }
884
+ return getFromPath(form.values, unref(path), unref(initialValue));
885
+ }
886
+ function createFieldMeta(currentValue, initialValue, errors, schema) {
887
+ const isRequired = computed(() => {
888
+ var _a, _b, _c;
889
+ return (_c = (_b = (_a = toValue(schema)) === null || _a === void 0 ? void 0 : _a.describe) === null || _b === void 0 ? void 0 : _b.call(_a).required) !== null && _c !== void 0 ? _c : false;
607
890
  });
608
- return se(n, (h) => {
609
- a.valid = !h.length;
891
+ const meta = reactive({
892
+ touched: false,
893
+ pending: false,
894
+ valid: true,
895
+ required: isRequired,
896
+ validated: !!unref(errors).length,
897
+ initialValue: computed(() => unref(initialValue)),
898
+ dirty: computed(() => {
899
+ return !isEqual(unref(currentValue), unref(initialValue));
900
+ })
901
+ });
902
+ watch(errors, (value) => {
903
+ meta.valid = !value.length;
610
904
  }, {
611
- immediate: !0,
905
+ immediate: true,
612
906
  flush: "sync"
613
- }), a;
907
+ });
908
+ return meta;
614
909
  }
615
- function yn() {
616
- const e = Y([]);
910
+ function createFieldErrors() {
911
+ const errors = ref([]);
617
912
  return {
618
- errors: e,
619
- setErrors: (t) => {
620
- e.value = He(t);
913
+ errors,
914
+ setErrors: (messages) => {
915
+ errors.value = normalizeErrorItem(messages);
621
916
  }
622
917
  };
623
918
  }
624
- function jn(e, t, n) {
625
- return mt(n == null ? void 0 : n.type) ? pn(e, t, n) : At(e, t, n);
626
- }
627
- function At(e, t, n) {
628
- const { initialValue: l, validateOnMount: u, bails: a, type: h, checkedValue: v, label: c, validateOnValueUpdate: s, uncheckedValue: S, controlled: b, keepValueOnUnmount: F, syncVModel: g, form: T } = gn(n), J = b ? pt(Xe) : void 0, _ = T || J, Q = j(() => be(O(e))), $ = j(() => {
629
- if (O(_ == null ? void 0 : _.schema))
630
- return;
631
- const V = w(t);
632
- return Ie(V) || X(V) || x(V) || Array.isArray(V) ? V : Vt(V);
633
- }), _e = !x($.value) && X(O(t)), { id: he, value: Z, initialValue: le, meta: B, setState: de, errors: me, flags: D } = fn(Q, {
634
- modelValue: l,
635
- form: _,
636
- bails: a,
637
- label: c,
638
- type: h,
639
- validate: $.value ? M : void 0,
640
- schema: _e ? t : void 0
641
- }), fe = j(() => me.value[0]);
642
- g && bn({
643
- value: Z,
644
- prop: g,
645
- handleChange: Ae,
646
- shouldValidate: () => s && !D.pendingReset
919
+ function useField(path, rules, opts) {
920
+ if (hasCheckedAttr(opts === null || opts === void 0 ? void 0 : opts.type)) {
921
+ return useFieldWithChecked(path, rules, opts);
922
+ }
923
+ return _useField(path, rules, opts);
924
+ }
925
+ function _useField(path, rules, opts) {
926
+ const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount, syncVModel, form: controlForm } = normalizeOptions(opts);
927
+ const injectedForm = controlled ? injectWithSelf(FormContextKey) : void 0;
928
+ const form = controlForm || injectedForm;
929
+ const name = computed(() => normalizeFormPath(toValue(path)));
930
+ const validator = computed(() => {
931
+ const schema = toValue(form === null || form === void 0 ? void 0 : form.schema);
932
+ if (schema) {
933
+ return void 0;
934
+ }
935
+ const rulesValue = unref(rules);
936
+ if (isYupValidator(rulesValue) || isTypedSchema(rulesValue) || isCallable(rulesValue) || Array.isArray(rulesValue)) {
937
+ return rulesValue;
938
+ }
939
+ return normalizeRules(rulesValue);
940
+ });
941
+ const isTyped = !isCallable(validator.value) && isTypedSchema(toValue(rules));
942
+ const { id, value, initialValue, meta, setState, errors, flags } = useFieldState(name, {
943
+ modelValue,
944
+ form,
945
+ bails,
946
+ label,
947
+ type,
948
+ validate: validator.value ? validate$1 : void 0,
949
+ schema: isTyped ? rules : void 0
647
950
  });
648
- const Te = (f, V = !1) => {
649
- B.touched = !0, V && ie();
951
+ const errorMessage = computed(() => errors.value[0]);
952
+ if (syncVModel) {
953
+ useVModel({
954
+ value,
955
+ prop: syncVModel,
956
+ handleChange,
957
+ shouldValidate: () => validateOnValueUpdate && !flags.pendingReset
958
+ });
959
+ }
960
+ const handleBlur = (evt, shouldValidate = false) => {
961
+ meta.touched = true;
962
+ if (shouldValidate) {
963
+ validateWithStateMutation();
964
+ }
650
965
  };
651
- async function Se(f) {
652
- var V, N;
653
- if (_ != null && _.validateSchema) {
654
- const { results: A } = await _.validateSchema(f);
655
- return (V = A[O(Q)]) !== null && V !== void 0 ? V : { valid: !0, errors: [] };
656
- }
657
- return $.value ? Ot(Z.value, $.value, {
658
- name: O(Q),
659
- label: O(c),
660
- values: (N = _ == null ? void 0 : _.values) !== null && N !== void 0 ? N : {},
661
- bails: a
662
- }) : { valid: !0, errors: [] };
663
- }
664
- const ie = Ge(async () => (B.pending = !0, B.validated = !0, Se("validated-only")), (f) => (D.pendingUnmount[W.id] || (de({ errors: f.errors }), B.pending = !1, B.valid = f.valid), f)), G = Ge(async () => Se("silent"), (f) => (B.valid = f.valid, f));
665
- function M(f) {
666
- return (f == null ? void 0 : f.mode) === "silent" ? G() : ie();
667
- }
668
- function Ae(f, V = !0) {
669
- const N = Ce(f);
670
- ve(N, V);
671
- }
672
- ft(() => {
673
- if (u)
674
- return ie();
675
- (!_ || !_.validateSchema) && G();
966
+ async function validateCurrentValue(mode) {
967
+ var _a, _b;
968
+ if (form === null || form === void 0 ? void 0 : form.validateSchema) {
969
+ const { results } = await form.validateSchema(mode);
970
+ return (_a = results[toValue(name)]) !== null && _a !== void 0 ? _a : { valid: true, errors: [] };
971
+ }
972
+ if (validator.value) {
973
+ return validate(value.value, validator.value, {
974
+ name: toValue(name),
975
+ label: toValue(label),
976
+ values: (_b = form === null || form === void 0 ? void 0 : form.values) !== null && _b !== void 0 ? _b : {},
977
+ bails
978
+ });
979
+ }
980
+ return { valid: true, errors: [] };
981
+ }
982
+ const validateWithStateMutation = withLatest(async () => {
983
+ meta.pending = true;
984
+ meta.validated = true;
985
+ return validateCurrentValue("validated-only");
986
+ }, (result) => {
987
+ if (flags.pendingUnmount[field.id]) {
988
+ return result;
989
+ }
990
+ setState({ errors: result.errors });
991
+ meta.pending = false;
992
+ meta.valid = result.valid;
993
+ return result;
676
994
  });
677
- function ae(f) {
678
- B.touched = f;
679
- }
680
- function ue(f) {
681
- var V;
682
- const N = f && "value" in f ? f.value : le.value;
683
- de({
684
- value: E(N),
685
- initialValue: E(N),
686
- touched: (V = f == null ? void 0 : f.touched) !== null && V !== void 0 ? V : !1,
687
- errors: (f == null ? void 0 : f.errors) || []
688
- }), B.pending = !1, B.validated = !1, G();
689
- }
690
- const je = Ne();
691
- function ve(f, V = !0) {
692
- Z.value = je && g ? Yt(f, je.props.modelModifiers) : f, (V ? ie : G)();
693
- }
694
- function Qe(f) {
695
- de({ errors: Array.isArray(f) ? f : [f] });
696
- }
697
- const ye = j({
995
+ const validateValidStateOnly = withLatest(async () => {
996
+ return validateCurrentValue("silent");
997
+ }, (result) => {
998
+ meta.valid = result.valid;
999
+ return result;
1000
+ });
1001
+ function validate$1(opts2) {
1002
+ if ((opts2 === null || opts2 === void 0 ? void 0 : opts2.mode) === "silent") {
1003
+ return validateValidStateOnly();
1004
+ }
1005
+ return validateWithStateMutation();
1006
+ }
1007
+ function handleChange(e, shouldValidate = true) {
1008
+ const newValue = normalizeEventValue(e);
1009
+ setValue(newValue, shouldValidate);
1010
+ }
1011
+ onMounted(() => {
1012
+ if (validateOnMount) {
1013
+ return validateWithStateMutation();
1014
+ }
1015
+ if (!form || !form.validateSchema) {
1016
+ validateValidStateOnly();
1017
+ }
1018
+ });
1019
+ function setTouched(isTouched) {
1020
+ meta.touched = isTouched;
1021
+ }
1022
+ function resetField(state) {
1023
+ var _a;
1024
+ const newValue = state && "value" in state ? state.value : initialValue.value;
1025
+ setState({
1026
+ value: klona(newValue),
1027
+ initialValue: klona(newValue),
1028
+ touched: (_a = state === null || state === void 0 ? void 0 : state.touched) !== null && _a !== void 0 ? _a : false,
1029
+ errors: (state === null || state === void 0 ? void 0 : state.errors) || []
1030
+ });
1031
+ meta.pending = false;
1032
+ meta.validated = false;
1033
+ validateValidStateOnly();
1034
+ }
1035
+ const vm = getCurrentInstance();
1036
+ function setValue(newValue, shouldValidate = true) {
1037
+ value.value = vm && syncVModel ? applyModelModifiers(newValue, vm.props.modelModifiers) : newValue;
1038
+ const validateFn = shouldValidate ? validateWithStateMutation : validateValidStateOnly;
1039
+ validateFn();
1040
+ }
1041
+ function setErrors(errors2) {
1042
+ setState({ errors: Array.isArray(errors2) ? errors2 : [errors2] });
1043
+ }
1044
+ const valueProxy = computed({
698
1045
  get() {
699
- return Z.value;
1046
+ return value.value;
700
1047
  },
701
- set(f) {
702
- ve(f, s);
703
- }
704
- }), W = {
705
- id: he,
706
- name: Q,
707
- label: c,
708
- value: ye,
709
- meta: B,
710
- errors: me,
711
- errorMessage: fe,
712
- type: h,
713
- checkedValue: v,
714
- uncheckedValue: S,
715
- bails: a,
716
- keepValueOnUnmount: F,
717
- resetField: ue,
718
- handleReset: () => ue(),
719
- validate: M,
720
- handleChange: Ae,
721
- handleBlur: Te,
722
- setState: de,
723
- setTouched: ae,
724
- setErrors: Qe,
725
- setValue: ve
1048
+ set(newValue) {
1049
+ setValue(newValue, validateOnValueUpdate);
1050
+ }
1051
+ });
1052
+ const field = {
1053
+ id,
1054
+ name,
1055
+ label,
1056
+ value: valueProxy,
1057
+ meta,
1058
+ errors,
1059
+ errorMessage,
1060
+ type,
1061
+ checkedValue,
1062
+ uncheckedValue,
1063
+ bails,
1064
+ keepValueOnUnmount,
1065
+ resetField,
1066
+ handleReset: () => resetField(),
1067
+ validate: validate$1,
1068
+ handleChange,
1069
+ handleBlur,
1070
+ setState,
1071
+ setTouched,
1072
+ setErrors,
1073
+ setValue
726
1074
  };
727
- if (vt($t, W), Fe(t) && typeof w(t) != "function" && se(t, (f, V) => {
728
- U(f, V) || (B.validated ? ie() : G());
729
- }, {
730
- deep: !0
731
- }), !_)
732
- return W;
733
- const ke = j(() => {
734
- const f = $.value;
735
- return !f || x(f) || Ie(f) || X(f) || Array.isArray(f) ? {} : Object.keys(f).reduce((V, N) => {
736
- const A = tn(f[N]).map((te) => te.__locatorRef).reduce((te, K) => {
737
- const ne = L(_.values, K) || _.values[K];
738
- return ne !== void 0 && (te[K] = ne), te;
1075
+ provide(FieldContextKey, field);
1076
+ if (isRef(rules) && typeof unref(rules) !== "function") {
1077
+ watch(rules, (value2, oldValue) => {
1078
+ if (isEqual(value2, oldValue)) {
1079
+ return;
1080
+ }
1081
+ meta.validated ? validateWithStateMutation() : validateValidStateOnly();
1082
+ }, {
1083
+ deep: true
1084
+ });
1085
+ }
1086
+ if (!form) {
1087
+ return field;
1088
+ }
1089
+ const dependencies = computed(() => {
1090
+ const rulesVal = validator.value;
1091
+ if (!rulesVal || isCallable(rulesVal) || isYupValidator(rulesVal) || isTypedSchema(rulesVal) || Array.isArray(rulesVal)) {
1092
+ return {};
1093
+ }
1094
+ return Object.keys(rulesVal).reduce((acc, rule) => {
1095
+ const deps = extractLocators(rulesVal[rule]).map((dep) => dep.__locatorRef).reduce((depAcc, depName) => {
1096
+ const depValue = getFromPath(form.values, depName) || form.values[depName];
1097
+ if (depValue !== void 0) {
1098
+ depAcc[depName] = depValue;
1099
+ }
1100
+ return depAcc;
739
1101
  }, {});
740
- return Object.assign(V, A), V;
1102
+ Object.assign(acc, deps);
1103
+ return acc;
741
1104
  }, {});
742
1105
  });
743
- return se(ke, (f, V) => {
744
- if (!Object.keys(f).length)
1106
+ watch(dependencies, (deps, oldDeps) => {
1107
+ if (!Object.keys(deps).length) {
745
1108
  return;
746
- !U(f, V) && (B.validated ? ie() : G());
747
- }), Tt(() => {
748
- var f;
749
- const V = (f = O(W.keepValueOnUnmount)) !== null && f !== void 0 ? f : O(_.keepValuesOnUnmount), N = O(Q);
750
- if (V || !_ || D.pendingUnmount[W.id]) {
751
- _ == null || _.removePathState(N, he);
1109
+ }
1110
+ const shouldValidate = !isEqual(deps, oldDeps);
1111
+ if (shouldValidate) {
1112
+ meta.validated ? validateWithStateMutation() : validateValidStateOnly();
1113
+ }
1114
+ });
1115
+ onBeforeUnmount(() => {
1116
+ var _a;
1117
+ const shouldKeepValue = (_a = toValue(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : toValue(form.keepValuesOnUnmount);
1118
+ const path2 = toValue(name);
1119
+ if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
1120
+ form === null || form === void 0 ? void 0 : form.removePathState(path2, id);
752
1121
  return;
753
1122
  }
754
- D.pendingUnmount[W.id] = !0;
755
- const A = _.getPathState(N);
756
- if (Array.isArray(A == null ? void 0 : A.id) && (A != null && A.multiple) ? A != null && A.id.includes(W.id) : (A == null ? void 0 : A.id) === W.id) {
757
- if (A != null && A.multiple && Array.isArray(A.value)) {
758
- const K = A.value.findIndex((ne) => U(ne, O(W.checkedValue)));
759
- if (K > -1) {
760
- const ne = [...A.value];
761
- ne.splice(K, 1), _.setFieldValue(N, ne);
762
- }
763
- Array.isArray(A.id) && A.id.splice(A.id.indexOf(W.id), 1);
764
- } else
765
- _.unsetPathValue(O(Q));
766
- _.removePathState(N, he);
1123
+ flags.pendingUnmount[field.id] = true;
1124
+ const pathState = form.getPathState(path2);
1125
+ const matchesId = Array.isArray(pathState === null || pathState === void 0 ? void 0 : pathState.id) && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) ? pathState === null || pathState === void 0 ? void 0 : pathState.id.includes(field.id) : (pathState === null || pathState === void 0 ? void 0 : pathState.id) === field.id;
1126
+ if (!matchesId) {
1127
+ return;
767
1128
  }
768
- }), W;
1129
+ if ((pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && Array.isArray(pathState.value)) {
1130
+ const valueIdx = pathState.value.findIndex((i) => isEqual(i, toValue(field.checkedValue)));
1131
+ if (valueIdx > -1) {
1132
+ const newVal = [...pathState.value];
1133
+ newVal.splice(valueIdx, 1);
1134
+ form.setFieldValue(path2, newVal);
1135
+ }
1136
+ if (Array.isArray(pathState.id)) {
1137
+ pathState.id.splice(pathState.id.indexOf(field.id), 1);
1138
+ }
1139
+ } else {
1140
+ form.unsetPathValue(toValue(name));
1141
+ }
1142
+ form.removePathState(path2, id);
1143
+ });
1144
+ return field;
769
1145
  }
770
- function gn(e) {
771
- const t = () => ({
1146
+ function normalizeOptions(opts) {
1147
+ const defaults = () => ({
772
1148
  initialValue: void 0,
773
- validateOnMount: !1,
774
- bails: !0,
1149
+ validateOnMount: false,
1150
+ bails: true,
775
1151
  label: void 0,
776
- validateOnValueUpdate: !0,
1152
+ validateOnValueUpdate: true,
777
1153
  keepValueOnUnmount: void 0,
778
- syncVModel: !1,
779
- controlled: !0
780
- }), n = !!(e != null && e.syncVModel), l = typeof (e == null ? void 0 : e.syncVModel) == "string" ? e.syncVModel : (e == null ? void 0 : e.modelPropName) || "modelValue", u = n && !("initialValue" in (e || {})) ? Ke(Ne(), l) : e == null ? void 0 : e.initialValue;
781
- if (!e)
782
- return Object.assign(Object.assign({}, t()), { initialValue: u });
783
- const a = "valueProp" in e ? e.valueProp : e.checkedValue, h = "standalone" in e ? !e.standalone : e.controlled, v = (e == null ? void 0 : e.modelPropName) || (e == null ? void 0 : e.syncVModel) || !1;
784
- return Object.assign(Object.assign(Object.assign({}, t()), e || {}), {
785
- initialValue: u,
786
- controlled: h ?? !0,
787
- checkedValue: a,
788
- syncVModel: v
1154
+ syncVModel: false,
1155
+ controlled: true
1156
+ });
1157
+ const isVModelSynced = !!(opts === null || opts === void 0 ? void 0 : opts.syncVModel);
1158
+ const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === "string" ? opts.syncVModel : (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || "modelValue";
1159
+ const initialValue = isVModelSynced && !("initialValue" in (opts || {})) ? getCurrentModelValue(getCurrentInstance(), modelPropName) : opts === null || opts === void 0 ? void 0 : opts.initialValue;
1160
+ if (!opts) {
1161
+ return Object.assign(Object.assign({}, defaults()), { initialValue });
1162
+ }
1163
+ const checkedValue = "valueProp" in opts ? opts.valueProp : opts.checkedValue;
1164
+ const controlled = "standalone" in opts ? !opts.standalone : opts.controlled;
1165
+ const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
1166
+ return Object.assign(Object.assign(Object.assign({}, defaults()), opts || {}), {
1167
+ initialValue,
1168
+ controlled: controlled !== null && controlled !== void 0 ? controlled : true,
1169
+ checkedValue,
1170
+ syncVModel
789
1171
  });
790
1172
  }
791
- function pn(e, t, n) {
792
- const l = n != null && n.standalone ? void 0 : pt(Xe), u = n == null ? void 0 : n.checkedValue, a = n == null ? void 0 : n.uncheckedValue;
793
- function h(v) {
794
- const c = v.handleChange, s = j(() => {
795
- const b = O(v.value), F = O(u);
796
- return Array.isArray(b) ? b.findIndex((g) => U(g, F)) >= 0 : U(F, b);
1173
+ function useFieldWithChecked(name, rules, opts) {
1174
+ const form = !(opts === null || opts === void 0 ? void 0 : opts.standalone) ? injectWithSelf(FormContextKey) : void 0;
1175
+ const checkedValue = opts === null || opts === void 0 ? void 0 : opts.checkedValue;
1176
+ const uncheckedValue = opts === null || opts === void 0 ? void 0 : opts.uncheckedValue;
1177
+ function patchCheckedApi(field) {
1178
+ const handleChange = field.handleChange;
1179
+ const checked = computed(() => {
1180
+ const currentValue = toValue(field.value);
1181
+ const checkedVal = toValue(checkedValue);
1182
+ return Array.isArray(currentValue) ? currentValue.findIndex((v) => isEqual(v, checkedVal)) >= 0 : isEqual(checkedVal, currentValue);
797
1183
  });
798
- function S(b, F = !0) {
799
- var g, T;
800
- if (s.value === ((g = b == null ? void 0 : b.target) === null || g === void 0 ? void 0 : g.checked)) {
801
- F && v.validate();
1184
+ function handleCheckboxChange(e, shouldValidate = true) {
1185
+ var _a, _b;
1186
+ if (checked.value === ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.checked)) {
1187
+ if (shouldValidate) {
1188
+ field.validate();
1189
+ }
802
1190
  return;
803
1191
  }
804
- const J = O(e), _ = l == null ? void 0 : l.getPathState(J), Q = Ce(b);
805
- let $ = (T = O(u)) !== null && T !== void 0 ? T : Q;
806
- l && (_ != null && _.multiple) && _.type === "checkbox" ? $ = ot(L(l.values, J) || [], $, void 0) : (n == null ? void 0 : n.type) === "checkbox" && ($ = ot(O(v.value), $, O(a))), c($, F);
807
- }
808
- return Object.assign(Object.assign({}, v), {
809
- checked: s,
810
- checkedValue: u,
811
- uncheckedValue: a,
812
- handleChange: S
1192
+ const path = toValue(name);
1193
+ const pathState = form === null || form === void 0 ? void 0 : form.getPathState(path);
1194
+ const value = normalizeEventValue(e);
1195
+ let newValue = (_b = toValue(checkedValue)) !== null && _b !== void 0 ? _b : value;
1196
+ if (form && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && pathState.type === "checkbox") {
1197
+ newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [], newValue, void 0);
1198
+ } else if ((opts === null || opts === void 0 ? void 0 : opts.type) === "checkbox") {
1199
+ newValue = resolveNextCheckboxValue(toValue(field.value), newValue, toValue(uncheckedValue));
1200
+ }
1201
+ handleChange(newValue, shouldValidate);
1202
+ }
1203
+ return Object.assign(Object.assign({}, field), {
1204
+ checked,
1205
+ checkedValue,
1206
+ uncheckedValue,
1207
+ handleChange: handleCheckboxChange
813
1208
  });
814
1209
  }
815
- return h(At(e, t, n));
1210
+ return patchCheckedApi(_useField(name, rules, opts));
816
1211
  }
817
- function bn({ prop: e, value: t, handleChange: n, shouldValidate: l }) {
818
- const u = Ne();
819
- if (!u || !e)
1212
+ function useVModel({ prop, value, handleChange, shouldValidate }) {
1213
+ const vm = getCurrentInstance();
1214
+ if (!vm || !prop) {
820
1215
  return;
821
- const a = typeof e == "string" ? e : "modelValue", h = `update:${a}`;
822
- a in u.props && (se(t, (v) => {
823
- U(v, Ke(u, a)) || u.emit(h, v);
824
- }), se(() => Ke(u, a), (v) => {
825
- if (v === lt && t.value === void 0)
1216
+ }
1217
+ const propName = typeof prop === "string" ? prop : "modelValue";
1218
+ const emitName = `update:${propName}`;
1219
+ if (!(propName in vm.props)) {
1220
+ return;
1221
+ }
1222
+ watch(value, (newValue) => {
1223
+ if (isEqual(newValue, getCurrentModelValue(vm, propName))) {
826
1224
  return;
827
- const c = v === lt ? void 0 : v;
828
- U(c, t.value) || n(c, l());
829
- }));
830
- }
831
- function Ke(e, t) {
832
- if (e)
833
- return e.props[t];
834
- }
835
- let Vn = 0;
836
- const we = ["bails", "fieldsCount", "id", "multiple", "type", "validate"];
837
- function jt(e) {
838
- const n = Object.assign({}, O({})), l = w(void 0);
839
- return l && X(l) && x(l.cast) ? E(l.cast(n) || {}) : E(n);
840
- }
841
- function En(e) {
842
- var t;
843
- const n = Vn++;
844
- let l = 0;
845
- const u = Y(!1), a = Y(!1), h = Y(0), v = [], c = Pe(jt()), s = Y([]), S = Y({}), b = Y({}), F = Xt(() => {
846
- b.value = s.value.reduce((i, r) => (i[be(O(r.path))] = r, i), {});
1225
+ }
1226
+ vm.emit(emitName, newValue);
847
1227
  });
848
- function g(i, r) {
849
- const o = M(i);
850
- if (!o) {
851
- typeof i == "string" && (S.value[be(i)] = He(r));
1228
+ watch(() => getCurrentModelValue(vm, propName), (propValue) => {
1229
+ if (propValue === IS_ABSENT && value.value === void 0) {
852
1230
  return;
853
1231
  }
854
- if (typeof i == "string") {
855
- const d = be(i);
856
- S.value[d] && delete S.value[d];
1232
+ const newValue = propValue === IS_ABSENT ? void 0 : propValue;
1233
+ if (isEqual(newValue, value.value)) {
1234
+ return;
857
1235
  }
858
- o.errors = He(r), o.valid = !o.errors.length;
1236
+ handleChange(newValue, shouldValidate());
1237
+ });
1238
+ }
1239
+ function getCurrentModelValue(vm, propName) {
1240
+ if (!vm) {
1241
+ return void 0;
1242
+ }
1243
+ return vm.props[propName];
1244
+ }
1245
+ let FORM_COUNTER = 0;
1246
+ const PRIVATE_PATH_STATE_KEYS = ["bails", "fieldsCount", "id", "multiple", "type", "validate"];
1247
+ function resolveInitialValues(opts) {
1248
+ const givenInitial = {};
1249
+ const providedValues = Object.assign({}, toValue(givenInitial));
1250
+ const schema = unref(void 0);
1251
+ if (schema && isTypedSchema(schema) && isCallable(schema.cast)) {
1252
+ return klona(schema.cast(providedValues) || {});
859
1253
  }
860
- function T(i) {
861
- q(i).forEach((r) => {
862
- g(r, i[r]);
1254
+ return klona(providedValues);
1255
+ }
1256
+ function useForm(opts) {
1257
+ var _a;
1258
+ const formId = FORM_COUNTER++;
1259
+ let FIELD_ID_COUNTER = 0;
1260
+ const isSubmitting = ref(false);
1261
+ const isValidating = ref(false);
1262
+ const submitCount = ref(0);
1263
+ const fieldArrays = [];
1264
+ const formValues = reactive(resolveInitialValues());
1265
+ const pathStates = ref([]);
1266
+ const extraErrorsBag = ref({});
1267
+ const pathStateLookup = ref({});
1268
+ const rebuildPathLookup = debounceNextTick(() => {
1269
+ pathStateLookup.value = pathStates.value.reduce((names, state) => {
1270
+ names[normalizeFormPath(toValue(state.path))] = state;
1271
+ return names;
1272
+ }, {});
1273
+ });
1274
+ function setFieldError(field, message) {
1275
+ const state = findPathState(field);
1276
+ if (!state) {
1277
+ if (typeof field === "string") {
1278
+ extraErrorsBag.value[normalizeFormPath(field)] = normalizeErrorItem(message);
1279
+ }
1280
+ return;
1281
+ }
1282
+ if (typeof field === "string") {
1283
+ const normalizedPath = normalizeFormPath(field);
1284
+ if (extraErrorsBag.value[normalizedPath]) {
1285
+ delete extraErrorsBag.value[normalizedPath];
1286
+ }
1287
+ }
1288
+ state.errors = normalizeErrorItem(message);
1289
+ state.valid = !state.errors.length;
1290
+ }
1291
+ function setErrors(paths) {
1292
+ keysOf(paths).forEach((path) => {
1293
+ setFieldError(path, paths[path]);
863
1294
  });
864
1295
  }
865
- const J = j(() => {
866
- const i = s.value.reduce((r, o) => (o.errors.length && (r[o.path] = o.errors), r), {});
867
- return Object.assign(Object.assign({}, S.value), i);
868
- }), _ = j(() => q(J.value).reduce((i, r) => {
869
- const o = J.value[r];
870
- return o != null && o.length && (i[r] = o[0]), i;
871
- }, {})), Q = j(() => s.value.reduce((i, r) => (i[r.path] = { name: r.path || "", label: r.label || "" }, i), {})), $ = j(() => s.value.reduce((i, r) => {
872
- var o;
873
- return i[r.path] = (o = r.bails) !== null && o !== void 0 ? o : !0, i;
874
- }, {})), _e = Object.assign({}, {}), he = (t = void 0) !== null && t !== void 0 ? t : !1, { initialValues: Z, originalInitialValues: le, setInitialValues: B } = _n(s, c), de = On(s, c, le, _), me = j(() => s.value.reduce((i, r) => {
875
- const o = L(c, r.path);
876
- return re(i, r.path, o), i;
877
- }, {})), D = void 0;
878
- function fe(i, r) {
879
- var o, d;
880
- const y = j(() => L(Z.value, O(i))), p = b.value[O(i)], m = (r == null ? void 0 : r.type) === "checkbox" || (r == null ? void 0 : r.type) === "radio";
881
- if (p && m) {
882
- p.multiple = !0;
883
- const H = l++;
884
- return Array.isArray(p.id) ? p.id.push(H) : p.id = [p.id, H], p.fieldsCount++, p.__flags.pendingUnmount[H] = !1, p;
885
- }
886
- const I = j(() => L(c, O(i))), C = O(i), k = ae.findIndex((H) => H === C);
887
- k !== -1 && ae.splice(k, 1);
888
- const P = j(() => {
889
- var H, pe, De, ze;
890
- const xe = O(D);
891
- if (X(xe))
892
- return (pe = (H = xe.describe) === null || H === void 0 ? void 0 : H.call(xe, O(i)).required) !== null && pe !== void 0 ? pe : !1;
893
- const Le = O(r == null ? void 0 : r.schema);
894
- return X(Le) && (ze = (De = Le.describe) === null || De === void 0 ? void 0 : De.call(Le).required) !== null && ze !== void 0 ? ze : !1;
895
- }), R = l++, z = Pe({
896
- id: R,
897
- path: i,
898
- touched: !1,
899
- pending: !1,
900
- valid: !0,
901
- validated: !!(!((o = _e[C]) === null || o === void 0) && o.length),
902
- required: P,
903
- initialValue: y,
904
- errors: Rt([]),
905
- bails: (d = r == null ? void 0 : r.bails) !== null && d !== void 0 ? d : !1,
906
- label: r == null ? void 0 : r.label,
907
- type: (r == null ? void 0 : r.type) || "default",
908
- value: I,
909
- multiple: !1,
1296
+ const errorBag = computed(() => {
1297
+ const pathErrors = pathStates.value.reduce((acc, state) => {
1298
+ if (state.errors.length) {
1299
+ acc[state.path] = state.errors;
1300
+ }
1301
+ return acc;
1302
+ }, {});
1303
+ return Object.assign(Object.assign({}, extraErrorsBag.value), pathErrors);
1304
+ });
1305
+ const errors = computed(() => {
1306
+ return keysOf(errorBag.value).reduce((acc, key) => {
1307
+ const errors2 = errorBag.value[key];
1308
+ if (errors2 === null || errors2 === void 0 ? void 0 : errors2.length) {
1309
+ acc[key] = errors2[0];
1310
+ }
1311
+ return acc;
1312
+ }, {});
1313
+ });
1314
+ const fieldNames = computed(() => {
1315
+ return pathStates.value.reduce((names, state) => {
1316
+ names[state.path] = { name: state.path || "", label: state.label || "" };
1317
+ return names;
1318
+ }, {});
1319
+ });
1320
+ const fieldBailsMap = computed(() => {
1321
+ return pathStates.value.reduce((map, state) => {
1322
+ var _a2;
1323
+ map[state.path] = (_a2 = state.bails) !== null && _a2 !== void 0 ? _a2 : true;
1324
+ return map;
1325
+ }, {});
1326
+ });
1327
+ const initialErrors = Object.assign({}, {});
1328
+ const keepValuesOnUnmount = (_a = void 0) !== null && _a !== void 0 ? _a : false;
1329
+ const { initialValues, originalInitialValues, setInitialValues } = useFormInitialValues(pathStates, formValues);
1330
+ const meta = useFormMeta(pathStates, formValues, originalInitialValues, errors);
1331
+ const controlledValues = computed(() => {
1332
+ return pathStates.value.reduce((acc, state) => {
1333
+ const value = getFromPath(formValues, state.path);
1334
+ setInPath(acc, state.path, value);
1335
+ return acc;
1336
+ }, {});
1337
+ });
1338
+ const schema = void 0;
1339
+ function createPathState(path, config) {
1340
+ var _a2, _b;
1341
+ const initialValue = computed(() => getFromPath(initialValues.value, toValue(path)));
1342
+ const pathStateExists = pathStateLookup.value[toValue(path)];
1343
+ const isCheckboxOrRadio = (config === null || config === void 0 ? void 0 : config.type) === "checkbox" || (config === null || config === void 0 ? void 0 : config.type) === "radio";
1344
+ if (pathStateExists && isCheckboxOrRadio) {
1345
+ pathStateExists.multiple = true;
1346
+ const id2 = FIELD_ID_COUNTER++;
1347
+ if (Array.isArray(pathStateExists.id)) {
1348
+ pathStateExists.id.push(id2);
1349
+ } else {
1350
+ pathStateExists.id = [pathStateExists.id, id2];
1351
+ }
1352
+ pathStateExists.fieldsCount++;
1353
+ pathStateExists.__flags.pendingUnmount[id2] = false;
1354
+ return pathStateExists;
1355
+ }
1356
+ const currentValue = computed(() => getFromPath(formValues, toValue(path)));
1357
+ const pathValue = toValue(path);
1358
+ const unsetBatchIndex = UNSET_BATCH.findIndex((_path) => _path === pathValue);
1359
+ if (unsetBatchIndex !== -1) {
1360
+ UNSET_BATCH.splice(unsetBatchIndex, 1);
1361
+ }
1362
+ const isRequired = computed(() => {
1363
+ var _a3, _b2, _c, _d;
1364
+ const schemaValue = toValue(schema);
1365
+ if (isTypedSchema(schemaValue)) {
1366
+ return (_b2 = (_a3 = schemaValue.describe) === null || _a3 === void 0 ? void 0 : _a3.call(schemaValue, toValue(path)).required) !== null && _b2 !== void 0 ? _b2 : false;
1367
+ }
1368
+ const configSchemaValue = toValue(config === null || config === void 0 ? void 0 : config.schema);
1369
+ if (isTypedSchema(configSchemaValue)) {
1370
+ return (_d = (_c = configSchemaValue.describe) === null || _c === void 0 ? void 0 : _c.call(configSchemaValue).required) !== null && _d !== void 0 ? _d : false;
1371
+ }
1372
+ return false;
1373
+ });
1374
+ const id = FIELD_ID_COUNTER++;
1375
+ const state = reactive({
1376
+ id,
1377
+ path,
1378
+ touched: false,
1379
+ pending: false,
1380
+ valid: true,
1381
+ validated: !!((_a2 = initialErrors[pathValue]) === null || _a2 === void 0 ? void 0 : _a2.length),
1382
+ required: isRequired,
1383
+ initialValue,
1384
+ errors: shallowRef([]),
1385
+ bails: (_b = config === null || config === void 0 ? void 0 : config.bails) !== null && _b !== void 0 ? _b : false,
1386
+ label: config === null || config === void 0 ? void 0 : config.label,
1387
+ type: (config === null || config === void 0 ? void 0 : config.type) || "default",
1388
+ value: currentValue,
1389
+ multiple: false,
910
1390
  __flags: {
911
- pendingUnmount: { [R]: !1 },
912
- pendingReset: !1
1391
+ pendingUnmount: { [id]: false },
1392
+ pendingReset: false
913
1393
  },
914
1394
  fieldsCount: 1,
915
- validate: r == null ? void 0 : r.validate,
916
- dirty: j(() => !U(w(I), w(y)))
1395
+ validate: config === null || config === void 0 ? void 0 : config.validate,
1396
+ dirty: computed(() => {
1397
+ return !isEqual(unref(currentValue), unref(initialValue));
1398
+ })
917
1399
  });
918
- return s.value.push(z), b.value[C] = z, F(), _.value[C] && !_e[C] && ee(() => {
919
- oe(C, { mode: "silent" });
920
- }), Fe(i) && se(i, (H) => {
921
- F();
922
- const pe = E(I.value);
923
- b.value[H] = z, ee(() => {
924
- re(c, H, pe);
1400
+ pathStates.value.push(state);
1401
+ pathStateLookup.value[pathValue] = state;
1402
+ rebuildPathLookup();
1403
+ if (errors.value[pathValue] && !initialErrors[pathValue]) {
1404
+ nextTick(() => {
1405
+ validateField(pathValue, { mode: "silent" });
925
1406
  });
926
- }), z;
927
- }
928
- const Te = st(nt, 5), Se = st(nt, 5), ie = Ge(async (i) => await (i === "silent" ? Te() : Se()), (i, [r]) => {
929
- const o = q(f.errorBag.value), y = [
930
- .../* @__PURE__ */ new Set([...q(i.results), ...s.value.map((p) => p.path), ...o])
931
- ].sort().reduce((p, m) => {
932
- var I;
933
- const C = m, k = M(C) || Ae(C), P = ((I = i.results[C]) === null || I === void 0 ? void 0 : I.errors) || [], R = O(k == null ? void 0 : k.path) || C, z = Sn({ errors: P, valid: !P.length }, p.results[R]);
934
- return p.results[R] = z, z.valid || (p.errors[R] = z.errors[0]), k && S.value[R] && delete S.value[R], k ? (k.valid = z.valid, r === "silent" || r === "validated-only" && !k.validated || g(k, z.errors), p) : (g(R, P), p);
1407
+ }
1408
+ if (isRef(path)) {
1409
+ watch(path, (newPath) => {
1410
+ rebuildPathLookup();
1411
+ const nextValue = klona(currentValue.value);
1412
+ pathStateLookup.value[newPath] = state;
1413
+ nextTick(() => {
1414
+ setInPath(formValues, newPath, nextValue);
1415
+ });
1416
+ });
1417
+ }
1418
+ return state;
1419
+ }
1420
+ const debouncedSilentValidation = debounceAsync(_validateSchema, 5);
1421
+ const debouncedValidation = debounceAsync(_validateSchema, 5);
1422
+ const validateSchema = withLatest(async (mode) => {
1423
+ return await (mode === "silent" ? debouncedSilentValidation() : debouncedValidation());
1424
+ }, (formResult, [mode]) => {
1425
+ const currentErrorsPaths = keysOf(formCtx.errorBag.value);
1426
+ const paths = [
1427
+ .../* @__PURE__ */ new Set([...keysOf(formResult.results), ...pathStates.value.map((p) => p.path), ...currentErrorsPaths])
1428
+ ].sort();
1429
+ const results = paths.reduce((validation, _path) => {
1430
+ var _a2;
1431
+ const expectedPath = _path;
1432
+ const pathState = findPathState(expectedPath) || findHoistedPath(expectedPath);
1433
+ const messages = ((_a2 = formResult.results[expectedPath]) === null || _a2 === void 0 ? void 0 : _a2.errors) || [];
1434
+ const path = toValue(pathState === null || pathState === void 0 ? void 0 : pathState.path) || expectedPath;
1435
+ const fieldResult = mergeValidationResults({ errors: messages, valid: !messages.length }, validation.results[path]);
1436
+ validation.results[path] = fieldResult;
1437
+ if (!fieldResult.valid) {
1438
+ validation.errors[path] = fieldResult.errors[0];
1439
+ }
1440
+ if (pathState && extraErrorsBag.value[path]) {
1441
+ delete extraErrorsBag.value[path];
1442
+ }
1443
+ if (!pathState) {
1444
+ setFieldError(path, messages);
1445
+ return validation;
1446
+ }
1447
+ pathState.valid = fieldResult.valid;
1448
+ if (mode === "silent") {
1449
+ return validation;
1450
+ }
1451
+ if (mode === "validated-only" && !pathState.validated) {
1452
+ return validation;
1453
+ }
1454
+ setFieldError(pathState, fieldResult.errors);
1455
+ return validation;
935
1456
  }, {
936
- valid: i.valid,
1457
+ valid: formResult.valid,
937
1458
  results: {},
938
1459
  errors: {},
939
- source: i.source
1460
+ source: formResult.source
1461
+ });
1462
+ if (formResult.values) {
1463
+ results.values = formResult.values;
1464
+ results.source = formResult.source;
1465
+ }
1466
+ keysOf(results.results).forEach((path) => {
1467
+ var _a2;
1468
+ const pathState = findPathState(path);
1469
+ if (!pathState) {
1470
+ return;
1471
+ }
1472
+ if (mode === "silent") {
1473
+ return;
1474
+ }
1475
+ if (mode === "validated-only" && !pathState.validated) {
1476
+ return;
1477
+ }
1478
+ setFieldError(pathState, (_a2 = results.results[path]) === null || _a2 === void 0 ? void 0 : _a2.errors);
940
1479
  });
941
- return i.values && (y.values = i.values, y.source = i.source), q(y.results).forEach((p) => {
942
- var m;
943
- const I = M(p);
944
- I && r !== "silent" && (r === "validated-only" && !I.validated || g(I, (m = y.results[p]) === null || m === void 0 ? void 0 : m.errors));
945
- }), y;
1480
+ return results;
946
1481
  });
947
- function G(i) {
948
- s.value.forEach(i);
949
- }
950
- function M(i) {
951
- const r = typeof i == "string" ? be(i) : i;
952
- return typeof r == "string" ? b.value[r] : r;
953
- }
954
- function Ae(i) {
955
- return s.value.filter((o) => i.startsWith(o.path)).reduce((o, d) => o ? d.path.length > o.path.length ? d : o : d, void 0);
956
- }
957
- let ae = [], ue;
958
- function je(i) {
959
- return ae.push(i), ue || (ue = ee(() => {
960
- [...ae].sort().reverse().forEach((o) => {
961
- ut(c, o);
962
- }), ae = [], ue = null;
963
- })), ue;
964
- }
965
- function ve(i) {
966
- return function(o, d) {
967
- return function(p) {
968
- return p instanceof Event && (p.preventDefault(), p.stopPropagation()), G((m) => m.touched = !0), u.value = !0, h.value++, ge().then((m) => {
969
- const I = E(c);
970
- if (m.valid && typeof o == "function") {
971
- const C = E(me.value);
972
- let k = i ? C : I;
973
- return m.values && (k = m.source === "schema" ? m.values : Object.assign({}, k, m.values)), o(k, {
974
- evt: p,
975
- controlledValues: C,
976
- setErrors: T,
977
- setFieldError: g,
978
- setTouched: Ze,
979
- setFieldTouched: K,
980
- setValues: A,
981
- setFieldValue: V,
982
- resetForm: Re,
983
- resetField: et
1482
+ function mutateAllPathState(mutation) {
1483
+ pathStates.value.forEach(mutation);
1484
+ }
1485
+ function findPathState(path) {
1486
+ const normalizedPath = typeof path === "string" ? normalizeFormPath(path) : path;
1487
+ const pathState = typeof normalizedPath === "string" ? pathStateLookup.value[normalizedPath] : normalizedPath;
1488
+ return pathState;
1489
+ }
1490
+ function findHoistedPath(path) {
1491
+ const candidates = pathStates.value.filter((state) => path.startsWith(state.path));
1492
+ return candidates.reduce((bestCandidate, candidate) => {
1493
+ if (!bestCandidate) {
1494
+ return candidate;
1495
+ }
1496
+ return candidate.path.length > bestCandidate.path.length ? candidate : bestCandidate;
1497
+ }, void 0);
1498
+ }
1499
+ let UNSET_BATCH = [];
1500
+ let PENDING_UNSET;
1501
+ function unsetPathValue(path) {
1502
+ UNSET_BATCH.push(path);
1503
+ if (!PENDING_UNSET) {
1504
+ PENDING_UNSET = nextTick(() => {
1505
+ const sortedPaths = [...UNSET_BATCH].sort().reverse();
1506
+ sortedPaths.forEach((p) => {
1507
+ unsetPath(formValues, p);
1508
+ });
1509
+ UNSET_BATCH = [];
1510
+ PENDING_UNSET = null;
1511
+ });
1512
+ }
1513
+ return PENDING_UNSET;
1514
+ }
1515
+ function makeSubmissionFactory(onlyControlled) {
1516
+ return function submitHandlerFactory(fn, onValidationError) {
1517
+ return function submissionHandler(e) {
1518
+ if (e instanceof Event) {
1519
+ e.preventDefault();
1520
+ e.stopPropagation();
1521
+ }
1522
+ mutateAllPathState((s) => s.touched = true);
1523
+ isSubmitting.value = true;
1524
+ submitCount.value++;
1525
+ return validate2().then((result) => {
1526
+ const values = klona(formValues);
1527
+ if (result.valid && typeof fn === "function") {
1528
+ const controlled = klona(controlledValues.value);
1529
+ let submittedValues = onlyControlled ? controlled : values;
1530
+ if (result.values) {
1531
+ submittedValues = result.source === "schema" ? result.values : Object.assign({}, submittedValues, result.values);
1532
+ }
1533
+ return fn(submittedValues, {
1534
+ evt: e,
1535
+ controlledValues: controlled,
1536
+ setErrors,
1537
+ setFieldError,
1538
+ setTouched,
1539
+ setFieldTouched,
1540
+ setValues,
1541
+ setFieldValue,
1542
+ resetForm,
1543
+ resetField
984
1544
  });
985
1545
  }
986
- !m.valid && typeof d == "function" && d({
987
- values: I,
988
- evt: p,
989
- errors: m.errors,
990
- results: m.results
991
- });
992
- }).then((m) => (u.value = !1, m), (m) => {
993
- throw u.value = !1, m;
1546
+ if (!result.valid && typeof onValidationError === "function") {
1547
+ onValidationError({
1548
+ values,
1549
+ evt: e,
1550
+ errors: result.errors,
1551
+ results: result.results
1552
+ });
1553
+ }
1554
+ }).then((returnVal) => {
1555
+ isSubmitting.value = false;
1556
+ return returnVal;
1557
+ }, (err) => {
1558
+ isSubmitting.value = false;
1559
+ throw err;
994
1560
  });
995
1561
  };
996
1562
  };
997
1563
  }
998
- const ye = ve(!1);
999
- ye.withControlled = ve(!0);
1000
- function W(i, r) {
1001
- const o = s.value.findIndex((y) => y.path === i && (Array.isArray(y.id) ? y.id.includes(r) : y.id === r)), d = s.value[o];
1002
- if (!(o === -1 || !d)) {
1003
- if (ee(() => {
1004
- oe(i, { mode: "silent", warn: !1 });
1005
- }), d.multiple && d.fieldsCount && d.fieldsCount--, Array.isArray(d.id)) {
1006
- const y = d.id.indexOf(r);
1007
- y >= 0 && d.id.splice(y, 1), delete d.__flags.pendingUnmount[r];
1564
+ const handleSubmitImpl = makeSubmissionFactory(false);
1565
+ const handleSubmit = handleSubmitImpl;
1566
+ handleSubmit.withControlled = makeSubmissionFactory(true);
1567
+ function removePathState(path, id) {
1568
+ const idx = pathStates.value.findIndex((s) => {
1569
+ return s.path === path && (Array.isArray(s.id) ? s.id.includes(id) : s.id === id);
1570
+ });
1571
+ const pathState = pathStates.value[idx];
1572
+ if (idx === -1 || !pathState) {
1573
+ return;
1574
+ }
1575
+ nextTick(() => {
1576
+ validateField(path, { mode: "silent", warn: false });
1577
+ });
1578
+ if (pathState.multiple && pathState.fieldsCount) {
1579
+ pathState.fieldsCount--;
1580
+ }
1581
+ if (Array.isArray(pathState.id)) {
1582
+ const idIndex = pathState.id.indexOf(id);
1583
+ if (idIndex >= 0) {
1584
+ pathState.id.splice(idIndex, 1);
1008
1585
  }
1009
- (!d.multiple || d.fieldsCount <= 0) && (s.value.splice(o, 1), tt(i), F(), delete b.value[i]);
1586
+ delete pathState.__flags.pendingUnmount[id];
1587
+ }
1588
+ if (!pathState.multiple || pathState.fieldsCount <= 0) {
1589
+ pathStates.value.splice(idx, 1);
1590
+ unsetInitialValue(path);
1591
+ rebuildPathLookup();
1592
+ delete pathStateLookup.value[path];
1010
1593
  }
1011
1594
  }
1012
- function ke(i) {
1013
- q(b.value).forEach((r) => {
1014
- r.startsWith(i) && delete b.value[r];
1015
- }), s.value = s.value.filter((r) => !r.path.startsWith(i)), ee(() => {
1016
- F();
1595
+ function destroyPath(path) {
1596
+ keysOf(pathStateLookup.value).forEach((key) => {
1597
+ if (key.startsWith(path)) {
1598
+ delete pathStateLookup.value[key];
1599
+ }
1600
+ });
1601
+ pathStates.value = pathStates.value.filter((s) => !s.path.startsWith(path));
1602
+ nextTick(() => {
1603
+ rebuildPathLookup();
1017
1604
  });
1018
1605
  }
1019
- const f = {
1020
- formId: n,
1021
- values: c,
1022
- controlledValues: me,
1023
- errorBag: J,
1024
- errors: _,
1025
- schema: D,
1026
- submitCount: h,
1027
- meta: de,
1028
- isSubmitting: u,
1029
- isValidating: a,
1030
- fieldArrays: v,
1031
- keepValuesOnUnmount: he,
1032
- validateSchema: w(D) ? ie : void 0,
1033
- validate: ge,
1034
- setFieldError: g,
1035
- validateField: oe,
1036
- setFieldValue: V,
1037
- setValues: A,
1038
- setErrors: T,
1039
- setFieldTouched: K,
1040
- setTouched: Ze,
1041
- resetForm: Re,
1042
- resetField: et,
1043
- handleSubmit: ye,
1044
- useFieldModel: It,
1045
- defineInputBinds: Ct,
1046
- defineComponentBinds: Nt,
1047
- defineField: Be,
1048
- stageInitialValue: Pt,
1049
- unsetInitialValue: tt,
1050
- setFieldInitialValue: Ue,
1051
- createPathState: fe,
1052
- getPathState: M,
1053
- unsetPathValue: je,
1054
- removePathState: W,
1055
- initialValues: Z,
1056
- getAllPathStates: () => s.value,
1057
- destroyPath: ke,
1058
- isFieldTouched: ne,
1059
- isFieldDirty: Et,
1060
- isFieldValid: wt
1606
+ const formCtx = {
1607
+ formId,
1608
+ values: formValues,
1609
+ controlledValues,
1610
+ errorBag,
1611
+ errors,
1612
+ schema,
1613
+ submitCount,
1614
+ meta,
1615
+ isSubmitting,
1616
+ isValidating,
1617
+ fieldArrays,
1618
+ keepValuesOnUnmount,
1619
+ validateSchema: unref(schema) ? validateSchema : void 0,
1620
+ validate: validate2,
1621
+ setFieldError,
1622
+ validateField,
1623
+ setFieldValue,
1624
+ setValues,
1625
+ setErrors,
1626
+ setFieldTouched,
1627
+ setTouched,
1628
+ resetForm,
1629
+ resetField,
1630
+ handleSubmit,
1631
+ useFieldModel,
1632
+ defineInputBinds,
1633
+ defineComponentBinds,
1634
+ defineField,
1635
+ stageInitialValue,
1636
+ unsetInitialValue,
1637
+ setFieldInitialValue,
1638
+ createPathState,
1639
+ getPathState: findPathState,
1640
+ unsetPathValue,
1641
+ removePathState,
1642
+ initialValues,
1643
+ getAllPathStates: () => pathStates.value,
1644
+ destroyPath,
1645
+ isFieldTouched,
1646
+ isFieldDirty,
1647
+ isFieldValid
1061
1648
  };
1062
- function V(i, r, o = !0) {
1063
- const d = E(r), y = typeof i == "string" ? i : i.path;
1064
- M(y) || fe(y), re(c, y, d), o && oe(y);
1065
- }
1066
- function N(i, r = !0) {
1067
- q(c).forEach((o) => {
1068
- delete c[o];
1069
- }), q(i).forEach((o) => {
1070
- V(o, i[o], !1);
1071
- }), r && ge();
1072
- }
1073
- function A(i, r = !0) {
1074
- Oe(c, i), v.forEach((o) => o && o.reset()), r && ge();
1075
- }
1076
- function te(i, r) {
1077
- const o = M(O(i)) || fe(i);
1078
- return j({
1649
+ function setFieldValue(field, value, shouldValidate = true) {
1650
+ const clonedValue = klona(value);
1651
+ const path = typeof field === "string" ? field : field.path;
1652
+ const pathState = findPathState(path);
1653
+ if (!pathState) {
1654
+ createPathState(path);
1655
+ }
1656
+ setInPath(formValues, path, clonedValue);
1657
+ if (shouldValidate) {
1658
+ validateField(path);
1659
+ }
1660
+ }
1661
+ function forceSetValues(fields, shouldValidate = true) {
1662
+ keysOf(formValues).forEach((key) => {
1663
+ delete formValues[key];
1664
+ });
1665
+ keysOf(fields).forEach((path) => {
1666
+ setFieldValue(path, fields[path], false);
1667
+ });
1668
+ if (shouldValidate) {
1669
+ validate2();
1670
+ }
1671
+ }
1672
+ function setValues(fields, shouldValidate = true) {
1673
+ merge(formValues, fields);
1674
+ fieldArrays.forEach((f) => f && f.reset());
1675
+ if (shouldValidate) {
1676
+ validate2();
1677
+ }
1678
+ }
1679
+ function createModel(path, shouldValidate) {
1680
+ const pathState = findPathState(toValue(path)) || createPathState(path);
1681
+ return computed({
1079
1682
  get() {
1080
- return o.value;
1683
+ return pathState.value;
1081
1684
  },
1082
- set(d) {
1083
- var y;
1084
- const p = O(i);
1085
- V(p, d, (y = O(r)) !== null && y !== void 0 ? y : !1);
1685
+ set(value) {
1686
+ var _a2;
1687
+ const pathValue = toValue(path);
1688
+ setFieldValue(pathValue, value, (_a2 = toValue(shouldValidate)) !== null && _a2 !== void 0 ? _a2 : false);
1086
1689
  }
1087
1690
  });
1088
1691
  }
1089
- function K(i, r) {
1090
- const o = M(i);
1091
- o && (o.touched = r);
1692
+ function setFieldTouched(field, isTouched) {
1693
+ const pathState = findPathState(field);
1694
+ if (pathState) {
1695
+ pathState.touched = isTouched;
1696
+ }
1092
1697
  }
1093
- function ne(i) {
1094
- const r = M(i);
1095
- return r ? r.touched : s.value.filter((o) => o.path.startsWith(i)).some((o) => o.touched);
1698
+ function isFieldTouched(field) {
1699
+ const pathState = findPathState(field);
1700
+ if (pathState) {
1701
+ return pathState.touched;
1702
+ }
1703
+ return pathStates.value.filter((s) => s.path.startsWith(field)).some((s) => s.touched);
1096
1704
  }
1097
- function Et(i) {
1098
- const r = M(i);
1099
- return r ? r.dirty : s.value.filter((o) => o.path.startsWith(i)).some((o) => o.dirty);
1705
+ function isFieldDirty(field) {
1706
+ const pathState = findPathState(field);
1707
+ if (pathState) {
1708
+ return pathState.dirty;
1709
+ }
1710
+ return pathStates.value.filter((s) => s.path.startsWith(field)).some((s) => s.dirty);
1100
1711
  }
1101
- function wt(i) {
1102
- const r = M(i);
1103
- return r ? r.valid : s.value.filter((o) => o.path.startsWith(i)).every((o) => o.valid);
1712
+ function isFieldValid(field) {
1713
+ const pathState = findPathState(field);
1714
+ if (pathState) {
1715
+ return pathState.valid;
1716
+ }
1717
+ return pathStates.value.filter((s) => s.path.startsWith(field)).every((s) => s.valid);
1104
1718
  }
1105
- function Ze(i) {
1106
- if (typeof i == "boolean") {
1107
- G((r) => {
1108
- r.touched = i;
1719
+ function setTouched(fields) {
1720
+ if (typeof fields === "boolean") {
1721
+ mutateAllPathState((state) => {
1722
+ state.touched = fields;
1109
1723
  });
1110
1724
  return;
1111
1725
  }
1112
- q(i).forEach((r) => {
1113
- K(r, !!i[r]);
1726
+ keysOf(fields).forEach((field) => {
1727
+ setFieldTouched(field, !!fields[field]);
1114
1728
  });
1115
1729
  }
1116
- function et(i, r) {
1117
- var o;
1118
- const d = r && "value" in r ? r.value : L(Z.value, i), y = M(i);
1119
- y && (y.__flags.pendingReset = !0), Ue(i, E(d), !0), V(i, d, !1), K(i, (o = r == null ? void 0 : r.touched) !== null && o !== void 0 ? o : !1), g(i, (r == null ? void 0 : r.errors) || []), ee(() => {
1120
- y && (y.__flags.pendingReset = !1);
1730
+ function resetField(field, state) {
1731
+ var _a2;
1732
+ const newValue = state && "value" in state ? state.value : getFromPath(initialValues.value, field);
1733
+ const pathState = findPathState(field);
1734
+ if (pathState) {
1735
+ pathState.__flags.pendingReset = true;
1736
+ }
1737
+ setFieldInitialValue(field, klona(newValue), true);
1738
+ setFieldValue(field, newValue, false);
1739
+ setFieldTouched(field, (_a2 = state === null || state === void 0 ? void 0 : state.touched) !== null && _a2 !== void 0 ? _a2 : false);
1740
+ setFieldError(field, (state === null || state === void 0 ? void 0 : state.errors) || []);
1741
+ nextTick(() => {
1742
+ if (pathState) {
1743
+ pathState.__flags.pendingReset = false;
1744
+ }
1121
1745
  });
1122
1746
  }
1123
- function Re(i, r) {
1124
- let o = E(i != null && i.values ? i.values : le.value);
1125
- o = r != null && r.force ? o : Oe(le.value, o), o = X(D) && x(D.cast) ? D.cast(o) : o, B(o, { force: r == null ? void 0 : r.force }), G((d) => {
1126
- var y;
1127
- d.__flags.pendingReset = !0, d.validated = !1, d.touched = ((y = i == null ? void 0 : i.touched) === null || y === void 0 ? void 0 : y[d.path]) || !1, V(d.path, L(o, d.path), !1), g(d.path, void 0);
1128
- }), r != null && r.force ? N(o, !1) : A(o, !1), T((i == null ? void 0 : i.errors) || {}), h.value = (i == null ? void 0 : i.submitCount) || 0, ee(() => {
1129
- ge({ mode: "silent" }), G((d) => {
1130
- d.__flags.pendingReset = !1;
1747
+ function resetForm(resetState, opts2) {
1748
+ let newValues = klona((resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value);
1749
+ newValues = (opts2 === null || opts2 === void 0 ? void 0 : opts2.force) ? newValues : merge(originalInitialValues.value, newValues);
1750
+ newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
1751
+ setInitialValues(newValues, { force: opts2 === null || opts2 === void 0 ? void 0 : opts2.force });
1752
+ mutateAllPathState((state) => {
1753
+ var _a2;
1754
+ state.__flags.pendingReset = true;
1755
+ state.validated = false;
1756
+ state.touched = ((_a2 = resetState === null || resetState === void 0 ? void 0 : resetState.touched) === null || _a2 === void 0 ? void 0 : _a2[state.path]) || false;
1757
+ setFieldValue(state.path, getFromPath(newValues, state.path), false);
1758
+ setFieldError(state.path, void 0);
1759
+ });
1760
+ (opts2 === null || opts2 === void 0 ? void 0 : opts2.force) ? forceSetValues(newValues, false) : setValues(newValues, false);
1761
+ setErrors((resetState === null || resetState === void 0 ? void 0 : resetState.errors) || {});
1762
+ submitCount.value = (resetState === null || resetState === void 0 ? void 0 : resetState.submitCount) || 0;
1763
+ nextTick(() => {
1764
+ validate2({ mode: "silent" });
1765
+ mutateAllPathState((state) => {
1766
+ state.__flags.pendingReset = false;
1131
1767
  });
1132
1768
  });
1133
1769
  }
1134
- async function ge(i) {
1135
- const r = (i == null ? void 0 : i.mode) || "force";
1136
- if (r === "force" && G((m) => m.validated = !0), f.validateSchema)
1137
- return f.validateSchema(r);
1138
- a.value = !0;
1139
- const o = await Promise.all(s.value.map((m) => m.validate ? m.validate(i).then((I) => ({
1140
- key: m.path,
1141
- valid: I.valid,
1142
- errors: I.errors,
1143
- value: I.value
1144
- })) : Promise.resolve({
1145
- key: m.path,
1146
- valid: !0,
1147
- errors: [],
1148
- value: void 0
1149
- })));
1150
- a.value = !1;
1151
- const d = {}, y = {}, p = {};
1152
- for (const m of o)
1153
- d[m.key] = {
1154
- valid: m.valid,
1155
- errors: m.errors
1156
- }, m.value && re(p, m.key, m.value), m.errors.length && (y[m.key] = m.errors[0]);
1770
+ async function validate2(opts2) {
1771
+ const mode = (opts2 === null || opts2 === void 0 ? void 0 : opts2.mode) || "force";
1772
+ if (mode === "force") {
1773
+ mutateAllPathState((f) => f.validated = true);
1774
+ }
1775
+ if (formCtx.validateSchema) {
1776
+ return formCtx.validateSchema(mode);
1777
+ }
1778
+ isValidating.value = true;
1779
+ const validations = await Promise.all(pathStates.value.map((state) => {
1780
+ if (!state.validate) {
1781
+ return Promise.resolve({
1782
+ key: state.path,
1783
+ valid: true,
1784
+ errors: [],
1785
+ value: void 0
1786
+ });
1787
+ }
1788
+ return state.validate(opts2).then((result) => {
1789
+ return {
1790
+ key: state.path,
1791
+ valid: result.valid,
1792
+ errors: result.errors,
1793
+ value: result.value
1794
+ };
1795
+ });
1796
+ }));
1797
+ isValidating.value = false;
1798
+ const results = {};
1799
+ const errors2 = {};
1800
+ const values = {};
1801
+ for (const validation of validations) {
1802
+ results[validation.key] = {
1803
+ valid: validation.valid,
1804
+ errors: validation.errors
1805
+ };
1806
+ if (validation.value) {
1807
+ setInPath(values, validation.key, validation.value);
1808
+ }
1809
+ if (validation.errors.length) {
1810
+ errors2[validation.key] = validation.errors[0];
1811
+ }
1812
+ }
1157
1813
  return {
1158
- valid: o.every((m) => m.valid),
1159
- results: d,
1160
- errors: y,
1161
- values: p,
1814
+ valid: validations.every((r) => r.valid),
1815
+ results,
1816
+ errors: errors2,
1817
+ values,
1162
1818
  source: "fields"
1163
1819
  };
1164
1820
  }
1165
- async function oe(i, r) {
1166
- var o;
1167
- const d = M(i);
1168
- return d && (r == null ? void 0 : r.mode) !== "silent" && (d.validated = !0), d != null && d.validate ? d.validate(r) : (!d && (o = r == null ? void 0 : r.warn), Promise.resolve({ errors: [], valid: !0 }));
1821
+ async function validateField(path, opts2) {
1822
+ var _a2;
1823
+ const state = findPathState(path);
1824
+ if (state && (opts2 === null || opts2 === void 0 ? void 0 : opts2.mode) !== "silent") {
1825
+ state.validated = true;
1826
+ }
1827
+ if (state === null || state === void 0 ? void 0 : state.validate) {
1828
+ return state.validate(opts2);
1829
+ }
1830
+ !state && ((_a2 = opts2 === null || opts2 === void 0 ? void 0 : opts2.warn) !== null && _a2 !== void 0 ? _a2 : true);
1831
+ return Promise.resolve({ errors: [], valid: true });
1169
1832
  }
1170
- function tt(i) {
1171
- ut(Z.value, i);
1833
+ function unsetInitialValue(path) {
1834
+ unsetPath(initialValues.value, path);
1172
1835
  }
1173
- function Pt(i, r, o = !1) {
1174
- Ue(i, r), re(c, i, r), o && re(le.value, i, E(r));
1836
+ function stageInitialValue(path, value, updateOriginal = false) {
1837
+ setFieldInitialValue(path, value);
1838
+ setInPath(formValues, path, value);
1839
+ if (updateOriginal && true) {
1840
+ setInPath(originalInitialValues.value, path, klona(value));
1841
+ }
1175
1842
  }
1176
- function Ue(i, r, o = !1) {
1177
- re(Z.value, i, E(r)), o && re(le.value, i, E(r));
1843
+ function setFieldInitialValue(path, value, updateOriginal = false) {
1844
+ setInPath(initialValues.value, path, klona(value));
1845
+ if (updateOriginal) {
1846
+ setInPath(originalInitialValues.value, path, klona(value));
1847
+ }
1178
1848
  }
1179
- async function nt() {
1180
- const i = w(D);
1181
- if (!i)
1182
- return { valid: !0, results: {}, errors: {}, source: "none" };
1183
- a.value = !0;
1184
- const r = Ie(i) || X(i) ? await cn(i, c) : await dn(i, c, {
1185
- names: Q.value,
1186
- bailsMap: $.value
1849
+ async function _validateSchema() {
1850
+ const schemaValue = unref(schema);
1851
+ if (!schemaValue) {
1852
+ return { valid: true, results: {}, errors: {}, source: "none" };
1853
+ }
1854
+ isValidating.value = true;
1855
+ const formResult = isYupValidator(schemaValue) || isTypedSchema(schemaValue) ? await validateTypedSchema(schemaValue, formValues) : await validateObjectSchema(schemaValue, formValues, {
1856
+ names: fieldNames.value,
1857
+ bailsMap: fieldBailsMap.value
1187
1858
  });
1188
- return a.value = !1, r;
1859
+ isValidating.value = false;
1860
+ return formResult;
1189
1861
  }
1190
- const Ft = ye((i, { evt: r }) => {
1191
- Kt(r) && r.target.submit();
1862
+ const submitForm = handleSubmit((_, { evt }) => {
1863
+ if (isFormSubmitEvent(evt)) {
1864
+ evt.target.submit();
1865
+ }
1192
1866
  });
1193
- ft(() => {
1194
- f.validateSchema && f.validateSchema("silent");
1195
- }), Fe(D) && se(D, () => {
1196
- var i;
1197
- (i = f.validateSchema) === null || i === void 0 || i.call(f, "validated-only");
1198
- }), vt(Xe, f);
1199
- function Be(i, r) {
1200
- const o = x(r) || r == null ? void 0 : r.label, d = M(O(i)) || fe(i, { label: o }), y = () => x(r) ? r(Ee(d, we)) : r || {};
1201
- function p() {
1202
- var P;
1203
- d.touched = !0, ((P = y().validateOnBlur) !== null && P !== void 0 ? P : Ve().validateOnBlur) && oe(d.path);
1204
- }
1205
- function m() {
1206
- var P;
1207
- ((P = y().validateOnInput) !== null && P !== void 0 ? P : Ve().validateOnInput) && ee(() => {
1208
- oe(d.path);
1209
- });
1867
+ onMounted(() => {
1868
+ if (formCtx.validateSchema) {
1869
+ formCtx.validateSchema("silent");
1210
1870
  }
1211
- function I() {
1212
- var P;
1213
- ((P = y().validateOnChange) !== null && P !== void 0 ? P : Ve().validateOnChange) && ee(() => {
1214
- oe(d.path);
1215
- });
1871
+ });
1872
+ if (isRef(schema)) {
1873
+ watch(schema, () => {
1874
+ var _a2;
1875
+ (_a2 = formCtx.validateSchema) === null || _a2 === void 0 ? void 0 : _a2.call(formCtx, "validated-only");
1876
+ });
1877
+ }
1878
+ provide(FormContextKey, formCtx);
1879
+ function defineField(path, config) {
1880
+ const label = isCallable(config) ? void 0 : config === null || config === void 0 ? void 0 : config.label;
1881
+ const pathState = findPathState(toValue(path)) || createPathState(path, { label });
1882
+ const evalConfig = () => isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {};
1883
+ function onBlur() {
1884
+ var _a2;
1885
+ pathState.touched = true;
1886
+ const validateOnBlur = (_a2 = evalConfig().validateOnBlur) !== null && _a2 !== void 0 ? _a2 : getConfig().validateOnBlur;
1887
+ if (validateOnBlur) {
1888
+ validateField(pathState.path);
1889
+ }
1890
+ }
1891
+ function onInput() {
1892
+ var _a2;
1893
+ const validateOnInput = (_a2 = evalConfig().validateOnInput) !== null && _a2 !== void 0 ? _a2 : getConfig().validateOnInput;
1894
+ if (validateOnInput) {
1895
+ nextTick(() => {
1896
+ validateField(pathState.path);
1897
+ });
1898
+ }
1216
1899
  }
1217
- const C = j(() => {
1218
- const P = {
1219
- onChange: I,
1220
- onInput: m,
1221
- onBlur: p
1900
+ function onChange() {
1901
+ var _a2;
1902
+ const validateOnChange = (_a2 = evalConfig().validateOnChange) !== null && _a2 !== void 0 ? _a2 : getConfig().validateOnChange;
1903
+ if (validateOnChange) {
1904
+ nextTick(() => {
1905
+ validateField(pathState.path);
1906
+ });
1907
+ }
1908
+ }
1909
+ const props = computed(() => {
1910
+ const base = {
1911
+ onChange,
1912
+ onInput,
1913
+ onBlur
1222
1914
  };
1223
- return x(r) ? Object.assign(Object.assign({}, P), r(Ee(d, we)).props || {}) : r != null && r.props ? Object.assign(Object.assign({}, P), r.props(Ee(d, we))) : P;
1915
+ if (isCallable(config)) {
1916
+ return Object.assign(Object.assign({}, base), config(omit(pathState, PRIVATE_PATH_STATE_KEYS)).props || {});
1917
+ }
1918
+ if (config === null || config === void 0 ? void 0 : config.props) {
1919
+ return Object.assign(Object.assign({}, base), config.props(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
1920
+ }
1921
+ return base;
1224
1922
  });
1225
- return [te(i, () => {
1226
- var P, R, z;
1227
- return (z = (P = y().validateOnModelUpdate) !== null && P !== void 0 ? P : (R = Ve()) === null || R === void 0 ? void 0 : R.validateOnModelUpdate) !== null && z !== void 0 ? z : !0;
1228
- }), C];
1229
- }
1230
- function It(i) {
1231
- return Array.isArray(i) ? i.map((r) => te(r, !0)) : te(i);
1232
- }
1233
- function Ct(i, r) {
1234
- const [o, d] = Be(i, r);
1235
- function y() {
1236
- d.value.onBlur();
1237
- }
1238
- function p(I) {
1239
- const C = Ce(I);
1240
- V(O(i), C, !1), d.value.onInput();
1241
- }
1242
- function m(I) {
1243
- const C = Ce(I);
1244
- V(O(i), C, !1), d.value.onChange();
1245
- }
1246
- return j(() => Object.assign(Object.assign({}, d.value), {
1247
- onBlur: y,
1248
- onInput: p,
1249
- onChange: m,
1250
- value: o.value
1251
- }));
1923
+ const model = createModel(path, () => {
1924
+ var _a2, _b, _c;
1925
+ return (_c = (_a2 = evalConfig().validateOnModelUpdate) !== null && _a2 !== void 0 ? _a2 : (_b = getConfig()) === null || _b === void 0 ? void 0 : _b.validateOnModelUpdate) !== null && _c !== void 0 ? _c : true;
1926
+ });
1927
+ return [model, props];
1928
+ }
1929
+ function useFieldModel(pathOrPaths) {
1930
+ if (!Array.isArray(pathOrPaths)) {
1931
+ return createModel(pathOrPaths);
1932
+ }
1933
+ return pathOrPaths.map((p) => createModel(p, true));
1252
1934
  }
1253
- function Nt(i, r) {
1254
- const [o, d] = Be(i, r), y = M(O(i));
1255
- function p(m) {
1256
- o.value = m;
1935
+ function defineInputBinds(path, config) {
1936
+ const [model, props] = defineField(path, config);
1937
+ function onBlur() {
1938
+ props.value.onBlur();
1939
+ }
1940
+ function onInput(e) {
1941
+ const value = normalizeEventValue(e);
1942
+ setFieldValue(toValue(path), value, false);
1943
+ props.value.onInput();
1944
+ }
1945
+ function onChange(e) {
1946
+ const value = normalizeEventValue(e);
1947
+ setFieldValue(toValue(path), value, false);
1948
+ props.value.onChange();
1257
1949
  }
1258
- return j(() => {
1259
- const m = x(r) ? r(Ee(y, we)) : r || {};
1260
- return Object.assign({ [m.model || "modelValue"]: o.value, [`onUpdate:${m.model || "modelValue"}`]: p }, d.value);
1950
+ return computed(() => {
1951
+ return Object.assign(Object.assign({}, props.value), {
1952
+ onBlur,
1953
+ onInput,
1954
+ onChange,
1955
+ value: model.value
1956
+ });
1261
1957
  });
1262
1958
  }
1263
- return Object.assign(Object.assign({}, f), { values: Mt(c), handleReset: () => Re(), submitForm: Ft });
1959
+ function defineComponentBinds(path, config) {
1960
+ const [model, props] = defineField(path, config);
1961
+ const pathState = findPathState(toValue(path));
1962
+ function onUpdateModelValue(value) {
1963
+ model.value = value;
1964
+ }
1965
+ return computed(() => {
1966
+ const conf = isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {};
1967
+ return Object.assign({ [conf.model || "modelValue"]: model.value, [`onUpdate:${conf.model || "modelValue"}`]: onUpdateModelValue }, props.value);
1968
+ });
1969
+ }
1970
+ return Object.assign(Object.assign({}, formCtx), { values: readonly(formValues), handleReset: () => resetForm(), submitForm });
1264
1971
  }
1265
- function On(e, t, n, l) {
1266
- const u = {
1972
+ function useFormMeta(pathsState, currentValues, initialValues, errors) {
1973
+ const MERGE_STRATEGIES = {
1267
1974
  touched: "some",
1268
1975
  pending: "some",
1269
1976
  valid: "every"
1270
- }, a = j(() => !U(t, w(n)));
1271
- function h() {
1272
- const c = e.value;
1273
- return q(u).reduce((s, S) => {
1274
- const b = u[S];
1275
- return s[S] = c[b]((F) => F[S]), s;
1977
+ };
1978
+ const isDirty = computed(() => {
1979
+ return !isEqual(currentValues, unref(initialValues));
1980
+ });
1981
+ function calculateFlags() {
1982
+ const states = pathsState.value;
1983
+ return keysOf(MERGE_STRATEGIES).reduce((acc, flag) => {
1984
+ const mergeMethod = MERGE_STRATEGIES[flag];
1985
+ acc[flag] = states[mergeMethod]((s) => s[flag]);
1986
+ return acc;
1276
1987
  }, {});
1277
1988
  }
1278
- const v = Pe(h());
1279
- return kt(() => {
1280
- const c = h();
1281
- v.touched = c.touched, v.valid = c.valid, v.pending = c.pending;
1282
- }), j(() => Object.assign(Object.assign({ initialValues: w(n) }, v), { valid: v.valid && !q(l.value).length, dirty: a.value }));
1283
- }
1284
- function _n(e, t, n) {
1285
- const l = jt(), u = Y(l), a = Y(E(l));
1286
- function h(v, c) {
1287
- c != null && c.force ? (u.value = E(v), a.value = E(v)) : (u.value = Oe(E(u.value) || {}, E(v)), a.value = Oe(E(a.value) || {}, E(v))), c != null && c.updateFields && e.value.forEach((s) => {
1288
- if (s.touched)
1989
+ const flags = reactive(calculateFlags());
1990
+ watchEffect(() => {
1991
+ const value = calculateFlags();
1992
+ flags.touched = value.touched;
1993
+ flags.valid = value.valid;
1994
+ flags.pending = value.pending;
1995
+ });
1996
+ return computed(() => {
1997
+ return Object.assign(Object.assign({ initialValues: unref(initialValues) }, flags), { valid: flags.valid && !keysOf(errors.value).length, dirty: isDirty.value });
1998
+ });
1999
+ }
2000
+ function useFormInitialValues(pathsState, formValues, opts) {
2001
+ const values = resolveInitialValues();
2002
+ const initialValues = ref(values);
2003
+ const originalInitialValues = ref(klona(values));
2004
+ function setInitialValues(values2, opts2) {
2005
+ if (opts2 === null || opts2 === void 0 ? void 0 : opts2.force) {
2006
+ initialValues.value = klona(values2);
2007
+ originalInitialValues.value = klona(values2);
2008
+ } else {
2009
+ initialValues.value = merge(klona(initialValues.value) || {}, klona(values2));
2010
+ originalInitialValues.value = merge(klona(originalInitialValues.value) || {}, klona(values2));
2011
+ }
2012
+ if (!(opts2 === null || opts2 === void 0 ? void 0 : opts2.updateFields)) {
2013
+ return;
2014
+ }
2015
+ pathsState.value.forEach((state) => {
2016
+ const wasTouched = state.touched;
2017
+ if (wasTouched) {
1289
2018
  return;
1290
- const b = L(u.value, s.path);
1291
- re(t, s.path, E(b));
2019
+ }
2020
+ const newValue = getFromPath(initialValues.value, state.path);
2021
+ setInPath(formValues, state.path, klona(newValue));
1292
2022
  });
1293
2023
  }
1294
2024
  return {
1295
- initialValues: u,
1296
- originalInitialValues: a,
1297
- setInitialValues: h
2025
+ initialValues,
2026
+ originalInitialValues,
2027
+ setInitialValues
1298
2028
  };
1299
2029
  }
1300
- function Sn(e, t) {
1301
- return t ? {
1302
- valid: e.valid && t.valid,
1303
- errors: [...e.errors, ...t.errors]
1304
- } : e;
2030
+ function mergeValidationResults(a, b) {
2031
+ if (!b) {
2032
+ return a;
2033
+ }
2034
+ return {
2035
+ valid: a.valid && b.valid,
2036
+ errors: [...a.errors, ...b.errors]
2037
+ };
1305
2038
  }
1306
2039
  export {
1307
- En as a,
1308
- jn as u
2040
+ useForm as a,
2041
+ useField as u
1309
2042
  };