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