@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.
- package/animation/index.es.js +54 -37
- package/assets/lottiejs/loading-page.es.js +14 -9
- package/assets/lottiejs/loading-plane.es.js +2 -2
- package/assets/lottiejs/loading-table.es.js +14 -9
- package/assets/lottiejs/no-data.es.js +14 -9
- package/backgroundimagecropper/index.es.js +61 -37
- package/badge/index.es.js +77 -67
- package/badgegroup/index.es.js +62 -50
- package/basecalendar/index.es.js +1258 -735
- package/basetree/index.es.js +213 -113
- package/breadcrumb/index.es.js +46 -38
- package/button/index.es.js +60 -54
- package/buttonbulkaction/index.es.js +168 -117
- package/buttoncopy/index.es.js +25 -22
- package/buttondownload/index.es.js +125 -76
- package/buttonfilter/index.es.js +21 -15
- package/buttonradio/index.es.js +91 -67
- package/buttonsearch/index.es.js +62 -46
- package/buttonselecttree/index.es.js +233 -172
- package/buttontoggle/index.es.js +8 -6
- package/calendar/index.es.js +113 -58
- package/card/index.es.js +44 -42
- package/checkbox/index.es.js +105 -74
- package/codesnippet/index.es.js +91 -71
- package/codesnippetadapter/index.es.js +25 -21
- package/columnlist/index.es.js +249 -171
- package/components.d.ts +0 -21
- package/config/defaultProps.es.js +9 -9
- package/config/index.es.js +11 -10
- package/config/locale.es.js +2 -2
- package/customcolumn/index.es.js +95 -78
- package/datatable/index.es.js +1071 -732
- package/dialog/index.es.js +54 -54
- package/dialogconfirm/index.es.js +90 -75
- package/dialogform/index.es.js +170 -133
- package/dialogselecttree/index.es.js +242 -194
- package/directives/focus.es.js +13 -8
- package/dropdown/index.es.js +250 -196
- package/editor/index.es.js +694 -498
- package/editorbutton/index.es.js +21 -19
- package/event-bus/index.es.js +3 -3
- package/event-bus/mitt.es.js +37 -20
- package/fieldwrapper/index.es.js +30 -25
- package/fileupload/index.es.js +230 -140
- package/filtercontainer/index.es.js +299 -222
- package/form/index.es.js +176 -126
- package/gallerypreview/index.es.js +138 -101
- package/icon/index.es.js +38 -36
- package/image/index.es.js +161 -108
- package/imagecompressor/index.es.js +616 -449
- package/imageinputinfo/index.es.js +26 -22
- package/inlinemessage/index.es.js +77 -65
- package/inputbadge/index.es.js +230 -156
- package/inputcurrency/index.es.js +146 -109
- package/inputemail/index.es.js +18 -16
- package/inputgroup/index.es.js +19 -16
- package/inputnumber/index.es.js +252 -182
- package/inputpassword/index.es.js +120 -94
- package/inputphonenumber/index.es.js +1017 -550
- package/inputrangenumber/index.es.js +129 -98
- package/inputtext/index.es.js +264 -189
- package/inputurl/index.es.js +31 -29
- package/invisiblefield/index.es.js +24 -16
- package/litedropdown/index.es.js +87 -81
- package/loading/index.es.js +21 -19
- package/loading-page-BXZ4fLOS.js +8 -0
- package/loading-page-BuLpsb_1.js +8 -0
- package/loading-page-CNqVBg__.js +4 -0
- package/loading-page-DbhhZih2.js +4 -0
- package/loading-page-DjfWXoOy.js +8 -0
- package/loading-page-S-KRY5zm.js +4 -0
- package/loading-plane-C1mi7Whv.js +4 -0
- package/loading-plane-CWq1hz_l.js +8 -0
- package/loading-table-B7LAXzAp.js +4 -0
- package/loading-table-BLmgKUsR.js +4 -0
- package/loading-table-CG7-cuhv.js +8 -0
- package/loading-table-CUPS49ta.js +4 -0
- package/loading-table-CuWWrTbv.js +8 -0
- package/loading-table-DbBzVwaZ.js +8 -0
- package/mentionlist/index.es.js +77 -44
- package/mentionsection/index.es.js +53 -43
- package/menu/index.es.js +65 -51
- package/menuitem/index.es.js +39 -37
- package/multirow/index.es.js +29 -28
- package/multiselect/index.es.js +184 -152
- package/no-data-B781skt3.js +4 -0
- package/no-data-CAksOnDl.js +4 -0
- package/no-data-DCsjBXQR.js +4 -0
- package/no-data-Dz0QOe7Q.js +8 -0
- package/no-data-_Huxiv9q.js +8 -0
- package/no-data-ybRQontJ.js +8 -0
- package/overlaypanel/index.es.js +49 -36
- package/package.json +1 -1
- package/paginator/index.es.js +36 -33
- package/plugins/WangsVue.es.js +63 -45
- package/plugins/formValidation.es.js +15 -11
- package/progressbar/index.es.js +39 -32
- package/quickfilter/index.es.js +94 -81
- package/stats.html +1 -1
- package/style.css +1 -1
- package/tabmenu/index.es.js +18 -16
- package/textarea/index.es.js +94 -72
- package/timeline/index.es.js +124 -102
- package/timelinecontentbytype/index.es.js +114 -92
- package/toast/index.es.js +67 -54
- package/toggleswitch/index.es.js +83 -66
- package/tree/index.es.js +306 -198
- package/treenode/index.es.js +464 -339
- package/treesearchinput/index.es.js +32 -26
- package/usergroup/index.es.js +83 -67
- package/username/index.es.js +99 -85
- package/utils/addAttachment.util.es.js +47 -21
- package/utils/baseToast.util.es.js +41 -33
- package/utils/convertJsonImage.util.es.js +24 -24
- package/utils/date.util.es.js +131 -106
- package/utils/exportToExcel.util.es.js +81 -47
- package/utils/filterOptions.util.es.js +8 -2
- package/utils/genPlaceholder.util.es.js +30 -16
- package/utils/getProjectPermission.util.es.js +15 -12
- package/utils/getSalesRole.util.es.js +4 -4
- package/utils/getUser.util.es.js +2 -2
- package/utils/getUserType.util.es.js +13 -8
- package/utils/isIntersect.es.js +4 -2
- package/utils/mergePropsWithDefaults.util.es.js +7 -6
- package/utils/object.util.es.js +88 -54
- package/utils/queryParamsStringfy.util.es.js +19 -11
- package/utils/role.util.es.js +5 -4
- package/utils/statusSeverity.util.es.js +20 -5
- package/utils/textFormatter.util.es.js +28 -50
- package/utils/toast.util.es.js +8 -5
- package/utils/xlsx.util.es.js +12 -6
- package/validatormessage/index.es.js +9 -9
- package/vendor/@popperjs/core/lib/createPopper.es.js +110 -83
- package/vendor/@popperjs/core/lib/dom-utils/contains.es.js +14 -13
- package/vendor/@popperjs/core/lib/dom-utils/getBoundingClientRect.es.js +33 -18
- package/vendor/@popperjs/core/lib/dom-utils/getClippingRect.es.js +55 -31
- package/vendor/@popperjs/core/lib/dom-utils/getCompositeRect.es.js +43 -22
- package/vendor/@popperjs/core/lib/dom-utils/getComputedStyle.es.js +4 -4
- package/vendor/@popperjs/core/lib/dom-utils/getDocumentElement.es.js +5 -5
- package/vendor/@popperjs/core/lib/dom-utils/getDocumentRect.es.js +23 -13
- package/vendor/@popperjs/core/lib/dom-utils/getHTMLElementScroll.es.js +4 -4
- package/vendor/@popperjs/core/lib/dom-utils/getLayoutRect.es.js +17 -9
- package/vendor/@popperjs/core/lib/dom-utils/getNodeName.es.js +3 -3
- package/vendor/@popperjs/core/lib/dom-utils/getNodeScroll.es.js +11 -7
- package/vendor/@popperjs/core/lib/dom-utils/getOffsetParent.es.js +42 -26
- package/vendor/@popperjs/core/lib/dom-utils/getParentNode.es.js +13 -10
- package/vendor/@popperjs/core/lib/dom-utils/getScrollParent.es.js +13 -7
- package/vendor/@popperjs/core/lib/dom-utils/getViewportRect.es.js +25 -15
- package/vendor/@popperjs/core/lib/dom-utils/getWindow.es.js +8 -7
- package/vendor/@popperjs/core/lib/dom-utils/getWindowScroll.es.js +8 -6
- package/vendor/@popperjs/core/lib/dom-utils/getWindowScrollBarX.es.js +6 -6
- package/vendor/@popperjs/core/lib/dom-utils/instanceOf.es.js +16 -15
- package/vendor/@popperjs/core/lib/dom-utils/isLayoutViewport.es.js +4 -4
- package/vendor/@popperjs/core/lib/dom-utils/isScrollParent.es.js +5 -5
- package/vendor/@popperjs/core/lib/dom-utils/isTableElement.es.js +4 -4
- package/vendor/@popperjs/core/lib/dom-utils/listScrollParents.es.js +17 -11
- package/vendor/@popperjs/core/lib/enums.es.js +43 -20
- package/vendor/@popperjs/core/lib/modifiers/applyStyles.es.js +49 -25
- package/vendor/@popperjs/core/lib/modifiers/arrow.es.js +61 -26
- package/vendor/@popperjs/core/lib/modifiers/computeStyles.es.js +101 -69
- package/vendor/@popperjs/core/lib/modifiers/eventListeners.es.js +30 -16
- package/vendor/@popperjs/core/lib/modifiers/flip.es.js +99 -60
- package/vendor/@popperjs/core/lib/modifiers/hide.es.js +44 -31
- package/vendor/@popperjs/core/lib/modifiers/offset.es.js +32 -20
- package/vendor/@popperjs/core/lib/modifiers/popperOffsets.es.js +11 -11
- package/vendor/@popperjs/core/lib/modifiers/preventOverflow.es.js +91 -40
- package/vendor/@popperjs/core/lib/popper.es.js +14 -13
- package/vendor/@popperjs/core/lib/utils/computeAutoPlacement.es.js +29 -21
- package/vendor/@popperjs/core/lib/utils/computeOffsets.es.js +41 -36
- package/vendor/@popperjs/core/lib/utils/debounce.es.js +11 -7
- package/vendor/@popperjs/core/lib/utils/detectOverflow.es.js +42 -28
- package/vendor/@popperjs/core/lib/utils/expandToHashMap.es.js +5 -4
- package/vendor/@popperjs/core/lib/utils/getAltAxis.es.js +3 -3
- package/vendor/@popperjs/core/lib/utils/getBasePlacement.es.js +3 -3
- package/vendor/@popperjs/core/lib/utils/getFreshSideObject.es.js +2 -2
- package/vendor/@popperjs/core/lib/utils/getMainAxisFromPlacement.es.js +3 -3
- package/vendor/@popperjs/core/lib/utils/getOppositePlacement.es.js +5 -5
- package/vendor/@popperjs/core/lib/utils/getOppositeVariationPlacement.es.js +5 -5
- package/vendor/@popperjs/core/lib/utils/getVariation.es.js +3 -3
- package/vendor/@popperjs/core/lib/utils/math.es.js +6 -4
- package/vendor/@popperjs/core/lib/utils/mergeByName.es.js +11 -10
- package/vendor/@popperjs/core/lib/utils/mergePaddingObject.es.js +4 -4
- package/vendor/@popperjs/core/lib/utils/orderModifiers.es.js +30 -22
- package/vendor/@popperjs/core/lib/utils/rectToClientRect.es.js +7 -7
- package/vendor/@popperjs/core/lib/utils/userAgent.es.js +9 -6
- package/vendor/@popperjs/core/lib/utils/within.es.js +8 -8
- package/vendor/@tiptap/core/dist/index.es.js +3494 -2000
- package/vendor/@tiptap/extension-bold/dist/index.es.js +29 -19
- package/vendor/@tiptap/extension-bubble-menu/dist/index.es.js +145 -71
- package/vendor/@tiptap/extension-bullet-list/dist/index.es.js +32 -19
- package/vendor/@tiptap/extension-code/dist/index.es.js +22 -14
- package/vendor/@tiptap/extension-document/dist/index.es.js +4 -4
- package/vendor/@tiptap/extension-floating-menu/dist/index.es.js +106 -51
- package/vendor/@tiptap/extension-heading/dist/index.es.js +38 -22
- package/vendor/@tiptap/extension-history/dist/index.es.js +11 -7
- package/vendor/@tiptap/extension-image/dist/index.es.js +20 -17
- package/vendor/@tiptap/extension-italic/dist/index.es.js +28 -18
- package/vendor/@tiptap/extension-link/dist/index.es.js +236 -147
- package/vendor/@tiptap/extension-list-item/dist/index.es.js +6 -6
- package/vendor/@tiptap/extension-mention/dist/index.es.js +98 -63
- package/vendor/@tiptap/extension-ordered-list/dist/index.es.js +38 -25
- package/vendor/@tiptap/extension-paragraph/dist/index.es.js +8 -6
- package/vendor/@tiptap/extension-placeholder/dist/index.es.js +34 -27
- package/vendor/@tiptap/extension-text/dist/index.es.js +3 -3
- package/vendor/@tiptap/extension-underline/dist/index.es.js +16 -10
- package/vendor/@tiptap/suggestion/dist/index.es.js +174 -90
- package/vendor/@tiptap/vue-3/dist/index.es.js +287 -188
- package/vendor/@wangs-ui/core/components/p-BU8h34na.es.js +17 -14
- package/vendor/@wangs-ui/core/components/p-C5lMEBcj.es.js +69 -55
- package/vendor/@wangs-ui/core/components/p-CKYwZoTo.es.js +26 -22
- package/vendor/@wangs-ui/core/components/p-CsoK-EWG.es.js +147 -102
- package/vendor/@wangs-ui/core/components/p-DPHEi31J.es.js +102 -77
- package/vendor/@wangs-ui/core/components/p-DTTCzifR.es.js +1298 -551
- package/vendor/@wangs-ui/core/components/p-Duri5p90.es.js +60 -49
- package/vendor/@wangs-ui/core/components/wangs-button.es.js +19 -15
- package/vendor/@wangs-ui/core/components/wangs-icon.es.js +3 -3
- package/vendor/@wangs-ui/core/components/wangs-input-otp.es.js +3 -3
- package/vendor/@wangs-ui/core/components/wangs-tab-menu.es.js +3 -3
- package/vendor/@wangs-ui/core/dist/esm/index-DCkh3cGv.es.js +116 -102
- package/vendor/@wangs-ui/vue/dist/index.es.js +77 -77
- package/vendor/base64toblob/base64toblob.es.js +31 -15
- package/vendor/highlight.js/es/core.es.js +5 -5
- package/vendor/highlight.js/es/languages/javascript.es.js +237 -193
- package/vendor/highlight.js/es/languages/json.es.js +18 -15
- package/vendor/highlight.js/es/languages/typescript.es.js +288 -228
- package/vendor/highlight.js/es/languages/vbscript-html.es.js +2 -2
- package/vendor/highlight.js/lib/core.es.js +1144 -666
- package/vendor/linkifyjs/dist/linkify.es.es.js +858 -405
- package/vendor/lodash/_Symbol.es.js +11 -8
- package/vendor/lodash/_baseGetTag.es.js +19 -12
- package/vendor/lodash/_baseTrim.es.js +13 -10
- package/vendor/lodash/_freeGlobal.es.js +10 -8
- package/vendor/lodash/_getRawTag.es.js +28 -15
- package/vendor/lodash/_objectToString.es.js +12 -9
- package/vendor/lodash/_root.es.js +12 -8
- package/vendor/lodash/_trimmedEndIndex.es.js +14 -11
- package/vendor/lodash/debounce.es.js +92 -54
- package/vendor/lodash/isObject.es.js +11 -9
- package/vendor/lodash/isObjectLike.es.js +10 -8
- package/vendor/lodash/isSymbol.es.js +14 -11
- package/vendor/lodash/now.es.js +12 -9
- package/vendor/lodash/throttle.es.js +25 -17
- package/vendor/lodash/toNumber.es.js +33 -23
- package/vendor/lodash-es/_DataView.es.js +4 -4
- package/vendor/lodash-es/_Hash.es.js +17 -16
- package/vendor/lodash-es/_ListCache.es.js +17 -16
- package/vendor/lodash-es/_Map.es.js +4 -4
- package/vendor/lodash-es/_MapCache.es.js +17 -16
- package/vendor/lodash-es/_Promise.es.js +4 -4
- package/vendor/lodash-es/_Set.es.js +4 -4
- package/vendor/lodash-es/_SetCache.es.js +12 -10
- package/vendor/lodash-es/_Stack.es.js +15 -15
- package/vendor/lodash-es/_Symbol.es.js +3 -3
- package/vendor/lodash-es/_Uint8Array.es.js +3 -3
- package/vendor/lodash-es/_WeakMap.es.js +4 -4
- package/vendor/lodash-es/_arrayEach.es.js +9 -5
- package/vendor/lodash-es/_arrayFilter.es.js +9 -6
- package/vendor/lodash-es/_arrayLikeKeys.es.js +21 -17
- package/vendor/lodash-es/_arrayPush.es.js +7 -5
- package/vendor/lodash-es/_arraySome.es.js +9 -6
- package/vendor/lodash-es/_assignValue.es.js +10 -7
- package/vendor/lodash-es/_assocIndexOf.es.js +9 -6
- package/vendor/lodash-es/_baseAssignValue.es.js +13 -9
- package/vendor/lodash-es/_baseClone.es.js +67 -49
- package/vendor/lodash-es/_baseCreate.es.js +15 -11
- package/vendor/lodash-es/_baseGetAllKeys.es.js +6 -6
- package/vendor/lodash-es/_baseGetTag.es.js +11 -7
- package/vendor/lodash-es/_baseIsArguments.es.js +6 -6
- package/vendor/lodash-es/_baseIsEqual.es.js +11 -5
- package/vendor/lodash-es/_baseIsEqualDeep.es.js +39 -26
- package/vendor/lodash-es/_baseIsMap.es.js +6 -6
- package/vendor/lodash-es/_baseIsNative.es.js +18 -12
- package/vendor/lodash-es/_baseIsSet.es.js +6 -6
- package/vendor/lodash-es/_baseIsTypedArray.es.js +11 -9
- package/vendor/lodash-es/_baseKeys.es.js +16 -11
- package/vendor/lodash-es/_baseTimes.es.js +7 -5
- package/vendor/lodash-es/_baseTrim.es.js +5 -5
- package/vendor/lodash-es/_baseUnary.es.js +4 -4
- package/vendor/lodash-es/_cacheHas.es.js +3 -3
- package/vendor/lodash-es/_cloneArrayBuffer.es.js +6 -5
- package/vendor/lodash-es/_cloneBuffer.es.js +11 -6
- package/vendor/lodash-es/_cloneDataView.es.js +5 -5
- package/vendor/lodash-es/_cloneRegExp.es.js +6 -5
- package/vendor/lodash-es/_cloneSymbol.es.js +5 -5
- package/vendor/lodash-es/_cloneTypedArray.es.js +5 -5
- package/vendor/lodash-es/_coreJsData.es.js +3 -3
- package/vendor/lodash-es/_defineProperty.es.js +7 -6
- package/vendor/lodash-es/_equalArrays.es.js +38 -28
- package/vendor/lodash-es/_equalByTag.es.js +55 -41
- package/vendor/lodash-es/_equalObjects.es.js +42 -28
- package/vendor/lodash-es/_freeGlobal.es.js +2 -2
- package/vendor/lodash-es/_getAllKeys.es.js +6 -6
- package/vendor/lodash-es/_getMapData.es.js +5 -5
- package/vendor/lodash-es/_getNative.es.js +6 -6
- package/vendor/lodash-es/_getPrototype.es.js +3 -3
- package/vendor/lodash-es/_getRawTag.es.js +20 -10
- package/vendor/lodash-es/_getSymbols.es.js +15 -8
- package/vendor/lodash-es/_getTag.es.js +31 -25
- package/vendor/lodash-es/_getValue.es.js +3 -3
- package/vendor/lodash-es/_hashClear.es.js +5 -4
- package/vendor/lodash-es/_hashDelete.es.js +5 -4
- package/vendor/lodash-es/_hashGet.es.js +11 -9
- package/vendor/lodash-es/_hashHas.es.js +7 -6
- package/vendor/lodash-es/_hashSet.es.js +8 -6
- package/vendor/lodash-es/_initCloneArray.es.js +10 -5
- package/vendor/lodash-es/_initCloneByTag.es.js +39 -38
- package/vendor/lodash-es/_initCloneObject.es.js +6 -6
- package/vendor/lodash-es/_isIndex.es.js +7 -5
- package/vendor/lodash-es/_isKeyable.es.js +4 -4
- package/vendor/lodash-es/_isMasked.es.js +7 -7
- package/vendor/lodash-es/_isPrototype.es.js +5 -5
- package/vendor/lodash-es/_listCacheClear.es.js +4 -3
- package/vendor/lodash-es/_listCacheDelete.es.js +17 -9
- package/vendor/lodash-es/_listCacheGet.es.js +5 -5
- package/vendor/lodash-es/_listCacheHas.es.js +4 -4
- package/vendor/lodash-es/_listCacheSet.es.js +11 -5
- package/vendor/lodash-es/_mapCacheClear.es.js +10 -9
- package/vendor/lodash-es/_mapCacheDelete.es.js +6 -5
- package/vendor/lodash-es/_mapCacheGet.es.js +4 -4
- package/vendor/lodash-es/_mapCacheHas.es.js +4 -4
- package/vendor/lodash-es/_mapCacheSet.es.js +7 -5
- package/vendor/lodash-es/_mapToArray.es.js +7 -6
- package/vendor/lodash-es/_nativeCreate.es.js +3 -3
- package/vendor/lodash-es/_nativeKeys.es.js +3 -3
- package/vendor/lodash-es/_nodeUtil.es.js +13 -6
- package/vendor/lodash-es/_objectToString.es.js +5 -4
- package/vendor/lodash-es/_overArg.es.js +4 -4
- package/vendor/lodash-es/_root.es.js +4 -3
- package/vendor/lodash-es/_setCacheAdd.es.js +5 -4
- package/vendor/lodash-es/_setCacheHas.es.js +3 -3
- package/vendor/lodash-es/_setToArray.es.js +7 -6
- package/vendor/lodash-es/_stackClear.es.js +5 -4
- package/vendor/lodash-es/_stackDelete.es.js +5 -4
- package/vendor/lodash-es/_stackGet.es.js +3 -3
- package/vendor/lodash-es/_stackHas.es.js +3 -3
- package/vendor/lodash-es/_stackSet.es.js +18 -13
- package/vendor/lodash-es/_toSource.es.js +9 -8
- package/vendor/lodash-es/_trimmedEndIndex.es.js +7 -6
- package/vendor/lodash-es/cloneDeep.es.js +5 -5
- package/vendor/lodash-es/debounce.es.js +84 -49
- package/vendor/lodash-es/eq.es.js +3 -3
- package/vendor/lodash-es/isArguments.es.js +9 -6
- package/vendor/lodash-es/isArray.es.js +2 -2
- package/vendor/lodash-es/isArrayLike.es.js +5 -5
- package/vendor/lodash-es/isBuffer.es.js +9 -4
- package/vendor/lodash-es/isEqual.es.js +4 -4
- package/vendor/lodash-es/isFunction.es.js +10 -9
- package/vendor/lodash-es/isLength.es.js +4 -4
- package/vendor/lodash-es/isMap.es.js +6 -5
- package/vendor/lodash-es/isObject.es.js +4 -4
- package/vendor/lodash-es/isObjectLike.es.js +3 -3
- package/vendor/lodash-es/isSet.es.js +6 -5
- package/vendor/lodash-es/isSymbol.es.js +6 -6
- package/vendor/lodash-es/isTypedArray.es.js +6 -5
- package/vendor/lodash-es/keys.es.js +6 -6
- package/vendor/lodash-es/now.es.js +4 -4
- package/vendor/lodash-es/stubArray.es.js +2 -2
- package/vendor/lodash-es/stubFalse.es.js +3 -3
- package/vendor/lodash-es/toNumber.es.js +25 -18
- package/vendor/lodash-es/toString.es.js +2 -2
- package/vendor/lodash-es/uniqueId.es.js +6 -6
- package/vendor/orderedmap/dist/index.es.js +65 -49
- package/vendor/primevue/api/api.esm.es.js +214 -121
- package/vendor/primevue/avatar/avatar.esm.es.js +44 -41
- package/vendor/primevue/avatar/style/avatarstyle.esm.es.js +12 -11
- package/vendor/primevue/avatargroup/avatargroup.esm.es.js +17 -16
- package/vendor/primevue/avatargroup/style/avatargroupstyle.esm.es.js +6 -5
- package/vendor/primevue/badge/badge.esm.es.js +21 -20
- package/vendor/primevue/badge/style/badgestyle.esm.es.js +19 -18
- package/vendor/primevue/base/style/basestyle.esm.es.js +88 -99
- package/vendor/primevue/basecomponent/basecomponent.esm.es.js +327 -261
- package/vendor/primevue/basedirective/basedirective.esm.es.js +257 -186
- package/vendor/primevue/baseicon/baseicon.esm.es.js +55 -49
- package/vendor/primevue/baseicon/style/baseiconstyle.esm.es.js +5 -35
- package/vendor/primevue/button/button.esm.es.js +76 -72
- package/vendor/primevue/button/style/buttonstyle.esm.es.js +46 -39
- package/vendor/primevue/card/card.esm.es.js +30 -29
- package/vendor/primevue/card/style/cardstyle.esm.es.js +6 -5
- package/vendor/primevue/checkbox/checkbox.esm.es.js +109 -101
- package/vendor/primevue/checkbox/style/checkboxstyle.esm.es.js +12 -11
- package/vendor/primevue/config/config.esm.es.js +76 -58
- package/vendor/primevue/dialog/dialog.esm.es.js +421 -281
- package/vendor/primevue/dialog/style/dialogstyle.esm.es.js +26 -22
- package/vendor/primevue/dropdown/dropdown.esm.es.js +956 -742
- package/vendor/primevue/dropdown/style/dropdownstyle.esm.es.js +33 -31
- package/vendor/primevue/fileupload/fileupload.esm.es.js +559 -450
- package/vendor/primevue/fileupload/style/fileuploadstyle.esm.es.js +14 -13
- package/vendor/primevue/focustrap/focustrap.esm.es.js +128 -90
- package/vendor/primevue/focustrap/style/focustrapstyle.esm.es.js +2 -2
- package/vendor/primevue/icons/angledoubleleft/index.esm.es.js +13 -11
- package/vendor/primevue/icons/angledoubleright/index.esm.es.js +13 -11
- package/vendor/primevue/icons/angledown/index.esm.es.js +13 -11
- package/vendor/primevue/icons/angleleft/index.esm.es.js +13 -11
- package/vendor/primevue/icons/angleright/index.esm.es.js +13 -11
- package/vendor/primevue/icons/angleup/index.esm.es.js +13 -11
- package/vendor/primevue/icons/blank/index.esm.es.js +13 -11
- package/vendor/primevue/icons/check/index.esm.es.js +13 -11
- package/vendor/primevue/icons/chevrondown/index.esm.es.js +13 -11
- package/vendor/primevue/icons/exclamationtriangle/index.esm.es.js +17 -13
- package/vendor/primevue/icons/eye/index.esm.es.js +13 -11
- package/vendor/primevue/icons/eyeslash/index.esm.es.js +13 -11
- package/vendor/primevue/icons/infocircle/index.esm.es.js +13 -11
- package/vendor/primevue/icons/plus/index.esm.es.js +13 -11
- package/vendor/primevue/icons/refresh/index.esm.es.js +13 -11
- package/vendor/primevue/icons/search/index.esm.es.js +13 -11
- package/vendor/primevue/icons/searchminus/index.esm.es.js +13 -11
- package/vendor/primevue/icons/searchplus/index.esm.es.js +13 -11
- package/vendor/primevue/icons/spinner/index.esm.es.js +13 -11
- package/vendor/primevue/icons/times/index.esm.es.js +13 -11
- package/vendor/primevue/icons/timescircle/index.esm.es.js +13 -11
- package/vendor/primevue/icons/undo/index.esm.es.js +13 -11
- package/vendor/primevue/icons/upload/index.esm.es.js +13 -11
- package/vendor/primevue/icons/windowmaximize/index.esm.es.js +13 -11
- package/vendor/primevue/icons/windowminimize/index.esm.es.js +13 -11
- package/vendor/primevue/image/image.esm.es.js +280 -235
- package/vendor/primevue/image/style/imagestyle.esm.es.js +18 -17
- package/vendor/primevue/inputgroup/inputgroup.esm.es.js +17 -16
- package/vendor/primevue/inputgroup/style/inputgroupstyle.esm.es.js +6 -5
- package/vendor/primevue/inputgroupaddon/inputgroupaddon.esm.es.js +17 -16
- package/vendor/primevue/inputgroupaddon/style/inputgroupaddonstyle.esm.es.js +6 -5
- package/vendor/primevue/inputnumber/inputnumber.esm.es.js +834 -566
- package/vendor/primevue/inputnumber/style/inputnumberstyle.esm.es.js +23 -22
- package/vendor/primevue/inputtext/inputtext.esm.es.js +32 -30
- package/vendor/primevue/inputtext/style/inputtextstyle.esm.es.js +13 -12
- package/vendor/primevue/menu/menu.esm.es.js +402 -304
- package/vendor/primevue/menu/style/menustyle.esm.es.js +14 -13
- package/vendor/primevue/message/message.esm.es.js +126 -112
- package/vendor/primevue/message/style/messagestyle.esm.es.js +9 -8
- package/vendor/primevue/multiselect/multiselect.esm.es.js +1083 -835
- package/vendor/primevue/multiselect/style/multiselectstyle.esm.es.js +38 -36
- package/vendor/primevue/overlayeventbus/overlayeventbus.esm.es.js +3 -3
- package/vendor/primevue/overlaypanel/overlaypanel.esm.es.js +275 -169
- package/vendor/primevue/overlaypanel/style/overlaypanelstyle.esm.es.js +9 -8
- package/vendor/primevue/paginator/paginator.esm.es.js +513 -469
- package/vendor/primevue/paginator/style/paginatorstyle.esm.es.js +50 -43
- package/vendor/primevue/password/password.esm.es.js +306 -233
- package/vendor/primevue/password/style/passwordstyle.esm.es.js +26 -24
- package/vendor/primevue/portal/portal.esm.es.js +17 -17
- package/vendor/primevue/progressbar/progressbar.esm.es.js +37 -35
- package/vendor/primevue/progressbar/style/progressbarstyle.esm.es.js +10 -9
- package/vendor/primevue/ripple/ripple.esm.es.js +90 -62
- package/vendor/primevue/ripple/style/ripplestyle.esm.es.js +6 -5
- package/vendor/primevue/selectbutton/selectbutton.esm.es.js +213 -167
- package/vendor/primevue/selectbutton/style/selectbuttonstyle.esm.es.js +14 -13
- package/vendor/primevue/skeleton/skeleton.esm.es.js +28 -26
- package/vendor/primevue/skeleton/style/skeletonstyle.esm.es.js +13 -11
- package/vendor/primevue/textarea/style/textareastyle.esm.es.js +12 -11
- package/vendor/primevue/textarea/textarea.esm.es.js +49 -33
- package/vendor/primevue/timeline/style/timelinestyle.esm.es.js +9 -8
- package/vendor/primevue/timeline/timeline.esm.es.js +53 -52
- package/vendor/primevue/toast/style/toaststyle.esm.es.js +54 -46
- package/vendor/primevue/toast/toast.esm.es.js +309 -260
- package/vendor/primevue/toasteventbus/toasteventbus.esm.es.js +3 -3
- package/vendor/primevue/toastservice/toastservice.esm.es.js +16 -15
- package/vendor/primevue/tooltip/style/tooltipstyle.esm.es.js +6 -5
- package/vendor/primevue/tooltip/tooltip.esm.es.js +383 -186
- package/vendor/primevue/usestyle/usestyle.esm.es.js +94 -64
- package/vendor/primevue/usetoast/usetoast.esm.es.js +9 -8
- package/vendor/primevue/utils/utils.esm.es.js +1078 -772
- package/vendor/primevue/virtualscroller/style/virtualscrollerstyle.esm.es.js +5 -67
- package/vendor/primevue/virtualscroller/virtualscroller.esm.es.js +655 -428
- package/vendor/prosemirror-commands/dist/index.es.js +454 -316
- package/vendor/prosemirror-history/dist/index.es.js +286 -178
- package/vendor/prosemirror-keymap/dist/index.es.js +68 -48
- package/vendor/prosemirror-model/dist/index.es.js +1905 -1436
- package/vendor/prosemirror-schema-list/dist/index.es.js +115 -73
- package/vendor/prosemirror-state/dist/index.es.js +467 -353
- package/vendor/prosemirror-transform/dist/index.es.js +1146 -829
- package/vendor/prosemirror-view/dist/index.es.js +4127 -2719
- package/vendor/rope-sequence/dist/index.es.js +165 -82
- package/vendor/simplebar-core/dist/index.es.js +670 -242
- package/vendor/simplebar-vue/dist/simplebar-vue.esm.es.js +73 -60
- package/vendor/single-spa/lib/es2015/esm/single-spa.min.es.js +511 -510
- package/vendor/tippy.js/dist/tippy.esm.es.js +971 -525
- package/vendor/vee-validate/dist/vee-validate.esm.es.js +1830 -1097
- package/vendor/vue-advanced-cropper/dist/index.esm-bundler.es.js +740 -738
- package/vendor/w3c-keyname/index.es.js +25 -13
- package/wangsvue.es.js +167 -208
- package/wangsvue.esm.browser.js +67705 -0
- package/wangsvue.system.js +67600 -234
- package/api/index.es.js +0 -149
- package/apiitem/index.es.js +0 -611
- package/assignmember/index.es.js +0 -434
- package/attachment/index.es.js +0 -118
- package/attachmentchangelog/index.es.js +0 -79
- package/attachmentitem/index.es.js +0 -231
- package/attachmentthumbnail/index.es.js +0 -83
- package/changelog/index.d.ts +0 -164
- package/changelog/index.es.js +0 -85
- package/changelogfilter/index.es.js +0 -113
- package/changelogpage/index.d.ts +0 -184
- package/changelogpage/index.es.js +0 -176
- package/checklist/index.es.js +0 -571
- package/checklistchangelog/index.es.js +0 -85
- package/comment/index.d.ts +0 -187
- package/comment/index.es.js +0 -267
- package/commentblock/index.es.js +0 -337
- package/confirmdeploy/index.es.js +0 -64
- package/dependencycol/index.es.js +0 -32
- package/description/index.es.js +0 -135
- package/descriptiontab/index.es.js +0 -30
- package/detailmember/index.d.ts +0 -77
- package/detailmember/index.es.js +0 -32
- package/detailmemberadmin/index.es.js +0 -210
- package/detailmemberleader/index.es.js +0 -164
- package/detailmemberlog/index.es.js +0 -117
- package/detailsprint/index.d.ts +0 -86
- package/detailsprint/index.es.js +0 -414
- package/dialogaddattachment/index.es.js +0 -273
- package/dialogaddchecklist/index.es.js +0 -120
- package/dialogaddeditapi/index.es.js +0 -87
- package/dialogaddpbi/index.es.js +0 -197
- package/dialogadjustmenttask/index.es.js +0 -484
- package/dialogadjustmenttaskheader/index.es.js +0 -193
- package/dialogapichangelog/index.es.js +0 -83
- package/dialogassignmember/index.es.js +0 -171
- package/dialogconfirmapproval/index.es.js +0 -54
- package/dialogconfirmchecklist/index.es.js +0 -189
- package/dialogconfirmdeletetask/index.es.js +0 -70
- package/dialogconfirmdeletetaskpermanently/index.es.js +0 -50
- package/dialogconfirmedit/index.es.js +0 -50
- package/dialogconfirmfinishtask/index.es.js +0 -50
- package/dialogconfirmrestoretask/index.es.js +0 -46
- package/dialogconfirmsprint/index.es.js +0 -42
- package/dialogcopyapi/index.es.js +0 -130
- package/dialogcustomdependency/index.es.js +0 -55
- package/dialogdetailchecklisttemplate/index.es.js +0 -214
- package/dialogdetailcomponent/index.es.js +0 -121
- package/dialogdetailpbi/index.es.js +0 -192
- package/dialogfinishreview/index.es.js +0 -126
- package/dialogimprovementtask/index.es.js +0 -191
- package/dialogmemberadmin/index.es.js +0 -93
- package/dialogpreparepbi/index.es.js +0 -93
- package/dialogpriorityvalue/index.es.js +0 -85
- package/dialogreportbug/index.es.js +0 -207
- package/dialogreviewleader/index.es.js +0 -280
- package/dialogsavechecklisttemplate/index.es.js +0 -127
- package/dialogselectproject/index.es.js +0 -69
- package/dialogsetduration/index.es.js +0 -109
- package/dialogsettasklink/index.es.js +0 -153
- package/dialogtestapi/index.es.js +0 -389
- package/eventlogtab/index.es.js +0 -50
- package/infotasktab/index.es.js +0 -186
- package/inputadditional/index.es.js +0 -62
- package/inputinitialname/index.d.ts +0 -118
- package/inputinitialname/index.es.js +0 -95
- package/inputrepositoryname/index.d.ts +0 -86
- package/inputrepositoryname/index.es.js +0 -41
- package/isrequiredtext/index.es.js +0 -16
- package/legend/index.es.js +0 -727
- package/legendlist/index.es.js +0 -33
- package/loading-page-BrQattYE.js +0 -1
- package/loading-page-CgfbWppy.js +0 -1
- package/loading-page-DbLuqCHa.js +0 -1
- package/loading-plane-CgfbWppy.js +0 -1
- package/loading-table-Bdr9ZhtP.js +0 -1
- package/loading-table-BzrSQlA0.js +0 -1
- package/loading-table-chOgXi94.js +0 -1
- package/no-data-Cgze_Rvp.js +0 -1
- package/no-data-Dep79CBh.js +0 -1
- package/no-data-y1X5WtcQ.js +0 -1
- package/notificationitem/index.d.ts +0 -107
- package/notificationitem/index.es.js +0 -333
- package/reviewitem/index.es.js +0 -65
- package/reviewtab/index.es.js +0 -44
- package/services/calendar.service.es.js +0 -32
- package/sonarqubesummary/index.es.js +0 -234
- package/sprintsummary/index.es.js +0 -73
- package/summaryaccordion/index.d.ts +0 -121
- package/summaryaccordion/index.es.js +0 -365
- package/taskdependency/index.es.js +0 -686
- package/taskdetail/index.d.ts +0 -82
- package/taskdetail/index.es.js +0 -491
- package/taskdetailpbi/index.d.ts +0 -35
- package/taskdetailpbi/index.es.js +0 -172
- package/taskdetailunassignedpbi/index.es.js +0 -261
- package/tasklink/index.es.js +0 -257
- package/tasklinkchangelog/index.es.js +0 -93
- package/tasklist/index.es.js +0 -92
- package/taskmore/index.es.js +0 -52
- package/taskstatusbadge/index.es.js +0 -18
- package/tasktable/index.d.ts +0 -87
- package/tasktable/index.es.js +0 -832
- package/ticket/index.es.js +0 -151
- package/tooltipspan/index.es.js +0 -30
- package/utils/updateSprintStatus.util.es.js +0 -17
- package/valueformdatainput/index.es.js +0 -70
- package/workcalendar/index.es.js +0 -351
|
@@ -1,1309 +1,2042 @@
|
|
|
1
|
-
import { ref
|
|
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
|
|
8
|
-
return typeof
|
|
9
|
-
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
return Number(
|
|
16
|
-
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
return isNaN(
|
|
20
|
-
}
|
|
21
|
-
function
|
|
22
|
-
return typeof
|
|
23
|
-
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
})
|
|
52
|
+
target[key] = source[key];
|
|
53
|
+
});
|
|
54
|
+
return target;
|
|
45
55
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
56
|
+
function normalizeFormPath(path) {
|
|
57
|
+
const pathArr = path.split(".");
|
|
58
|
+
if (!pathArr.length) {
|
|
49
59
|
return "";
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
57
|
-
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
const
|
|
61
|
-
function
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
function
|
|
65
|
-
typeof
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
function
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
|
190
|
-
let
|
|
191
|
-
for (let
|
|
192
|
-
if (
|
|
193
|
-
|
|
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
|
-
(!(
|
|
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
|
|
200
|
-
if (Array.isArray(
|
|
201
|
-
|
|
286
|
+
function unset(object, key) {
|
|
287
|
+
if (Array.isArray(object) && isIndex(key)) {
|
|
288
|
+
object.splice(Number(key), 1);
|
|
202
289
|
return;
|
|
203
290
|
}
|
|
204
|
-
|
|
291
|
+
if (isObject(object)) {
|
|
292
|
+
delete object[key];
|
|
293
|
+
}
|
|
205
294
|
}
|
|
206
|
-
function
|
|
207
|
-
if (
|
|
208
|
-
delete
|
|
295
|
+
function unsetPath(object, path) {
|
|
296
|
+
if (isNotNestedPath(path)) {
|
|
297
|
+
delete object[cleanupNonNestedPath(path)];
|
|
209
298
|
return;
|
|
210
299
|
}
|
|
211
|
-
const
|
|
212
|
-
let
|
|
213
|
-
for (let
|
|
214
|
-
if (
|
|
215
|
-
|
|
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 (!(
|
|
307
|
+
if (!(keys[i] in acc) || isNullOrUndefined(acc[keys[i]])) {
|
|
219
308
|
break;
|
|
220
|
-
|
|
309
|
+
}
|
|
310
|
+
acc = acc[keys[i]];
|
|
221
311
|
}
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
|
233
|
-
return Object.keys(
|
|
326
|
+
function keysOf(record) {
|
|
327
|
+
return Object.keys(record);
|
|
234
328
|
}
|
|
235
|
-
function
|
|
236
|
-
const
|
|
237
|
-
return (
|
|
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
|
|
240
|
-
if (Array.isArray(
|
|
241
|
-
const
|
|
242
|
-
|
|
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
|
|
245
|
-
}
|
|
246
|
-
function
|
|
247
|
-
let
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
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
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
|
268
|
-
return Array.isArray(
|
|
379
|
+
function normalizeErrorItem(message) {
|
|
380
|
+
return Array.isArray(message) ? message : message ? [message] : [];
|
|
269
381
|
}
|
|
270
|
-
function
|
|
271
|
-
const
|
|
272
|
-
for (const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
283
|
-
|
|
398
|
+
}
|
|
399
|
+
const result = inner(...args);
|
|
400
|
+
resolves.forEach((r) => r(result));
|
|
401
|
+
resolves = [];
|
|
402
|
+
lastTick = null;
|
|
284
403
|
});
|
|
285
|
-
|
|
404
|
+
lastTick = thisTick;
|
|
405
|
+
return new Promise((resolve) => resolves.push(resolve));
|
|
286
406
|
};
|
|
287
407
|
}
|
|
288
|
-
function
|
|
289
|
-
if (
|
|
290
|
-
return
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
return
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
|
359
|
-
const
|
|
360
|
-
async function
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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:
|
|
592
|
+
errors: errors2
|
|
399
593
|
};
|
|
400
594
|
}
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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 (
|
|
408
|
-
|
|
409
|
-
|
|
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
|
|
615
|
+
errors
|
|
414
616
|
};
|
|
415
617
|
}
|
|
416
|
-
function
|
|
417
|
-
return !!
|
|
618
|
+
function isYupError(err) {
|
|
619
|
+
return !!err && err.name === "ValidationError";
|
|
418
620
|
}
|
|
419
|
-
function
|
|
420
|
-
|
|
621
|
+
function yupToTypedSchema(yupSchema) {
|
|
622
|
+
const schema = {
|
|
421
623
|
__type: "VVTypedSchema",
|
|
422
|
-
async parse(
|
|
423
|
-
var
|
|
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
|
|
629
|
+
output,
|
|
427
630
|
errors: []
|
|
428
631
|
};
|
|
429
|
-
} catch (
|
|
430
|
-
if (!
|
|
431
|
-
throw
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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(
|
|
647
|
+
return { errors: Object.values(errors) };
|
|
439
648
|
}
|
|
440
649
|
}
|
|
441
650
|
};
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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:
|
|
449
|
-
errors:
|
|
663
|
+
value: result.value,
|
|
664
|
+
errors: messages
|
|
450
665
|
};
|
|
451
666
|
}
|
|
452
|
-
async function
|
|
453
|
-
const
|
|
454
|
-
if (!
|
|
455
|
-
throw new Error(`No such validator '${
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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
|
-
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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: !
|
|
486
|
-
results
|
|
487
|
-
errors
|
|
488
|
-
values:
|
|
729
|
+
valid: !validationResult.errors.length,
|
|
730
|
+
results,
|
|
731
|
+
errors,
|
|
732
|
+
values: validationResult.value,
|
|
489
733
|
source: "schema"
|
|
490
734
|
};
|
|
491
735
|
}
|
|
492
|
-
async function
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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({},
|
|
747
|
+
return Object.assign(Object.assign({}, fieldResult), { path });
|
|
502
748
|
});
|
|
503
|
-
let
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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:
|
|
512
|
-
results
|
|
513
|
-
errors
|
|
764
|
+
valid: isAllValid,
|
|
765
|
+
results,
|
|
766
|
+
errors,
|
|
514
767
|
source: "schema"
|
|
515
768
|
};
|
|
516
769
|
}
|
|
517
|
-
let
|
|
518
|
-
function
|
|
519
|
-
const { value
|
|
520
|
-
if (!
|
|
521
|
-
let
|
|
522
|
-
var
|
|
523
|
-
|
|
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:
|
|
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
|
|
528
|
-
path
|
|
529
|
-
value
|
|
530
|
-
initialValue
|
|
531
|
-
meta
|
|
532
|
-
flags: { pendingUnmount: { [
|
|
533
|
-
errors:
|
|
534
|
-
setState:
|
|
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
|
|
538
|
-
bails:
|
|
539
|
-
label:
|
|
540
|
-
type:
|
|
541
|
-
validate:
|
|
542
|
-
schema:
|
|
543
|
-
})
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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(
|
|
550
|
-
path
|
|
551
|
-
value
|
|
552
|
-
errors
|
|
553
|
-
meta:
|
|
554
|
-
initialValue
|
|
555
|
-
flags:
|
|
556
|
-
setState
|
|
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
|
|
560
|
-
const
|
|
561
|
-
function
|
|
562
|
-
|
|
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
|
|
565
|
-
if (!
|
|
566
|
-
|
|
845
|
+
function setInitialValue(value2) {
|
|
846
|
+
if (!form) {
|
|
847
|
+
modelRef.value = value2;
|
|
567
848
|
return;
|
|
568
849
|
}
|
|
569
|
-
|
|
850
|
+
form.setFieldInitialValue(unref(path), value2, true);
|
|
570
851
|
}
|
|
571
|
-
const
|
|
572
|
-
if (!
|
|
852
|
+
const initialValue = computed(resolveInitialValue2);
|
|
853
|
+
if (!form) {
|
|
854
|
+
const value2 = ref(resolveInitialValue2());
|
|
573
855
|
return {
|
|
574
|
-
value:
|
|
575
|
-
initialValue
|
|
576
|
-
setInitialValue
|
|
856
|
+
value: value2,
|
|
857
|
+
initialValue,
|
|
858
|
+
setInitialValue
|
|
577
859
|
};
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
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
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
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
|
-
|
|
609
|
-
|
|
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:
|
|
905
|
+
immediate: true,
|
|
612
906
|
flush: "sync"
|
|
613
|
-
})
|
|
907
|
+
});
|
|
908
|
+
return meta;
|
|
614
909
|
}
|
|
615
|
-
function
|
|
616
|
-
const
|
|
910
|
+
function createFieldErrors() {
|
|
911
|
+
const errors = ref([]);
|
|
617
912
|
return {
|
|
618
|
-
errors
|
|
619
|
-
setErrors: (
|
|
620
|
-
|
|
913
|
+
errors,
|
|
914
|
+
setErrors: (messages) => {
|
|
915
|
+
errors.value = normalizeErrorItem(messages);
|
|
621
916
|
}
|
|
622
917
|
};
|
|
623
918
|
}
|
|
624
|
-
function
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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
|
|
649
|
-
|
|
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
|
|
652
|
-
var
|
|
653
|
-
if (
|
|
654
|
-
const { results
|
|
655
|
-
return (
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
(
|
|
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
|
-
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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
|
|
1046
|
+
return value.value;
|
|
700
1047
|
},
|
|
701
|
-
set(
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
})
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
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
|
-
|
|
1102
|
+
Object.assign(acc, deps);
|
|
1103
|
+
return acc;
|
|
741
1104
|
}, {});
|
|
742
1105
|
});
|
|
743
|
-
|
|
744
|
-
if (!Object.keys(
|
|
1106
|
+
watch(dependencies, (deps, oldDeps) => {
|
|
1107
|
+
if (!Object.keys(deps).length) {
|
|
745
1108
|
return;
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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
|
-
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
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
|
-
|
|
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
|
|
771
|
-
const
|
|
1146
|
+
function normalizeOptions(opts) {
|
|
1147
|
+
const defaults = () => ({
|
|
772
1148
|
initialValue: void 0,
|
|
773
|
-
validateOnMount:
|
|
774
|
-
bails:
|
|
1149
|
+
validateOnMount: false,
|
|
1150
|
+
bails: true,
|
|
775
1151
|
label: void 0,
|
|
776
|
-
validateOnValueUpdate:
|
|
1152
|
+
validateOnValueUpdate: true,
|
|
777
1153
|
keepValueOnUnmount: void 0,
|
|
778
|
-
syncVModel:
|
|
779
|
-
controlled:
|
|
780
|
-
})
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
initialValue
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
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
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
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
|
|
799
|
-
var
|
|
800
|
-
if (
|
|
801
|
-
|
|
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
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
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
|
|
1210
|
+
return patchCheckedApi(_useField(name, rules, opts));
|
|
816
1211
|
}
|
|
817
|
-
function
|
|
818
|
-
const
|
|
819
|
-
if (!
|
|
1212
|
+
function useVModel({ prop, value, handleChange, shouldValidate }) {
|
|
1213
|
+
const vm = getCurrentInstance();
|
|
1214
|
+
if (!vm || !prop) {
|
|
820
1215
|
return;
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
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
|
-
|
|
828
|
-
|
|
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
|
-
|
|
849
|
-
|
|
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
|
-
|
|
855
|
-
|
|
856
|
-
|
|
1232
|
+
const newValue = propValue === IS_ABSENT ? void 0 : propValue;
|
|
1233
|
+
if (isEqual(newValue, value.value)) {
|
|
1234
|
+
return;
|
|
857
1235
|
}
|
|
858
|
-
|
|
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
|
-
|
|
861
|
-
|
|
862
|
-
|
|
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
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
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: { [
|
|
912
|
-
pendingReset:
|
|
1391
|
+
pendingUnmount: { [id]: false },
|
|
1392
|
+
pendingReset: false
|
|
913
1393
|
},
|
|
914
1394
|
fieldsCount: 1,
|
|
915
|
-
validate:
|
|
916
|
-
dirty:
|
|
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
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
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
|
-
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
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:
|
|
1457
|
+
valid: formResult.valid,
|
|
937
1458
|
results: {},
|
|
938
1459
|
errors: {},
|
|
939
|
-
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
|
|
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
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
function
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
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
|
-
!
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
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
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
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
|
-
|
|
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
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
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
|
|
1020
|
-
formId
|
|
1021
|
-
values:
|
|
1022
|
-
controlledValues
|
|
1023
|
-
errorBag
|
|
1024
|
-
errors
|
|
1025
|
-
schema
|
|
1026
|
-
submitCount
|
|
1027
|
-
meta
|
|
1028
|
-
isSubmitting
|
|
1029
|
-
isValidating
|
|
1030
|
-
fieldArrays
|
|
1031
|
-
keepValuesOnUnmount
|
|
1032
|
-
validateSchema:
|
|
1033
|
-
validate:
|
|
1034
|
-
setFieldError
|
|
1035
|
-
validateField
|
|
1036
|
-
setFieldValue
|
|
1037
|
-
setValues
|
|
1038
|
-
setErrors
|
|
1039
|
-
setFieldTouched
|
|
1040
|
-
setTouched
|
|
1041
|
-
resetForm
|
|
1042
|
-
resetField
|
|
1043
|
-
handleSubmit
|
|
1044
|
-
useFieldModel
|
|
1045
|
-
defineInputBinds
|
|
1046
|
-
defineComponentBinds
|
|
1047
|
-
defineField
|
|
1048
|
-
stageInitialValue
|
|
1049
|
-
unsetInitialValue
|
|
1050
|
-
setFieldInitialValue
|
|
1051
|
-
createPathState
|
|
1052
|
-
getPathState:
|
|
1053
|
-
unsetPathValue
|
|
1054
|
-
removePathState
|
|
1055
|
-
initialValues
|
|
1056
|
-
getAllPathStates: () =>
|
|
1057
|
-
destroyPath
|
|
1058
|
-
isFieldTouched
|
|
1059
|
-
isFieldDirty
|
|
1060
|
-
isFieldValid
|
|
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
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
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
|
|
1683
|
+
return pathState.value;
|
|
1081
1684
|
},
|
|
1082
|
-
set(
|
|
1083
|
-
var
|
|
1084
|
-
const
|
|
1085
|
-
|
|
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
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1692
|
+
function setFieldTouched(field, isTouched) {
|
|
1693
|
+
const pathState = findPathState(field);
|
|
1694
|
+
if (pathState) {
|
|
1695
|
+
pathState.touched = isTouched;
|
|
1696
|
+
}
|
|
1092
1697
|
}
|
|
1093
|
-
function
|
|
1094
|
-
const
|
|
1095
|
-
|
|
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
|
|
1098
|
-
const
|
|
1099
|
-
|
|
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
|
|
1102
|
-
const
|
|
1103
|
-
|
|
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
|
|
1106
|
-
if (typeof
|
|
1107
|
-
|
|
1108
|
-
|
|
1719
|
+
function setTouched(fields) {
|
|
1720
|
+
if (typeof fields === "boolean") {
|
|
1721
|
+
mutateAllPathState((state) => {
|
|
1722
|
+
state.touched = fields;
|
|
1109
1723
|
});
|
|
1110
1724
|
return;
|
|
1111
1725
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1726
|
+
keysOf(fields).forEach((field) => {
|
|
1727
|
+
setFieldTouched(field, !!fields[field]);
|
|
1114
1728
|
});
|
|
1115
1729
|
}
|
|
1116
|
-
function
|
|
1117
|
-
var
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1120
|
-
|
|
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
|
|
1124
|
-
let
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
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
|
|
1135
|
-
const
|
|
1136
|
-
if (
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
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:
|
|
1159
|
-
results
|
|
1160
|
-
errors:
|
|
1161
|
-
values
|
|
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
|
|
1166
|
-
var
|
|
1167
|
-
const
|
|
1168
|
-
|
|
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
|
|
1171
|
-
|
|
1833
|
+
function unsetInitialValue(path) {
|
|
1834
|
+
unsetPath(initialValues.value, path);
|
|
1172
1835
|
}
|
|
1173
|
-
function
|
|
1174
|
-
|
|
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
|
|
1177
|
-
|
|
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
|
|
1180
|
-
const
|
|
1181
|
-
if (!
|
|
1182
|
-
return { valid:
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
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
|
-
|
|
1859
|
+
isValidating.value = false;
|
|
1860
|
+
return formResult;
|
|
1189
1861
|
}
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1862
|
+
const submitForm = handleSubmit((_, { evt }) => {
|
|
1863
|
+
if (isFormSubmitEvent(evt)) {
|
|
1864
|
+
evt.target.submit();
|
|
1865
|
+
}
|
|
1192
1866
|
});
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
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
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
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
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1226
|
-
var
|
|
1227
|
-
return (
|
|
1228
|
-
})
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
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
|
|
1254
|
-
const [
|
|
1255
|
-
function
|
|
1256
|
-
|
|
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
|
|
1259
|
-
|
|
1260
|
-
|
|
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
|
-
|
|
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
|
|
1266
|
-
const
|
|
1972
|
+
function useFormMeta(pathsState, currentValues, initialValues, errors) {
|
|
1973
|
+
const MERGE_STRATEGIES = {
|
|
1267
1974
|
touched: "some",
|
|
1268
1975
|
pending: "some",
|
|
1269
1976
|
valid: "every"
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
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
|
|
1279
|
-
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
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
|
-
|
|
1291
|
-
|
|
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
|
|
1296
|
-
originalInitialValues
|
|
1297
|
-
setInitialValues
|
|
2025
|
+
initialValues,
|
|
2026
|
+
originalInitialValues,
|
|
2027
|
+
setInitialValues
|
|
1298
2028
|
};
|
|
1299
2029
|
}
|
|
1300
|
-
function
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
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
|
-
|
|
1308
|
-
|
|
2040
|
+
useForm as a,
|
|
2041
|
+
useField as u
|
|
1309
2042
|
};
|