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