vue-devui 1.0.0-beta.2 → 1.0.0-beta.220808
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 +9053 -0
- package/auto-complete/index.umd.js +40 -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 +5921 -146
- 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 +8122 -255
- package/checkbox/index.umd.js +38 -1
- package/checkbox/style.css +1 -1
- package/collapse/index.d.ts +7 -0
- package/collapse/index.es.js +195 -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 +12035 -0
- package/date-picker-pro/index.umd.js +38 -0
- package/date-picker-pro/package.json +7 -0
- package/date-picker-pro/style.css +1 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +205 -154
- 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 +736 -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 +908 -461
- 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 +2439 -1995
- package/form/index.umd.js +29 -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 +271 -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 +154 -62
- 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 +8269 -145
- package/input/index.umd.js +38 -1
- package/input/style.css +1 -1
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +260 -191
- 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 +89 -73
- 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 +8326 -0
- package/mention/index.umd.js +47 -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 +891 -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 +533 -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 +611 -877
- 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 +528 -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 +8015 -182
- package/radio/index.umd.js +38 -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 +56 -61
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +8381 -406
- package/search/index.umd.js +38 -1
- package/search/style.css +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +9331 -576
- package/select/index.umd.js +38 -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 +6308 -181
- 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 +253 -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 +7819 -65
- package/switch/index.umd.js +38 -1
- package/switch/style.css +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +11435 -204
- package/table/index.umd.js +38 -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 +7989 -0
- package/textarea/index.umd.js +46 -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 +9126 -597
- package/time-picker/index.umd.js +38 -1
- package/time-picker/style.css +1 -1
- package/time-select/index.d.ts +7 -0
- package/time-select/index.es.js +9606 -0
- package/time-select/index.umd.js +38 -0
- package/{breadcrumb → time-select}/package.json +1 -1
- package/time-select/style.css +1 -0
- package/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 +11504 -692
- package/tree/index.umd.js +38 -1
- package/tree/style.css +1 -1
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +968 -2748
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +22816 -16568
- package/vue-devui.umd.js +42 -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,25 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
import { defineComponent, provide, createVNode, Fragment, ref, toRefs, reactive, withDirectives, resolveDirective, resolveComponent, inject, computed, onMounted, onBeforeUnmount } from "vue";
|
|
18
|
-
var form = "";
|
|
1
|
+
import { defineComponent, watch, provide, reactive, toRefs, createVNode, onUnmounted, Transition, mergeProps, ref, nextTick, unref, Comment, Text, Fragment, h, inject, withDirectives, cloneVNode, computed, onMounted, Teleport, withModifiers, createTextVNode, onBeforeUnmount } from "vue";
|
|
2
|
+
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
19
3
|
const formProps = {
|
|
20
|
-
|
|
4
|
+
data: {
|
|
21
5
|
type: Object,
|
|
22
|
-
default: {}
|
|
6
|
+
default: () => ({})
|
|
23
7
|
},
|
|
24
8
|
layout: {
|
|
25
9
|
type: String,
|
|
@@ -27,1598 +11,73 @@ const formProps = {
|
|
|
27
11
|
},
|
|
28
12
|
labelSize: {
|
|
29
13
|
type: String,
|
|
30
|
-
default: ""
|
|
14
|
+
default: "md"
|
|
31
15
|
},
|
|
32
16
|
labelAlign: {
|
|
33
17
|
type: String,
|
|
34
18
|
default: "start"
|
|
35
19
|
},
|
|
36
20
|
rules: {
|
|
37
|
-
type: Object
|
|
38
|
-
default: {}
|
|
21
|
+
type: Object
|
|
39
22
|
},
|
|
40
|
-
|
|
23
|
+
messageType: {
|
|
41
24
|
type: String,
|
|
42
|
-
default: ""
|
|
25
|
+
default: "popover"
|
|
43
26
|
},
|
|
44
|
-
|
|
45
|
-
type:
|
|
46
|
-
default: ""
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const formItemProps = {
|
|
50
|
-
dHasFeedback: {
|
|
27
|
+
popPosition: {
|
|
28
|
+
type: Array,
|
|
29
|
+
default: ["right", "bottom"]
|
|
30
|
+
},
|
|
31
|
+
validateOnRuleChange: {
|
|
51
32
|
type: Boolean,
|
|
52
33
|
default: false
|
|
53
34
|
},
|
|
54
|
-
|
|
55
|
-
type: String,
|
|
56
|
-
default: ""
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const formLabelProps = {
|
|
60
|
-
required: {
|
|
35
|
+
showFeedback: {
|
|
61
36
|
type: Boolean,
|
|
62
37
|
default: false
|
|
63
38
|
},
|
|
64
|
-
|
|
39
|
+
disabled: {
|
|
65
40
|
type: Boolean,
|
|
66
41
|
default: false
|
|
67
42
|
},
|
|
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];
|
|
43
|
+
size: {
|
|
44
|
+
type: String
|
|
275
45
|
}
|
|
276
46
|
};
|
|
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
|
-
};
|
|
47
|
+
const FORM_TOKEN = Symbol("dForm");
|
|
48
|
+
function createBem(namespace, element, modifier) {
|
|
49
|
+
let cls = namespace;
|
|
50
|
+
if (element) {
|
|
51
|
+
cls += `__${element}`;
|
|
415
52
|
}
|
|
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
|
-
};
|
|
53
|
+
if (modifier) {
|
|
54
|
+
cls += `--${modifier}`;
|
|
454
55
|
}
|
|
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);
|
|
470
|
-
}
|
|
471
|
-
function _inheritsLoose(subClass, superClass) {
|
|
472
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
473
|
-
subClass.prototype.constructor = subClass;
|
|
474
|
-
_setPrototypeOf(subClass, superClass);
|
|
475
|
-
}
|
|
476
|
-
function _getPrototypeOf(o) {
|
|
477
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
|
478
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
479
|
-
};
|
|
480
|
-
return _getPrototypeOf(o);
|
|
56
|
+
return cls;
|
|
481
57
|
}
|
|
482
|
-
function
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
58
|
+
function useNamespace(block, needDot = false) {
|
|
59
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
60
|
+
const b = () => createBem(namespace);
|
|
61
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
62
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
63
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
64
|
+
return {
|
|
65
|
+
b,
|
|
66
|
+
e,
|
|
67
|
+
m,
|
|
68
|
+
em
|
|
486
69
|
};
|
|
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
|
-
}
|
|
504
|
-
function _construct(Parent, args, Class) {
|
|
505
|
-
if (_isNativeReflectConstruct()) {
|
|
506
|
-
_construct = Reflect.construct;
|
|
507
|
-
} else {
|
|
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
70
|
}
|
|
523
|
-
function
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
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);
|
|
71
|
+
function useFieldCollection() {
|
|
72
|
+
const itemContexts = [];
|
|
73
|
+
const addItemContext = (field) => {
|
|
74
|
+
itemContexts.push(field);
|
|
548
75
|
};
|
|
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
|
-
}
|
|
76
|
+
const removeItemContext = (field) => {
|
|
77
|
+
itemContexts.splice(itemContexts.indexOf(field), 1);
|
|
563
78
|
};
|
|
79
|
+
return { itemContexts, addItemContext, removeItemContext };
|
|
564
80
|
}
|
|
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
81
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
1623
82
|
var lodash = { exports: {} };
|
|
1624
83
|
/**
|
|
@@ -2049,9 +508,9 @@ var lodash = { exports: {} };
|
|
|
2049
508
|
return result;
|
|
2050
509
|
}
|
|
2051
510
|
function arrayPush(array4, values) {
|
|
2052
|
-
var index2 = -1, length = values.length,
|
|
511
|
+
var index2 = -1, length = values.length, offset2 = array4.length;
|
|
2053
512
|
while (++index2 < length) {
|
|
2054
|
-
array4[
|
|
513
|
+
array4[offset2 + index2] = values[index2];
|
|
2055
514
|
}
|
|
2056
515
|
return array4;
|
|
2057
516
|
}
|
|
@@ -2330,7 +789,7 @@ var lodash = { exports: {} };
|
|
|
2330
789
|
var objectCtorString = funcToString.call(Object2);
|
|
2331
790
|
var oldDash = root._;
|
|
2332
791
|
var reIsNative = RegExp2("^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
|
|
2333
|
-
var
|
|
792
|
+
var Buffer = moduleExports ? context.Buffer : undefined$1, Symbol2 = context.Symbol, Uint8Array = context.Uint8Array, allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined$1, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined$1, symIterator = Symbol2 ? Symbol2.iterator : undefined$1, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined$1;
|
|
2334
793
|
var defineProperty = function() {
|
|
2335
794
|
try {
|
|
2336
795
|
var func = getNative(Object2, "defineProperty");
|
|
@@ -2340,7 +799,7 @@ var lodash = { exports: {} };
|
|
|
2340
799
|
}
|
|
2341
800
|
}();
|
|
2342
801
|
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
|
|
2343
|
-
var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer =
|
|
802
|
+
var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
|
|
2344
803
|
var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
|
|
2345
804
|
var metaMap = WeakMap && new WeakMap();
|
|
2346
805
|
var realNames = {};
|
|
@@ -3579,7 +2038,7 @@ var lodash = { exports: {} };
|
|
|
3579
2038
|
end = end === undefined$1 ? length : end;
|
|
3580
2039
|
return !start && end >= length ? array4 : baseSlice(array4, start, end);
|
|
3581
2040
|
}
|
|
3582
|
-
var
|
|
2041
|
+
var clearTimeout = ctxClearTimeout || function(id) {
|
|
3583
2042
|
return root.clearTimeout(id);
|
|
3584
2043
|
};
|
|
3585
2044
|
function cloneBuffer(buffer, isDeep) {
|
|
@@ -3592,7 +2051,7 @@ var lodash = { exports: {} };
|
|
|
3592
2051
|
}
|
|
3593
2052
|
function cloneArrayBuffer(arrayBuffer) {
|
|
3594
2053
|
var result2 = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
3595
|
-
new
|
|
2054
|
+
new Uint8Array(result2).set(new Uint8Array(arrayBuffer));
|
|
3596
2055
|
return result2;
|
|
3597
2056
|
}
|
|
3598
2057
|
function cloneDataView(dataView, isDeep) {
|
|
@@ -3658,13 +2117,13 @@ var lodash = { exports: {} };
|
|
|
3658
2117
|
while (++argsIndex < rangeLength) {
|
|
3659
2118
|
result2[argsIndex] = args[argsIndex];
|
|
3660
2119
|
}
|
|
3661
|
-
var
|
|
2120
|
+
var offset2 = argsIndex;
|
|
3662
2121
|
while (++rightIndex < rightLength) {
|
|
3663
|
-
result2[
|
|
2122
|
+
result2[offset2 + rightIndex] = partials[rightIndex];
|
|
3664
2123
|
}
|
|
3665
2124
|
while (++holdersIndex < holdersLength) {
|
|
3666
2125
|
if (isUncurried || argsIndex < argsLength) {
|
|
3667
|
-
result2[
|
|
2126
|
+
result2[offset2 + holders[holdersIndex]] = args[argsIndex++];
|
|
3668
2127
|
}
|
|
3669
2128
|
}
|
|
3670
2129
|
return result2;
|
|
@@ -4174,7 +2633,7 @@ var lodash = { exports: {} };
|
|
|
4174
2633
|
object4 = object4.buffer;
|
|
4175
2634
|
other = other.buffer;
|
|
4176
2635
|
case arrayBufferTag:
|
|
4177
|
-
if (object4.byteLength != other.byteLength || !equalFunc(new
|
|
2636
|
+
if (object4.byteLength != other.byteLength || !equalFunc(new Uint8Array(object4), new Uint8Array(other))) {
|
|
4178
2637
|
return false;
|
|
4179
2638
|
}
|
|
4180
2639
|
return true;
|
|
@@ -5379,7 +3838,7 @@ var lodash = { exports: {} };
|
|
|
5379
3838
|
result2.placeholder = curryRight.placeholder;
|
|
5380
3839
|
return result2;
|
|
5381
3840
|
}
|
|
5382
|
-
function
|
|
3841
|
+
function debounce(func, wait, options) {
|
|
5383
3842
|
var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
5384
3843
|
if (typeof func != "function") {
|
|
5385
3844
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
@@ -5428,7 +3887,7 @@ var lodash = { exports: {} };
|
|
|
5428
3887
|
}
|
|
5429
3888
|
function cancel() {
|
|
5430
3889
|
if (timerId !== undefined$1) {
|
|
5431
|
-
|
|
3890
|
+
clearTimeout(timerId);
|
|
5432
3891
|
}
|
|
5433
3892
|
lastInvokeTime = 0;
|
|
5434
3893
|
lastArgs = lastCallTime = lastThis = timerId = undefined$1;
|
|
@@ -5446,7 +3905,7 @@ var lodash = { exports: {} };
|
|
|
5446
3905
|
return leadingEdge(lastCallTime);
|
|
5447
3906
|
}
|
|
5448
3907
|
if (maxing) {
|
|
5449
|
-
|
|
3908
|
+
clearTimeout(timerId);
|
|
5450
3909
|
timerId = setTimeout2(timerExpired, wait);
|
|
5451
3910
|
return invokeFunc(lastCallTime);
|
|
5452
3911
|
}
|
|
@@ -5559,7 +4018,7 @@ var lodash = { exports: {} };
|
|
|
5559
4018
|
leading = "leading" in options ? !!options.leading : leading;
|
|
5560
4019
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
5561
4020
|
}
|
|
5562
|
-
return
|
|
4021
|
+
return debounce(func, wait, {
|
|
5563
4022
|
"leading": leading,
|
|
5564
4023
|
"maxWait": wait,
|
|
5565
4024
|
"trailing": trailing
|
|
@@ -6211,9 +4670,9 @@ var lodash = { exports: {} };
|
|
|
6211
4670
|
var isEscaping, isEvaluating, index2 = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '";
|
|
6212
4671
|
var reDelimiters = RegExp2((options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$", "g");
|
|
6213
4672
|
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,
|
|
4673
|
+
string3.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset2) {
|
|
6215
4674
|
interpolateValue || (interpolateValue = esTemplateValue);
|
|
6216
|
-
source += string3.slice(index2,
|
|
4675
|
+
source += string3.slice(index2, offset2).replace(reUnescapedString, escapeStringChar);
|
|
6217
4676
|
if (escapeValue) {
|
|
6218
4677
|
isEscaping = true;
|
|
6219
4678
|
source += "' +\n__e(" + escapeValue + ") +\n'";
|
|
@@ -6225,7 +4684,7 @@ var lodash = { exports: {} };
|
|
|
6225
4684
|
if (interpolateValue) {
|
|
6226
4685
|
source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
|
6227
4686
|
}
|
|
6228
|
-
index2 =
|
|
4687
|
+
index2 = offset2 + match.length;
|
|
6229
4688
|
return match;
|
|
6230
4689
|
});
|
|
6231
4690
|
source += "';\n";
|
|
@@ -6570,7 +5029,7 @@ var lodash = { exports: {} };
|
|
|
6570
5029
|
lodash2.create = create;
|
|
6571
5030
|
lodash2.curry = curry;
|
|
6572
5031
|
lodash2.curryRight = curryRight;
|
|
6573
|
-
lodash2.debounce =
|
|
5032
|
+
lodash2.debounce = debounce;
|
|
6574
5033
|
lodash2.defaults = defaults;
|
|
6575
5034
|
lodash2.defaultsDeep = defaultsDeep;
|
|
6576
5035
|
lodash2.defer = defer;
|
|
@@ -6878,432 +5337,2417 @@ var lodash = { exports: {} };
|
|
|
6878
5337
|
"type": methodName + (result2.__dir__ < 0 ? "Right" : "")
|
|
6879
5338
|
});
|
|
6880
5339
|
}
|
|
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);
|
|
5340
|
+
return result2;
|
|
5341
|
+
};
|
|
5342
|
+
LazyWrapper.prototype[methodName + "Right"] = function(n) {
|
|
5343
|
+
return this.reverse()[methodName](n).reverse();
|
|
5344
|
+
};
|
|
5345
|
+
});
|
|
5346
|
+
arrayEach(["filter", "map", "takeWhile"], function(methodName, index2) {
|
|
5347
|
+
var type4 = index2 + 1, isFilter = type4 == LAZY_FILTER_FLAG || type4 == LAZY_WHILE_FLAG;
|
|
5348
|
+
LazyWrapper.prototype[methodName] = function(iteratee2) {
|
|
5349
|
+
var result2 = this.clone();
|
|
5350
|
+
result2.__iteratees__.push({
|
|
5351
|
+
"iteratee": getIteratee(iteratee2, 3),
|
|
5352
|
+
"type": type4
|
|
5353
|
+
});
|
|
5354
|
+
result2.__filtered__ = result2.__filtered__ || isFilter;
|
|
5355
|
+
return result2;
|
|
5356
|
+
};
|
|
5357
|
+
});
|
|
5358
|
+
arrayEach(["head", "last"], function(methodName, index2) {
|
|
5359
|
+
var takeName = "take" + (index2 ? "Right" : "");
|
|
5360
|
+
LazyWrapper.prototype[methodName] = function() {
|
|
5361
|
+
return this[takeName](1).value()[0];
|
|
5362
|
+
};
|
|
5363
|
+
});
|
|
5364
|
+
arrayEach(["initial", "tail"], function(methodName, index2) {
|
|
5365
|
+
var dropName = "drop" + (index2 ? "" : "Right");
|
|
5366
|
+
LazyWrapper.prototype[methodName] = function() {
|
|
5367
|
+
return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
|
|
5368
|
+
};
|
|
5369
|
+
});
|
|
5370
|
+
LazyWrapper.prototype.compact = function() {
|
|
5371
|
+
return this.filter(identity);
|
|
5372
|
+
};
|
|
5373
|
+
LazyWrapper.prototype.find = function(predicate) {
|
|
5374
|
+
return this.filter(predicate).head();
|
|
5375
|
+
};
|
|
5376
|
+
LazyWrapper.prototype.findLast = function(predicate) {
|
|
5377
|
+
return this.reverse().find(predicate);
|
|
5378
|
+
};
|
|
5379
|
+
LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
|
|
5380
|
+
if (typeof path == "function") {
|
|
5381
|
+
return new LazyWrapper(this);
|
|
5382
|
+
}
|
|
5383
|
+
return this.map(function(value) {
|
|
5384
|
+
return baseInvoke(value, path, args);
|
|
5385
|
+
});
|
|
5386
|
+
});
|
|
5387
|
+
LazyWrapper.prototype.reject = function(predicate) {
|
|
5388
|
+
return this.filter(negate(getIteratee(predicate)));
|
|
5389
|
+
};
|
|
5390
|
+
LazyWrapper.prototype.slice = function(start, end) {
|
|
5391
|
+
start = toInteger(start);
|
|
5392
|
+
var result2 = this;
|
|
5393
|
+
if (result2.__filtered__ && (start > 0 || end < 0)) {
|
|
5394
|
+
return new LazyWrapper(result2);
|
|
5395
|
+
}
|
|
5396
|
+
if (start < 0) {
|
|
5397
|
+
result2 = result2.takeRight(-start);
|
|
5398
|
+
} else if (start) {
|
|
5399
|
+
result2 = result2.drop(start);
|
|
5400
|
+
}
|
|
5401
|
+
if (end !== undefined$1) {
|
|
5402
|
+
end = toInteger(end);
|
|
5403
|
+
result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start);
|
|
5404
|
+
}
|
|
5405
|
+
return result2;
|
|
5406
|
+
};
|
|
5407
|
+
LazyWrapper.prototype.takeRightWhile = function(predicate) {
|
|
5408
|
+
return this.reverse().takeWhile(predicate).reverse();
|
|
5409
|
+
};
|
|
5410
|
+
LazyWrapper.prototype.toArray = function() {
|
|
5411
|
+
return this.take(MAX_ARRAY_LENGTH);
|
|
5412
|
+
};
|
|
5413
|
+
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
|
5414
|
+
var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash2[isTaker ? "take" + (methodName == "last" ? "Right" : "") : methodName], retUnwrapped = isTaker || /^find/.test(methodName);
|
|
5415
|
+
if (!lodashFunc) {
|
|
5416
|
+
return;
|
|
5417
|
+
}
|
|
5418
|
+
lodash2.prototype[methodName] = function() {
|
|
5419
|
+
var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray(value);
|
|
5420
|
+
var interceptor = function(value2) {
|
|
5421
|
+
var result3 = lodashFunc.apply(lodash2, arrayPush([value2], args));
|
|
5422
|
+
return isTaker && chainAll ? result3[0] : result3;
|
|
5423
|
+
};
|
|
5424
|
+
if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
|
|
5425
|
+
isLazy = useLazy = false;
|
|
5426
|
+
}
|
|
5427
|
+
var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
|
|
5428
|
+
if (!retUnwrapped && useLazy) {
|
|
5429
|
+
value = onlyLazy ? value : new LazyWrapper(this);
|
|
5430
|
+
var result2 = func.apply(value, args);
|
|
5431
|
+
result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined$1 });
|
|
5432
|
+
return new LodashWrapper(result2, chainAll);
|
|
5433
|
+
}
|
|
5434
|
+
if (isUnwrapped && onlyLazy) {
|
|
5435
|
+
return func.apply(this, args);
|
|
5436
|
+
}
|
|
5437
|
+
result2 = this.thru(interceptor);
|
|
5438
|
+
return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
|
|
5439
|
+
};
|
|
5440
|
+
});
|
|
5441
|
+
arrayEach(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
|
|
5442
|
+
var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
|
|
5443
|
+
lodash2.prototype[methodName] = function() {
|
|
5444
|
+
var args = arguments;
|
|
5445
|
+
if (retUnwrapped && !this.__chain__) {
|
|
5446
|
+
var value = this.value();
|
|
5447
|
+
return func.apply(isArray(value) ? value : [], args);
|
|
5448
|
+
}
|
|
5449
|
+
return this[chainName](function(value2) {
|
|
5450
|
+
return func.apply(isArray(value2) ? value2 : [], args);
|
|
5451
|
+
});
|
|
5452
|
+
};
|
|
5453
|
+
});
|
|
5454
|
+
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
|
5455
|
+
var lodashFunc = lodash2[methodName];
|
|
5456
|
+
if (lodashFunc) {
|
|
5457
|
+
var key = lodashFunc.name + "";
|
|
5458
|
+
if (!hasOwnProperty.call(realNames, key)) {
|
|
5459
|
+
realNames[key] = [];
|
|
5460
|
+
}
|
|
5461
|
+
realNames[key].push({ "name": methodName, "func": lodashFunc });
|
|
5462
|
+
}
|
|
5463
|
+
});
|
|
5464
|
+
realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
|
|
5465
|
+
"name": "wrapper",
|
|
5466
|
+
"func": undefined$1
|
|
5467
|
+
}];
|
|
5468
|
+
LazyWrapper.prototype.clone = lazyClone;
|
|
5469
|
+
LazyWrapper.prototype.reverse = lazyReverse;
|
|
5470
|
+
LazyWrapper.prototype.value = lazyValue;
|
|
5471
|
+
lodash2.prototype.at = wrapperAt;
|
|
5472
|
+
lodash2.prototype.chain = wrapperChain;
|
|
5473
|
+
lodash2.prototype.commit = wrapperCommit;
|
|
5474
|
+
lodash2.prototype.next = wrapperNext;
|
|
5475
|
+
lodash2.prototype.plant = wrapperPlant;
|
|
5476
|
+
lodash2.prototype.reverse = wrapperReverse;
|
|
5477
|
+
lodash2.prototype.toJSON = lodash2.prototype.valueOf = lodash2.prototype.value = wrapperValue;
|
|
5478
|
+
lodash2.prototype.first = lodash2.prototype.head;
|
|
5479
|
+
if (symIterator) {
|
|
5480
|
+
lodash2.prototype[symIterator] = wrapperToIterator;
|
|
5481
|
+
}
|
|
5482
|
+
return lodash2;
|
|
5483
|
+
};
|
|
5484
|
+
var _ = runInContext();
|
|
5485
|
+
if (freeModule) {
|
|
5486
|
+
(freeModule.exports = _)._ = _;
|
|
5487
|
+
freeExports._ = _;
|
|
5488
|
+
} else {
|
|
5489
|
+
root._ = _;
|
|
5490
|
+
}
|
|
5491
|
+
}).call(commonjsGlobal);
|
|
5492
|
+
})(lodash, lodash.exports);
|
|
5493
|
+
function useFormValidation(itemContexts) {
|
|
5494
|
+
const getValidateFields = (fields) => {
|
|
5495
|
+
if (!itemContexts.length) {
|
|
5496
|
+
return [];
|
|
5497
|
+
}
|
|
5498
|
+
const normalizedFields = lodash.exports.castArray(fields);
|
|
5499
|
+
const filteredFields = normalizedFields.length ? itemContexts.filter((context) => context.field && normalizedFields.includes(context.field)) : itemContexts;
|
|
5500
|
+
if (!filteredFields.length) {
|
|
5501
|
+
return [];
|
|
5502
|
+
}
|
|
5503
|
+
return filteredFields;
|
|
5504
|
+
};
|
|
5505
|
+
const execValidateFields = async (fields = []) => {
|
|
5506
|
+
const validateFields2 = getValidateFields(fields);
|
|
5507
|
+
if (!validateFields2.length) {
|
|
5508
|
+
return true;
|
|
5509
|
+
}
|
|
5510
|
+
let errors = {};
|
|
5511
|
+
for (const field of validateFields2) {
|
|
5512
|
+
try {
|
|
5513
|
+
await field.validate("");
|
|
5514
|
+
} catch (err) {
|
|
5515
|
+
errors = {
|
|
5516
|
+
...errors,
|
|
5517
|
+
...err
|
|
5518
|
+
};
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5521
|
+
if (!Object.keys(errors).length) {
|
|
5522
|
+
return true;
|
|
5523
|
+
}
|
|
5524
|
+
return Promise.reject(errors);
|
|
5525
|
+
};
|
|
5526
|
+
const validateFields = async (fields = [], callback) => {
|
|
5527
|
+
try {
|
|
5528
|
+
const result = await execValidateFields(fields);
|
|
5529
|
+
if (result) {
|
|
5530
|
+
callback == null ? void 0 : callback(result);
|
|
5531
|
+
}
|
|
5532
|
+
return result;
|
|
5533
|
+
} catch (err) {
|
|
5534
|
+
const invalidFields = err;
|
|
5535
|
+
callback == null ? void 0 : callback(false, invalidFields);
|
|
5536
|
+
return !callback && Promise.reject(invalidFields);
|
|
5537
|
+
}
|
|
5538
|
+
};
|
|
5539
|
+
const validate = async (callback) => validateFields(void 0, callback);
|
|
5540
|
+
const clearValidate = (fields = []) => {
|
|
5541
|
+
getValidateFields(fields).forEach((field) => field.clearValidate());
|
|
5542
|
+
};
|
|
5543
|
+
const resetFields = (fields = []) => {
|
|
5544
|
+
getValidateFields(fields).forEach((field) => field.resetField());
|
|
5545
|
+
};
|
|
5546
|
+
return { validate, validateFields, resetFields, clearValidate };
|
|
5547
|
+
}
|
|
5548
|
+
var Form = defineComponent({
|
|
5549
|
+
name: "DForm",
|
|
5550
|
+
props: formProps,
|
|
5551
|
+
emits: ["validate"],
|
|
5552
|
+
setup(props, ctx) {
|
|
5553
|
+
const ns2 = useNamespace("form");
|
|
5554
|
+
const {
|
|
5555
|
+
itemContexts,
|
|
5556
|
+
addItemContext,
|
|
5557
|
+
removeItemContext
|
|
5558
|
+
} = useFieldCollection();
|
|
5559
|
+
const {
|
|
5560
|
+
validate,
|
|
5561
|
+
validateFields,
|
|
5562
|
+
resetFields,
|
|
5563
|
+
clearValidate
|
|
5564
|
+
} = useFormValidation(itemContexts);
|
|
5565
|
+
const onSubmit = (e) => {
|
|
5566
|
+
e.preventDefault();
|
|
5567
|
+
};
|
|
5568
|
+
watch(() => props.rules, () => {
|
|
5569
|
+
if (props.validateOnRuleChange) {
|
|
5570
|
+
validate();
|
|
5571
|
+
}
|
|
5572
|
+
}, {
|
|
5573
|
+
deep: true
|
|
5574
|
+
});
|
|
5575
|
+
provide(FORM_TOKEN, reactive({
|
|
5576
|
+
...toRefs(props),
|
|
5577
|
+
emit: ctx.emit,
|
|
5578
|
+
addItemContext,
|
|
5579
|
+
removeItemContext
|
|
5580
|
+
}));
|
|
5581
|
+
ctx.expose({
|
|
5582
|
+
validate,
|
|
5583
|
+
validateFields,
|
|
5584
|
+
resetFields,
|
|
5585
|
+
clearValidate
|
|
5586
|
+
});
|
|
5587
|
+
return () => {
|
|
5588
|
+
var _a, _b;
|
|
5589
|
+
return createVNode("form", {
|
|
5590
|
+
"onSubmit": onSubmit,
|
|
5591
|
+
"class": ns2.b()
|
|
5592
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
5593
|
+
};
|
|
5594
|
+
}
|
|
5595
|
+
});
|
|
5596
|
+
const formItemProps = {
|
|
5597
|
+
label: {
|
|
5598
|
+
type: String
|
|
5599
|
+
},
|
|
5600
|
+
field: {
|
|
5601
|
+
type: String,
|
|
5602
|
+
default: ""
|
|
5603
|
+
},
|
|
5604
|
+
required: {
|
|
5605
|
+
type: Boolean,
|
|
5606
|
+
default: false
|
|
5607
|
+
},
|
|
5608
|
+
messageType: {
|
|
5609
|
+
type: String
|
|
5610
|
+
},
|
|
5611
|
+
popPosition: {
|
|
5612
|
+
type: Array
|
|
5613
|
+
},
|
|
5614
|
+
rules: {
|
|
5615
|
+
type: [Object, Array]
|
|
5616
|
+
},
|
|
5617
|
+
showFeedback: {
|
|
5618
|
+
type: Boolean,
|
|
5619
|
+
default: void 0
|
|
5620
|
+
},
|
|
5621
|
+
helpTips: {
|
|
5622
|
+
type: String,
|
|
5623
|
+
default: ""
|
|
5624
|
+
},
|
|
5625
|
+
feedbackStatus: {
|
|
5626
|
+
type: String
|
|
5627
|
+
},
|
|
5628
|
+
extraInfo: {
|
|
5629
|
+
type: String,
|
|
5630
|
+
default: ""
|
|
5631
|
+
}
|
|
5632
|
+
};
|
|
5633
|
+
const FORM_ITEM_TOKEN = Symbol("dFormItem");
|
|
5634
|
+
const LABEL_DATA = Symbol("labelData");
|
|
5635
|
+
const formLabelProps = {
|
|
5636
|
+
helpTips: {
|
|
5637
|
+
type: String,
|
|
5638
|
+
default: ""
|
|
5639
|
+
}
|
|
5640
|
+
};
|
|
5641
|
+
const fixedOverlayProps = {
|
|
5642
|
+
modelValue: {
|
|
5643
|
+
type: Boolean,
|
|
5644
|
+
default: false
|
|
5645
|
+
},
|
|
5646
|
+
lockScroll: {
|
|
5647
|
+
type: Boolean,
|
|
5648
|
+
default: true
|
|
5649
|
+
},
|
|
5650
|
+
closeOnClickOverlay: {
|
|
5651
|
+
type: Boolean,
|
|
5652
|
+
default: true
|
|
5653
|
+
}
|
|
5654
|
+
};
|
|
5655
|
+
function lockScroll() {
|
|
5656
|
+
if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
|
|
5657
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
5658
|
+
const style = document.documentElement.getAttribute("style");
|
|
5659
|
+
document.documentElement.style.position = "fixed";
|
|
5660
|
+
document.documentElement.style.top = `-${scrollTop}px`;
|
|
5661
|
+
document.documentElement.style.width = document.documentElement.style.width || "100%";
|
|
5662
|
+
document.documentElement.style.overflowY = "scroll";
|
|
5663
|
+
return () => {
|
|
5664
|
+
if (style) {
|
|
5665
|
+
document.documentElement.setAttribute("style", style);
|
|
5666
|
+
} else {
|
|
5667
|
+
document.documentElement.removeAttribute("style");
|
|
5668
|
+
}
|
|
5669
|
+
document.documentElement.scrollTop = scrollTop;
|
|
5670
|
+
};
|
|
5671
|
+
}
|
|
5672
|
+
return;
|
|
5673
|
+
}
|
|
5674
|
+
function useFixedOverlay(props, ctx) {
|
|
5675
|
+
let lockScrollCb;
|
|
5676
|
+
const onClick = (event) => {
|
|
5677
|
+
event.preventDefault();
|
|
5678
|
+
ctx.emit("click", event);
|
|
5679
|
+
if (props.closeOnClickOverlay) {
|
|
5680
|
+
ctx.emit("update:modelValue", false);
|
|
5681
|
+
}
|
|
5682
|
+
};
|
|
5683
|
+
const removeBodyAdditions = () => {
|
|
5684
|
+
lockScrollCb == null ? void 0 : lockScrollCb();
|
|
5685
|
+
};
|
|
5686
|
+
watch(() => props.modelValue, (val) => {
|
|
5687
|
+
if (val) {
|
|
5688
|
+
props.lockScroll && (lockScrollCb = lockScroll());
|
|
5689
|
+
} else {
|
|
5690
|
+
removeBodyAdditions();
|
|
5691
|
+
}
|
|
5692
|
+
});
|
|
5693
|
+
onUnmounted(removeBodyAdditions);
|
|
5694
|
+
return { onClick };
|
|
5695
|
+
}
|
|
5696
|
+
var fixedOverlay = "";
|
|
5697
|
+
defineComponent({
|
|
5698
|
+
name: "DFixedOverlay",
|
|
5699
|
+
inheritAttrs: false,
|
|
5700
|
+
props: fixedOverlayProps,
|
|
5701
|
+
emits: ["update:modelValue", "click"],
|
|
5702
|
+
setup(props, ctx) {
|
|
5703
|
+
const {
|
|
5704
|
+
modelValue
|
|
5705
|
+
} = toRefs(props);
|
|
5706
|
+
const ns2 = useNamespace("fixed-overlay");
|
|
5707
|
+
const {
|
|
5708
|
+
onClick
|
|
5709
|
+
} = useFixedOverlay(props, ctx);
|
|
5710
|
+
return () => createVNode(Transition, {
|
|
5711
|
+
"name": ns2.m("fade")
|
|
5712
|
+
}, {
|
|
5713
|
+
default: () => {
|
|
5714
|
+
var _a, _b;
|
|
5715
|
+
return [modelValue.value && createVNode("div", mergeProps({
|
|
5716
|
+
"class": ns2.b()
|
|
5717
|
+
}, ctx.attrs, {
|
|
5718
|
+
"onClick": onClick
|
|
5719
|
+
}), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
|
|
5720
|
+
}
|
|
5721
|
+
});
|
|
5722
|
+
}
|
|
5723
|
+
});
|
|
5724
|
+
const flexibleOverlayProps = {
|
|
5725
|
+
modelValue: {
|
|
5726
|
+
type: Boolean,
|
|
5727
|
+
default: false
|
|
5728
|
+
},
|
|
5729
|
+
origin: {
|
|
5730
|
+
type: Object,
|
|
5731
|
+
require: true
|
|
5732
|
+
},
|
|
5733
|
+
position: {
|
|
5734
|
+
type: Array,
|
|
5735
|
+
default: ["bottom"]
|
|
5736
|
+
},
|
|
5737
|
+
offset: {
|
|
5738
|
+
type: [Number, Object],
|
|
5739
|
+
default: 8
|
|
5740
|
+
},
|
|
5741
|
+
shiftOffset: {
|
|
5742
|
+
type: Number
|
|
5743
|
+
},
|
|
5744
|
+
align: {
|
|
5745
|
+
type: String,
|
|
5746
|
+
default: null
|
|
5747
|
+
},
|
|
5748
|
+
showArrow: {
|
|
5749
|
+
type: Boolean,
|
|
5750
|
+
default: false
|
|
5751
|
+
},
|
|
5752
|
+
isArrowCenter: {
|
|
5753
|
+
type: Boolean,
|
|
5754
|
+
default: true
|
|
5755
|
+
}
|
|
5756
|
+
};
|
|
5757
|
+
function getScrollParent(element) {
|
|
5758
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
5759
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
5760
|
+
const style = window.getComputedStyle(parent);
|
|
5761
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
5762
|
+
return parent;
|
|
5763
|
+
}
|
|
5764
|
+
}
|
|
5765
|
+
return window;
|
|
5766
|
+
}
|
|
5767
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
5768
|
+
let { x, y } = point;
|
|
5769
|
+
if (!isArrowCenter) {
|
|
5770
|
+
const { width, height } = originRect;
|
|
5771
|
+
if (x && placement.includes("start")) {
|
|
5772
|
+
x = 12;
|
|
5773
|
+
}
|
|
5774
|
+
if (x && placement.includes("end")) {
|
|
5775
|
+
x = Math.round(width - 24);
|
|
5776
|
+
}
|
|
5777
|
+
if (y && placement.includes("start")) {
|
|
5778
|
+
y = 10;
|
|
5779
|
+
}
|
|
5780
|
+
if (y && placement.includes("end")) {
|
|
5781
|
+
y = height - 14;
|
|
5782
|
+
}
|
|
5783
|
+
}
|
|
5784
|
+
return { x, y };
|
|
5785
|
+
}
|
|
5786
|
+
function useOverlay(props, emit) {
|
|
5787
|
+
const overlayRef = ref();
|
|
5788
|
+
const arrowRef = ref();
|
|
5789
|
+
let originParent = null;
|
|
5790
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
5791
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
5792
|
+
const staticSide = {
|
|
5793
|
+
top: "bottom",
|
|
5794
|
+
right: "left",
|
|
5795
|
+
bottom: "top",
|
|
5796
|
+
left: "right"
|
|
5797
|
+
}[placement.split("-")[0]];
|
|
5798
|
+
Object.assign(arrowEl.style, {
|
|
5799
|
+
left: x ? `${x}px` : "",
|
|
5800
|
+
top: y ? `${y}px` : "",
|
|
5801
|
+
right: "",
|
|
5802
|
+
bottom: "",
|
|
5803
|
+
[staticSide]: "-4px"
|
|
5804
|
+
});
|
|
5805
|
+
};
|
|
5806
|
+
const updatePosition = async () => {
|
|
5807
|
+
const hostEl = props.origin;
|
|
5808
|
+
const overlayEl = unref(overlayRef.value);
|
|
5809
|
+
const arrowEl = unref(arrowRef.value);
|
|
5810
|
+
const middleware = [
|
|
5811
|
+
offset(props.offset),
|
|
5812
|
+
autoPlacement({
|
|
5813
|
+
alignment: props.align,
|
|
5814
|
+
allowedPlacements: props.position
|
|
5815
|
+
})
|
|
5816
|
+
];
|
|
5817
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
5818
|
+
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
5819
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
5820
|
+
strategy: "fixed",
|
|
5821
|
+
middleware
|
|
5822
|
+
});
|
|
5823
|
+
let applyX = x;
|
|
5824
|
+
let applyY = y;
|
|
5825
|
+
if (props.shiftOffset !== void 0) {
|
|
5826
|
+
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
5827
|
+
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
5828
|
+
shiftX > 0 && (applyX += props.shiftOffset);
|
|
5829
|
+
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
5830
|
+
shiftY > 0 && (applyY += props.shiftOffset);
|
|
5831
|
+
}
|
|
5832
|
+
emit("positionChange", placement);
|
|
5833
|
+
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
5834
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
5835
|
+
};
|
|
5836
|
+
watch(() => props.modelValue, () => {
|
|
5837
|
+
if (props.modelValue && props.origin) {
|
|
5838
|
+
originParent = getScrollParent(props.origin);
|
|
5839
|
+
nextTick(updatePosition);
|
|
5840
|
+
originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
|
|
5841
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
5842
|
+
window.addEventListener("resize", updatePosition);
|
|
5843
|
+
} else {
|
|
5844
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5845
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5846
|
+
window.removeEventListener("resize", updatePosition);
|
|
5847
|
+
}
|
|
5848
|
+
});
|
|
5849
|
+
onUnmounted(() => {
|
|
5850
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5851
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5852
|
+
window.removeEventListener("resize", updatePosition);
|
|
5853
|
+
});
|
|
5854
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
5855
|
+
}
|
|
5856
|
+
var flexibleOverlay = "";
|
|
5857
|
+
const FlexibleOverlay = defineComponent({
|
|
5858
|
+
name: "DFlexibleOverlay",
|
|
5859
|
+
inheritAttrs: false,
|
|
5860
|
+
props: flexibleOverlayProps,
|
|
5861
|
+
emits: ["update:modelValue", "positionChange"],
|
|
5862
|
+
setup(props, {
|
|
5863
|
+
slots,
|
|
5864
|
+
attrs,
|
|
5865
|
+
emit,
|
|
5866
|
+
expose
|
|
5867
|
+
}) {
|
|
5868
|
+
const ns2 = useNamespace("flexible-overlay");
|
|
5869
|
+
const {
|
|
5870
|
+
arrowRef,
|
|
5871
|
+
overlayRef,
|
|
5872
|
+
updatePosition
|
|
5873
|
+
} = useOverlay(props, emit);
|
|
5874
|
+
expose({
|
|
5875
|
+
updatePosition
|
|
5876
|
+
});
|
|
5877
|
+
return () => {
|
|
5878
|
+
var _a;
|
|
5879
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
5880
|
+
"ref": overlayRef,
|
|
5881
|
+
"class": ns2.b()
|
|
5882
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
5883
|
+
"ref": arrowRef,
|
|
5884
|
+
"class": ns2.e("arrow")
|
|
5885
|
+
}, null)]);
|
|
5886
|
+
};
|
|
5887
|
+
}
|
|
5888
|
+
});
|
|
5889
|
+
const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
|
|
5890
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
5891
|
+
const ns$1 = useNamespace("popper-trigger");
|
|
5892
|
+
function wrapContent(content) {
|
|
5893
|
+
return h("span", { class: ns$1.b() }, content);
|
|
5894
|
+
}
|
|
5895
|
+
function getFirstValidChild(nodes) {
|
|
5896
|
+
for (const child of nodes) {
|
|
5897
|
+
if (isObject(child)) {
|
|
5898
|
+
if (child.type === Comment) {
|
|
5899
|
+
continue;
|
|
5900
|
+
}
|
|
5901
|
+
if (child.type === "svg" || child.type === Text) {
|
|
5902
|
+
return wrapContent(child);
|
|
5903
|
+
}
|
|
5904
|
+
if (child.type === Fragment) {
|
|
5905
|
+
return getFirstValidChild(child.children);
|
|
5906
|
+
}
|
|
5907
|
+
return child;
|
|
5908
|
+
}
|
|
5909
|
+
return wrapContent(child);
|
|
5910
|
+
}
|
|
5911
|
+
return null;
|
|
5912
|
+
}
|
|
5913
|
+
var PopperTrigger = defineComponent({
|
|
5914
|
+
name: "DPopperTrigger",
|
|
5915
|
+
setup(_, ctx) {
|
|
5916
|
+
const {
|
|
5917
|
+
slots,
|
|
5918
|
+
attrs
|
|
5919
|
+
} = ctx;
|
|
5920
|
+
return () => {
|
|
5921
|
+
var _a;
|
|
5922
|
+
const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
|
|
5923
|
+
const triggerRef = inject(POPPER_TRIGGER_TOKEN);
|
|
5924
|
+
if (!defaultSlot) {
|
|
5925
|
+
return null;
|
|
5926
|
+
}
|
|
5927
|
+
const firstValidChild = getFirstValidChild(defaultSlot);
|
|
5928
|
+
if (!firstValidChild) {
|
|
5929
|
+
return null;
|
|
5930
|
+
}
|
|
5931
|
+
return withDirectives(cloneVNode(firstValidChild, attrs), [[{
|
|
5932
|
+
mounted(el) {
|
|
5933
|
+
triggerRef.value = el;
|
|
5934
|
+
},
|
|
5935
|
+
updated(el) {
|
|
5936
|
+
triggerRef.value = el;
|
|
5937
|
+
},
|
|
5938
|
+
unmounted() {
|
|
5939
|
+
triggerRef.value = null;
|
|
5940
|
+
}
|
|
5941
|
+
}]]);
|
|
5942
|
+
};
|
|
5943
|
+
}
|
|
5944
|
+
});
|
|
5945
|
+
const popoverProps = {
|
|
5946
|
+
isOpen: {
|
|
5947
|
+
type: Boolean,
|
|
5948
|
+
default: false
|
|
5949
|
+
},
|
|
5950
|
+
position: {
|
|
5951
|
+
type: Array,
|
|
5952
|
+
default: ["bottom"]
|
|
5953
|
+
},
|
|
5954
|
+
align: {
|
|
5955
|
+
type: String,
|
|
5956
|
+
default: null
|
|
5957
|
+
},
|
|
5958
|
+
offset: {
|
|
5959
|
+
type: [Number, Object],
|
|
5960
|
+
default: 8
|
|
5961
|
+
},
|
|
5962
|
+
content: {
|
|
5963
|
+
type: String,
|
|
5964
|
+
default: ""
|
|
5965
|
+
},
|
|
5966
|
+
trigger: {
|
|
5967
|
+
type: String,
|
|
5968
|
+
default: "click"
|
|
5969
|
+
},
|
|
5970
|
+
popType: {
|
|
5971
|
+
type: String,
|
|
5972
|
+
default: "default"
|
|
5973
|
+
},
|
|
5974
|
+
showAnimation: {
|
|
5975
|
+
type: Boolean,
|
|
5976
|
+
default: true
|
|
5977
|
+
},
|
|
5978
|
+
mouseEnterDelay: {
|
|
5979
|
+
type: Number,
|
|
5980
|
+
default: 150
|
|
5981
|
+
},
|
|
5982
|
+
mouseLeaveDelay: {
|
|
5983
|
+
type: Number,
|
|
5984
|
+
default: 100
|
|
5985
|
+
},
|
|
5986
|
+
disabled: {
|
|
5987
|
+
type: Boolean,
|
|
5988
|
+
default: false
|
|
5989
|
+
}
|
|
5990
|
+
};
|
|
5991
|
+
const TransformOriginMap = {
|
|
5992
|
+
top: "50% calc(100% + 8px)",
|
|
5993
|
+
bottom: "50% -8px",
|
|
5994
|
+
left: "calc(100% + 8px)",
|
|
5995
|
+
right: "-8px 50%"
|
|
5996
|
+
};
|
|
5997
|
+
function usePopover(props, visible, placement, origin, popoverRef) {
|
|
5998
|
+
const { trigger, isOpen } = toRefs(props);
|
|
5999
|
+
const overlayStyles = computed(() => ({
|
|
6000
|
+
zIndex: 1060,
|
|
6001
|
+
transformOrigin: TransformOriginMap[placement.value]
|
|
6002
|
+
}));
|
|
6003
|
+
const onDocumentClick = (e) => {
|
|
6004
|
+
var _a, _b;
|
|
6005
|
+
if (!((_a = origin.value) == null ? void 0 : _a.contains(e.target)) && !((_b = popoverRef.value.$el) == null ? void 0 : _b.contains(e.target))) {
|
|
6006
|
+
visible.value = false;
|
|
6007
|
+
}
|
|
6008
|
+
};
|
|
6009
|
+
watch(isOpen, (isOpenVal) => {
|
|
6010
|
+
visible.value = isOpenVal;
|
|
6011
|
+
});
|
|
6012
|
+
watch(visible, () => {
|
|
6013
|
+
if (visible.value && trigger.value !== "manually") {
|
|
6014
|
+
document.addEventListener("click", onDocumentClick);
|
|
6015
|
+
} else {
|
|
6016
|
+
document.removeEventListener("click", onDocumentClick);
|
|
6017
|
+
}
|
|
6018
|
+
});
|
|
6019
|
+
onUnmounted(() => {
|
|
6020
|
+
document.removeEventListener("click", onDocumentClick);
|
|
6021
|
+
});
|
|
6022
|
+
return { overlayStyles };
|
|
6023
|
+
}
|
|
6024
|
+
function usePopoverEvent(props, visible, origin) {
|
|
6025
|
+
const { trigger, position, mouseEnterDelay, mouseLeaveDelay, disabled } = toRefs(props);
|
|
6026
|
+
const isClick = computed(() => trigger.value === "click");
|
|
6027
|
+
const placement = ref(position.value[0].split("-")[0]);
|
|
6028
|
+
const isEnter = ref(false);
|
|
6029
|
+
const onClick = () => {
|
|
6030
|
+
if (disabled.value) {
|
|
6031
|
+
return;
|
|
6032
|
+
}
|
|
6033
|
+
isClick.value && (visible.value = !visible.value);
|
|
6034
|
+
};
|
|
6035
|
+
const enter = lodash.exports.debounce(() => {
|
|
6036
|
+
isEnter.value && (visible.value = true);
|
|
6037
|
+
}, mouseEnterDelay.value);
|
|
6038
|
+
const leave = lodash.exports.debounce(() => {
|
|
6039
|
+
!isEnter.value && (visible.value = false);
|
|
6040
|
+
}, mouseLeaveDelay.value);
|
|
6041
|
+
const onMouseenter = () => {
|
|
6042
|
+
if (disabled.value) {
|
|
6043
|
+
return;
|
|
6044
|
+
}
|
|
6045
|
+
if (!isClick.value) {
|
|
6046
|
+
isEnter.value = true;
|
|
6047
|
+
enter();
|
|
6048
|
+
}
|
|
6049
|
+
};
|
|
6050
|
+
const onMouseleave = () => {
|
|
6051
|
+
if (!isClick.value) {
|
|
6052
|
+
isEnter.value = false;
|
|
6053
|
+
leave();
|
|
6054
|
+
}
|
|
6055
|
+
};
|
|
6056
|
+
const quickLeave = () => {
|
|
6057
|
+
isEnter.value = false;
|
|
6058
|
+
visible.value = false;
|
|
6059
|
+
};
|
|
6060
|
+
watch(disabled, (newVal) => {
|
|
6061
|
+
if (newVal && visible.value) {
|
|
6062
|
+
quickLeave();
|
|
6063
|
+
}
|
|
6064
|
+
});
|
|
6065
|
+
const handlePositionChange = (pos) => {
|
|
6066
|
+
placement.value = pos.split("-")[0];
|
|
6067
|
+
};
|
|
6068
|
+
onMounted(() => {
|
|
6069
|
+
if (trigger.value === "click") {
|
|
6070
|
+
origin.value.addEventListener("click", onClick);
|
|
6071
|
+
} else if (trigger.value === "hover") {
|
|
6072
|
+
origin.value.addEventListener("mouseenter", onMouseenter);
|
|
6073
|
+
origin.value.addEventListener("mouseleave", onMouseleave);
|
|
6074
|
+
}
|
|
6075
|
+
});
|
|
6076
|
+
return { placement, handlePositionChange, onMouseenter, onMouseleave };
|
|
6077
|
+
}
|
|
6078
|
+
const ns = useNamespace("popover");
|
|
6079
|
+
function SuccessIcon$1() {
|
|
6080
|
+
return createVNode("svg", {
|
|
6081
|
+
"class": [ns.e("icon"), ns.em("icon", "success")],
|
|
6082
|
+
"viewBox": "0 0 16 16",
|
|
6083
|
+
"version": "1.1",
|
|
6084
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
6085
|
+
}, [createVNode("g", {
|
|
6086
|
+
"stroke": "none",
|
|
6087
|
+
"stroke-width": "1",
|
|
6088
|
+
"fill": "none",
|
|
6089
|
+
"fill-rule": "evenodd"
|
|
6090
|
+
}, [createVNode("circle", {
|
|
6091
|
+
"cx": "8",
|
|
6092
|
+
"cy": "8",
|
|
6093
|
+
"r": "7"
|
|
6094
|
+
}, null), createVNode("path", {
|
|
6095
|
+
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z",
|
|
6096
|
+
"fill-rule": "nonzero"
|
|
6097
|
+
}, null), createVNode("polygon", {
|
|
6098
|
+
"stroke-width": "0.4",
|
|
6099
|
+
"fill-rule": "nonzero",
|
|
6100
|
+
"points": "8.16 10.48 7.32 11.32 6.48 10.48 6.48 10.48 3.6 7.68 4.44 6.84 7.28 9.68 11.52 5.44 12.36 6.28"
|
|
6101
|
+
}, null)])]);
|
|
6102
|
+
}
|
|
6103
|
+
function WarningIcon() {
|
|
6104
|
+
return createVNode("svg", {
|
|
6105
|
+
"class": [ns.e("icon"), ns.em("icon", "warning")],
|
|
6106
|
+
"viewBox": "0 0 16 16",
|
|
6107
|
+
"version": "1.1",
|
|
6108
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
6109
|
+
}, [createVNode("g", {
|
|
6110
|
+
"stroke": "none",
|
|
6111
|
+
"stroke-width": "1",
|
|
6112
|
+
"fill": "none",
|
|
6113
|
+
"fill-rule": "evenodd"
|
|
6114
|
+
}, [createVNode("polygon", {
|
|
6115
|
+
"points": "7.5 1.74501946 1.39184847 13.5954649 7.08947368 14.2207621 13.9973698 13.5954649 10.9383683 5.61273879 8.40084114 1.27624313"
|
|
6116
|
+
}, null), createVNode("path", {
|
|
6117
|
+
"d": "M8.51325441,0.127397589 C8.70423071,0.228333932 8.8605922,0.383286648 8.96244623,0.57254229 L15.8714442,13.4101975 C16.1549662,13.9370117 15.9538562,14.5918482 15.4222523,14.8728158 C15.2642579,14.9563203 15.0879506,15 14.9088903,15 L1.09089441,15 C0.488410063,15 0,14.5159904 0,13.9189343 C0,13.7414873 0.0440768395,13.5667684 0.128340519,13.4101975 L7.03733844,0.57254229 C7.32086049,0.0457280838 7.98165058,-0.153569987 8.51325441,0.127397589 Z M8.87894737,11.2105263 L7.08947368,11.2105263 L7.08947368,13 L8.87894737,13 L8.87894737,11.2105263 Z M8.96842105,4.5 L7,4.5 L7.08947368,9.86842105 L8.87894737,9.86842105 L8.96842105,4.5 Z"
|
|
6118
|
+
}, null)])]);
|
|
6119
|
+
}
|
|
6120
|
+
function InfoIcon() {
|
|
6121
|
+
return createVNode("svg", {
|
|
6122
|
+
"class": [ns.e("icon"), ns.em("icon", "info")],
|
|
6123
|
+
"viewBox": "0 0 16 16",
|
|
6124
|
+
"version": "1.1",
|
|
6125
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
6126
|
+
}, [createVNode("g", {
|
|
6127
|
+
"stroke": "none",
|
|
6128
|
+
"stroke-width": "1",
|
|
6129
|
+
"fill": "none",
|
|
6130
|
+
"fill-rule": "evenodd"
|
|
6131
|
+
}, [createVNode("circle", {
|
|
6132
|
+
"cx": "8",
|
|
6133
|
+
"cy": "8",
|
|
6134
|
+
"r": "7"
|
|
6135
|
+
}, null), createVNode("g", {
|
|
6136
|
+
"stroke-width": "1"
|
|
6137
|
+
}, [createVNode("path", {
|
|
6138
|
+
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z M9,5 L7,5 L7,3 L9,3 L9,5 Z M9,12.6 L7,12.6 L7,6.6 L9,6.6 L9,12.6 Z"
|
|
6139
|
+
}, null)])])]);
|
|
6140
|
+
}
|
|
6141
|
+
function ErrorIcon$1() {
|
|
6142
|
+
return createVNode("svg", {
|
|
6143
|
+
"class": [ns.e("icon"), ns.em("icon", "error")],
|
|
6144
|
+
"width": "16px",
|
|
6145
|
+
"height": "16px",
|
|
6146
|
+
"viewBox": "0 0 16 16",
|
|
6147
|
+
"version": "1.1",
|
|
6148
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
6149
|
+
}, [createVNode("g", {
|
|
6150
|
+
"stroke": "none",
|
|
6151
|
+
"stroke-width": "1",
|
|
6152
|
+
"fill": "none",
|
|
6153
|
+
"fill-rule": "evenodd"
|
|
6154
|
+
}, [createVNode("circle", {
|
|
6155
|
+
"cx": "8",
|
|
6156
|
+
"cy": "8",
|
|
6157
|
+
"r": "7"
|
|
6158
|
+
}, null), createVNode("path", {
|
|
6159
|
+
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z M9,12.6 L7,12.6 L7,10.6 L9,10.6 L9,12.6 Z M9,9.1 L7,9.1 L6.9,3.1 L9.1,3.1 L9,9.1 Z",
|
|
6160
|
+
"fill-rule": "nonzero"
|
|
6161
|
+
}, null)])]);
|
|
6162
|
+
}
|
|
6163
|
+
var popoverIcon = "";
|
|
6164
|
+
var PopoverIcon = defineComponent({
|
|
6165
|
+
props: {
|
|
6166
|
+
type: {
|
|
6167
|
+
type: String,
|
|
6168
|
+
default: "default"
|
|
6169
|
+
}
|
|
6170
|
+
},
|
|
6171
|
+
setup(props) {
|
|
6172
|
+
const ns2 = useNamespace("popover");
|
|
6173
|
+
return () => props.type && props.type !== "default" && createVNode("span", {
|
|
6174
|
+
"class": ns2.e("icon-wrap")
|
|
6175
|
+
}, [props.type === "success" && createVNode(SuccessIcon$1, null, null), props.type === "warning" && createVNode(WarningIcon, null, null), props.type === "info" && createVNode(InfoIcon, null, null), props.type === "error" && createVNode(ErrorIcon$1, null, null)]);
|
|
6176
|
+
}
|
|
6177
|
+
});
|
|
6178
|
+
var popover = "";
|
|
6179
|
+
var Popover = defineComponent({
|
|
6180
|
+
name: "DPopover",
|
|
6181
|
+
inheritAttrs: false,
|
|
6182
|
+
props: popoverProps,
|
|
6183
|
+
emits: ["show", "hide"],
|
|
6184
|
+
setup(props, {
|
|
6185
|
+
slots,
|
|
6186
|
+
attrs,
|
|
6187
|
+
emit
|
|
6188
|
+
}) {
|
|
6189
|
+
const {
|
|
6190
|
+
content,
|
|
6191
|
+
popType,
|
|
6192
|
+
position,
|
|
6193
|
+
align,
|
|
6194
|
+
offset: offset2,
|
|
6195
|
+
showAnimation
|
|
6196
|
+
} = toRefs(props);
|
|
6197
|
+
const origin = ref();
|
|
6198
|
+
const popoverRef = ref();
|
|
6199
|
+
const visible = ref(false);
|
|
6200
|
+
const {
|
|
6201
|
+
placement,
|
|
6202
|
+
handlePositionChange,
|
|
6203
|
+
onMouseenter,
|
|
6204
|
+
onMouseleave
|
|
6205
|
+
} = usePopoverEvent(props, visible, origin);
|
|
6206
|
+
const {
|
|
6207
|
+
overlayStyles
|
|
6208
|
+
} = usePopover(props, visible, placement, origin, popoverRef);
|
|
6209
|
+
const ns2 = useNamespace("popover");
|
|
6210
|
+
provide(POPPER_TRIGGER_TOKEN, origin);
|
|
6211
|
+
watch(visible, (newVal) => {
|
|
6212
|
+
if (newVal) {
|
|
6213
|
+
emit("show");
|
|
6214
|
+
} else {
|
|
6215
|
+
emit("hide");
|
|
6216
|
+
}
|
|
6217
|
+
});
|
|
6218
|
+
return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
|
|
6219
|
+
default: () => {
|
|
6220
|
+
var _a;
|
|
6221
|
+
return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
|
6222
|
+
}
|
|
6223
|
+
}), createVNode(Teleport, {
|
|
6224
|
+
"to": "body"
|
|
6225
|
+
}, {
|
|
6226
|
+
default: () => [createVNode(Transition, {
|
|
6227
|
+
"name": showAnimation.value ? ns2.m(`fade-${placement.value}`) : ""
|
|
6228
|
+
}, {
|
|
6229
|
+
default: () => [createVNode(FlexibleOverlay, mergeProps({
|
|
6230
|
+
"modelValue": visible.value,
|
|
6231
|
+
"onUpdate:modelValue": ($event) => visible.value = $event,
|
|
6232
|
+
"ref": popoverRef,
|
|
6233
|
+
"origin": origin.value,
|
|
6234
|
+
"position": position.value,
|
|
6235
|
+
"align": align.value,
|
|
6236
|
+
"offset": offset2.value,
|
|
6237
|
+
"class": [ns2.e("content"), popType.value !== "default" ? "is-icon" : ""],
|
|
6238
|
+
"show-arrow": true,
|
|
6239
|
+
"is-arrow-center": false,
|
|
6240
|
+
"style": overlayStyles.value
|
|
6241
|
+
}, attrs, {
|
|
6242
|
+
"onPositionChange": handlePositionChange,
|
|
6243
|
+
"onClick": withModifiers(() => ({}), ["stop"]),
|
|
6244
|
+
"onPointerup": withModifiers(() => ({}), ["stop"]),
|
|
6245
|
+
"onMouseenter": onMouseenter,
|
|
6246
|
+
"onMouseleave": onMouseleave
|
|
6247
|
+
}), {
|
|
6248
|
+
default: () => {
|
|
6249
|
+
var _a;
|
|
6250
|
+
return [createVNode(PopoverIcon, {
|
|
6251
|
+
"type": popType.value
|
|
6252
|
+
}, null), ((_a = slots.content) == null ? void 0 : _a.call(slots)) || createVNode("span", null, [content.value])];
|
|
6253
|
+
}
|
|
6254
|
+
})]
|
|
6255
|
+
})]
|
|
6256
|
+
})]);
|
|
6257
|
+
}
|
|
6258
|
+
});
|
|
6259
|
+
function HelpTipsIcon() {
|
|
6260
|
+
return createVNode("svg", {
|
|
6261
|
+
"width": "16px",
|
|
6262
|
+
"height": "16px",
|
|
6263
|
+
"viewBox": "0 0 16 16"
|
|
6264
|
+
}, [createVNode("g", {
|
|
6265
|
+
"stroke": "none",
|
|
6266
|
+
"stroke-width": "1",
|
|
6267
|
+
"fill": "none",
|
|
6268
|
+
"fill-rule": "evenodd"
|
|
6269
|
+
}, [createVNode("g", null, [createVNode("path", {
|
|
6270
|
+
"d": "M8.5,8.95852078 L8.5,11 L7.5,11 L7.5,8.5 C7.5,8.22385763 7.72385763,8 8,8 C9.1045695,8 10,7.1045695 10,6 C10,4.8954305 9.1045695,4 8,4 C6.8954305,4 6,4.8954305 6,6 L5,6 C5,4.34314575 6.34314575,3 8,3 C9.65685425,3 11,4.34314575 11,6 C11,7.48649814 9.91885667,8.72048173 8.5,8.95852078 L8.5,8.95852078 Z M8,16 C3.581722,16 0,12.418278 0,8 C0,3.581722 3.581722,0 8,0 C12.418278,0 16,3.581722 16,8 C16,12.418278 12.418278,16 8,16 Z M8,15 C11.8659932,15 15,11.8659932 15,8 C15,4.13400675 11.8659932,1 8,1 C4.13400675,1 1,4.13400675 1,8 C1,11.8659932 4.13400675,15 8,15 Z M7.5,12 L8.5,12 L8.5,13 L7.5,13 L7.5,12 Z",
|
|
6271
|
+
"fill": "#293040",
|
|
6272
|
+
"fill-rule": "nonzero"
|
|
6273
|
+
}, null)])])]);
|
|
6274
|
+
}
|
|
6275
|
+
function ErrorIcon() {
|
|
6276
|
+
return createVNode("svg", {
|
|
6277
|
+
"width": "14px",
|
|
6278
|
+
"height": "14px",
|
|
6279
|
+
"viewBox": "0 0 16 16"
|
|
6280
|
+
}, [createVNode("g", {
|
|
6281
|
+
"stroke": "none",
|
|
6282
|
+
"stroke-width": "1",
|
|
6283
|
+
"fill": "none",
|
|
6284
|
+
"fill-rule": "evenodd"
|
|
6285
|
+
}, [createVNode("circle", {
|
|
6286
|
+
"cx": "8",
|
|
6287
|
+
"cy": "8",
|
|
6288
|
+
"r": "8"
|
|
6289
|
+
}, null), createVNode("polygon", {
|
|
6290
|
+
"points": "8.07106781 6.65685425 10.8994949 3.82842712 12.3137085 5.24264069 9.48528137 8.07106781 12.3137085 10.8994949 10.8994949 12.3137085 8.07106781 9.48528137 5.24264069 12.3137085 3.82842712 10.8994949 6.65685425 8.07106781 3.82842712 5.24264069 5.24264069 3.82842712"
|
|
6291
|
+
}, null)])]);
|
|
6292
|
+
}
|
|
6293
|
+
function SuccessIcon() {
|
|
6294
|
+
return createVNode("svg", {
|
|
6295
|
+
"width": "14px",
|
|
6296
|
+
"height": "14px",
|
|
6297
|
+
"viewBox": "0 0 16 16"
|
|
6298
|
+
}, [createVNode("g", {
|
|
6299
|
+
"stroke": "none",
|
|
6300
|
+
"stroke-width": "1",
|
|
6301
|
+
"fill": "none",
|
|
6302
|
+
"fill-rule": "evenodd"
|
|
6303
|
+
}, [createVNode("circle", {
|
|
6304
|
+
"cx": "8",
|
|
6305
|
+
"cy": "8",
|
|
6306
|
+
"r": "8"
|
|
6307
|
+
}, null), createVNode("polygon", {
|
|
6308
|
+
"points": "6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459"
|
|
6309
|
+
}, null)])]);
|
|
6310
|
+
}
|
|
6311
|
+
function PendingIcon() {
|
|
6312
|
+
return createVNode("svg", {
|
|
6313
|
+
"width": "14px",
|
|
6314
|
+
"height": "14px",
|
|
6315
|
+
"viewBox": "0 0 16 16"
|
|
6316
|
+
}, [createVNode("g", {
|
|
6317
|
+
"id": "loading",
|
|
6318
|
+
"stroke": "none",
|
|
6319
|
+
"stroke-width": "1",
|
|
6320
|
+
"fill": "none",
|
|
6321
|
+
"fill-rule": "evenodd"
|
|
6322
|
+
}, [createVNode("path", {
|
|
6323
|
+
"d": "M8,0 C12.4,0 16,3.6 16,8 C16,12.4 12.4,16 8,16 C3.6,16 0,12.4 0,8 C0,3.6 3.6,0 8,0 Z M8,1 C4.15,1 1,4.15 1,8 C1,11.85 4.15,15 8,15 C11.85,15 15,11.85 15,8 C15,4.15 11.85,1 8,1 Z",
|
|
6324
|
+
"fill-rule": "nonzero"
|
|
6325
|
+
}, null), createVNode("path", {
|
|
6326
|
+
"d": "M8,0 C12.4,0 16,3.6 16,8 L15,8 C15,4.15 11.85,1 8,1 L8,0 Z",
|
|
6327
|
+
"fill-rule": "nonzero"
|
|
6328
|
+
}, null)])]);
|
|
6329
|
+
}
|
|
6330
|
+
function useFormLabel() {
|
|
6331
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6332
|
+
const labelData = inject(LABEL_DATA);
|
|
6333
|
+
const ns2 = useNamespace("form");
|
|
6334
|
+
const labelClasses = computed(() => ({
|
|
6335
|
+
[`${ns2.e("label")}`]: true,
|
|
6336
|
+
[`${ns2.em("label", "vertical")}`]: labelData.value.layout === "vertical",
|
|
6337
|
+
[`${ns2.em("label", labelData.value.labelSize)}`]: labelData.value.layout === "horizontal",
|
|
6338
|
+
[`${ns2.em("label", labelData.value.labelAlign)}`]: labelData.value.layout === "horizontal"
|
|
6339
|
+
}));
|
|
6340
|
+
const labelInnerClasses = computed(() => ({
|
|
6341
|
+
[`${ns2.e("label-span")}`]: true,
|
|
6342
|
+
[`${ns2.em("label", "required")}`]: formItemContext.isRequired
|
|
6343
|
+
}));
|
|
6344
|
+
return { labelClasses, labelInnerClasses };
|
|
6345
|
+
}
|
|
6346
|
+
var formLabel = "";
|
|
6347
|
+
var FormLabel = defineComponent({
|
|
6348
|
+
name: "DFormLabel",
|
|
6349
|
+
props: formLabelProps,
|
|
6350
|
+
setup(props, ctx) {
|
|
6351
|
+
const ns2 = useNamespace("form");
|
|
6352
|
+
const {
|
|
6353
|
+
labelClasses,
|
|
6354
|
+
labelInnerClasses
|
|
6355
|
+
} = useFormLabel();
|
|
6356
|
+
return () => {
|
|
6357
|
+
var _a, _b;
|
|
6358
|
+
return createVNode("span", {
|
|
6359
|
+
"class": labelClasses.value
|
|
6360
|
+
}, [createVNode("span", {
|
|
6361
|
+
"class": labelInnerClasses.value
|
|
6362
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), props.helpTips && createVNode(Popover, {
|
|
6363
|
+
"content": props.helpTips,
|
|
6364
|
+
"position": ["top"],
|
|
6365
|
+
"trigger": "hover",
|
|
6366
|
+
"pop-type": "info"
|
|
6367
|
+
}, {
|
|
6368
|
+
default: () => [createVNode(HelpTipsIcon, {
|
|
6369
|
+
"class": ns2.e("label-help")
|
|
6370
|
+
}, null), createTextVNode(",")]
|
|
6371
|
+
})]);
|
|
6372
|
+
};
|
|
6373
|
+
}
|
|
6374
|
+
});
|
|
6375
|
+
const formControlProps = {
|
|
6376
|
+
feedbackStatus: {
|
|
6377
|
+
type: String
|
|
6378
|
+
},
|
|
6379
|
+
extraInfo: {
|
|
6380
|
+
type: String,
|
|
6381
|
+
default: ""
|
|
6382
|
+
}
|
|
6383
|
+
};
|
|
6384
|
+
function useFormControl(props) {
|
|
6385
|
+
const labelData = inject(LABEL_DATA);
|
|
6386
|
+
const ns2 = useNamespace("form");
|
|
6387
|
+
const { feedbackStatus } = toRefs(props);
|
|
6388
|
+
const controlClasses = computed(() => ({
|
|
6389
|
+
[ns2.e("control")]: true,
|
|
6390
|
+
[ns2.em("control", "horizontal")]: labelData.value.layout === "horizontal"
|
|
6391
|
+
}));
|
|
6392
|
+
const controlContainerClasses = computed(() => ({
|
|
6393
|
+
[ns2.e("control-container")]: true,
|
|
6394
|
+
[ns2.em("control-container", "horizontal")]: labelData.value.layout === "horizontal",
|
|
6395
|
+
[ns2.em("control-container", "has-feedback")]: Boolean(feedbackStatus == null ? void 0 : feedbackStatus.value),
|
|
6396
|
+
[ns2.em("control-container", "feedback-error")]: Boolean((feedbackStatus == null ? void 0 : feedbackStatus.value) === "error")
|
|
6397
|
+
}));
|
|
6398
|
+
return { controlClasses, controlContainerClasses };
|
|
6399
|
+
}
|
|
6400
|
+
function useFormControlValidate() {
|
|
6401
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6402
|
+
const feedbackStatus = computed(() => formItemContext.validateState);
|
|
6403
|
+
const showFeedback = computed(() => formItemContext.showFeedback && Boolean(formItemContext.validateState));
|
|
6404
|
+
const showPopover = computed(() => formItemContext.messageType === "popover" && formItemContext.validateState === "error");
|
|
6405
|
+
const showMessage = computed(() => formItemContext.messageType === "text" && formItemContext.validateState === "error");
|
|
6406
|
+
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
6407
|
+
const popPosition = computed(() => formItemContext.popPosition);
|
|
6408
|
+
return { feedbackStatus, showFeedback, showPopover, showMessage, errorMessage, popPosition };
|
|
6409
|
+
}
|
|
6410
|
+
var formControl = "";
|
|
6411
|
+
var FormControl = defineComponent({
|
|
6412
|
+
name: "DFormControl",
|
|
6413
|
+
props: formControlProps,
|
|
6414
|
+
setup(props, ctx) {
|
|
6415
|
+
const formControl2 = ref();
|
|
6416
|
+
const ns2 = useNamespace("form");
|
|
6417
|
+
const {
|
|
6418
|
+
controlClasses,
|
|
6419
|
+
controlContainerClasses
|
|
6420
|
+
} = useFormControl(props);
|
|
6421
|
+
const {
|
|
6422
|
+
feedbackStatus,
|
|
6423
|
+
showFeedback,
|
|
6424
|
+
showPopover,
|
|
6425
|
+
showMessage,
|
|
6426
|
+
errorMessage,
|
|
6427
|
+
popPosition
|
|
6428
|
+
} = useFormControlValidate();
|
|
6429
|
+
return () => createVNode("div", {
|
|
6430
|
+
"class": controlClasses.value,
|
|
6431
|
+
"ref": formControl2
|
|
6432
|
+
}, [createVNode("div", {
|
|
6433
|
+
"class": controlContainerClasses.value
|
|
6434
|
+
}, [createVNode(Popover, {
|
|
6435
|
+
"is-open": showPopover.value,
|
|
6436
|
+
"trigger": "manually",
|
|
6437
|
+
"content": errorMessage.value,
|
|
6438
|
+
"pop-type": "error",
|
|
6439
|
+
"position": popPosition.value
|
|
6440
|
+
}, {
|
|
6441
|
+
default: () => {
|
|
6442
|
+
var _a, _b;
|
|
6443
|
+
return [createVNode("div", {
|
|
6444
|
+
"class": ns2.e("control-content")
|
|
6445
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createTextVNode(",")];
|
|
6446
|
+
}
|
|
6447
|
+
}), showFeedback.value && createVNode("span", {
|
|
6448
|
+
"class": [ns2.e("feedback-icon"), ns2.em("feedback-icon", feedbackStatus.value)]
|
|
6449
|
+
}, [feedbackStatus.value === "error" && createVNode(ErrorIcon, null, null), feedbackStatus.value === "success" && createVNode(SuccessIcon, null, null), feedbackStatus.value === "pending" && createVNode(PendingIcon, null, null)])]), createVNode("div", {
|
|
6450
|
+
"class": ns2.e("control-info")
|
|
6451
|
+
}, [showMessage.value && createVNode("div", {
|
|
6452
|
+
"class": "error-message"
|
|
6453
|
+
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
6454
|
+
"class": ns2.e("control-extra")
|
|
6455
|
+
}, [props.extraInfo])])]);
|
|
6456
|
+
}
|
|
6457
|
+
});
|
|
6458
|
+
function _extends() {
|
|
6459
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
6460
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
6461
|
+
var source = arguments[i];
|
|
6462
|
+
for (var key in source) {
|
|
6463
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
6464
|
+
target[key] = source[key];
|
|
6465
|
+
}
|
|
6466
|
+
}
|
|
6467
|
+
}
|
|
6468
|
+
return target;
|
|
6469
|
+
};
|
|
6470
|
+
return _extends.apply(this, arguments);
|
|
6471
|
+
}
|
|
6472
|
+
function _inheritsLoose(subClass, superClass) {
|
|
6473
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
6474
|
+
subClass.prototype.constructor = subClass;
|
|
6475
|
+
_setPrototypeOf(subClass, superClass);
|
|
6476
|
+
}
|
|
6477
|
+
function _getPrototypeOf(o) {
|
|
6478
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
|
6479
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
6480
|
+
};
|
|
6481
|
+
return _getPrototypeOf(o);
|
|
6482
|
+
}
|
|
6483
|
+
function _setPrototypeOf(o, p) {
|
|
6484
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
|
6485
|
+
o2.__proto__ = p2;
|
|
6486
|
+
return o2;
|
|
6487
|
+
};
|
|
6488
|
+
return _setPrototypeOf(o, p);
|
|
6489
|
+
}
|
|
6490
|
+
function _isNativeReflectConstruct() {
|
|
6491
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
6492
|
+
return false;
|
|
6493
|
+
if (Reflect.construct.sham)
|
|
6494
|
+
return false;
|
|
6495
|
+
if (typeof Proxy === "function")
|
|
6496
|
+
return true;
|
|
6497
|
+
try {
|
|
6498
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
6499
|
+
}));
|
|
6500
|
+
return true;
|
|
6501
|
+
} catch (e) {
|
|
6502
|
+
return false;
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
function _construct(Parent, args, Class) {
|
|
6506
|
+
if (_isNativeReflectConstruct()) {
|
|
6507
|
+
_construct = Reflect.construct.bind();
|
|
6508
|
+
} else {
|
|
6509
|
+
_construct = function _construct2(Parent2, args2, Class2) {
|
|
6510
|
+
var a = [null];
|
|
6511
|
+
a.push.apply(a, args2);
|
|
6512
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
6513
|
+
var instance = new Constructor();
|
|
6514
|
+
if (Class2)
|
|
6515
|
+
_setPrototypeOf(instance, Class2.prototype);
|
|
6516
|
+
return instance;
|
|
6517
|
+
};
|
|
6518
|
+
}
|
|
6519
|
+
return _construct.apply(null, arguments);
|
|
6520
|
+
}
|
|
6521
|
+
function _isNativeFunction(fn) {
|
|
6522
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
6523
|
+
}
|
|
6524
|
+
function _wrapNativeSuper(Class) {
|
|
6525
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
6526
|
+
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
|
6527
|
+
if (Class2 === null || !_isNativeFunction(Class2))
|
|
6528
|
+
return Class2;
|
|
6529
|
+
if (typeof Class2 !== "function") {
|
|
6530
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
6531
|
+
}
|
|
6532
|
+
if (typeof _cache !== "undefined") {
|
|
6533
|
+
if (_cache.has(Class2))
|
|
6534
|
+
return _cache.get(Class2);
|
|
6535
|
+
_cache.set(Class2, Wrapper);
|
|
6536
|
+
}
|
|
6537
|
+
function Wrapper() {
|
|
6538
|
+
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
|
6539
|
+
}
|
|
6540
|
+
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
6541
|
+
constructor: {
|
|
6542
|
+
value: Wrapper,
|
|
6543
|
+
enumerable: false,
|
|
6544
|
+
writable: true,
|
|
6545
|
+
configurable: true
|
|
6546
|
+
}
|
|
6547
|
+
});
|
|
6548
|
+
return _setPrototypeOf(Wrapper, Class2);
|
|
6549
|
+
};
|
|
6550
|
+
return _wrapNativeSuper(Class);
|
|
6551
|
+
}
|
|
6552
|
+
var formatRegExp = /%[sdj%]/g;
|
|
6553
|
+
var warning = function warning2() {
|
|
6554
|
+
};
|
|
6555
|
+
if (typeof process !== "undefined" && process.env && false) {
|
|
6556
|
+
warning = function warning3(type4, errors) {
|
|
6557
|
+
if (typeof console !== "undefined" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === "undefined") {
|
|
6558
|
+
if (errors.every(function(e) {
|
|
6559
|
+
return typeof e === "string";
|
|
6560
|
+
})) {
|
|
6561
|
+
console.warn(type4, errors);
|
|
6562
|
+
}
|
|
6563
|
+
}
|
|
6564
|
+
};
|
|
6565
|
+
}
|
|
6566
|
+
function convertFieldsError(errors) {
|
|
6567
|
+
if (!errors || !errors.length)
|
|
6568
|
+
return null;
|
|
6569
|
+
var fields = {};
|
|
6570
|
+
errors.forEach(function(error) {
|
|
6571
|
+
var field = error.field;
|
|
6572
|
+
fields[field] = fields[field] || [];
|
|
6573
|
+
fields[field].push(error);
|
|
6574
|
+
});
|
|
6575
|
+
return fields;
|
|
6576
|
+
}
|
|
6577
|
+
function format(template) {
|
|
6578
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
6579
|
+
args[_key - 1] = arguments[_key];
|
|
6580
|
+
}
|
|
6581
|
+
var i = 0;
|
|
6582
|
+
var len = args.length;
|
|
6583
|
+
if (typeof template === "function") {
|
|
6584
|
+
return template.apply(null, args);
|
|
6585
|
+
}
|
|
6586
|
+
if (typeof template === "string") {
|
|
6587
|
+
var str = template.replace(formatRegExp, function(x) {
|
|
6588
|
+
if (x === "%%") {
|
|
6589
|
+
return "%";
|
|
6590
|
+
}
|
|
6591
|
+
if (i >= len) {
|
|
6592
|
+
return x;
|
|
6593
|
+
}
|
|
6594
|
+
switch (x) {
|
|
6595
|
+
case "%s":
|
|
6596
|
+
return String(args[i++]);
|
|
6597
|
+
case "%d":
|
|
6598
|
+
return Number(args[i++]);
|
|
6599
|
+
case "%j":
|
|
6600
|
+
try {
|
|
6601
|
+
return JSON.stringify(args[i++]);
|
|
6602
|
+
} catch (_) {
|
|
6603
|
+
return "[Circular]";
|
|
6604
|
+
}
|
|
6605
|
+
break;
|
|
6606
|
+
default:
|
|
6607
|
+
return x;
|
|
6608
|
+
}
|
|
6609
|
+
});
|
|
6610
|
+
return str;
|
|
6611
|
+
}
|
|
6612
|
+
return template;
|
|
6613
|
+
}
|
|
6614
|
+
function isNativeStringType(type4) {
|
|
6615
|
+
return type4 === "string" || type4 === "url" || type4 === "hex" || type4 === "email" || type4 === "date" || type4 === "pattern";
|
|
6616
|
+
}
|
|
6617
|
+
function isEmptyValue(value, type4) {
|
|
6618
|
+
if (value === void 0 || value === null) {
|
|
6619
|
+
return true;
|
|
6620
|
+
}
|
|
6621
|
+
if (type4 === "array" && Array.isArray(value) && !value.length) {
|
|
6622
|
+
return true;
|
|
6623
|
+
}
|
|
6624
|
+
if (isNativeStringType(type4) && typeof value === "string" && !value) {
|
|
6625
|
+
return true;
|
|
6626
|
+
}
|
|
6627
|
+
return false;
|
|
6628
|
+
}
|
|
6629
|
+
function asyncParallelArray(arr, func, callback) {
|
|
6630
|
+
var results = [];
|
|
6631
|
+
var total = 0;
|
|
6632
|
+
var arrLength = arr.length;
|
|
6633
|
+
function count(errors) {
|
|
6634
|
+
results.push.apply(results, errors || []);
|
|
6635
|
+
total++;
|
|
6636
|
+
if (total === arrLength) {
|
|
6637
|
+
callback(results);
|
|
6638
|
+
}
|
|
6639
|
+
}
|
|
6640
|
+
arr.forEach(function(a) {
|
|
6641
|
+
func(a, count);
|
|
6642
|
+
});
|
|
6643
|
+
}
|
|
6644
|
+
function asyncSerialArray(arr, func, callback) {
|
|
6645
|
+
var index2 = 0;
|
|
6646
|
+
var arrLength = arr.length;
|
|
6647
|
+
function next(errors) {
|
|
6648
|
+
if (errors && errors.length) {
|
|
6649
|
+
callback(errors);
|
|
6650
|
+
return;
|
|
6651
|
+
}
|
|
6652
|
+
var original = index2;
|
|
6653
|
+
index2 = index2 + 1;
|
|
6654
|
+
if (original < arrLength) {
|
|
6655
|
+
func(arr[original], next);
|
|
6656
|
+
} else {
|
|
6657
|
+
callback([]);
|
|
6658
|
+
}
|
|
6659
|
+
}
|
|
6660
|
+
next([]);
|
|
6661
|
+
}
|
|
6662
|
+
function flattenObjArr(objArr) {
|
|
6663
|
+
var ret = [];
|
|
6664
|
+
Object.keys(objArr).forEach(function(k) {
|
|
6665
|
+
ret.push.apply(ret, objArr[k] || []);
|
|
6666
|
+
});
|
|
6667
|
+
return ret;
|
|
6668
|
+
}
|
|
6669
|
+
var AsyncValidationError = /* @__PURE__ */ function(_Error) {
|
|
6670
|
+
_inheritsLoose(AsyncValidationError2, _Error);
|
|
6671
|
+
function AsyncValidationError2(errors, fields) {
|
|
6672
|
+
var _this;
|
|
6673
|
+
_this = _Error.call(this, "Async Validation Error") || this;
|
|
6674
|
+
_this.errors = errors;
|
|
6675
|
+
_this.fields = fields;
|
|
6676
|
+
return _this;
|
|
6677
|
+
}
|
|
6678
|
+
return AsyncValidationError2;
|
|
6679
|
+
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
6680
|
+
function asyncMap(objArr, option, func, callback, source) {
|
|
6681
|
+
if (option.first) {
|
|
6682
|
+
var _pending = new Promise(function(resolve, reject) {
|
|
6683
|
+
var next = function next2(errors) {
|
|
6684
|
+
callback(errors);
|
|
6685
|
+
return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
|
|
6919
6686
|
};
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6687
|
+
var flattenArr = flattenObjArr(objArr);
|
|
6688
|
+
asyncSerialArray(flattenArr, func, next);
|
|
6689
|
+
});
|
|
6690
|
+
_pending["catch"](function(e) {
|
|
6691
|
+
return e;
|
|
6692
|
+
});
|
|
6693
|
+
return _pending;
|
|
6694
|
+
}
|
|
6695
|
+
var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
|
|
6696
|
+
var objArrKeys = Object.keys(objArr);
|
|
6697
|
+
var objArrLength = objArrKeys.length;
|
|
6698
|
+
var total = 0;
|
|
6699
|
+
var results = [];
|
|
6700
|
+
var pending = new Promise(function(resolve, reject) {
|
|
6701
|
+
var next = function next2(errors) {
|
|
6702
|
+
results.push.apply(results, errors);
|
|
6703
|
+
total++;
|
|
6704
|
+
if (total === objArrLength) {
|
|
6705
|
+
callback(results);
|
|
6706
|
+
return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
|
|
6707
|
+
}
|
|
6708
|
+
};
|
|
6709
|
+
if (!objArrKeys.length) {
|
|
6710
|
+
callback(results);
|
|
6711
|
+
resolve(source);
|
|
6712
|
+
}
|
|
6713
|
+
objArrKeys.forEach(function(key) {
|
|
6714
|
+
var arr = objArr[key];
|
|
6715
|
+
if (firstFields.indexOf(key) !== -1) {
|
|
6716
|
+
asyncSerialArray(arr, func, next);
|
|
6717
|
+
} else {
|
|
6718
|
+
asyncParallelArray(arr, func, next);
|
|
6719
|
+
}
|
|
6720
|
+
});
|
|
6721
|
+
});
|
|
6722
|
+
pending["catch"](function(e) {
|
|
6723
|
+
return e;
|
|
6724
|
+
});
|
|
6725
|
+
return pending;
|
|
6726
|
+
}
|
|
6727
|
+
function isErrorObj(obj) {
|
|
6728
|
+
return !!(obj && obj.message !== void 0);
|
|
6729
|
+
}
|
|
6730
|
+
function getValue(value, path) {
|
|
6731
|
+
var v = value;
|
|
6732
|
+
for (var i = 0; i < path.length; i++) {
|
|
6733
|
+
if (v == void 0) {
|
|
6734
|
+
return v;
|
|
6735
|
+
}
|
|
6736
|
+
v = v[path[i]];
|
|
6737
|
+
}
|
|
6738
|
+
return v;
|
|
6739
|
+
}
|
|
6740
|
+
function complementError(rule, source) {
|
|
6741
|
+
return function(oe) {
|
|
6742
|
+
var fieldValue;
|
|
6743
|
+
if (rule.fullFields) {
|
|
6744
|
+
fieldValue = getValue(source, rule.fullFields);
|
|
6745
|
+
} else {
|
|
6746
|
+
fieldValue = source[oe.field || rule.fullField];
|
|
6747
|
+
}
|
|
6748
|
+
if (isErrorObj(oe)) {
|
|
6749
|
+
oe.field = oe.field || rule.fullField;
|
|
6750
|
+
oe.fieldValue = fieldValue;
|
|
6751
|
+
return oe;
|
|
6752
|
+
}
|
|
6753
|
+
return {
|
|
6754
|
+
message: typeof oe === "function" ? oe() : oe,
|
|
6755
|
+
fieldValue,
|
|
6756
|
+
field: oe.field || rule.fullField
|
|
6757
|
+
};
|
|
6758
|
+
};
|
|
6759
|
+
}
|
|
6760
|
+
function deepMerge(target, source) {
|
|
6761
|
+
if (source) {
|
|
6762
|
+
for (var s in source) {
|
|
6763
|
+
if (source.hasOwnProperty(s)) {
|
|
6764
|
+
var value = source[s];
|
|
6765
|
+
if (typeof value === "object" && typeof target[s] === "object") {
|
|
6766
|
+
target[s] = _extends({}, target[s], value);
|
|
6767
|
+
} else {
|
|
6768
|
+
target[s] = value;
|
|
6923
6769
|
}
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6770
|
+
}
|
|
6771
|
+
}
|
|
6772
|
+
}
|
|
6773
|
+
return target;
|
|
6774
|
+
}
|
|
6775
|
+
var required$1 = function required(rule, value, source, errors, options, type4) {
|
|
6776
|
+
if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type4 || rule.type))) {
|
|
6777
|
+
errors.push(format(options.messages.required, rule.fullField));
|
|
6778
|
+
}
|
|
6779
|
+
};
|
|
6780
|
+
var whitespace = function whitespace2(rule, value, source, errors, options) {
|
|
6781
|
+
if (/^\s+$/.test(value) || value === "") {
|
|
6782
|
+
errors.push(format(options.messages.whitespace, rule.fullField));
|
|
6783
|
+
}
|
|
6784
|
+
};
|
|
6785
|
+
var urlReg;
|
|
6786
|
+
var getUrlRegex = function() {
|
|
6787
|
+
if (urlReg) {
|
|
6788
|
+
return urlReg;
|
|
6789
|
+
}
|
|
6790
|
+
var word = "[a-fA-F\\d:]";
|
|
6791
|
+
var b = function b2(options) {
|
|
6792
|
+
return options && options.includeBoundaries ? "(?:(?<=\\s|^)(?=" + word + ")|(?<=" + word + ")(?=\\s|$))" : "";
|
|
6793
|
+
};
|
|
6794
|
+
var v4 = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}";
|
|
6795
|
+
var v6seg = "[a-fA-F\\d]{1,4}";
|
|
6796
|
+
var v6 = ("\n(?:\n(?:" + v6seg + ":){7}(?:" + v6seg + "|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:" + v6seg + ":){6}(?:" + v4 + "|:" + v6seg + "|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:" + v6seg + ":){5}(?::" + v4 + "|(?::" + v6seg + "){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:" + v6seg + ":){4}(?:(?::" + v6seg + "){0,1}:" + v4 + "|(?::" + v6seg + "){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:" + v6seg + ":){3}(?:(?::" + v6seg + "){0,2}:" + v4 + "|(?::" + v6seg + "){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:" + v6seg + ":){2}(?:(?::" + v6seg + "){0,3}:" + v4 + "|(?::" + v6seg + "){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:" + v6seg + ":){1}(?:(?::" + v6seg + "){0,4}:" + v4 + "|(?::" + v6seg + "){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::" + v6seg + "){0,5}:" + v4 + "|(?::" + v6seg + "){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim();
|
|
6797
|
+
var v46Exact = new RegExp("(?:^" + v4 + "$)|(?:^" + v6 + "$)");
|
|
6798
|
+
var v4exact = new RegExp("^" + v4 + "$");
|
|
6799
|
+
var v6exact = new RegExp("^" + v6 + "$");
|
|
6800
|
+
var ip = function ip2(options) {
|
|
6801
|
+
return options && options.exact ? v46Exact : new RegExp("(?:" + b(options) + v4 + b(options) + ")|(?:" + b(options) + v6 + b(options) + ")", "g");
|
|
6802
|
+
};
|
|
6803
|
+
ip.v4 = function(options) {
|
|
6804
|
+
return options && options.exact ? v4exact : new RegExp("" + b(options) + v4 + b(options), "g");
|
|
6805
|
+
};
|
|
6806
|
+
ip.v6 = function(options) {
|
|
6807
|
+
return options && options.exact ? v6exact : new RegExp("" + b(options) + v6 + b(options), "g");
|
|
6808
|
+
};
|
|
6809
|
+
var protocol = "(?:(?:[a-z]+:)?//)";
|
|
6810
|
+
var auth = "(?:\\S+(?::\\S*)?@)?";
|
|
6811
|
+
var ipv4 = ip.v4().source;
|
|
6812
|
+
var ipv6 = ip.v6().source;
|
|
6813
|
+
var host = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)";
|
|
6814
|
+
var domain = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*";
|
|
6815
|
+
var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
|
|
6816
|
+
var port = "(?::\\d{2,5})?";
|
|
6817
|
+
var path = '(?:[/?#][^\\s"]*)?';
|
|
6818
|
+
var regex = "(?:" + protocol + "|www\\.)" + auth + "(?:localhost|" + ipv4 + "|" + ipv6 + "|" + host + domain + tld + ")" + port + path;
|
|
6819
|
+
urlReg = new RegExp("(?:^" + regex + "$)", "i");
|
|
6820
|
+
return urlReg;
|
|
6821
|
+
};
|
|
6822
|
+
var pattern$2 = {
|
|
6823
|
+
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
|
|
6824
|
+
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
|
6825
|
+
};
|
|
6826
|
+
var types = {
|
|
6827
|
+
integer: function integer(value) {
|
|
6828
|
+
return types.number(value) && parseInt(value, 10) === value;
|
|
6829
|
+
},
|
|
6830
|
+
"float": function float(value) {
|
|
6831
|
+
return types.number(value) && !types.integer(value);
|
|
6832
|
+
},
|
|
6833
|
+
array: function array(value) {
|
|
6834
|
+
return Array.isArray(value);
|
|
6835
|
+
},
|
|
6836
|
+
regexp: function regexp(value) {
|
|
6837
|
+
if (value instanceof RegExp) {
|
|
6838
|
+
return true;
|
|
6839
|
+
}
|
|
6840
|
+
try {
|
|
6841
|
+
return !!new RegExp(value);
|
|
6842
|
+
} catch (e) {
|
|
6843
|
+
return false;
|
|
6844
|
+
}
|
|
6845
|
+
},
|
|
6846
|
+
date: function date(value) {
|
|
6847
|
+
return typeof value.getTime === "function" && typeof value.getMonth === "function" && typeof value.getYear === "function" && !isNaN(value.getTime());
|
|
6848
|
+
},
|
|
6849
|
+
number: function number(value) {
|
|
6850
|
+
if (isNaN(value)) {
|
|
6851
|
+
return false;
|
|
6852
|
+
}
|
|
6853
|
+
return typeof value === "number";
|
|
6854
|
+
},
|
|
6855
|
+
object: function object(value) {
|
|
6856
|
+
return typeof value === "object" && !types.array(value);
|
|
6857
|
+
},
|
|
6858
|
+
method: function method(value) {
|
|
6859
|
+
return typeof value === "function";
|
|
6860
|
+
},
|
|
6861
|
+
email: function email(value) {
|
|
6862
|
+
return typeof value === "string" && value.length <= 320 && !!value.match(pattern$2.email);
|
|
6863
|
+
},
|
|
6864
|
+
url: function url(value) {
|
|
6865
|
+
return typeof value === "string" && value.length <= 2048 && !!value.match(getUrlRegex());
|
|
6866
|
+
},
|
|
6867
|
+
hex: function hex(value) {
|
|
6868
|
+
return typeof value === "string" && !!value.match(pattern$2.hex);
|
|
6869
|
+
}
|
|
6870
|
+
};
|
|
6871
|
+
var type$1 = function type(rule, value, source, errors, options) {
|
|
6872
|
+
if (rule.required && value === void 0) {
|
|
6873
|
+
required$1(rule, value, source, errors, options);
|
|
6874
|
+
return;
|
|
6875
|
+
}
|
|
6876
|
+
var custom = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"];
|
|
6877
|
+
var ruleType = rule.type;
|
|
6878
|
+
if (custom.indexOf(ruleType) > -1) {
|
|
6879
|
+
if (!types[ruleType](value)) {
|
|
6880
|
+
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
6881
|
+
}
|
|
6882
|
+
} else if (ruleType && typeof value !== rule.type) {
|
|
6883
|
+
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
6884
|
+
}
|
|
6885
|
+
};
|
|
6886
|
+
var range = function range2(rule, value, source, errors, options) {
|
|
6887
|
+
var len = typeof rule.len === "number";
|
|
6888
|
+
var min = typeof rule.min === "number";
|
|
6889
|
+
var max = typeof rule.max === "number";
|
|
6890
|
+
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
6891
|
+
var val = value;
|
|
6892
|
+
var key = null;
|
|
6893
|
+
var num = typeof value === "number";
|
|
6894
|
+
var str = typeof value === "string";
|
|
6895
|
+
var arr = Array.isArray(value);
|
|
6896
|
+
if (num) {
|
|
6897
|
+
key = "number";
|
|
6898
|
+
} else if (str) {
|
|
6899
|
+
key = "string";
|
|
6900
|
+
} else if (arr) {
|
|
6901
|
+
key = "array";
|
|
6902
|
+
}
|
|
6903
|
+
if (!key) {
|
|
6904
|
+
return false;
|
|
6905
|
+
}
|
|
6906
|
+
if (arr) {
|
|
6907
|
+
val = value.length;
|
|
6908
|
+
}
|
|
6909
|
+
if (str) {
|
|
6910
|
+
val = value.replace(spRegexp, "_").length;
|
|
6911
|
+
}
|
|
6912
|
+
if (len) {
|
|
6913
|
+
if (val !== rule.len) {
|
|
6914
|
+
errors.push(format(options.messages[key].len, rule.fullField, rule.len));
|
|
6915
|
+
}
|
|
6916
|
+
} else if (min && !max && val < rule.min) {
|
|
6917
|
+
errors.push(format(options.messages[key].min, rule.fullField, rule.min));
|
|
6918
|
+
} else if (max && !min && val > rule.max) {
|
|
6919
|
+
errors.push(format(options.messages[key].max, rule.fullField, rule.max));
|
|
6920
|
+
} else if (min && max && (val < rule.min || val > rule.max)) {
|
|
6921
|
+
errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
|
|
6922
|
+
}
|
|
6923
|
+
};
|
|
6924
|
+
var ENUM$1 = "enum";
|
|
6925
|
+
var enumerable$1 = function enumerable(rule, value, source, errors, options) {
|
|
6926
|
+
rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
|
|
6927
|
+
if (rule[ENUM$1].indexOf(value) === -1) {
|
|
6928
|
+
errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(", ")));
|
|
6929
|
+
}
|
|
6930
|
+
};
|
|
6931
|
+
var pattern$1 = function pattern(rule, value, source, errors, options) {
|
|
6932
|
+
if (rule.pattern) {
|
|
6933
|
+
if (rule.pattern instanceof RegExp) {
|
|
6934
|
+
rule.pattern.lastIndex = 0;
|
|
6935
|
+
if (!rule.pattern.test(value)) {
|
|
6936
|
+
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
6937
|
+
}
|
|
6938
|
+
} else if (typeof rule.pattern === "string") {
|
|
6939
|
+
var _pattern = new RegExp(rule.pattern);
|
|
6940
|
+
if (!_pattern.test(value)) {
|
|
6941
|
+
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6945
|
+
};
|
|
6946
|
+
var rules = {
|
|
6947
|
+
required: required$1,
|
|
6948
|
+
whitespace,
|
|
6949
|
+
type: type$1,
|
|
6950
|
+
range,
|
|
6951
|
+
"enum": enumerable$1,
|
|
6952
|
+
pattern: pattern$1
|
|
6953
|
+
};
|
|
6954
|
+
var string = function string2(rule, value, callback, source, options) {
|
|
6955
|
+
var errors = [];
|
|
6956
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
6957
|
+
if (validate) {
|
|
6958
|
+
if (isEmptyValue(value, "string") && !rule.required) {
|
|
6959
|
+
return callback();
|
|
6960
|
+
}
|
|
6961
|
+
rules.required(rule, value, source, errors, options, "string");
|
|
6962
|
+
if (!isEmptyValue(value, "string")) {
|
|
6963
|
+
rules.type(rule, value, source, errors, options);
|
|
6964
|
+
rules.range(rule, value, source, errors, options);
|
|
6965
|
+
rules.pattern(rule, value, source, errors, options);
|
|
6966
|
+
if (rule.whitespace === true) {
|
|
6967
|
+
rules.whitespace(rule, value, source, errors, options);
|
|
6968
|
+
}
|
|
6969
|
+
}
|
|
6970
|
+
}
|
|
6971
|
+
callback(errors);
|
|
6972
|
+
};
|
|
6973
|
+
var method2 = function method3(rule, value, callback, source, options) {
|
|
6974
|
+
var errors = [];
|
|
6975
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
6976
|
+
if (validate) {
|
|
6977
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
6978
|
+
return callback();
|
|
6979
|
+
}
|
|
6980
|
+
rules.required(rule, value, source, errors, options);
|
|
6981
|
+
if (value !== void 0) {
|
|
6982
|
+
rules.type(rule, value, source, errors, options);
|
|
6983
|
+
}
|
|
6984
|
+
}
|
|
6985
|
+
callback(errors);
|
|
6986
|
+
};
|
|
6987
|
+
var number2 = function number3(rule, value, callback, source, options) {
|
|
6988
|
+
var errors = [];
|
|
6989
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
6990
|
+
if (validate) {
|
|
6991
|
+
if (value === "") {
|
|
6992
|
+
value = void 0;
|
|
6993
|
+
}
|
|
6994
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
6995
|
+
return callback();
|
|
6996
|
+
}
|
|
6997
|
+
rules.required(rule, value, source, errors, options);
|
|
6998
|
+
if (value !== void 0) {
|
|
6999
|
+
rules.type(rule, value, source, errors, options);
|
|
7000
|
+
rules.range(rule, value, source, errors, options);
|
|
7001
|
+
}
|
|
7002
|
+
}
|
|
7003
|
+
callback(errors);
|
|
7004
|
+
};
|
|
7005
|
+
var _boolean = function _boolean2(rule, value, callback, source, options) {
|
|
7006
|
+
var errors = [];
|
|
7007
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7008
|
+
if (validate) {
|
|
7009
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
7010
|
+
return callback();
|
|
7011
|
+
}
|
|
7012
|
+
rules.required(rule, value, source, errors, options);
|
|
7013
|
+
if (value !== void 0) {
|
|
7014
|
+
rules.type(rule, value, source, errors, options);
|
|
7015
|
+
}
|
|
7016
|
+
}
|
|
7017
|
+
callback(errors);
|
|
7018
|
+
};
|
|
7019
|
+
var regexp2 = function regexp3(rule, value, callback, source, options) {
|
|
7020
|
+
var errors = [];
|
|
7021
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7022
|
+
if (validate) {
|
|
7023
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
7024
|
+
return callback();
|
|
7025
|
+
}
|
|
7026
|
+
rules.required(rule, value, source, errors, options);
|
|
7027
|
+
if (!isEmptyValue(value)) {
|
|
7028
|
+
rules.type(rule, value, source, errors, options);
|
|
7029
|
+
}
|
|
7030
|
+
}
|
|
7031
|
+
callback(errors);
|
|
7032
|
+
};
|
|
7033
|
+
var integer2 = function integer3(rule, value, callback, source, options) {
|
|
7034
|
+
var errors = [];
|
|
7035
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7036
|
+
if (validate) {
|
|
7037
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
7038
|
+
return callback();
|
|
7039
|
+
}
|
|
7040
|
+
rules.required(rule, value, source, errors, options);
|
|
7041
|
+
if (value !== void 0) {
|
|
7042
|
+
rules.type(rule, value, source, errors, options);
|
|
7043
|
+
rules.range(rule, value, source, errors, options);
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
callback(errors);
|
|
7047
|
+
};
|
|
7048
|
+
var floatFn = function floatFn2(rule, value, callback, source, options) {
|
|
7049
|
+
var errors = [];
|
|
7050
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7051
|
+
if (validate) {
|
|
7052
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
7053
|
+
return callback();
|
|
7054
|
+
}
|
|
7055
|
+
rules.required(rule, value, source, errors, options);
|
|
7056
|
+
if (value !== void 0) {
|
|
7057
|
+
rules.type(rule, value, source, errors, options);
|
|
7058
|
+
rules.range(rule, value, source, errors, options);
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
callback(errors);
|
|
7062
|
+
};
|
|
7063
|
+
var array2 = function array3(rule, value, callback, source, options) {
|
|
7064
|
+
var errors = [];
|
|
7065
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7066
|
+
if (validate) {
|
|
7067
|
+
if ((value === void 0 || value === null) && !rule.required) {
|
|
7068
|
+
return callback();
|
|
7069
|
+
}
|
|
7070
|
+
rules.required(rule, value, source, errors, options, "array");
|
|
7071
|
+
if (value !== void 0 && value !== null) {
|
|
7072
|
+
rules.type(rule, value, source, errors, options);
|
|
7073
|
+
rules.range(rule, value, source, errors, options);
|
|
7074
|
+
}
|
|
7075
|
+
}
|
|
7076
|
+
callback(errors);
|
|
7077
|
+
};
|
|
7078
|
+
var object2 = function object3(rule, value, callback, source, options) {
|
|
7079
|
+
var errors = [];
|
|
7080
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7081
|
+
if (validate) {
|
|
7082
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
7083
|
+
return callback();
|
|
7084
|
+
}
|
|
7085
|
+
rules.required(rule, value, source, errors, options);
|
|
7086
|
+
if (value !== void 0) {
|
|
7087
|
+
rules.type(rule, value, source, errors, options);
|
|
7088
|
+
}
|
|
7089
|
+
}
|
|
7090
|
+
callback(errors);
|
|
7091
|
+
};
|
|
7092
|
+
var ENUM = "enum";
|
|
7093
|
+
var enumerable2 = function enumerable3(rule, value, callback, source, options) {
|
|
7094
|
+
var errors = [];
|
|
7095
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7096
|
+
if (validate) {
|
|
7097
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
7098
|
+
return callback();
|
|
7099
|
+
}
|
|
7100
|
+
rules.required(rule, value, source, errors, options);
|
|
7101
|
+
if (value !== void 0) {
|
|
7102
|
+
rules[ENUM](rule, value, source, errors, options);
|
|
7103
|
+
}
|
|
7104
|
+
}
|
|
7105
|
+
callback(errors);
|
|
7106
|
+
};
|
|
7107
|
+
var pattern2 = function pattern3(rule, value, callback, source, options) {
|
|
7108
|
+
var errors = [];
|
|
7109
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7110
|
+
if (validate) {
|
|
7111
|
+
if (isEmptyValue(value, "string") && !rule.required) {
|
|
7112
|
+
return callback();
|
|
7113
|
+
}
|
|
7114
|
+
rules.required(rule, value, source, errors, options);
|
|
7115
|
+
if (!isEmptyValue(value, "string")) {
|
|
7116
|
+
rules.pattern(rule, value, source, errors, options);
|
|
7117
|
+
}
|
|
7118
|
+
}
|
|
7119
|
+
callback(errors);
|
|
7120
|
+
};
|
|
7121
|
+
var date2 = function date3(rule, value, callback, source, options) {
|
|
7122
|
+
var errors = [];
|
|
7123
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7124
|
+
if (validate) {
|
|
7125
|
+
if (isEmptyValue(value, "date") && !rule.required) {
|
|
7126
|
+
return callback();
|
|
7127
|
+
}
|
|
7128
|
+
rules.required(rule, value, source, errors, options);
|
|
7129
|
+
if (!isEmptyValue(value, "date")) {
|
|
7130
|
+
var dateObject;
|
|
7131
|
+
if (value instanceof Date) {
|
|
7132
|
+
dateObject = value;
|
|
7133
|
+
} else {
|
|
7134
|
+
dateObject = new Date(value);
|
|
7135
|
+
}
|
|
7136
|
+
rules.type(rule, dateObject, source, errors, options);
|
|
7137
|
+
if (dateObject) {
|
|
7138
|
+
rules.range(rule, dateObject.getTime(), source, errors, options);
|
|
7139
|
+
}
|
|
7140
|
+
}
|
|
7141
|
+
}
|
|
7142
|
+
callback(errors);
|
|
7143
|
+
};
|
|
7144
|
+
var required2 = function required3(rule, value, callback, source, options) {
|
|
7145
|
+
var errors = [];
|
|
7146
|
+
var type4 = Array.isArray(value) ? "array" : typeof value;
|
|
7147
|
+
rules.required(rule, value, source, errors, options, type4);
|
|
7148
|
+
callback(errors);
|
|
7149
|
+
};
|
|
7150
|
+
var type2 = function type3(rule, value, callback, source, options) {
|
|
7151
|
+
var ruleType = rule.type;
|
|
7152
|
+
var errors = [];
|
|
7153
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7154
|
+
if (validate) {
|
|
7155
|
+
if (isEmptyValue(value, ruleType) && !rule.required) {
|
|
7156
|
+
return callback();
|
|
7157
|
+
}
|
|
7158
|
+
rules.required(rule, value, source, errors, options, ruleType);
|
|
7159
|
+
if (!isEmptyValue(value, ruleType)) {
|
|
7160
|
+
rules.type(rule, value, source, errors, options);
|
|
7161
|
+
}
|
|
7162
|
+
}
|
|
7163
|
+
callback(errors);
|
|
7164
|
+
};
|
|
7165
|
+
var any = function any2(rule, value, callback, source, options) {
|
|
7166
|
+
var errors = [];
|
|
7167
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
7168
|
+
if (validate) {
|
|
7169
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
7170
|
+
return callback();
|
|
7171
|
+
}
|
|
7172
|
+
rules.required(rule, value, source, errors, options);
|
|
7173
|
+
}
|
|
7174
|
+
callback(errors);
|
|
7175
|
+
};
|
|
7176
|
+
var validators = {
|
|
7177
|
+
string,
|
|
7178
|
+
method: method2,
|
|
7179
|
+
number: number2,
|
|
7180
|
+
"boolean": _boolean,
|
|
7181
|
+
regexp: regexp2,
|
|
7182
|
+
integer: integer2,
|
|
7183
|
+
"float": floatFn,
|
|
7184
|
+
array: array2,
|
|
7185
|
+
object: object2,
|
|
7186
|
+
"enum": enumerable2,
|
|
7187
|
+
pattern: pattern2,
|
|
7188
|
+
date: date2,
|
|
7189
|
+
url: type2,
|
|
7190
|
+
hex: type2,
|
|
7191
|
+
email: type2,
|
|
7192
|
+
required: required2,
|
|
7193
|
+
any
|
|
7194
|
+
};
|
|
7195
|
+
function newMessages() {
|
|
7196
|
+
return {
|
|
7197
|
+
"default": "Validation error on field %s",
|
|
7198
|
+
required: "%s is required",
|
|
7199
|
+
"enum": "%s must be one of %s",
|
|
7200
|
+
whitespace: "%s cannot be empty",
|
|
7201
|
+
date: {
|
|
7202
|
+
format: "%s date %s is invalid for format %s",
|
|
7203
|
+
parse: "%s date could not be parsed, %s is invalid ",
|
|
7204
|
+
invalid: "%s date %s is invalid"
|
|
7205
|
+
},
|
|
7206
|
+
types: {
|
|
7207
|
+
string: "%s is not a %s",
|
|
7208
|
+
method: "%s is not a %s (function)",
|
|
7209
|
+
array: "%s is not an %s",
|
|
7210
|
+
object: "%s is not an %s",
|
|
7211
|
+
number: "%s is not a %s",
|
|
7212
|
+
date: "%s is not a %s",
|
|
7213
|
+
"boolean": "%s is not a %s",
|
|
7214
|
+
integer: "%s is not an %s",
|
|
7215
|
+
"float": "%s is not a %s",
|
|
7216
|
+
regexp: "%s is not a valid %s",
|
|
7217
|
+
email: "%s is not a valid %s",
|
|
7218
|
+
url: "%s is not a valid %s",
|
|
7219
|
+
hex: "%s is not a valid %s"
|
|
7220
|
+
},
|
|
7221
|
+
string: {
|
|
7222
|
+
len: "%s must be exactly %s characters",
|
|
7223
|
+
min: "%s must be at least %s characters",
|
|
7224
|
+
max: "%s cannot be longer than %s characters",
|
|
7225
|
+
range: "%s must be between %s and %s characters"
|
|
7226
|
+
},
|
|
7227
|
+
number: {
|
|
7228
|
+
len: "%s must equal %s",
|
|
7229
|
+
min: "%s cannot be less than %s",
|
|
7230
|
+
max: "%s cannot be greater than %s",
|
|
7231
|
+
range: "%s must be between %s and %s"
|
|
7232
|
+
},
|
|
7233
|
+
array: {
|
|
7234
|
+
len: "%s must be exactly %s in length",
|
|
7235
|
+
min: "%s cannot be less than %s in length",
|
|
7236
|
+
max: "%s cannot be greater than %s in length",
|
|
7237
|
+
range: "%s must be between %s and %s in length"
|
|
7238
|
+
},
|
|
7239
|
+
pattern: {
|
|
7240
|
+
mismatch: "%s value %s does not match pattern %s"
|
|
7241
|
+
},
|
|
7242
|
+
clone: function clone() {
|
|
7243
|
+
var cloned = JSON.parse(JSON.stringify(this));
|
|
7244
|
+
cloned.clone = this.clone;
|
|
7245
|
+
return cloned;
|
|
7246
|
+
}
|
|
7247
|
+
};
|
|
7248
|
+
}
|
|
7249
|
+
var messages = newMessages();
|
|
7250
|
+
var Schema = /* @__PURE__ */ function() {
|
|
7251
|
+
function Schema2(descriptor) {
|
|
7252
|
+
this.rules = null;
|
|
7253
|
+
this._messages = messages;
|
|
7254
|
+
this.define(descriptor);
|
|
7255
|
+
}
|
|
7256
|
+
var _proto = Schema2.prototype;
|
|
7257
|
+
_proto.define = function define(rules2) {
|
|
7258
|
+
var _this = this;
|
|
7259
|
+
if (!rules2) {
|
|
7260
|
+
throw new Error("Cannot configure a schema with no rules");
|
|
7261
|
+
}
|
|
7262
|
+
if (typeof rules2 !== "object" || Array.isArray(rules2)) {
|
|
7263
|
+
throw new Error("Rules must be an object");
|
|
7264
|
+
}
|
|
7265
|
+
this.rules = {};
|
|
7266
|
+
Object.keys(rules2).forEach(function(name) {
|
|
7267
|
+
var item = rules2[name];
|
|
7268
|
+
_this.rules[name] = Array.isArray(item) ? item : [item];
|
|
7269
|
+
});
|
|
7270
|
+
};
|
|
7271
|
+
_proto.messages = function messages2(_messages) {
|
|
7272
|
+
if (_messages) {
|
|
7273
|
+
this._messages = deepMerge(newMessages(), _messages);
|
|
7274
|
+
}
|
|
7275
|
+
return this._messages;
|
|
7276
|
+
};
|
|
7277
|
+
_proto.validate = function validate(source_, o, oc) {
|
|
7278
|
+
var _this2 = this;
|
|
7279
|
+
if (o === void 0) {
|
|
7280
|
+
o = {};
|
|
7281
|
+
}
|
|
7282
|
+
if (oc === void 0) {
|
|
7283
|
+
oc = function oc2() {
|
|
6930
7284
|
};
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
7285
|
+
}
|
|
7286
|
+
var source = source_;
|
|
7287
|
+
var options = o;
|
|
7288
|
+
var callback = oc;
|
|
7289
|
+
if (typeof options === "function") {
|
|
7290
|
+
callback = options;
|
|
7291
|
+
options = {};
|
|
7292
|
+
}
|
|
7293
|
+
if (!this.rules || Object.keys(this.rules).length === 0) {
|
|
7294
|
+
if (callback) {
|
|
7295
|
+
callback(null, source);
|
|
7296
|
+
}
|
|
7297
|
+
return Promise.resolve(source);
|
|
7298
|
+
}
|
|
7299
|
+
function complete(results) {
|
|
7300
|
+
var errors = [];
|
|
7301
|
+
var fields = {};
|
|
7302
|
+
function add(e) {
|
|
7303
|
+
if (Array.isArray(e)) {
|
|
7304
|
+
var _errors;
|
|
7305
|
+
errors = (_errors = errors).concat.apply(_errors, e);
|
|
7306
|
+
} else {
|
|
7307
|
+
errors.push(e);
|
|
6936
7308
|
}
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
7309
|
+
}
|
|
7310
|
+
for (var i = 0; i < results.length; i++) {
|
|
7311
|
+
add(results[i]);
|
|
7312
|
+
}
|
|
7313
|
+
if (!errors.length) {
|
|
7314
|
+
callback(null, source);
|
|
7315
|
+
} else {
|
|
7316
|
+
fields = convertFieldsError(errors);
|
|
7317
|
+
callback(errors, fields);
|
|
7318
|
+
}
|
|
7319
|
+
}
|
|
7320
|
+
if (options.messages) {
|
|
7321
|
+
var messages$1 = this.messages();
|
|
7322
|
+
if (messages$1 === messages) {
|
|
7323
|
+
messages$1 = newMessages();
|
|
7324
|
+
}
|
|
7325
|
+
deepMerge(messages$1, options.messages);
|
|
7326
|
+
options.messages = messages$1;
|
|
7327
|
+
} else {
|
|
7328
|
+
options.messages = this.messages();
|
|
7329
|
+
}
|
|
7330
|
+
var series = {};
|
|
7331
|
+
var keys = options.keys || Object.keys(this.rules);
|
|
7332
|
+
keys.forEach(function(z) {
|
|
7333
|
+
var arr = _this2.rules[z];
|
|
7334
|
+
var value = source[z];
|
|
7335
|
+
arr.forEach(function(r) {
|
|
7336
|
+
var rule = r;
|
|
7337
|
+
if (typeof rule.transform === "function") {
|
|
7338
|
+
if (source === source_) {
|
|
7339
|
+
source = _extends({}, source);
|
|
7340
|
+
}
|
|
7341
|
+
value = source[z] = rule.transform(value);
|
|
6941
7342
|
}
|
|
6942
|
-
if (
|
|
6943
|
-
|
|
6944
|
-
|
|
7343
|
+
if (typeof rule === "function") {
|
|
7344
|
+
rule = {
|
|
7345
|
+
validator: rule
|
|
7346
|
+
};
|
|
7347
|
+
} else {
|
|
7348
|
+
rule = _extends({}, rule);
|
|
6945
7349
|
}
|
|
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) {
|
|
7350
|
+
rule.validator = _this2.getValidationMethod(rule);
|
|
7351
|
+
if (!rule.validator) {
|
|
6957
7352
|
return;
|
|
6958
7353
|
}
|
|
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;
|
|
7354
|
+
rule.field = z;
|
|
7355
|
+
rule.fullField = rule.fullField || z;
|
|
7356
|
+
rule.type = _this2.getType(rule);
|
|
7357
|
+
series[z] = series[z] || [];
|
|
7358
|
+
series[z].push({
|
|
7359
|
+
rule,
|
|
7360
|
+
value,
|
|
7361
|
+
source,
|
|
7362
|
+
field: z
|
|
7363
|
+
});
|
|
7364
|
+
});
|
|
7365
|
+
});
|
|
7366
|
+
var errorFields = {};
|
|
7367
|
+
return asyncMap(series, options, function(data, doIt) {
|
|
7368
|
+
var rule = data.rule;
|
|
7369
|
+
var deep = (rule.type === "object" || rule.type === "array") && (typeof rule.fields === "object" || typeof rule.defaultField === "object");
|
|
7370
|
+
deep = deep && (rule.required || !rule.required && data.value);
|
|
7371
|
+
rule.field = data.field;
|
|
7372
|
+
function addFullField(key, schema) {
|
|
7373
|
+
return _extends({}, schema, {
|
|
7374
|
+
fullField: rule.fullField + "." + key,
|
|
7375
|
+
fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key]
|
|
7376
|
+
});
|
|
7022
7377
|
}
|
|
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
|
-
});
|
|
7378
|
+
function cb(e) {
|
|
7379
|
+
if (e === void 0) {
|
|
7380
|
+
e = [];
|
|
7052
7381
|
}
|
|
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
|
-
});
|
|
7382
|
+
var errorList = Array.isArray(e) ? e : [e];
|
|
7383
|
+
if (!options.suppressWarning && errorList.length) {
|
|
7384
|
+
Schema2.warning("async-validator:", errorList);
|
|
7066
7385
|
}
|
|
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
|
-
});
|
|
7386
|
+
if (errorList.length && rule.message !== void 0) {
|
|
7387
|
+
errorList = [].concat(rule.message);
|
|
7079
7388
|
}
|
|
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
|
-
});
|
|
7389
|
+
var filledErrors = errorList.map(complementError(rule, source));
|
|
7390
|
+
if (options.first && filledErrors.length) {
|
|
7391
|
+
errorFields[rule.field] = 1;
|
|
7392
|
+
return doIt(filledErrors);
|
|
7092
7393
|
}
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
if (
|
|
7100
|
-
|
|
7101
|
-
} else {
|
|
7102
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7394
|
+
if (!deep) {
|
|
7395
|
+
doIt(filledErrors);
|
|
7396
|
+
} else {
|
|
7397
|
+
if (rule.required && !data.value) {
|
|
7398
|
+
if (rule.message !== void 0) {
|
|
7399
|
+
filledErrors = [].concat(rule.message).map(complementError(rule, source));
|
|
7400
|
+
} else if (options.error) {
|
|
7401
|
+
filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
|
|
7103
7402
|
}
|
|
7403
|
+
return doIt(filledErrors);
|
|
7404
|
+
}
|
|
7405
|
+
var fieldsSchema = {};
|
|
7406
|
+
if (rule.defaultField) {
|
|
7407
|
+
Object.keys(data.value).map(function(key) {
|
|
7408
|
+
fieldsSchema[key] = rule.defaultField;
|
|
7409
|
+
});
|
|
7410
|
+
}
|
|
7411
|
+
fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
|
|
7412
|
+
var paredFieldsSchema = {};
|
|
7413
|
+
Object.keys(fieldsSchema).forEach(function(field) {
|
|
7414
|
+
var fieldSchema = fieldsSchema[field];
|
|
7415
|
+
var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
|
|
7416
|
+
paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
|
|
7104
7417
|
});
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7418
|
+
var schema = new Schema2(paredFieldsSchema);
|
|
7419
|
+
schema.messages(options.messages);
|
|
7420
|
+
if (data.rule.options) {
|
|
7421
|
+
data.rule.options.messages = options.messages;
|
|
7422
|
+
data.rule.options.error = options.error;
|
|
7423
|
+
}
|
|
7424
|
+
schema.validate(data.value, data.rule.options || options, function(errs) {
|
|
7425
|
+
var finalErrors = [];
|
|
7426
|
+
if (filledErrors && filledErrors.length) {
|
|
7427
|
+
finalErrors.push.apply(finalErrors, filledErrors);
|
|
7115
7428
|
}
|
|
7429
|
+
if (errs && errs.length) {
|
|
7430
|
+
finalErrors.push.apply(finalErrors, errs);
|
|
7431
|
+
}
|
|
7432
|
+
doIt(finalErrors.length ? finalErrors : null);
|
|
7116
7433
|
});
|
|
7117
7434
|
}
|
|
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
|
-
|
|
7149
|
-
|
|
7435
|
+
}
|
|
7436
|
+
var res;
|
|
7437
|
+
if (rule.asyncValidator) {
|
|
7438
|
+
res = rule.asyncValidator(rule, data.value, cb, data.source, options);
|
|
7439
|
+
} else if (rule.validator) {
|
|
7440
|
+
try {
|
|
7441
|
+
res = rule.validator(rule, data.value, cb, data.source, options);
|
|
7442
|
+
} catch (error) {
|
|
7443
|
+
console.error == null ? void 0 : console.error(error);
|
|
7444
|
+
if (!options.suppressValidatorError) {
|
|
7445
|
+
setTimeout(function() {
|
|
7446
|
+
throw error;
|
|
7447
|
+
}, 0);
|
|
7448
|
+
}
|
|
7449
|
+
cb(error.message);
|
|
7450
|
+
}
|
|
7451
|
+
if (res === true) {
|
|
7452
|
+
cb();
|
|
7453
|
+
} else if (res === false) {
|
|
7454
|
+
cb(typeof rule.message === "function" ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails");
|
|
7455
|
+
} else if (res instanceof Array) {
|
|
7456
|
+
cb(res);
|
|
7457
|
+
} else if (res instanceof Error) {
|
|
7458
|
+
cb(res.message);
|
|
7459
|
+
}
|
|
7460
|
+
}
|
|
7461
|
+
if (res && res.then) {
|
|
7462
|
+
res.then(function() {
|
|
7463
|
+
return cb();
|
|
7464
|
+
}, function(e) {
|
|
7465
|
+
return cb(e);
|
|
7466
|
+
});
|
|
7467
|
+
}
|
|
7468
|
+
}, function(results) {
|
|
7469
|
+
complete(results);
|
|
7470
|
+
}, source);
|
|
7471
|
+
};
|
|
7472
|
+
_proto.getType = function getType(rule) {
|
|
7473
|
+
if (rule.type === void 0 && rule.pattern instanceof RegExp) {
|
|
7474
|
+
rule.type = "pattern";
|
|
7150
7475
|
}
|
|
7476
|
+
if (typeof rule.validator !== "function" && rule.type && !validators.hasOwnProperty(rule.type)) {
|
|
7477
|
+
throw new Error(format("Unknown rule type %s", rule.type));
|
|
7478
|
+
}
|
|
7479
|
+
return rule.type || "string";
|
|
7480
|
+
};
|
|
7481
|
+
_proto.getValidationMethod = function getValidationMethod(rule) {
|
|
7482
|
+
if (typeof rule.validator === "function") {
|
|
7483
|
+
return rule.validator;
|
|
7484
|
+
}
|
|
7485
|
+
var keys = Object.keys(rule);
|
|
7486
|
+
var messageIndex = keys.indexOf("message");
|
|
7487
|
+
if (messageIndex !== -1) {
|
|
7488
|
+
keys.splice(messageIndex, 1);
|
|
7489
|
+
}
|
|
7490
|
+
if (keys.length === 1 && keys[0] === "required") {
|
|
7491
|
+
return validators.required;
|
|
7492
|
+
}
|
|
7493
|
+
return validators[this.getType(rule)] || void 0;
|
|
7494
|
+
};
|
|
7495
|
+
return Schema2;
|
|
7496
|
+
}();
|
|
7497
|
+
Schema.register = function register(type4, validator) {
|
|
7498
|
+
if (typeof validator !== "function") {
|
|
7499
|
+
throw new Error("Cannot register a validator by type, validator is not a function");
|
|
7151
7500
|
}
|
|
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);
|
|
7501
|
+
validators[type4] = validator;
|
|
7502
|
+
};
|
|
7503
|
+
Schema.warning = warning;
|
|
7504
|
+
Schema.messages = messages;
|
|
7505
|
+
Schema.validators = validators;
|
|
7506
|
+
function getFieldValue(obj, path) {
|
|
7507
|
+
return {
|
|
7508
|
+
get value() {
|
|
7509
|
+
return lodash.exports.get(obj, path);
|
|
7510
|
+
},
|
|
7511
|
+
set value(val) {
|
|
7512
|
+
lodash.exports.set(obj, path, val);
|
|
7513
|
+
}
|
|
7514
|
+
};
|
|
7182
7515
|
}
|
|
7183
|
-
function
|
|
7184
|
-
|
|
7185
|
-
|
|
7516
|
+
function useFormItem(messageType, _rules, validateState) {
|
|
7517
|
+
const formContext = inject(FORM_TOKEN);
|
|
7518
|
+
const ns2 = useNamespace("form");
|
|
7519
|
+
const itemClasses = computed(() => ({
|
|
7520
|
+
[`${ns2.em("item", "horizontal")}`]: formContext.layout === "horizontal",
|
|
7521
|
+
[`${ns2.em("item", "vertical")}`]: formContext.layout === "vertical",
|
|
7522
|
+
[`${ns2.em("item", "error")}`]: messageType.value === "text" && validateState.value === "error"
|
|
7523
|
+
}));
|
|
7524
|
+
const isRequired = computed(() => _rules.value.some((rule) => Boolean(rule.required)));
|
|
7525
|
+
return { itemClasses, isRequired };
|
|
7186
7526
|
}
|
|
7187
|
-
function
|
|
7188
|
-
const
|
|
7189
|
-
const
|
|
7190
|
-
|
|
7527
|
+
function useFormItemRule(props) {
|
|
7528
|
+
const formContext = inject(FORM_TOKEN);
|
|
7529
|
+
const _rules = computed(() => {
|
|
7530
|
+
const rules2 = props.rules ? lodash.exports.castArray(props.rules) : [];
|
|
7531
|
+
const formRules = formContext.rules;
|
|
7532
|
+
if (formRules && props.field) {
|
|
7533
|
+
const _itemRules = lodash.exports.get(formRules, props.field, void 0);
|
|
7534
|
+
if (_itemRules) {
|
|
7535
|
+
rules2.push(...lodash.exports.castArray(_itemRules));
|
|
7536
|
+
}
|
|
7537
|
+
}
|
|
7538
|
+
if (props.required) {
|
|
7539
|
+
rules2.push({ required: Boolean(props.required) });
|
|
7540
|
+
}
|
|
7541
|
+
return rules2;
|
|
7542
|
+
});
|
|
7543
|
+
return { _rules };
|
|
7191
7544
|
}
|
|
7192
|
-
function
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7545
|
+
function useFormItemValidate(props, _rules) {
|
|
7546
|
+
const formContext = inject(FORM_TOKEN);
|
|
7547
|
+
const validateState = ref("");
|
|
7548
|
+
const validateMessage = ref("");
|
|
7549
|
+
let initFieldValue = void 0;
|
|
7550
|
+
let isResetting = false;
|
|
7551
|
+
const computedField = computed(() => {
|
|
7552
|
+
return typeof props.field === "string" ? props.field : "";
|
|
7553
|
+
});
|
|
7554
|
+
const fieldValue = computed(() => {
|
|
7555
|
+
const formData = formContext.data;
|
|
7556
|
+
if (!formData || !props.field) {
|
|
7198
7557
|
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
7558
|
}
|
|
7205
|
-
|
|
7559
|
+
return getFieldValue(formData, props.field).value;
|
|
7206
7560
|
});
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
avaliableRuleObj = getAvaliableRuleObj(item.key, item.value);
|
|
7235
|
-
ruleObj = __spreadValues(__spreadValues({}, ruleObj), avaliableRuleObj);
|
|
7236
|
-
});
|
|
7237
|
-
descriptor.modelName.push(ruleObj);
|
|
7561
|
+
const getRuleByTrigger = (triggerVal) => {
|
|
7562
|
+
return _rules.value.filter((rule) => {
|
|
7563
|
+
if (!rule.trigger || !triggerVal) {
|
|
7564
|
+
return true;
|
|
7565
|
+
}
|
|
7566
|
+
if (Array.isArray(rule.trigger)) {
|
|
7567
|
+
return rule.trigger.includes(triggerVal);
|
|
7568
|
+
} else {
|
|
7569
|
+
return rule.trigger === triggerVal;
|
|
7570
|
+
}
|
|
7571
|
+
}).map(({ ...rule }) => rule);
|
|
7572
|
+
};
|
|
7573
|
+
const onValidateSuccess = () => {
|
|
7574
|
+
validateState.value = "success";
|
|
7575
|
+
validateMessage.value = "";
|
|
7576
|
+
formContext.emit("validate", props.field, true, "");
|
|
7577
|
+
};
|
|
7578
|
+
const onValidateError = ({ errors }) => {
|
|
7579
|
+
var _a;
|
|
7580
|
+
validateState.value = "error";
|
|
7581
|
+
validateMessage.value = ((_a = errors == null ? void 0 : errors[0]) == null ? void 0 : _a.message) || "";
|
|
7582
|
+
formContext.emit("validate", props.field, false, validateMessage.value);
|
|
7583
|
+
};
|
|
7584
|
+
const execValidate = async (rules2) => {
|
|
7585
|
+
const ruleName = computedField.value;
|
|
7586
|
+
const validator = new Schema({
|
|
7587
|
+
[ruleName]: rules2
|
|
7238
7588
|
});
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
asyncValidator: (rule, value, callback) => {
|
|
7252
|
-
return new Promise(lodash.exports.debounce((resolve, reject) => {
|
|
7253
|
-
const res = item.asyncValidator(rule, value);
|
|
7254
|
-
if (res) {
|
|
7255
|
-
resolve("");
|
|
7256
|
-
} else {
|
|
7257
|
-
reject(rule.message);
|
|
7258
|
-
}
|
|
7259
|
-
}, asyncDebounceTime));
|
|
7260
|
-
}
|
|
7261
|
-
};
|
|
7262
|
-
descriptor.modelName.push(ruleObj);
|
|
7263
|
-
});
|
|
7589
|
+
return validator.validate({ [ruleName]: fieldValue.value }, { firstFields: true }).then(() => {
|
|
7590
|
+
onValidateSuccess();
|
|
7591
|
+
return true;
|
|
7592
|
+
}).catch((error) => {
|
|
7593
|
+
onValidateError(error);
|
|
7594
|
+
return Promise.reject(error);
|
|
7595
|
+
});
|
|
7596
|
+
};
|
|
7597
|
+
const validate = async (trigger, callback) => {
|
|
7598
|
+
if (isResetting) {
|
|
7599
|
+
isResetting = false;
|
|
7600
|
+
return false;
|
|
7264
7601
|
}
|
|
7265
|
-
const
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
}
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
}
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7602
|
+
const rules2 = getRuleByTrigger(trigger);
|
|
7603
|
+
if (!rules2.length) {
|
|
7604
|
+
callback == null ? void 0 : callback(true);
|
|
7605
|
+
return true;
|
|
7606
|
+
}
|
|
7607
|
+
validateState.value = "pending";
|
|
7608
|
+
return execValidate(rules2).then(() => {
|
|
7609
|
+
callback == null ? void 0 : callback(true);
|
|
7610
|
+
return true;
|
|
7611
|
+
}).catch((error) => {
|
|
7612
|
+
const { fields } = error;
|
|
7613
|
+
callback == null ? void 0 : callback(false, fields);
|
|
7614
|
+
return lodash.exports.isFunction(callback) ? false : Promise.reject(fields);
|
|
7615
|
+
});
|
|
7616
|
+
};
|
|
7617
|
+
const clearValidate = () => {
|
|
7618
|
+
validateState.value = "";
|
|
7619
|
+
validateMessage.value = "";
|
|
7620
|
+
};
|
|
7621
|
+
const resetField = async () => {
|
|
7622
|
+
if (!formContext.data || !props.field) {
|
|
7623
|
+
return;
|
|
7624
|
+
}
|
|
7625
|
+
const currentValue = getFieldValue(formContext.data, props.field);
|
|
7626
|
+
if (!lodash.exports.isEqual(currentValue.value, initFieldValue)) {
|
|
7627
|
+
isResetting = true;
|
|
7628
|
+
}
|
|
7629
|
+
currentValue.value = initFieldValue;
|
|
7630
|
+
await nextTick();
|
|
7631
|
+
clearValidate();
|
|
7632
|
+
};
|
|
7633
|
+
onMounted(() => {
|
|
7634
|
+
initFieldValue = lodash.exports.clone(fieldValue.value);
|
|
7635
|
+
});
|
|
7636
|
+
return { validateState, validateMessage, validate, resetField, clearValidate };
|
|
7637
|
+
}
|
|
7638
|
+
var formItem = "";
|
|
7639
|
+
var FormItem = defineComponent({
|
|
7640
|
+
name: "DFormItem",
|
|
7641
|
+
props: formItemProps,
|
|
7642
|
+
setup(props, ctx) {
|
|
7643
|
+
const formContext = inject(FORM_TOKEN);
|
|
7644
|
+
const {
|
|
7645
|
+
messageType: itemMessageType,
|
|
7646
|
+
popPosition: itemPopPosition,
|
|
7647
|
+
showFeedback: itemShowFeedback,
|
|
7648
|
+
...otherProps
|
|
7649
|
+
} = toRefs(props);
|
|
7650
|
+
const {
|
|
7651
|
+
label,
|
|
7652
|
+
helpTips,
|
|
7653
|
+
feedbackStatus,
|
|
7654
|
+
extraInfo
|
|
7655
|
+
} = toRefs(props);
|
|
7656
|
+
const showFeedback = computed(() => (itemShowFeedback == null ? void 0 : itemShowFeedback.value) !== void 0 ? itemShowFeedback.value : formContext.showFeedback);
|
|
7657
|
+
const messageType = computed(() => (itemMessageType == null ? void 0 : itemMessageType.value) || formContext.messageType);
|
|
7658
|
+
const popPosition = computed(() => (itemPopPosition == null ? void 0 : itemPopPosition.value) || formContext.popPosition);
|
|
7659
|
+
const {
|
|
7660
|
+
_rules
|
|
7661
|
+
} = useFormItemRule(props);
|
|
7662
|
+
const {
|
|
7663
|
+
validateState,
|
|
7664
|
+
validateMessage,
|
|
7665
|
+
validate,
|
|
7666
|
+
resetField,
|
|
7667
|
+
clearValidate
|
|
7668
|
+
} = useFormItemValidate(props, _rules);
|
|
7669
|
+
const {
|
|
7670
|
+
itemClasses,
|
|
7671
|
+
isRequired
|
|
7672
|
+
} = useFormItem(messageType, _rules, validateState);
|
|
7673
|
+
const labelData = computed(() => ({
|
|
7674
|
+
layout: formContext.layout,
|
|
7675
|
+
labelSize: formContext.labelSize,
|
|
7676
|
+
labelAlign: formContext.labelAlign
|
|
7677
|
+
}));
|
|
7678
|
+
provide(LABEL_DATA, labelData);
|
|
7679
|
+
const context = reactive({
|
|
7680
|
+
...otherProps,
|
|
7681
|
+
showFeedback,
|
|
7682
|
+
messageType,
|
|
7683
|
+
popPosition,
|
|
7684
|
+
isRequired,
|
|
7685
|
+
validateState,
|
|
7686
|
+
validateMessage,
|
|
7687
|
+
validate,
|
|
7688
|
+
resetField,
|
|
7689
|
+
clearValidate
|
|
7279
7690
|
});
|
|
7691
|
+
provide(FORM_ITEM_TOKEN, context);
|
|
7692
|
+
ctx.expose({
|
|
7693
|
+
resetField,
|
|
7694
|
+
clearValidate
|
|
7695
|
+
});
|
|
7696
|
+
onMounted(() => {
|
|
7697
|
+
if (props.field) {
|
|
7698
|
+
formContext == null ? void 0 : formContext.addItemContext(context);
|
|
7699
|
+
}
|
|
7700
|
+
});
|
|
7701
|
+
onBeforeUnmount(() => {
|
|
7702
|
+
formContext == null ? void 0 : formContext.removeItemContext(context);
|
|
7703
|
+
});
|
|
7704
|
+
return () => createVNode("div", {
|
|
7705
|
+
"class": itemClasses.value
|
|
7706
|
+
}, [createVNode(FormLabel, {
|
|
7707
|
+
"help-tips": helpTips.value
|
|
7708
|
+
}, {
|
|
7709
|
+
default: () => [label == null ? void 0 : label.value]
|
|
7710
|
+
}), createVNode(FormControl, {
|
|
7711
|
+
"feedback-status": feedbackStatus == null ? void 0 : feedbackStatus.value,
|
|
7712
|
+
"extra-info": extraInfo.value
|
|
7713
|
+
}, {
|
|
7714
|
+
default: () => {
|
|
7715
|
+
var _a, _b;
|
|
7716
|
+
return [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)];
|
|
7717
|
+
}
|
|
7718
|
+
})]);
|
|
7280
7719
|
}
|
|
7281
|
-
};
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
};
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
};
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7720
|
+
});
|
|
7721
|
+
var formOperation = "";
|
|
7722
|
+
var FormOperation = defineComponent({
|
|
7723
|
+
name: "DFormOperation",
|
|
7724
|
+
setup(props, ctx) {
|
|
7725
|
+
const formContext = inject(FORM_TOKEN);
|
|
7726
|
+
const LabelSizeMap = {
|
|
7727
|
+
sm: 80,
|
|
7728
|
+
md: 100,
|
|
7729
|
+
lg: 150
|
|
7730
|
+
};
|
|
7731
|
+
const styles = computed(() => ({
|
|
7732
|
+
marginLeft: formContext.layout === "horizontal" ? `${LabelSizeMap[formContext.labelSize] + 16}px` : void 0
|
|
7733
|
+
}));
|
|
7734
|
+
return () => {
|
|
7735
|
+
var _a, _b;
|
|
7736
|
+
return createVNode("div", {
|
|
7737
|
+
"class": "devui-form-operation",
|
|
7738
|
+
"style": styles.value
|
|
7739
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
7740
|
+
};
|
|
7741
|
+
}
|
|
7742
|
+
});
|
|
7298
7743
|
var index = {
|
|
7299
7744
|
title: "Form \u8868\u5355",
|
|
7300
7745
|
category: "\u6570\u636E\u5F55\u5165",
|
|
7746
|
+
status: "75%",
|
|
7301
7747
|
install(app) {
|
|
7302
|
-
app.
|
|
7303
|
-
app.
|
|
7304
|
-
app.
|
|
7305
|
-
app.use(FormControl);
|
|
7306
|
-
app.use(FormOperation);
|
|
7748
|
+
app.component(Form.name, Form);
|
|
7749
|
+
app.component(FormItem.name, FormItem);
|
|
7750
|
+
app.component(FormOperation.name, FormOperation);
|
|
7307
7751
|
}
|
|
7308
7752
|
};
|
|
7309
|
-
export {
|
|
7753
|
+
export { FORM_ITEM_TOKEN, FORM_TOKEN, Form, FormItem, FormOperation, LABEL_DATA, index as default, formItemProps, formProps };
|