fusions-ui 1.2.7 → 1.2.8
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/LICENSE +1 -1
- package/changelog.md +2 -0
- package/components/avatar/index.ts +1 -0
- package/components/avatar/src/avatar.ts +131 -0
- package/components/avatar/src/avatar.vue +104 -0
- package/components/avatar/src/composables/index.ts +1 -0
- package/components/avatar/src/composables/use-avatar.ts +61 -0
- package/components/avatar-group/index.ts +1 -0
- package/components/avatar-group/src/avatar-group.ts +86 -0
- package/components/{fu-avatar-group/fu-avatar-group.vue → avatar-group/src/avatar-group.vue} +27 -34
- package/components/avatar-group/src/composables/index.ts +1 -0
- package/components/avatar-group/src/composables/use-avatar-group.ts +17 -0
- package/components/badge/index.ts +1 -0
- package/components/badge/src/badge.ts +126 -0
- package/components/{fu-badge/fu-badge.vue → badge/src/badge.vue} +26 -62
- package/components/badge/src/composables/badge-custom.ts +51 -0
- package/components/badge/src/composables/index.ts +1 -0
- package/components/banner-arc/index.ts +1 -0
- package/components/banner-arc/src/banner-arc.ts +41 -0
- package/components/banner-arc/src/banner-arc.vue +49 -0
- package/components/banner-arc/src/composables/banner-arc-custom.ts +19 -0
- package/components/banner-arc/src/composables/index.ts +1 -0
- package/components/button/index.ts +1 -0
- package/components/button/src/button.ts +332 -0
- package/components/{fu-button/fu-button.vue → button/src/button.vue} +57 -163
- package/components/button/src/composables/button-custom.ts +90 -0
- package/components/button/src/composables/index.ts +2 -0
- package/components/button/src/composables/use-button.ts +137 -0
- package/components/cell/index.ts +1 -0
- package/components/cell/src/cell.ts +167 -0
- package/components/{fu-cell/fu-cell.vue → cell/src/cell.vue} +29 -38
- package/components/cell/src/composables/index.ts +1 -0
- package/components/cell/src/composables/use-cell.ts +20 -0
- package/components/cell-group/index.ts +1 -0
- package/components/cell-group/src/cell-group.ts +23 -0
- package/components/{fu-cell-group/fu-cell-group.vue → cell-group/src/cell-group.vue} +8 -13
- package/components/checkbox/index.ts +1 -0
- package/components/checkbox/src/checkbox.ts +144 -0
- package/components/checkbox/src/checkbox.vue +270 -0
- package/components/checkbox/src/composables/checkbox-custom.ts +15 -0
- package/components/checkbox/src/composables/index.ts +2 -0
- package/components/checkbox/src/composables/use-checkbox.ts +200 -0
- package/components/code-input/index.ts +1 -0
- package/components/code-input/src/code-input.ts +157 -0
- package/components/code-input/src/code-input.vue +158 -0
- package/components/code-input/src/composables/code-input-custom.ts +74 -0
- package/components/code-input/src/composables/index.ts +2 -0
- package/components/code-input/src/composables/use-code-input.ts +67 -0
- package/components/code-verify/index.ts +1 -0
- package/components/code-verify/src/code-verify.ts +160 -0
- package/components/code-verify/src/code-verify.vue +87 -0
- package/components/code-verify/src/composables/code-verify-custom.ts +23 -0
- package/components/code-verify/src/composables/index.ts +2 -0
- package/components/code-verify/src/composables/use-code-verify.ts +132 -0
- package/components/collapse/index.ts +1 -0
- package/components/collapse/src/collapse.ts +41 -0
- package/components/collapse/src/collapse.vue +48 -0
- package/components/collapse/src/composables/index.ts +1 -0
- package/components/collapse/src/composables/use-collapse.ts +150 -0
- package/components/collapse-item/index.ts +1 -0
- package/components/collapse-item/src/collapse-item.ts +102 -0
- package/components/{fu-collapse-item/fu-collapse-item.vue → collapse-item/src/collapse-item.vue} +20 -159
- package/components/collapse-item/src/composables/index.ts +1 -0
- package/components/collapse-item/src/composables/use-collapse-item.ts +139 -0
- package/components/countdown/index.ts +1 -0
- package/components/countdown/src/composables/index.ts +1 -0
- package/components/countdown/src/composables/use-countdown.ts +133 -0
- package/components/countdown/src/countdown.ts +63 -0
- package/components/countdown/src/countdown.vue +60 -0
- package/components/{fu-countdown/util.js → countdown/src/util.ts} +5 -5
- package/components/datetime-picker/index.ts +1 -0
- package/components/datetime-picker/src/composables/index.ts +1 -0
- package/components/datetime-picker/src/composables/use-datetime-picker.ts +325 -0
- package/components/datetime-picker/src/datetime-picker.ts +223 -0
- package/components/datetime-picker/src/datetime-picker.vue +96 -0
- package/components/form/index.ts +1 -0
- package/components/form/src/composables/index.ts +1 -0
- package/components/form/src/composables/use-form.ts +256 -0
- package/components/form/src/form.ts +108 -0
- package/components/form/src/form.vue +64 -0
- package/components/{fu-form/utils.js → form/src/utils.ts} +49 -42
- package/components/{fu-form/validate.js → form/src/validate.ts} +58 -49
- package/components/form-item/index.ts +1 -0
- package/components/form-item/src/composables/index.ts +1 -0
- package/components/form-item/src/composables/use-form-item.ts +292 -0
- package/components/form-item/src/form-item.ts +81 -0
- package/components/form-item/src/form-item.vue +229 -0
- package/components/fusions-ui/src/fusions-ui.vue +8 -0
- package/components/grid/index.ts +1 -0
- package/components/grid/src/composables/index.ts +1 -0
- package/components/grid/src/composables/use-grid.ts +67 -0
- package/components/grid/src/grid.ts +54 -0
- package/components/grid/src/grid.vue +69 -0
- package/components/grid-item/index.ts +1 -0
- package/components/grid-item/src/composables/grid-item-custom.ts +16 -0
- package/components/grid-item/src/composables/index.ts +2 -0
- package/components/grid-item/src/composables/use-grid-item.ts +55 -0
- package/components/grid-item/src/grid-item.ts +15 -0
- package/components/grid-item/src/grid-item.vue +102 -0
- package/components/icon/index.ts +1 -0
- package/components/icon/src/composables/icon-custom.ts +41 -0
- package/components/icon/src/composables/index.ts +2 -0
- package/components/icon/src/composables/use-icon.ts +14 -0
- package/components/{fu-icon → icon/src}/fuicon.css +584 -584
- package/components/icon/src/fuicon.ts +1023 -0
- package/components/icon/src/icon.ts +84 -0
- package/components/icon/src/icon.vue +92 -0
- package/components/image/index.ts +1 -0
- package/components/image/src/composables/image-custom.ts +36 -0
- package/components/image/src/composables/index.ts +2 -0
- package/components/image/src/composables/use-image.ts +135 -0
- package/components/image/src/image.ts +185 -0
- package/components/image/src/image.vue +152 -0
- package/components/index-anchor/index.ts +1 -0
- package/components/index-anchor/src/composables/index.ts +1 -0
- package/components/index-anchor/src/composables/use-index-anchor.ts +44 -0
- package/components/index-anchor/src/index-anchor.ts +45 -0
- package/components/index-anchor/src/index-anchor.vue +60 -0
- package/components/index-item/index.ts +1 -0
- package/components/index-item/src/composables/index.ts +1 -0
- package/components/index-item/src/composables/use-index-item.ts +75 -0
- package/components/index-item/src/index-item.ts +13 -0
- package/components/index-item/src/index-item.vue +32 -0
- package/components/index-list/index.ts +1 -0
- package/components/index-list/src/composables/index.ts +1 -0
- package/components/index-list/src/composables/use-index-list.ts +297 -0
- package/components/index-list/src/index-list.ts +52 -0
- package/components/index-list/src/index-list.vue +178 -0
- package/components/index.ts +62 -0
- package/components/input/index.ts +1 -0
- package/components/input/src/composables/index.ts +2 -0
- package/components/input/src/composables/input-custom.ts +69 -0
- package/components/input/src/composables/use-input.ts +117 -0
- package/components/input/src/input.ts +360 -0
- package/components/input/src/input.vue +241 -0
- package/components/keyboard/index.ts +1 -0
- package/components/keyboard/src/composables/index.ts +3 -0
- package/components/keyboard/src/composables/use-keyboard-car.ts +99 -0
- package/components/keyboard/src/composables/use-keyboard-number.ts +81 -0
- package/components/keyboard/src/composables/use-keyboard.ts +61 -0
- package/components/keyboard/src/keyboard-car.ts +53 -0
- package/components/{fu-keyboard → keyboard/src}/keyboard-car.vue +37 -199
- package/components/keyboard/src/keyboard-number.ts +44 -0
- package/components/keyboard/src/keyboard-number.vue +108 -0
- package/components/keyboard/src/keyboard.ts +174 -0
- package/components/{fu-keyboard/fu-keyboard.vue → keyboard/src/keyboard.vue} +38 -63
- package/components/line/index.ts +1 -0
- package/components/line/src/composables/index.ts +1 -0
- package/components/line/src/composables/line-custom.ts +30 -0
- package/components/line/src/line.ts +82 -0
- package/components/line/src/line.vue +44 -0
- package/components/link/index.ts +1 -0
- package/components/link/src/composables/index.ts +2 -0
- package/components/link/src/composables/link-custom.ts +19 -0
- package/components/link/src/composables/use-link.ts +33 -0
- package/components/link/src/link.ts +61 -0
- package/components/link/src/link.vue +62 -0
- package/components/loading/index.ts +1 -0
- package/{libs/function/colorGradient.js → components/loading/src/composables/colorGradient.ts} +4 -4
- package/components/loading/src/composables/index.ts +2 -0
- package/components/loading/src/composables/loading-custom.ts +21 -0
- package/components/loading/src/composables/use-loading.ts +100 -0
- package/components/loading/src/loading.ts +77 -0
- package/components/{fu-loading/fu-loading.vue → loading/src/loading.vue} +23 -119
- package/components/loading-more/index.ts +1 -0
- package/components/loading-more/src/loading-more.ts +75 -0
- package/components/{fu-loading-more/fu-loading-more.vue → loading-more/src/loading-more.vue} +18 -19
- package/components/modal/index.ts +1 -0
- package/components/modal/src/composables/index.ts +2 -0
- package/components/modal/src/composables/modal-custom.ts +17 -0
- package/components/modal/src/composables/use-modal.ts +56 -0
- package/components/modal/src/modal.ts +152 -0
- package/components/{fu-modal/fu-modal.vue → modal/src/modal.vue} +41 -69
- package/components/navbar/index.ts +1 -0
- package/components/navbar/src/composables/index.ts +2 -0
- package/components/navbar/src/composables/navbar-custom.ts +62 -0
- package/components/navbar/src/composables/use-navbar.ts +42 -0
- package/components/navbar/src/navbar.ts +151 -0
- package/components/navbar/src/navbar.vue +249 -0
- package/components/notice-bar/index.ts +3 -0
- package/components/notice-bar/src/composables/index.ts +5 -0
- package/components/notice-bar/src/composables/notice-column-custom.ts +43 -0
- package/components/notice-bar/src/composables/notice-row-custom.ts +26 -0
- package/components/notice-bar/src/composables/use-notice-bar.ts +34 -0
- package/components/notice-bar/src/composables/use-notice-column.ts +31 -0
- package/components/notice-bar/src/composables/use-notice-row.ts +88 -0
- package/components/notice-bar/src/notice-bar.ts +197 -0
- package/components/{fu-notice-bar/fu-notice-bar.vue → notice-bar/src/notice-bar.vue} +28 -41
- package/components/notice-bar/src/notice-column.ts +172 -0
- package/components/notice-bar/src/notice-column.vue +129 -0
- package/components/notice-bar/src/notice-row.ts +155 -0
- package/components/notice-bar/src/notice-row.vue +135 -0
- package/components/number-box/index.ts +1 -0
- package/components/number-box/src/composables/index.ts +2 -0
- package/components/number-box/src/composables/number-box-custom.ts +16 -0
- package/components/number-box/src/composables/use-number-box.ts +84 -0
- package/components/number-box/src/number-box.ts +98 -0
- package/components/number-box/src/number-box.vue +123 -0
- package/components/parse/index.ts +1 -0
- package/components/parse/src/app-plus/html/js/handler.js +254 -0
- package/components/parse/src/app-plus/html/js/uni.webview.min.js +188 -0
- package/components/parse/src/app-plus/html/local.html +32 -0
- package/components/parse/src/composables/index.ts +1 -0
- package/components/parse/src/composables/use-parse.ts +428 -0
- package/components/parse/src/node/node.vue +635 -0
- package/components/parse/src/parse.ts +156 -0
- package/components/parse/src/parse.vue +131 -0
- package/components/parse/src/parser.ts +1402 -0
- package/components/picker/index.ts +1 -0
- package/components/picker/src/composables/index.ts +2 -0
- package/components/picker/src/composables/picker-custom.ts +40 -0
- package/components/picker/src/composables/use-picker.ts +179 -0
- package/components/picker/src/picker.ts +172 -0
- package/components/picker/src/picker.vue +197 -0
- package/components/popup/index.ts +1 -0
- package/components/popup/src/composables/index.ts +1 -0
- package/components/popup/src/composables/use-popup.ts +346 -0
- package/components/popup/src/keypress.ts +55 -0
- package/components/popup/src/popup.ts +101 -0
- package/components/popup/src/popup.vue +204 -0
- package/components/progress/index.ts +1 -0
- package/components/progress/src/composables/index.ts +2 -0
- package/components/progress/src/composables/progress-custom.ts +24 -0
- package/components/progress/src/composables/use-progress.ts +159 -0
- package/components/progress/src/progress.ts +84 -0
- package/components/progress/src/progress.vue +150 -0
- package/components/rate/index.ts +1 -0
- package/components/rate/src/composables/index.ts +1 -0
- package/components/rate/src/composables/use-rate.ts +196 -0
- package/components/rate/src/rate.ts +114 -0
- package/components/rate/src/rate.vue +113 -0
- package/components/read-more/index.ts +1 -0
- package/components/read-more/src/composables/index.ts +2 -0
- package/components/read-more/src/composables/read-more-custom.ts +46 -0
- package/components/read-more/src/composables/use-read-more.ts +72 -0
- package/components/read-more/src/read-more.ts +102 -0
- package/components/read-more/src/read-more.vue +104 -0
- package/components/safe-bottom/index.ts +1 -0
- package/components/safe-bottom/src/composables/index.ts +2 -0
- package/components/safe-bottom/src/composables/safe-bottom-custom.ts +18 -0
- package/components/safe-bottom/src/composables/use-safe-bottom.ts +17 -0
- package/components/safe-bottom/src/safe-bottom.ts +8 -0
- package/components/safe-bottom/src/safe-bottom.vue +43 -0
- package/components/scroll-list/index.ts +1 -0
- package/components/scroll-list/src/composables/index.ts +2 -0
- package/components/scroll-list/src/composables/scroll-list-custom.ts +41 -0
- package/components/scroll-list/src/composables/use-scroll-list.ts +126 -0
- package/components/scroll-list/src/scroll-list.ts +57 -0
- package/components/scroll-list/src/scroll-list.vue +143 -0
- package/components/{fu-scroll-list/scrollWxs.wxs → scroll-list/src/scroll-wxs.wxs} +2 -2
- package/components/search/index.ts +1 -0
- package/components/search/src/composables/index.ts +2 -0
- package/components/search/src/composables/search-custom.ts +25 -0
- package/components/search/src/composables/use-search.ts +106 -0
- package/components/search/src/search.ts +186 -0
- package/components/{fu-search/fu-search.vue → search/src/search.vue} +42 -154
- package/components/section/index.ts +1 -0
- package/components/section/src/composables/index.ts +1 -0
- package/components/section/src/composables/use-section.ts +19 -0
- package/components/section/src/section.ts +83 -0
- package/components/{fu-section/fu-section.vue → section/src/section.vue} +36 -35
- package/components/sign-board/index.ts +1 -0
- package/components/sign-board/src/composables/index.ts +1 -0
- package/components/sign-board/src/composables/use-sign-board.ts +552 -0
- package/components/sign-board/src/sign-board.ts +48 -0
- package/components/sign-board/src/sign-board.vue +191 -0
- package/components/skeleton/index.ts +1 -0
- package/components/skeleton/src/composables/index.ts +2 -0
- package/components/skeleton/src/composables/skeleton-custom.ts +23 -0
- package/components/skeleton/src/composables/use-skeleton.ts +102 -0
- package/components/skeleton/src/skeleton.ts +37 -0
- package/components/skeleton/src/skeleton.vue +147 -0
- package/components/status-bar/src/composables/index.ts +1 -0
- package/components/status-bar/src/composables/use-status-bar.ts +29 -0
- package/components/status-bar/src/status-bar.vue +21 -0
- package/components/steps/index.ts +1 -0
- package/components/steps/src/composables/index.ts +1 -0
- package/components/steps/src/composables/use-steps.ts +27 -0
- package/components/steps/src/steps.ts +65 -0
- package/components/steps/src/steps.vue +46 -0
- package/components/steps-item/index.ts +1 -0
- package/components/steps-item/src/composables/index.ts +2 -0
- package/components/steps-item/src/composables/steps-item-custom.ts +81 -0
- package/components/steps-item/src/composables/use-steps-item.ts +87 -0
- package/components/steps-item/src/steps-item.ts +38 -0
- package/components/steps-item/src/steps-item.vue +224 -0
- package/components/sticky/index.ts +1 -0
- package/components/sticky/src/composables/index.ts +2 -0
- package/components/sticky/src/composables/sticky-custom.ts +57 -0
- package/components/sticky/src/composables/use-sticky.ts +152 -0
- package/components/sticky/src/sticky.ts +62 -0
- package/components/sticky/src/sticky.vue +65 -0
- package/components/subsection/index.ts +1 -0
- package/components/subsection/src/composables/index.ts +2 -0
- package/components/subsection/src/composables/subsection-custom.ts +71 -0
- package/components/subsection/src/composables/use-subsection.ts +85 -0
- package/components/subsection/src/subsection.ts +107 -0
- package/components/subsection/src/subsection.vue +165 -0
- package/components/swipe-action/src/composables/index.ts +1 -0
- package/components/swipe-action/src/composables/use-swipe-action.ts +58 -0
- package/components/swipe-action/src/swipe-action.vue +81 -0
- package/components/swipe-action-item/index.ts +1 -0
- package/components/{fu-swipe-action-item/mpwxs.js → swipe-action-item/src/mpwxs.ts} +22 -27
- package/components/swipe-action-item/src/swipe-action-item.ts +68 -0
- package/components/{fu-swipe-action-item/fu-swipe-action-item.vue → swipe-action-item/src/swipe-action-item.vue} +24 -17
- package/components/{fu-swipe-action-item → swipe-action-item/src}/wx.wxs +2 -2
- package/components/swiper/index.ts +1 -0
- package/components/swiper/src/composables/index.ts +2 -0
- package/components/swiper/src/composables/swiper-custom.ts +40 -0
- package/components/swiper/src/composables/use-swiper.ts +75 -0
- package/components/swiper/src/swiper.ts +189 -0
- package/components/{fu-swiper/fu-swiper.vue → swiper/src/swiper.vue} +49 -118
- package/components/switch/index.ts +1 -0
- package/components/switch/src/composables/index.ts +2 -0
- package/components/switch/src/composables/switch-custom.ts +32 -0
- package/components/switch/src/composables/use-switch.ts +38 -0
- package/components/switch/src/switch.ts +115 -0
- package/components/{fu-switch/fu-switch.vue → switch/src/switch.vue} +25 -73
- package/components/tabs/index.ts +1 -0
- package/components/tabs/src/composables/index.ts +2 -0
- package/components/tabs/src/composables/tabs-custom.ts +43 -0
- package/components/tabs/src/composables/use-tabs.ts +210 -0
- package/components/tabs/src/tabs.ts +123 -0
- package/components/tabs/src/tabs.vue +153 -0
- package/components/tag/index.ts +1 -0
- package/components/tag/src/composables/index.ts +2 -0
- package/components/tag/src/composables/tag-custom.ts +61 -0
- package/components/tag/src/composables/use-tag.ts +23 -0
- package/components/tag/src/tag.ts +159 -0
- package/components/{fu-tag/fu-tag.vue → tag/src/tag.vue} +53 -93
- package/components/text/index.ts +1 -0
- package/components/text/src/composables/index.ts +2 -0
- package/components/text/src/composables/text-custom.ts +120 -0
- package/components/text/src/composables/use-text.ts +83 -0
- package/components/text/src/text.ts +261 -0
- package/components/text/src/text.vue +186 -0
- package/components/textarea/index.ts +1 -0
- package/components/textarea/src/composables/index.ts +2 -0
- package/components/textarea/src/composables/textarea-custom.ts +50 -0
- package/components/textarea/src/composables/use-textarea.ts +88 -0
- package/components/textarea/src/textarea.ts +250 -0
- package/components/textarea/src/textarea.vue +162 -0
- package/components/{fu-timeaxis/fu-timeaxis.vue → timeaxis/src/timeaxis.vue} +3 -9
- package/components/timeaxis-item/index.ts +1 -0
- package/components/timeaxis-item/src/timeaxis-item.ts +20 -0
- package/components/timeaxis-item/src/timeaxis-item.vue +50 -0
- package/components/transition/index.ts +1 -0
- package/components/transition/src/composables/createAnimation.ts +171 -0
- package/components/transition/src/composables/index.ts +2 -0
- package/components/transition/src/composables/transform-custom.ts +18 -0
- package/components/transition/src/composables/use-transition.ts +251 -0
- package/components/transition/src/transition.ts +64 -0
- package/components/transition/src/transition.vue +70 -0
- package/components/upload/index.ts +1 -0
- package/components/upload/src/composables/index.ts +5 -0
- package/components/upload/src/composables/upload-file-custom.ts +68 -0
- package/components/upload/src/composables/upload-image-custom.ts +76 -0
- package/components/upload/src/composables/use-upload-file.ts +27 -0
- package/components/upload/src/composables/use-upload-image.ts +38 -0
- package/components/upload/src/composables/use-upload.ts +388 -0
- package/components/upload/src/upload-file.ts +84 -0
- package/components/upload/src/upload-file.vue +193 -0
- package/components/upload/src/upload-image.ts +90 -0
- package/components/upload/src/upload-image.vue +158 -0
- package/components/upload/src/upload.ts +196 -0
- package/components/upload/src/upload.vue +151 -0
- package/components/{fu-upload/utils.js → upload/src/utils.ts} +12 -12
- package/components/vtabs/index.ts +1 -0
- package/components/vtabs/src/composables/index.ts +2 -0
- package/components/vtabs/src/composables/use-vtabs.ts +276 -0
- package/components/vtabs/src/composables/vtabs-custom.ts +54 -0
- package/components/vtabs/src/vtabs.ts +130 -0
- package/components/vtabs/src/vtabs.vue +189 -0
- package/components/vtabs-item/index.ts +1 -0
- package/components/vtabs-item/src/composables/index.ts +1 -0
- package/components/vtabs-item/src/composables/use-vtabs-item.ts +60 -0
- package/components/vtabs-item/src/vtabs-item.ts +10 -0
- package/components/vtabs-item/src/vtabs-item.vue +20 -0
- package/components/waterfall/index.ts +1 -0
- package/components/waterfall/src/composables/index.ts +2 -0
- package/components/waterfall/src/composables/use-waterfall.ts +139 -0
- package/components/waterfall/src/composables/waterfall-custom.ts +18 -0
- package/components/waterfall/src/waterfall.ts +114 -0
- package/components/waterfall/src/waterfall.vue +104 -0
- package/{libs/config/config.js → config/config.ts} +13 -7
- package/constants/images.ts +18 -0
- package/constants/index.ts +6 -0
- package/constants/open-types.ts +33 -0
- package/constants/props.ts +18 -0
- package/constants/shapes.ts +6 -0
- package/constants/types.ts +10 -0
- package/constants/z-index.ts +27 -0
- package/global.d.ts +103 -0
- package/hooks/index.ts +25 -0
- package/index.scss +3 -5
- package/index.ts +56 -0
- package/package.json +1 -1
- package/{libs/route/min.route.config.js → route/min.route.config.ts} +62 -23
- package/route/route.config.ts +93 -0
- package/style/color.scss +26 -0
- package/{libs/style → style}/common.scss +1 -14
- package/{libs/function/applyEven.js → utils/applyEven.ts} +21 -12
- package/utils/check.ts +276 -0
- package/{libs/function/chooseUploadFile.js → utils/chooseUploadFile.ts} +22 -26
- package/utils/common.ts +609 -0
- package/{libs/function/digit.js → utils/digit.ts} +63 -33
- package/{components/fu-swipe-action-item/isPC.js → utils/isPC.ts} +1 -1
- package/utils/toast.ts +42 -0
- package/components/fu-avatar/fu-avatar.vue +0 -157
- package/components/fu-avatar/props.js +0 -117
- package/components/fu-avatar-group/props.js +0 -74
- package/components/fu-badge/props.js +0 -112
- package/components/fu-banner-arc/fu-banner-arc.vue +0 -58
- package/components/fu-banner-arc/props.js +0 -35
- package/components/fu-button/props.js +0 -228
- package/components/fu-cell/props.js +0 -108
- package/components/fu-cell-group/props.js +0 -19
- package/components/fu-checkbox/fu-checkbox.vue +0 -469
- package/components/fu-checkbox/props.js +0 -126
- package/components/fu-code-input/fu-code-input.vue +0 -269
- package/components/fu-code-input/props.js +0 -136
- package/components/fu-code-verify/fu-code-verify.vue +0 -221
- package/components/fu-code-verify/props.js +0 -136
- package/components/fu-collapse/fu-collapse.vue +0 -143
- package/components/fu-collapse/props.js +0 -29
- package/components/fu-collapse-item/props.js +0 -101
- package/components/fu-countdown/fu-countdown.vue +0 -164
- package/components/fu-countdown/props.js +0 -35
- package/components/fu-datetime-picker/fu-datetime-picker.vue +0 -375
- package/components/fu-datetime-picker/props.js +0 -194
- package/components/fu-form/fu-form.vue +0 -284
- package/components/fu-form/props.js +0 -74
- package/components/fu-form-item/fu-form-item.vue +0 -535
- package/components/fu-form-item/props.js +0 -66
- package/components/fu-grid/fu-grid.vue +0 -113
- package/components/fu-grid/props.js +0 -44
- package/components/fu-grid-item/fu-grid-item.vue +0 -136
- package/components/fu-grid-item/props.js +0 -27
- package/components/fu-icon/fu-icon.vue +0 -110
- package/components/fu-icon/fuicon.js +0 -1031
- package/components/fu-icon/props.js +0 -55
- package/components/fu-image/fu-image.vue +0 -268
- package/components/fu-image/props.js +0 -145
- package/components/fu-index-anchor/fu-index-anchor.vue +0 -91
- package/components/fu-index-anchor/props.js +0 -43
- package/components/fu-index-item/fu-index-item.vue +0 -79
- package/components/fu-index-list/fu-index-list.vue +0 -426
- package/components/fu-index-list/props.js +0 -42
- package/components/fu-input/fu-input.vue +0 -393
- package/components/fu-input/props.js +0 -291
- package/components/fu-keyboard/keyboard-number.vue +0 -195
- package/components/fu-keyboard/props.js +0 -138
- package/components/fu-line/fu-line.vue +0 -64
- package/components/fu-line/props.js +0 -58
- package/components/fu-link/fu-link.vue +0 -91
- package/components/fu-link/props.js +0 -49
- package/components/fu-loading/props.js +0 -60
- package/components/fu-loading-more/props.js +0 -59
- package/components/fu-modal/props.js +0 -128
- package/components/fu-navbar/fu-navbar.vue +0 -271
- package/components/fu-navbar/props.js +0 -72
- package/components/fu-navbar/status-bar.vue +0 -27
- package/components/fu-notice-bar/notice-column.vue +0 -313
- package/components/fu-notice-bar/notice-row.vue +0 -363
- package/components/fu-notice-bar/props.js +0 -173
- package/components/fu-number-box/fu-number-box.vue +0 -210
- package/components/fu-number-box/props.js +0 -79
- package/components/fu-parse/fu-parse.vue +0 -508
- package/components/fu-parse/node/node.vue +0 -576
- package/components/fu-parse/parser.js +0 -1335
- package/components/fu-picker/fu-picker.vue +0 -347
- package/components/fu-picker/props.js +0 -150
- package/components/fu-popup/fu-popup.vue +0 -475
- package/components/fu-popup/keypress.js +0 -45
- package/components/fu-popup/props.js +0 -83
- package/components/fu-progress/fu-progress.vue +0 -292
- package/components/fu-progress/props.js +0 -76
- package/components/fu-rate/fu-rate.vue +0 -301
- package/components/fu-rate/props.js +0 -103
- package/components/fu-read-more/fu-read-more.vue +0 -191
- package/components/fu-read-more/props.js +0 -72
- package/components/fu-ribbon/fu-ribbon.vue +0 -106
- package/components/fu-ribbon/props.js +0 -35
- package/components/fu-safe-area/fu-safe-area.vue +0 -61
- package/components/fu-scroll-list/fu-scroll-list.vue +0 -196
- package/components/fu-scroll-list/nvue.js +0 -28
- package/components/fu-scroll-list/props.js +0 -43
- package/components/fu-search/props.js +0 -149
- package/components/fu-section/props.js +0 -59
- package/components/fu-sign-board/fu-sign-board.vue +0 -730
- package/components/fu-sign-board/props.js +0 -34
- package/components/fu-skeleton/fu-skeleton.vue +0 -238
- package/components/fu-skeleton/props.js +0 -35
- package/components/fu-steps/fu-steps.vue +0 -81
- package/components/fu-steps/props.js +0 -55
- package/components/fu-steps-item/fu-steps-item.vue +0 -274
- package/components/fu-steps-item/props.js +0 -34
- package/components/fu-sticky/fu-sticky.vue +0 -232
- package/components/fu-sticky/props.js +0 -54
- package/components/fu-subsection/fu-subsection.vue +0 -288
- package/components/fu-subsection/props.js +0 -88
- package/components/fu-swipe-action/fu-swipe-action.vue +0 -64
- package/components/fu-swipe-action-item/props.js +0 -54
- package/components/fu-swiper/props.js +0 -163
- package/components/fu-switch/props.js +0 -102
- package/components/fu-tabs/fu-tabs.vue +0 -361
- package/components/fu-tabs/props.js +0 -109
- package/components/fu-tag/props.js +0 -135
- package/components/fu-text/button.js +0 -13
- package/components/fu-text/fu-text.vue +0 -254
- package/components/fu-text/openType.js +0 -47
- package/components/fu-text/props.js +0 -173
- package/components/fu-text/value.js +0 -88
- package/components/fu-textarea/fu-textarea.vue +0 -288
- package/components/fu-textarea/props.js +0 -206
- package/components/fu-timeaxis-item/fu-timeaxis-item.vue +0 -68
- package/components/fu-transition/createAnimation.js +0 -131
- package/components/fu-transition/fu-transition.vue +0 -292
- package/components/fu-transition/props.js +0 -21
- package/components/fu-upload/fu-upload.vue +0 -563
- package/components/fu-upload/props.js +0 -171
- package/components/fu-upload/upload-file.vue +0 -332
- package/components/fu-upload/upload-image.vue +0 -304
- package/components/fu-vtabs/fu-vtabs.vue +0 -443
- package/components/fu-vtabs/props.js +0 -114
- package/components/fu-vtabs-item/fu-vtabs-item.vue +0 -71
- package/components/fu-waterfall/fu-waterfall.vue +0 -238
- package/components/fu-waterfall/props.js +0 -85
- package/index.js +0 -71
- package/libs/function/check.js +0 -215
- package/libs/function/common.js +0 -527
- package/libs/function/message.js +0 -47
- package/libs/mixin/button.js +0 -85
- package/libs/mixin/mixin.js +0 -94
- package/libs/mixin/mpMixin.js +0 -8
- package/libs/mixin/mpShare.js +0 -15
- package/libs/route/route.config.js +0 -66
- package/libs/style/color.scss +0 -24
- /package/components/{fu-icon → icon/src}/fuicon.ttf +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/bindingx.js +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/mpalipay.js +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/mpother.js +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/render.js +0 -0
- /package/{libs/style → style}/components.scss +0 -0
- /package/{libs/style → style}/style.h5.scss +0 -0
- /package/{libs/style → style}/style.mp.scss +0 -0
- /package/{libs/function → utils}/dayjs.js +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { computed, ref, watch, type SetupContext, provide } from 'vue';
|
|
2
|
+
import type { FormProps, FormEmits } from '../form';
|
|
3
|
+
import Validator from '../validate';
|
|
4
|
+
import {
|
|
5
|
+
deepCopy,
|
|
6
|
+
getValue,
|
|
7
|
+
isRequiredField,
|
|
8
|
+
setDataValue,
|
|
9
|
+
getDataValue,
|
|
10
|
+
realProp,
|
|
11
|
+
isRealProp,
|
|
12
|
+
rawData,
|
|
13
|
+
isEqual ,
|
|
14
|
+
} from '../utils'
|
|
15
|
+
|
|
16
|
+
export const useForm = (props: FormProps, $emit: SetupContext<FormEmits>['emit']) => {
|
|
17
|
+
// 表单本地值的记录,不应该与传如的值进行关联
|
|
18
|
+
const formData = ref<Record<string, any>>({});
|
|
19
|
+
const formRules = ref({});
|
|
20
|
+
// 原始的model快照,用于resetFields方法重置表单时使用
|
|
21
|
+
const originalModel = ref<any>(null);
|
|
22
|
+
// 子组件实例数组
|
|
23
|
+
const childrens = ref<any[]>([]);
|
|
24
|
+
let validator: any = null;
|
|
25
|
+
|
|
26
|
+
// 计算数据源变化的
|
|
27
|
+
const localData = computed(() => {
|
|
28
|
+
const localVal = props.model;
|
|
29
|
+
if (localVal) {
|
|
30
|
+
return deepCopy(localVal)
|
|
31
|
+
}
|
|
32
|
+
return {}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 外部调用方法
|
|
37
|
+
* 设置规则,主要用于小程序自定义检验规则
|
|
38
|
+
* @param {Array} rules 规则源数据
|
|
39
|
+
*/
|
|
40
|
+
const setRules = (rules: any) => {
|
|
41
|
+
// 有可能子组件合并规则的时机比这个要早,所以需要合并对象 ,而不是直接赋值,可能会被覆盖
|
|
42
|
+
formRules.value = Object.assign({}, formRules.value, rules);
|
|
43
|
+
// 初始化校验函数
|
|
44
|
+
validator = new Validator(rules);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 外部调用方法
|
|
49
|
+
* 设置数据,用于设置表单数据,公开给用户使用,不支持在动态表单中使用
|
|
50
|
+
* @param {Object} key
|
|
51
|
+
* @param {Object} value
|
|
52
|
+
*/
|
|
53
|
+
const setValue = (key: string, value: any) => {
|
|
54
|
+
let example = childrens.value.find(child => child.prop === key);
|
|
55
|
+
if (!example) return null;
|
|
56
|
+
formData.value[key] = getValue(key, value, (formRules.value[key] && formRules.value[key].rules) || [])
|
|
57
|
+
return example.onFieldChange(formData.value[key]);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 外部调用方法
|
|
62
|
+
* 手动提交校验表单
|
|
63
|
+
* 对整个表单进行校验的方法,参数为一个回调函数。
|
|
64
|
+
* @param {Array} keepitem 保留不参与校验的字段
|
|
65
|
+
* @param {type} callback 方法回调
|
|
66
|
+
*/
|
|
67
|
+
const validate = (keepitem?: any[] | Function, callback?: Function): Promise<any> => {
|
|
68
|
+
return checkAll(formData.value, keepitem, callback);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 外部调用方法
|
|
73
|
+
* 部分表单校验
|
|
74
|
+
* @param {Array|String} propsList 需要校验的字段
|
|
75
|
+
* @param {Function} callback 回调函数
|
|
76
|
+
*/
|
|
77
|
+
const validateField = (propsList: string | string[] = [], callback?: Function): Promise<any> => {
|
|
78
|
+
const fields = [].concat(propsList);
|
|
79
|
+
let invalidFields: Record<string, any> = {};
|
|
80
|
+
childrens.value.forEach(item => {
|
|
81
|
+
const prop = realProp(item.prop)
|
|
82
|
+
if (fields.indexOf(prop) !== -1) {
|
|
83
|
+
invalidFields = Object.assign({}, invalidFields, {
|
|
84
|
+
[prop]: formData.value[prop]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return checkAll(invalidFields, [], callback);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 外部调用方法
|
|
93
|
+
* 手动重置表单
|
|
94
|
+
* 清空所有fu-form-item组件的内容,本质上是调用了fu-form-item中的resetFields()方法
|
|
95
|
+
*/
|
|
96
|
+
const resetFields = () => {
|
|
97
|
+
resetModel()
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// 重置model为初始值的快照
|
|
101
|
+
const resetModel = () => {
|
|
102
|
+
childrens.value.map((item) => {
|
|
103
|
+
const prop = item?.prop;
|
|
104
|
+
const value = uni.$fu.getProperty(originalModel.value, prop);
|
|
105
|
+
uni.$fu.setProperty(props.model, prop, value);
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 外部调用方法
|
|
111
|
+
* 移除表单项的校验结果。传入待移除的表单项的 prop 属性或者 prop 组成的数组,如不传则移除整个表单的校验结果
|
|
112
|
+
* @param {Array|String} propsList 需要移除校验的字段 ,不填为所有
|
|
113
|
+
*/
|
|
114
|
+
const clearValidate = (propsList: string | string[] = []) => {
|
|
115
|
+
const fields = [].concat(propsList);
|
|
116
|
+
childrens.value.forEach(item => {
|
|
117
|
+
if (fields.length === 0) {
|
|
118
|
+
item.errMsg = '';
|
|
119
|
+
} else {
|
|
120
|
+
const prop = realProp(item.prop)
|
|
121
|
+
if (fields.indexOf(prop) !== -1) {
|
|
122
|
+
item.errMsg = '';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// 校验所有
|
|
129
|
+
const checkAll = async (
|
|
130
|
+
invalidFields: Record<string, any>,
|
|
131
|
+
keepitem: any[] | Function,
|
|
132
|
+
callback?: Function,
|
|
133
|
+
_type?: string
|
|
134
|
+
) => {
|
|
135
|
+
// 不存在校验规则 ,则停止校验流程
|
|
136
|
+
if (!validator) return null
|
|
137
|
+
|
|
138
|
+
let items: any[] = [];
|
|
139
|
+
// 处理参与校验的item实例
|
|
140
|
+
for (let i in invalidFields) {
|
|
141
|
+
const item = childrens.value.find(item => realProp(item.prop) === i);
|
|
142
|
+
if (item) {
|
|
143
|
+
items.push(item)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 如果validate第一个参数是function, 那就走回调
|
|
148
|
+
if (!callback && typeof keepitem === 'function') {
|
|
149
|
+
callback = keepitem;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let promise: Promise<any> | undefined;
|
|
153
|
+
// 如果不存在回调,那么使用 Promise 方式返回
|
|
154
|
+
if (!callback && typeof callback !== 'function' && Promise) {
|
|
155
|
+
promise = new Promise((resolve, reject) => {
|
|
156
|
+
callback = (valid: boolean, invalidFields: any) => {
|
|
157
|
+
!valid ? resolve(invalidFields) : reject(valid);
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let results = [];
|
|
163
|
+
// 避免引用错乱 ,建议拷贝对象处理
|
|
164
|
+
let tempFormData = JSON.parse(JSON.stringify(invalidFields))
|
|
165
|
+
// 所有子组件参与校验,使用 for 可以使用 awiat
|
|
166
|
+
for (let i in items) {
|
|
167
|
+
const child = items[i];
|
|
168
|
+
let prop = realProp(child.prop);
|
|
169
|
+
const result = await child.onFieldChange(tempFormData[prop]);
|
|
170
|
+
if (result) {
|
|
171
|
+
results.push(result);
|
|
172
|
+
// toast ,modal 只需要执行第一次就可以
|
|
173
|
+
if (props.errShowType === 'toast' || props.errShowType === 'modal') break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (Array.isArray(results)) {
|
|
178
|
+
if (results.length === 0) results = null;
|
|
179
|
+
}
|
|
180
|
+
if (Array.isArray(keepitem)) {
|
|
181
|
+
keepitem.forEach(item => {
|
|
182
|
+
let itemProp = realProp(item);
|
|
183
|
+
let value = getDataValue(item, localData.value)
|
|
184
|
+
if (value !== undefined) {
|
|
185
|
+
tempFormData[itemProp] = value
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
validateCheck(results)
|
|
191
|
+
|
|
192
|
+
const resetFormData = rawData(tempFormData);
|
|
193
|
+
callback && typeof callback === 'function' && callback(results, resetFormData);
|
|
194
|
+
|
|
195
|
+
if (promise && callback) {
|
|
196
|
+
return promise;
|
|
197
|
+
} else {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 返回validate事件
|
|
204
|
+
* @param {Object} result
|
|
205
|
+
*/
|
|
206
|
+
const validateCheck = (result: any) => {
|
|
207
|
+
$emit('validate', result);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// watch监听事件
|
|
211
|
+
// 监听规则变化
|
|
212
|
+
watch(() => props.rules, (newVal) => {
|
|
213
|
+
setRules(newVal)
|
|
214
|
+
}, { immediate: true, deep: true });
|
|
215
|
+
|
|
216
|
+
// 监听model变化
|
|
217
|
+
watch(() => props.model, (newVal) => {
|
|
218
|
+
if (!originalModel.value && newVal) {
|
|
219
|
+
originalModel.value = uni.$fu.deepClone(newVal);
|
|
220
|
+
}
|
|
221
|
+
}, { immediate: true });
|
|
222
|
+
|
|
223
|
+
// 提供父组件上下文
|
|
224
|
+
provide('formContext', {
|
|
225
|
+
childrens,
|
|
226
|
+
formData,
|
|
227
|
+
formRules: formRules.value,
|
|
228
|
+
validator,
|
|
229
|
+
localData,
|
|
230
|
+
labelWidth: props.labelWidth,
|
|
231
|
+
labelPosition: props.labelPosition,
|
|
232
|
+
labelAlign: props.labelAlign,
|
|
233
|
+
errShowType: props.errShowType,
|
|
234
|
+
validateTrigger: props.validateTrigger,
|
|
235
|
+
border: props.border,
|
|
236
|
+
isFirstBorder: false,
|
|
237
|
+
validateCheck,
|
|
238
|
+
_getValue: getValue,
|
|
239
|
+
_isRequiredField: isRequiredField,
|
|
240
|
+
_setDataValue: setDataValue,
|
|
241
|
+
_getDataValue: getDataValue,
|
|
242
|
+
_realProp: realProp,
|
|
243
|
+
_isRealProp: isRealProp,
|
|
244
|
+
_isEqual: isEqual
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
formData,
|
|
249
|
+
setRules,
|
|
250
|
+
setValue,
|
|
251
|
+
validate,
|
|
252
|
+
validateField,
|
|
253
|
+
resetFields,
|
|
254
|
+
clearValidate
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 表单 validateTrigger 有效值
|
|
5
|
+
*/
|
|
6
|
+
export const formValidateTriggers = ['bind', 'submit', 'blur'] as const;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 表单 errShowType 有效值
|
|
10
|
+
*/
|
|
11
|
+
export const formErrShowTypes = ['undertext', 'toast', 'modal'] as const;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 表单 labelPosition 有效值
|
|
15
|
+
*/
|
|
16
|
+
export const formLabelPositions = ['top', 'left'] as const;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 表单 labelAlign 有效值
|
|
20
|
+
*/
|
|
21
|
+
export const formLabelAligns = ['left', 'center', 'right'] as const;
|
|
22
|
+
|
|
23
|
+
export const formProps = {
|
|
24
|
+
/**
|
|
25
|
+
* @description 绑定数据
|
|
26
|
+
* @default null
|
|
27
|
+
*/
|
|
28
|
+
model: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default() {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* @description 表单校验规则
|
|
36
|
+
*/
|
|
37
|
+
rules: {
|
|
38
|
+
type: Object,
|
|
39
|
+
default() {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* @description 校验触发器方式
|
|
45
|
+
* @values 'bind' - 发生变化时触发, 'submit' - 提交时触发, 'blur' - 失去焦点时触发
|
|
46
|
+
* @default 'submit'
|
|
47
|
+
*/
|
|
48
|
+
validateTrigger: {
|
|
49
|
+
type: String,
|
|
50
|
+
values: formValidateTriggers,
|
|
51
|
+
default: 'submit'
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* @description 校验错误信息提示方式
|
|
55
|
+
* @values 'undertext' - 错误信息在底部显示, 'toast' - 错误信息toast显示, 'modal' - 错误信息modal显示
|
|
56
|
+
* @default 'undertext'
|
|
57
|
+
*/
|
|
58
|
+
errShowType: {
|
|
59
|
+
type: String,
|
|
60
|
+
values: formErrShowTypes,
|
|
61
|
+
default: 'undertext'
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* @description label 位置
|
|
65
|
+
* @values 'top' - 顶部显示 label, 'left' - 左侧显示 label
|
|
66
|
+
* @default 'left'
|
|
67
|
+
*/
|
|
68
|
+
labelPosition: {
|
|
69
|
+
type: String,
|
|
70
|
+
values: formLabelPositions,
|
|
71
|
+
default: 'left'
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* @description label 宽度
|
|
75
|
+
*/
|
|
76
|
+
labelWidth: {
|
|
77
|
+
type: [String, Number],
|
|
78
|
+
default: ''
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* @description label 居中方式
|
|
82
|
+
* @values 'left' - label 左侧对齐, 'center' - label 居中, 'right' - label 右侧对齐
|
|
83
|
+
* @default 'left'
|
|
84
|
+
*/
|
|
85
|
+
labelAlign: {
|
|
86
|
+
type: String,
|
|
87
|
+
values: formLabelAligns,
|
|
88
|
+
default: 'left'
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* @description 是否显示边框
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
border: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const formEmits = {
|
|
101
|
+
/**
|
|
102
|
+
* @description 校验结果发生变化触发
|
|
103
|
+
*/
|
|
104
|
+
validate: (_result : any) => true
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type FormProps = ExtractPropTypes<typeof formProps>;
|
|
108
|
+
export type FormEmits = typeof formEmits;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="fu-form">
|
|
3
|
+
<form>
|
|
4
|
+
<slot></slot>
|
|
5
|
+
</form>
|
|
6
|
+
</view>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
/**
|
|
11
|
+
* Form 表单
|
|
12
|
+
* @description 此组件由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据
|
|
13
|
+
* @tutorial http://www.fusions.top/components/form.html
|
|
14
|
+
* @property {Object} model 表单数据
|
|
15
|
+
* @property {Object} rules 表单校验规则
|
|
16
|
+
* @property {String} validateTrigger = [bind|submit|blur] 校验触发器方式 默认 submit
|
|
17
|
+
* @value bind 发生变化时触发
|
|
18
|
+
* @value submit 提交时触发
|
|
19
|
+
* @value blur 失去焦点时触发
|
|
20
|
+
* @property {String} labelPosition = [top|left] label 位置 默认 left
|
|
21
|
+
* @value top 顶部显示 label
|
|
22
|
+
* @value left 左侧显示 label
|
|
23
|
+
* @property {String} labelWidth label 宽度,默认 70
|
|
24
|
+
* @property {String} labelAlign = [left|center|right] label 居中方式 默认 left
|
|
25
|
+
* @value left label 左侧对齐
|
|
26
|
+
* @value center label 居中
|
|
27
|
+
* @value right label 右侧对齐
|
|
28
|
+
* @property {String} errShowType = [undertext|toast|modal] 校验错误信息提示方式
|
|
29
|
+
* @value undertext 错误信息在底部显示
|
|
30
|
+
* @value toast 错误信息toast显示
|
|
31
|
+
* @value modal 错误信息modal显示
|
|
32
|
+
* @event {Function} validate 校验结果发生变化触发
|
|
33
|
+
*/
|
|
34
|
+
import { formEmits, formProps } from './form';
|
|
35
|
+
import { useForm } from './composables';
|
|
36
|
+
|
|
37
|
+
defineOptions({ name: 'FuForm', options: { virtualHost: true } });
|
|
38
|
+
|
|
39
|
+
const props = defineProps(formProps);
|
|
40
|
+
const $emit = defineEmits(formEmits);
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
setRules,
|
|
44
|
+
setValue,
|
|
45
|
+
validate,
|
|
46
|
+
validateField,
|
|
47
|
+
resetFields,
|
|
48
|
+
clearValidate
|
|
49
|
+
} = useForm(props, $emit);
|
|
50
|
+
|
|
51
|
+
// 暴露方法
|
|
52
|
+
defineExpose({
|
|
53
|
+
setRules,
|
|
54
|
+
setValue,
|
|
55
|
+
validate,
|
|
56
|
+
validateField,
|
|
57
|
+
resetFields,
|
|
58
|
+
clearValidate
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<style>
|
|
63
|
+
|
|
64
|
+
</style>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 简单处理对象拷贝
|
|
3
|
-
* @param {Obejct} 被拷贝对象
|
|
4
|
-
*
|
|
3
|
+
* @param {Obejct} value 被拷贝对象
|
|
4
|
+
* @return {Object} 拷贝对象
|
|
5
5
|
*/
|
|
6
|
-
export const deepCopy = (
|
|
7
|
-
return JSON.parse(JSON.stringify(
|
|
6
|
+
export const deepCopy = <T>(value: T): T => {
|
|
7
|
+
return JSON.parse(JSON.stringify(value))
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* 过滤数字类型
|
|
11
11
|
* @param {String} format 数字类型
|
|
12
|
-
*
|
|
12
|
+
* @return {Boolean} 返回是否为数字类型
|
|
13
13
|
*/
|
|
14
|
-
export const typeFilter = (format) => {
|
|
14
|
+
export const typeFilter = (format: string): boolean => {
|
|
15
15
|
return format === 'int' || format === 'double' || format === 'number' || format === 'timestamp';
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -21,21 +21,21 @@ export const typeFilter = (format) => {
|
|
|
21
21
|
* @param {any} value 字段值
|
|
22
22
|
* @param {Object} rules 表单校验规则
|
|
23
23
|
*/
|
|
24
|
-
export const getValue = (key, value, rules) => {
|
|
24
|
+
export const getValue = (key: string, value: any, rules: any[]): any => {
|
|
25
25
|
const isRuleNumType = rules.find(val => val.format && typeFilter(val.format));
|
|
26
26
|
const isRuleBoolType = rules.find(val => (val.format && val.format === 'boolean') || val.format === 'bool');
|
|
27
27
|
// 输入类型为 number
|
|
28
28
|
if (!!isRuleNumType) {
|
|
29
29
|
if (!value && value !== 0) {
|
|
30
|
-
value = null
|
|
30
|
+
value = null;
|
|
31
31
|
} else {
|
|
32
|
-
value = isNumber(Number(value))
|
|
32
|
+
value = isNumber(Number(value))? Number(value): value;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// 输入类型为 boolean
|
|
37
37
|
if (!!isRuleBoolType) {
|
|
38
|
-
value = isBoolean(value) ? value : false
|
|
38
|
+
value = isBoolean(value) ? value : false;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return value;
|
|
@@ -44,11 +44,11 @@ export const getValue = (key, value, rules) => {
|
|
|
44
44
|
/**
|
|
45
45
|
* 获取表单数据
|
|
46
46
|
* @param {String|Array} field 真实名称,需要使用 realProp 获取
|
|
47
|
-
* @param {Object}
|
|
47
|
+
* @param {Object} formdata 原始数据
|
|
48
48
|
* @param {any} value 需要设置的值
|
|
49
49
|
*/
|
|
50
|
-
export const setDataValue = (field, formdata, value) => {
|
|
51
|
-
formdata[field] = value
|
|
50
|
+
export const setDataValue = <T extends Record<string, any>>(field: keyof T & string, formdata: T, value: any) => {
|
|
51
|
+
formdata[field] = value;
|
|
52
52
|
return value || ''
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -57,7 +57,7 @@ export const setDataValue = (field, formdata, value) => {
|
|
|
57
57
|
* @param {String|Array} field 真实名称,需要使用 realProp 获取
|
|
58
58
|
* @param {Object} data 原始数据
|
|
59
59
|
*/
|
|
60
|
-
export const getDataValue = (field, data) => {
|
|
60
|
+
export const getDataValue = <T extends Record<string, any>>(field: string, data: T) => {
|
|
61
61
|
return objGet(data, field)
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -65,8 +65,8 @@ export const getDataValue = (field, data) => {
|
|
|
65
65
|
* 获取表单类型
|
|
66
66
|
* @param {String|Array} field 真实名称,需要使用 realProp 获取
|
|
67
67
|
*/
|
|
68
|
-
export const getDataValueType = (field, data) => {
|
|
69
|
-
const value = getDataValue(field, data)
|
|
68
|
+
export const getDataValueType = <T extends Record<string, any>>(field: string, data: T) => {
|
|
69
|
+
const value = getDataValue(field, data);
|
|
70
70
|
return {
|
|
71
71
|
type: type(value),
|
|
72
72
|
value
|
|
@@ -76,32 +76,34 @@ export const getDataValueType = (field, data) => {
|
|
|
76
76
|
/**
|
|
77
77
|
* 获取表单可用的真实prop
|
|
78
78
|
* @param {String|Array} prop 表单prop
|
|
79
|
-
*
|
|
79
|
+
* @return {String} 表单可用的真实prop
|
|
80
80
|
*/
|
|
81
|
-
export const realProp = (prop, data = {}) => {
|
|
82
|
-
const
|
|
83
|
-
if (typeof
|
|
84
|
-
const real_prop =
|
|
81
|
+
export const realProp = (prop: string | any[], data: any = {}): string => {
|
|
82
|
+
const baseProp = _basePath(prop)
|
|
83
|
+
if (typeof baseProp === 'object' && Array.isArray(baseProp) && baseProp.length > 1) {
|
|
84
|
+
const real_prop = baseProp.reduce((a, b) => a += `#${b}`, '_formdata_')
|
|
85
85
|
return real_prop
|
|
86
86
|
}
|
|
87
|
-
return
|
|
87
|
+
return (baseProp as string[])[0] || prop as string
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* 判断是否表单可用的真实prop
|
|
92
92
|
* @param {String|Array} prop 表单prop
|
|
93
|
-
*
|
|
93
|
+
* @return {String} 表单可用的真实prop
|
|
94
94
|
*/
|
|
95
|
-
export const isRealProp = (prop) => {
|
|
95
|
+
export const isRealProp = (prop: string): boolean => {
|
|
96
96
|
const reg = /^_formdata_#*/
|
|
97
97
|
return reg.test(prop)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* 获取表单数据的原始格式
|
|
102
|
-
*
|
|
102
|
+
* @param object 需要解析的数据
|
|
103
|
+
* @param prop 可选属性
|
|
104
|
+
* @returns 解析后的数据
|
|
103
105
|
*/
|
|
104
|
-
export const rawData = (object = {}, prop) => {
|
|
106
|
+
export const rawData = <T extends Record<string, any>>(object: T = {} as T, prop?: string): Record<string, any> => {
|
|
105
107
|
let newData = JSON.parse(JSON.stringify(object))
|
|
106
108
|
let formData = {}
|
|
107
109
|
for(let i in newData){
|
|
@@ -113,23 +115,24 @@ export const rawData = (object = {}, prop) => {
|
|
|
113
115
|
|
|
114
116
|
/**
|
|
115
117
|
* 真实prop还原为 array
|
|
116
|
-
* @param {*} prop
|
|
118
|
+
* @param {*} prop 真实prop
|
|
119
|
+
* @returns 数组路径
|
|
117
120
|
*/
|
|
118
|
-
export const prop2arr = (prop) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return
|
|
121
|
+
export const prop2arr = (prop: string): (string | number)[] => {
|
|
122
|
+
const fieldStr = prop.replace('_formdata_#', '');
|
|
123
|
+
const result = fieldStr.split('#').map(v => (isNumber(v) ? Number(v) : v));
|
|
124
|
+
return result
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
/**
|
|
125
128
|
* 对象中设置值
|
|
126
129
|
* @param {Object|Array} object 源数据
|
|
127
|
-
* @param {String|
|
|
130
|
+
* @param {String|Array} path 'a.b.c' 或 ['a',0,'b','c']
|
|
128
131
|
* @param {String} value 需要设置的值
|
|
129
132
|
*/
|
|
130
|
-
export const objSet = (object, path, value) => {
|
|
133
|
+
export const objSet = <T extends Record<string, any>>(object: T, path: string | any[], value: any): T => {
|
|
131
134
|
if (typeof object !== 'object') return object;
|
|
132
|
-
_basePath(path).reduce((o, k, i, _) => {
|
|
135
|
+
_basePath(path).reduce((o: any, k: any, i: number, _: any[]) => {
|
|
133
136
|
if (i === _.length - 1) {
|
|
134
137
|
// 若遍历结束直接赋值
|
|
135
138
|
o[k] = value
|
|
@@ -147,8 +150,12 @@ export const objSet = (object, path, value) => {
|
|
|
147
150
|
return object;
|
|
148
151
|
}
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
/**
|
|
154
|
+
* 处理 path, path有三种形式:'a[0].b.c'、'a.0.b.c' 和 ['a','0','b','c'],需要统一处理成数组,便于后续使用
|
|
155
|
+
* @param path 路径
|
|
156
|
+
* @returns 数组路径
|
|
157
|
+
*/
|
|
158
|
+
function _basePath(path: string | any[]): string[] {
|
|
152
159
|
// 若是数组,则直接返回
|
|
153
160
|
if (Array.isArray(path)) return path
|
|
154
161
|
// 若有 '[',']',则替换成将 '[' 替换成 '.',去掉 ']'
|
|
@@ -161,7 +168,7 @@ function _basePath(path) {
|
|
|
161
168
|
* @param {String| Array} path 'a.b.c' 或 ['a',0,'b','c']
|
|
162
169
|
* @param {String} defaultVal 如果无法从调用链中获取值的默认值
|
|
163
170
|
*/
|
|
164
|
-
export const objGet = (object, path, defaultVal = 'undefined') => {
|
|
171
|
+
export const objGet = <T extends Record<string, any>>(object: T, path: string | any[], defaultVal: any = 'undefined'): any => {
|
|
165
172
|
// 先将path处理成统一格式
|
|
166
173
|
let newPath = _basePath(path)
|
|
167
174
|
// 递归处理,返回最后结果
|
|
@@ -177,7 +184,7 @@ export const objGet = (object, path, defaultVal = 'undefined') => {
|
|
|
177
184
|
* @param {any} num 需要判断的值
|
|
178
185
|
* @return {Boolean} 是否为 number
|
|
179
186
|
*/
|
|
180
|
-
export const isNumber = (num) => {
|
|
187
|
+
export const isNumber = (num: any): boolean => {
|
|
181
188
|
return !isNaN(Number(num))
|
|
182
189
|
}
|
|
183
190
|
|
|
@@ -186,7 +193,7 @@ export const isNumber = (num) => {
|
|
|
186
193
|
* @param {any} bool 需要判断的值
|
|
187
194
|
* @return {Boolean} 是否为 boolean
|
|
188
195
|
*/
|
|
189
|
-
export const isBoolean = (bool) => {
|
|
196
|
+
export const isBoolean = (bool: any): boolean => {
|
|
190
197
|
return (typeof bool === 'boolean')
|
|
191
198
|
}
|
|
192
199
|
/**
|
|
@@ -194,7 +201,7 @@ export const isBoolean = (bool) => {
|
|
|
194
201
|
* @param {Object} rules 规则
|
|
195
202
|
* @return {Boolean} 是否有必填字段
|
|
196
203
|
*/
|
|
197
|
-
export const isRequiredField = (rules) => {
|
|
204
|
+
export const isRequiredField = (rules: any): boolean => {
|
|
198
205
|
let isNoField = false;
|
|
199
206
|
for (let i = 0; i < rules.length; i++) {
|
|
200
207
|
const ruleData = rules[i];
|
|
@@ -211,7 +218,7 @@ export const isRequiredField = (rules) => {
|
|
|
211
218
|
* 获取数据类型
|
|
212
219
|
* @param {Any} obj 需要获取数据类型的值
|
|
213
220
|
*/
|
|
214
|
-
export const type = (obj) => {
|
|
221
|
+
export const type = (obj: any): string => {
|
|
215
222
|
var class2type = {};
|
|
216
223
|
|
|
217
224
|
// 生成class2type映射
|
|
@@ -232,7 +239,7 @@ export const type = (obj) => {
|
|
|
232
239
|
* @param {any} b 值
|
|
233
240
|
* @return {Boolean} 是否相等
|
|
234
241
|
*/
|
|
235
|
-
export const isEqual = (a, b) => {
|
|
242
|
+
export const isEqual = (a: any, b: any): boolean => {
|
|
236
243
|
//如果a和b本来就全等
|
|
237
244
|
if (a === b) {
|
|
238
245
|
//判断是否为0和-0
|