@wot-ui/ui 1.0.0 → 2.0.0-alpha.3
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 +21 -0
- package/README.md +134 -0
- package/attributes.json +1 -0
- package/changelog.md +53 -0
- package/common/AbortablePromise.ts +28 -0
- package/common/canvasHelper.ts +49 -0
- package/common/clickoutside.ts +25 -0
- package/common/event.ts +8 -0
- package/common/formatDate.ts +68 -0
- package/common/interceptor.ts +43 -0
- package/common/props.ts +53 -0
- package/common/util.ts +836 -0
- package/components/wd-action-sheet/index.scss +232 -0
- package/components/wd-action-sheet/types.ts +155 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +176 -0
- package/components/wd-avatar/index.scss +150 -0
- package/components/wd-avatar/types.ts +98 -0
- package/components/wd-avatar/wd-avatar.vue +184 -0
- package/components/wd-avatar-group/index.scss +11 -0
- package/components/wd-avatar-group/types.ts +61 -0
- package/components/wd-avatar-group/wd-avatar-group.vue +115 -0
- package/components/wd-backtop/index.scss +67 -0
- package/components/wd-backtop/types.ts +66 -0
- package/components/wd-backtop/wd-backtop.vue +57 -0
- package/components/wd-badge/index.scss +116 -0
- package/components/wd-badge/types.ts +94 -0
- package/components/wd-badge/wd-badge.vue +78 -0
- package/components/wd-button/index.scss +436 -0
- package/components/wd-button/types.ts +204 -0
- package/components/wd-button/wd-button.vue +210 -0
- package/components/wd-calendar/index.scss +97 -0
- package/components/wd-calendar/types.ts +221 -0
- package/components/wd-calendar/wd-calendar.vue +339 -0
- package/components/wd-calendar-view/index.scss +41 -0
- package/components/wd-calendar-view/month/index.scss +144 -0
- package/components/wd-calendar-view/month/month.vue +389 -0
- package/components/wd-calendar-view/month/types.ts +70 -0
- package/components/wd-calendar-view/monthPanel/index.scss +84 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +541 -0
- package/components/wd-calendar-view/monthPanel/types.ts +151 -0
- package/components/wd-calendar-view/types.ts +166 -0
- package/components/wd-calendar-view/utils.ts +318 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +117 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +74 -0
- package/components/wd-calendar-view/year/year.vue +206 -0
- package/components/wd-calendar-view/yearPanel/index.scss +42 -0
- package/components/wd-calendar-view/yearPanel/types.ts +96 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +249 -0
- package/components/wd-card/index.scss +104 -0
- package/components/wd-card/types.ts +47 -0
- package/components/wd-card/wd-card.vue +38 -0
- package/components/wd-cascader/index.scss +154 -0
- package/components/wd-cascader/types.ts +191 -0
- package/components/wd-cascader/wd-cascader.vue +589 -0
- package/components/wd-cell/index.scss +244 -0
- package/components/wd-cell/types.ts +205 -0
- package/components/wd-cell/wd-cell.vue +172 -0
- package/components/wd-cell-group/index.scss +53 -0
- package/components/wd-cell-group/types.ts +97 -0
- package/components/wd-cell-group/wd-cell-group.vue +48 -0
- package/components/wd-checkbox/index.scss +166 -0
- package/components/wd-checkbox/types.ts +118 -0
- package/components/wd-checkbox/wd-checkbox.vue +216 -0
- package/components/wd-checkbox-group/index.scss +5 -0
- package/components/wd-checkbox-group/types.ts +93 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +148 -0
- package/components/wd-circle/index.scss +28 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +306 -0
- package/components/wd-col/index.scss +5 -0
- package/components/wd-col/types.ts +16 -0
- package/components/wd-col/wd-col.vue +83 -0
- package/components/wd-collapse/index.scss +71 -0
- package/components/wd-collapse/types.ts +68 -0
- package/components/wd-collapse/wd-collapse.vue +165 -0
- package/components/wd-collapse-item/index.scss +86 -0
- package/components/wd-collapse-item/types.ts +62 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +184 -0
- package/components/wd-config-provider/index.scss +10 -0
- package/components/wd-config-provider/types.ts +2063 -0
- package/components/wd-config-provider/wd-config-provider.vue +61 -0
- package/components/wd-count-down/index.scss +16 -0
- package/components/wd-count-down/types.ts +58 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +62 -0
- package/components/wd-count-to/index.scss +25 -0
- package/components/wd-count-to/types.ts +121 -0
- package/components/wd-count-to/wd-count-to.vue +126 -0
- package/components/wd-curtain/index.scss +96 -0
- package/components/wd-curtain/types.ts +82 -0
- package/components/wd-curtain/wd-curtain.vue +172 -0
- package/components/wd-datetime-picker/index.scss +133 -0
- package/components/wd-datetime-picker/types.ts +198 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +526 -0
- package/components/wd-datetime-picker-view/types.ts +171 -0
- package/components/wd-datetime-picker-view/util.ts +30 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +402 -0
- package/components/wd-dialog/index.scss +281 -0
- package/components/wd-dialog/index.ts +168 -0
- package/components/wd-dialog/types.ts +452 -0
- package/components/wd-dialog/wd-dialog.vue +586 -0
- package/components/wd-divider/index.scss +122 -0
- package/components/wd-divider/types.ts +50 -0
- package/components/wd-divider/wd-divider.vue +54 -0
- package/components/wd-drop-menu/index.scss +90 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +168 -0
- package/components/wd-drop-menu-item/index.scss +96 -0
- package/components/wd-drop-menu-item/types.ts +93 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +205 -0
- package/components/wd-empty/index.scss +46 -0
- package/components/wd-empty/types.ts +37 -0
- package/components/wd-empty/wd-empty.vue +47 -0
- package/components/wd-fab/index.scss +124 -0
- package/components/wd-fab/types.ts +119 -0
- package/components/wd-fab/wd-fab.vue +322 -0
- package/components/wd-floating-panel/index.scss +73 -0
- package/components/wd-floating-panel/type.ts +32 -0
- package/components/wd-floating-panel/wd-floating-panel.vue +142 -0
- package/components/wd-form/adapters/zod.ts +56 -0
- package/components/wd-form/types.ts +147 -0
- package/components/wd-form/wd-form.vue +121 -0
- package/components/wd-form-item/index.scss +26 -0
- package/components/wd-form-item/types.ts +134 -0
- package/components/wd-form-item/wd-form-item.vue +182 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +26 -0
- package/components/wd-gap/wd-gap.vue +38 -0
- package/components/wd-grid/index.scss +11 -0
- package/components/wd-grid/types.ts +97 -0
- package/components/wd-grid/wd-grid.vue +48 -0
- package/components/wd-grid-item/index.scss +187 -0
- package/components/wd-grid-item/types.ts +98 -0
- package/components/wd-grid-item/wd-grid-item.vue +295 -0
- package/components/wd-icon/index.scss +46 -0
- package/components/wd-icon/types.ts +44 -0
- package/components/wd-icon/wd-icon.vue +66 -0
- package/components/wd-image-preview/index.scss +94 -0
- package/components/wd-image-preview/index.ts +95 -0
- package/components/wd-image-preview/types.ts +165 -0
- package/components/wd-image-preview/wd-image-preview.vue +233 -0
- package/components/wd-img/index.scss +82 -0
- package/components/wd-img/types.ts +96 -0
- package/components/wd-img/wd-img.vue +91 -0
- package/components/wd-img-cropper/index.scss +259 -0
- package/components/wd-img-cropper/types.ts +101 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +653 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +55 -0
- package/components/wd-index-bar/index.scss +68 -0
- package/components/wd-index-bar/type.ts +23 -0
- package/components/wd-index-bar/wd-index-bar.vue +157 -0
- package/components/wd-input/index.scss +129 -0
- package/components/wd-input/types.ts +165 -0
- package/components/wd-input/wd-input.vue +237 -0
- package/components/wd-input-number/index.scss +233 -0
- package/components/wd-input-number/types.ts +131 -0
- package/components/wd-input-number/wd-input-number.vue +473 -0
- package/components/wd-keyboard/constants.ts +81 -0
- package/components/wd-keyboard/index.scss +104 -0
- package/components/wd-keyboard/key/index.scss +103 -0
- package/components/wd-keyboard/key/index.vue +84 -0
- package/components/wd-keyboard/key/types.ts +44 -0
- package/components/wd-keyboard/types.ts +138 -0
- package/components/wd-keyboard/wd-keyboard.vue +236 -0
- package/components/wd-loading/index.scss +205 -0
- package/components/wd-loading/types.ts +61 -0
- package/components/wd-loading/wd-loading.vue +70 -0
- package/components/wd-loadmore/index.scss +62 -0
- package/components/wd-loadmore/types.ts +42 -0
- package/components/wd-loadmore/wd-loadmore.vue +68 -0
- package/components/wd-navbar/index.scss +96 -0
- package/components/wd-navbar/types.ts +74 -0
- package/components/wd-navbar/wd-navbar.vue +136 -0
- package/components/wd-navbar-capsule/index.scss +70 -0
- package/components/wd-navbar-capsule/types.ts +11 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +48 -0
- package/components/wd-notice-bar/index.scss +94 -0
- package/components/wd-notice-bar/types.ts +97 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +270 -0
- package/components/wd-notify/index.scss +114 -0
- package/components/wd-notify/index.ts +63 -0
- package/components/wd-notify/types.ts +130 -0
- package/components/wd-notify/wd-notify.vue +162 -0
- package/components/wd-overlay/index.scss +14 -0
- package/components/wd-overlay/types.ts +42 -0
- package/components/wd-overlay/wd-overlay.vue +55 -0
- package/components/wd-pagination/index.scss +71 -0
- package/components/wd-pagination/types.ts +69 -0
- package/components/wd-pagination/wd-pagination.vue +118 -0
- package/components/wd-password-input/index.scss +134 -0
- package/components/wd-password-input/types.ts +42 -0
- package/components/wd-password-input/wd-password-input.vue +51 -0
- package/components/wd-picker/index.scss +72 -0
- package/components/wd-picker/types.ts +141 -0
- package/components/wd-picker/wd-picker.vue +220 -0
- package/components/wd-picker-view/index.scss +93 -0
- package/components/wd-picker-view/types.ts +145 -0
- package/components/wd-picker-view/useSelection.ts +385 -0
- package/components/wd-picker-view/wd-picker-view.vue +227 -0
- package/components/wd-popover/index.scss +117 -0
- package/components/wd-popover/types.ts +106 -0
- package/components/wd-popover/wd-popover.vue +212 -0
- package/components/wd-popup/index.scss +89 -0
- package/components/wd-popup/types.ts +110 -0
- package/components/wd-popup/wd-popup.vue +174 -0
- package/components/wd-progress/index.scss +155 -0
- package/components/wd-progress/types.ts +94 -0
- package/components/wd-progress/wd-progress.vue +249 -0
- package/components/wd-radio/index.scss +189 -0
- package/components/wd-radio/types.ts +64 -0
- package/components/wd-radio/wd-radio.vue +164 -0
- package/components/wd-radio-group/index.scss +5 -0
- package/components/wd-radio-group/types.ts +70 -0
- package/components/wd-radio-group/wd-radio-group.vue +53 -0
- package/components/wd-rate/index.scss +57 -0
- package/components/wd-rate/types.ts +86 -0
- package/components/wd-rate/wd-rate.vue +168 -0
- package/components/wd-resize/index.scss +31 -0
- package/components/wd-resize/types.ts +14 -0
- package/components/wd-resize/wd-resize.vue +157 -0
- package/components/wd-root-portal/wd-root-portal.vue +77 -0
- package/components/wd-row/index.scss +6 -0
- package/components/wd-row/types.ts +36 -0
- package/components/wd-row/wd-row.vue +88 -0
- package/components/wd-search/index.scss +171 -0
- package/components/wd-search/types.ts +107 -0
- package/components/wd-search/wd-search.vue +198 -0
- package/components/wd-segmented/index.scss +155 -0
- package/components/wd-segmented/types.ts +81 -0
- package/components/wd-segmented/wd-segmented.vue +169 -0
- package/components/wd-select-picker/index.scss +72 -0
- package/components/wd-select-picker/types.ts +72 -0
- package/components/wd-select-picker/wd-select-picker.vue +371 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +34 -0
- package/components/wd-sidebar/wd-sidebar.vue +57 -0
- package/components/wd-sidebar-item/index.scss +91 -0
- package/components/wd-sidebar-item/types.ts +28 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +118 -0
- package/components/wd-signature/index.scss +42 -0
- package/components/wd-signature/types.ts +295 -0
- package/components/wd-signature/wd-signature.vue +664 -0
- package/components/wd-skeleton/index.scss +112 -0
- package/components/wd-skeleton/types.ts +124 -0
- package/components/wd-skeleton/wd-skeleton.vue +110 -0
- package/components/wd-slide-verify/index.scss +112 -0
- package/components/wd-slide-verify/types.ts +98 -0
- package/components/wd-slide-verify/wd-slide-verify.vue +222 -0
- package/components/wd-slider/index.scss +485 -0
- package/components/wd-slider/types.ts +166 -0
- package/components/wd-slider/wd-slider.vue +529 -0
- package/components/wd-sort-button/index.scss +126 -0
- package/components/wd-sort-button/types.ts +68 -0
- package/components/wd-sort-button/wd-sort-button.vue +67 -0
- package/components/wd-step/index.scss +366 -0
- package/components/wd-step/types.ts +43 -0
- package/components/wd-step/wd-step.vue +181 -0
- package/components/wd-steps/index.scss +7 -0
- package/components/wd-steps/types.ts +50 -0
- package/components/wd-steps/wd-steps.vue +39 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +192 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +157 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +87 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +320 -0
- package/components/wd-swiper/index.scss +69 -0
- package/components/wd-swiper/types.ts +275 -0
- package/components/wd-swiper/wd-swiper.vue +332 -0
- package/components/wd-swiper-nav/index.scss +179 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +42 -0
- package/components/wd-switch/index.scss +177 -0
- package/components/wd-switch/types.ts +93 -0
- package/components/wd-switch/wd-switch.vue +107 -0
- package/components/wd-tab/index.scss +16 -0
- package/components/wd-tab/types.ts +45 -0
- package/components/wd-tab/wd-tab.vue +99 -0
- package/components/wd-tabbar/index.scss +71 -0
- package/components/wd-tabbar/types.ts +79 -0
- package/components/wd-tabbar/wd-tabbar.vue +109 -0
- package/components/wd-tabbar-item/index.scss +50 -0
- package/components/wd-tabbar-item/types.ts +45 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +128 -0
- package/components/wd-table/types.ts +160 -0
- package/components/wd-table/wd-table.vue +331 -0
- package/components/wd-table-column/index.scss +15 -0
- package/components/wd-table-column/types.ts +81 -0
- package/components/wd-table-column/wd-table-column.vue +198 -0
- package/components/wd-tabs/index.scss +332 -0
- package/components/wd-tabs/types.ts +155 -0
- package/components/wd-tabs/wd-tabs.vue +508 -0
- package/components/wd-tag/index.scss +325 -0
- package/components/wd-tag/types.ts +90 -0
- package/components/wd-tag/wd-tag.vue +158 -0
- package/components/wd-text/index.scss +52 -0
- package/components/wd-text/types.ts +107 -0
- package/components/wd-text/wd-text.vue +141 -0
- package/components/wd-textarea/index.scss +112 -0
- package/components/wd-textarea/types.ts +151 -0
- package/components/wd-textarea/wd-textarea.vue +212 -0
- package/components/wd-toast/index.scss +92 -0
- package/components/wd-toast/index.ts +97 -0
- package/components/wd-toast/types.ts +190 -0
- package/components/wd-toast/wd-toast.vue +158 -0
- package/components/wd-tooltip/index.scss +77 -0
- package/components/wd-tooltip/types.ts +105 -0
- package/components/wd-tooltip/wd-tooltip.vue +169 -0
- package/components/wd-tour/index.scss +106 -0
- package/components/wd-tour/types.ts +268 -0
- package/components/wd-tour/wd-tour.vue +518 -0
- package/components/wd-transition/index.scss +67 -0
- package/components/wd-transition/types.ts +106 -0
- package/components/wd-transition/wd-transition.vue +238 -0
- package/components/wd-upload/index.scss +204 -0
- package/components/wd-upload/types.ts +390 -0
- package/components/wd-upload/wd-upload.vue +565 -0
- package/components/wd-video-preview/index.scss +54 -0
- package/components/wd-video-preview/index.ts +64 -0
- package/components/wd-video-preview/types.ts +66 -0
- package/components/wd-video-preview/wd-video-preview.vue +141 -0
- package/components/wd-watermark/index.scss +21 -0
- package/components/wd-watermark/types.ts +130 -0
- package/components/wd-watermark/wd-watermark.vue +718 -0
- package/components/wot-ui/wot-ui.vue +5 -0
- package/composables/index.ts +12 -0
- package/composables/useCell.ts +34 -0
- package/composables/useChildren.ts +120 -0
- package/composables/useConfigProvider.ts +45 -0
- package/composables/useCountDown.ts +138 -0
- package/composables/useDeviceInfo.ts +136 -0
- package/composables/useLockScroll.ts +37 -0
- package/composables/useParent.ts +51 -0
- package/composables/usePopover.ts +212 -0
- package/composables/useQueue.ts +52 -0
- package/composables/useRaf.ts +37 -0
- package/composables/useTouch.ts +43 -0
- package/composables/useTranslate.ts +12 -0
- package/composables/useUpload.ts +366 -0
- package/global.d.ts +106 -0
- package/index.ts +11 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +150 -0
- package/locale/lang/de-DE.ts +150 -0
- package/locale/lang/en-US.ts +150 -0
- package/locale/lang/es-ES.ts +150 -0
- package/locale/lang/fr-FR.ts +150 -0
- package/locale/lang/ja-JP.ts +150 -0
- package/locale/lang/ko-KR.ts +150 -0
- package/locale/lang/pt-PT.ts +150 -0
- package/locale/lang/ru-RU.ts +150 -0
- package/locale/lang/th-TH.ts +150 -0
- package/locale/lang/tr-TR.ts +155 -0
- package/locale/lang/ug-CN.ts +154 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +154 -0
- package/locale/lang/zh-HK.ts +78 -0
- package/locale/lang/zh-TW.ts +78 -0
- package/package.json +1 -11
- package/styles/iconfont/iconfont.scss +1243 -0
- package/styles/mixin/_config.scss +7 -0
- package/styles/mixin/_function.scss +44 -0
- package/styles/mixin/_mixin.scss +473 -0
- package/styles/theme/base/color.scss +210 -0
- package/styles/theme/base/font.scss +13 -0
- package/styles/theme/base/index.scss +8 -0
- package/styles/theme/base/insets.scss +32 -0
- package/styles/theme/base/number.scss +36 -0
- package/styles/theme/base/opacity.scss +9 -0
- package/styles/theme/base/radius.scss +13 -0
- package/styles/theme/base/stroke.scss +9 -0
- package/styles/theme/base/typography.scss +44 -0
- package/styles/theme/dark.scss +101 -0
- package/styles/theme/index.scss +16 -0
- package/styles/theme/light.scss +101 -0
- package/styles/variable.scss +472 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type PropType, type ExtractPropTypes, type InjectionKey } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, numericProp } from '../../common/props'
|
|
3
|
+
import type { CellLayout, CellSize, CellValueAlign } from '../wd-cell/types'
|
|
4
|
+
|
|
5
|
+
export type CellGroupProvide = {
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* 是否显示边框线
|
|
9
|
+
* 类型: boolean
|
|
10
|
+
*/
|
|
11
|
+
border?: boolean
|
|
12
|
+
/**
|
|
13
|
+
* 是否使内容垂直居中
|
|
14
|
+
* 类型: boolean
|
|
15
|
+
*/
|
|
16
|
+
center?: boolean
|
|
17
|
+
/**
|
|
18
|
+
* 单元格大小
|
|
19
|
+
* 类型: CellSize
|
|
20
|
+
*/
|
|
21
|
+
size?: CellSize
|
|
22
|
+
/**
|
|
23
|
+
* 左侧标题宽度
|
|
24
|
+
* 类型: string | number
|
|
25
|
+
*/
|
|
26
|
+
titleWidth?: string | number
|
|
27
|
+
/**
|
|
28
|
+
* 单元格布局方式
|
|
29
|
+
* 类型: CellLayout
|
|
30
|
+
*/
|
|
31
|
+
layout?: CellLayout
|
|
32
|
+
/**
|
|
33
|
+
* 右侧内容对齐方式
|
|
34
|
+
* 类型: CellValueAlign
|
|
35
|
+
*/
|
|
36
|
+
valueAlign?: CellValueAlign
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const CELL_GROUP_KEY: InjectionKey<CellGroupProvide> = Symbol('wd-cell-group')
|
|
41
|
+
|
|
42
|
+
export const cellGroupProps = {
|
|
43
|
+
...baseProps,
|
|
44
|
+
/**
|
|
45
|
+
* 分组标题
|
|
46
|
+
* 类型: string
|
|
47
|
+
*/
|
|
48
|
+
title: String,
|
|
49
|
+
/**
|
|
50
|
+
* 分组右侧内容
|
|
51
|
+
* 类型: string
|
|
52
|
+
*/
|
|
53
|
+
value: String,
|
|
54
|
+
/**
|
|
55
|
+
* 是否展示外边框
|
|
56
|
+
* 类型: boolean
|
|
57
|
+
* 默认值: false
|
|
58
|
+
*/
|
|
59
|
+
border: makeBooleanProp(false),
|
|
60
|
+
/**
|
|
61
|
+
* 是否展示为圆角卡片风格
|
|
62
|
+
* 类型: boolean
|
|
63
|
+
* 默认值: false
|
|
64
|
+
*/
|
|
65
|
+
insert: makeBooleanProp(false),
|
|
66
|
+
/**
|
|
67
|
+
* 是否使内容垂直居中
|
|
68
|
+
* 类型: boolean
|
|
69
|
+
* 默认值: false
|
|
70
|
+
*/
|
|
71
|
+
center: makeBooleanProp(false),
|
|
72
|
+
/**
|
|
73
|
+
* 单元格大小
|
|
74
|
+
* 类型: CellSize
|
|
75
|
+
* 可选值: 'large'
|
|
76
|
+
*/
|
|
77
|
+
size: String as PropType<CellSize>,
|
|
78
|
+
/**
|
|
79
|
+
* 左侧标题宽度
|
|
80
|
+
* 类型: string | number
|
|
81
|
+
*/
|
|
82
|
+
titleWidth: numericProp,
|
|
83
|
+
/**
|
|
84
|
+
* 单元格布局方式
|
|
85
|
+
* 类型: CellLayout
|
|
86
|
+
* 可选值: 'horizontal' | 'vertical'
|
|
87
|
+
*/
|
|
88
|
+
layout: String as PropType<CellLayout>,
|
|
89
|
+
/**
|
|
90
|
+
* 右侧内容对齐方式
|
|
91
|
+
* 类型: CellValueAlign
|
|
92
|
+
* 可选值: 'left' | 'right' | 'center'
|
|
93
|
+
*/
|
|
94
|
+
valueAlign: String as PropType<CellValueAlign>
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type CellGroupProps = ExtractPropTypes<typeof cellGroupProps>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="['wd-cell-group', border ? 'is-border' : '', customClass, insert ? 'wd-cell-group--insert' : '']" :style="customStyle">
|
|
3
|
+
<view v-if="title || value || $slots.title || $slots.value" class="wd-cell-group__title">
|
|
4
|
+
<!--左侧标题-->
|
|
5
|
+
<view class="wd-cell-group__left">
|
|
6
|
+
<text v-if="!$slots.title">{{ title }}</text>
|
|
7
|
+
<slot v-else name="title"></slot>
|
|
8
|
+
</view>
|
|
9
|
+
<!--右侧标题-->
|
|
10
|
+
<view class="wd-cell-group__right">
|
|
11
|
+
<text v-if="!$slots.value">{{ value }}</text>
|
|
12
|
+
<slot v-else name="value"></slot>
|
|
13
|
+
</view>
|
|
14
|
+
</view>
|
|
15
|
+
<view class="wd-cell-group__body">
|
|
16
|
+
<slot></slot>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
export default {
|
|
23
|
+
name: 'wd-cell-group',
|
|
24
|
+
options: {
|
|
25
|
+
addGlobalClass: true,
|
|
26
|
+
// #ifndef MP-TOUTIAO
|
|
27
|
+
virtualHost: true,
|
|
28
|
+
// #endif
|
|
29
|
+
styleIsolation: 'shared'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script lang="ts" setup>
|
|
35
|
+
import { useChildren } from '../../composables/useChildren'
|
|
36
|
+
import { CELL_GROUP_KEY, cellGroupProps } from './types'
|
|
37
|
+
|
|
38
|
+
const props = defineProps(cellGroupProps)
|
|
39
|
+
|
|
40
|
+
const { linkChildren } = useChildren(CELL_GROUP_KEY)
|
|
41
|
+
|
|
42
|
+
// 向子组件提供共享属性
|
|
43
|
+
linkChildren({ props })
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<style lang="scss">
|
|
47
|
+
@use './index.scss';
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss'as *;
|
|
2
|
+
@use '../../styles/variable.scss'as *;
|
|
3
|
+
|
|
4
|
+
$checkbox-label-margin: var(--wot-checkbox-label-margin, $spacing-tight) !default; // 文字与图标距离
|
|
5
|
+
$checkbox-color-checked: var(--wot-checkbox-color-checked, $primary-6) !default; // 选中颜色
|
|
6
|
+
$checkbox-icon-size: var(--wot-checkbox-icon-size, $n-22) !default; // 图标尺寸
|
|
7
|
+
$checkbox-unchecked-color: var(--wot-checkbox-unchecked-color, $coolgrey-3) !default; // 未选中图标颜色
|
|
8
|
+
$checkbox-label-font-size: var(--wot-checkbox-label-font-size, $typography-body-size-main) !default; // 文字字号
|
|
9
|
+
$checkbox-label-color: var(--wot-checkbox-label-color, $text-main) !default; // 文字颜色
|
|
10
|
+
$checkbox-label-line-height: var(--wot-checkbox-label-line-height, $typography-body-line--height-size-main) !default; // 文字行高
|
|
11
|
+
$checkbox-opacity-disabled: var(--wot-checkbox-opacity-disabled, $opacity-disabled) !default; // 禁用态透明度
|
|
12
|
+
$checkbox-horizontal-margin: var(--wot-checkbox-horizontal-margin, $spacing-zero $spacing-extra-loose $spacing-zero $spacing-zero) !default; // 水平模式多个单选框距离
|
|
13
|
+
$checkbox-button-margin: var(--wot-checkbox-button-margin, $spacing-zero $spacing-extra-loose $spacing-extra-loose $spacing-zero) !default; // 按钮模式多个单选框距离
|
|
14
|
+
$checkbox-button-border-width: var(--wot-checkbox-button-border-width, $stroke-main) !default; // 边框宽度
|
|
15
|
+
$checkbox-button-shape-border-radius: var(--wot-checkbox-button-shape-border-radius, $radius-radius-full) !default; // 按钮模式图标圆角大小
|
|
16
|
+
$checkbox-button-shape-size: var(--wot-checkbox-button-shape-size, $n-26) !default; // 按钮模式图标容器大小
|
|
17
|
+
$checkbox-button-font-size: var(--wot-checkbox-button-font-size, $typography-body-size-main) !default; // 按钮模式字号
|
|
18
|
+
$checkbox-button-line-height: var(--wot-checkbox-button-line-height, $typography-body-line--height-size-main) !default; // 按钮模式行高
|
|
19
|
+
$checkbox-button-bg: var(--wot-checkbox-button-bg, $filled-bottom) !default; // 按钮模式背景颜色
|
|
20
|
+
$checkbox-button-bg-checked: var(--wot-checkbox-button-bg-checked, $filled-oppo) !default; // 按钮模式选中状态背景颜色
|
|
21
|
+
$checkbox-button-icon-size: var(--wot-checkbox-icon-size, $n-10) !default; // 按钮模式图标尺寸
|
|
22
|
+
$checkbox-button-min-width: var(--wot-checkbox-button-min-width, calc(74 * #{$n-1})) !default; // 按钮模式最小宽
|
|
23
|
+
$checkbox-button-max-width: var(--wot-checkbox-button-max-width, calc(148 * #{$n-1})) !default; // 按钮模式最大宽
|
|
24
|
+
$checkbox-button-border-radius: var(--wot-checkbox-button-border-radius, $radius-main) !default; // 按钮圆角大小
|
|
25
|
+
$checkbox-button-padding: var(--wot-checkbox-button-padding, $padding-extra-tight $padding-extra-loose) !default; // 按钮模式内边距
|
|
26
|
+
$checkbox-button-icon-color: var(--wot-checkbox-button-icon-color, $icon-white) !default; // 按钮模式图标颜色
|
|
27
|
+
$checkbox-button-shape-top: var(--wot-checkbox-button-shape-top, calc(-1 * #{$n-11})) !default; // 按钮模式勾角顶部偏移
|
|
28
|
+
$checkbox-button-shape-left: var(--wot-checkbox-button-shape-left, calc(-1 * #{$n-9})) !default; // 按钮模式勾角左侧偏移
|
|
29
|
+
$checkbox-button-shape-right: var(--wot-checkbox-button-shape-right, calc(-1 * #{$n-9})) !default; // 按钮模式勾角右侧偏移
|
|
30
|
+
$checkbox-button-icon-top: var(--wot-checkbox-button-icon-top, calc(13 * #{$n-1})) !default; // 按钮模式图标顶部偏移
|
|
31
|
+
$checkbox-button-icon-right: var(--wot-checkbox-button-icon-right, $n-4) !default; // 按钮模式图标右侧偏移
|
|
32
|
+
$checkbox-button-icon-left: var(--wot-checkbox-button-icon-left, $n-4) !default; // 按钮模式图标左侧偏移
|
|
33
|
+
|
|
34
|
+
@include b(checkbox) {
|
|
35
|
+
position: relative;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
|
|
41
|
+
@include m(horizontal) {
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
justify-content: flex-start;
|
|
44
|
+
vertical-align: middle;
|
|
45
|
+
|
|
46
|
+
&:not(:last-child) {
|
|
47
|
+
margin: $checkbox-horizontal-margin;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@include m(right) {
|
|
52
|
+
.wd-checkbox__label {
|
|
53
|
+
margin-right: $checkbox-label-margin;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@include m(left) {
|
|
58
|
+
flex-direction: row-reverse;
|
|
59
|
+
justify-content: flex-end;
|
|
60
|
+
|
|
61
|
+
.wd-checkbox__label {
|
|
62
|
+
margin-left: $checkbox-label-margin;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@include edeep(icon) {
|
|
67
|
+
font-size: $checkbox-icon-size;
|
|
68
|
+
height: $checkbox-icon-size;
|
|
69
|
+
line-height: $checkbox-icon-size;
|
|
70
|
+
color: $checkbox-unchecked-color;
|
|
71
|
+
transition: all 0.2s;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@include e(label) {
|
|
75
|
+
font-size: $checkbox-label-font-size;
|
|
76
|
+
color: $checkbox-label-color;
|
|
77
|
+
line-height: $checkbox-label-line-height;
|
|
78
|
+
word-break: break-all;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@include e(shape) {
|
|
82
|
+
position: relative;
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@include when(checked) {
|
|
89
|
+
:deep(.wd-checkbox__icon) {
|
|
90
|
+
color: $checkbox-color-checked;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@include when(indeterminate) {
|
|
95
|
+
:deep(.wd-checkbox__icon) {
|
|
96
|
+
color: $checkbox-color-checked;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@include when(button) {
|
|
101
|
+
display: inline-block;
|
|
102
|
+
min-width: $checkbox-button-min-width;
|
|
103
|
+
max-width: $checkbox-button-max-width;
|
|
104
|
+
margin: $checkbox-button-margin;
|
|
105
|
+
border-radius: $checkbox-button-border-radius;
|
|
106
|
+
background: $checkbox-button-bg;
|
|
107
|
+
font-size: $checkbox-button-font-size;
|
|
108
|
+
box-sizing: border-box;
|
|
109
|
+
border: $checkbox-button-border-width solid $checkbox-button-bg;
|
|
110
|
+
|
|
111
|
+
.wd-checkbox__label {
|
|
112
|
+
position: relative;
|
|
113
|
+
padding: $checkbox-button-padding;
|
|
114
|
+
margin: auto;
|
|
115
|
+
text-align: center;
|
|
116
|
+
@include lineEllipsis;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.wd-checkbox__shape {
|
|
120
|
+
position: absolute;
|
|
121
|
+
top: $checkbox-button-shape-top;
|
|
122
|
+
left: $checkbox-button-shape-left;
|
|
123
|
+
width: $checkbox-button-shape-size;
|
|
124
|
+
height: $checkbox-button-shape-size;
|
|
125
|
+
border-radius: $checkbox-button-shape-border-radius;
|
|
126
|
+
background: transparent;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:deep(.wd-checkbox__icon) {
|
|
130
|
+
position: absolute;
|
|
131
|
+
top: $checkbox-button-icon-top;
|
|
132
|
+
right: $checkbox-button-icon-right;
|
|
133
|
+
font-size: $checkbox-button-icon-size;
|
|
134
|
+
line-height: $checkbox-button-icon-size;
|
|
135
|
+
height: $checkbox-button-icon-size;
|
|
136
|
+
color: $checkbox-button-icon-color;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&.wd-checkbox--right {
|
|
140
|
+
.wd-checkbox__shape {
|
|
141
|
+
left: auto;
|
|
142
|
+
right: $checkbox-button-shape-right;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:deep(.wd-checkbox__icon) {
|
|
146
|
+
right: auto;
|
|
147
|
+
left: $checkbox-button-icon-left;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@include when(checked) {
|
|
152
|
+
color: $checkbox-color-checked;
|
|
153
|
+
border-color: currentColor;
|
|
154
|
+
background: $checkbox-button-bg-checked;
|
|
155
|
+
|
|
156
|
+
.wd-checkbox__shape {
|
|
157
|
+
color: $checkbox-color-checked;
|
|
158
|
+
background: currentColor;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@include when(disabled) {
|
|
164
|
+
opacity: $checkbox-opacity-disabled;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps } from '../../common/props'
|
|
3
|
+
import type { RadioDirection, RadioPlacement, RadioType } from '../wd-radio/types'
|
|
4
|
+
|
|
5
|
+
export type CheckboxType = RadioType
|
|
6
|
+
export type CheckboxPlacement = RadioPlacement
|
|
7
|
+
export type CheckboxDirection = RadioDirection
|
|
8
|
+
|
|
9
|
+
export const checkboxProps = {
|
|
10
|
+
...baseProps,
|
|
11
|
+
/**
|
|
12
|
+
* 单选框选中时的值
|
|
13
|
+
* 默认值: false
|
|
14
|
+
*/
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: [String, Number, Boolean],
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
name: {
|
|
20
|
+
type: [String, Number, Boolean],
|
|
21
|
+
default: ''
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* 单选框形状
|
|
25
|
+
* 可选值: circle | square | button | dot
|
|
26
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
27
|
+
*/
|
|
28
|
+
type: {
|
|
29
|
+
type: String as PropType<CheckboxType>
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* 选中的颜色
|
|
33
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
34
|
+
*/
|
|
35
|
+
checkedColor: String,
|
|
36
|
+
/**
|
|
37
|
+
* 未选中时的颜色
|
|
38
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
39
|
+
*/
|
|
40
|
+
uncheckedColor: String,
|
|
41
|
+
/**
|
|
42
|
+
* 禁用
|
|
43
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
44
|
+
*/
|
|
45
|
+
disabled: {
|
|
46
|
+
type: [Boolean, null] as PropType<boolean | null>,
|
|
47
|
+
default: null
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* 是否为不确定状态(样式优先级最高)
|
|
51
|
+
* 默认值: false
|
|
52
|
+
*/
|
|
53
|
+
indeterminate: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* 只读
|
|
59
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
60
|
+
*/
|
|
61
|
+
readonly: {
|
|
62
|
+
type: [Boolean, null] as PropType<boolean | null>,
|
|
63
|
+
default: null
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* 选中值,在 checkbox-group 中使用无效,需同 false-value 一块使用
|
|
67
|
+
* 默认值: true
|
|
68
|
+
*/
|
|
69
|
+
trueValue: {
|
|
70
|
+
type: [String, Number, Boolean],
|
|
71
|
+
default: true
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* 非选中时的值,在 checkbox-group 中使用无效,需同 true-value 一块使用
|
|
75
|
+
* 默认值: false
|
|
76
|
+
*/
|
|
77
|
+
falseValue: {
|
|
78
|
+
type: [String, Number, Boolean],
|
|
79
|
+
default: false
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* 设置大小
|
|
83
|
+
* 可选值: large
|
|
84
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
85
|
+
*/
|
|
86
|
+
size: String,
|
|
87
|
+
/**
|
|
88
|
+
* 文字位置最大宽度
|
|
89
|
+
*/
|
|
90
|
+
maxWidth: String,
|
|
91
|
+
/**
|
|
92
|
+
* 文本位置
|
|
93
|
+
* 可选值: left | right
|
|
94
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
95
|
+
*/
|
|
96
|
+
placement: String as PropType<CheckboxPlacement>,
|
|
97
|
+
/**
|
|
98
|
+
* 布局方向
|
|
99
|
+
* 可选值: horizontal | vertical
|
|
100
|
+
* 默认值: 继承自 wd-checkbox-group
|
|
101
|
+
*/
|
|
102
|
+
direction: String as PropType<CheckboxDirection>,
|
|
103
|
+
/**
|
|
104
|
+
* 自定义label文本类名
|
|
105
|
+
*/
|
|
106
|
+
customLabelClass: String
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type CheckboxProps = ExtractPropTypes<typeof checkboxProps>
|
|
110
|
+
|
|
111
|
+
export type CheckboxExpose = {
|
|
112
|
+
/**
|
|
113
|
+
* 切换当前选中状态
|
|
114
|
+
*/
|
|
115
|
+
toggle: () => void
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type CheckboxInstance = ComponentPublicInstance<CheckboxProps, CheckboxExpose>
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
:class="`wd-checkbox wd-checkbox--${placementValue} ${isButton ? 'is-button' : 'wd-checkbox--' + directionValue} ${
|
|
4
|
+
isChecked ? 'is-checked' : ''
|
|
5
|
+
} ${indeterminate ? 'is-indeterminate' : ''} ${disabledValue ? 'is-disabled' : ''} ${customClass}`"
|
|
6
|
+
:style="customStyle"
|
|
7
|
+
@click="toggle"
|
|
8
|
+
>
|
|
9
|
+
<view :class="`wd-checkbox__label ${customLabelClass || ''}`" v-if="$slots.default">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</view>
|
|
12
|
+
|
|
13
|
+
<template v-if="isButton">
|
|
14
|
+
<slot name="icon" :is-checked="isChecked">
|
|
15
|
+
<view v-if="isChecked" class="wd-checkbox__shape">
|
|
16
|
+
<wd-icon custom-class="wd-checkbox__icon" :custom-style="iconStyle" :name="iconValue"></wd-icon>
|
|
17
|
+
</view>
|
|
18
|
+
</slot>
|
|
19
|
+
</template>
|
|
20
|
+
<view v-else class="wd-checkbox__shape">
|
|
21
|
+
<slot name="icon" :is-checked="isChecked">
|
|
22
|
+
<wd-icon custom-class="wd-checkbox__icon" :custom-style="iconStyle" :name="iconValue"></wd-icon>
|
|
23
|
+
</slot>
|
|
24
|
+
</view>
|
|
25
|
+
</view>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
export default {
|
|
30
|
+
name: 'wd-checkbox',
|
|
31
|
+
options: {
|
|
32
|
+
addGlobalClass: true,
|
|
33
|
+
// #ifndef MP-TOUTIAO
|
|
34
|
+
virtualHost: true,
|
|
35
|
+
// #endif
|
|
36
|
+
styleIsolation: 'shared'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<script lang="ts" setup>
|
|
42
|
+
import wdIcon from '../wd-icon/wd-icon.vue'
|
|
43
|
+
import { computed, getCurrentInstance, onBeforeMount, watch } from 'vue'
|
|
44
|
+
import { useParent } from '../../composables/useParent'
|
|
45
|
+
import { CHECKBOX_GROUP_KEY } from '../wd-checkbox-group/types'
|
|
46
|
+
import { getPropByPath, isDef } from '../../common/util'
|
|
47
|
+
import { checkboxProps, type CheckboxExpose, type CheckboxDirection, type CheckboxPlacement, type CheckboxType } from './types'
|
|
48
|
+
|
|
49
|
+
const props = defineProps(checkboxProps)
|
|
50
|
+
const emit = defineEmits(['change', 'update:modelValue'])
|
|
51
|
+
|
|
52
|
+
defineExpose<CheckboxExpose>({
|
|
53
|
+
toggle
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const { parent: checkboxGroup } = useParent(CHECKBOX_GROUP_KEY)
|
|
57
|
+
const { proxy } = getCurrentInstance() as any
|
|
58
|
+
|
|
59
|
+
const isChecked = computed(() => {
|
|
60
|
+
if (checkboxGroup.value) {
|
|
61
|
+
return checkboxGroup.value.props.modelValue.indexOf(props.name) > -1
|
|
62
|
+
} else {
|
|
63
|
+
return props.modelValue === props.trueValue
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const typeValue = computed(() => {
|
|
68
|
+
return props.type || getPropByPath(checkboxGroup.value, 'props.type') || 'circle'
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const isButton = computed(() => {
|
|
72
|
+
return typeValue.value === 'button'
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const iconValue = computed(() => {
|
|
76
|
+
// indeterminate 状态下,且非 button 类型,使用 minus-circle-fill
|
|
77
|
+
if (props.indeterminate && !isButton.value) {
|
|
78
|
+
return 'minus-circle-fill'
|
|
79
|
+
}
|
|
80
|
+
let icon = ''
|
|
81
|
+
switch (typeValue.value) {
|
|
82
|
+
case 'circle':
|
|
83
|
+
icon = isChecked.value ? 'check-circle-fill' : 'uncheck-circle'
|
|
84
|
+
break
|
|
85
|
+
case 'square':
|
|
86
|
+
icon = isChecked.value ? 'check-square-fill' : 'uncheck-square'
|
|
87
|
+
break
|
|
88
|
+
case 'dot':
|
|
89
|
+
icon = isChecked.value ? 'check-circle-radio-fill' : 'uncheck-circle'
|
|
90
|
+
break
|
|
91
|
+
case 'button':
|
|
92
|
+
icon = isChecked.value ? 'check' : ''
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
return icon
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const checkedColorValue = computed(() => {
|
|
99
|
+
return props.checkedColor || getPropByPath(checkboxGroup.value, 'props.checkedColor')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const uncheckedColorValue = computed(() => {
|
|
103
|
+
return props.uncheckedColor || getPropByPath(checkboxGroup.value, 'props.uncheckedColor')
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const disabledValue = computed(() => {
|
|
107
|
+
if (isDef(props.disabled)) {
|
|
108
|
+
return props.disabled
|
|
109
|
+
}
|
|
110
|
+
if (checkboxGroup.value) {
|
|
111
|
+
const { max, min, modelValue, disabled } = checkboxGroup.value.props
|
|
112
|
+
if ((max && modelValue.length >= max && !isChecked.value) || (min && modelValue.length <= min && isChecked.value) || disabled) {
|
|
113
|
+
return true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return false
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const readonlyValue = computed(() => {
|
|
120
|
+
if (isDef(props.readonly)) {
|
|
121
|
+
return props.readonly
|
|
122
|
+
} else {
|
|
123
|
+
return getPropByPath(checkboxGroup.value, 'props.readonly')
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const directionValue = computed(() => {
|
|
128
|
+
if (isDef(props.direction)) {
|
|
129
|
+
return props.direction
|
|
130
|
+
} else {
|
|
131
|
+
return getPropByPath(checkboxGroup.value, 'props.direction') as CheckboxDirection
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const placementValue = computed<CheckboxPlacement>(() => {
|
|
136
|
+
if (isDef(props.placement)) {
|
|
137
|
+
return props.placement
|
|
138
|
+
} else {
|
|
139
|
+
return getPropByPath(checkboxGroup.value, 'props.placement')
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const iconStyle = computed(() => {
|
|
144
|
+
if (isButton.value) return ''
|
|
145
|
+
if ((isChecked.value || props.indeterminate) && checkedColorValue.value) {
|
|
146
|
+
return `color: ${checkedColorValue.value}`
|
|
147
|
+
}
|
|
148
|
+
if (!isChecked.value && uncheckedColorValue.value) {
|
|
149
|
+
return `color: ${uncheckedColorValue.value}`
|
|
150
|
+
}
|
|
151
|
+
return ''
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
watch(
|
|
155
|
+
() => props.name,
|
|
156
|
+
() => {
|
|
157
|
+
// 组合使用走这个逻辑
|
|
158
|
+
if (checkboxGroup.value) {
|
|
159
|
+
checkName()
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
watch(
|
|
165
|
+
() => props.type,
|
|
166
|
+
(newValue) => {
|
|
167
|
+
const type = ['circle', 'square', 'button', 'dot']
|
|
168
|
+
if (isDef(newValue) && type.indexOf(newValue) === -1) console.error(`type must be one of ${type.toString()}`)
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
onBeforeMount(() => {
|
|
173
|
+
// eslint-disable-next-line quotes
|
|
174
|
+
if (props.modelValue === null && !checkboxGroup.value) console.warn("checkbox's value must be set")
|
|
175
|
+
if (checkboxGroup.value && !props.name) {
|
|
176
|
+
// eslint-disable-next-line quotes
|
|
177
|
+
console.warn("checkbox's name must be set when used in checkbox-group")
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @description 检测checkbox绑定的value是否和其它checkbox的value冲突
|
|
183
|
+
* @param {Object} self 自身
|
|
184
|
+
* @param myName 自己的标识符
|
|
185
|
+
*/
|
|
186
|
+
function checkName() {
|
|
187
|
+
checkboxGroup.value &&
|
|
188
|
+
checkboxGroup.value.children &&
|
|
189
|
+
checkboxGroup.value.children.forEach((child: any) => {
|
|
190
|
+
if (child.$.uid !== proxy.$.uid && child.name === props.name) {
|
|
191
|
+
console.error(`The checkbox's bound value: ${props.name} has been used`)
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @description 点击checkbox的Event handle
|
|
198
|
+
*/
|
|
199
|
+
function toggle() {
|
|
200
|
+
if (disabledValue.value || readonlyValue.value) return
|
|
201
|
+
// 复选框单独使用时点击反选,并且在checkbox上触发change事件
|
|
202
|
+
if (checkboxGroup.value) {
|
|
203
|
+
checkboxGroup.value.changeSelectState(props.name)
|
|
204
|
+
} else {
|
|
205
|
+
const newVal = props.modelValue === props.trueValue ? props.falseValue : props.trueValue
|
|
206
|
+
emit('update:modelValue', newVal)
|
|
207
|
+
emit('change', {
|
|
208
|
+
value: newVal
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
</script>
|
|
213
|
+
|
|
214
|
+
<style lang="scss">
|
|
215
|
+
@use './index.scss';
|
|
216
|
+
</style>
|