@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,114 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
@click="handleClick"
|
|
4
|
+
:class="`wd-sidebar-item ${active ? 'wd-sidebar-item--active' : ''} ${prefix ? 'wd-sidebar-item--prefix' : ''} ${
|
|
5
|
+
suffix ? 'wd-sidebar-item--suffix' : ''
|
|
6
|
+
} ${disabled ? 'wd-sidebar-item--disabled' : ''} ${customClass}`"
|
|
7
|
+
:style="customStyle"
|
|
8
|
+
>
|
|
9
|
+
<slot name="icon"></slot>
|
|
10
|
+
<template v-if="!$slots.icon && icon">
|
|
11
|
+
<wd-icon custom-class="wd-sidebar-item__icon" :name="icon"></wd-icon>
|
|
12
|
+
</template>
|
|
13
|
+
<wd-badge v-bind="customBadgeProps" custom-class="wd-sidebar-item__badge">
|
|
14
|
+
{{ label }}
|
|
15
|
+
</wd-badge>
|
|
16
|
+
</view>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
export default {
|
|
21
|
+
name: 'wd-sidebar-item',
|
|
22
|
+
options: {
|
|
23
|
+
addGlobalClass: true,
|
|
24
|
+
virtualHost: true,
|
|
25
|
+
styleIsolation: 'shared',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script lang="ts" setup>
|
|
31
|
+
import { computed } from 'vue'
|
|
32
|
+
import { useParent } from '../composables/useParent'
|
|
33
|
+
import { SIDEBAR_KEY } from '../wd-sidebar/types'
|
|
34
|
+
import { sidebarItemProps } from './types'
|
|
35
|
+
import type { BadgeProps } from '../wd-badge/types'
|
|
36
|
+
import { deepAssign, isDef, isUndefined, omitBy } from '../common/util'
|
|
37
|
+
|
|
38
|
+
const props = defineProps(sidebarItemProps)
|
|
39
|
+
|
|
40
|
+
const { parent: sidebar } = useParent(SIDEBAR_KEY)
|
|
41
|
+
|
|
42
|
+
const customBadgeProps = computed(() => {
|
|
43
|
+
const badgeProps: Partial<BadgeProps> = deepAssign(
|
|
44
|
+
isDef(props.badgeProps) ? omitBy(props.badgeProps, isUndefined) : {},
|
|
45
|
+
omitBy(
|
|
46
|
+
{
|
|
47
|
+
max: props.max,
|
|
48
|
+
isDot: props.isDot,
|
|
49
|
+
modelValue: props.badge,
|
|
50
|
+
},
|
|
51
|
+
isUndefined,
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
if (!isDef(badgeProps.max)) {
|
|
55
|
+
badgeProps.max = 99
|
|
56
|
+
}
|
|
57
|
+
return badgeProps
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const active = computed(() => {
|
|
61
|
+
let active: boolean = false
|
|
62
|
+
if (sidebar && sidebar.props.modelValue === props.value) {
|
|
63
|
+
active = true
|
|
64
|
+
}
|
|
65
|
+
return active
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const prefix = computed(() => {
|
|
69
|
+
let prefix: boolean = false
|
|
70
|
+
if (sidebar) {
|
|
71
|
+
const activeIndex: number = sidebar.children.findIndex((c: any) => {
|
|
72
|
+
return c.value === sidebar.props.modelValue
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const currentIndex: number = sidebar.children.findIndex((c: any) => {
|
|
76
|
+
return c.value === props.value
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
if (currentIndex === activeIndex - 1) {
|
|
80
|
+
prefix = true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return prefix
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const suffix = computed(() => {
|
|
87
|
+
let suffix: boolean = false
|
|
88
|
+
if (sidebar) {
|
|
89
|
+
const activeIndex: number = sidebar.children.findIndex((c: any) => {
|
|
90
|
+
return c.value === sidebar.props.modelValue
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const currentIndex: number = sidebar.children.findIndex((c: any) => {
|
|
94
|
+
return c.value === props.value
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
if (currentIndex === activeIndex + 1) {
|
|
98
|
+
suffix = true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return suffix
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
function handleClick() {
|
|
105
|
+
if (props.disabled) {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
sidebar && sidebar.setChange(props.value, props.label)
|
|
109
|
+
}
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<style lang="scss" scoped>
|
|
113
|
+
@import './index';
|
|
114
|
+
</style>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.wot-theme-dark {
|
|
5
|
+
@include b(skeleton) {
|
|
6
|
+
@include e(col) {
|
|
7
|
+
background-color: $-dark-background4;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
@include b(skeleton) {
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
|
|
14
|
+
@include e(row) {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
margin-bottom: $-skeleton-row-margin-bottom;
|
|
19
|
+
|
|
20
|
+
&:only-child,
|
|
21
|
+
&:last-child {
|
|
22
|
+
margin-bottom: 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
@include e(col) {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
background-color: $-skeleton-background-color;
|
|
30
|
+
border-radius: $-skeleton-border-radius-text;
|
|
31
|
+
|
|
32
|
+
&:first-child:last-child,
|
|
33
|
+
&:last-child {
|
|
34
|
+
margin-right: 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
@include m(type) {
|
|
38
|
+
&-text {
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: $-skeleton-text-height-default;
|
|
41
|
+
border-radius: $-skeleton-border-radius-text;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&-rect {
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: $-skeleton-rect-height-default;
|
|
47
|
+
border-radius: $-skeleton-border-radius-rect;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&-circle {
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
width: $-skeleton-circle-height-default;
|
|
53
|
+
height: $-skeleton-circle-height-default;
|
|
54
|
+
border-radius: $-skeleton-border-radius-circle;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
@include m(animation) {
|
|
58
|
+
&-gradient {
|
|
59
|
+
position: relative;
|
|
60
|
+
overflow-x: hidden;
|
|
61
|
+
|
|
62
|
+
&::after {
|
|
63
|
+
position: absolute;
|
|
64
|
+
inset: 0;
|
|
65
|
+
content: ' ';
|
|
66
|
+
background: linear-gradient(
|
|
67
|
+
90deg,
|
|
68
|
+
rgba(255, 255, 255, 0),
|
|
69
|
+
$-skeleton-animation-gradient,
|
|
70
|
+
rgba(255, 255, 255, 0)
|
|
71
|
+
);
|
|
72
|
+
animation: wd-skeleton-gradient 1.5s linear 2s infinite;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&-flashed {
|
|
77
|
+
animation: wd-skeleton-flashed 2s linear 2s infinite;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@keyframes wd-skeleton-gradient {
|
|
82
|
+
0% {
|
|
83
|
+
transform: translateX(-100%) skewX(-15deg);
|
|
84
|
+
}
|
|
85
|
+
100% {
|
|
86
|
+
transform: translateX(100%) skewX(-15deg);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
@keyframes wd-skeleton-flashed {
|
|
90
|
+
0% {
|
|
91
|
+
opacity: 1;
|
|
92
|
+
}
|
|
93
|
+
50% {
|
|
94
|
+
background-color: $-skeleton-animation-flashed;
|
|
95
|
+
opacity: 0.3;
|
|
96
|
+
}
|
|
97
|
+
100% {
|
|
98
|
+
opacity: 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SkeletonThemeVars } from './types'
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { PropType, ExtractPropTypes, CSSProperties } from 'vue'
|
|
2
|
+
import { makeArrayProp, makeBooleanProp, makeStringProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
type SkeletonTheme = 'text' | 'avatar' | 'paragraph' | 'image'
|
|
5
|
+
type SkeletonAnimation = 'gradient' | 'flashed'
|
|
6
|
+
export type SkeletonRowColObj = {
|
|
7
|
+
[key: string]: any
|
|
8
|
+
type?: 'rect' | 'circle' | 'text'
|
|
9
|
+
size?: string | number
|
|
10
|
+
width?: string | number
|
|
11
|
+
height?: string | number
|
|
12
|
+
margin?: string | number
|
|
13
|
+
background?: string
|
|
14
|
+
marginLeft?: string | number
|
|
15
|
+
marginRight?: string | number
|
|
16
|
+
borderRadius?: string | number
|
|
17
|
+
backgroundColor?: string
|
|
18
|
+
}
|
|
19
|
+
export type SkeletonRowCol = number | SkeletonRowColObj | Array<SkeletonRowColObj>
|
|
20
|
+
export type SkeletonThemeVars = {
|
|
21
|
+
notifyPadding?: string
|
|
22
|
+
notifyFontSize?: string
|
|
23
|
+
notifyTextColor?: string
|
|
24
|
+
notifyLineHeight?: number | string
|
|
25
|
+
notifyDangerBackground?: string
|
|
26
|
+
notifyPrimaryBackground?: string
|
|
27
|
+
notifySuccessBackground?: string
|
|
28
|
+
notifyWarningBackground?: string
|
|
29
|
+
}
|
|
30
|
+
export const skeletonProps = {
|
|
31
|
+
/**
|
|
32
|
+
* 骨架图风格,有基础、头像组合等两大类
|
|
33
|
+
*/
|
|
34
|
+
theme: makeStringProp<SkeletonTheme>('text'),
|
|
35
|
+
/**
|
|
36
|
+
* 用于设置行列数量、宽度高度、间距等。
|
|
37
|
+
* @example
|
|
38
|
+
* 【示例一】,`[1, 1, 2]` 表示输出三行骨架图,第一行一列,第二行一列,第三行两列。
|
|
39
|
+
* 【示例二】,`[1, 1, { width: '100px' }]` 表示自定义第三行的宽度为 `100px`。
|
|
40
|
+
* 【示例三】,`[1, 2, [{ width, height }, { width, height, marginLeft }]]` 表示第三行有两列,且自定义宽度、高度和间距
|
|
41
|
+
*/
|
|
42
|
+
rowCol: makeArrayProp<SkeletonRowCol>(),
|
|
43
|
+
/**
|
|
44
|
+
* 是否为加载状态,如果是则显示骨架图,如果不是则显示加载完成的内容
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
loading: makeBooleanProp(true),
|
|
48
|
+
/**
|
|
49
|
+
* 动画效果,有「渐变加载动画」和「闪烁加载动画」两种。值为空则表示没有动画
|
|
50
|
+
*/
|
|
51
|
+
animation: {
|
|
52
|
+
type: String as PropType<SkeletonAnimation>,
|
|
53
|
+
default: '',
|
|
54
|
+
},
|
|
55
|
+
// 自定义类名
|
|
56
|
+
customClass: {
|
|
57
|
+
type: [String, Array, Object],
|
|
58
|
+
default: '',
|
|
59
|
+
},
|
|
60
|
+
// 自定义样式
|
|
61
|
+
customStyle: {
|
|
62
|
+
type: Object as PropType<CSSProperties>,
|
|
63
|
+
default() {
|
|
64
|
+
return {}
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type SkeletonProps = ExtractPropTypes<typeof skeletonProps>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2024-03-15 11:36:12
|
|
4
|
+
* @LastEditTime: 2024-04-01 20:24:22
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-skeleton/wd-skeleton.vue
|
|
8
|
+
* 记得注释
|
|
9
|
+
-->
|
|
10
|
+
<template>
|
|
11
|
+
<view :class="`wd-skeleton ${customClass}`" :style="customStyle">
|
|
12
|
+
<view class="wd-skeleton__content" v-if="show">
|
|
13
|
+
<view class="wd-skeleton__row" v-for="(row, index) of parsedRowCols" :key="`row-${index}`">
|
|
14
|
+
<view v-for="(col, idx) of row" :key="`col-${idx}`" :class="col.class" :style="col.style" />
|
|
15
|
+
</view>
|
|
16
|
+
</view>
|
|
17
|
+
<view v-else>
|
|
18
|
+
<slot />
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
</template>
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
export default {
|
|
24
|
+
// #ifdef H5
|
|
25
|
+
name: 'wd-skeleton',
|
|
26
|
+
// #endif
|
|
27
|
+
options: { virtualHost: true, addGlobalClass: true, styleIsolation: 'shared' },
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<script lang="ts" setup>
|
|
32
|
+
import type { CSSProperties } from 'vue'
|
|
33
|
+
import { ref, computed, watch } from 'vue'
|
|
34
|
+
import type { SkeletonRowCol, SkeletonRowColObj } from './types'
|
|
35
|
+
import { skeletonProps } from './types'
|
|
36
|
+
import { isNumber, addUnit } from '../common/util'
|
|
37
|
+
|
|
38
|
+
const themeMap = {
|
|
39
|
+
avatar: [{ type: 'circle', height: '64px', width: '64px' }],
|
|
40
|
+
image: [{ type: 'rect', height: '64px', width: '64px' }],
|
|
41
|
+
text: [
|
|
42
|
+
1,
|
|
43
|
+
[
|
|
44
|
+
{ width: '24%', height: '16px', marginRight: '16px' },
|
|
45
|
+
{ width: '76%', height: '16px' },
|
|
46
|
+
],
|
|
47
|
+
],
|
|
48
|
+
paragraph: [1, 1, 1, { width: '55%' }],
|
|
49
|
+
}
|
|
50
|
+
const props = defineProps(skeletonProps)
|
|
51
|
+
const rowCols = ref<SkeletonRowCol[]>([])
|
|
52
|
+
|
|
53
|
+
const parsedRowCols = computed(() => {
|
|
54
|
+
return rowCols.value.map((item) => {
|
|
55
|
+
if (isNumber(item)) {
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
class: getColItemClass({ type: 'text' }),
|
|
59
|
+
style: {},
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(item)) {
|
|
64
|
+
return item.map((col) => {
|
|
65
|
+
return {
|
|
66
|
+
...col,
|
|
67
|
+
class: getColItemClass(col),
|
|
68
|
+
style: getColItemStyle(col),
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
const nItem = item as SkeletonRowColObj
|
|
73
|
+
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
...nItem,
|
|
77
|
+
class: getColItemClass(nItem),
|
|
78
|
+
style: getColItemStyle(nItem),
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
function getColItemClass(rowCol: SkeletonRowColObj) {
|
|
85
|
+
return [
|
|
86
|
+
'wd-skeleton__col',
|
|
87
|
+
`wd-skeleton--type-${rowCol.type || 'text'}`,
|
|
88
|
+
{ [`wd-skeleton--animation-${props.animation}`]: props.animation },
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
function getColItemStyle(rowCol: SkeletonRowColObj) {
|
|
92
|
+
const style: CSSProperties = {}
|
|
93
|
+
const styleName = [
|
|
94
|
+
'size',
|
|
95
|
+
'width',
|
|
96
|
+
'height',
|
|
97
|
+
'margin',
|
|
98
|
+
'background',
|
|
99
|
+
'marginLeft',
|
|
100
|
+
'marginRight',
|
|
101
|
+
'borderRadius',
|
|
102
|
+
'backgroundColor',
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
for (const name of styleName) {
|
|
106
|
+
if (Object.prototype.hasOwnProperty.call(rowCol, name)) {
|
|
107
|
+
const px = addUnit(rowCol[name])
|
|
108
|
+
|
|
109
|
+
if (name === 'size') {
|
|
110
|
+
style.width = px
|
|
111
|
+
style.height = px
|
|
112
|
+
} else {
|
|
113
|
+
;(style as any)[name] = px
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return style
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
watch(
|
|
121
|
+
() => props.rowCol,
|
|
122
|
+
(rowCol) => {
|
|
123
|
+
rowCols.value = [
|
|
124
|
+
...(Array.isArray(rowCol) && rowCol.length ? props.rowCol : themeMap[props.theme]),
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{ immediate: true },
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
const show = computed(() => props.loading === undefined || props.loading === true)
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<style lang="scss" scoped>
|
|
134
|
+
@import './index';
|
|
135
|
+
</style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.wot-theme-dark {
|
|
5
|
+
@include b(slider) {
|
|
6
|
+
@include e(label-min, label-max) {
|
|
7
|
+
color: $-dark-color;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@include e(label) {
|
|
11
|
+
color: $-dark-color;
|
|
12
|
+
background-color: rgba($color: $-dark-background2, $alpha: 0.5);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@include m(disabled) {
|
|
16
|
+
@include me(label-min, label-max) {
|
|
17
|
+
color: $-dark-color-gray;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@include b(slider) {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-flow: row nowrap;
|
|
26
|
+
align-items: center;
|
|
27
|
+
height: calc($-slider-handle-radius * 3);
|
|
28
|
+
|
|
29
|
+
@include e(label-min, label-max) {
|
|
30
|
+
font-size: $-slider-fs;
|
|
31
|
+
color: $-slider-color;
|
|
32
|
+
}
|
|
33
|
+
@include e(label) {
|
|
34
|
+
position: absolute;
|
|
35
|
+
bottom: calc($-slider-handle-radius * 2 + 8px);
|
|
36
|
+
width: calc($-slider-handle-radius * 2);
|
|
37
|
+
font-size: $-slider-fs;
|
|
38
|
+
line-height: calc($-slider-handle-radius * 2);
|
|
39
|
+
line-height: 1.2;
|
|
40
|
+
color: $-slider-color;
|
|
41
|
+
text-align: center;
|
|
42
|
+
background-color: rgba($color: #fff, $alpha: 0.5);
|
|
43
|
+
border-radius: 100%;
|
|
44
|
+
}
|
|
45
|
+
@include e(bar-wrapper) {
|
|
46
|
+
position: relative;
|
|
47
|
+
flex: 1;
|
|
48
|
+
margin: calc($-slider-handle-radius - $-slider-axie-height / 2) 0;
|
|
49
|
+
background-color: #e5e5e5;
|
|
50
|
+
border-radius: calc($-slider-axie-height / 2);
|
|
51
|
+
}
|
|
52
|
+
@include e(bar) {
|
|
53
|
+
position: relative;
|
|
54
|
+
height: $-slider-axie-height;
|
|
55
|
+
background: $-slider-line-color;
|
|
56
|
+
border-radius: inherit;
|
|
57
|
+
}
|
|
58
|
+
@include e(button-wrapper) {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 0;
|
|
61
|
+
right: 0;
|
|
62
|
+
width: calc($-slider-handle-radius * 2);
|
|
63
|
+
transform: translate3d(-50%, -50%, 0);
|
|
64
|
+
}
|
|
65
|
+
@include e(has-label) {
|
|
66
|
+
padding-top: calc($-slider-fs * 1.2 + 8px);
|
|
67
|
+
}
|
|
68
|
+
@include e(button) {
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
width: calc($-slider-handle-radius * 2);
|
|
71
|
+
height: calc($-slider-handle-radius * 2);
|
|
72
|
+
background: $-slider-handle-bg;
|
|
73
|
+
border: 1px solid $-slider-axie-bg;
|
|
74
|
+
border-radius: 100%;
|
|
75
|
+
box-shadow: 0 2px 4px 0 rgba($color: #9b9b9b, $alpha: 0.5);
|
|
76
|
+
}
|
|
77
|
+
@include e(label-min) {
|
|
78
|
+
margin-right: $-slider-handle-radius + 11px;
|
|
79
|
+
}
|
|
80
|
+
@include e(label-max) {
|
|
81
|
+
margin-left: $-slider-handle-radius + 11px;
|
|
82
|
+
}
|
|
83
|
+
@include m(disabled) {
|
|
84
|
+
@include me(bar) {
|
|
85
|
+
opacity: 0.25;
|
|
86
|
+
}
|
|
87
|
+
@include me(label-min, label-max) {
|
|
88
|
+
color: $-slider-disabled-color;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2024-06-03 23:43:43
|
|
4
|
+
* @LastEditTime: 2024-06-06 22:03:57
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-slider/types.ts
|
|
8
|
+
* 记得注释
|
|
9
|
+
*/
|
|
10
|
+
import type { ComponentPublicInstance, PropType } from 'vue'
|
|
11
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../common/props'
|
|
12
|
+
|
|
13
|
+
export const sliderProps = {
|
|
14
|
+
...baseProps,
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 自定义最小值的样式类名
|
|
18
|
+
* 类型: string
|
|
19
|
+
* 默认值: ''
|
|
20
|
+
*/
|
|
21
|
+
customMinClass: makeStringProp(''),
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 自定义最大值的样式类名
|
|
25
|
+
* 类型: string
|
|
26
|
+
* 默认值: ''
|
|
27
|
+
*/
|
|
28
|
+
customMaxClass: makeStringProp(''),
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 是否隐藏左右的最大最小值
|
|
32
|
+
* 类型: boolean
|
|
33
|
+
* 默认值: false
|
|
34
|
+
*/
|
|
35
|
+
hideMinMax: makeBooleanProp(false),
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 是否隐藏当前滑块值
|
|
39
|
+
* 类型: boolean
|
|
40
|
+
* 默认值: false
|
|
41
|
+
*/
|
|
42
|
+
hideLabel: makeBooleanProp(false),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 是否禁用滑块
|
|
46
|
+
* 类型: boolean
|
|
47
|
+
* 默认值: false
|
|
48
|
+
*/
|
|
49
|
+
disabled: makeBooleanProp(false),
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 进度条未激活的背景颜色
|
|
53
|
+
* 类型: string
|
|
54
|
+
* 默认值: '#e5e5e5'
|
|
55
|
+
*/
|
|
56
|
+
inactiveColor: makeStringProp('#e5e5e5'),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 进度条激活的背景颜色
|
|
60
|
+
* 类型: string
|
|
61
|
+
* 默认值: ''
|
|
62
|
+
*/
|
|
63
|
+
activeColor: makeStringProp(''),
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 滑块的最大值
|
|
67
|
+
* 类型: number
|
|
68
|
+
* 默认值: 100
|
|
69
|
+
*/
|
|
70
|
+
max: makeNumberProp(100),
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 滑块的最小值
|
|
74
|
+
* 类型: number
|
|
75
|
+
* 默认值: 0
|
|
76
|
+
*/
|
|
77
|
+
min: makeNumberProp(0),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 滑块的步进值
|
|
81
|
+
* 类型: number
|
|
82
|
+
* 默认值: 1
|
|
83
|
+
*/
|
|
84
|
+
step: makeNumberProp(1),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 滑块的值,如果为数组,则为双向滑块
|
|
88
|
+
* 类型: number | number[]
|
|
89
|
+
* 默认值: 0
|
|
90
|
+
*/
|
|
91
|
+
modelValue: {
|
|
92
|
+
type: [Number, Array] as PropType<number | number[]>,
|
|
93
|
+
default: 0,
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type SliderExpose = {
|
|
98
|
+
/**
|
|
99
|
+
* 初始化slider宽度
|
|
100
|
+
*/
|
|
101
|
+
initSlider: () => void
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type SliderInstance = ComponentPublicInstance<SliderExpose>
|