@tplc/wot 0.0.1
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/components/common/AbortablePromise.ts +36 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +76 -0
- package/components/common/abstracts/_mixin.scss +339 -0
- package/components/common/abstracts/variable.scss +1346 -0
- package/components/common/base64.ts +30 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +34 -0
- package/components/common/dayjs.ts +157 -0
- package/components/common/event.ts +8 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +751 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +122 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +39 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +193 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +44 -0
- package/components/composables/useTranslate.ts +22 -0
- package/components/wd-action-sheet/index.scss +204 -0
- package/components/wd-action-sheet/types.ts +128 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +174 -0
- package/components/wd-backtop/index.scss +25 -0
- package/components/wd-backtop/types.ts +37 -0
- package/components/wd-backtop/wd-backtop.vue +48 -0
- package/components/wd-badge/index.scss +59 -0
- package/components/wd-badge/types.ts +53 -0
- package/components/wd-badge/wd-badge.vue +69 -0
- package/components/wd-button/index.scss +340 -0
- package/components/wd-button/types.ts +112 -0
- package/components/wd-button/wd-button.vue +176 -0
- package/components/wd-calendar/index.scss +244 -0
- package/components/wd-calendar/types.ts +235 -0
- package/components/wd-calendar/wd-calendar.vue +456 -0
- package/components/wd-calendar-view/index.scss +9 -0
- package/components/wd-calendar-view/month/index.scss +151 -0
- package/components/wd-calendar-view/month/month.vue +391 -0
- package/components/wd-calendar-view/month/types.ts +19 -0
- package/components/wd-calendar-view/monthPanel/index.scss +89 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +388 -0
- package/components/wd-calendar-view/monthPanel/types.ts +48 -0
- package/components/wd-calendar-view/types.ts +134 -0
- package/components/wd-calendar-view/utils.ts +451 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +111 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +19 -0
- package/components/wd-calendar-view/year/year.vue +220 -0
- package/components/wd-calendar-view/yearPanel/index.scss +24 -0
- package/components/wd-calendar-view/yearPanel/types.ts +38 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +140 -0
- package/components/wd-card/index.scss +70 -0
- package/components/wd-card/types.ts +30 -0
- package/components/wd-card/wd-card.vue +40 -0
- package/components/wd-cell/index.scss +189 -0
- package/components/wd-cell/types.ts +96 -0
- package/components/wd-cell/wd-cell.vue +135 -0
- package/components/wd-cell-group/index.scss +55 -0
- package/components/wd-cell-group/types.ts +41 -0
- package/components/wd-cell-group/wd-cell-group.vue +45 -0
- package/components/wd-checkbox/index.scss +285 -0
- package/components/wd-checkbox/types.ts +68 -0
- package/components/wd-checkbox/wd-checkbox.vue +185 -0
- package/components/wd-checkbox-group/index.scss +20 -0
- package/components/wd-checkbox-group/types.ts +59 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +103 -0
- package/components/wd-circle/index.scss +18 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +318 -0
- package/components/wd-col/index.scss +19 -0
- package/components/wd-col/types.ts +15 -0
- package/components/wd-col/wd-col.vue +91 -0
- package/components/wd-col-picker/index.scss +241 -0
- package/components/wd-col-picker/types.ts +170 -0
- package/components/wd-col-picker/wd-col-picker.vue +550 -0
- package/components/wd-collapse/index.scss +55 -0
- package/components/wd-collapse/types.ts +63 -0
- package/components/wd-collapse/wd-collapse.vue +160 -0
- package/components/wd-collapse-item/index.scss +79 -0
- package/components/wd-collapse-item/types.ts +36 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +182 -0
- package/components/wd-config-provider/types.ts +1023 -0
- package/components/wd-config-provider/wd-config-provider.vue +82 -0
- package/components/wd-count-down/index.scss +14 -0
- package/components/wd-count-down/types.ts +41 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +60 -0
- package/components/wd-count-to/index.scss +6 -0
- package/components/wd-count-to/types.ts +110 -0
- package/components/wd-count-to/wd-count-to.vue +134 -0
- package/components/wd-curtain/index.scss +80 -0
- package/components/wd-curtain/types.ts +45 -0
- package/components/wd-curtain/wd-curtain.vue +174 -0
- package/components/wd-datetime-picker/index.scss +243 -0
- package/components/wd-datetime-picker/types.ts +225 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +827 -0
- package/components/wd-datetime-picker-view/index.scss +0 -0
- package/components/wd-datetime-picker-view/types.ts +137 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +514 -0
- package/components/wd-divider/index.scss +32 -0
- package/components/wd-divider/types.ts +12 -0
- package/components/wd-divider/wd-divider.vue +29 -0
- package/components/wd-drop-menu/index.scss +89 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +128 -0
- package/components/wd-drop-menu-item/index.scss +66 -0
- package/components/wd-drop-menu-item/types.ts +78 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +230 -0
- package/components/wd-fab/index.scss +115 -0
- package/components/wd-fab/types.ts +61 -0
- package/components/wd-fab/wd-fab.vue +257 -0
- package/components/wd-form/index.scss +10 -0
- package/components/wd-form/types.ts +93 -0
- package/components/wd-form/wd-form.vue +185 -0
- package/components/wd-form-item/index.scss +17 -0
- package/components/wd-form-item/types.ts +22 -0
- package/components/wd-form-item/wd-form-item.vue +65 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +23 -0
- package/components/wd-gap/wd-gap.vue +39 -0
- package/components/wd-grid/index.scss +9 -0
- package/components/wd-grid/types.ts +54 -0
- package/components/wd-grid/wd-grid.vue +107 -0
- package/components/wd-grid-item/index.scss +137 -0
- package/components/wd-grid-item/types.ts +74 -0
- package/components/wd-grid-item/wd-grid-item.vue +181 -0
- package/components/wd-icon/index.scss +1222 -0
- package/components/wd-icon/types.ts +21 -0
- package/components/wd-icon/wd-icon.vue +53 -0
- package/components/wd-icon/wd-icons.ttf +0 -0
- package/components/wd-img/index.scss +19 -0
- package/components/wd-img/types.ts +53 -0
- package/components/wd-img/wd-img.vue +76 -0
- package/components/wd-img-cropper/index.scss +227 -0
- package/components/wd-img-cropper/types.ts +87 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +659 -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 +57 -0
- package/components/wd-index-bar/index.scss +39 -0
- package/components/wd-index-bar/type.ts +28 -0
- package/components/wd-index-bar/wd-index-bar.vue +158 -0
- package/components/wd-input/index.scss +326 -0
- package/components/wd-input/types.ts +182 -0
- package/components/wd-input/wd-input.vue +327 -0
- package/components/wd-input-number/index.scss +132 -0
- package/components/wd-input-number/types.ts +78 -0
- package/components/wd-input-number/wd-input-number.vue +221 -0
- package/components/wd-loading/index.scss +34 -0
- package/components/wd-loading/types.ts +31 -0
- package/components/wd-loading/wd-loading.vue +90 -0
- package/components/wd-loadmore/index.scss +39 -0
- package/components/wd-loadmore/types.ts +24 -0
- package/components/wd-loadmore/wd-loadmore.vue +53 -0
- package/components/wd-message-box/index.scss +121 -0
- package/components/wd-message-box/index.ts +95 -0
- package/components/wd-message-box/types.ts +116 -0
- package/components/wd-message-box/wd-message-box.vue +326 -0
- package/components/wd-navbar/index.scss +103 -0
- package/components/wd-navbar/types.ts +52 -0
- package/components/wd-navbar/wd-navbar.vue +142 -0
- package/components/wd-navbar-capsule/index.scss +65 -0
- package/components/wd-navbar-capsule/types.ts +0 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +31 -0
- package/components/wd-notice-bar/index.scss +86 -0
- package/components/wd-notice-bar/types.ts +56 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +223 -0
- package/components/wd-notify/index.scss +34 -0
- package/components/wd-notify/index.ts +59 -0
- package/components/wd-notify/types.ts +62 -0
- package/components/wd-notify/wd-notify.vue +83 -0
- package/components/wd-number-keyboard/index.scss +78 -0
- package/components/wd-number-keyboard/key/index.scss +79 -0
- package/components/wd-number-keyboard/key/index.vue +76 -0
- package/components/wd-number-keyboard/key/types.ts +11 -0
- package/components/wd-number-keyboard/types.ts +79 -0
- package/components/wd-number-keyboard/wd-number-keyboard.vue +173 -0
- package/components/wd-overlay/index.scss +17 -0
- package/components/wd-overlay/types.ts +25 -0
- package/components/wd-overlay/wd-overlay.vue +46 -0
- package/components/wd-pagination/index.scss +57 -0
- package/components/wd-pagination/types.ts +41 -0
- package/components/wd-pagination/wd-pagination.vue +121 -0
- package/components/wd-password-input/index.scss +123 -0
- package/components/wd-password-input/types.ts +48 -0
- package/components/wd-password-input/wd-password-input.vue +58 -0
- package/components/wd-picker/index.scss +216 -0
- package/components/wd-picker/types.ts +186 -0
- package/components/wd-picker/wd-picker.vue +409 -0
- package/components/wd-picker-view/index.scss +91 -0
- package/components/wd-picker-view/types.ts +162 -0
- package/components/wd-picker-view/wd-picker-view.vue +361 -0
- package/components/wd-popover/index.scss +123 -0
- package/components/wd-popover/types.ts +69 -0
- package/components/wd-popover/wd-popover.vue +216 -0
- package/components/wd-popup/index.scss +112 -0
- package/components/wd-popup/types.ts +68 -0
- package/components/wd-popup/wd-popup.vue +227 -0
- package/components/wd-progress/index.scss +62 -0
- package/components/wd-progress/types.ts +40 -0
- package/components/wd-progress/wd-progress.vue +201 -0
- package/components/wd-radio/index.scss +300 -0
- package/components/wd-radio/types.ts +42 -0
- package/components/wd-radio/wd-radio.vue +136 -0
- package/components/wd-radio-group/index.scss +23 -0
- package/components/wd-radio-group/types.ts +36 -0
- package/components/wd-radio-group/wd-radio-group.vue +54 -0
- package/components/wd-rate/index.scss +24 -0
- package/components/wd-rate/types.ts +91 -0
- package/components/wd-rate/wd-rate.vue +131 -0
- package/components/wd-resize/index.scss +26 -0
- package/components/wd-resize/types.ts +6 -0
- package/components/wd-resize/wd-resize.vue +155 -0
- package/components/wd-row/index.scss +10 -0
- package/components/wd-row/types.ts +16 -0
- package/components/wd-row/wd-row.vue +63 -0
- package/components/wd-search/index.scss +148 -0
- package/components/wd-search/types.ts +83 -0
- package/components/wd-search/wd-search.vue +237 -0
- package/components/wd-segmented/index.scss +97 -0
- package/components/wd-segmented/types.ts +68 -0
- package/components/wd-segmented/wd-segmented.vue +143 -0
- package/components/wd-select-picker/index.scss +177 -0
- package/components/wd-select-picker/types.ts +116 -0
- package/components/wd-select-picker/wd-select-picker.vue +486 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +28 -0
- package/components/wd-sidebar/wd-sidebar.vue +41 -0
- package/components/wd-sidebar-item/index.scss +93 -0
- package/components/wd-sidebar-item/types.ts +31 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +114 -0
- package/components/wd-skeleton/index.scss +101 -0
- package/components/wd-skeleton/index.ts +1 -0
- package/components/wd-skeleton/types.ts +69 -0
- package/components/wd-skeleton/wd-skeleton.vue +135 -0
- package/components/wd-slider/index.scss +91 -0
- package/components/wd-slider/types.ts +104 -0
- package/components/wd-slider/wd-slider.vue +377 -0
- package/components/wd-sort-button/index.scss +86 -0
- package/components/wd-sort-button/types.ts +43 -0
- package/components/wd-sort-button/wd-sort-button.vue +76 -0
- package/components/wd-status-tip/index.scss +37 -0
- package/components/wd-status-tip/types.ts +59 -0
- package/components/wd-status-tip/wd-status-tip.vue +94 -0
- package/components/wd-step/index.scss +236 -0
- package/components/wd-step/types.ts +33 -0
- package/components/wd-step/wd-step.vue +151 -0
- package/components/wd-steps/index.scss +10 -0
- package/components/wd-steps/types.ts +59 -0
- package/components/wd-steps/wd-steps.vue +37 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +190 -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 +154 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +43 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +307 -0
- package/components/wd-swiper/index.scss +23 -0
- package/components/wd-swiper/types.ts +189 -0
- package/components/wd-swiper/wd-swiper.vue +202 -0
- package/components/wd-swiper-nav/index.scss +153 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +37 -0
- package/components/wd-switch/index.scss +58 -0
- package/components/wd-switch/types.ts +56 -0
- package/components/wd-switch/wd-switch.vue +83 -0
- package/components/wd-tab/index.scss +8 -0
- package/components/wd-tab/types.ts +20 -0
- package/components/wd-tab/wd-tab.vue +100 -0
- package/components/wd-tabbar/index.scss +57 -0
- package/components/wd-tabbar/types.ts +88 -0
- package/components/wd-tabbar/wd-tabbar.vue +104 -0
- package/components/wd-tabbar-item/index.scss +52 -0
- package/components/wd-tabbar-item/types.ts +51 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +132 -0
- package/components/wd-table/types.ts +69 -0
- package/components/wd-table/wd-table.vue +255 -0
- package/components/wd-table-col/index.scss +44 -0
- package/components/wd-table-col/types.ts +54 -0
- package/components/wd-table-col/wd-table-col.vue +149 -0
- package/components/wd-tabs/index.scss +280 -0
- package/components/wd-tabs/types.ts +71 -0
- package/components/wd-tabs/wd-tabs.vue +528 -0
- package/components/wd-tag/index.scss +115 -0
- package/components/wd-tag/types.ts +81 -0
- package/components/wd-tag/wd-tag.vue +154 -0
- package/components/wd-text/index.scss +34 -0
- package/components/wd-text/types.ts +98 -0
- package/components/wd-text/wd-text.vue +138 -0
- package/components/wd-textarea/index.scss +343 -0
- package/components/wd-textarea/types.ts +298 -0
- package/components/wd-textarea/wd-textarea.vue +303 -0
- package/components/wd-toast/index.scss +66 -0
- package/components/wd-toast/index.ts +109 -0
- package/components/wd-toast/types.ts +76 -0
- package/components/wd-toast/wd-toast.vue +212 -0
- package/components/wd-tooltip/index.scss +61 -0
- package/components/wd-tooltip/types.ts +102 -0
- package/components/wd-tooltip/wd-tooltip.vue +167 -0
- package/components/wd-transition/index.scss +91 -0
- package/components/wd-transition/types.ts +89 -0
- package/components/wd-transition/wd-transition.vue +221 -0
- package/components/wd-upload/index.scss +173 -0
- package/components/wd-upload/types.ts +378 -0
- package/components/wd-upload/utils.ts +152 -0
- package/components/wd-upload/wd-upload.vue +737 -0
- package/components/wd-video-preview/index.scss +34 -0
- package/components/wd-video-preview/types.ts +32 -0
- package/components/wd-video-preview/wd-video-preview.vue +76 -0
- package/components/wd-watermark/index.scss +18 -0
- package/components/wd-watermark/types.ts +82 -0
- package/components/wd-watermark/wd-watermark.vue +592 -0
- package/components/wot-design-uni/wot-design-uni.vue +14 -0
- package/global.d.ts +108 -0
- package/index.ts +30 -0
- package/locale/index.ts +41 -0
- package/locale/lang/en-US.ts +128 -0
- package/locale/lang/th-TH.ts +127 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +127 -0
- package/locale/lang/zh-HK.ts +84 -0
- package/locale/lang/zh-TW.ts +84 -0
- package/package.json +20 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
:class="`wd-select-picker ${cell.border.value ? 'is-border' : ''} ${customClass}`"
|
|
4
|
+
:style="customStyle"
|
|
5
|
+
>
|
|
6
|
+
<view class="wd-select-picker__field" @click="open">
|
|
7
|
+
<slot v-if="useDefaultSlot"></slot>
|
|
8
|
+
<view
|
|
9
|
+
v-else
|
|
10
|
+
:class="`wd-select-picker__cell ${disabled && 'is-disabled'} ${readonly && 'is-readonly'} ${alignRight && 'is-align-right'} ${
|
|
11
|
+
error && 'is-error'
|
|
12
|
+
} ${size && 'is-' + size}`"
|
|
13
|
+
>
|
|
14
|
+
<view
|
|
15
|
+
v-if="label || useLabelSlot"
|
|
16
|
+
:class="`wd-select-picker__label ${isRequired && 'is-required'} ${customLabelClass}`"
|
|
17
|
+
:style="labelWidth ? 'min-width:' + labelWidth + ';max-width:' + labelWidth + ';' : ''"
|
|
18
|
+
>
|
|
19
|
+
<block v-if="label">{{ label }}</block>
|
|
20
|
+
<slot v-else name="label"></slot>
|
|
21
|
+
</view>
|
|
22
|
+
<view class="wd-select-picker__body">
|
|
23
|
+
<view class="wd-select-picker__value-wraper">
|
|
24
|
+
<view
|
|
25
|
+
:class="`wd-select-picker__value ${ellipsis && 'is-ellipsis'} ${customValueClass} ${
|
|
26
|
+
showValue ? '' : 'wd-select-picker__value--placeholder'
|
|
27
|
+
}`"
|
|
28
|
+
>
|
|
29
|
+
{{ showValue || placeholder || translate('placeholder') }}
|
|
30
|
+
</view>
|
|
31
|
+
<wd-icon
|
|
32
|
+
v-if="!disabled && !readonly"
|
|
33
|
+
custom-class="wd-select-picker__arrow"
|
|
34
|
+
name="arrow-right"
|
|
35
|
+
/>
|
|
36
|
+
</view>
|
|
37
|
+
|
|
38
|
+
<view v-if="errorMessage" class="wd-select-picker__error-message">
|
|
39
|
+
{{ errorMessage }}
|
|
40
|
+
</view>
|
|
41
|
+
</view>
|
|
42
|
+
</view>
|
|
43
|
+
</view>
|
|
44
|
+
<wd-action-sheet
|
|
45
|
+
v-model="pickerShow"
|
|
46
|
+
:duration="250"
|
|
47
|
+
:title="title || translate('title')"
|
|
48
|
+
:close-on-click-modal="closeOnClickModal"
|
|
49
|
+
:z-index="zIndex"
|
|
50
|
+
:safe-area-inset-bottom="safeAreaInsetBottom"
|
|
51
|
+
@close="close"
|
|
52
|
+
@opened="scrollIntoView ? setScrollIntoView() : ''"
|
|
53
|
+
custom-header-class="wd-select-picker__header"
|
|
54
|
+
>
|
|
55
|
+
<wd-search
|
|
56
|
+
v-if="filterable"
|
|
57
|
+
v-model="filterVal"
|
|
58
|
+
:placeholder="filterPlaceholder || translate('filterPlaceholder')"
|
|
59
|
+
hide-cancel
|
|
60
|
+
placeholder-left
|
|
61
|
+
@change="handleFilterChange"
|
|
62
|
+
/>
|
|
63
|
+
<scroll-view
|
|
64
|
+
:class="`wd-select-picker__wrapper ${filterable ? 'is-filterable' : ''} ${loading ? 'is-loading' : ''} ${customContentClass}`"
|
|
65
|
+
:scroll-y="!loading"
|
|
66
|
+
:scroll-top="scrollTop"
|
|
67
|
+
:scroll-with-animation="true"
|
|
68
|
+
>
|
|
69
|
+
<!-- 多选 -->
|
|
70
|
+
<view v-if="type === 'checkbox' && isArray(selectList)" id="wd-checkbox-group">
|
|
71
|
+
<wd-checkbox-group
|
|
72
|
+
v-model="selectList"
|
|
73
|
+
cell
|
|
74
|
+
:size="selectSize"
|
|
75
|
+
:checked-color="checkedColor"
|
|
76
|
+
:min="min"
|
|
77
|
+
:max="max"
|
|
78
|
+
@change="handleChange"
|
|
79
|
+
>
|
|
80
|
+
<view
|
|
81
|
+
v-for="item in filterColumns"
|
|
82
|
+
:key="item[valueKey]"
|
|
83
|
+
:id="'check' + item[valueKey]"
|
|
84
|
+
>
|
|
85
|
+
<wd-checkbox :modelValue="item[valueKey]" :disabled="item.disabled">
|
|
86
|
+
<block v-if="filterable && filterVal">
|
|
87
|
+
<block v-for="text in item[labelKey]" :key="text.label">
|
|
88
|
+
<text v-if="text.type === 'active'" class="wd-select-picker__text-active">
|
|
89
|
+
{{ text.label }}
|
|
90
|
+
</text>
|
|
91
|
+
<block v-else>{{ text.label }}</block>
|
|
92
|
+
</block>
|
|
93
|
+
</block>
|
|
94
|
+
<block v-else>
|
|
95
|
+
{{ item[labelKey] }}
|
|
96
|
+
</block>
|
|
97
|
+
</wd-checkbox>
|
|
98
|
+
</view>
|
|
99
|
+
</wd-checkbox-group>
|
|
100
|
+
</view>
|
|
101
|
+
<!-- 单选 -->
|
|
102
|
+
<view v-if="type === 'radio' && !isArray(selectList)" id="wd-radio-group">
|
|
103
|
+
<wd-radio-group
|
|
104
|
+
v-model="selectList"
|
|
105
|
+
cell
|
|
106
|
+
:size="selectSize"
|
|
107
|
+
:checked-color="checkedColor"
|
|
108
|
+
@change="handleChange"
|
|
109
|
+
>
|
|
110
|
+
<view
|
|
111
|
+
v-for="(item, index) in filterColumns"
|
|
112
|
+
:key="index"
|
|
113
|
+
:id="'radio' + item[valueKey]"
|
|
114
|
+
>
|
|
115
|
+
<wd-radio :value="item[valueKey]" :disabled="item.disabled">
|
|
116
|
+
<block v-if="filterable && filterVal">
|
|
117
|
+
<block v-for="text in item[labelKey]" :key="text.label">
|
|
118
|
+
<text
|
|
119
|
+
:clsss="`${text.type === 'active' ? 'wd-select-picker__text-active' : ''}`"
|
|
120
|
+
>
|
|
121
|
+
{{ text.label }}
|
|
122
|
+
</text>
|
|
123
|
+
</block>
|
|
124
|
+
</block>
|
|
125
|
+
<block v-else>
|
|
126
|
+
{{ item[labelKey] }}
|
|
127
|
+
</block>
|
|
128
|
+
</wd-radio>
|
|
129
|
+
</view>
|
|
130
|
+
</wd-radio-group>
|
|
131
|
+
</view>
|
|
132
|
+
<view v-if="loading" class="wd-select-picker__loading" @touchmove="noop">
|
|
133
|
+
<wd-loading :color="loadingColor" />
|
|
134
|
+
</view>
|
|
135
|
+
</scroll-view>
|
|
136
|
+
<!-- 确认按钮 -->
|
|
137
|
+
<view v-if="showConfirm" class="wd-select-picker__footer">
|
|
138
|
+
<wd-button block size="large" @click="onConfirm" :disabled="loading">
|
|
139
|
+
{{ confirmButtonText || translate('confirm') }}
|
|
140
|
+
</wd-button>
|
|
141
|
+
</view>
|
|
142
|
+
</wd-action-sheet>
|
|
143
|
+
</view>
|
|
144
|
+
</template>
|
|
145
|
+
<script lang="ts">
|
|
146
|
+
export default {
|
|
147
|
+
name: 'wd-select-picker',
|
|
148
|
+
options: {
|
|
149
|
+
addGlobalClass: true,
|
|
150
|
+
virtualHost: true,
|
|
151
|
+
styleIsolation: 'shared',
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<script lang="ts" setup>
|
|
157
|
+
import { getCurrentInstance, onBeforeMount, ref, watch, nextTick, computed } from 'vue'
|
|
158
|
+
import { useCell } from '../composables/useCell'
|
|
159
|
+
import { getRect, isArray, isDef, isFunction, requestAnimationFrame } from '../common/util'
|
|
160
|
+
import { useParent } from '../composables/useParent'
|
|
161
|
+
import { FORM_KEY, type FormItemRule } from '../wd-form/types'
|
|
162
|
+
import { useTranslate } from '../composables/useTranslate'
|
|
163
|
+
import { selectPickerProps, type SelectPickerExpose } from './types'
|
|
164
|
+
|
|
165
|
+
const { translate } = useTranslate('select-picker')
|
|
166
|
+
|
|
167
|
+
const props = defineProps(selectPickerProps)
|
|
168
|
+
const emit = defineEmits(['change', 'cancel', 'confirm', 'update:modelValue', 'open', 'close'])
|
|
169
|
+
|
|
170
|
+
const pickerShow = ref<boolean>(false)
|
|
171
|
+
const selectList = ref<Array<number | boolean | string> | number | boolean | string>([])
|
|
172
|
+
const isConfirm = ref<boolean>(false)
|
|
173
|
+
const lastSelectList = ref<Array<number | boolean | string> | number | boolean | string>([])
|
|
174
|
+
const filterVal = ref<string>('')
|
|
175
|
+
const filterColumns = ref<Array<Record<string, any>>>([])
|
|
176
|
+
const scrollTop = ref<number | null>(0) // 滚动位置
|
|
177
|
+
const cell = useCell()
|
|
178
|
+
|
|
179
|
+
const showValue = computed(() => {
|
|
180
|
+
const value = valueFormat(props.modelValue)
|
|
181
|
+
let showValueTemp: string = ''
|
|
182
|
+
|
|
183
|
+
if (props.displayFormat) {
|
|
184
|
+
showValueTemp = props.displayFormat(value, props.columns)
|
|
185
|
+
} else {
|
|
186
|
+
const { type, labelKey } = props
|
|
187
|
+
if (type === 'checkbox') {
|
|
188
|
+
const selectedItems = (isArray(value) ? value : []).map((item) => {
|
|
189
|
+
return getSelectedItem(item)
|
|
190
|
+
})
|
|
191
|
+
showValueTemp = selectedItems
|
|
192
|
+
.map((item) => {
|
|
193
|
+
return item[labelKey]
|
|
194
|
+
})
|
|
195
|
+
.join(', ')
|
|
196
|
+
} else if (type === 'radio') {
|
|
197
|
+
const selectedItem = getSelectedItem(value as string | number | boolean)
|
|
198
|
+
showValueTemp = selectedItem[labelKey]
|
|
199
|
+
} else {
|
|
200
|
+
showValueTemp = value as string
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return showValueTemp
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
watch(
|
|
207
|
+
() => props.modelValue,
|
|
208
|
+
(newValue) => {
|
|
209
|
+
if (newValue === selectList.value) return
|
|
210
|
+
selectList.value = valueFormat(newValue)
|
|
211
|
+
lastSelectList.value = valueFormat(newValue)
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
deep: true,
|
|
215
|
+
immediate: true,
|
|
216
|
+
},
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
watch(
|
|
220
|
+
() => props.columns,
|
|
221
|
+
(newValue) => {
|
|
222
|
+
if (props.filterable && filterVal.value) {
|
|
223
|
+
formatFilterColumns(newValue, filterVal.value)
|
|
224
|
+
} else {
|
|
225
|
+
filterColumns.value = newValue
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
deep: true,
|
|
230
|
+
immediate: true,
|
|
231
|
+
},
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
watch(
|
|
235
|
+
() => props.displayFormat,
|
|
236
|
+
(fn) => {
|
|
237
|
+
if (fn && !isFunction(fn)) {
|
|
238
|
+
console.error('The type of displayFormat must be Function')
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
deep: true,
|
|
243
|
+
immediate: true,
|
|
244
|
+
},
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
watch(
|
|
248
|
+
() => props.beforeConfirm,
|
|
249
|
+
(fn) => {
|
|
250
|
+
if (fn && !isFunction(fn)) {
|
|
251
|
+
console.error('The type of beforeConfirm must be Function')
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
deep: true,
|
|
256
|
+
immediate: true,
|
|
257
|
+
},
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
const { parent: form } = useParent(FORM_KEY)
|
|
261
|
+
|
|
262
|
+
// 表单校验错误信息
|
|
263
|
+
const errorMessage = computed(() => {
|
|
264
|
+
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
|
265
|
+
return form.errorMessages[props.prop]
|
|
266
|
+
} else {
|
|
267
|
+
return ''
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
// 是否展示必填
|
|
272
|
+
const isRequired = computed(() => {
|
|
273
|
+
let formRequired = false
|
|
274
|
+
if (form && form.props.rules) {
|
|
275
|
+
const rules = form.props.rules
|
|
276
|
+
for (const key in rules) {
|
|
277
|
+
if (
|
|
278
|
+
Object.prototype.hasOwnProperty.call(rules, key) &&
|
|
279
|
+
key === props.prop &&
|
|
280
|
+
Array.isArray(rules[key])
|
|
281
|
+
) {
|
|
282
|
+
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return props.required || props.rules.some((rule) => rule.required) || formRequired
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
onBeforeMount(() => {
|
|
290
|
+
selectList.value = valueFormat(props.modelValue)
|
|
291
|
+
filterColumns.value = props.columns
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
const { proxy } = getCurrentInstance() as any
|
|
295
|
+
|
|
296
|
+
function setScrollIntoView() {
|
|
297
|
+
let wraperSelector: string = ''
|
|
298
|
+
let selectorPromise: Promise<UniApp.NodeInfo | UniApp.NodeInfo[]>[] = []
|
|
299
|
+
if (isDef(selectList.value) && selectList.value !== '' && !isArray(selectList.value)) {
|
|
300
|
+
wraperSelector = '#wd-radio-group'
|
|
301
|
+
selectorPromise = [getRect(`#radio${selectList.value}`, false, proxy)]
|
|
302
|
+
} else if (isArray(selectList.value) && selectList.value.length > 0) {
|
|
303
|
+
selectList.value.forEach((value) => {
|
|
304
|
+
selectorPromise.push(getRect(`#check${value}`, false, proxy))
|
|
305
|
+
})
|
|
306
|
+
wraperSelector = '#wd-checkbox-group'
|
|
307
|
+
}
|
|
308
|
+
if (wraperSelector) {
|
|
309
|
+
requestAnimationFrame().then(() => {
|
|
310
|
+
requestAnimationFrame().then(() => {
|
|
311
|
+
Promise.all([
|
|
312
|
+
getRect('.wd-select-picker__wrapper', false, proxy),
|
|
313
|
+
getRect(wraperSelector, false, proxy),
|
|
314
|
+
...selectorPromise,
|
|
315
|
+
])
|
|
316
|
+
.then((res: any[]) => {
|
|
317
|
+
if (isDef(res) && isArray(res)) {
|
|
318
|
+
const scrollView = res[0]
|
|
319
|
+
const wraper = res[1]
|
|
320
|
+
const target = res.slice(2) || []
|
|
321
|
+
if (isDef(wraper) && isDef(scrollView)) {
|
|
322
|
+
const index = target.findIndex((item) => {
|
|
323
|
+
return item.top >= scrollView.top && item.bottom <= scrollView.bottom
|
|
324
|
+
})
|
|
325
|
+
if (index < 0) {
|
|
326
|
+
scrollTop.value = -1
|
|
327
|
+
nextTick(() => {
|
|
328
|
+
scrollTop.value = Math.max(
|
|
329
|
+
0,
|
|
330
|
+
target[0].top - wraper.top - scrollView.height / 2,
|
|
331
|
+
)
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
.catch((error) => {
|
|
338
|
+
console.log(error)
|
|
339
|
+
})
|
|
340
|
+
})
|
|
341
|
+
})
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function noop() {}
|
|
346
|
+
|
|
347
|
+
function getSelectedItem(value: string | number | boolean) {
|
|
348
|
+
const { valueKey, labelKey, columns } = props
|
|
349
|
+
|
|
350
|
+
const selecteds = columns.filter((item) => {
|
|
351
|
+
return item[valueKey] === value
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
if (selecteds.length > 0) {
|
|
355
|
+
return selecteds[0]
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return {
|
|
359
|
+
[valueKey]: value,
|
|
360
|
+
[labelKey]: '',
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function valueFormat(value: string | number | boolean | (string | number | boolean)[]) {
|
|
365
|
+
return props.type === 'checkbox' ? (isArray(value) ? value : []) : value
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function handleChange({
|
|
369
|
+
value,
|
|
370
|
+
}: {
|
|
371
|
+
value: string | number | boolean | (string | number | boolean)[]
|
|
372
|
+
}) {
|
|
373
|
+
selectList.value = value
|
|
374
|
+
emit('change', { value })
|
|
375
|
+
if (props.type === 'radio' && !props.showConfirm) {
|
|
376
|
+
onConfirm()
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function close() {
|
|
381
|
+
pickerShow.value = false
|
|
382
|
+
// 未确定选项时,数据还原复位
|
|
383
|
+
if (!isConfirm.value) {
|
|
384
|
+
selectList.value = valueFormat(lastSelectList.value)
|
|
385
|
+
}
|
|
386
|
+
emit('cancel')
|
|
387
|
+
emit('close')
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function open() {
|
|
391
|
+
if (props.disabled || props.readonly) return
|
|
392
|
+
selectList.value = valueFormat(props.modelValue)
|
|
393
|
+
pickerShow.value = true
|
|
394
|
+
isConfirm.value = false
|
|
395
|
+
emit('open')
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function onConfirm() {
|
|
399
|
+
if (props.loading) {
|
|
400
|
+
pickerShow.value = false
|
|
401
|
+
emit('confirm')
|
|
402
|
+
emit('close')
|
|
403
|
+
return
|
|
404
|
+
}
|
|
405
|
+
if (props.beforeConfirm) {
|
|
406
|
+
props.beforeConfirm(selectList.value, (isPass: boolean) => {
|
|
407
|
+
isPass && handleConfirm()
|
|
408
|
+
})
|
|
409
|
+
} else {
|
|
410
|
+
handleConfirm()
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function handleConfirm() {
|
|
415
|
+
isConfirm.value = true
|
|
416
|
+
pickerShow.value = false
|
|
417
|
+
lastSelectList.value = valueFormat(selectList.value)
|
|
418
|
+
let selectedItems: Record<string, any> = {}
|
|
419
|
+
if (props.type === 'checkbox') {
|
|
420
|
+
selectedItems = (isArray(lastSelectList.value) ? lastSelectList.value : []).map((item) => {
|
|
421
|
+
return getSelectedItem(item)
|
|
422
|
+
})
|
|
423
|
+
} else {
|
|
424
|
+
selectedItems = getSelectedItem(lastSelectList.value as string | number | boolean)
|
|
425
|
+
}
|
|
426
|
+
emit('update:modelValue', lastSelectList.value)
|
|
427
|
+
emit('confirm', {
|
|
428
|
+
value: lastSelectList.value,
|
|
429
|
+
selectedItems,
|
|
430
|
+
})
|
|
431
|
+
emit('close')
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function getFilterText(label: string, filterVal: string) {
|
|
435
|
+
const reg = new RegExp(`(${filterVal})`, 'g')
|
|
436
|
+
|
|
437
|
+
return label.split(reg).map((text) => {
|
|
438
|
+
return {
|
|
439
|
+
type: text === filterVal ? 'active' : 'normal',
|
|
440
|
+
label: text,
|
|
441
|
+
}
|
|
442
|
+
})
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function handleFilterChange({ value }: { value: string }) {
|
|
446
|
+
if (value === '') {
|
|
447
|
+
filterColumns.value = []
|
|
448
|
+
filterVal.value = value
|
|
449
|
+
nextTick(() => {
|
|
450
|
+
filterColumns.value = props.columns
|
|
451
|
+
})
|
|
452
|
+
} else {
|
|
453
|
+
filterVal.value = value
|
|
454
|
+
formatFilterColumns(props.columns, value)
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function formatFilterColumns(columns: Record<string, any>[], filterVal: string) {
|
|
459
|
+
const filterColumnsTemp = columns.filter((item) => {
|
|
460
|
+
return item[props.labelKey].indexOf(filterVal) > -1
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
const formatFilterColumns = filterColumnsTemp.map((item) => {
|
|
464
|
+
return {
|
|
465
|
+
...item,
|
|
466
|
+
[props.labelKey]: getFilterText(item[props.labelKey], filterVal),
|
|
467
|
+
}
|
|
468
|
+
})
|
|
469
|
+
filterColumns.value = []
|
|
470
|
+
nextTick(() => {
|
|
471
|
+
filterColumns.value = formatFilterColumns
|
|
472
|
+
})
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const showConfirm = computed(() => {
|
|
476
|
+
return (props.type === 'radio' && props.showConfirm) || props.type === 'checkbox'
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
defineExpose<SelectPickerExpose>({
|
|
480
|
+
close,
|
|
481
|
+
open,
|
|
482
|
+
})
|
|
483
|
+
</script>
|
|
484
|
+
<style lang="scss" scoped>
|
|
485
|
+
@import './index';
|
|
486
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.wot-theme-dark {
|
|
5
|
+
@include b(sidebar) {
|
|
6
|
+
background: $-dark-background;
|
|
7
|
+
@include e(padding) {
|
|
8
|
+
background: $-dark-background2;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@include b(sidebar) {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
width: $-sidebar-width;
|
|
17
|
+
height: $-sidebar-height;
|
|
18
|
+
overflow-y: auto;
|
|
19
|
+
background: $-color-white;
|
|
20
|
+
|
|
21
|
+
@include e(padding) {
|
|
22
|
+
flex: 1 1 auto;
|
|
23
|
+
background: $-sidebar-bg;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2024-01-05 18:03:27
|
|
4
|
+
* @LastEditTime: 2024-03-18 15:52:37
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\components\wd-sidebar\types.ts
|
|
8
|
+
* 记得注释
|
|
9
|
+
*/
|
|
10
|
+
import { type ExtractPropTypes, type InjectionKey } from 'vue'
|
|
11
|
+
import { baseProps, makeNumericProp } from '../common/props'
|
|
12
|
+
|
|
13
|
+
export type SidebarProvide = {
|
|
14
|
+
props: Partial<SidebarProps>
|
|
15
|
+
setChange: (value: number | string, label: string) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const SIDEBAR_KEY: InjectionKey<SidebarProvide> = Symbol('wd-sidebar')
|
|
19
|
+
|
|
20
|
+
export const sidebarProps = {
|
|
21
|
+
...baseProps,
|
|
22
|
+
/**
|
|
23
|
+
* 当前导航项的索引
|
|
24
|
+
*/
|
|
25
|
+
modelValue: makeNumericProp(0),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SidebarProps = ExtractPropTypes<typeof sidebarProps>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`wd-sidebar ${customClass}`" :style="customStyle">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
<view class="wd-sidebar__padding"></view>
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
export default {
|
|
10
|
+
name: 'wd-sidebar',
|
|
11
|
+
options: {
|
|
12
|
+
addGlobalClass: true,
|
|
13
|
+
virtualHost: true,
|
|
14
|
+
styleIsolation: 'shared',
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
import { useChildren } from '../composables/useChildren'
|
|
21
|
+
import { SIDEBAR_KEY, sidebarProps } from './types'
|
|
22
|
+
|
|
23
|
+
const props = defineProps(sidebarProps)
|
|
24
|
+
const emit = defineEmits(['change', 'update:modelValue'])
|
|
25
|
+
|
|
26
|
+
const { linkChildren } = useChildren(SIDEBAR_KEY)
|
|
27
|
+
linkChildren({ props, setChange })
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 子项状态变更
|
|
31
|
+
* @param child 子项
|
|
32
|
+
*/
|
|
33
|
+
function setChange(value: number | string, label: string) {
|
|
34
|
+
emit('update:modelValue', value)
|
|
35
|
+
emit('change', { value, label })
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<style lang="scss" scoped>
|
|
40
|
+
@import './index';
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.wot-theme-dark {
|
|
5
|
+
@include b(sidebar-item) {
|
|
6
|
+
color: $-dark-color;
|
|
7
|
+
background: $-dark-background2;
|
|
8
|
+
|
|
9
|
+
&:active {
|
|
10
|
+
background-color: $-dark-background4;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@include m(active) {
|
|
14
|
+
color: $-sidebar-active-color;
|
|
15
|
+
background: $-dark-background;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@include m(disabled) {
|
|
19
|
+
color: $-dark-color-gray;
|
|
20
|
+
|
|
21
|
+
&:active {
|
|
22
|
+
background-color: $-dark-background2;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@include b(sidebar-item) {
|
|
29
|
+
position: relative;
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
min-height: $-sidebar-item-height;
|
|
35
|
+
padding: 32rpx;
|
|
36
|
+
font-size: $-sidebar-font-size;
|
|
37
|
+
line-height: $-sidebar-item-line-height;
|
|
38
|
+
color: $-sidebar-color;
|
|
39
|
+
white-space: wrap;
|
|
40
|
+
background: $-sidebar-bg;
|
|
41
|
+
|
|
42
|
+
&:active {
|
|
43
|
+
background-color: $-sidebar-hover-bg;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@include m(active) {
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
color: $-sidebar-active-color;
|
|
49
|
+
background: $-sidebar-active-bg;
|
|
50
|
+
|
|
51
|
+
&::before {
|
|
52
|
+
position: absolute;
|
|
53
|
+
top: 50%;
|
|
54
|
+
left: 0;
|
|
55
|
+
width: $-sidebar-active-border-width;
|
|
56
|
+
height: $-sidebar-active-border-height;
|
|
57
|
+
content: '';
|
|
58
|
+
background: $-sidebar-active-color;
|
|
59
|
+
border-radius: $-sidebar-active-border-width;
|
|
60
|
+
transform: translateY(-50%);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:active {
|
|
64
|
+
background-color: transparent;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@include m(prefix) {
|
|
69
|
+
border-bottom-right-radius: $-sidebar-border-radius;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@include m(suffix) {
|
|
73
|
+
border-top-right-radius: $-sidebar-border-radius;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@include m(disabled) {
|
|
77
|
+
color: $-sidebar-disabled-color;
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
|
|
80
|
+
&:active {
|
|
81
|
+
background-color: $-sidebar-bg;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@include edeep(badge) {
|
|
86
|
+
z-index: 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@include edeep(icon) {
|
|
90
|
+
margin-right: 2px;
|
|
91
|
+
font-size: $-sidebar-icon-size;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ExtractPropTypes, Prop, PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeRequiredProp } from '../common/props'
|
|
3
|
+
import type { BadgeProps } from '../wd-badge/types'
|
|
4
|
+
|
|
5
|
+
export const sidebarItemProps = {
|
|
6
|
+
...baseProps,
|
|
7
|
+
/** 当前选项标题 */
|
|
8
|
+
label: makeRequiredProp(String),
|
|
9
|
+
/** 当前选项的值,唯一标识 */
|
|
10
|
+
value: makeRequiredProp([Number, String]),
|
|
11
|
+
/** 徽标显示值 */
|
|
12
|
+
badge: {
|
|
13
|
+
type: [String, Number, null] as PropType<string | number | null>,
|
|
14
|
+
default: null,
|
|
15
|
+
},
|
|
16
|
+
/** 徽标属性,透传给 Badge 组件 */
|
|
17
|
+
badgeProps: Object as PropType<Partial<BadgeProps>>,
|
|
18
|
+
/** 图标 */
|
|
19
|
+
icon: String,
|
|
20
|
+
/** 是否点状徽标 */
|
|
21
|
+
isDot: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: undefined,
|
|
24
|
+
},
|
|
25
|
+
/** 徽标最大值 */
|
|
26
|
+
max: Number,
|
|
27
|
+
/** 是否禁用 */
|
|
28
|
+
disabled: makeBooleanProp(false),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type SidebarItemProps = ExtractPropTypes<typeof sidebarItemProps>
|