oxy-uni-ui 1.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/LICENSE +21 -0
- package/README.md +13 -0
- package/attributes.json +1 -0
- package/components/common/AbortablePromise.ts +28 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +89 -0
- package/components/common/abstracts/_mixin.scss +385 -0
- package/components/common/abstracts/variable.scss +974 -0
- package/components/common/base64.ts +29 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +25 -0
- package/components/common/event.ts +8 -0
- package/components/common/interceptor.ts +43 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +778 -0
- package/components/composables/index.ts +11 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +113 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +37 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +176 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +43 -0
- package/components/composables/useTranslate.ts +12 -0
- package/components/composables/useUpload.ts +364 -0
- package/components/oxy-action-sheet/index.scss +204 -0
- package/components/oxy-action-sheet/oxy-action-sheet.vue +155 -0
- package/components/oxy-action-sheet/types.ts +118 -0
- package/components/oxy-backtop/index.scss +25 -0
- package/components/oxy-backtop/oxy-backtop.vue +45 -0
- package/components/oxy-backtop/types.ts +37 -0
- package/components/oxy-badge/index.scss +63 -0
- package/components/oxy-badge/oxy-badge.vue +61 -0
- package/components/oxy-badge/types.ts +41 -0
- package/components/oxy-button/index.scss +336 -0
- package/components/oxy-button/oxy-button.vue +195 -0
- package/components/oxy-button/types.ts +133 -0
- package/components/oxy-calendar/index.scss +158 -0
- package/components/oxy-calendar/oxy-calendar.vue +451 -0
- package/components/oxy-calendar/types.ts +217 -0
- package/components/oxy-calendar-view/index.scss +0 -0
- package/components/oxy-calendar-view/month/index.scss +162 -0
- package/components/oxy-calendar-view/month/month.vue +389 -0
- package/components/oxy-calendar-view/month/types.ts +20 -0
- package/components/oxy-calendar-view/monthPanel/index.scss +89 -0
- package/components/oxy-calendar-view/monthPanel/month-panel.vue +374 -0
- package/components/oxy-calendar-view/monthPanel/types.ts +48 -0
- package/components/oxy-calendar-view/oxy-calendar-view.vue +111 -0
- package/components/oxy-calendar-view/types.ts +109 -0
- package/components/oxy-calendar-view/utils.ts +429 -0
- package/components/oxy-calendar-view/year/index.scss +153 -0
- package/components/oxy-calendar-view/year/types.ts +20 -0
- package/components/oxy-calendar-view/year/year.vue +202 -0
- package/components/oxy-calendar-view/yearPanel/index.scss +24 -0
- package/components/oxy-calendar-view/yearPanel/types.ts +38 -0
- package/components/oxy-calendar-view/yearPanel/year-panel.vue +135 -0
- package/components/oxy-card/index.scss +71 -0
- package/components/oxy-card/oxy-card.vue +37 -0
- package/components/oxy-card/types.ts +30 -0
- package/components/oxy-cell/index.scss +206 -0
- package/components/oxy-cell/oxy-cell.vue +140 -0
- package/components/oxy-cell/types.ts +111 -0
- package/components/oxy-cell-group/index.scss +56 -0
- package/components/oxy-cell-group/oxy-cell-group.vue +45 -0
- package/components/oxy-cell-group/types.ts +32 -0
- package/components/oxy-checkbox/index.scss +285 -0
- package/components/oxy-checkbox/oxy-checkbox.vue +177 -0
- package/components/oxy-checkbox/types.ts +68 -0
- package/components/oxy-checkbox-group/index.scss +20 -0
- package/components/oxy-checkbox-group/oxy-checkbox-group.vue +100 -0
- package/components/oxy-checkbox-group/types.ts +59 -0
- package/components/oxy-circle/index.scss +18 -0
- package/components/oxy-circle/oxy-circle.vue +296 -0
- package/components/oxy-circle/types.ts +54 -0
- package/components/oxy-col/index.scss +19 -0
- package/components/oxy-col/oxy-col.vue +49 -0
- package/components/oxy-col/types.ts +15 -0
- package/components/oxy-col-picker/index.scss +168 -0
- package/components/oxy-col-picker/oxy-col-picker.vue +498 -0
- package/components/oxy-col-picker/types.ts +166 -0
- package/components/oxy-collapse/index.scss +55 -0
- package/components/oxy-collapse/oxy-collapse.vue +151 -0
- package/components/oxy-collapse/types.ts +58 -0
- package/components/oxy-collapse-item/index.scss +90 -0
- package/components/oxy-collapse-item/oxy-collapse-item.vue +171 -0
- package/components/oxy-collapse-item/types.ts +48 -0
- package/components/oxy-config-provider/oxy-config-provider.vue +73 -0
- package/components/oxy-config-provider/types.ts +1052 -0
- package/components/oxy-count-down/index.scss +15 -0
- package/components/oxy-count-down/oxy-count-down.vue +60 -0
- package/components/oxy-count-down/types.ts +41 -0
- package/components/oxy-count-down/utils.ts +52 -0
- package/components/oxy-count-to/index.scss +7 -0
- package/components/oxy-count-to/oxy-count-to.vue +125 -0
- package/components/oxy-count-to/types.ts +117 -0
- package/components/oxy-curtain/index.scss +85 -0
- package/components/oxy-curtain/oxy-curtain.vue +172 -0
- package/components/oxy-curtain/types.ts +73 -0
- package/components/oxy-datetime-picker/index.scss +164 -0
- package/components/oxy-datetime-picker/oxy-datetime-picker.vue +801 -0
- package/components/oxy-datetime-picker/types.ts +231 -0
- package/components/oxy-datetime-picker-view/oxy-datetime-picker-view.vue +499 -0
- package/components/oxy-datetime-picker-view/types.ts +120 -0
- package/components/oxy-datetime-picker-view/util.ts +30 -0
- package/components/oxy-design-uni/oxy-design-uni.vue +5 -0
- package/components/oxy-divider/index.scss +100 -0
- package/components/oxy-divider/oxy-divider.vue +52 -0
- package/components/oxy-divider/types.ts +35 -0
- package/components/oxy-drop-menu/index.scss +86 -0
- package/components/oxy-drop-menu/oxy-drop-menu.vue +166 -0
- package/components/oxy-drop-menu/types.ts +38 -0
- package/components/oxy-drop-menu-item/index.scss +66 -0
- package/components/oxy-drop-menu-item/oxy-drop-menu-item.vue +221 -0
- package/components/oxy-drop-menu-item/types.ts +94 -0
- package/components/oxy-fab/index.scss +116 -0
- package/components/oxy-fab/oxy-fab.vue +276 -0
- package/components/oxy-fab/types.ts +66 -0
- package/components/oxy-floating-panel/index.scss +64 -0
- package/components/oxy-floating-panel/oxy-floating-panel.vue +140 -0
- package/components/oxy-floating-panel/type.ts +32 -0
- package/components/oxy-form/oxy-form.vue +207 -0
- package/components/oxy-form/types.ts +76 -0
- package/components/oxy-form-item/index.scss +18 -0
- package/components/oxy-form-item/oxy-form-item.vue +56 -0
- package/components/oxy-form-item/types.ts +16 -0
- package/components/oxy-gap/index.scss +9 -0
- package/components/oxy-gap/oxy-gap.vue +36 -0
- package/components/oxy-gap/types.ts +17 -0
- package/components/oxy-grid/index.scss +9 -0
- package/components/oxy-grid/oxy-grid.vue +106 -0
- package/components/oxy-grid/types.ts +50 -0
- package/components/oxy-grid-item/index.scss +148 -0
- package/components/oxy-grid-item/oxy-grid-item.vue +176 -0
- package/components/oxy-grid-item/types.ts +77 -0
- package/components/oxy-icon/index.scss +1230 -0
- package/components/oxy-icon/oxy-icon.vue +53 -0
- package/components/oxy-icon/oxy-icons.ttf +0 -0
- package/components/oxy-icon/types.ts +21 -0
- package/components/oxy-img/index.scss +19 -0
- package/components/oxy-img/oxy-img.vue +81 -0
- package/components/oxy-img/types.ts +61 -0
- package/components/oxy-img-cropper/index.scss +231 -0
- package/components/oxy-img-cropper/oxy-img-cropper.vue +664 -0
- package/components/oxy-img-cropper/types.ts +76 -0
- package/components/oxy-index-anchor/index.scss +35 -0
- package/components/oxy-index-anchor/oxy-index-anchor.vue +55 -0
- package/components/oxy-index-anchor/type.ts +9 -0
- package/components/oxy-index-bar/index.scss +39 -0
- package/components/oxy-index-bar/oxy-index-bar.vue +156 -0
- package/components/oxy-index-bar/type.ts +23 -0
- package/components/oxy-input/index.scss +323 -0
- package/components/oxy-input/oxy-input.vue +300 -0
- package/components/oxy-input/placeholder.scss +21 -0
- package/components/oxy-input/types.ts +189 -0
- package/components/oxy-input-number/index.scss +132 -0
- package/components/oxy-input-number/oxy-input-number.vue +464 -0
- package/components/oxy-input-number/types.ts +101 -0
- package/components/oxy-keyboard/constants.ts +81 -0
- package/components/oxy-keyboard/index.scss +102 -0
- package/components/oxy-keyboard/key/index.scss +79 -0
- package/components/oxy-keyboard/key/index.vue +76 -0
- package/components/oxy-keyboard/key/types.ts +11 -0
- package/components/oxy-keyboard/oxy-keyboard.vue +206 -0
- package/components/oxy-keyboard/types.ts +92 -0
- package/components/oxy-loading/index.scss +37 -0
- package/components/oxy-loading/oxy-loading.vue +90 -0
- package/components/oxy-loading/types.ts +22 -0
- package/components/oxy-loadmore/index.scss +39 -0
- package/components/oxy-loadmore/oxy-loadmore.vue +59 -0
- package/components/oxy-loadmore/types.ts +30 -0
- package/components/oxy-message-box/index.scss +108 -0
- package/components/oxy-message-box/index.ts +87 -0
- package/components/oxy-message-box/oxy-message-box.vue +291 -0
- package/components/oxy-message-box/types.ts +132 -0
- package/components/oxy-navbar/index.scss +93 -0
- package/components/oxy-navbar/oxy-navbar.vue +111 -0
- package/components/oxy-navbar/types.ts +52 -0
- package/components/oxy-navbar-capsule/index.scss +66 -0
- package/components/oxy-navbar-capsule/oxy-navbar-capsule.vue +35 -0
- package/components/oxy-navbar-capsule/types.ts +8 -0
- package/components/oxy-notice-bar/index.scss +68 -0
- package/components/oxy-notice-bar/oxy-notice-bar.vue +266 -0
- package/components/oxy-notice-bar/types.ts +67 -0
- package/components/oxy-notify/index.scss +34 -0
- package/components/oxy-notify/index.ts +61 -0
- package/components/oxy-notify/oxy-notify.vue +85 -0
- package/components/oxy-notify/types.ts +66 -0
- package/components/oxy-number-keyboard/index.scss +78 -0
- package/components/oxy-number-keyboard/key/index.scss +81 -0
- package/components/oxy-number-keyboard/key/index.vue +78 -0
- package/components/oxy-number-keyboard/key/types.ts +11 -0
- package/components/oxy-number-keyboard/oxy-number-keyboard.vue +151 -0
- package/components/oxy-number-keyboard/types.ts +83 -0
- package/components/oxy-overlay/index.scss +17 -0
- package/components/oxy-overlay/oxy-overlay.vue +47 -0
- package/components/oxy-overlay/types.ts +25 -0
- package/components/oxy-pagination/index.scss +57 -0
- package/components/oxy-pagination/oxy-pagination.vue +110 -0
- package/components/oxy-pagination/types.ts +41 -0
- package/components/oxy-password-input/index.scss +124 -0
- package/components/oxy-password-input/oxy-password-input.vue +49 -0
- package/components/oxy-password-input/types.ts +33 -0
- package/components/oxy-picker/index.scss +110 -0
- package/components/oxy-picker/oxy-picker.vue +412 -0
- package/components/oxy-picker/types.ts +189 -0
- package/components/oxy-picker-view/index.scss +92 -0
- package/components/oxy-picker-view/oxy-picker-view.vue +369 -0
- package/components/oxy-picker-view/types.ts +152 -0
- package/components/oxy-popover/index.scss +116 -0
- package/components/oxy-popover/oxy-popover.vue +180 -0
- package/components/oxy-popover/types.ts +69 -0
- package/components/oxy-popup/index.scss +84 -0
- package/components/oxy-popup/oxy-popup.vue +169 -0
- package/components/oxy-popup/types.ts +95 -0
- package/components/oxy-progress/index.scss +68 -0
- package/components/oxy-progress/oxy-progress.vue +197 -0
- package/components/oxy-progress/types.ts +35 -0
- package/components/oxy-radio/index.scss +301 -0
- package/components/oxy-radio/oxy-radio.vue +118 -0
- package/components/oxy-radio/types.ts +42 -0
- package/components/oxy-radio-group/index.scss +23 -0
- package/components/oxy-radio-group/oxy-radio-group.vue +51 -0
- package/components/oxy-radio-group/types.ts +39 -0
- package/components/oxy-rate/index.scss +25 -0
- package/components/oxy-rate/oxy-rate.vue +178 -0
- package/components/oxy-rate/types.ts +103 -0
- package/components/oxy-resize/index.scss +27 -0
- package/components/oxy-resize/oxy-resize.vue +144 -0
- package/components/oxy-resize/types.ts +6 -0
- package/components/oxy-root-portal/oxy-root-portal.vue +50 -0
- package/components/oxy-row/index.scss +10 -0
- package/components/oxy-row/oxy-row.vue +42 -0
- package/components/oxy-row/types.ts +16 -0
- package/components/oxy-search/index.scss +148 -0
- package/components/oxy-search/oxy-search.vue +187 -0
- package/components/oxy-search/types.ts +93 -0
- package/components/oxy-segmented/index.scss +101 -0
- package/components/oxy-segmented/oxy-segmented.vue +143 -0
- package/components/oxy-segmented/types.ts +71 -0
- package/components/oxy-select-picker/index.scss +102 -0
- package/components/oxy-select-picker/oxy-select-picker.vue +432 -0
- package/components/oxy-select-picker/types.ts +123 -0
- package/components/oxy-sidebar/index.scss +25 -0
- package/components/oxy-sidebar/oxy-sidebar.vue +63 -0
- package/components/oxy-sidebar/types.ts +38 -0
- package/components/oxy-sidebar-item/index.scss +97 -0
- package/components/oxy-sidebar-item/oxy-sidebar-item.vue +116 -0
- package/components/oxy-sidebar-item/types.ts +31 -0
- package/components/oxy-signature/index.scss +31 -0
- package/components/oxy-signature/oxy-signature.vue +630 -0
- package/components/oxy-signature/types.ts +108 -0
- package/components/oxy-skeleton/index.scss +96 -0
- package/components/oxy-skeleton/index.ts +1 -0
- package/components/oxy-skeleton/oxy-skeleton.vue +110 -0
- package/components/oxy-skeleton/types.ts +69 -0
- package/components/oxy-slider/index.scss +98 -0
- package/components/oxy-slider/oxy-slider.vue +356 -0
- package/components/oxy-slider/types.ts +138 -0
- package/components/oxy-sort-button/index.scss +89 -0
- package/components/oxy-sort-button/oxy-sort-button.vue +69 -0
- package/components/oxy-sort-button/types.ts +43 -0
- package/components/oxy-status-tip/images/collect.png +0 -0
- package/components/oxy-status-tip/images/content.png +0 -0
- package/components/oxy-status-tip/images/network.png +0 -0
- package/components/oxy-status-tip/images/search.png +0 -0
- package/components/oxy-status-tip/index.scss +37 -0
- package/components/oxy-status-tip/oxy-status-tip.vue +71 -0
- package/components/oxy-status-tip/types.ts +50 -0
- package/components/oxy-step/index.scss +235 -0
- package/components/oxy-step/oxy-step.vue +150 -0
- package/components/oxy-step/types.ts +33 -0
- package/components/oxy-steps/index.scss +10 -0
- package/components/oxy-steps/oxy-steps.vue +28 -0
- package/components/oxy-steps/types.ts +50 -0
- package/components/oxy-sticky/index.scss +9 -0
- package/components/oxy-sticky/oxy-sticky.vue +190 -0
- package/components/oxy-sticky/types.ts +13 -0
- package/components/oxy-sticky-box/index.scss +6 -0
- package/components/oxy-sticky-box/oxy-sticky-box.vue +155 -0
- package/components/oxy-sticky-box/types.ts +11 -0
- package/components/oxy-swipe-action/index.scss +22 -0
- package/components/oxy-swipe-action/oxy-swipe-action.vue +294 -0
- package/components/oxy-swipe-action/types.ts +40 -0
- package/components/oxy-swiper/index.scss +53 -0
- package/components/oxy-swiper/oxy-swiper.vue +318 -0
- package/components/oxy-swiper/types.ts +264 -0
- package/components/oxy-swiper-nav/index.scss +159 -0
- package/components/oxy-swiper-nav/oxy-swiper-nav.vue +37 -0
- package/components/oxy-swiper-nav/types.ts +42 -0
- package/components/oxy-switch/index.scss +58 -0
- package/components/oxy-switch/oxy-switch.vue +83 -0
- package/components/oxy-switch/types.ts +58 -0
- package/components/oxy-tab/index.scss +16 -0
- package/components/oxy-tab/oxy-tab.vue +88 -0
- package/components/oxy-tab/types.ts +30 -0
- package/components/oxy-tabbar/index.scss +62 -0
- package/components/oxy-tabbar/oxy-tabbar.vue +91 -0
- package/components/oxy-tabbar/types.ts +73 -0
- package/components/oxy-tabbar-item/index.scss +55 -0
- package/components/oxy-tabbar-item/oxy-tabbar-item.vue +99 -0
- package/components/oxy-tabbar-item/types.ts +51 -0
- package/components/oxy-table/index.scss +163 -0
- package/components/oxy-table/oxy-table.vue +283 -0
- package/components/oxy-table/types.ts +58 -0
- package/components/oxy-table-col/index.scss +46 -0
- package/components/oxy-table-col/oxy-table-col.vue +149 -0
- package/components/oxy-table-col/types.ts +54 -0
- package/components/oxy-tabs/index.scss +299 -0
- package/components/oxy-tabs/oxy-tabs.vue +443 -0
- package/components/oxy-tabs/types.ts +107 -0
- package/components/oxy-tag/index.scss +115 -0
- package/components/oxy-tag/oxy-tag.vue +148 -0
- package/components/oxy-tag/types.ts +81 -0
- package/components/oxy-text/index.scss +37 -0
- package/components/oxy-text/oxy-text.vue +139 -0
- package/components/oxy-text/types.ts +98 -0
- package/components/oxy-textarea/index.scss +340 -0
- package/components/oxy-textarea/oxy-textarea.vue +296 -0
- package/components/oxy-textarea/placeholder.scss +20 -0
- package/components/oxy-textarea/types.ts +288 -0
- package/components/oxy-toast/index.scss +75 -0
- package/components/oxy-toast/index.ts +92 -0
- package/components/oxy-toast/oxy-toast.vue +198 -0
- package/components/oxy-toast/types.ts +181 -0
- package/components/oxy-tooltip/index.scss +66 -0
- package/components/oxy-tooltip/oxy-tooltip.vue +141 -0
- package/components/oxy-tooltip/types.ts +107 -0
- package/components/oxy-transition/index.scss +95 -0
- package/components/oxy-transition/oxy-transition.vue +232 -0
- package/components/oxy-transition/types.ts +98 -0
- package/components/oxy-upload/index.scss +175 -0
- package/components/oxy-upload/oxy-upload.vue +673 -0
- package/components/oxy-upload/types.ts +391 -0
- package/components/oxy-video-preview/index.scss +34 -0
- package/components/oxy-video-preview/oxy-video-preview.vue +72 -0
- package/components/oxy-video-preview/types.ts +23 -0
- package/components/oxy-watermark/index.scss +18 -0
- package/components/oxy-watermark/oxy-watermark.vue +486 -0
- package/components/oxy-watermark/types.ts +76 -0
- package/dayjs/constant.js +26 -0
- package/dayjs/index.d.ts +430 -0
- package/dayjs/index.js +542 -0
- package/dayjs/locale/en.js +13 -0
- package/dayjs/utils.js +59 -0
- package/global.d.ts +101 -0
- package/index.ts +12 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +133 -0
- package/locale/lang/en-US.ts +133 -0
- package/locale/lang/zh-CN.ts +137 -0
- package/package.json +1 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<template v-if="sticky">
|
|
3
|
+
<oxy-sticky-box>
|
|
4
|
+
<view
|
|
5
|
+
:class="`oxy-tabs ${customClass} ${innerSlidable ? 'is-slide' : ''} ${mapNum < children.length && mapNum !== 0 ? 'is-map' : ''}`"
|
|
6
|
+
:style="customStyle"
|
|
7
|
+
>
|
|
8
|
+
<oxy-sticky :offset-top="offsetTop">
|
|
9
|
+
<view class="oxy-tabs__nav oxy-tabs__nav--sticky">
|
|
10
|
+
<view class="oxy-tabs__nav--wrap">
|
|
11
|
+
<scroll-view :scroll-x="innerSlidable" scroll-with-animation :scroll-left="state.scrollLeft">
|
|
12
|
+
<view class="oxy-tabs__nav-container">
|
|
13
|
+
<view
|
|
14
|
+
@click="handleSelect(index)"
|
|
15
|
+
v-for="(item, index) in children"
|
|
16
|
+
:key="index"
|
|
17
|
+
:class="`oxy-tabs__nav-item ${state.activeIndex === index ? 'is-active' : ''} ${item.disabled ? 'is-disabled' : ''}`"
|
|
18
|
+
:style="state.activeIndex === index ? (color ? 'color:' + color : '') : inactiveColor ? 'color:' + inactiveColor : ''"
|
|
19
|
+
>
|
|
20
|
+
<oxy-badge v-if="item.badgeProps" v-bind="item.badgeProps">
|
|
21
|
+
<text class="oxy-tabs__nav-item-text">{{ item.title }}</text>
|
|
22
|
+
</oxy-badge>
|
|
23
|
+
<text v-else class="oxy-tabs__nav-item-text">{{ item.title }}</text>
|
|
24
|
+
|
|
25
|
+
<view class="oxy-tabs__line oxy-tabs__line--inner" v-if="state.activeIndex === index && state.useInnerLine"></view>
|
|
26
|
+
</view>
|
|
27
|
+
<view class="oxy-tabs__line" :style="state.lineStyle"></view>
|
|
28
|
+
</view>
|
|
29
|
+
</scroll-view>
|
|
30
|
+
</view>
|
|
31
|
+
<view class="oxy-tabs__map" v-if="mapNum < children.length && mapNum !== 0">
|
|
32
|
+
<view :class="`oxy-tabs__map-btn ${state.animating ? 'is-open' : ''}`" @click="toggleMap">
|
|
33
|
+
<view :class="`oxy-tabs__map-arrow ${state.animating ? 'is-open' : ''}`">
|
|
34
|
+
<oxy-icon name="arrow-down" />
|
|
35
|
+
</view>
|
|
36
|
+
</view>
|
|
37
|
+
<view class="oxy-tabs__map-header" :style="`${state.mapShow ? '' : 'display:none;'} ${state.animating ? 'opacity:1;' : ''}`">
|
|
38
|
+
{{ mapTitle || translate('all') }}
|
|
39
|
+
</view>
|
|
40
|
+
<view :class="`oxy-tabs__map-body ${state.animating ? 'is-open' : ''}`" :style="state.mapShow ? '' : 'display:none'">
|
|
41
|
+
<view class="oxy-tabs__map-nav-item" v-for="(item, index) in children" :key="index" @click="handleSelect(index)">
|
|
42
|
+
<view
|
|
43
|
+
:class="`oxy-tabs__map-nav-btn ${state.activeIndex === index ? 'is-active' : ''} ${item.disabled ? 'is-disabled' : ''}`"
|
|
44
|
+
:style="
|
|
45
|
+
state.activeIndex === index
|
|
46
|
+
? color
|
|
47
|
+
? 'color:' + color + ';border-color:' + color
|
|
48
|
+
: ''
|
|
49
|
+
: inactiveColor
|
|
50
|
+
? 'color:' + inactiveColor
|
|
51
|
+
: ''
|
|
52
|
+
"
|
|
53
|
+
>
|
|
54
|
+
{{ item.title }}
|
|
55
|
+
</view>
|
|
56
|
+
</view>
|
|
57
|
+
</view>
|
|
58
|
+
</view>
|
|
59
|
+
</view>
|
|
60
|
+
</oxy-sticky>
|
|
61
|
+
|
|
62
|
+
<view class="oxy-tabs__container" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd" @touchcancel="onTouchEnd">
|
|
63
|
+
<view :class="['oxy-tabs__body', animated ? 'is-animated' : '']" :style="bodyStyle">
|
|
64
|
+
<slot />
|
|
65
|
+
</view>
|
|
66
|
+
</view>
|
|
67
|
+
|
|
68
|
+
<view
|
|
69
|
+
class="oxy-tabs__mask"
|
|
70
|
+
:style="`${state.mapShow ? '' : 'display:none;'} ${state.animating ? 'opacity:1;' : ''}`"
|
|
71
|
+
@click="toggleMap"
|
|
72
|
+
></view>
|
|
73
|
+
</view>
|
|
74
|
+
</oxy-sticky-box>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<template v-else>
|
|
78
|
+
<view :class="`oxy-tabs ${customClass} ${innerSlidable ? 'is-slide' : ''} ${mapNum < children.length && mapNum !== 0 ? 'is-map' : ''}`">
|
|
79
|
+
<view class="oxy-tabs__nav">
|
|
80
|
+
<view class="oxy-tabs__nav--wrap">
|
|
81
|
+
<scroll-view :scroll-x="innerSlidable" scroll-with-animation :scroll-left="state.scrollLeft">
|
|
82
|
+
<view class="oxy-tabs__nav-container">
|
|
83
|
+
<view
|
|
84
|
+
v-for="(item, index) in children"
|
|
85
|
+
@click="handleSelect(index)"
|
|
86
|
+
:key="index"
|
|
87
|
+
:class="`oxy-tabs__nav-item ${state.activeIndex === index ? 'is-active' : ''} ${item.disabled ? 'is-disabled' : ''}`"
|
|
88
|
+
:style="state.activeIndex === index ? (color ? 'color:' + color : '') : inactiveColor ? 'color:' + inactiveColor : ''"
|
|
89
|
+
>
|
|
90
|
+
<oxy-badge custom-class="oxy-tabs__nav-item-badge" v-if="item.badgeProps" v-bind="item.badgeProps">
|
|
91
|
+
<text class="oxy-tabs__nav-item-text">{{ item.title }}</text>
|
|
92
|
+
</oxy-badge>
|
|
93
|
+
<text v-else class="oxy-tabs__nav-item-text">{{ item.title }}</text>
|
|
94
|
+
<view class="oxy-tabs__line oxy-tabs__line--inner" v-if="state.activeIndex === index && state.useInnerLine"></view>
|
|
95
|
+
</view>
|
|
96
|
+
<view class="oxy-tabs__line" :style="state.lineStyle"></view>
|
|
97
|
+
</view>
|
|
98
|
+
</scroll-view>
|
|
99
|
+
</view>
|
|
100
|
+
<view class="oxy-tabs__map" v-if="mapNum < children.length && mapNum !== 0">
|
|
101
|
+
<view class="oxy-tabs__map-btn" @click="toggleMap">
|
|
102
|
+
<view :class="`oxy-tabs__map-arrow ${state.animating ? 'is-open' : ''}`">
|
|
103
|
+
<oxy-icon name="arrow-down" />
|
|
104
|
+
</view>
|
|
105
|
+
</view>
|
|
106
|
+
<view class="oxy-tabs__map-header" :style="`${state.mapShow ? '' : 'display:none;'} ${state.animating ? 'opacity:1;' : ''}`">
|
|
107
|
+
{{ mapTitle || translate('all') }}
|
|
108
|
+
</view>
|
|
109
|
+
<view :class="`oxy-tabs__map-body ${state.animating ? 'is-open' : ''}`" :style="state.mapShow ? '' : 'display:none'">
|
|
110
|
+
<view class="oxy-tabs__map-nav-item" v-for="(item, index) in children" :key="index" @click="handleSelect(index)">
|
|
111
|
+
<view :class="`oxy-tabs__map-nav-btn ${state.activeIndex === index ? 'is-active' : ''} ${item.disabled ? 'is-disabled' : ''}`">
|
|
112
|
+
{{ item.title }}
|
|
113
|
+
</view>
|
|
114
|
+
</view>
|
|
115
|
+
</view>
|
|
116
|
+
</view>
|
|
117
|
+
</view>
|
|
118
|
+
|
|
119
|
+
<view class="oxy-tabs__container" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd" @touchcancel="onTouchEnd">
|
|
120
|
+
<view :class="['oxy-tabs__body', animated ? 'is-animated' : '']" :style="bodyStyle">
|
|
121
|
+
<slot />
|
|
122
|
+
</view>
|
|
123
|
+
</view>
|
|
124
|
+
|
|
125
|
+
<view
|
|
126
|
+
class="oxy-tabs__mask"
|
|
127
|
+
:style="`${state.mapShow ? '' : 'display:none;'} ${state.animating ? 'opacity:1' : ''}`"
|
|
128
|
+
@click="toggleMap"
|
|
129
|
+
></view>
|
|
130
|
+
</view>
|
|
131
|
+
</template>
|
|
132
|
+
</template>
|
|
133
|
+
<script lang="ts">
|
|
134
|
+
export default {
|
|
135
|
+
name: 'oxy-tabs',
|
|
136
|
+
options: {
|
|
137
|
+
addGlobalClass: true,
|
|
138
|
+
virtualHost: true,
|
|
139
|
+
styleIsolation: 'shared'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</script>
|
|
143
|
+
<script lang="ts" setup>
|
|
144
|
+
import OxyIcon from '../oxy-icon/oxy-icon.vue'
|
|
145
|
+
import OxySticky from '../oxy-sticky/oxy-sticky.vue'
|
|
146
|
+
import OxyStickyBox from '../oxy-sticky-box/oxy-sticky-box.vue'
|
|
147
|
+
import { computed, getCurrentInstance, onMounted, watch, nextTick, reactive, type CSSProperties, type ComponentInstance } from 'vue'
|
|
148
|
+
import { addUnit, checkNumRange, debounce, getRect, isDef, isNumber, isString, objToStyle } from '../common/util'
|
|
149
|
+
import { useTouch } from '../composables/useTouch'
|
|
150
|
+
import { TABS_KEY, tabsProps, type TabsExpose } from './types'
|
|
151
|
+
import { useChildren } from '../composables/useChildren'
|
|
152
|
+
import { useTranslate } from '../composables/useTranslate'
|
|
153
|
+
|
|
154
|
+
const $item = '.oxy-tabs__nav-item'
|
|
155
|
+
const $itemText = '.oxy-tabs__nav-item-text'
|
|
156
|
+
const $container = '.oxy-tabs__nav-container'
|
|
157
|
+
|
|
158
|
+
const props = defineProps(tabsProps)
|
|
159
|
+
const emit = defineEmits(['change', 'disabled', 'click', 'update:modelValue'])
|
|
160
|
+
|
|
161
|
+
const { translate } = useTranslate('tabs')
|
|
162
|
+
|
|
163
|
+
const state = reactive({
|
|
164
|
+
activeIndex: 0, // 选中值的索引,默认第一个
|
|
165
|
+
lineStyle: 'display:none;', // 激活项边框线样式
|
|
166
|
+
useInnerLine: false, // 是否使用内部激活项边框线,当外部激活下划线未成功渲染时显示内部定位的
|
|
167
|
+
inited: false, // 是否初始化
|
|
168
|
+
animating: false, // 是否动画中
|
|
169
|
+
mapShow: false, // map的开关
|
|
170
|
+
scrollLeft: 0 // scroll-view偏移量
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const { children, linkChildren } = useChildren(TABS_KEY)
|
|
174
|
+
linkChildren({ state, props })
|
|
175
|
+
|
|
176
|
+
const { proxy } = getCurrentInstance() as any
|
|
177
|
+
|
|
178
|
+
const touch = useTouch()
|
|
179
|
+
|
|
180
|
+
const innerSlidable = computed(() => {
|
|
181
|
+
return props.slidable === 'always' || children.length > props.slidableNum
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const bodyStyle = computed(() => {
|
|
185
|
+
if (!props.animated) {
|
|
186
|
+
return ''
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return objToStyle({
|
|
190
|
+
left: -100 * state.activeIndex + '%',
|
|
191
|
+
'transition-duration': props.duration + 'ms',
|
|
192
|
+
'-webkit-transition-duration': props.duration + 'ms'
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
const getTabName = (tab: ComponentInstance<any>, index: number) => {
|
|
197
|
+
return isDef(tab.name) ? tab.name : index
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 更新激活项
|
|
202
|
+
* @param value 激活值
|
|
203
|
+
* @param init 是否已初始化
|
|
204
|
+
* @param setScroll // 是否设置scroll-view滚动
|
|
205
|
+
*/
|
|
206
|
+
const updateActive = (value: number | string = 0, init: boolean = false, setScroll: boolean = true) => {
|
|
207
|
+
// 没有tab子元素,不执行任何操作
|
|
208
|
+
if (children.length === 0) return
|
|
209
|
+
|
|
210
|
+
value = getActiveIndex(value)
|
|
211
|
+
// 被禁用,不执行任何操作
|
|
212
|
+
if (children[value].disabled) return
|
|
213
|
+
state.activeIndex = value
|
|
214
|
+
if (setScroll) {
|
|
215
|
+
updateLineStyle(init === false)
|
|
216
|
+
scrollIntoView()
|
|
217
|
+
}
|
|
218
|
+
setActiveTab()
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @description 修改选中的tab Index
|
|
223
|
+
* @param {String |Number } value - radio绑定的value或者tab索引,默认值0
|
|
224
|
+
* @param {Boolean } init - 是否伴随初始化操作
|
|
225
|
+
*/
|
|
226
|
+
const setActive = debounce(updateActive, 100, { leading: true })
|
|
227
|
+
|
|
228
|
+
watch(
|
|
229
|
+
() => props.modelValue,
|
|
230
|
+
(newValue) => {
|
|
231
|
+
if (!isNumber(newValue) && !isString(newValue)) {
|
|
232
|
+
console.error('[Oxy ui] error(oxy-tabs): the type of value should be number or string')
|
|
233
|
+
}
|
|
234
|
+
// 保证不为非空字符串,小于0的数字
|
|
235
|
+
if (newValue === '' || !isDef(newValue)) {
|
|
236
|
+
// eslint-disable-next-line quotes
|
|
237
|
+
console.error("[Oxy ui] error(oxy-tabs): tabs's value cannot be '' null or undefined")
|
|
238
|
+
}
|
|
239
|
+
if (typeof newValue === 'number' && newValue < 0) {
|
|
240
|
+
// eslint-disable-next-line quotes
|
|
241
|
+
console.error("[Oxy ui] error(oxy-tabs): tabs's value cannot be less than zero")
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
immediate: true,
|
|
246
|
+
deep: true
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
watch(
|
|
251
|
+
() => props.modelValue,
|
|
252
|
+
(newValue) => {
|
|
253
|
+
const index = getActiveIndex(newValue)
|
|
254
|
+
setActive(newValue, false, index !== state.activeIndex)
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
immediate: false,
|
|
258
|
+
deep: true
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
watch(
|
|
263
|
+
() => children.length,
|
|
264
|
+
() => {
|
|
265
|
+
if (state.inited) {
|
|
266
|
+
nextTick(() => {
|
|
267
|
+
setActive(props.modelValue)
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
watch(
|
|
274
|
+
() => props.slidableNum,
|
|
275
|
+
(newValue) => {
|
|
276
|
+
checkNumRange(newValue, 'slidableNum')
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
watch(
|
|
281
|
+
() => props.mapNum,
|
|
282
|
+
(newValue) => {
|
|
283
|
+
checkNumRange(newValue, 'mapNum')
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
onMounted(() => {
|
|
288
|
+
state.inited = true
|
|
289
|
+
nextTick(() => {
|
|
290
|
+
updateActive(props.modelValue, true)
|
|
291
|
+
state.useInnerLine = true
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
function toggleMap() {
|
|
296
|
+
if (state.mapShow) {
|
|
297
|
+
state.animating = false
|
|
298
|
+
setTimeout(() => {
|
|
299
|
+
state.mapShow = false
|
|
300
|
+
}, 300)
|
|
301
|
+
} else {
|
|
302
|
+
state.mapShow = true
|
|
303
|
+
setTimeout(() => {
|
|
304
|
+
state.animating = true
|
|
305
|
+
}, 100)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* 更新 underline的偏移量
|
|
311
|
+
* @param animation 是否开启动画
|
|
312
|
+
*/
|
|
313
|
+
async function updateLineStyle(animation: boolean = true) {
|
|
314
|
+
if (!state.inited) return
|
|
315
|
+
const { autoLineWidth, lineWidth, lineHeight } = props
|
|
316
|
+
try {
|
|
317
|
+
const lineStyle: CSSProperties = {}
|
|
318
|
+
if (isDef(lineWidth)) {
|
|
319
|
+
lineStyle.width = addUnit(lineWidth)
|
|
320
|
+
} else {
|
|
321
|
+
if (autoLineWidth) {
|
|
322
|
+
const textRects = await getRect($itemText, true, proxy)
|
|
323
|
+
const textWidth = Number(textRects[state.activeIndex].width)
|
|
324
|
+
lineStyle.width = addUnit(textWidth)
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (isDef(lineHeight)) {
|
|
328
|
+
lineStyle.height = addUnit(lineHeight)
|
|
329
|
+
lineStyle.borderRadius = `calc(${addUnit(lineHeight)} / 2)`
|
|
330
|
+
}
|
|
331
|
+
const rects = await getRect($item, true, proxy)
|
|
332
|
+
const rect = rects[state.activeIndex]
|
|
333
|
+
let left = rects.slice(0, state.activeIndex).reduce((prev, curr) => prev + Number(curr.width), 0) + Number(rect.width) / 2
|
|
334
|
+
if (left) {
|
|
335
|
+
lineStyle.transform = `translateX(${left}px) translateX(-50%)`
|
|
336
|
+
if (animation) {
|
|
337
|
+
lineStyle.transition = 'width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);'
|
|
338
|
+
}
|
|
339
|
+
state.useInnerLine = false
|
|
340
|
+
state.lineStyle = objToStyle(lineStyle)
|
|
341
|
+
}
|
|
342
|
+
} catch (error) {
|
|
343
|
+
console.error('[Oxy ui] error(oxy-tabs): update line style failed', error)
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function setActiveTab() {
|
|
348
|
+
if (!state.inited) return
|
|
349
|
+
const name = getTabName(children[state.activeIndex], state.activeIndex)
|
|
350
|
+
if (name !== props.modelValue) {
|
|
351
|
+
emit('change', {
|
|
352
|
+
index: state.activeIndex,
|
|
353
|
+
name: name
|
|
354
|
+
})
|
|
355
|
+
emit('update:modelValue', name)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function scrollIntoView() {
|
|
360
|
+
if (!state.inited) return
|
|
361
|
+
Promise.all([getRect($item, true, proxy), getRect($container, false, proxy)]).then(([navItemsRects, navRect]) => {
|
|
362
|
+
// 选中元素
|
|
363
|
+
const selectItem = navItemsRects[state.activeIndex]
|
|
364
|
+
// 选中元素之前的节点的宽度总和
|
|
365
|
+
const offsetLeft = (navItemsRects as any).slice(0, state.activeIndex).reduce((prev: any, curr: any) => prev + curr.width, 0)
|
|
366
|
+
// scroll-view滑动到selectItem的偏移量
|
|
367
|
+
const left = offsetLeft - ((navRect as any).width - Number(selectItem.width)) / 2
|
|
368
|
+
if (left === state.scrollLeft) {
|
|
369
|
+
state.scrollLeft = left + Math.random() / 10000
|
|
370
|
+
} else {
|
|
371
|
+
state.scrollLeft = left
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* @description 单击tab的处理
|
|
378
|
+
* @param index
|
|
379
|
+
*/
|
|
380
|
+
function handleSelect(index: number) {
|
|
381
|
+
if (index === undefined) return
|
|
382
|
+
const { disabled } = children[index]
|
|
383
|
+
const name = getTabName(children[index], index)
|
|
384
|
+
|
|
385
|
+
if (disabled) {
|
|
386
|
+
emit('disabled', {
|
|
387
|
+
index,
|
|
388
|
+
name
|
|
389
|
+
})
|
|
390
|
+
return
|
|
391
|
+
}
|
|
392
|
+
state.mapShow && toggleMap()
|
|
393
|
+
setActive(index)
|
|
394
|
+
emit('click', {
|
|
395
|
+
index,
|
|
396
|
+
name
|
|
397
|
+
})
|
|
398
|
+
}
|
|
399
|
+
function onTouchStart(event: any) {
|
|
400
|
+
if (!props.swipeable) return
|
|
401
|
+
touch.touchStart(event)
|
|
402
|
+
}
|
|
403
|
+
function onTouchMove(event: any) {
|
|
404
|
+
if (!props.swipeable) return
|
|
405
|
+
touch.touchMove(event)
|
|
406
|
+
}
|
|
407
|
+
function onTouchEnd() {
|
|
408
|
+
if (!props.swipeable) return
|
|
409
|
+
const { direction, deltaX, offsetX } = touch
|
|
410
|
+
const minSwipeDistance = 50
|
|
411
|
+
if (direction.value === 'horizontal' && offsetX.value >= minSwipeDistance) {
|
|
412
|
+
if (deltaX.value > 0 && state.activeIndex !== 0) {
|
|
413
|
+
setActive(state.activeIndex - 1)
|
|
414
|
+
} else if (deltaX.value < 0 && state.activeIndex !== children.length - 1) {
|
|
415
|
+
setActive(state.activeIndex + 1)
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function getActiveIndex(value: number | string) {
|
|
420
|
+
// name代表的索引超过了children长度的边界,自动用0兜底
|
|
421
|
+
if (isNumber(value) && value >= children.length) {
|
|
422
|
+
// eslint-disable-next-line prettier/prettier
|
|
423
|
+
console.error('[Oxy ui] warning(oxy-tabs): the type of tabs\' value is Number shouldn\'t be less than its children')
|
|
424
|
+
value = 0
|
|
425
|
+
}
|
|
426
|
+
// 如果是字符串直接匹配,匹配不到用0兜底
|
|
427
|
+
if (isString(value)) {
|
|
428
|
+
const index = children.findIndex((item) => item.name === value)
|
|
429
|
+
value = index === -1 ? 0 : index
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return value
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
defineExpose<TabsExpose>({
|
|
436
|
+
setActive,
|
|
437
|
+
scrollIntoView,
|
|
438
|
+
updateLineStyle
|
|
439
|
+
})
|
|
440
|
+
</script>
|
|
441
|
+
<style lang="scss" scoped>
|
|
442
|
+
@import './index.scss';
|
|
443
|
+
</style>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type ComponentPublicInstance, type ExtractPropTypes, type InjectionKey } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeNumericProp, makeStringProp, numericProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type TabsProvide = {
|
|
5
|
+
state: {
|
|
6
|
+
activeIndex: number
|
|
7
|
+
lineStyle: string // 激活项边框线样式
|
|
8
|
+
inited: boolean // 是否初始化
|
|
9
|
+
animating: boolean // 是否动画中
|
|
10
|
+
mapShow: boolean // map的开关
|
|
11
|
+
scrollLeft: number // scroll-view偏移量
|
|
12
|
+
}
|
|
13
|
+
props: Partial<TabsProps>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TabsSlidable = 'auto' | 'always'
|
|
17
|
+
|
|
18
|
+
export const TABS_KEY: InjectionKey<TabsProvide> = Symbol('oxy-tabs')
|
|
19
|
+
|
|
20
|
+
export const tabsProps = {
|
|
21
|
+
...baseProps,
|
|
22
|
+
/**
|
|
23
|
+
* 绑定值
|
|
24
|
+
*/
|
|
25
|
+
modelValue: makeNumericProp(0),
|
|
26
|
+
/**
|
|
27
|
+
* 标签数超过阈值可滑动
|
|
28
|
+
*/
|
|
29
|
+
slidableNum: makeNumberProp(6),
|
|
30
|
+
/**
|
|
31
|
+
* 标签数超过阈值显示导航地图
|
|
32
|
+
*/
|
|
33
|
+
mapNum: makeNumberProp(10),
|
|
34
|
+
/**
|
|
35
|
+
* 导航地图的标题
|
|
36
|
+
*/
|
|
37
|
+
mapTitle: String,
|
|
38
|
+
/**
|
|
39
|
+
* 粘性布局
|
|
40
|
+
*/
|
|
41
|
+
sticky: makeBooleanProp(false),
|
|
42
|
+
/**
|
|
43
|
+
* 粘性布局吸顶位置
|
|
44
|
+
*/
|
|
45
|
+
offsetTop: makeNumberProp(0),
|
|
46
|
+
/**
|
|
47
|
+
* 开启手势滑动
|
|
48
|
+
*/
|
|
49
|
+
swipeable: makeBooleanProp(false),
|
|
50
|
+
/**
|
|
51
|
+
* 自动调整底部条宽度,设置了 lineWidth 后无效
|
|
52
|
+
*/
|
|
53
|
+
autoLineWidth: makeBooleanProp(false),
|
|
54
|
+
/**
|
|
55
|
+
* 底部条宽度,单位像素
|
|
56
|
+
*/
|
|
57
|
+
lineWidth: numericProp,
|
|
58
|
+
/**
|
|
59
|
+
* 底部条高度,单位像素
|
|
60
|
+
*/
|
|
61
|
+
lineHeight: numericProp,
|
|
62
|
+
/**
|
|
63
|
+
* 颜色
|
|
64
|
+
*/
|
|
65
|
+
color: makeStringProp(''),
|
|
66
|
+
/**
|
|
67
|
+
* 非活动状态颜色
|
|
68
|
+
*/
|
|
69
|
+
inactiveColor: makeStringProp(''),
|
|
70
|
+
/**
|
|
71
|
+
* 是否开启切换标签内容时的过渡动画
|
|
72
|
+
*/
|
|
73
|
+
animated: makeBooleanProp(false),
|
|
74
|
+
/**
|
|
75
|
+
* 切换动画过渡时间,单位毫秒
|
|
76
|
+
*/
|
|
77
|
+
duration: makeNumberProp(300),
|
|
78
|
+
/**
|
|
79
|
+
* 是否开启滚动导航
|
|
80
|
+
* 可选值:'auto' | 'always'
|
|
81
|
+
* @default auto
|
|
82
|
+
*/
|
|
83
|
+
slidable: makeStringProp<TabsSlidable>('auto')
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type TabsExpose = {
|
|
87
|
+
/**
|
|
88
|
+
* 设置激活项
|
|
89
|
+
* @param value 激活值
|
|
90
|
+
* @param init 是否已初始化
|
|
91
|
+
* @param setScroll 是否设置scroll-view滚动
|
|
92
|
+
*/
|
|
93
|
+
setActive: (value: number | string, init: boolean, setScroll: boolean) => void
|
|
94
|
+
/**
|
|
95
|
+
* 使选中项滚动到可视区域
|
|
96
|
+
*/
|
|
97
|
+
scrollIntoView: () => void
|
|
98
|
+
/**
|
|
99
|
+
* 更新激活项边框线样式
|
|
100
|
+
* @param animation 是否开启动画,默认开启
|
|
101
|
+
*/
|
|
102
|
+
updateLineStyle: (animation?: boolean) => void
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type TabsProps = ExtractPropTypes<typeof tabsProps>
|
|
106
|
+
|
|
107
|
+
export type TabsInstance = ComponentPublicInstance<TabsProps, TabsExpose>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
@mixin tag-type-style ($normalColor, $normalBg) {
|
|
5
|
+
background: $normalBg;
|
|
6
|
+
|
|
7
|
+
@include when(plain) {
|
|
8
|
+
background: transparent;
|
|
9
|
+
color: $normalColor;
|
|
10
|
+
border: 1px solid $normalColor;
|
|
11
|
+
padding: 0 4px;
|
|
12
|
+
}
|
|
13
|
+
@include when(round) {
|
|
14
|
+
line-height: 1.2;
|
|
15
|
+
font-size: $-tag-fs;
|
|
16
|
+
padding: 4px 11px;
|
|
17
|
+
background: transparent;
|
|
18
|
+
color: if($normalColor != $-tag-info-color, $normalColor, $-tag-round-color);
|
|
19
|
+
border: 1px solid if($normalColor != $-tag-info-color, $normalColor, $-tag-round-border-color);
|
|
20
|
+
border-radius: $-tag-round-radius;
|
|
21
|
+
}
|
|
22
|
+
@include when(mark) {
|
|
23
|
+
padding: 1px 6px;
|
|
24
|
+
border-radius: $-tag-mark-radius;
|
|
25
|
+
|
|
26
|
+
@include when(plain) {
|
|
27
|
+
padding: 0 6px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
@include when(active) {
|
|
31
|
+
color: $-tag-primary-color;
|
|
32
|
+
border-color: $-tag-primary-color;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
@include b(tag) {
|
|
36
|
+
font-size: $-tag-small-fs;
|
|
37
|
+
display: inline-block;
|
|
38
|
+
color: $-tag-color;
|
|
39
|
+
padding: 0 3px;
|
|
40
|
+
border-radius: 2px;
|
|
41
|
+
transition: opacity .3s;
|
|
42
|
+
vertical-align: middle;
|
|
43
|
+
line-height: initial;
|
|
44
|
+
|
|
45
|
+
@include when(default) {
|
|
46
|
+
@include tag-type-style($-tag-info-color, $-tag-info-bg);
|
|
47
|
+
}
|
|
48
|
+
@include when(primary) {
|
|
49
|
+
@include tag-type-style($-tag-primary-color, $-tag-primary-bg);
|
|
50
|
+
}
|
|
51
|
+
@include when(danger) {
|
|
52
|
+
@include tag-type-style($-tag-danger-color, $-tag-danger-bg);
|
|
53
|
+
}
|
|
54
|
+
@include when(warning) {
|
|
55
|
+
@include tag-type-style($-tag-warning-color, $-tag-warning-bg);
|
|
56
|
+
}
|
|
57
|
+
@include when(success) {
|
|
58
|
+
@include tag-type-style($-tag-success-color, $-tag-success-bg);
|
|
59
|
+
}
|
|
60
|
+
@include when(icon) {
|
|
61
|
+
font-size: $-tag-fs;
|
|
62
|
+
line-height: 1.2;
|
|
63
|
+
padding: 2px 5px;
|
|
64
|
+
}
|
|
65
|
+
@include when(dynamic) {
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
width: 88px;
|
|
68
|
+
transition: .3s;
|
|
69
|
+
|
|
70
|
+
&:active {
|
|
71
|
+
color: $-tag-primary-color;
|
|
72
|
+
border-color: $-tag-primary-color;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
@include when(dynamic-input) {
|
|
76
|
+
border-color: $-tag-primary-color;
|
|
77
|
+
}
|
|
78
|
+
@include edeep(icon) {
|
|
79
|
+
display: inline-block;
|
|
80
|
+
margin-right: 4px;
|
|
81
|
+
font-size: $-tag-fs;
|
|
82
|
+
line-height: 1.2;
|
|
83
|
+
vertical-align: baseline;
|
|
84
|
+
}
|
|
85
|
+
@include e(text) {
|
|
86
|
+
display: inline-block;
|
|
87
|
+
vertical-align: text-top;
|
|
88
|
+
}
|
|
89
|
+
@include e(add-text) {
|
|
90
|
+
width: 60px;
|
|
91
|
+
height: 14px;
|
|
92
|
+
min-height: 14px;
|
|
93
|
+
display: inline-block;
|
|
94
|
+
font-size: $-tag-fs;
|
|
95
|
+
vertical-align: middle;
|
|
96
|
+
padding: 0;
|
|
97
|
+
}
|
|
98
|
+
@include e(close) {
|
|
99
|
+
display: inline-block;
|
|
100
|
+
margin-left: 24px;
|
|
101
|
+
margin-right: -4px;
|
|
102
|
+
font-size: $-tag-close-size;
|
|
103
|
+
height: 14px;
|
|
104
|
+
line-height: 1.1;
|
|
105
|
+
vertical-align: text-bottom;
|
|
106
|
+
color: $-tag-close-color;
|
|
107
|
+
|
|
108
|
+
&:active {
|
|
109
|
+
color: $-tag-close-active-color;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
@include edeep(add) {
|
|
113
|
+
vertical-align: bottom;
|
|
114
|
+
}
|
|
115
|
+
}
|